Skip to contents

The alter command of SPICE3, with ngspice's parameter names: an unnamed value sets the element's principal value; named values set the named parameters.

Usage

spice_alter(session, refdes, ...)

Arguments

session

A spice_session().

refdes

The element name, a string.

...

The new value(s): one unnamed number, or name = value pairs.

Value

session, invisibly (modified in place).

Details

elementunnamed valuenamed parameters
Rresistance (nonzero)resistance
C, Lcapacitance, inductancecapacitance/inductance, ic
V, IDC leveldc, acmag, acphase (degrees), and pulse, sin, exp, pwl, sffm (a numeric vector of the card's arguments; replaces the transient function)
E, F, G, Hgaingain
M (every level, BSIM)–w, l (meters); temp (degrees C, levels 1/2/3/6)
D, Q, Jareaarea, temp (degrees C)
Zareaarea

The units are the card's. Element names are case-insensitive; subcircuit elements go by their expanded name (r.x1.r1). The circuit temperature is spice_set_temp().

A value equals the altered card when it is the same double: the card parser is SPICE3's, which reads 10u as 10 * 1e-6 (9.999999999999999e-06, not 1e-05).

Errors

A refused value – unknown element or parameter, non-finite value, zero resistance, nonpositive w/l/area – is an error of class spice_error_alter; the parameters before it in the same call stay altered, the refused one and those after it do not.

Examples

s <- spice_session("amp
vdd 1 0 dc 5
vin 2 0 dc 1.2 ac 1
rd 1 3 10k
m1 3 2 0 0 nm l=2u w=10u
.model nm nmos level=1 vto=0.7 kp=50u
.op
.end")
s |>
  spice_alter("rd", 4.7e3) |>
  spice_alter("m1", w = 20e-6, l = 1e-6) |>
  spice_alter("vin", dc = 1.5)
spice_param(s, "m1", "w")
#> [1] 2e-05