diff --git a/previews/PR117/elements/index.html b/previews/PR117/elements/index.html index 91df3cd..97490c8 100644 --- a/previews/PR117/elements/index.html +++ b/previews/PR117/elements/index.html @@ -1,16 +1,16 @@ -Element Reference · ACME.jl

Element Reference

Passives

ACME.resistorFunction
resistor(r)

Creates a resistor obeying Ohm’s law. The resistance r has to be given in Ohm.

Pins: 1, 2

source
ACME.capacitorFunction
capacitor(c)

Creates a capacitor. The capacitance c has to be given in Farad.

Pins: 1, 2

source
ACME.inductorMethod
inductor(l)

Creates an inductor. The inductance l has to be given in Henri.

Pins: 1, 2

source
ACME.inductorMethod
inductor(Val{:JA}; D, A, n, a, α, c, k, Ms)

Creates a non-linear inductor based on the Jiles-Atherton model of magnetization assuming a toroidal core thin compared to its diameter. The parameters are set using named arguments:

parameterdescription
DTorus diameter (in meters)
ATorus cross-sectional area (in square-meters)
nWinding's number of turns
aShape parameter of the anhysteretic magnetization curve (in Ampere-per-meter)
αInter-domain coupling
cRatio of the initial normal to the initial anhysteretic differential susceptibility
kamount of hysteresis (in Ampere-per-meter)
Mssaturation magnetization (in Ampere-per-meter)

A detailed discussion of the parameters can be found in D. C. Jiles and D. L. Atherton, “Theory of ferromagnetic hysteresis,” J. Magn. Magn. Mater., vol. 61, no. 1–2, pp. 48–60, Sep. 1986 and J. H. B. Deane, “Modeling the dynamics of nonlinear inductor circuits,” IEEE Trans. Magn., vol. 30, no. 5, pp. 2795–2801, 1994, where the definition of c is taken from the latter. The ACME implementation is discussed in M. Holters, U. Zölzer, "Circuit Simulation with Inductors and Transformers Based on the Jiles-Atherton Model of Magnetization".

Pins: 1, 2

source
ACME.transformerMethod
transformer(l1, l2; coupling_coefficient=1, mutual_coupling=coupling_coefficient*sqrt(l1*l2))

Creates a transformer with two windings having inductances. The primary self-inductance l1 and the secondary self-inductance l2 have to be given in Henri. The coupling can either be specified using coupling_coefficient (0 is not coupled, 1 is closely coupled) or by mutual_coupling, the mutual inductance in Henri, where the latter takes precedence if both are given.

Pins: primary1 and primary2 for primary winding, secondary1 and secondary2 for secondary winding

source
ACME.transformerMethod
transformer(Val{:JA}; D, A, ns, a, α, c, k, Ms)

Creates a non-linear transformer based on the Jiles-Atherton model of magnetization assuming a toroidal core thin compared to its diameter. The parameters are set using named arguments:

parameterdescription
DTorus diameter (in meters)
ATorus cross-sectional area (in square-meters)
nsWindings' number of turns as a vector with one entry per winding
aShape parameter of the anhysteretic magnetization curve (in Ampere-per-meter)
αInter-domain coupling
cRatio of the initial normal to the initial anhysteretic differential susceptibility
kamount of hysteresis (in Ampere-per-meter)
Mssaturation magnetization (in Ampere-per-meter)

A detailed discussion of the parameters can be found in D. C. Jiles and D. L. Atherton, “Theory of ferromagnetic hysteresis,” J. Magn. Magn. Mater., vol. 61, no. 1–2, pp. 48–60, Sep. 1986 and J. H. B. Deane, “Modeling the dynamics of nonlinear inductor circuits,” IEEE Trans. Magn., vol. 30, no. 5, pp. 2795–2801, 1994, where the definition of c is taken from the latter. The ACME implementation is discussed in M. Holters, U. Zölzer, "Circuit Simulation with Inductors and Transformers Based on the Jiles-Atherton Model of Magnetization".

Pins: 1 and 2 for primary winding, 3 and 4 for secondary winding, and so on

source

Independent Sources

