I am a realistic capacitor that you can get rapidly charged up to an initial value in a couple of different ways.

My V0 attribute sets an initial voltage of the capacitor rapidly but not instantly using a fast and simulation-friendly error-feedback approach. The value of V0 can be any of several different types that determine my behavior differently:

  • None: No initial voltage (the default). This is mandatory if you set bypass, because it makes no sense to have me quickly charge up to an unknown voltage when you have set what it actually is.
  • float or int: Set my initial voltage to this fixed value. If my V0x attribute is set True, Ngspice's XSPICE-based capacitor model will be used with its initial condition set to this value (voltage). That's simple, but can result in convergence problems. Otherwise (the default), pingspice's capacitance.Initializer will be used. Not AV compatible, and typically will just be used to force a capacitor to start discharged with V0=0.
  • True: This will make me expect a third node 'v0', an input that determines my initial voltage. This is the only way to initialize the capacitor voltage to an alterable value; define your f.vav AV-controlled voltage source outside the subcircuit.

I set the ti entry of setupResults to my initial charging time, when my V0 attribute is set True. Otherwise, I set it to None.

FIVI

If you set fivi to a fast initial voltage interval (seconds, usually in the microsecond range), my underlying Capacitance will do what it can to quickly charge up my voltage at the very beginning of your transient simulation. It uses a FastChargeCap to do this.

You can set fivi to None for no such irregular warm-up (that is the default). You can also set it to True or to a value less than 10x the pingspice-only simulation variable ts, in which case its value will be forced to 10x ts. NOTE: timeWarp, if any, still applies.

If you set my bypass constructor keyword (and thus instance attribute) True, I will also bypass my ESR and ESL during that initial interval. Note: Setting this with V0 also set True will raise an exception, because there's no point setting an initial voltage and also doing an initial fast-charge to some unknown terminal voltage. The resistance of the bypass path will be made as low as needed for the capacitor voltage to reach 99.9% of the terminal voltage, but not lower than 1 mOhm.

Instance Variable C The capacitance value. This is technically AV compatible, but, as with all subcircuit attributes, its value can't actually altered at runtime.
Instance Variable V0 The initial voltage that the capacitance is fast-charged to reach within Initializer.Nts multiples of the simulation timestep specified in pingspice-only simulation variable ts. See discussion above for the several different types that this value can be.
Instance Variable tcon Set to an RC time constant that this capacitance is part of to avoid having it scaled down so far that the time constant is less than the ts pingspice-only simulation option value. Technically can be an AV object, though, again, subcircuit attributes can't be altered at runtime.
Instance Variable timeWarp Set this to a time speed-up factor to make things charge up (and down) x times faster. The speed-up will be limited to tcon if it is set. Default is 1.0, for no time warp.
Instance Variable fivi Set to the initial time allocated for fast initial voltage interval, for an initially fast and still simulation-friendly initial charge-up.
Instance Variable faster The ratio of how much faster the voltage increases if fivi is set. Default is 100.
Instance Variable V0s Set True to cause the capacitance to be subject to an initial voltage-zeroing short circuit. Only applies if fivi is not set and V0 is None.
Instance Variable V0x Set True to use the XSPICE version of voltage initialization. This can cause convergence problems, but is a bit simpler. If it works for your circuit, use it! Setting this with fivi set raises an exception.
Instance Variable ESR Equivalent series resistance, Ohms. If you set this, you can set pdiss True to get an output node with my power dissipation.
Instance Variable ESL Equivalent series inductance, Henries. Seldom known, calculated from leadSpacing if not and that is specified.
Instance Variable leadSpacing Radial lead or screw-terminal spacing (mm, provides an ESL estimate)
Instance Variable df Dissipation factor (fraction) and frequency (Hz), as a 2-tuple or 2-element list. (These may be specified instead of ESR.)
Instance Variable I_leakage Leakage current (if specified).
Instance Variable R_leakage May be used with V_max to compute I_leakage.
Instance Variable V_max Rated voltage, presently only used for computing leakage current with UCC's formula.
Instance Variable pdiss Set True if a 'pdiss' (power dissipation) node is desired. Setting this without ESR defined raises an exception. The 'pdiss' node will come after the second capacitor node, or after the third one if V0 is set True.
Instance Variable bypass Set True to also bypass my ESR and ESL for my fivi time in addition to reducing my capacitance during that interval. fivi must be set, but V0 must not be.
Method nodes Property: There are two basic nodes 'a' and 'b' and two optional ones.
Method R Property: Effective series resistance.
Method L Property: Series inductance.
Method check_config Checks my configuration with all its possible variations of attributes for incompatible combinations. Returns True if my V0 attribute is a number, False otherwise.
Method setup_leakage Adds a parallel resistance for rated or computed leakage current.
Method setup_seriesImpedance Inserts a series resistance and possibly also a series inductance.
Method setup_bypass Adds a TempShort that connects n1 to n2 via a very low resistance, bypasses my ESR and ESL for fast initial charging to some unknown terminal voltage.
Method setup Subcircuit definition.

