Documentation /  Analog Insydes /  Reference Manual /  Subcircuit and Device Model Definition /

IntroductionSubcircuit

3.2.1 Model

Command structure of Model.

Subcircuits and device models can be implemented either as netlists, i.e. as equivalent circuits composed of electrical primitives and model references (see Section 3.1.3), or as behavioral descriptions in terms of linear and nonlinear algebraic and differential equations. Both equivalent circuits and analog behavioral models (ABMs) can be defined with the Model command. Model takes a sequence of named arguments, four of which are required while the remaining arguments are optional.

Required arguments of the Model command.

Optional arguments of the Model command.

A valid Model definition has the following general form:

Model[

Name -> name,

Selector -> selector

Ports -> port nodes,

-> ,



Definition -> Netlist[] | Circuit[] | Equations[]

]

Arguments Description

The arguments of the Model command are explained in detail below.

Name

Format of the Name argument.

The value of the argument Name identifies a class of model definitions for a non-primitive circuit object or a device type, such as current mirror, operational amplifier, bipolar junction transistor, or MOSFET. The class name must be a symbol or a string. For example, the class names of BJT and MOSFET models are defined in the Analog Insydes model library as:

Name -> "BJT"

Name -> "MOSFET"

You may assign one or more alias names to a model class by specifying a list of strings:

Name -> {"BJT", "Q"}

Selector

Format of the Selector argument.

The value of the argument Selector selects a particular member from the class of models identified with Name. For instance, the AC, DC, and dynamic large-signal models of the device type MOSFET can be defined and distinguished with the following Name/Selector pairs:

Model[Name -> "MOSFET", Selector -> "AC", ],

Model[Name -> "MOSFET", Selector -> "DC", ],

Model[Name -> "MOSFET", Selector -> "Transient", ]

By assigning several selector keys to a model definition, you can set up a list of alias names for the model. This feature allows you to configure models for use with several closely related analysis modes, such as AC and noise analysis (see DefaultSelector in Section 3.5.1). To prepare a model for use with both AC and noise analysis, your selector specification should be written as follows:

Model[Name -> "MOSFET", Selector -> {"AC", "Noise"}, ]

Scope

Format of the Scope argument.

The optional argument Scope determines the scope of the model definition. With the default setting Scope -> Local, the model can only be referenced from Netlist objects inside the Circuit object that contains the corresponding Model statement. With Scope -> Global, the model is stored in the global subcircuit database and can be accessed by other Circuit objects.

You can use the Scope mechanism to implement a library of frequently used device models separately from any top-level circuit description and load the models into Analog Insydes' global subcircuit database. This can be accomplished by implementing a set of models in a Mathematica *.m file as illustrated below.

(* Begin MyModels.m *)

Circuit[

Model[Name -> "BJT", Selector -> "AC", Scope -> Global,

Definition -> ],

Model[Name -> "MOSFET", Selector -> "AC", Scope -> Global,

Definition -> ],



] // ExpandSubcircuits;

(* End MyModels.m *)

The library file "MyModels.m" can then be loaded using the command Get["MyModels.m"].

See also: GlobalSubcircuits, RemoveSubcircuit.

Ports

Format of the Ports argument.

With the Ports keyword, you can define the port nodes of a model. The value of the argument must be a list of the identifiers of the model nodes which serve as external connection points. Nodes in a model definition which are not listed in the Ports statement (internal nodes) are not accessible from the outside.

Values for the port specification portspec.

For a three-pin BJT model with collector (C), base (B), and emitter (E) terminals, the list of port nodes can be specified as a list of strings

Ports -> {"C", "B", "E"}

or, equivalently, as a list of symbols

Ports -> {C, B, E}