ACME.voltagesourceFunction
voltagesource(; rs=0)
-voltagesource(v; rs=0)

Creates a voltage source. The source voltage v has to be given in Volt. If omitted, the source voltage will be an input of the circuit. Optionally, an internal series resistance rs (in Ohm) can be given which defaults to zero.

Pins: + and - with v being measured from + to -

source
ACME.currentsourceFunction
currentsource(; gp=0)
-currentsource(i; gp=0)

Creates a current source. The source current i has to be given in Ampere. If omitted, the source current will be an input of the circuit. Optionally, an internal parallel conductance gp (in Ohm⁻¹) can be given which defaults to zero.

Pins: + and - where i measures the current leaving source at the + pin

source

Probes

ACME.voltageprobeFunction
voltageprobe()

Creates a voltage probe, providing the measured voltage as a circuit output. Optionally, an internal parallel conductance gp (in Ohm⁻¹) can be given which defaults to zero.

Pins: + and - with the output voltage being measured from + to -

source
ACME.currentprobeFunction
currentprobe()

Creates a current probe, providing the measured current as a circuit output. Optionally, an internal series resistance rs (in Ohm) can be given which defaults to zero.

Pins: + and - with the output current being the current entering the probe at +

source

Semiconductors

ACME.diodeFunction
diode(;is=1e-12, η = 1)

Creates a diode obeying Shockley's law $i=I_S\cdot(e^{v/(\eta v_T)}-1)$ where $v_T$ is fixed at 25 mV. The reverse saturation current is has to be given in Ampere, the emission coefficient η is unitless.

Pins: + (anode) and - (cathode)