Inherited from NodeStuff (via Subcircuit):

Instance Variable shunts A dict of current sensing V elements with the pairs of nodes they connect.
Class Variable debug A Bag that gets set True for all instances to log info about each setup call.
Class Method autoName Undocumented
Method setupResults Undocumented
Method fill Undocumented
Method nodeCheck Call with the circuit building tool f and a sequence of nodes provided to this Include or Subcircuit.
Method rawNetlist Get lines of a raw netlist from a search hierarchy of possible sources.
Method shunt Call to insert a current-measuring shunt and add an entry to my Elements baton's dict of shunts.
Method raw See Elements.raw.
Method iNode See Elements.iNode.
Method ground See Elements.ground.
Method sca See Elements.sca.
Method sca6 See Elements.sca6.
Class Method _libDir Undocumented
Method _strippedLines Undocumented
Method _call_setup Calls my setup method (almost always your override of that method, actually) and processes any return value.

Inherited from NodeStuff (via Subcircuit):

Instance Variable shunts A dict of current sensing V elements with the pairs of nodes they connect.
Class Variable debug A Bag that gets set True for all instances to log info about each setup call.
Class Method autoName Undocumented
Method setupResults Undocumented
Method fill Undocumented
Method nodeCheck Call with the circuit building tool f and a sequence of nodes provided to this Include or Subcircuit.
Method rawNetlist Get lines of a raw netlist from a search hierarchy of possible sources.
Method shunt Call to insert a current-measuring shunt and add an entry to my Elements baton's dict of shunts.
Method raw See Elements.raw.
Method iNode See Elements.iNode.
Method ground See Elements.ground.
Method sca See Elements.sca.
Method sca6 See Elements.sca6.
Class Method _libDir Undocumented
Method _strippedLines Undocumented
Method _call_setup Calls my setup method (almost always your override of that method, actually) and processes any return value.
C =
The capacitance value. This is technically AV compatible, but, as with all subcircuit attributes, its value can't actually altered at runtime.
V0 =
The initial voltage that the capacitance is fast-charged to reach within Initializer.Nts multiples of the simulation timestep specified in pingspice-only simulation variable ts. See discussion above for the several different types that this value can be.
tcon =
Set to an RC time constant that this capacitance is part of to avoid having it scaled down so far that the time constant is less than the ts pingspice-only simulation option value. Technically can be an AV object, though, again, subcircuit attributes can't be altered at runtime.
timeWarp =
Set this to a time speed-up factor to make things charge up (and down) x times faster. The speed-up will be limited to tcon if it is set. Default is 1.0, for no time warp.
fivi =
Set to the initial time allocated for fast initial voltage interval, for an initially fast and still simulation-friendly initial charge-up.
faster =
The ratio of how much faster the voltage increases if fivi is set. Default is 100.
V0s =
Set True to cause the capacitance to be subject to an initial voltage-zeroing short circuit. Only applies if fivi is not set and V0 is None.
V0x =
Set True to use the XSPICE version of voltage initialization. This can cause convergence problems, but is a bit simpler. If it works for your circuit, use it! Setting this with fivi set raises an exception.
ESR =
Equivalent series resistance, Ohms. If you set this, you can set pdiss True to get an output node with my power dissipation.
ESL =
Equivalent series inductance, Henries. Seldom known, calculated from leadSpacing if not and that is specified.
leadSpacing =
Radial lead or screw-terminal spacing (mm, provides an ESL estimate)
df =
Dissipation factor (fraction) and frequency (Hz), as a 2-tuple or 2-element list. (These may be specified instead of ESR.)
I_leakage =
Leakage current (if specified).
R_leakage =
May be used with V_max to compute I_leakage.
V_max =
Rated voltage, presently only used for computing leakage current with UCC's formula.
pdiss =
Set True if a 'pdiss' (power dissipation) node is desired. Setting this without ESR defined raises an exception. The 'pdiss' node will come after the second capacitor node, or after the third one if V0 is set True.
bypass =
Set True to also bypass my ESR and ESL for my fivi time in addition to reducing my capacitance during that interval. fivi must be set, but V0 must not be.
@property
def nodes(self):