In a model reference, all required ports listed in the Ports argument of the corresponding model definition must be connected to an external node exactly once; otherwise, subcircuit expansion fails. By declaring a port as Optional, you can tell Analog Insydes to ignore any missing connections to this port and perform some default action instead, such as connecting the port to the ground node. This is useful for modeling integrated semiconductor devices with substrate pins. If the substrate pin of a BJT or MOSFET model is an optional port, you can use the same model definition for both three-pin and four-pin devices. If you write the Ports specifications for these device types as shown below, then the substrate pin is connected implicitly to the ground node and source terminal, respectively, whenever a BJT or MOSFET model is instantiated as a three-pin device.

The following Ports declaration causes the substrate pin S of a BJT device to be connected to the ground node if S is left unconnected:

Ports -> {"C", "B", "E", Optional["S", 0]}

This causes the bulk node B of a MOSFET device to be connected to the source terminal if the port node B is left unconnected:

Ports -> {"D", "G", "S", Optional["B", "S"]}

You can also tell Analog Insydes to leave an unconnected node floating by using Optional without a second argument. The following Ports declaration treats S as if it were an internal node of the model definition if S is left unconnected.

Ports -> {"C", "B", "E", Optional["S"]}

Parameters

Format of the Parameters argument.

With the Parameters keyword, you can specify the set of symbols which represent the parameters of a model definition. Possible values are:

Values for the parameter specification parspec.

Any symbol which appears in the value field of a model netlist entry or in a set of behavioral equations can be designated as a parameter. The difference between parameters and other symbols is that you can assign instance-specific values only to parameters. Other symbols are regarded as global quantities which cannot be bound to instance-specific values in a model reference. In addition, if a model parameter p is left unbound in a model reference, it will be replaced by a uniquely instantiated symbol p$instance upon subcircuit expansion whereas symbols representing global quantities are not changed. The following line shows a valid example for the Parameters declaration of a BJT model:

Parameters -> {IS, N, BF, BR}

In some cases it is necessary to override the value of a global circuit parameter locally for a particular model instance. For example, you may have set the environmental temperature TEMP in a Circuit object with the GlobalParameters statement

Circuit[

Netlist[],

GlobalParameters[TEMP -> 300.15]

]

but you want to specify a different operating temperature for an individual device, such as a temperature sensor or the output transistor of a power amplifier. In order to override the global value of TEMP for this device, the local temperature value must be specified explicitly in the corresponding model reference:

{QOUT, {VCC -> C, 5 -> B, out -> E},

Model -> BJT, Selector -> DC,

IS -> 1.*^-16, N -> 1., BF -> 100., BR -> 1., TEMP -> 340.}

However, TEMP is a global quantity and not an instance parameter of the model BJT/DC. Therefore, the local setting TEMP -> 340. in the model reference QOUT has no effect unless the Parameters specification in the model definition is modified as follows:

Parameters -> {IS, N, BF, BR, Global[TEMP]}

Now the setting Global[TEMP] allows you to change the value of TEMP individually for any instance of BJT/DC while the setting from the GlobalParameters list will be used for all instances for which no local temperature value is given.

Defaults

Format of the Defaults argument.

With the Defaults keyword, you can specify default values for model parameters which have been left unbound in a model reference. For example, with the settings



Parameters -> {IS, N, BF, BR, Global[TEMP]},

Defaults -> {IS -> 1.*^-16, N -> 1., BF -> 100.,

BR -> 1., TEMP -> 300.15},

you can instantiate a default BJT device without having to specify values for the parameters in the model reference:

{QDEF, {nout -> C, 2 -> B, 3 -> E}, Model -> BJT, Selector -> DC}

During subcircuit expansion the numerical default values specified by the Defaults argument are used as model parameter values. The above model reference is thus processed as if its value field had been specified as shown below.

{QDEF, {nout -> C, 2 -> B, 3 -> E}, Model -> BJT, Selector -> DC,

IS -> 1.*^-16, N -> 1., BF -> 100., BR -> 1., TEMP -> 300.15}

Translation

Format of the Translation argument.

The optional argument Translation allows you to specify conversion rules for calculating values of internal model parameters from external parameters declared with the Parameters argument.

For example, the following code defines a simple BJT small-signal model with the external parameters RB (base resistance) and beta (current gain). Internally, the model is implemented using a VCCS whose transconductance gm is calculated automatically from RB and beta by means of the Translation rule gm -> RB*beta.