source
ACME.bjtFunction
bjt(typ; is=1e-12, η=1, isc=is, ise=is, ηc=η, ηe=η, βf=1000, βr=10,
+Element Reference · ACME.jl

Element Reference

Passives

ACME.resistorFunction
resistor(r)

Creates a resistor obeying Ohm’s law. The resistance r has to be given in Ohm.

Pins: 1, 2

source
ACME.capacitorFunction
capacitor(c)

Creates a capacitor. The capacitance c has to be given in Farad.

Pins: 1, 2

source
ACME.inductorMethod
inductor(l)

Creates an inductor. The inductance l has to be given in Henri.

Pins: 1, 2

source
ACME.inductorMethod
inductor(Val{:JA}; D, A, n, a, α, c, k, Ms)

Creates a non-linear inductor based on the Jiles-Atherton model of magnetization assuming a toroidal core thin compared to its diameter. The parameters are set using named arguments:

parameterdescription
DTorus diameter (in meters)
ATorus cross-sectional area (in square-meters)
nWinding's number of turns
aShape parameter of the anhysteretic magnetization curve (in Ampere-per-meter)
αInter-domain coupling
cRatio of the initial normal to the initial anhysteretic differential susceptibility
kamount of hysteresis (in Ampere-per-meter)
Mssaturation magnetization (in Ampere-per-meter)

A detailed discussion of the parameters can be found in D. C. Jiles and D. L. Atherton, “Theory of ferromagnetic hysteresis,” J. Magn. Magn. Mater., vol. 61, no. 1–2, pp. 48–60, Sep. 1986 and J. H. B. Deane, “Modeling the dynamics of nonlinear inductor circuits,” IEEE Trans. Magn., vol. 30, no. 5, pp. 2795–2801, 1994, where the definition of c is taken from the latter. The ACME implementation is discussed in M. Holters, U. Zölzer, "Circuit Simulation with Inductors and Transformers Based on the Jiles-Atherton Model of Magnetization".

Pins: 1, 2

source
ACME.transformerMethod
transformer(l1, l2; coupling_coefficient=1, mutual_coupling=coupling_coefficient*sqrt(l1*l2))

Creates a transformer with two windings having inductances. The primary self-inductance l1 and the secondary self-inductance l2 have to be given in Henri. The coupling can either be specified using coupling_coefficient (0 is not coupled, 1 is closely coupled) or by mutual_coupling, the mutual inductance in Henri, where the latter takes precedence if both are given.

Pins: primary1 and primary2 for primary winding, secondary1 and secondary2 for secondary winding

source
ACME.transformerMethod
transformer(Val{:JA}; D, A, ns, a, α, c, k, Ms)

Creates a non-linear transformer based on the Jiles-Atherton model of magnetization assuming a toroidal core thin compared to its diameter. The parameters are set using named arguments:

parameterdescription
DTorus diameter (in meters)
ATorus cross-sectional area (in square-meters)
nsWindings' number of turns as a vector with one entry per winding
aShape parameter of the anhysteretic magnetization curve (in Ampere-per-meter)
αInter-domain coupling
cRatio of the initial normal to the initial anhysteretic differential susceptibility
kamount of hysteresis (in Ampere-per-meter)
Mssaturation magnetization (in Ampere-per-meter)

A detailed discussion of the parameters can be found in D. C. Jiles and D. L. Atherton, “Theory of ferromagnetic hysteresis,” J. Magn. Magn. Mater., vol. 61, no. 1–2, pp. 48–60, Sep. 1986 and J. H. B. Deane, “Modeling the dynamics of nonlinear inductor circuits,” IEEE Trans. Magn., vol. 30, no. 5, pp. 2795–2801, 1994, where the definition of c is taken from the latter. The ACME implementation is discussed in M. Holters, U. Zölzer, "Circuit Simulation with Inductors and Transformers Based on the Jiles-Atherton Model of Magnetization".

Pins: 1 and 2 for primary winding, 3 and 4 for secondary winding, and so on

source

Independent Sources

ACME.voltagesourceFunction
voltagesource(; rs=0)
+voltagesource(v; rs=0)

Creates a voltage source. The source voltage v has to be given in Volt. If omitted, the source voltage will be an input of the circuit. Optionally, an internal series resistance rs (in Ohm) can be given which defaults to zero.

Pins: + and - with v being measured from + to -

source
ACME.currentsourceFunction
currentsource(; gp=0)
+currentsource(i; gp=0)

Creates a current source. The source current i has to be given in Ampere. If omitted, the source current will be an input of the circuit. Optionally, an internal parallel conductance gp (in Ohm⁻¹) can be given which defaults to zero.

Pins: + and - where i measures the current leaving source at the + pin

source

Probes

ACME.voltageprobeFunction
voltageprobe()

Creates a voltage probe, providing the measured voltage as a circuit output. Optionally, an internal parallel conductance gp (in Ohm⁻¹) can be given which defaults to zero.

Pins: + and - with the output voltage being measured from + to -

source
ACME.currentprobeFunction
currentprobe()

Creates a current probe, providing the measured current as a circuit output. Optionally, an internal series resistance rs (in Ohm) can be given which defaults to zero.

Pins: + and - with the output current being the current entering the probe at +

source

Semiconductors

ACME.diodeFunction
diode(;is=1e-12, η = 1)

Creates a diode obeying Shockley's law $i=I_S\cdot(e^{v/(\eta v_T)}-1)$ where $v_T$ is fixed at 25 mV. The reverse saturation current is has to be given in Ampere, the emission coefficient η is unitless.

Pins: + (anode) and - (cathode)

source
ACME.bjtFunction
bjt(typ; is=1e-12, η=1, isc=is, ise=is, ηc=η, ηe=η, βf=1000, βr=10,
     ile=0, ilc=0, ηcl=ηc, ηel=ηe, vaf=Inf, var=Inf, ikf=Inf, ikr=Inf)

Creates a bipolar junction transistor obeying the Gummel-Poon model

\[i_f = \frac{\beta_f}{1+\beta_f} I_{S,E} \cdot (e^{v_E/(\eta_E v_T)}-1)\]

\[i_r = \frac{\beta_r}{1+\beta_r} I_{S,C} \cdot (e^{v_C/(\eta_C v_T)}-1)\]

\[i_{cc} = \frac{2(1-\frac{V_E}{V_{ar}}-\frac{V_C}{V_{af}})} {1+\sqrt{1+4(\frac{i_f}{I_{KF}}+\frac{i_r}{I_{KR}})}} (i_f - i_r)\]

\[i_{BE} = \frac{1}{\beta_f} i_f + I_{L,E} \cdot (e^{v_E/(\eta_{EL} v_T)}-1)\]

\[i_{BC} = \frac{1}{\beta_r} i_r + I_{L,C} \cdot (e^{v_C/(\eta_{CL} v_T)}-1)\]

\[i_E = i_{cc} + i_{BE} \qquad i_C=-i_{cc} + i_{BC}\]

where $v_T$ is fixed at 25 mV. For

\[I_{L,E}=I_{L,C}=0,\quad V_{ar}=V_{af}=I_{KF}=I_{KR}=∞,\]

this reduces to the Ebers-Moll equation

\[i_E = I_{S,E} \cdot (e^{v_E/(\eta_E v_T)}-1) - \frac{\beta_r}{1+\beta_r} I_{S,C} \cdot (e^{v_C/(\eta_C v_T)}-1)\]

\[i_C = -\frac{\beta_f}{1+\beta_f} I_{S,E} \cdot (e^{v_E/(\eta_E v_T)}-1) - + I_{S,C} \cdot (e^{v_C/(\eta_C v_T)}-1).\]

Additionally, terminal series resistances are supported.

The parameters are set using named arguments:

parameterdescription
typEither :npn or :pnp, depending on desired transistor type
isReverse saturation current in Ampere
ηEmission coefficient
iscCollector reverse saturation current in Ampere (overriding is)
iseEmitter reverse saturation current in Ampere (overriding is)
ηcCollector emission coefficient (overriding η)
ηeEmitter emission coefficient (overriding η)
βfForward current gain
βrReverse current gain
ilcBase-collector junction leakage current in Ampere
ileBase-emitter junction leakage current in Ampere
ηclBase-collector junction leakage emission coefficient (overriding η)
ηelBase-emitter junction leakage emission coefficient (overriding η)
vafForward Early voltage in Volt
varReverse Early voltage in Volt
ikfForward knee current (gain roll-off) in Ampere
ikrReverse knee current (gain roll-off) in Ampere
reEmitter terminal resistance
rcCollector terminal resistance
rbBase terminal resistance

Pins: base, emitter, collector

source
ACME.mosfetFunction
mosfet(typ; vt=0.7, α=2e-5, λ=0)

Creates a MOSFET transistor with the simple model

\[i_D=\begin{cases} + + I_{S,C} \cdot (e^{v_C/(\eta_C v_T)}-1).\]

Additionally, terminal series resistances are supported.

The parameters are set using named arguments:

parameterdescription
typEither :npn or :pnp, depending on desired transistor type
isReverse saturation current in Ampere
ηEmission coefficient
iscCollector reverse saturation current in Ampere (overriding is)
iseEmitter reverse saturation current in Ampere (overriding is)
ηcCollector emission coefficient (overriding η)
ηeEmitter emission coefficient (overriding η)
βfForward current gain
βrReverse current gain
ilcBase-collector junction leakage current in Ampere
ileBase-emitter junction leakage current in Ampere
ηclBase-collector junction leakage emission coefficient (overriding η)
ηelBase-emitter junction leakage emission coefficient (overriding η)
vafForward Early voltage in Volt
varReverse Early voltage in Volt
ikfForward knee current (gain roll-off) in Ampere
ikrReverse knee current (gain roll-off) in Ampere
reEmitter terminal resistance
rcCollector terminal resistance
rbBase terminal resistance

Pins: base, emitter, collector

source
ACME.mosfetFunction
mosfet(typ; vt=0.7, α=2e-5, λ=0)

Creates a MOSFET transistor with the simple model

\[i_D=\begin{cases} 0 & \text{if } v_{GS} \le v_T \\ \alpha \cdot (v_{GS} - v_T - \tfrac{1}{2}v_{DS})\cdot v_{DS} \cdot (1 + \lambda v_{DS}) & \text{if } v_{DS} \le v_{GS} - v_T \cap v_{GS} > v_T \\ \frac{\alpha}{2} \cdot (v_{GS} - v_T)^2 \cdot (1 + \lambda v_{DS}) & \text{otherwise.} -\end{cases}\]

The typ parameter chooses between NMOS (:n) and PMOS (:p). The threshold voltage vt is given in Volt, α (in A/V²) is a constant depending on the physics and dimensions of the device, and λ (in V⁻¹) controls the channel length modulation.

Optionally, it is possible to specify tuples of coefficients for vt and α. These will be used as polynomials in $v_{GS}$ to determine $v_T$ and $\alpha$, respectively. E.g. with vt=(0.7, 0.1, 0.02), the $v_{GS}$-dpendent threshold voltage $v_T = 0.7 + 0.1\cdot v_{GS} + 0.02\cdot v_{GS}^2$ will be used.

Pins: gate, source, drain

source

Integrated Circuits

ACME.opampMethod
opamp(;maxgain=Inf, gain_bw_prod=Inf)

Creates a linear operational amplifier as a voltage-controlled voltage source. The input current is zero while the input voltage is mapped to the output voltage according to the transfer function

\[H(f) = \frac{A_\text{max}}{\sqrt{A_\text{max}^2-1} i \frac{f}{f_\text{UG}} + 1}\]

where $f$ is the signal frequency, $A_\text{max}$ (maxgain) is the maximum open loop gain and $f_\text{UG}$ (gain_bw_prod) is the gain/bandwidth product (unity gain bandwidth). For gain_bw_prod=Inf (the default), this corresponds to a frequency-independent gain of maxgain. For maxgain=Inf (the default), the amplifier behaves as a perfect integrator.

For both maxgain=Inf and gain_bw_prod=Inf, i.e. just opamp(), an ideal operational amplifier is obtained that enforces the voltage between the input pins to be zero while sourcing arbitrary current on the output pins without restricting their voltage.

Note that the opamp has two output pins, where the negative one will typically be connected to a ground node and has to provide the current sourced on the positive one.

Pins: in+ and in- for input, out+ and out- for output

source
Missing docstring.

Missing docstring for opamp(::Type{Val{:macak}}, gain, vomin, vomax). Check Documenter's build log for details.

+\end{cases}\]

