I can’t figure out how to specify an initial condition for inductor current in a KiCad 6 schematic (a.k.a. ‘eeschema’) such that the ngspice simulator honors the specification.
Things I’ve tried:
Text entry in schematic with .ic i(L1)=1
Result: syntax error in ngspice - perhaps ngspice only takes node voltages as ics?
Setting a parameter/property within the eeschema symbol for the inductor: ".ic" : "1"
Result: no change. inductor initial current is zero
Modifying the definition of the inductor in Simulator windows “Simulation”->“Show SPICE Netlist…”
Any text modification is removed after closing and opening the popup window
Creating a subcircuit model for the inductor
Subcircuit as per below
No SPICE error, but no effect on initial current in inductor
* Sample library of diode model parameters
*
*
*
.subckt L_test one two
L_test one two 1 ic=0.5
* End of library file
.ends
Use the .tran command with th uic parameter, e.g. .tran 1u 1m uic
Only then the initial condition on the instance line becomes effective.
Basically there is another option with code models (A devices):
**
* This circuit contains a capacitor and an inductor with
* initial conditions on them. Each of the components
* has a parallel resistor so that an exponential decay
* of the initial condition occurs with a time constant of
* 1 second.
*
a1 1 0 cap
.model cap capacitoric (c=1000uf ic=1)
r1 1 0 1k
*
a2 2 0 ind
.model ind inductoric (l=1H ic=1)
r2 2 0 1.0
*
L3 3 0 1 ic=1
r3 3 0 1.0
.control
tran 0.01 3 uic
plot v(1) v(2) v(3)
.endc
.end
Tried this trick for a .subcircuit (a Mosfet model), trying to introduce the M = 2 parameter in order to simulate two mosfets in parallell but it did not end up in the netlist.
Any proposals?
I answer myselt.
By adding the params: M=1 in the model file, the parameter shows up in the dialoge for the sim model and I can then change the value to 2.