Model[

Name -> "BJT", Selector -> "SimpleACgm",

Ports -> {"C", "B", "E"},

Parameters -> {RB, beta},

Translation -> {gm -> RB*beta},

Definition -> Netlist[

{"RB", {"B", "E"}, RB},

{"VC", {"B", "E", "C", "E"}, gm}

]

]

Translation rules may also be specified using the RuleDelayed operator (:>). This enables you to defer the evaluation of function calls on the right-hand sides of translation rules until model expansion. In the following list of rules, the thermal voltage Vt of a semiconductor device is calculated by a delayed rule to prevent the function ThermalVoltage to be evaluated before the value of TEMP is known for an individual device.

Translation -> {Is -> Js*Area, Vt :> ThermalVoltage[TEMP]}

If Vt were calculated using a simple Rule (->), ThermalVoltage would already be called at the time of model definition, i.e. execution of the Model command.

Symbolic

Format of the Symbolic argument.

The optional argument Symbolic is used only in conjunction with analog behavioral model definitions. It lets you specify the subset of the model parameters declared in the Parameters section that will be treated as symbolic quantities in a set of behavioral model equations. Model parameters which are not listed in the Symbolic section are always replaced by their numerical values when you set up circuit equations. This feature allows you to restrict the parameters that will appear in a system of symbolic circuit equations to the ones you really wish to see.

The following code defines a DC model for a temperature-dependent linear resistor. The model parameters are the nominal resistance RES, the first-order temperature coefficient TC1, the ambient temperature TEMP, and the reference temperature TNOM. The Symbolic argument declares RES as a model parameter which will appear in symbolic circuit equations. The other parameters will always be evaluated numerically and will not appear explicitly in circuit equations.

Model[

Name -> "RES", Selector -> "DC",

Ports -> {"P", "N"},

Parameters -> {RES, TC1, Global[TEMP, TNOM]},

Symbolic -> {RES},

Variables -> {Voltage["P", "N"], Current["P", "N"]},

Definition -> Equations[

Voltage["P", "N"] ==

RES*(1 + TC1*(TEMP - TNOM))*Current["P", "N"]

]

]

Names of device model or instance parameters in netlists imported from external circuit simulators with ReadNetlist sometimes have lengthy or ugly names. The alternative format of the Symbolic argument allows you to assign alias names to model parameters which will appear in symbolic circuit equations in place of the original names.

For example, the following declaration causes the symbol R to be used instead of the original model parameter name RES whenever you set up symbolic circuit equations with the above model definition.

Symbolic -> {RES -> R}

Variables

Format of the Variables argument.

The Variables argument is used only in conjunction with analog behavioral model definitions. It serves to declare the identifiers in a set of model equations which represent the unknowns. The identifiers have to be of the following form:

Values for the variable specification varspec.

Definition

Format of the Definition argument.

With the Definition argument, you specify the implementation of a model. A model can be implemented either as an equivalent circuit or as a set of linear or nonlinear differential-algebraic equations.

You may use a Netlist or a Circuit object to implement an equivalent circuit. The netlist that represents the equivalent circuit may contain primitive devices as well as further model references. There is no fixed limit of the subcircuit nesting level.

The following example shows a model implementation for a simple RC tank.

Definition -> Netlist[

{R, {in, out}, R},

{C, {out, ref}, C}

]

A Circuit object may contain local ModelParameters sections as well as local Model definitions. Local model definitions and parameter sets should have Scope -> Local to prevent interference with the global subcircuit and parameter databases. Using a Circuit instead of a simple Netlist feature allows you to define models with instance-specific model parameter sets, i.e. device model parameters whose values are calculated from model instance parameters.

For example, the following code implements a device-level description of a bipolar differential pair with emitter degeneration resistors. The model definition contains a local ModelParameters statement in which the ohmic collector and emitter resistances RC and RE are calculated as functions of the BJT area factor Area for each instance of the subcircuit DifferentialPair/DeviceLevel.