The typ parameter chooses between NMOS (:n) and PMOS (:p). The threshold voltage vt is given in Volt, α (in A/V²) is a constant depending on the physics and dimensions of the device, and λ (in V⁻¹) controls the channel length modulation.

Optionally, it is possible to specify tuples of coefficients for vt and α. These will be used as polynomials in $v_{GS}$ to determine $v_T$ and $\alpha$, respectively. E.g. with vt=(0.7, 0.1, 0.02), the $v_{GS}$-dpendent threshold voltage $v_T = 0.7 + 0.1\cdot v_{GS} + 0.02\cdot v_{GS}^2$ will be used.

Pins: gate, source, drain

source

Integrated Circuits

ACME.opampMethod
opamp(;maxgain=Inf, gain_bw_prod=Inf)

Creates a linear operational amplifier as a voltage-controlled voltage source. The input current is zero while the input voltage is mapped to the output voltage according to the transfer function

\[H(f) = \frac{A_\text{max}}{\sqrt{A_\text{max}^2-1} i \frac{f}{f_\text{UG}} + 1}\]

where $f$ is the signal frequency, $A_\text{max}$ (maxgain) is the maximum open loop gain and $f_\text{UG}$ (gain_bw_prod) is the gain/bandwidth product (unity gain bandwidth). For gain_bw_prod=Inf (the default), this corresponds to a frequency-independent gain of maxgain. For maxgain=Inf (the default), the amplifier behaves as a perfect integrator.

