Could you advise whether it is possible to directly import Python code into PSIM?

Nasrin90
Nasrin90 New Altair Community Member
edited April 1 in Community Q&A

Description:

I am attempting to implement a controller, originally written in Python, into PSIM. The idea is to use the controller's output to generate reference signals for my converter’s control circuit and run simulations. This controller is intended to function as a higher-level controller.Could you advise whether it is possible to directly import Python code into PSIM? Are there compatibility issues with PSIM’s libraries that I should be aware of, or would it be more effective to rewrite the code in C for implementation?

Product/Topic Name : [PSIM 2024.1 ]

 

Tagged:

Answers

  • NikosDimitrakopoulos
    NikosDimitrakopoulos
    Altair Employee

    Dear @Nasrin90,

    While it is possible to automate PSIM simulations with Python and call PSIM from Python, it is not possible to include Python code inside the simulation to implement control in the same way as the C blocks do.

    I am curious why you would want to do that, since ultimately all embedded control should be in C. Is your MCU programmed with Python? If not, the translation step to C cannot be avoided.


    There are cases where users use AI chats to generate control code with python and then use a converter similar to this one:

    https://www.codeconvert.ai/python-to-c-converter

    To get the C code and work with it inside PSIM with the C blocks.

    Hope this helps!

    BR,

    Nikos

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.