0
\$\begingroup\$

I'm new to python. I have a python code to simulate my LTspice model. I need to change the on time in the pulse parameters and I need a large number of simulations for at least 100 different Ton. So I want to add an iterative function in the python code that can change the Ton every 1s within a specific range. Please how can I achieve this?

\$\endgroup\$
6
  • \$\begingroup\$ Ever heard of Monte Carlo or stepping features? \$\endgroup\$
    – Andy aka
    Commented Jul 6 at 9:34
  • \$\begingroup\$ .step param will do that for you. \$\endgroup\$
    – winny
    Commented Jul 6 at 10:19
  • 1
    \$\begingroup\$ You can do all of that inside LtSpice. The Python code would have to generate the .asc file and then start LtSpice. \$\endgroup\$ Commented Jul 6 at 21:38
  • \$\begingroup\$ @Andyaka yes i have heard about Monte Carlo but never used it. I will maje some research on it, thanks. \$\endgroup\$
    – New_User
    Commented Jul 7 at 21:12
  • \$\begingroup\$ @winny Thank you for your response. My supervisor told me to use Python, but I will try your suggestions. I want to add that,I need a lot of values. Can I simulate 100+ steps with .step param? \$\endgroup\$
    – New_User
    Commented Jul 7 at 21:21

1 Answer 1

1
\$\begingroup\$

You can call ltspice from the command line:

XVIIx64.exe -Run -b examplecircuit.asc

So you would need to modify the .asc file and then run it.

You can also run netlist files which are easier to manipulate.

It would probably be best to generate a netlist file and then modify the text in python and then run it.

use .meas statements to generate a text output you can parse.

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.