Eeschema/ngspice: how to specify initial condition for inductors?

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

Thanks for the suggestions and the pointer to the uic directive.

When looking at the ngspice manual on initial conditions, specifying a current as an initial condition is conspicuously absent, so my takeaway is that

  • inductor initial conditions must be provided in the device definition, L <node+> <node-> <component_val> (ic=<initial_current>)
  • specifying inductor initial current with the .IC directive will always result in a syntax error.

Looking at the file produced by KiCad, (“spice_test.wbk” in my case), the contents are minimal:

2
9
.tran 100n 100u uic
0
0

0

So, I guess to refine my question: Is there a way to specify the initial condition on the KiCad schematic?

If not, is there a method to intercept the spice netlist, modify it, then run it through the ngspice bundled with KiCad?

Double-click on the symbol and add to the Spice_Model field

Ah! that makes sense to me now and works. Thank you!