Closed gudnimg closed 10 months ago
There is also an issue with range(-1, self.num_runs, max_runs_per_sim)
in ToleranceDeviations
class run()
Using the example https://github.com/nunobrum/PyLTSpice/blob/master/examples/run_worst_case.py
And removing only these lines:
wca.set_tolerance('R', 0.01) # 1% tolerance
wca.set_tolerance('C', 0.1) # 10% tolerance
wca.set_tolerance('V', 0.1) # 10% tolerance. For Worst Case analysis, the distribution is irrelevant
But keep this code code:
# Some components can have a different tolerance
wca.set_tolerance('R1', 0.05) # 5% tolerance for R1 only. This only overrides the default tolerance for R1
# Tolerances can be set for parameters as well.
wca.set_parameter_deviation('Vos', 3e-4, 5e-3)
This will only run one simulation! I'd expected more.
Because range(-1, self.num_runs, max_runs_per_sim)
with self.num_runs = 9
and max_runs_per_sim = 512
yields only -1
It should produce iterable of length self.num_runs
I seem to have been using an outdated version for some reason. I will look at this more and use spicelib
.
Thanks for your contact.
I understood that there are situations were the user wants to restrict the worst case to just a few components.
I should default to 0% deviation in all components, unless user reverts it. In this case, only components with !=0 deviation should be considered.
Best regards, Nuno
A new version has been pushed that has some more fixes introduced to the toolkit.
In the
WorstCaseAnalysis
class, if a component does not have any tolerance assigned via for examplewca.set_tolerance('C2', 0.05)
then the component will be given 0% tolerance.This yields 4095 simulations! In this scenario I expect only 2 simulations for C2 at +5% and -5%
The problem is
prepare_testbench
incrementsindex
in the calculation for number of simulations to run:self.num_runs = 2**index - 1
, even if the component has no tolerance set. In my use case, I don't set tolerance to a component I know has no effect on the circuit in order to reduce simulation time.Would it be a reasonable solution to not increment
index
ifComponentDeviation
class hasmax_val = 0
andmin_val = 0
?Example from here https://github.com/nunobrum/PyLTSpice/blob/master/examples/run_worst_case.py should suffice to reproduce this.
Remove these lines:
⚠️ And change
wca.run()
intowca.run(1)
somehow this helps trigger the problem.