Property: There are two basic nodes 'a' and 'b' and two optional ones.

If my V0 attribute is set True, then those are followed by a third node 'v0', a high-impedance input that you can set to an initial capacitance voltage, fast-charged within a few simulation time steps by capacitance.Initializer. If there is no input, 'v0' floats to zero, and then that is the initial capacitance voltage.

If my pdiss attribute is set True, then 'a' and 'b' and possibly also 'v0' are followed by an output node 'pdiss' whose voltage equals the total power dissipation of the capacitor.

@property
def R(self):

Property: Effective series resistance.

If my ESR attribute is set, then that is the value of R. Otherwise, if my df (dissipation factor) is set to a 2-element sequence (df, freq), then R is set based on how much power dissipation there is at that frequency, given my capacitance value C.

@property
def L(self):

Property: Series inductance.

If my ESL attribute is set, then that is the value of L. Otherwise, if my leadSpacing is set (mm), the series inductance is calculated from that.

The formula is simply 1.5 nH per mm of spacing between the leads. This is from Sam G. Parler, Jr., "Improved Spice Models of Aluminum Electrolytic Capacitors for Inverter Applications," p. 3: "Typical series inductance values of radial and screw-terminal capacitors are about 1-2 nH/mm terminal spacing. This value does not vary significantly with temperature or frequency..."

def check_config(self):

Checks my configuration with all its possible variations of attributes for incompatible combinations. Returns True if my V0 attribute is a number, False otherwise.

def setup_leakage(self, f):

Adds a parallel resistance for rated or computed leakage current.

If V_max is specified but I_leakage is not, uses UCC's formula for their big capacitors.

def setup_seriesImpedance(self, f):

Inserts a series resistance and possibly also a series inductance.

If there's a series resistance and pdiss is set True, also inserts a power dissipation measuring device with output node 'pdiss'.

Returns a reference to the node that will connect to the actual capacitor from the first subcircuit node.

def setup_bypass(self, f, n1, n2):

Adds a TempShort that connects n1 to n2 via a very low resistance, bypasses my ESR and ESL for fast initial charging to some unknown terminal voltage.

def setup(self, f):

Subcircuit definition.

Why use f? Because it's short and a conveniently typed letter on the keyboard.

Override this if your subclass does not reference a param.ParameterFinder subclass via the Finder class attribute. As with Include.setup, your override method can return a dict of attribute names and values to set in my instance.

API Documentation for pingspice, generated by pydoctor at 2021-09-18 08:41:11.