Subcircuit[

Name -> "DifferentialPair", Selector -> "DeviceLevel",

Ports -> {"H1", "H2", "IN1", "IN2", "L"},

Parameters -> {Area, RED},

Definition -> Circuit[

Netlist[

{"Q1", {"H1" -> "C", "IN1" -> "B", "ED1" -> "E"},

Model -> "BJT", Selector -> Selector["BJT", "Q1"],

Parameters -> "LocalNPN"},

{"RED1", {"ED1", "L"}, RED},

{"Q2", {"H2" -> "C", "IN2" -> "B", "ED2" -> "E"},

Model -> "BJT", Selector -> Selector["BJT", "Q2"],

Parameters -> "LocalNPN"},

{"RED2", {"ED2", "L"}, RED}

],

ModelParameters[Name -> "LocalNPN", Type -> "NPN",

IS -> 2.*^-15, BF -> 200., RC -> 50./Area, RE -> 2./Area]

]

]

Analog Insydes allows you to implement arbitrary multi-dimensional voltage-current relations as analog behavioral models. ABMs are implemented using sets of Equations instead of Netlist or Circuit objects. Each model equation must be written in the form lhs == rhs, where lhs and rhs denote arbitrary Mathematica expressions.

The following code implements a nonlinear DC model for a bipolar junction diode with series resistance Rs. The first equation serves to compute the effective diode voltage vdeff. It is written in implicit notation to demonstrate that Analog Insydes does not require model equations to be written in explicit form var == expr, where var denotes a single symbol or branch quantity identifier.

Model[

Name -> "Diode", Selector -> "DC",

Ports -> {"A", "C"}, Parameters -> {Rs, Is, Global[Vt]},

Variables -> {Voltage["A", "C"], Current["A", "C"], vdeff},

Definition -> Equations[

Voltage["A", "C"] - Rs*Current["A", "C"] - vdeff == 0,

Current["A", "C"] == Is*(Exp[vdeff/Vt] - 1)

]

]

In addition, the Model command lets you implement behavioral models involving ordinary differential equations (ODEs). In general, the independent variable of such equations is the time variable, denoted by the symbol Time, but other quantities than time may be used as independent variable as well (see Section 3.5.1).