For both maxgain=Inf and gain_bw_prod=Inf, i.e. just opamp(), an ideal operational amplifier is obtained that enforces the voltage between the input pins to be zero while sourcing arbitrary current on the output pins without restricting their voltage.

Note that the opamp has two output pins, where the negative one will typically be connected to a ground node and has to provide the current sourced on the positive one.

Pins: in+ and in- for input, out+ and out- for output

source
Missing docstring.

Missing docstring for opamp(::Type{Val{:macak}}, gain, vomin, vomax). Check Documenter's build log for details.

diff --git a/previews/PR117/gettingstarted/index.html b/previews/PR117/gettingstarted/index.html index eac1091..c1169e1 100644 --- a/previews/PR117/gettingstarted/index.html +++ b/previews/PR117/gettingstarted/index.html @@ -22,4 +22,4 @@ # output 1×44100 Matrix{Float64}: - 0.0 0.0275964 0.0990996 0.195777 … -0.537508 -0.462978 -0.36521

The output y now likewise is a matrix with one row for the one probe we have added to the circuit and one column per sample.

More interesting circuits can be found in the examples located at Pkg.dir("ACME/examples").

In the likely event that you would like to process real audio data, take a look at the WAV package for reading writing WAV files.

Note that the solver used to solve the non-linear equation when running the model saves solutions to use as starting points in the future. Model execution will therefore become faster after an initial learning phase. Nevertheless, ACME is at present more geared towards computing all the model matrices than to actually running the model. More complex circuits may run intolerably slow or fail to run altogether.

