Time-modulated capacitors in NGSPICE: missing (dC/dt)·V term?

Hi all,

I hope you are doing well.
I’ve been working with time-modulated capacitors in NGSPICE and noticed something that seems inconsistent with the expected physics. Cutting to the chase:

The charge of a capacitor with time-dependent capacitance is
Q=C(t)V(t)

and the current should be

I(t) = \frac{dQ}{dt} = \frac{dC}{dt}V(t) + C(t)\frac{dV}{dt}

However, NGSPICE appears to neglect the (dC/dt).V term. In my test circuit (see below), the simulated capacitor current (black line in the attached figure) agrees only with the C(t).dV/dt contribution.

My questions:
– Is this a known limitation of NGSPICE’s capacitor model?
– Is there a recommended workaround to include the full time-dependent behavior (e.g. using B-sources, behavioral capacitors, or Verilog-A)?

Thanks very much for any insight!

Best regards,
Lucas

CT circuit
*==============================================================

.param freq=500k      $ source frequency
.param dt=1/freq/400    $ time step for transient analysis
.param tau=20/freq      $ evolution time

* Voltage source
Vs1 v1 0 SIN(0 1 {freq})

* Time modulated capacitance
Ck v1 0 {1000p*(1+0.9*cos(3.14159*freq*time))}

* Also tried: --> gives the same result.
* Ck v1 0 C = {1000p*(1+0.9*cos(3.14159*freq*time))}


*--------------------------------------------------------------
*--------------------------------------------------------------
* Transient analysis specs
*--------------------------------------------------------------

.tran {dt} {tau} uic

*==============================================================
.control
    run
    set wr_singlescale
    wrdata current.dat V(v1) I(Vs1)
.endc

.END

1 Like

Yes it may be a limitation of the capacitor model, but it has not been known up to now.

And therefore there is no immediate workaround available.

Unfortunately this forum probably is not the best place tro discuss this problem, as the questions are unrelated to KiCad, and most ngspice maintainers are not here, but listening to the ngspice discussion forums at ngspice / Discussion. So please repost your question at the user forum, and we might work out a solution.

Thank you so much.
Will do.

Best regards,
Lucas.