I have an LCR circuit including voltage sources where I need to sweep more than three parameters (nested sweep) for a transient simulation. I need to try a large number of different combinations of parameter values (I have 5 parameters, each of them can take anywhere from 3 to 10 values, for a total number of combinations up to 5000). Once the simulation stops, I need to use cursors in Probe to figure out which combination of parameters generates close to a a certain result. I cannot use Monte Carlo since the cursor information is missing (i.e. which parameter combination corresponds with which waveform). Besides, the Monte Carlo will take too long and it may 'duplicate' some combinations. Is there a trick I can use to overcome the 'up to three nested loops' limitation?

  • \$\begingroup\$ Welcome to EE.SE! This could be a case of you get what you pay for. PSPICE is more suited for this but if you are good at scripting, this should be possible to solve in NGSPICE. \$\endgroup\$
    – winny
    Apr 15 '20 at 17:19
  • \$\begingroup\$ You can combine your sweeps by inventing integers that composite them together and then divide them back out using LTspice functions that are available to you. For example, combine parameter A and parameter B into a new parameter, (A*100+B), and sweep that. You can break that back out into A and B as it executes. \$\endgroup\$
    – jonk
    Apr 16 '20 at 4:28
  • \$\begingroup\$ Does this answer your question? I'm surprised it didn't come up when you were writing your question (you did verify, didn't you?). \$\endgroup\$ Apr 16 '20 at 7:04
  • \$\begingroup\$ I am not sure if my question was well understood (yes I did find other similar posts but no applicable answers). 'Jonk' may be up to something but still unclear how to perform for example 5x10x4x4x6=4800 independent simulations by 'combining' parameters and then 'breaking them back'. \$\endgroup\$
    – NP1
    Apr 16 '20 at 19:37

I managed to do it using the TABLE function for each of the five variables. The problem was that the size of the tables (given by the number of total parameter combinations) was prohibitive to write by hand. So I wrote a C++ script to create the tables as (long) text files. Then you use .include and .step param and the TABLE function in LTspice to perform the sweeps. The probe cursor indicates which 'key' (i.e. parameter combination) was used for each simulation. The general idea (not the implementation) came from the LTspice yahoo group (e.g. https://groups.io/g/LTspice/topic/50201465#60860).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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