+ 0.0 0.0275964 0.0990996 0.195777 … -0.537508 -0.462978 -0.36521

The output y now likewise is a matrix with one row for the one probe we have added to the circuit and one column per sample.

More interesting circuits can be found in the examples located at Pkg.dir("ACME/examples").

In the likely event that you would like to process real audio data, take a look at the WAV package for reading writing WAV files.

Note that the solver used to solve the non-linear equation when running the model saves solutions to use as starting points in the future. Model execution will therefore become faster after an initial learning phase. Nevertheless, ACME is at present more geared towards computing all the model matrices than to actually running the model. More complex circuits may run intolerably slow or fail to run altogether.

diff --git a/previews/PR117/index.html b/previews/PR117/index.html index feb12bd..9880d82 100644 --- a/previews/PR117/index.html +++ b/previews/PR117/index.html @@ -1,2 +1,2 @@ -Home · ACME.jl

ACME.jl - Analog Circuit Modeling and Emulation for Julia

ACME is a Julia package for the simulation of electrical circuits, focusing on audio effect circuits. It allows to programmatically describe a circuit in terms of elements and connections between them and then automatically derive a model for the circuit. The model can then be run on varying input data.

ACME is based on the method described in M. Holters, U. Zölzer, "A Generalized Method for the Derivation of Non-Linear State-Space Models from Circuit Schematics".

+Home · ACME.jl

ACME.jl - Analog Circuit Modeling and Emulation for Julia

ACME is a Julia package for the simulation of electrical circuits, focusing on audio effect circuits. It allows to programmatically describe a circuit in terms of elements and connections between them and then automatically derive a model for the circuit. The model can then be run on varying input data.

ACME is based on the method described in M. Holters, U. Zölzer, "A Generalized Method for the Derivation of Non-Linear State-Space Models from Circuit Schematics".

diff --git a/previews/PR117/search/index.html b/previews/PR117/search/index.html index 8e562fd..b5615d4 100644 --- a/previews/PR117/search/index.html +++ b/previews/PR117/search/index.html @@ -1,2 +1,2 @@ -Search · ACME.jl