You can attach a trailing tick mark (') to a variable in a set of model equations to denote a time derivative. The following model definition implements the voltage-current relation of a linear, time-invariant capacitor in the time domain. The time derivative of the capacitor voltage is denoted by Voltage["P", "N"]'.



Variables -> {Current["P", "N"], Voltage["P", "N"]},

Definition -> Equations[

Current["P", "N"] == C*Voltage["P", "N"]'

],

To denote a derivative of a variable var with respect to some other quantity q, you must use Mathematica's full derivative notation

Derivative[n][var][q]

where n is the order of the differentiation. Of course, you can also use this notation for time derivatives. For example, the first derivative of the variable vdeff with respect to time can be written as:

Derivative[1][vdeff][Time]

Since Time is the default quantity with respect to which derivatives are computed, the above line can be abbreviated as follows.

Derivative[1][vdeff]

See also: CircuitEquations, Section 3.1.7.

InitialGuess

Format of the InitialGuess argument.

With the InitialGuess argument, you can specify a set of numerical values that will be used by NDAESolve as initial guess for the solution of behavioral model variables. Initial guesses may be specified for some or all of the variables listed in the corresponding Variables declaration.

In the example shown below, initial guesses of and are specified for the model variables vdeff and Voltage["A", "C"], respectively. No initial guess is given for Current["A", "C"], therefore, NDAESolve uses 0 as initial guess for this current.

Model[

Name -> "Diode", Selector -> "DC",

Ports -> {"A", "C"}, Parameters -> {Rs, Is, Global[Vt]},

Variables -> {Voltage["A", "C"], Current["A", "C"], vdeff},

Definition -> Equations[

Voltage["A", "C"] - Rs*Current["A", "C"] - vdeff == 0,

Current["A", "C"] == Is*(Exp[vdeff/Vt] - 1)

],

InitialGuess -> {vdeff -> 0.7, Voltage["A", "C"] -> 0.8}

]

InitialConditions

Format of the InitialConditions argument.

With the InitialConditions argument, you can specify initial conditions for dynamic variables in behavioral model equations. Initial conditions can be assigned to any quantity x whose derivative x' appears in the equations. This applies to internal model variables as well as to branch voltages and currents.

The following example shows how to specify an initial condition for the branch quantity Voltage["P", "N"]. Note that it is not important whether this quantity appears directly in the equations or not. However, its derivative Voltage["P", "N"]' must be present as a prerequisite for the assignment of an initial condition.

Model[

Name -> "Capacitor", Selector -> "Behavioral",

Ports -> {"P", "N"}, Parameters -> {C},

Variables -> {Current["P", "N"], Voltage["P", "N"]},

Definition -> Equations[

Current["P", "N"] == C*Voltage["P", "N"]'

],

InitialConditions -> {Voltage["P", "N"] -> 1.52}

]

Examples

Load Analog Insydes.

In[1]:= <<AnalogInsydes`

The following model commands implement a CCCS-based model for bipolar transistors and an equivalent VCCS-based model. The transconductance of the VCCS in BJT/SimpleACgm is calculated automatically from the parameters RB and beta by means of a translation rule.

CCCS and VCCS-based BJT small-signal models.

In[2]:= Circuit[
Model[
Name -> "BJT", Selector -> "SimpleACbeta",
Scope -> Global, Ports -> {"C", "B", "E"},
Parameters -> {RB, beta},
Definition -> Netlist[
{"RB", {"B", "X"}, RB},
{"CC", {"X", "E", "C", "E"}, beta}
]
],
Model[
Name -> "BJT", Selector -> "SimpleACgm",
Scope -> Global, Ports -> {"C", "B", "E"},
Parameters -> {RB, beta},
Translation -> {gm -> RB*beta},
Definition -> Netlist[
{"RB", {"B", "E"}, RB},
{"VC", {"B", "E", "C", "E"}, gm}
]
]
] // ExpandSubcircuits;

List the contents of the global subcircuit database.

In[3]:= GlobalSubcircuits[]

Out[3]=

The Circuit object shown below describes a common-source amplifier with a MOSFET device. In the model definition for MOSFET, the bulk terminal B is defined as an optional port. Since this node is not connected in the top-level netlist, the bulk terminal is connected implicitly to the source node.

This netlist describes a common-source amplifier.

In[4]:= csamp = Circuit[
Netlist[
{V1, {1, 0}, Value -> {DC -> 1.5, AC -> 1}},
{M1, {"out" -> "D", 1 -> "G", 3 -> "S"},
Model -> "MOSFET", Selector -> "DCSmallSignal",
GM -> 2.*^-4, GMB -> 3.*^-5, GDS -> 1.*^-6},
{RD, {"VDD", "out"}, Symbolic -> Rd, Value -> 1.*^6},
{RS, {3, 0}, Symbolic -> Rs, Value -> 5000.},
{VDD, {"VDD", 0}, Value -> {DC -> 3.3, _ -> 0}}
],
Model[
Name -> "MOSFET", Selector -> "DCSmallSignal",
Ports -> {"D", "G", "S", Optional["B", "S"]},
Parameters -> {gm, gmb, Gds, GM, GMB, GDS},
Definition -> Netlist[
{VCG, {"G", "S", "D", "S"}, Symbolic -> gm,
Value -> GM},
{VCB, {"B", "S", "D", "S"}, Symbolic -> gmb,
Value -> GMB},
{GDS, {"D", "S"}, Symbolic -> Gds,
Value -> GDS}
]
]
]

Out[4]=

Expand the MOSFET model.

In[5]:= ExpandSubcircuits[csamp] // DisplayForm

Out[5]//DisplayForm=

This example shows the effect of the argument Symbolic in a Model statement. The model equations describe the DC behavior of a linear resistor including first-order temperature dependence. Note that although there are four model parameters, only the resistance appears explicitly in symbolic circuit equations. Note also that the alias name R is used instead of RES to denote the resistance.

A circuit with a resistor model.

In[6]:= resckt = Circuit[
Netlist[
{V0, {1, 0}, Symbolic -> V0, Value -> 1},
{R1, {1 -> "P", 0 -> "N"},
Model -> "RES", Selector -> "DC",
RES -> 1000., TC1 -> 10^-3}
],
Model[
Name -> "RES", Selector -> "DC",
Ports -> {"P", "N"},
Parameters -> {RES, TC1, Global[TEMP, TNOM]},
Defaults -> {TC1 -> 0, TNOM -> 300.15, TEMP -> 300.15},
Symbolic -> {RES -> R},
Variables -> {Voltage["P", "N"], Current["P", "N"]},
Definition -> Equations[
Voltage["P", "N"] ==
RES*(1 + TC1*(TEMP - TNOM))*Current["P", "N"]
]
],
GlobalParameters[TEMP -> 310.]
]

Out[6]=

Note that only R$R1 is kept in symbolic form.

In[7]:= CircuitEquations[resckt, AnalysisMode -> DC,
ElementValues -> Symbolic] // DisplayForm

Out[7]//DisplayForm=

The following example demonstrates the use of local model parameter sets in a subcircuit definition. The netlist shown below represents a bipolar differential pair with emitter degeneration resistors. The Circuit object contains a local ModelParameters statement in which the values of the BJT's ohmic collector and emitter resistances are calculated as a function of the area factor.

A differential pair with emitter degeneration resistors.

In[8]:= dpwedr = Subcircuit[
Name -> "DifferentialPair", Selector -> "DeviceLevel",
Ports -> {"H1", "H2", "IN1", "IN2", "L"},
Parameters -> {Area, RED},
Definition -> Circuit[
Netlist[
{"Q1", {"H1" -> "C", "IN1" -> "B", "ED1" -> "E"},
Model -> "BJT", Selector -> Selector["BJT", "Q1"],
Parameters -> "LocalNPN"},
{"RED1", {"ED1", "L"}, RED},
{"Q2", {"H2" -> "C", "IN2" -> "B", "ED2" -> "E"},
Model -> "BJT", Selector -> Selector["BJT", "Q2"],
Parameters -> "LocalNPN"},
{"RED2", {"ED2", "L"}, RED}
],
ModelParameters[Name -> "LocalNPN", Type -> "NPN",
IS -> 2.*^-15, BF -> 200., RC -> 50./Area,
RE -> 2./Area]
]
]

Out[8]=

This netlist describes a differential amplifier on the basis of the subcircuit implemented above.

In[9]:= diffamp = Circuit[
Netlist[
{V0, {"VCC", 0}, Value -> {DC -> 9., _ -> 0}},
{V1, {2, 0}, Value -> {DC -> 4.5, AC -> 1}},
{V2, {3, 0}, Value -> {DC -> 4.5, AC -> 0}},
{R1, {"VCC", 4}, 5000.},
{R2, {"VCC", 5}, 5000.},
{DP1, {4 -> "H1", 5 -> "H2", 2 -> "IN1",
3 -> "IN2", 6 -> "L"},
Model -> "DifferentialPair",
Selector -> "DeviceLevel",
RED -> 100., Area -> 2.},
{IBIAS, {6, 0}, Value -> {DC -> 0.001, _ -> 0}}
],
dpwedr
]

Out[9]=

Set up circuit equations.

In[10]:= diffampeqs = CircuitEquations[diffamp,
AnalysisMode -> DC, ElementValues -> Symbolic]

Out[10]=

The nominal collector and emitter resistances have been divided by the area factor.

In[11]:= {RC$Q1$DP1, RE$Q1$DP1} /. GetDesignPoint[diffampeqs]

Out[11]=

The following code is a slightly more complex example for a behavioral model definition. The Model statement implements a nonlinear DC model for a bipolar junction diode, taking into account junction voltage reduction due to series resistance (Rs) and DC convergence issues (GMIN).

This code defines a diode model and stores it in the global subcircuit database.

In[12]:= Circuit[
Model[
Name -> "Diode", Selector -> "DC",
Scope -> Global, Ports -> {"A", "C"},
Parameters -> {Is, Rs, Global[TEMP, GMIN]},
Defaults -> {Is -> 1.*^-15, Rs -> 0, TEMP -> 300.,
GMIN -> 1.*^-12, $q -> 1.6021918*^-19,
$k -> 1.3806226*^-23},
Translation -> {Vt -> $k*TEMP/$q},
Symbolic -> {Is, Vt, Rs, GMIN},
Variables -> {Voltage["A", "C"],
Current["A", "C"], vdeff},
Definition -> Equations[
Current["A", "C"] ==
Is*(Exp[vdeff/Vt] - 1) + vdeff*GMIN,
vdeff == Voltage["A", "C"] - Rs*Current["A", "C"]
],
InitialGuess -> {vdeff -> 0.7}
]
] // ExpandSubcircuits;

This defines a circuit with a diode in series connection with a resistor.

In[13]:= diodeckt = Circuit[
Netlist[
{V1, {1, 0}, Vin},
{R1, {1, 2}, Symbolic -> R1, Value -> 1000.},
{D1, {2 -> "A", 0 -> "C"},
Model -> "Diode", Selector -> "DC", Rs -> 10.}
],
GlobalParameters[TEMP -> 330.]
]

Out[13]=

Set up modified nodal equations.

In[14]:= diodeeqs = CircuitEquations[diodeckt,
AnalysisMode -> DC, ElementValues -> Symbolic]

Out[14]=

Display the equations.

In[15]:= diodeeqs // DisplayForm

Out[15]//DisplayForm=

Calculate the DC response while sweeping Rs$D1 from to .

In[16]:= diodedc = NDAESolve[diodeeqs,
{Vin, -1., 5.}, {Rs$D1, 0., 200., 50.}];

Plot the diode voltage.

In[17]:= TransientPlot[diodedc, V$2[Vin], {Vin, -1., 5.}]

Out[17]=

This example demonstrates how to specify initial conditions. The netlist describes an RLC series resonator. The behavior of the LC subcircuit is modeled by a system of differential equations.

An RLC circuit with a behavioral description for the LC resonator.

In[18]:= rlcfilter = Circuit[
Netlist[
{R, {1, 0}, 100.},
{LC, {1 -> "P", 0 -> "N"},
Model -> "LCSeriesResonator",
Selector -> "Behavioral", L -> 0.02, C -> 5.*^-7}
],
Model[
Name -> "LCSeriesResonator",
Selector -> "Behavioral",
Ports -> {"P", "N"}, Parameters -> {L, C},
Variables -> {Current["P", "N"], Voltage["P", "N"],
vind, vcap},
Definition -> Equations[
vind == L*Current["P", "N"]',
Voltage["P", "N"] - vcap - vind == 0,
Current["P", "N"] == C*vcap'
],
InitialConditions -> {vcap -> 5.,
Current["P", "N"] -> -0.02}
]
]

Out[18]=

Set up time-domain circuit equations.

In[19]:= rlcfeqs = CircuitEquations[rlcfilter,
AnalysisMode -> Transient,
InitialConditions -> Automatic]

Out[19]=

Display the circuit equations.

In[20]:= rlcfeqs // DisplayForm

Out[20]//DisplayForm=

Simulate the circuit.

In[21]:= rlcftran = NDAESolve[rlcfeqs, {t, 0., 0.002}]

Out[21]=

Display the capacitor voltage and the inductor current.

In[22]:= TransientPlot[rlcftran, {vcap$LC[t], I$PN$LC[t]},
{t, 0., 0.002}, SingleDiagram -> False, PlotRange -> All]

Out[22]=

IntroductionSubcircuit