LTspice: Vary a capacitor's value over time

Well, yes and no. From the ltspice help:

There is also a general nonlinear capacitor available. Instead of specifying the capacitance, one writes an expression for the charge.

LTspice will compile this expression and symbolically differentiate it with respect to all the variables, finding the partial derivative's that correspond to capacitances.

Syntax: Cnnn n1 n2 Q=<expression> [ic=<value>] [m=<value>]

There is a special variable, x, that means the voltage across the device. Therefore, a 100pF constant capacitance can be written as

Cnnn n1 n2 Q=100p*x

A capacitance with an abrupt change from 100p to 300p at zero volts can be written as

Cnnn n1 n2 Q=x*if(x<0,100p,300p)

This requires a bit of different thinking, and although you can make use of the special time variable, I have never verified that things work as expected. Especially intresting would be the point where the capacity will suddenly be lower than what the cap is currently holding in energy, what will ltspice do here? Or if when for the next timestep the capacity is now higher, will the stored energy be the same or scaled too?

You should test if it behaves the way you want it in a seperate test circuit first.

Tags:

Ltspice