Loading search...

    +Search · ACME.jl

    Loading search...

      diff --git a/previews/PR117/ug/index.html b/previews/PR117/ug/index.html index eca9446..2957699 100644 --- a/previews/PR117/ug/index.html +++ b/previews/PR117/ug/index.html @@ -10,10 +10,10 @@ end

      Finally, a connection endpoint may simply be of the form netname, to connect to a named net. (Such named nets are created as needed.)

      Example

      @circuit begin
           src = voltagesource(5), [-] ⟷ gnd
           r = resistor(1000), [1] ⟷ src[+], [2] ⟷ gnd
      -end

      If a net or pin specification is not just a single symbol or number, and has to be put in quotes (e.g. "in+", "9V")

      Note

      Instead of (\longleftrightarrow), one can also use ==.

      source

      The pins provided by each type of element are described in the Element Reference.

      Instead of or in addition to using the @circuit macro, Circuit instances can also be populated and modified programmatically using the following functions:

      ACME.add!Function
      add!(c::Circuit, elem::Element)

      Adds the element elem to the circuit c, creating and returning a new, unique reference designator, leaving its pins unconnected.

      source
      add!(c::Circuit, designator::Symbol, elem::Element)

      Adds the element elem to the circuit c with the reference designator designator, leaving its pins unconnected. If the circuit already contained an element named designator, it is removed first.

      source
      Base.delete!Function
      delete!(c::Circuit, designator::Symbol)

      Deletes the element named designator from the circuit c (disconnecting all its pins).

      source
      ACME.connect!Function
      connect!(c::Circuit, pins::Union{Symbol,Tuple{Symbol,Any}}...)

      Connects the given pins (or named nets) to each other in the circuit c. Named nets are given as Symbols, pins are given as Tuple{Symbols,Any}s, where the first entry is the reference designator of an element in c, and the second entry is the pin name. For convenience, the latter is automatically converted to a Symbol as needed.

      Example

      circ = Circuit()
      +end

      If a net or pin specification is not just a single symbol or number, and has to be put in quotes (e.g. "in+", "9V")

      Note

      Instead of (\longleftrightarrow), one can also use ==.

      source

      The pins provided by each type of element are described in the Element Reference.

      Instead of or in addition to using the @circuit macro, Circuit instances can also be populated and modified programmatically using the following functions:

      ACME.add!Function
      add!(c::Circuit, elem::Element)

      Adds the element elem to the circuit c, creating and returning a new, unique reference designator, leaving its pins unconnected.

      source
      add!(c::Circuit, designator::Symbol, elem::Element)

      Adds the element elem to the circuit c with the reference designator designator, leaving its pins unconnected. If the circuit already contained an element named designator, it is removed first.

      source
      Base.delete!Function
      delete!(c::Circuit, designator::Symbol)

      Deletes the element named designator from the circuit c (disconnecting all its pins).

      source
      ACME.connect!Function
      connect!(c::Circuit, pins::Union{Symbol,Tuple{Symbol,Any}}...)

      Connects the given pins (or named nets) to each other in the circuit c. Named nets are given as Symbols, pins are given as Tuple{Symbols,Any}s, where the first entry is the reference designator of an element in c, and the second entry is the pin name. For convenience, the latter is automatically converted to a Symbol as needed.

      Example

      circ = Circuit()
       add!(circ, :r, resistor(1e3))
       add!(circ, :src, voltagesource(5))
      -connect!(circ, (:src, -), (:r, 2), :gnd) # connect to gnd net
      source
      ACME.disconnect!Function
      disconnect!(c::Circuit, p::Tuple{Symbol,Any})

      Disconnects the given pin p from anything else in the circuit c. The pin is given as aTuple{Symbols,Any}, where the first entry is the reference designator of an element in c, and the second entry is the pin name. For convenience, the latter is automatically converted to a Symbol as needed. Note that if e.g. three pin p1, p2, and p3 are connected then disconnect!(c, p1) will disconnect p1 from p2 and p3, but leave p2 and p3 connected to each other.

      source

      For example, a cascade of 20 RC-lowpasses could be generated by:

      circ = @circuit begin
      +connect!(circ, (:src, -), (:r, 2), :gnd) # connect to gnd net
      source
      ACME.disconnect!Function
      disconnect!(c::Circuit, p::Tuple{Symbol,Any})

      Disconnects the given pin p from anything else in the circuit c. The pin is given as aTuple{Symbols,Any}, where the first entry is the reference designator of an element in c, and the second entry is the pin name. For convenience, the latter is automatically converted to a Symbol as needed. Note that if e.g. three pin p1, p2, and p3 are connected then disconnect!(c, p1) will disconnect p1 from p2 and p3, but leave p2 and p3 connected to each other.

      source

      For example, a cascade of 20 RC-lowpasses could be generated by:

      circ = @circuit begin
           src = voltagesource(), [-] ⟷ gnd
           output = voltageprobe(), [-] ⟷ gnd
       end
      @@ -32,4 +32,4 @@
       
       1×100 Matrix{Float64}:
        1.83357e-8  3.1622e-7  2.59861e-6  …  0.00465423  0.00459275  0.00453208

      To simulate a circuit without inputs, a matrix with zero rows may be passed:

      y = run!(model, zeros(0, 100))

      The internal state of the model (e.g. capacitor charges) is preserved accross calls to run!.

      Each invocation of run! in this way has to allocate some memory as temporary storage. To avoid this overhead when running the same model for many small input blocks, a ModelRunner instance can be created explicitly:

      runner = ModelRunner(model, false)
      -run!(runner, y, u)

      By using a pre-allocated output y as in the example, allocations in run! are reduced to a minimum.

      Upon creation of a DiscreteModel, its internal states (e.g. capacitor charges) are set to zero. It is also possible to set the states to a steady state (if one can be found) with:

      steadystate!(model)

      This is often desirable for circuits where bias voltages are only slowly obtained after turning them on.

      Solvers

      ACME.SimpleSolverType
      SimpleSolver

      The SimpleSolver is the simplest available solver. It uses Newton iteration which features fast local convergence, but makes no guarantees about global convergence. The initial solution of the iteration is obtained by extrapolating the last solution found (or another solution provided externally) using the available Jacobians. Due to the missing global convergence, the SimpleSolver is rarely useful as such.

      source
      ACME.HomotopySolverType
      HomotopySolver{BaseSolver}

      The HomotopySolver extends an existing solver (provided as the type parameter) by applying homotopy to (at least theoretically) ensure global convergence. It can be combined with the SimpleSolver as HomotopySolver{SimpleSolver} to obtain a useful Newton homtopy solver with generally good convergence properties.

      source
      ACME.CachingSolverType
      CachingSolver{BaseSolver}

      The CachingSolver extends an existing solver (provided as the type parameter) by storing found solutions in a k-d tree to use as initial solutions in the future. Whenever the underlying solver needs more than a preset number of iterations (defaults to five), the solution will be stored. Storing new solutions is a relatively expensive operation, so until the stored solutions suffice to ensure convergence in few iterations throughout, use of a CachingSolver may actually slow things down.

      See M. Holters, U. Zölzer, "A k-d Tree Based Solution Cache for the Non-linear Equation of Circuit Simulations" for a more detailed discussion.

      source

      The default solver used is a HomotopySolver{CachingSolver{SimpleSolver}}.

      +run!(runner, y, u)

      By using a pre-allocated output y as in the example, allocations in run! are reduced to a minimum.

      Upon creation of a DiscreteModel, its internal states (e.g. capacitor charges) are set to zero. It is also possible to set the states to a steady state (if one can be found) with:

      steadystate!(model)

      This is often desirable for circuits where bias voltages are only slowly obtained after turning them on.

      Solvers

      ACME.SimpleSolverType
      SimpleSolver

      The SimpleSolver is the simplest available solver. It uses Newton iteration which features fast local convergence, but makes no guarantees about global convergence. The initial solution of the iteration is obtained by extrapolating the last solution found (or another solution provided externally) using the available Jacobians. Due to the missing global convergence, the SimpleSolver is rarely useful as such.

      source
      ACME.HomotopySolverType
      HomotopySolver{BaseSolver}

      The HomotopySolver extends an existing solver (provided as the type parameter) by applying homotopy to (at least theoretically) ensure global convergence. It can be combined with the SimpleSolver as HomotopySolver{SimpleSolver} to obtain a useful Newton homtopy solver with generally good convergence properties.

      source
      ACME.CachingSolverType
      CachingSolver{BaseSolver}

      The CachingSolver extends an existing solver (provided as the type parameter) by storing found solutions in a k-d tree to use as initial solutions in the future. Whenever the underlying solver needs more than a preset number of iterations (defaults to five), the solution will be stored. Storing new solutions is a relatively expensive operation, so until the stored solutions suffice to ensure convergence in few iterations throughout, use of a CachingSolver may actually slow things down.

      See M. Holters, U. Zölzer, "A k-d Tree Based Solution Cache for the Non-linear Equation of Circuit Simulations" for a more detailed discussion.

      source

      The default solver used is a HomotopySolver{CachingSolver{SimpleSolver}}.