Post Go back to editing

Passing MonteCarlo generated parameters to .subcircuit and simultaneously to the .log

Category: Software
Product Number: LTspice
Software Version: 24.1.7

Hi,

I have following netlist:

*test2.net

.options measdgt=99 numdgt=99 plotwinsize=0

.tran 1

V1 n1 0 {xp}

X1 n2 0 tst2 input={xp}

.param xp mc(10,1)

.meas p1 param xp

.meas p2 find xp at 0

.meas p3 find v(n1) at 0

.meas p4 find v(n2) at 0

.subckt tst2 n2 0 input=1

E1 n2 0 value = {input}

.ends

.end

I generate xp parameter by MonteCarlo and then measure it four ways: p1, p2, p3, p4. The issue is that in the .log the value p4 is different from the first three.

p1: xp=7.7838149338983

p2: xp=7.7838149338983 at 0

p3: v(n1)=7.7838149338983 at 0

p4: v(n2)=13.16445919037762 at 0

It looks like for the subcircuit there is a separate mc() call made.

It appeared since version 24.1.3. For 24.0.12 it looks ok:

p1: xp=15.5320902127

p2: xp=15.5320902127 at 0

p3: v(n1)=15.5320902127 at 0

p4: v(n2)=15.5320902127 at 0

Similarly for earlier versions all are same.

Is it a bug or feature Wink?

The above simple netlist is just for emphasizing the issue. I run thousands of stepped MonteCarlo simulations for sensitivity analysis in the batch mode. If results of some of them are odd for me, I’m reproducing those exact simulations and looking at the waves what happened, etc. For that I measure every MC-generated parameter to have it in the .log and use it later for reproducing.

The above issue complicates the simulations a lot because the above workaround of adding a parameter controlled source and additional node, correcting the symbol, in every subcircuit from the library one want to use to have the correct parameter back outside at the top level for logging is not a good solution.

Or maybe there is a simple solution I can’t see.

Best regards,

pavo