Using External Parameter Files in PSIM

jcm18
jcm18 Altair Community Member

I am trying to automate my runs using Python and with the PsimCmd.exe. I have created the parameter files for my run and have checked that the generated file was working when loaded in the internal parameter file of the schematic. However, the thing is when I run it using python (with PsimCmd.exe) it seems that the parameter file I am passing is not seen. I have confirmed it by passing an invalid variable and expecting to see an error message in python but as I have suspected, the file is not read at all.

Has anybody have done a similar task in psim + python? What is the correct step so that my external file will be seen. I am running more than 100+ test cases so I want to really automate it. Otherwise, do you have any suggestions on how I can go about it? I am using PSIM2024 and Python 3.1

 

Best Answers

  • RSGarciarivas
    RSGarciarivas
    Altair Employee
    edited April 21 Answer ✓

    Hi @jcm18,

    There's a PSIM Python API you can use instead of PsimCmd.exe, you can leverage commands like PsimASimulate.

    Open PSIM and go to Help > Index and type Python in the search bat to get more info on this. There's also a PSIM OML API that you can use from Altair Compose, which I find it's easier to use. Have a look here. Syntax is very similar for both APIs so you can translate the OML example to Python easily. Hope this helps!

    Rafael

  • Ju4n_R0sales
    Ju4n_R0sales
    Altair Employee
    Answer ✓

    Hello @jcm18, Adding to what Rafael said:

    I extended my reply on the support ticket but for anyone else wondering, you can leave the elements in your circuit parametrized, then create a dictionary with the definition of these variables use PsimSimulate and point to the dictionary. Take a look at this section on the Demo_PSimSimulate,py example:

    #use PsimSimulate passing the variables with a dictionary object

    d2 = dict(Simview=0, C = "500u", R = 2.5, Fsw="20k", L=5e-6, TotalTime= 0.02, TimeStep=1E-6)
    d2.update({"Vin": 20})


    res2 = p1.PsimSimulate(str_sample_folder + "buck.psimsch", str_sample_folder + "graphs\\buck1_d.txt", **d2)

    Or you could try modifying the parameter file's text, making sure that you're referencing the correct parameter file.

Answers

  • RSGarciarivas
    RSGarciarivas
    Altair Employee
    edited April 21 Answer ✓

    Hi @jcm18,

    There's a PSIM Python API you can use instead of PsimCmd.exe, you can leverage commands like PsimASimulate.

    Open PSIM and go to Help > Index and type Python in the search bat to get more info on this. There's also a PSIM OML API that you can use from Altair Compose, which I find it's easier to use. Have a look here. Syntax is very similar for both APIs so you can translate the OML example to Python easily. Hope this helps!

    Rafael

  • Ju4n_R0sales
    Ju4n_R0sales
    Altair Employee
    Answer ✓

    Hello @jcm18, Adding to what Rafael said:

    I extended my reply on the support ticket but for anyone else wondering, you can leave the elements in your circuit parametrized, then create a dictionary with the definition of these variables use PsimSimulate and point to the dictionary. Take a look at this section on the Demo_PSimSimulate,py example:

    #use PsimSimulate passing the variables with a dictionary object

    d2 = dict(Simview=0, C = "500u", R = 2.5, Fsw="20k", L=5e-6, TotalTime= 0.02, TimeStep=1E-6)
    d2.update({"Vin": 20})


    res2 = p1.PsimSimulate(str_sample_folder + "buck.psimsch", str_sample_folder + "graphs\\buck1_d.txt", **d2)

    Or you could try modifying the parameter file's text, making sure that you're referencing the correct parameter file.

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.