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?
Asked
Active
Viewed 815 times
2
-
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. – winny Apr 15 '20 at 17:19
-
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. – jonk Apr 16 '20 at 04:28
-
Does [this](https://electronics.stackexchange.com/q/126659/95619) answer your question? I'm surprised it didn't come up when you were writing your question (you did verify, didn't you?). – a concerned citizen Apr 16 '20 at 07:04
-
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'. – NP1 Apr 16 '20 at 19:37
1 Answers
2
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).

NP1
- 41
- 2
-
Would you mind sharing a minimal reproducible example of your solution with just a few data points (i.e. not all 5000) and your `.include` statement? You could paste the contents of your `.asc` file directly into your answer inside a code block. – pfabri May 19 '23 at 15:31