From f355bccbba9ee606bb1fc906cd0294f94949f84c Mon Sep 17 00:00:00 2001 From: "Documenter.jl" Date: Fri, 22 Mar 2024 15:13:34 +0000 Subject: [PATCH] build based on 2f87ff1 --- dev/.documenter-siteinfo.json | 2 +- dev/API/blocks/index.html | 21 +- dev/API/electrical/index.html | 2 +- dev/API/hydraulic/index.html | 4 +- .../{13e8f9d6.svg => 01e9a6f3.svg} | 72 +++---- .../{ba6b679c.svg => 4beb0d98.svg} | 112 +++++------ dev/API/linear_analysis/index.html | 16 +- dev/API/magnetic/index.html | 2 +- dev/API/mechanical/index.html | 2 +- dev/API/thermal/index.html | 2 +- dev/assets/Manifest.toml | 54 ++--- .../{1937296f.svg => 36d9ec33.svg} | 68 +++---- .../{10c3ae5b.svg => 5ba0ab6b.svg} | 128 ++++++------ .../{25910cf7.svg => 861a5613.svg} | 56 +++--- .../{8d6d9b9a.svg => a9a3019e.svg} | 128 ++++++------ .../{5583bbeb.svg => c9ef0a40.svg} | 84 ++++---- .../{f8c9463f.svg => e635af09.svg} | 188 +++++++++--------- dev/connectors/connections/index.html | 12 +- dev/index.html | 22 +- dev/objects.inv | Bin 2965 -> 2971 bytes dev/search_index.js | 2 +- dev/tutorials/custom_component/index.html | 2 +- .../{d83c12b9.svg => 4778243c.svg} | 72 +++---- .../{cc6ffa09.svg => 87508734.svg} | 82 ++++---- .../{679f584b.svg => d0c422d0.svg} | 128 ++++++------ dev/tutorials/dc_motor_pi/index.html | 15 +- dev/tutorials/input_component/index.html | 2 +- dev/tutorials/rc_circuit/index.html | 2 +- dev/tutorials/thermal_model/index.html | 2 +- 29 files changed, 632 insertions(+), 650 deletions(-) rename dev/API/linear_analysis/{13e8f9d6.svg => 01e9a6f3.svg} (84%) rename dev/API/linear_analysis/{ba6b679c.svg => 4beb0d98.svg} (87%) rename dev/connectors/connections/{1937296f.svg => 36d9ec33.svg} (92%) rename dev/connectors/connections/{10c3ae5b.svg => 5ba0ab6b.svg} (89%) rename dev/connectors/connections/{25910cf7.svg => 861a5613.svg} (85%) rename dev/connectors/connections/{8d6d9b9a.svg => a9a3019e.svg} (89%) rename dev/connectors/connections/{5583bbeb.svg => c9ef0a40.svg} (91%) rename dev/connectors/connections/{f8c9463f.svg => e635af09.svg} (89%) rename dev/tutorials/dc_motor_pi/{d83c12b9.svg => 4778243c.svg} (86%) rename dev/tutorials/dc_motor_pi/{cc6ffa09.svg => 87508734.svg} (85%) rename dev/tutorials/dc_motor_pi/{679f584b.svg => d0c422d0.svg} (85%) diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index 189f7b781..22b0f7dfb 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.2","generation_timestamp":"2024-03-20T13:23:16","documenter_version":"1.3.0"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.2","generation_timestamp":"2024-03-22T15:13:27","documenter_version":"1.3.0"}} \ No newline at end of file diff --git a/dev/API/blocks/index.html b/dev/API/blocks/index.html index d5029ecfd..a45ef9a99 100644 --- a/dev/API/blocks/index.html +++ b/dev/API/blocks/index.html @@ -1,23 +1,22 @@ -Basic Blocks · ModelingToolkitStandardLibrary.jl

ModelingToolkitStandardLibrary: Blocks

Index

Utility Blocks

ModelingToolkitStandardLibrary.Blocks.RealOutputFunction
RealOutput(;name, nout, u_start)

Connector with one output signal of type Real.

Parameters:

  • nout=1: Number of inputs
  • u_start=0: Initial value for u

States:

  • u: Value of the connector; if nout=1 this is a scalar
source

Math Blocks

ModelingToolkitStandardLibrary.Blocks.Add3Constant
Add(; name, k1 = 1, k2 = 1, k3 = 1)

Output the sum of the three scalar inputs.

Parameters:

  • k1: Gain for first input
  • k2: Gain for second input
  • k3: Gain for third input

Connectors:

  • input1
  • input2
  • input3
  • output
source

Source Blocks

ModelingToolkitStandardLibrary.Blocks.SineFunction
Sine(; name, frequency, amplitude = 1, phase = 0, offset = 0, start_time = 0,
-smooth = false)

Generate sine signal.

Parameters:

  • frequency: [Hz] Frequency of sine wave
  • amplitude: Amplitude of sine wave
  • phase: [rad] Phase of sine wave
  • offset: Offset of output signal
  • start_time: [s] Output y = offset for t < start_time
  • smooth: If true, returns a smooth wave. Defaults to false It uses a default smoothing factor of δ=1e-5, but this can be changed by supplying smooth=δ.

Connectors:

  • output
source
Missing docstring.

Missing docstring for Cosine. Check Documenter's build log for details.

ModelingToolkitStandardLibrary.Blocks.RampFunction

Ramp(; name, height = 1, duration = 1, offset = 0, start_time = 0, smooth = false)

Generate ramp signal.

Parameters:

  • height: Height of ramp
  • duration: [s] Duration of ramp (= 0.0 gives a Step)
  • offset: Offset of output signal
  • start_time: [s] Output y = offset for t < start_time
  • smooth: If true, returns a smooth wave. Defaults to false It uses a default smoothing factor of δ=1e-5, but this can be changed by supplying smooth=δ.

Connectors:

  • output
source
ModelingToolkitStandardLibrary.Blocks.StepFunction
Step(;name, height=1, offset=0, start_time=0, duration=Inf, smooth=true)

Generate step signal.

Parameters:

  • height: Height of step
  • offset: Offset of output signal
  • start_time: [s] Output y = offset for t < start_time and thereafter offset+height.
  • duration: [s] If duration < Inf is supplied, the output will revert to offset after duration seconds.
  • smooth: If true, returns a smooth wave. Defaults to true It uses a default smoothing factor of δ=1e-5, but this can be changed by supplying smooth=δ.

Connectors:

  • output
source
ModelingToolkitStandardLibrary.Blocks.ExpSineFunction
ExpSine(; name, frequency, amplitude = 1, damping = 0.1, phase = 0, offset = 0, start_time = 0, smooth = false)

Exponentially damped sine signal.

Parameters:

  • frequency: [Hz] Frequency of sine wave
  • amplitude: Amplitude of sine wave
  • damping: [1/s] Damping coefficient of sine wave
  • phase: [rad] Phase of sine wave
  • offset: Offset of output signal
  • start_time: [s] Output y = offset for t < start_time
  • smooth: If true, returns a smooth wave. Defaults to false It uses a default smoothing factor of δ=1e-5, but this can be changed by supplying smooth=δ.

Connectors:

  • output
source

Nonlinear Blocks

ModelingToolkitStandardLibrary.Blocks.DeadZoneConstant
DeadZone(; name, u_max, u_min = -u_max)

The DeadZone block defines a region of zero output. If the input is within u_min ... u_max, the output is zero. Outside of this zone, the output is a linear function of the input with a slope of 1.

       y▲
+Basic Blocks · ModelingToolkitStandardLibrary.jl

ModelingToolkitStandardLibrary: Blocks

Index

Utility Blocks

ModelingToolkitStandardLibrary.Blocks.RealOutputFunction
RealOutput(;name, nout, u_start)

Connector with one output signal of type Real.

Parameters:

  • nout=1: Number of outputs
  • u_start=0: Initial value for u

States:

  • u: Value of the connector; if nout=1 this is a scalar
source
ModelingToolkitStandardLibrary.Blocks.SISOConstant
SISO(;name, u_start = 0.0, y_start = 0.0)

Single input single output (SISO) continuous system block.

Parameters:

  • u_start: Initial value for the input
  • y_start: Initial value for the output
source

Math Blocks

ModelingToolkitStandardLibrary.Blocks.Add3Constant
Add(; name, k1 = 1.0, k2 = 1.0, k3 = 1.0)

Output the sum of the three scalar inputs.

Parameters:

  • k1: Gain for first input
  • k2: Gain for second input
  • k3: Gain for third input

Connectors:

  • input1
  • input2
  • input3
  • output
source

Source Blocks

ModelingToolkitStandardLibrary.Blocks.SineFunction
Sine(; name, frequency, amplitude = 1, phase = 0, offset = 0, start_time = 0,
+smooth = false)

Generate sine signal.

Parameters:

  • frequency: [Hz] Frequency of sine wave
  • amplitude: Amplitude of sine wave
  • phase: [rad] Phase of sine wave
  • offset: Offset of output signal
  • start_time: [s] Output y = offset for t < start_time
  • smooth: If true, returns a smooth wave. Defaults to false It uses a default smoothing factor of δ=1e-5, but this can be changed by supplying smooth=δ.

Connectors:

  • output
source
ModelingToolkitStandardLibrary.Blocks.CosineFunction
Cosine(; name, frequency, amplitude = 1, phase = 0, offset = 0, start_time = 0,
+smooth = false)

Generate cosine signal.

Parameters:

  • frequency: [Hz] Frequency of cosine wave
  • amplitude: Amplitude of cosine wave
  • phase: [rad] Phase of cosine wave
  • offset: Offset of output signal
  • start_time: [s] Output y = offset for t < start_time
  • smooth: If true, returns a smooth wave. Defaults to false It uses a default smoothing factor of δ=1e-5, but this can be changed by supplying smooth=δ.

Connectors:

  • output
source
ModelingToolkitStandardLibrary.Blocks.RampFunction

Ramp(; name, height = 1, duration = 1, offset = 0, start_time = 0, smooth = false)

Generate ramp signal.

Parameters:

  • height: Height of ramp
  • duration: [s] Duration of ramp (= 0.0 gives a Step)
  • offset: Offset of output signal
  • start_time: [s] Output y = offset for t < start_time
  • smooth: If true, returns a smooth wave. Defaults to false It uses a default smoothing factor of δ=1e-5, but this can be changed by supplying smooth=δ.

Connectors:

  • output
source
ModelingToolkitStandardLibrary.Blocks.StepFunction
Step(;name, height=1, offset=0, start_time=0, duration=Inf, smooth=true)

Generate step signal.

Parameters:

  • height: Height of step
  • offset: Offset of output signal
  • start_time: [s] Output y = offset for t < start_time and thereafter offset+height.
  • duration: [s] If duration < Inf is supplied, the output will revert to offset after duration seconds.
  • smooth: If true, returns a smooth wave. Defaults to true It uses a default smoothing factor of δ=1e-5, but this can be changed by supplying smooth=δ.

Connectors:

  • output
source
ModelingToolkitStandardLibrary.Blocks.ExpSineFunction
ExpSine(; name, frequency, amplitude = 1, damping = 0.1, phase = 0, offset = 0, start_time = 0, smooth = false)

Exponentially damped sine signal.

Parameters:

  • frequency: [Hz] Frequency of sine wave
  • amplitude: Amplitude of sine wave
  • damping: [1/s] Damping coefficient of sine wave
  • phase: [rad] Phase of sine wave
  • offset: Offset of output signal
  • start_time: [s] Output y = offset for t < start_time
  • smooth: If true, returns a smooth wave. Defaults to false It uses a default smoothing factor of δ=1e-5, but this can be changed by supplying smooth=δ.

Connectors:

  • output
source

Nonlinear Blocks

ModelingToolkitStandardLibrary.Blocks.DeadZoneConstant
DeadZone(; name, u_max, u_min = -u_max)

The DeadZone block defines a region of zero output. If the input is within u_min ... u_max, the output is zero. Outside of this zone, the output is a linear function of the input with a slope of 1.

       y▲
         │     /
         │    /
   u_min │   /
 ─────|──┼──|───────► u
     /   │   u_max
    /    │
-  /     │

Parameters:

  • u_max: Upper limit of dead zone
  • u_min: Lower limit of dead zone

Connectors:

  • input
  • output
source
ModelingToolkitStandardLibrary.Blocks.SlewRateLimiterConstant
SlewRateLimiter(; name, y_start, rising = 1.0, falling = -rising, Td = 0.001)

Limits the slew rate of a signal. Initial value of state Y can be set with int.y

Parameters:

  • rising: Maximum rising slew rate
  • falling: Maximum falling slew rate
  • Td: [s] Derivative time constant
  • y_start: Initial value of y state of SISO

Connectors:

  • input
  • output
source

Continuous Blocks

ModelingToolkitStandardLibrary.Blocks.IntegratorConstant
Integrator(;name, k = 1, x = 0.0)

Outputs y = ∫k*u dt, corresponding to the transfer function $1/s$. Initial value of integrator state $x$ can be set with x

Connectors:

  • input
  • output

Parameters:

  • k: Gain of integrator
source
ModelingToolkitStandardLibrary.Blocks.DerivativeConstant
Derivative(; name, k = 1, T, x = 0.0)

Outputs an approximate derivative of the input. The transfer function of this block is Initial value of the state $x$ can be set with x

k       k
-─ - ──────────
-T    2 ⎛    1⎞
-    T ⋅⎜s + ─⎟
-       ⎝    T⎠

and a state-space realization is given by ss(-1/T, 1/T, -k/T, k/T) where T is the time constant of the filter. A smaller T leads to a more ideal approximation of the derivative.

Parameters:

  • k: Gain
  • T: [s] Time constants (T>0 required; T=0 is ideal derivative block)

Connectors:

  • input
  • output
source
ModelingToolkitStandardLibrary.Blocks.FirstOrderConstant
FirstOrder(; name, k = 1.0, T, x = 0.0, lowpass = true)

A first-order filter with a single real pole in s = -T and gain k. If lowpass=true (default), the transfer function is given by $Y(s)/U(s) =$

   k
+  /     │

Parameters:

  • u_max: Upper limit of dead zone
  • u_min: Lower limit of dead zone

Connectors:

  • input
  • output
source
ModelingToolkitStandardLibrary.Blocks.SlewRateLimiterConstant
SlewRateLimiter(; name, y_start, rising = 1.0, falling = -rising, Td = 0.001)

Limits the slew rate of a signal. Initial value of state Y can be set with int.y

Parameters:

  • rising: Maximum rising slew rate
  • falling: Maximum falling slew rate
  • Td: [s] Derivative time constant
  • y_start: Initial value of y state of SISO

Connectors:

  • input
  • output
source

Continuous Blocks

ModelingToolkitStandardLibrary.Blocks.IntegratorConstant
Integrator(;name, k = 1, x = 0.0)

Outputs y = ∫k*u dt, corresponding to the transfer function $1/s$. Initial value of integrator state $x$ can be set with x

Connectors:

  • input
  • output

Parameters:

  • k: Gain of integrator

Unknowns:

  • x: State of Integrator. Defaults to 0.0.
source
ModelingToolkitStandardLibrary.Blocks.DerivativeConstant
Derivative(; name, k = 1, T, x = 0.0)

Outputs an approximate derivative of the input. The transfer function of this block is

k      k        ks  
+─ - ─────── = ────── 
+T   sT² + T   sT + 1

and a state-space realization is given by ss(-1/T, 1/T, -k/T, k/T) where T is the time constant of the filter. A smaller T leads to a more ideal approximation of the derivative.

Initial value of the state $x$ can be set with x.

Parameters:

  • k: Gain
  • T: [s] Time constant (T>0 required; T=0 is ideal derivative block)

Unknowns:

  • x: Unknown of Derivative. Defaults to 0.0.

Connectors:

  • input
  • output
source
ModelingToolkitStandardLibrary.Blocks.FirstOrderConstant
FirstOrder(; name, k = 1.0, T, x = 0.0, lowpass = true)

A first-order filter with a single real pole at s = -1/T and gain k. If lowpass=true (default), the transfer function is given by $Y(s)/U(s) =$

   k
 ───────
 sT + 1

and if lowpass=false, by

sT + 1 - k
 ──────────
-  sT + 1

Initial value of the state x can be set with x

Parameters:

  • k: Gain
  • T: [s] Time constant (T>0 required)

Connectors:

  • input
  • output

See also SecondOrder

source
ModelingToolkitStandardLibrary.Blocks.SecondOrderConstant
SecondOrder(; name, k = 1.0, w = 1.0, d = 1.0, x = 0.0, xd = 0.0)

A second-order filter with gain k, a bandwidth of w rad/s and relative damping d. The transfer function is given by Y(s)/U(s) =

      k*w^2
+  sT + 1

Initial value of the state x can be set with x

Parameters:

  • k: Gain
  • T: [s] Time constant (T>0 required)

Connectors:

  • input
  • output

See also SecondOrder

source
ModelingToolkitStandardLibrary.Blocks.SecondOrderConstant
SecondOrder(; name, k = 1.0, w = 1.0, d = 1.0, x = 0.0, xd = 0.0)

A second-order filter with gain k, a bandwidth of w rad/s and relative damping d. The transfer function is given by Y(s)/U(s) =

      k*w^2
 ─────────────────
-s² + 2d*w*s + w^2

Critical damping corresponds to d=1, which yields the fastest step response without overshoot, d < 1 results in an underdamped filter while d > 1 results in an overdamped filter. d = 1/√2 corresponds to a Butterworth filter of order 2 (maximally flat frequency response). Initial value of the state x can be set with x, and of derivative state xd with xd.

Parameters:

  • k: Gain
  • w: [rad/s] Angular frequency
  • d: Damping

Connectors:

  • input
  • output
source
ModelingToolkitStandardLibrary.Blocks.StateSpaceFunction
StateSpace(A, B, C, D = 0; x = zeros(size(A,1)), u0 = zeros(size(B,2)), y0 = zeros(size(C,1)), name)

A linear, time-invariant state-space system on the form.

\[\begin{aligned} +s² + 2d*w*s + w^2

Critical damping corresponds to d=1, which yields the fastest step response without overshoot, d < 1 results in an underdamped filter while d > 1 results in an overdamped filter. d = 1/√2 corresponds to a Butterworth filter of order 2 (maximally flat frequency response). Initial value of the state x can be set with x, and of derivative state xd with xd.

Parameters:

  • k: Gain
  • w: [rad/s] Angular frequency
  • d: Damping

Connectors:

  • input
  • output
source
ModelingToolkitStandardLibrary.Blocks.StateSpaceFunction
StateSpace(A, B, C, D = 0; x = zeros(size(A,1)), u0 = zeros(size(B,2)), y0 = zeros(size(C,1)), name)

A linear, time-invariant state-space system on the form.

\[\begin{aligned} ẋ &= Ax + Bu \\ y &= Cx + Du \end{aligned}\]

Transfer functions can also be simulated by converting them to a StateSpace form.

y0 and u0 can be used to set an operating point, providing them changes the dynamics from an LTI system to the affine system

\[\begin{aligned} @@ -26,7 +25,7 @@ \end{aligned}\]

For a nonlinear system

\[\begin{aligned} ẋ &= f(x, u) \\ y &= h(x, u) -\end{aligned}\]

linearized around the operating point x₀, u₀, we have y0, u0 = h(x₀, u₀), u₀.

source
ModelingToolkitStandardLibrary.Blocks.TransferFunctionFunction
TransferFunction(; b, a, name)

A single input, single output, linear time-invariant system provided as a transfer-function.

Y(s) = b(s) / a(s)  U(s)

where b and a are vectors of coefficients of the numerator and denominator polynomials, respectively, ordered such that the coefficient of the highest power of s is first.

The internal state realization is on controller canonical form, with state variable x, output variable y and input variable u. For numerical robustness, the realization used by the integrator is scaled by the last entry of the a parameter. The internally scaled state variable is available as x_scaled.

To set the initial state, it's recommended to set the initial condition for x, and let that of x_scaled be computed automatically.

Parameters:

  • b: Numerator polynomial coefficients, e.g., 2s + 3 is specified as [2, 3]
  • a: Denominator polynomial coefficients, e.g., s² + 2ωs + ω^2 is specified as [1, 2ω, ω^2]

Connectors:

  • input
  • output

See also StateSpace which handles MIMO systems, as well as ControlSystemsMTK.jl for an interface between ControlSystems.jl and ModelingToolkit.jl for advanced manipulation of transfer functions and linear statespace systems. For linearization, see linearize and Linear Analysis.

source
ModelingToolkitStandardLibrary.Blocks.PIConstant
PI(;name, k = 1.0, T = 1.0, int.x = 0.0)

Textbook version of a PI-controller without actuator saturation and anti-windup measure. The proportional gain can be set with k Initial value of integrator state x can be set with int.x

The PI controller is implemented on standard form:

\[U(s) = k (1 + \dfrac{1}{sT}) E(S)\]

Parameters:

  • k: Proportional gain
  • T: [s] Integrator time constant (T>0 required)

Connectors:

  • err_input
  • ctr_output

See also LimPI

source
ModelingToolkitStandardLibrary.Blocks.LimPIFunction
LimPI(; name, k = 1.0, T, Ta, int__x = 0.0, u_max = 1.0, u_min = -u_max)

Text-book version of a PI-controller with actuator saturation and anti-windup measure.

The PI controller is implemented on standard form

\[u(t) = sat(k (e(t) + ∫\dfrac{1}{T}e(t) dt) )\]

The simplified expression above is given without the anti-windup protection.

Parameters:

  • k: Proportional gain
  • T: [s] Integrator time constant (T>0 required)
  • Ta: [s] Tracking time constant (Ta>0 required)

Connectors:

  • err_input
  • ctr_output
source
ModelingToolkitStandardLibrary.Blocks.PIDFunction
PID(;name, k=1, Ti=false, Td=false, Nd=10, int__x=0, der__x=0)

Text-book version of a PID-controller without actuator saturation and anti-windup measure.

Parameters:

  • k: Gain
  • Ti: [s] Integrator time constant (Ti>0 required). If set to false, no integral action is used.
  • Td: [s] Derivative time constant (Td>0 required). If set to false, no derivative action is used.
  • Nd: [s] Time constant for the derivative approximation (Nd>0 required; Nd=0 is ideal derivative).
  • int__x: Initial value for the integrator.
  • der__x: Initial value for the derivative state.

Connectors:

  • err_input
  • ctr_output

See also LimPID

source
ModelingToolkitStandardLibrary.Blocks.LimPIDFunction
LimPID(; k, Ti=false, Td=false, wp=1, wd=1, Ni, Nd=12, u_max=Inf, u_min=-u_max, gains = false, name)

Proportional-Integral-Derivative (PID) controller with output saturation, set-point weighting and integrator anti-windup.

The equation for the control signal is roughly

k(ep + 1/Ti * ∫e + Td * d/dt(ed))
+\end{aligned}\]

linearized around the operating point x₀, u₀, we have y0, u0 = h(x₀, u₀), u₀.

source
ModelingToolkitStandardLibrary.Blocks.TransferFunctionFunction
TransferFunction(; b, a, name)

A single input, single output, linear time-invariant system provided as a transfer-function.

Y(s) = b(s) / a(s)  U(s)

where b and a are vectors of coefficients of the numerator and denominator polynomials, respectively, ordered such that the coefficient of the highest power of s is first.

The internal state realization is on controller canonical form, with state variable x, output variable y and input variable u. For numerical robustness, the realization used by the integrator is scaled by the last entry of the a parameter. The internally scaled state variable is available as x_scaled.

To set the initial state, it's recommended to set the initial condition for x, and let that of x_scaled be computed automatically.

Parameters:

  • b: Numerator polynomial coefficients, e.g., 2s + 3 is specified as [2, 3]
  • a: Denominator polynomial coefficients, e.g., s² + 2ωs + ω^2 is specified as [1, 2ω, ω^2]

Connectors:

  • input
  • output

See also StateSpace which handles MIMO systems, as well as ControlSystemsMTK.jl for an interface between ControlSystems.jl and ModelingToolkit.jl for advanced manipulation of transfer functions and linear statespace systems. For linearization, see linearize and Linear Analysis.

source
ModelingToolkitStandardLibrary.Blocks.PIConstant
PI(;name, k = 1.0, T = 1.0, int.x = 0.0)

Textbook version of a PI-controller without actuator saturation and anti-windup measure. The proportional gain can be set with k Initial value of integrator state x can be set with int.x

The PI controller is implemented on standard form:

\[U(s) = k (1 + \dfrac{1}{sT}) E(S)\]

Parameters:

  • k: Proportional gain
  • T: [s] Integrator time constant (T>0 required)

Connectors:

  • err_input
  • ctr_output

See also LimPI

source
ModelingToolkitStandardLibrary.Blocks.LimPIFunction
LimPI(; name, k = 1.0, T, Ta, int__x = 0.0, u_max = 1.0, u_min = -u_max)

Text-book version of a PI-controller with actuator saturation and anti-windup measure.

The PI controller is implemented on standard form

\[u(t) = sat(k (e(t) + ∫\dfrac{1}{T}e(t) dt) )\]

The simplified expression above is given without the anti-windup protection.

Parameters:

  • k: Proportional gain
  • T: [s] Integrator time constant (T>0 required)
  • Ta: [s] Tracking time constant (Ta>0 required)

Connectors:

  • err_input
  • ctr_output
source
ModelingToolkitStandardLibrary.Blocks.PIDFunction
PID(;name, k=1, Ti=false, Td=false, Nd=10, int__x=0, der__x=0)

Text-book version of a PID-controller without actuator saturation and anti-windup measure.

Parameters:

  • k: Gain
  • Ti: [s] Integrator time constant (Ti>0 required). If set to false, no integral action is used.
  • Td: [s] Derivative time constant (Td>0 required). If set to false, no derivative action is used.
  • Nd: [s] Time constant for the derivative approximation (Nd>0 required; Nd=0 is ideal derivative).
  • int__x: Initial value for the integrator.
  • der__x: Initial value for the derivative state.

Connectors:

  • err_input
  • ctr_output

See also LimPID

source
ModelingToolkitStandardLibrary.Blocks.LimPIDFunction
LimPID(; k, Ti=false, Td=false, wp=1, wd=1, Ni, Nd=12, u_max=Inf, u_min=-u_max, gains = false, name)

Proportional-Integral-Derivative (PID) controller with output saturation, set-point weighting and integrator anti-windup.

The equation for the control signal is roughly

k(ep + 1/Ti * ∫e + Td * d/dt(ed))
 e = u_r - u_y
 ep = wp*u_r - u_y
-ed = wd*u_r - u_y

where the transfer function for the derivative includes additional filtering, see ? Derivative for more details.

Parameters:

  • k: Proportional gain
  • Ti: [s] Integrator time constant. Set to false to turn off integral action.
  • Td: [s] Derivative time constant. Set to false to turn off derivative action.
  • wp: [0,1] Set-point weighting in the proportional part.
  • wd: [0,1] Set-point weighting in the derivative part.
  • Nd: [1/s] Derivative limit, limits the derivative gain to Nd/Td. Reasonable values are ∈ [8, 20]. A higher value gives a better approximation of an ideal derivative at the expense of higher noise amplification.
  • Ni: Ni*Ti controls the time constant Ta of anti-windup tracking. A common (default) choice is Ta = √(Ti*Td) which is realized by Ni = √(Td / Ti). Anti-windup can be effectively turned off by setting Ni = Inf.
  • gains: If gains = true, Ti and Td will be interpreted as gains with a fundamental PID transfer function on parallel form ki=Ti, kd=Td, k + ki/s + kd*s.

Connectors:

  • reference
  • measurement
  • ctr_output
source
+ed = wd*u_r - u_y

where the transfer function for the derivative includes additional filtering, see ? Derivative for more details.

Parameters:

Connectors:

source diff --git a/dev/API/electrical/index.html b/dev/API/electrical/index.html index 10a1a4717..c5ef38c26 100644 --- a/dev/API/electrical/index.html +++ b/dev/API/electrical/index.html @@ -1,2 +1,2 @@ -Electrical Components · ModelingToolkitStandardLibrary.jl

ModelingToolkitStandardLibrary: Electrical Components

Index

Electrical Utilities

ModelingToolkitStandardLibrary.Electrical.OnePortConstant
OnePort(; name, v = 0.0, i = 0.0)

Component with two electrical pins p and n and current i flows from p to n.

States:

  • v(t): [V] The voltage across component p.v - n.v
  • i(t): [A] The current passing through positive pin

Connectors:

  • p Positive pin
  • n Negative pin
source
ModelingToolkitStandardLibrary.Electrical.DigitalPinFunction
DigitalPin(; name)

A pin in a digital circuit.

States:

  • v(t): [V] The voltage at this pin
  • i(t): [A] The current passing through this pin
  • val(t): The binary value of the pin at this point. A voltage from 0V to 0.8V is a binary value of 0.

A voltage in the range 2.0V to 5.0V is 1. Any other value is X.

source

Analog Components

ModelingToolkitStandardLibrary.Electrical.IdealOpAmpConstant
IdealOpAmp(; name)

Ideal operational amplifier (norator-nullator pair). The ideal OpAmp is a two-port. The left port is fixed to v1 = 0 and i1 = 0 (nullator). At the right port both any voltage v2 and any current i2 are possible (norator).

States:

See TwoPort

Connectors:

  • p1 Positive pin (left port)
  • p2 Positive pin (right port)
  • n1 Negative pin (left port)
  • n2 Negative pin (right port)
source

Analog Sensors

ModelingToolkitStandardLibrary.Electrical.VoltageSensorConstant

VoltageSensor(; name)

Creates a circuit component that measures the voltage across it. Analogous to an ideal voltmeter.

States:

  • v(t): [V] The voltage difference from positive to negative pin p.v - n.v

Connectors:

  • p Positive pin
  • n Negative pin
source
ModelingToolkitStandardLibrary.Electrical.PowerSensorConstant

PowerSensor(; name)

Combines a VoltageSensor and a CurrentSensor to measure the power being consumed by a circuit.

States:

Connectors:

source

Analog Sources

Digital Gates

Missing docstring.

Missing docstring for Not. Check Documenter's build log for details.

Missing docstring.

Missing docstring for And. Check Documenter's build log for details.

Missing docstring.

Missing docstring for Nand. Check Documenter's build log for details.

Missing docstring.

Missing docstring for Or. Check Documenter's build log for details.

Missing docstring.

Missing docstring for Nor. Check Documenter's build log for details.

Missing docstring.

Missing docstring for Xor. Check Documenter's build log for details.

Missing docstring.

Missing docstring for Xnor. Check Documenter's build log for details.

Digital Components

Missing docstring.

Missing docstring for HalfAdder. Check Documenter's build log for details.

Missing docstring.

Missing docstring for FullAdder. Check Documenter's build log for details.

Missing docstring.

Missing docstring for MUX. Check Documenter's build log for details.

Missing docstring.

Missing docstring for DEMUX. Check Documenter's build log for details.

Missing docstring.

Missing docstring for Encoder. Check Documenter's build log for details.

Missing docstring.

Missing docstring for Decoder. Check Documenter's build log for details.

Digital Sources

Missing docstring.

Missing docstring for PulseDiff. Check Documenter's build log for details.

Missing docstring.

Missing docstring for Set. Check Documenter's build log for details.

Missing docstring.

Missing docstring for Reset. Check Documenter's build log for details.

Missing docstring.

Missing docstring for Pulse. Check Documenter's build log for details.

+Electrical Components · ModelingToolkitStandardLibrary.jl

ModelingToolkitStandardLibrary: Electrical Components

Index

Electrical Utilities

ModelingToolkitStandardLibrary.Electrical.OnePortConstant
OnePort(; name, v = 0.0, i = 0.0)

Component with two electrical pins p and n and current i flows from p to n.

States:

  • v(t): [V] The voltage across component p.v - n.v
  • i(t): [A] The current passing through positive pin

Connectors:

  • p Positive pin
  • n Negative pin
source
ModelingToolkitStandardLibrary.Electrical.DigitalPinFunction
DigitalPin(; name)

A pin in a digital circuit.

States:

  • v(t): [V] The voltage at this pin
  • i(t): [A] The current passing through this pin
  • val(t): The binary value of the pin at this point. A voltage from 0V to 0.8V is a binary value of 0.

A voltage in the range 2.0V to 5.0V is 1. Any other value is X.

source

Analog Components

ModelingToolkitStandardLibrary.Electrical.IdealOpAmpConstant
IdealOpAmp(; name)

Ideal operational amplifier (norator-nullator pair). The ideal OpAmp is a two-port. The left port is fixed to v1 = 0 and i1 = 0 (nullator). At the right port both any voltage v2 and any current i2 are possible (norator).

States:

See TwoPort

Connectors:

  • p1 Positive pin (left port)
  • p2 Positive pin (right port)
  • n1 Negative pin (left port)
  • n2 Negative pin (right port)
source

Analog Sensors

ModelingToolkitStandardLibrary.Electrical.VoltageSensorConstant

VoltageSensor(; name)

Creates a circuit component that measures the voltage across it. Analogous to an ideal voltmeter.

States:

  • v(t): [V] The voltage difference from positive to negative pin p.v - n.v

Connectors:

  • p Positive pin
  • n Negative pin
source
ModelingToolkitStandardLibrary.Electrical.PowerSensorConstant

PowerSensor(; name)

Combines a VoltageSensor and a CurrentSensor to measure the power being consumed by a circuit.

States:

Connectors:

source

Analog Sources

Digital Gates

Missing docstring.

Missing docstring for Not. Check Documenter's build log for details.

Missing docstring.

Missing docstring for And. Check Documenter's build log for details.

Missing docstring.

Missing docstring for Nand. Check Documenter's build log for details.

Missing docstring.

Missing docstring for Or. Check Documenter's build log for details.

Missing docstring.

Missing docstring for Nor. Check Documenter's build log for details.

Missing docstring.

Missing docstring for Xor. Check Documenter's build log for details.

Missing docstring.

Missing docstring for Xnor. Check Documenter's build log for details.

Digital Components

Missing docstring.

Missing docstring for HalfAdder. Check Documenter's build log for details.

Missing docstring.

Missing docstring for FullAdder. Check Documenter's build log for details.

Missing docstring.

Missing docstring for MUX. Check Documenter's build log for details.

Missing docstring.

Missing docstring for DEMUX. Check Documenter's build log for details.

Missing docstring.

Missing docstring for Encoder. Check Documenter's build log for details.

Missing docstring.

Missing docstring for Decoder. Check Documenter's build log for details.

Digital Sources

Missing docstring.

Missing docstring for PulseDiff. Check Documenter's build log for details.

Missing docstring.

Missing docstring for Set. Check Documenter's build log for details.

Missing docstring.

Missing docstring for Reset. Check Documenter's build log for details.

Missing docstring.

Missing docstring for Pulse. Check Documenter's build log for details.

diff --git a/dev/API/hydraulic/index.html b/dev/API/hydraulic/index.html index 8b97e9359..1c41a3401 100644 --- a/dev/API/hydraulic/index.html +++ b/dev/API/hydraulic/index.html @@ -1,5 +1,5 @@ -Hydraulic Components · ModelingToolkitStandardLibrary.jl

ModelingToolkit Standard Library: Hydraulic Components

Index

IsothermalCompressible Components

IsothermalCompressible Utils

ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.HydraulicFluidFunction
HydraulicFluid(; density = 997, bulk_modulus = 2.09e9, viscosity = 0.0010016, gas_density = 0.0073955, gas_pressure = -1000, n = 1, let_gas = 1, name)

Fluid parameter setter for isothermal compressible fluid domain. Defaults given for water at 20°C and 0Pa gage (1atm absolute) reference pressure. Density is modeled using the Tait equation of state. For pressures below the reference pressure, density is linearly interpolated to the gas state (when let_gas is set to 1), this helps prevent pressures from going below the reference pressure.

Parameters:

  • ρ: [kg/m^3] fluid density at 0Pa reference gage pressure (set by density argument)
  • Β: [Pa] fluid bulk modulus describing the compressibility (set by bulk_modulus argument)
  • μ: [Pa*s] or [kg/m-s] fluid dynamic viscosity (set by viscosity argument)
  • n: density exponent
  • let_gas: set to 1 to allow fluid to transition from liquid to gas (for density calculation only)
  • ρ_gas: [kg/m^3] density of fluid in gas state at reference gage pressure p_gas (set by gas_density argument)
  • p_gas: [Pa] reference pressure (set by gas_pressure argument)
source
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.friction_factorFunction
friction_factor(dm, area, d_h, viscosity, shape_factor)

Calculates the friction factor $f$ for fully developed flow in a tube such that $Δp = f \cdot \rho \frac{u^2}{2} \frac{l}{d_h}$ where

  • $Δp$: [Pa] is the pressure difference over the tube length $l$
  • $\rho$: [kg/m^3] is the average fluid density
  • $u$: [m/s] is the average fluid velocity
  • $l$: [m] is the tube length

The friction factor is calculated for laminar and turbulent flow with a transition region between Reynolds number 2000 to 3000. Turbulent flow equation is for smooth tubes, valid for the Reynolds number range up to 5e6.

Arguments:

  • dm: [kg/s] mass flow
  • area: [m^2] tube cross sectional area
  • d_h: [m] tube hydraulic diameter. For circular tubes d_h is the tube diameter, otherwise it can be found from 4*area/perimeter
  • density: [kg/m^3] fluid density
  • viscosity: [Pa*s] or [kg/m-s] fluid dynamic viscosity
  • shape_factor: the constant defining the laminar fully developed constant f*Re related to the shape of the tube cross section

Reference: Introduction to Fluid Mechanics, Fox & McDonald, 5th Edition, equations 8.19 and 8.21

source

IsothermalCompressible Components

ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.TubeBaseFunction
TubeBase(add_inertia = true; p_int, area, length_int, head_factor = 1, perimeter = 2 * sqrt(area * pi), shape_factor = 64, name)

Variable length internal flow model of the fully developed incompressible flow friction. Includes optional inertia term when add_inertia = true to model wave propagation. Hydraulic ports have equal flow but variable pressure. Density is averaged over the pressures, used to calculated average flow velocity and flow friction.

States:

  • x: [m] length of the pipe
  • ddm: [kg/s^2] Rate of change of mass flow rate in control volume.

Parameters:

  • p_int: [Pa] initial pressure
  • area: [m^2] tube cross sectional area
  • length_int: [m] initial tube length
  • perimeter: [m] perimeter of the pipe cross section (needed only for non-circular pipes)
  • shape_factor: shape factor, see friction_factor function
  • head_factor: effective length multiplier, used to account for addition friction from flow development and additional friction such as pipe bends, entrance/exit lossses, etc.

Connectors:

  • port_a: hydraulic port
  • port_b: hydraulic port
source
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.TubeFunction
Tube(N, add_inertia=true; p_int, area, length, head_factor=1, perimeter = 2 * sqrt(area * pi), shape_factor = 64, name)

Constant length internal flow model discretized by N (FixedVolume: N, TubeBase:N-1) which models the fully developed flow friction, compressibility (when N>1), and inertia effects when add_inertia = true. See TubeBase and FixedVolume for more information.

Parameters:

  • p_int: [Pa] initial pressure
  • area: [m^2] tube cross sectional area
  • length: [m] real length of the tube
  • perimeter: [m] perimeter of the pipe cross section (needed only for non-circular pipes)
  • shape_factor: shape factor, see friction_factor function
  • head_factor: effective length multiplier, used to account for addition friction from flow development and additional friction such as pipe bends, entrance/exit lossses, etc.

Connectors:

  • port_a: hydraulic port
  • port_b: hydraulic port
source
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.DynamicVolumeFunction

DynamicVolume(N, addinertia=true; pint, area, xint = 0, xmax, xmin = 0, xdamp = xmin, direction = +1, perimeter = 2 * sqrt(area * pi), shapefactor = 64, headfactor = 1, Cd = 1e2, Cdreverse = Cd, name)

Volume with moving wall with flange connector for converting hydraulic energy to 1D mechanical. The direction argument aligns the mechanical port with the hydraulic port, useful when connecting two dynamic volumes together in oppsing directions to create an actuator.

     ┌─────────────────┐ ───
+Hydraulic Components · ModelingToolkitStandardLibrary.jl

ModelingToolkit Standard Library: Hydraulic Components

Index

IsothermalCompressible Components

IsothermalCompressible Utils

ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.HydraulicFluidFunction
HydraulicFluid(; density = 997, bulk_modulus = 2.09e9, viscosity = 0.0010016, gas_density = 0.0073955, gas_pressure = -1000, n = 1, let_gas = 1, name)

Fluid parameter setter for isothermal compressible fluid domain. Defaults given for water at 20°C and 0Pa gage (1atm absolute) reference pressure. Density is modeled using the Tait equation of state. For pressures below the reference pressure, density is linearly interpolated to the gas state (when let_gas is set to 1), this helps prevent pressures from going below the reference pressure.

Parameters:

  • ρ: [kg/m^3] fluid density at 0Pa reference gage pressure (set by density argument)
  • Β: [Pa] fluid bulk modulus describing the compressibility (set by bulk_modulus argument)
  • μ: [Pa*s] or [kg/m-s] fluid dynamic viscosity (set by viscosity argument)
  • n: density exponent
  • let_gas: set to 1 to allow fluid to transition from liquid to gas (for density calculation only)
  • ρ_gas: [kg/m^3] density of fluid in gas state at reference gage pressure p_gas (set by gas_density argument)
  • p_gas: [Pa] reference pressure (set by gas_pressure argument)
source
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.friction_factorFunction
friction_factor(dm, area, d_h, viscosity, shape_factor)

Calculates the friction factor $f$ for fully developed flow in a tube such that $Δp = f \cdot \rho \frac{u^2}{2} \frac{l}{d_h}$ where

  • $Δp$: [Pa] is the pressure difference over the tube length $l$
  • $\rho$: [kg/m^3] is the average fluid density
  • $u$: [m/s] is the average fluid velocity
  • $l$: [m] is the tube length

The friction factor is calculated for laminar and turbulent flow with a transition region between Reynolds number 2000 to 3000. Turbulent flow equation is for smooth tubes, valid for the Reynolds number range up to 5e6.

Arguments:

  • dm: [kg/s] mass flow
  • area: [m^2] tube cross sectional area
  • d_h: [m] tube hydraulic diameter. For circular tubes d_h is the tube diameter, otherwise it can be found from 4*area/perimeter
  • density: [kg/m^3] fluid density
  • viscosity: [Pa*s] or [kg/m-s] fluid dynamic viscosity
  • shape_factor: the constant defining the laminar fully developed constant f*Re related to the shape of the tube cross section

Reference: Introduction to Fluid Mechanics, Fox & McDonald, 5th Edition, equations 8.19 and 8.21

source

IsothermalCompressible Components

ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.TubeBaseFunction
TubeBase(add_inertia = true; p_int, area, length_int, head_factor = 1, perimeter = 2 * sqrt(area * pi), shape_factor = 64, name)

Variable length internal flow model of the fully developed incompressible flow friction. Includes optional inertia term when add_inertia = true to model wave propagation. Hydraulic ports have equal flow but variable pressure. Density is averaged over the pressures, used to calculated average flow velocity and flow friction.

States:

  • x: [m] length of the pipe
  • ddm: [kg/s^2] Rate of change of mass flow rate in control volume.

Parameters:

  • p_int: [Pa] initial pressure
  • area: [m^2] tube cross sectional area
  • length_int: [m] initial tube length
  • perimeter: [m] perimeter of the pipe cross section (needed only for non-circular pipes)
  • shape_factor: shape factor, see friction_factor function
  • head_factor: effective length multiplier, used to account for addition friction from flow development and additional friction such as pipe bends, entrance/exit lossses, etc.

Connectors:

  • port_a: hydraulic port
  • port_b: hydraulic port
source
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.TubeFunction
Tube(N, add_inertia=true; p_int, area, length, head_factor=1, perimeter = 2 * sqrt(area * pi), shape_factor = 64, name)

Constant length internal flow model discretized by N (FixedVolume: N, TubeBase:N-1) which models the fully developed flow friction, compressibility (when N>1), and inertia effects when add_inertia = true. See TubeBase and FixedVolume for more information.

Parameters:

  • p_int: [Pa] initial pressure
  • area: [m^2] tube cross sectional area
  • length: [m] real length of the tube
  • perimeter: [m] perimeter of the pipe cross section (needed only for non-circular pipes)
  • shape_factor: shape factor, see friction_factor function
  • head_factor: effective length multiplier, used to account for addition friction from flow development and additional friction such as pipe bends, entrance/exit lossses, etc.

Connectors:

  • port_a: hydraulic port
  • port_b: hydraulic port
source
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.DynamicVolumeFunction

DynamicVolume(N, addinertia=true; pint, area, xint = 0, xmax, xmin = 0, xdamp = xmin, direction = +1, perimeter = 2 * sqrt(area * pi), shapefactor = 64, headfactor = 1, Cd = 1e2, Cdreverse = Cd, name)

Volume with moving wall with flange connector for converting hydraulic energy to 1D mechanical. The direction argument aligns the mechanical port with the hydraulic port, useful when connecting two dynamic volumes together in oppsing directions to create an actuator.

     ┌─────────────────┐ ───
      │                 │  ▲
                        │  │
 dm ────►               │  │ area
@@ -7,4 +7,4 @@
      │                 │  ▼
      └─────────────────┤ ───
                        │
-                       └─► x (= ∫ flange.v * direction)

Features:

  • volume discretization with flow resistance and inertia: use N to control number of volume and resistance elements. Set N=0 to turn off volume discretization. See TubeBase for more information about flow resistance.
  • minimum volume flow shutoff with damping and directional resistance. Use reversible=false when problem defines volume position x and solves for dm to prevent numerical instability.

Parameters:

volume

  • p_int: [Pa] initial pressure

  • area: [m^2] moving wall area

  • x_int: [m] initial wall position

  • x_max: [m] max wall position, needed for volume discretization to apply the correct volume sizing as a function of x

  • x_min: [m] wall position that shuts off flow and prevents negative volume.

  • x_damp: [m] wall position that initiates a linear damping region before reaching full flow shut off. Helps provide a smooth end stop.

  • direction: [+/-1] applies the direction conversion from the flange to x

flow resistance

  • perimeter: [m] perimeter of the cross section (needed only for non-circular volumes)
  • shape_factor: shape factor, see friction_factor function
  • head_factor: effective length multiplier, used to account for addition friction from flow development and additional friction such as pipe bends, entrance/exit lossses, etc.

flow shut off and damping

  • Cd: discharge coefficient for flow out of the volume. Note: area is 1m² when valve is fully open. Ensure this does not induce unwanted flow resistance.
  • Cd_reverse: discharge coefficient for flow into the volume. Use a lower value to allow easy wall release, in some cases the wall can "stick".

Connectors:

  • port: hydraulic port
  • flange: mechanical translational port
source

IsothermalCompressible Sources

+ └─► x (= ∫ flange.v * direction)

Features:

  • volume discretization with flow resistance and inertia: use N to control number of volume and resistance elements. Set N=0 to turn off volume discretization. See TubeBase for more information about flow resistance.
  • minimum volume flow shutoff with damping and directional resistance. Use reversible=false when problem defines volume position x and solves for dm to prevent numerical instability.

Parameters:

volume

  • p_int: [Pa] initial pressure

  • area: [m^2] moving wall area

  • x_int: [m] initial wall position

  • x_max: [m] max wall position, needed for volume discretization to apply the correct volume sizing as a function of x

  • x_min: [m] wall position that shuts off flow and prevents negative volume.

  • x_damp: [m] wall position that initiates a linear damping region before reaching full flow shut off. Helps provide a smooth end stop.

  • direction: [+/-1] applies the direction conversion from the flange to x

flow resistance

  • perimeter: [m] perimeter of the cross section (needed only for non-circular volumes)
  • shape_factor: shape factor, see friction_factor function
  • head_factor: effective length multiplier, used to account for addition friction from flow development and additional friction such as pipe bends, entrance/exit lossses, etc.

flow shut off and damping

  • Cd: discharge coefficient for flow out of the volume. Note: area is 1m² when valve is fully open. Ensure this does not induce unwanted flow resistance.
  • Cd_reverse: discharge coefficient for flow into the volume. Use a lower value to allow easy wall release, in some cases the wall can "stick".

Connectors:

  • port: hydraulic port
  • flange: mechanical translational port
source

IsothermalCompressible Sources

diff --git a/dev/API/linear_analysis/13e8f9d6.svg b/dev/API/linear_analysis/01e9a6f3.svg similarity index 84% rename from dev/API/linear_analysis/13e8f9d6.svg rename to dev/API/linear_analysis/01e9a6f3.svg index 83f6f607b..09f2524b6 100644 --- a/dev/API/linear_analysis/13e8f9d6.svg +++ b/dev/API/linear_analysis/01e9a6f3.svg @@ -1,50 +1,50 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/API/linear_analysis/ba6b679c.svg b/dev/API/linear_analysis/4beb0d98.svg similarity index 87% rename from dev/API/linear_analysis/ba6b679c.svg rename to dev/API/linear_analysis/4beb0d98.svg index ec1d999bf..a167f6001 100644 --- a/dev/API/linear_analysis/ba6b679c.svg +++ b/dev/API/linear_analysis/4beb0d98.svg @@ -1,78 +1,78 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - + - + diff --git a/dev/API/linear_analysis/index.html b/dev/API/linear_analysis/index.html index 453d20f39..91a1860ce 100644 --- a/dev/API/linear_analysis/index.html +++ b/dev/API/linear_analysis/index.html @@ -20,7 +20,7 @@ S = ss(matrices_S...) T = ss(matrices_T...) bodeplot([S, T], lab = ["S" "" "T" ""], plot_title = "Bode plot of sensitivity functions", - margin = 5Plots.mm)Example block output

The sensitivity functions obtained this way should be equivalent to the ones obtained with the code below

using ControlSystemsBase
+    margin = 5Plots.mm)
Example block output

The sensitivity functions obtained this way should be equivalent to the ones obtained with the code below

using ControlSystemsBase
 P = tf(1.0, [1, 1]) |> ss
 C = 1                      # Negative feedback assumed in ControlSystems
 S = sensitivity(P, C)      # or feedback(1, P*C)
@@ -70,11 +70,11 @@
 ----------
 1.0s + 2.0
 
-Continuous-time transfer function model

Gain and phase margins

Further linear analysis can be performed using the analysis methods from ControlSystemsBase. For example, calculating the gain and phase margins of a system can be done using

margin(P)
(wgm = [NaN;;], gm = [Inf;;], wpm = [NaN;;], pm = [Inf;;])

(they are infinite for this system). A Nyquist plot can be produced using

nyquistplot(P)
Example block output

Index

ModelingToolkitStandardLibrary.Blocks.get_comp_sensitivityFunction
get_comp_sensitivity(sys, ap::AnalysisPoint; kwargs)
-get_comp_sensitivity(sys, ap_name::Symbol; kwargs)

Compute the complementary sensitivity function in analysis point ap. The complementary sensitivity function is obtained by introducing an infinitesimal perturbation d at the output of ap, linearizing the system and computing the transfer function between d and the input of ap.

Experimental

The analysis-point interface is currently experimental and at any time subject to breaking changes not respecting semantic versioning.

Arguments:

  • kwargs: Are sent to ModelingToolkit.linearize

See also get_sensitivity, get_looptransfer.

source
ModelingToolkitStandardLibrary.Blocks.get_looptransferFunction
get_looptransfer(sys, ap::AnalysisPoint; kwargs)
-get_looptransfer(sys, ap_name::Symbol; kwargs)

Compute the (linearized) loop-transfer function in analysis point ap, from ap.out to ap.in.

Negative feedback

Feedback loops often use negative feedback, and the computed loop-transfer function will in this case have the negative feedback included. Standard analysis tools often assume a loop-transfer function without the negative gain built in, and the result of this function may thus need negation before use.

Experimental

The analysis-point interface is currently experimental and at any time subject to breaking changes not respecting semantic versioning.

Arguments:

  • kwargs: Are sent to ModelingToolkit.linearize

See also get_sensitivity, get_comp_sensitivity, open_loop.

source
ModelingToolkitStandardLibrary.Blocks.get_sensitivityFunction
get_sensitivity(sys, ap::AnalysisPoint; kwargs)
-get_sensitivity(sys, ap_name::Symbol; kwargs)

Compute the sensitivity function in analysis point ap. The sensitivity function is obtained by introducing an infinitesimal perturbation d at the input of ap, linearizing the system and computing the transfer function between d and the output of ap.

Experimental

The analysis-point interface is currently experimental and at any time subject to breaking changes not respecting semantic versioning.

Arguments:

  • kwargs: Are sent to ModelingToolkit.linearize

See also get_comp_sensitivity, get_looptransfer.

source
ModelingToolkitStandardLibrary.Blocks.open_loopMethod
open_sys = open_loop(sys, ap::AnalysisPoint; kwargs)
-open_sys = open_loop(sys, ap_name::Symbol; kwargs)

Open the loop at analysis point ap by breaking the connection through ap.

open_sys will have u ~ ap.out as input and y ~ ap.in as output.

Experimental

The analysis-point interface is currently experimental and at any time subject to breaking changes not respecting semantic versioning.

Arguments:

  • kwargs: Are sent to ModelingToolkit.linearize

See also get_sensitivity, get_comp_sensitivity, get_looptransfer.

source
ModelingToolkitStandardLibrary.Blocks.AnalysisPointMethod
AnalysisPoint(in, out, name::Symbol)
+Continuous-time transfer function model

Gain and phase margins

Further linear analysis can be performed using the analysis methods from ControlSystemsBase. For example, calculating the gain and phase margins of a system can be done using

margin(P)
(wgm = [NaN;;], gm = [Inf;;], wpm = [NaN;;], pm = [Inf;;])

(they are infinite for this system). A Nyquist plot can be produced using

nyquistplot(P)
Example block output

Index

ModelingToolkitStandardLibrary.Blocks.get_comp_sensitivityFunction
get_comp_sensitivity(sys, ap::AnalysisPoint; kwargs)
+get_comp_sensitivity(sys, ap_name::Symbol; kwargs)

Compute the complementary sensitivity function in analysis point ap. The complementary sensitivity function is obtained by introducing an infinitesimal perturbation d at the output of ap, linearizing the system and computing the transfer function between d and the input of ap.

Experimental

The analysis-point interface is currently experimental and at any time subject to breaking changes not respecting semantic versioning.

Arguments:

  • kwargs: Are sent to ModelingToolkit.linearize

See also get_sensitivity, get_looptransfer.

source
ModelingToolkitStandardLibrary.Blocks.get_looptransferFunction
get_looptransfer(sys, ap::AnalysisPoint; kwargs)
+get_looptransfer(sys, ap_name::Symbol; kwargs)

Compute the (linearized) loop-transfer function in analysis point ap, from ap.out to ap.in.

Negative feedback

Feedback loops often use negative feedback, and the computed loop-transfer function will in this case have the negative feedback included. Standard analysis tools often assume a loop-transfer function without the negative gain built in, and the result of this function may thus need negation before use.

Experimental

The analysis-point interface is currently experimental and at any time subject to breaking changes not respecting semantic versioning.

Arguments:

  • kwargs: Are sent to ModelingToolkit.linearize

See also get_sensitivity, get_comp_sensitivity, open_loop.

source
ModelingToolkitStandardLibrary.Blocks.get_sensitivityFunction
get_sensitivity(sys, ap::AnalysisPoint; kwargs)
+get_sensitivity(sys, ap_name::Symbol; kwargs)

Compute the sensitivity function in analysis point ap. The sensitivity function is obtained by introducing an infinitesimal perturbation d at the input of ap, linearizing the system and computing the transfer function between d and the output of ap.

Experimental

The analysis-point interface is currently experimental and at any time subject to breaking changes not respecting semantic versioning.

Arguments:

  • kwargs: Are sent to ModelingToolkit.linearize

See also get_comp_sensitivity, get_looptransfer.

source
ModelingToolkitStandardLibrary.Blocks.open_loopMethod
open_sys = open_loop(sys, ap::AnalysisPoint; kwargs)
+open_sys = open_loop(sys, ap_name::Symbol; kwargs)

Open the loop at analysis point ap by breaking the connection through ap.

open_sys will have u ~ ap.out as input and y ~ ap.in as output.

Experimental

The analysis-point interface is currently experimental and at any time subject to breaking changes not respecting semantic versioning.

Arguments:

  • kwargs: Are sent to ModelingToolkit.linearize

See also get_sensitivity, get_comp_sensitivity, get_looptransfer.

source
ModelingToolkitStandardLibrary.Blocks.AnalysisPointMethod
AnalysisPoint(in, out, name::Symbol)
 AnalysisPoint(in, out; name::Symbol)
 AnalysisPoint(name::Symbol)

Create an AnalysisPoint for linear analysis. Analysis points can also be created automatically by calling

connect(in, :ap_name, out)
Experimental

The analysis-point interface is currently experimental and at any time subject to breaking changes not respecting semantic versioning.

Arguments:

  • in: A connector of type RealOutput.
  • out: A connector of type RealInput.
  • name: The name of the analysis point.

See also get_sensitivity, get_comp_sensitivity, get_looptransfer, open_loop

Example

using ModelingToolkitStandardLibrary.Blocks
 @named P = FirstOrder(k = 1, T = 1)
@@ -92,7 +92,7 @@
 P = tf(1.0, [1, 1])
 C = 1                      # Negative feedback assumed in ControlSystems
 S = sensitivity(P, C)      # or feedback(1, P*C)
-T = comp_sensitivity(P, C) # or feedback(P*C)
source
ModelingToolkit.linearizeFunction
(; A, B, C, D), simplified_sys = linearize(sys, inputs, outputs;    t=0.0, op = Dict(), allow_input_derivatives = false, zero_dummy_der=false, kwargs...)
+T = comp_sensitivity(P, C) # or feedback(P*C)
source
ModelingToolkit.linearizeFunction
(; A, B, C, D), simplified_sys = linearize(sys, inputs, outputs;    t=0.0, op = Dict(), allow_input_derivatives = false, zero_dummy_der=false, kwargs...)
 (; A, B, C, D)                 = linearize(simplified_sys, lin_fun; t=0.0, op = Dict(), allow_input_derivatives = false, zero_dummy_der=false)

Linearize sys between inputs and outputs, both vectors of variables. Return a NamedTuple with the matrices of a linear statespace representation on the form

\[\begin{aligned} ẋ &= Ax + Bu\\ y &= Cx + Du @@ -154,4 +154,4 @@ ## Symbolic linearization lsys_sym, _ = ModelingToolkit.linearize_symbolic(cl, [f.u], [p.x]) -@assert substitute(lsys_sym.A, ModelingToolkit.defaults(cl)) == lsys.A

source
ModelingToolkit.linearize(sys, input_name::Symbol, output_name; kwargs...)

Linearize a system between two analysis points. To get a loop-transfer function, see get_looptransfer.

The output is allowed to be either an analysis-point name, or a vector of symbolic variables like the standard interface to linearize. The input must be an analysis-point name.

source
+@assert substitute(lsys_sym.A, ModelingToolkit.defaults(cl)) == lsys.Asource
ModelingToolkit.linearize(sys, input_name::Symbol, output_name; kwargs...)

Linearize a system between two analysis points. To get a loop-transfer function, see get_looptransfer.

The output is allowed to be either an analysis-point name, or a vector of symbolic variables like the standard interface to linearize. The input must be an analysis-point name.

source
diff --git a/dev/API/magnetic/index.html b/dev/API/magnetic/index.html index d1c327fce..8d6ece527 100644 --- a/dev/API/magnetic/index.html +++ b/dev/API/magnetic/index.html @@ -1,2 +1,2 @@ -Magnetic Components · ModelingToolkitStandardLibrary.jl

ModelingToolkitStandardLibrary: Magnetic Components

Index

Flux Tubes

Flux Tube Utilities

ModelingToolkitStandardLibrary.Magnetic.FluxTubes.TwoPortConstant
TwoPort(; name, V_m = 0.0, Phi = 0.0)

Partial component with magnetic potential difference between two magnetic ports p and n and magnetic flux Phi from p to n.

Parameters:

  • V_m: Initial magnetic potential difference between both ports
  • Phi: Initial magnetic flux from portp to portn
source

Basic Flux Tube Blocks

ModelingToolkitStandardLibrary.Magnetic.FluxTubes.EddyCurrentConstant
EddyCurrent(;name, Phi, rho = 0.098e-6, l = 1, A = 1)

For modelling of eddy current in a conductive magnetic flux tube. Initial magnetic flux flowing into the port_p can be set with Phi ([Wb])

Parameters:

  • rho: [ohm * m] Resistivity of flux tube material (default: Iron at 20degC)
  • l: [m] Average length of eddy current path
  • A: [m^2] Cross sectional area of eddy current path
source

Flux Tube Sources

+Magnetic Components · ModelingToolkitStandardLibrary.jl

ModelingToolkitStandardLibrary: Magnetic Components

Index

Flux Tubes

Flux Tube Utilities

ModelingToolkitStandardLibrary.Magnetic.FluxTubes.TwoPortConstant
TwoPort(; name, V_m = 0.0, Phi = 0.0)

Partial component with magnetic potential difference between two magnetic ports p and n and magnetic flux Phi from p to n.

Parameters:

  • V_m: Initial magnetic potential difference between both ports
  • Phi: Initial magnetic flux from portp to portn
source

Basic Flux Tube Blocks

ModelingToolkitStandardLibrary.Magnetic.FluxTubes.EddyCurrentConstant
EddyCurrent(;name, Phi, rho = 0.098e-6, l = 1, A = 1)

For modelling of eddy current in a conductive magnetic flux tube. Initial magnetic flux flowing into the port_p can be set with Phi ([Wb])

Parameters:

  • rho: [ohm * m] Resistivity of flux tube material (default: Iron at 20degC)
  • l: [m] Average length of eddy current path
  • A: [m^2] Cross sectional area of eddy current path
source

Flux Tube Sources

diff --git a/dev/API/mechanical/index.html b/dev/API/mechanical/index.html index 28eeca953..e2eec3ed3 100644 --- a/dev/API/mechanical/index.html +++ b/dev/API/mechanical/index.html @@ -1,2 +1,2 @@ -Mechanical Components · ModelingToolkitStandardLibrary.jl

ModelingToolkit Standard Library: Mechanical Components

Index

Rotational Components

Rotational Utils

ModelingToolkitStandardLibrary.Mechanical.Rotational.PartialCompliantWithRelativeStatesConstant
PartialCompliantWithRelativeStates(; name, phi_rel = 0.0, tau = 0.0)

Partial model for the compliant connection of two rotational 1-dim. shaft flanges where the relative angle and speed are used as preferred states

States:

  • phi_rel(t): [rad] Relative rotation angle (= flangeb.phi - flangea.phi). It accepts an initial value, which defaults to 0.0.
  • w_rel(t): [rad/s] Relative angular velocity (= D(phi_rel)). It accepts an initial value, which defaults to 0.0.
  • a_rel(t): [rad/s²] Relative angular acceleration (= D(w_rel)). It accepts an initial value, which defaults to 0.0.
  • tau(t): [N.m] Torque between flanges (= flange_b.tau). It accepts an initial value, which defaults to 0.0.

Connectors:

source
ModelingToolkitStandardLibrary.Mechanical.Rotational.PartialElementaryTwoFlangesAndSupport2Function
PartialElementaryTwoFlangesAndSupport2(;name, use_support=false)

Partial model for a component with two rotational 1-dim. shaft flanges and a support used for textual modeling, i.e., for elementary models

States:

  • phi_support(t): [rad] Absolute angle of support flange

Connectors:

Parameters:

  • use_support: If support flange enabled, otherwise implicitly grounded
source
ModelingToolkitStandardLibrary.Mechanical.Rotational.PartialCompliantConstant
PartialCompliant(;  name, phi_rel = 0.0, tau = 0.0)

Partial model for the compliant connection of two rotational 1-dim. shaft flanges.

States:

  • phi_rel(t): [rad] Relative rotation angle (flange_b.phi - flange_a.phi). It accepts an initial value, which defaults to 0.0.
  • tau(t): [N.m] Torque between flanges (flange_b.tau). It accepts an initial value, which defaults to 0.0.

Connectors:

source

Rotational Core Components

ModelingToolkitStandardLibrary.Mechanical.Rotational.InertiaConstant
Inertia(;name, J, phi = 0.0, w = 0.0, a = 0.0)

1D-rotational component with inertia.

States:

  • phi: [rad] Absolute rotation angle of component
  • w: [rad/s] Absolute angular velocity of component (= D(phi))
  • a: [rad/s²] Absolute angular acceleration of component (= D(w))

Connectors:

Parameters:

  • J: [kg·m²] Moment of inertia
source
ModelingToolkitStandardLibrary.Mechanical.Rotational.SpringConstant
Spring(; name, c, phi_rel0 = 0.0)

Linear 1D rotational spring

States:

  • phi_rel(t): [rad] Relative rotation angle (flange_b.phi - flange_a.phi)
  • tau(t): [N.m] Torque between flanges (flange_b.tau)

Connectors:

Parameters:

  • c: [N.m/rad] Spring constant
  • phi_rel0: [rad] Unstretched spring angle
source
ModelingToolkitStandardLibrary.Mechanical.Rotational.DamperConstant
Damper(; name, d)

Linear 1D rotational damper

States:

  • phi_rel(t): [rad] Relative rotation angle (= flangeb.phi - flangea.phi)
  • w_rel(t): [rad/s] Relative angular velocity (= D(phi_rel))
  • a_rel(t): [rad/s²] Relative angular acceleration (= D(w_rel))
  • tau(t): [N.m] Torque between flanges (= flange_b.tau)

Connectors:

Parameters:

  • d: [N.m.s/rad] Damping constant
source
ModelingToolkitStandardLibrary.Mechanical.Rotational.SpringDamperConstant
SpringDamper(; name, d)

Linear 1D rotational spring and damper

States:

  • phi_rel(t): [rad] Relative rotation angle (= flangeb.phi - flangea.phi)
  • w_rel(t): [rad/s] Relative angular velocity (= D(phi_rel))
  • a_rel(t): [rad/s²] Relative angular acceleration (= D(w_rel))
  • tau(t): [N.m] Torque between flanges (= flange_b.tau)

Connectors:

Parameters:

  • d: [N.m.s/rad] Damping constant
  • c: [N.m/rad] Spring constant
  • phi_rel0: [rad] Unstretched spring angle
source
ModelingToolkitStandardLibrary.Mechanical.Rotational.IdealGearConstant
IdealGear(; name, ratio, use_support = false)

Ideal gear without inertia.

This element characterizes any type of gear box which is fixed in the ground and which has one driving shaft and one driven shaft.

States:

  • phi_a(t): [rad] Relative angle between shaft a and the support
  • phi_b(t): [rad] Relative angle between shaft b and the support

Connectors:

Parameters:

  • ratio: Transmission ratio (flangea.phi/flangeb.phi)
  • use_support: If support flange enabled, otherwise implicitly grounded. By default it is false
source
ModelingToolkitStandardLibrary.Mechanical.Rotational.RotationalFrictionConstant
RotationalFriction(; name, f, tau_c, w_brk, tau_brk)

Models rotational friction with Stribeck effect, Coulomb friction and viscous friction between the two flanges. The friction torque is a function of the relative angular velocity between flange_a and flange_b.

Friction model: "Armstrong, B. and C.C. de Wit, Friction Modeling and Compensation, The Control Handbook, CRC Press, 1995."

States:

  • phi_rel(t): [rad] Relative rotation angle (= flange_b.phi - flange_a.phi)
  • w_rel(t): [rad/s] Relative angular velocity (= D(phi_rel))
  • a_rel(t): [rad/s²] Relative angular acceleration (= D(w_rel))
  • tau(t): [N.m] Torque between flanges (= flange_b.tau)

Connectors:

Parameters:

  • f: [N⋅m/(rad/s)] Viscous friction coefficient
  • tau_c: [N⋅m] Coulomb friction torque
  • w_brk: [rad/s] Breakaway friction velocity
  • tau_brk: [N⋅m] Breakaway friction torque
source

Rotational Sources

ModelingToolkitStandardLibrary.Mechanical.Rotational.SpeedFunction
Speed(; name, use_support = false, exact = false, f_crit = 50)

Forced movement of a flange according to a reference angular velocity signal

States:

  • phi_support(t): [rad] Absolute angle of support flange"

Connectors:

  • flange Flange
  • w_ref RealInput Reference angular velocity of flange with respect to support as input signal needs to be continuously differential

Parameters:

  • use_support: If support flange enabled, otherwise implicitly grounded
  • exact: true/false exact treatment/filtering the input signal
  • tau_filt: [rad/s] if exact=false, Time constant of low-pass filter to filter input signal
source

Rotational Sensors

Translational Components

Translational Utils

Translational Core Components

ModelingToolkitStandardLibrary.Mechanical.Translational.MassFunction
Mass(; name, v_0 = 0.0, m, s = nothing, g = nothing)

Sliding mass with inertia

Parameters:

  • m: [kg] mass of sliding body
  • v_0: [m/s] Initial value of absolute linear velocity of sliding mass (default 0 m/s)
  • s: [m] initial value of absolute position of sliding mass (optional)
  • g: [m/s²] gravity field acting on the mass, positive value acts in the positive direction (optional)

States:

  • v: [m/s] absolute linear velocity of sliding mass
  • s: [m] absolute position of sliding mass (optional with parameter s)

Connectors:

  • flange: 1-dim. translational flange
source
ModelingToolkitStandardLibrary.Mechanical.Translational.SpringFunction
Spring(; name, k, delta_s = 0.0,  va=0.0, v_b_0=0.0)

Linear 1D translational spring

Parameters:

  • k: [N/m] Spring constant
  • delta_s: initial spring stretch
  • va: [m/s] Initial value of absolute linear velocity at flange_a (default 0 m/s)
  • v_b_0: [m/s] Initial value of absolute linear velocity at flange_b (default 0 m/s)

Connectors:

  • flange_a: 1-dim. translational flange on one side of spring
  • flange_b: 1-dim. translational flange on opposite side of spring
source
ModelingToolkitStandardLibrary.Mechanical.Translational.DamperConstant
Damper(; name, d, flange_a.v = 0.0, flange_b.v = 0.0)

Linear 1D translational damper

Parameters:

  • d: [N.s/m] Damping constant

Connectors:

  • flange_a: 1-dim. translational flange on one side of damper. Initial value of state v is set to 0.0 m/s.
  • flange_b: 1-dim. translational flange on opposite side of damper. Initial value of state v is set to 0.0 m/s.
source

Translational Sources

ModelingToolkitStandardLibrary.Mechanical.Translational.PositionFunction
Position(solves_force = true; name)

Linear 1D position input source. Set solves_force=false to force input force to 0 (i.e. only the position is given, the respective force needed is already provided elsewhere in the model).

Connectors:

  • flange: 1-dim. translational flange
  • s: real input
source
ModelingToolkitStandardLibrary.Mechanical.Translational.VelocityFunction
Velocity(solves_force = true; name)

Linear 1D position input source. Set solves_force=false to force input force to 0 (i.e. only the velocity is given, the respective force needed is already provided elsewhere in the model).

Connectors:

  • flange: 1-dim. translational flange
  • v: real input
source
ModelingToolkitStandardLibrary.Mechanical.Translational.AccelerationFunction

Acceleration(solves_force = true; name)

Linear 1D position input source. Set solves_force=false to force input force to 0 (i.e. only the acceleration is given, the respective force needed is already provided elsewhere in the model).

Connectors:

  • flange: 1-dim. translational flange
  • a: real input
source

Translational Sensors

+Mechanical Components · ModelingToolkitStandardLibrary.jl

ModelingToolkit Standard Library: Mechanical Components

Index

Rotational Components

Rotational Utils

ModelingToolkitStandardLibrary.Mechanical.Rotational.PartialCompliantWithRelativeStatesConstant
PartialCompliantWithRelativeStates(; name, phi_rel = 0.0, tau = 0.0)

Partial model for the compliant connection of two rotational 1-dim. shaft flanges where the relative angle and speed are used as preferred states

States:

  • phi_rel(t): [rad] Relative rotation angle (= flangeb.phi - flangea.phi). It accepts an initial value, which defaults to 0.0.
  • w_rel(t): [rad/s] Relative angular velocity (= D(phi_rel)). It accepts an initial value, which defaults to 0.0.
  • a_rel(t): [rad/s²] Relative angular acceleration (= D(w_rel)). It accepts an initial value, which defaults to 0.0.
  • tau(t): [N.m] Torque between flanges (= flange_b.tau). It accepts an initial value, which defaults to 0.0.

Connectors:

source
ModelingToolkitStandardLibrary.Mechanical.Rotational.PartialElementaryTwoFlangesAndSupport2Function
PartialElementaryTwoFlangesAndSupport2(;name, use_support=false)

Partial model for a component with two rotational 1-dim. shaft flanges and a support used for textual modeling, i.e., for elementary models

States:

  • phi_support(t): [rad] Absolute angle of support flange

Connectors:

Parameters:

  • use_support: If support flange enabled, otherwise implicitly grounded
source
ModelingToolkitStandardLibrary.Mechanical.Rotational.PartialCompliantConstant
PartialCompliant(;  name, phi_rel = 0.0, tau = 0.0)

Partial model for the compliant connection of two rotational 1-dim. shaft flanges.

States:

  • phi_rel(t): [rad] Relative rotation angle (flange_b.phi - flange_a.phi). It accepts an initial value, which defaults to 0.0.
  • tau(t): [N.m] Torque between flanges (flange_b.tau). It accepts an initial value, which defaults to 0.0.

Connectors:

source

Rotational Core Components

ModelingToolkitStandardLibrary.Mechanical.Rotational.InertiaConstant
Inertia(;name, J, phi = 0.0, w = 0.0, a = 0.0)

1D-rotational component with inertia.

States:

  • phi: [rad] Absolute rotation angle of component
  • w: [rad/s] Absolute angular velocity of component (= D(phi))
  • a: [rad/s²] Absolute angular acceleration of component (= D(w))

Connectors:

Parameters:

  • J: [kg·m²] Moment of inertia
source
ModelingToolkitStandardLibrary.Mechanical.Rotational.SpringConstant
Spring(; name, c, phi_rel0 = 0.0)

Linear 1D rotational spring

States:

  • phi_rel(t): [rad] Relative rotation angle (flange_b.phi - flange_a.phi)
  • tau(t): [N.m] Torque between flanges (flange_b.tau)

Connectors:

Parameters:

  • c: [N.m/rad] Spring constant
  • phi_rel0: [rad] Unstretched spring angle. Defaults to 0.0.
source
ModelingToolkitStandardLibrary.Mechanical.Rotational.DamperConstant
Damper(; name, d)

Linear 1D rotational damper

States:

  • phi_rel(t): [rad] Relative rotation angle (= flangeb.phi - flangea.phi)
  • w_rel(t): [rad/s] Relative angular velocity (= D(phi_rel))
  • a_rel(t): [rad/s²] Relative angular acceleration (= D(w_rel))
  • tau(t): [N.m] Torque between flanges (= flange_b.tau)

Connectors:

Parameters:

  • d: [N.m.s/rad] Damping constant
source
ModelingToolkitStandardLibrary.Mechanical.Rotational.SpringDamperConstant
SpringDamper(; name, d)

Linear 1D rotational spring and damper

States:

  • phi_rel(t): [rad] Relative rotation angle (= flangeb.phi - flangea.phi)
  • w_rel(t): [rad/s] Relative angular velocity (= D(phi_rel))
  • a_rel(t): [rad/s²] Relative angular acceleration (= D(w_rel))
  • tau(t): [N.m] Torque between flanges (= flange_b.tau)

Connectors:

Parameters:

  • d: [N.m.s/rad] Damping constant
  • c: [N.m/rad] Spring constant
  • phi_rel0: [rad] Unstretched spring angle. Defaults to 0.0
source
ModelingToolkitStandardLibrary.Mechanical.Rotational.IdealGearConstant
IdealGear(; name, ratio, use_support = false)

Ideal gear without inertia.

This element characterizes any type of gear box which is fixed in the ground and which has one driving shaft and one driven shaft.

States:

  • phi_a(t): [rad] Relative angle between shaft a and the support
  • phi_b(t): [rad] Relative angle between shaft b and the support

Connectors:

Parameters:

  • ratio: Transmission ratio (flangea.phi/flangeb.phi)
  • use_support: If support flange enabled, otherwise implicitly grounded. By default it is false
source
ModelingToolkitStandardLibrary.Mechanical.Rotational.RotationalFrictionConstant
RotationalFriction(; name, f, tau_c, w_brk, tau_brk)

Models rotational friction with Stribeck effect, Coulomb friction and viscous friction between the two flanges. The friction torque is a function of the relative angular velocity between flange_a and flange_b.

Friction model: "Armstrong, B. and C.C. de Wit, Friction Modeling and Compensation, The Control Handbook, CRC Press, 1995."

States:

  • phi_rel(t): [rad] Relative rotation angle (= flange_b.phi - flange_a.phi)
  • w_rel(t): [rad/s] Relative angular velocity (= D(phi_rel))
  • a_rel(t): [rad/s²] Relative angular acceleration (= D(w_rel))
  • tau(t): [N.m] Torque between flanges (= flange_b.tau)

Connectors:

Parameters:

  • f: [N⋅m/(rad/s)] Viscous friction coefficient
  • tau_c: [N⋅m] Coulomb friction torque
  • w_brk: [rad/s] Breakaway friction velocity
  • tau_brk: [N⋅m] Breakaway friction torque
source

Rotational Sources

ModelingToolkitStandardLibrary.Mechanical.Rotational.SpeedFunction
Speed(; name, use_support = false, exact = false, f_crit = 50)

Forced movement of a flange according to a reference angular velocity signal

States:

  • phi_support(t): [rad] Absolute angle of support flange"

Connectors:

  • flange Flange
  • w_ref RealInput Reference angular velocity of flange with respect to support as input signal needs to be continuously differential

Parameters:

  • use_support: If support flange enabled, otherwise implicitly grounded
  • exact: true/false exact treatment/filtering the input signal
  • tau_filt: [rad/s] if exact=false, Time constant of low-pass filter to filter input signal
source

Rotational Sensors

Translational Components

Translational Utils

Translational Core Components

ModelingToolkitStandardLibrary.Mechanical.Translational.MassFunction
Mass(; name, v_0 = 0.0, m, s = nothing, g = nothing)

Sliding mass with inertia

Parameters:

  • m: [kg] mass of sliding body
  • v_0: [m/s] Initial value of absolute linear velocity of sliding mass (default 0 m/s)
  • s: [m] initial value of absolute position of sliding mass (optional)
  • g: [m/s²] gravity field acting on the mass, positive value acts in the positive direction (optional)

States:

  • v: [m/s] absolute linear velocity of sliding mass
  • s: [m] absolute position of sliding mass (optional with parameter s)

Connectors:

  • flange: 1-dim. translational flange
source
ModelingToolkitStandardLibrary.Mechanical.Translational.SpringFunction
Spring(; name, k, delta_s = 0.0,  va=0.0, v_b_0=0.0)

Linear 1D translational spring

Parameters:

  • k: [N/m] Spring constant
  • delta_s: initial spring stretch
  • va: [m/s] Initial value of absolute linear velocity at flange_a (default 0 m/s)
  • v_b_0: [m/s] Initial value of absolute linear velocity at flange_b (default 0 m/s)

Connectors:

  • flange_a: 1-dim. translational flange on one side of spring
  • flange_b: 1-dim. translational flange on opposite side of spring
source
ModelingToolkitStandardLibrary.Mechanical.Translational.DamperConstant
Damper(; name, d, flange_a.v = 0.0, flange_b.v = 0.0)

Linear 1D translational damper

Parameters:

  • d: [N.s/m] Damping constant

Connectors:

  • flange_a: 1-dim. translational flange on one side of damper. Initial value of state v is set to 0.0 m/s.
  • flange_b: 1-dim. translational flange on opposite side of damper. Initial value of state v is set to 0.0 m/s.
source

Translational Sources

ModelingToolkitStandardLibrary.Mechanical.Translational.PositionFunction
Position(solves_force = true; name)

Linear 1D position input source. Set solves_force=false to force input force to 0 (i.e. only the position is given, the respective force needed is already provided elsewhere in the model).

Connectors:

  • flange: 1-dim. translational flange
  • s: real input
source
ModelingToolkitStandardLibrary.Mechanical.Translational.VelocityFunction
Velocity(solves_force = true; name)

Linear 1D position input source. Set solves_force=false to force input force to 0 (i.e. only the velocity is given, the respective force needed is already provided elsewhere in the model).

Connectors:

  • flange: 1-dim. translational flange
  • v: real input
source
ModelingToolkitStandardLibrary.Mechanical.Translational.AccelerationFunction

Acceleration(solves_force = true; name)

Linear 1D position input source. Set solves_force=false to force input force to 0 (i.e. only the acceleration is given, the respective force needed is already provided elsewhere in the model).

Connectors:

  • flange: 1-dim. translational flange
  • a: real input
source

Translational Sensors

diff --git a/dev/API/thermal/index.html b/dev/API/thermal/index.html index 80cc73c93..88721fc12 100644 --- a/dev/API/thermal/index.html +++ b/dev/API/thermal/index.html @@ -1,2 +1,2 @@ -Thermal Components · ModelingToolkitStandardLibrary.jl

ModelingToolkitStandardLibrary: Thermal Components

Index

Thermal Utilities

ModelingToolkitStandardLibrary.Thermal.HeatPortConstant
HeatPort(; name, T = 273.15 + 20.0, Q_flow = 0.0)

Port for a thermal system.

States:

  • T: [K] Temperature of the port. It accepts an initial value, which defaults to 273.15 + 20.
  • Q_flow: [W] Heat flow rate at the port. It accepts an initial value, which defaults to 0.0.
source
ModelingToolkitStandardLibrary.Thermal.Element1DConstant
Element1D(; name, dT = 0.0, Q_flow = 0.0)

This partial model contains the basic connectors and variables to allow heat transfer models to be created that do not store energy. This model defines and includes equations for the temperature drop across the element, dT, and the heat flow rate through the element from port_a to port_b, Q_flow.

States:

  • dT: [K] Temperature difference across the component a.T - b.T. It accepts an initial value, which defaults to 0.0.
  • Q_flow: [W] Heat flow rate from port a -> port b. It accepts an initial value, which defaults to 0.0.

Connectors:

port_a port_b

source

Thermal Components

ModelingToolkitStandardLibrary.Thermal.BodyRadiationConstant
BodyRadiation(; name, G)

Lumped thermal element for radiation heat transfer.

States:

  • dT: [K] Temperature difference across the component a.T - b.T
  • Q_flow: [W] Heat flow rate from port a -> port b

Connectors:

  • port_a
  • port_b

Parameters:

  • G: [m^2] Net radiation conductance between two surfaces # Stefan-Boltzmann constant TODO: extract into physical constants module or use existing one
source
ModelingToolkitStandardLibrary.Thermal.ConvectiveConductorConstant
ConvectiveConductor(; name, G)

Lumped thermal element for heat convection.

States:

  • dT: [K] Temperature difference across the component solid.T - fluid.T
  • Q_flow: [W] Heat flow rate from solid -> fluid

Connectors:

  • solid
  • fluid

Parameters:

  • G: [W/K] Convective thermal conductance
source
ModelingToolkitStandardLibrary.Thermal.ConvectiveResistorConstant
ConvectiveResistor(; name, R)

Lumped thermal element for heat convection.

States:

  • dT: [K] Temperature difference across the component solid.T - fluid.T
  • Q_flow: [W] Heat flow rate from solid -> fluid

Connectors:

  • solid
  • fluid

Parameters:

  • R: [K/W] Constant thermal resistance of material
source
ModelingToolkitStandardLibrary.Thermal.HeatCapacitorConstant
HeatCapacitor(; name, C, T = 273.15 + 20)

Lumped thermal element storing heat

States:

  • T: [K] Temperature of element. It accepts an initial value, which defaults to 273.15 + 20.
  • der_T: [K/s] Time derivative of temperature

Connectors:

  • port

Parameters:

  • C: [J/K] Heat capacity of element (= cp*m)
source
ModelingToolkitStandardLibrary.Thermal.ThermalResistorConstant
ThermalResistor(; name, R)

Lumped thermal element transporting heat without storing it.

States:

  • dT: [K] Temperature difference across the component a.T - b.T
  • Q_flow: [W] Heat flow rate from port a -> port b

Connectors:

  • port_a
  • port_b

Parameters:

  • R: [K/W] Constant thermal resistance of material
source
ModelingToolkitStandardLibrary.Thermal.ThermalCollectorFunction
ThermalCollector(; name, m = 1)

Collects m heat flows

This is a model to collect the heat flows from m heatports to one single heatport.

States:

Connectors:

  • port_a1 to port_am
  • port_b

Parameters:

  • m: Number of heat ports (e.g. m=2: port_a1, port_a2)
source

Thermal Sensors

ModelingToolkitStandardLibrary.Thermal.RelativeTemperatureSensorConstant
RelativeTemperatureSensor(; name)

Relative Temperature sensor.

The relative temperature port_a.T - port_b.T is determined between the two ports of this component and is provided as output signal in kelvin.

States:

  • T(t): [K] Relative temperature a.T - b.T

Connectors:

  • port_a
  • port_b
source
ModelingToolkitStandardLibrary.Thermal.HeatFlowSensorConstant
HeatFlowSensor(; name)

Heat flow rate sensor.

This model is capable of monitoring the heat flow rate flowing through this component. The sensed value of heat flow rate is the amount that passes through this sensor while keeping the temperature drop across the sensor zero. This is an ideal model, so it does not absorb any energy, and it has no direct effect on the thermal response of a system it is included in. The output signal is positive, if the heat flows from port_a to port_b.

States:

  • Q_flow(t): [W] Heat flow from port_a to port_b

Connectors:

  • port_a
  • port_b
source
ModelingToolkitStandardLibrary.Thermal.TemperatureSensorConstant
TemperatureSensor(; name)

Absolute temperature sensor in kelvin.

This is an ideal absolute temperature sensor which returns the temperature of the connected port in kelvin as an output signal. The sensor itself has no thermal interaction with whatever it is connected to. Furthermore, no thermocouple-like lags are associated with this sensor model.

States:

  • T(t): [K] Absolute temperature

Connectors:

  • port
source

Thermal Sources

ModelingToolkitStandardLibrary.Thermal.FixedHeatFlowConstant
FixedHeatFlow(; name, Q_flow = 1.0, T_ref = 293.15, alpha = 0.0)

Fixed heat flow boundary condition.

This model allows a specified amount of heat flow rate to be "injected" into a thermal system at a given port. The constant amount of heat flow rate Q_flow is given as a parameter. The heat flows into the component to which the component FixedHeatFlow is connected, if parameter Q_flow is positive.

Connectors:

  • port

Parameters:

  • Q_flow: [W] Fixed heat flow rate at port
  • T_ref: [K] Reference temperature
  • alpha: [1/K] Temperature coefficient of heat flow rate
source
ModelingToolkitStandardLibrary.Thermal.FixedTemperatureConstant
FixedTemperature(; name, T)

Fixed temperature boundary condition in kelvin.

This model defines a fixed temperature T at its port in kelvin, i.e., it defines a fixed temperature as a boundary condition.

Connectors:

  • port

Parameters:

  • T: [K] Fixed temperature boundary condition
source
ModelingToolkitStandardLibrary.Thermal.PrescribedHeatFlowConstant
PrescribedHeatFlow(; name, T_ref = 293.15, alpha = 0.0)

Prescribed heat flow boundary condition.

This model allows a specified amount of heat flow rate to be "injected" into a thermal system at a given port. The amount of heat is given by the input signal Q_flow into the model. The heat flows into the component to which the component PrescribedHeatFlow is connected, if the input signal is positive. If parameter alpha is > 0, the heat flow is multiplied by 1 + alpha*(port.T - T_ref) in order to simulate temperature dependent losses (which are given a reference temperature T_ref).

Connectors:

  • port
  • RealInput Q_flow Input for the heat flow

Parameters:

  • T_ref: [K] Reference temperature
  • alpha: [1/K] Temperature coefficient of heat flow rate
source
ModelingToolkitStandardLibrary.Thermal.PrescribedTemperatureConstant
PrescribedTemperature(; name)

This model represents a variable temperature boundary condition.

The temperature in kelvin is given as input signal to the RealInput T. The effect is that an instance of this model acts as an infinite reservoir, able to absorb or generate as much energy as required to keep the temperature at the specified value.

Connectors:

  • port
  • RealInput T input for the temperature
source
+Thermal Components · ModelingToolkitStandardLibrary.jl

ModelingToolkitStandardLibrary: Thermal Components

Index

Thermal Utilities

ModelingToolkitStandardLibrary.Thermal.HeatPortConstant
HeatPort(; name, T = 273.15 + 20.0, Q_flow = 0.0)

Port for a thermal system.

States:

  • T: [K] Temperature of the port. It accepts an initial value, which defaults to 273.15 + 20.
  • Q_flow: [W] Heat flow rate at the port. It accepts an initial value, which defaults to 0.0.
source
ModelingToolkitStandardLibrary.Thermal.Element1DConstant
Element1D(; name, dT = 0.0, Q_flow = 0.0)

This partial model contains the basic connectors and variables to allow heat transfer models to be created that do not store energy. This model defines and includes equations for the temperature drop across the element, dT, and the heat flow rate through the element from port_a to port_b, Q_flow.

States:

  • dT: [K] Temperature difference across the component a.T - b.T. It accepts an initial value, which defaults to 0.0.
  • Q_flow: [W] Heat flow rate from port a -> port b. It accepts an initial value, which defaults to 0.0.

Connectors:

port_a port_b

source

Thermal Components

ModelingToolkitStandardLibrary.Thermal.BodyRadiationConstant
BodyRadiation(; name, G)

Lumped thermal element for radiation heat transfer.

States:

  • dT: [K] Temperature difference across the component a.T - b.T
  • Q_flow: [W] Heat flow rate from port a -> port b

Connectors:

  • port_a
  • port_b

Parameters:

  • G: [m^2] Net radiation conductance between two surfaces # Stefan-Boltzmann constant TODO: extract into physical constants module or use existing one
source
ModelingToolkitStandardLibrary.Thermal.ConvectiveConductorConstant
ConvectiveConductor(; name, G)

Lumped thermal element for heat convection.

States:

  • dT: [K] Temperature difference across the component solid.T - fluid.T
  • Q_flow: [W] Heat flow rate from solid -> fluid

Connectors:

  • solid
  • fluid

Parameters:

  • G: [W/K] Convective thermal conductance
source
ModelingToolkitStandardLibrary.Thermal.ConvectiveResistorConstant
ConvectiveResistor(; name, R)

Lumped thermal element for heat convection.

States:

  • dT: [K] Temperature difference across the component solid.T - fluid.T
  • Q_flow: [W] Heat flow rate from solid -> fluid

Connectors:

  • solid
  • fluid

Parameters:

  • R: [K/W] Constant thermal resistance of material
source
ModelingToolkitStandardLibrary.Thermal.HeatCapacitorConstant
HeatCapacitor(; name, C, T = 273.15 + 20)

Lumped thermal element storing heat

States:

  • T: [K] Temperature of element. It accepts an initial value, which defaults to 273.15 + 20.
  • der_T: [K/s] Time derivative of temperature

Connectors:

  • port

Parameters:

  • C: [J/K] Heat capacity of element (= cp*m)
source
ModelingToolkitStandardLibrary.Thermal.ThermalResistorConstant
ThermalResistor(; name, R)

Lumped thermal element transporting heat without storing it.

States:

  • dT: [K] Temperature difference across the component a.T - b.T
  • Q_flow: [W] Heat flow rate from port a -> port b

Connectors:

  • port_a
  • port_b

Parameters:

  • R: [K/W] Constant thermal resistance of material
source
ModelingToolkitStandardLibrary.Thermal.ThermalCollectorFunction
ThermalCollector(; name, m = 1)

Collects m heat flows

This is a model to collect the heat flows from m heatports to one single heatport.

States:

Connectors:

  • port_a1 to port_am
  • port_b

Parameters:

  • m: Number of heat ports (e.g. m=2: port_a1, port_a2)
source

Thermal Sensors

ModelingToolkitStandardLibrary.Thermal.RelativeTemperatureSensorConstant
RelativeTemperatureSensor(; name)

Relative Temperature sensor.

The relative temperature port_a.T - port_b.T is determined between the two ports of this component and is provided as output signal in kelvin.

States:

  • T(t): [K] Relative temperature a.T - b.T

Connectors:

  • port_a
  • port_b
source
ModelingToolkitStandardLibrary.Thermal.HeatFlowSensorConstant
HeatFlowSensor(; name)

Heat flow rate sensor.

This model is capable of monitoring the heat flow rate flowing through this component. The sensed value of heat flow rate is the amount that passes through this sensor while keeping the temperature drop across the sensor zero. This is an ideal model, so it does not absorb any energy, and it has no direct effect on the thermal response of a system it is included in. The output signal is positive, if the heat flows from port_a to port_b.

States:

  • Q_flow(t): [W] Heat flow from port_a to port_b

Connectors:

  • port_a
  • port_b
source
ModelingToolkitStandardLibrary.Thermal.TemperatureSensorConstant
TemperatureSensor(; name)

Absolute temperature sensor in kelvin.

This is an ideal absolute temperature sensor which returns the temperature of the connected port in kelvin as an output signal. The sensor itself has no thermal interaction with whatever it is connected to. Furthermore, no thermocouple-like lags are associated with this sensor model.

States:

  • T(t): [K] Absolute temperature

Connectors:

  • port
source

Thermal Sources

ModelingToolkitStandardLibrary.Thermal.FixedHeatFlowConstant
FixedHeatFlow(; name, Q_flow = 1.0, T_ref = 293.15, alpha = 0.0)

Fixed heat flow boundary condition.

This model allows a specified amount of heat flow rate to be "injected" into a thermal system at a given port. The constant amount of heat flow rate Q_flow is given as a parameter. The heat flows into the component to which the component FixedHeatFlow is connected, if parameter Q_flow is positive.

Connectors:

  • port

Parameters:

  • Q_flow: [W] Fixed heat flow rate at port
  • T_ref: [K] Reference temperature
  • alpha: [1/K] Temperature coefficient of heat flow rate
source
ModelingToolkitStandardLibrary.Thermal.FixedTemperatureConstant
FixedTemperature(; name, T)

Fixed temperature boundary condition in kelvin.

This model defines a fixed temperature T at its port in kelvin, i.e., it defines a fixed temperature as a boundary condition.

Connectors:

  • port

Parameters:

  • T: [K] Fixed temperature boundary condition
source
ModelingToolkitStandardLibrary.Thermal.PrescribedHeatFlowConstant
PrescribedHeatFlow(; name, T_ref = 293.15, alpha = 0.0)

Prescribed heat flow boundary condition.

This model allows a specified amount of heat flow rate to be "injected" into a thermal system at a given port. The amount of heat is given by the input signal Q_flow into the model. The heat flows into the component to which the component PrescribedHeatFlow is connected, if the input signal is positive. If parameter alpha is > 0, the heat flow is multiplied by 1 + alpha*(port.T - T_ref) in order to simulate temperature dependent losses (which are given a reference temperature T_ref).

Connectors:

  • port
  • RealInput Q_flow Input for the heat flow

Parameters:

  • T_ref: [K] Reference temperature
  • alpha: [1/K] Temperature coefficient of heat flow rate
source
ModelingToolkitStandardLibrary.Thermal.PrescribedTemperatureConstant
PrescribedTemperature(; name)

This model represents a variable temperature boundary condition.

The temperature in kelvin is given as input signal to the RealInput T. The effect is that an instance of this model acts as an infinite reservoir, able to absorb or generate as much energy as required to keep the temperature at the specified value.

Connectors:

  • port
  • RealInput T input for the temperature
source
diff --git a/dev/assets/Manifest.toml b/dev/assets/Manifest.toml index 216ccdbcd..7087da631 100644 --- a/dev/assets/Manifest.toml +++ b/dev/assets/Manifest.toml @@ -32,9 +32,9 @@ version = "0.4.5" [[deps.Adapt]] deps = ["LinearAlgebra", "Requires"] -git-tree-sha1 = "cea4ac3f5b4bc4b3000aa55afb6e5626518948fa" +git-tree-sha1 = "6a55b747d1812e699320963ffde36f1ebdda4099" uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" -version = "4.0.3" +version = "4.0.4" weakdeps = ["StaticArrays"] [deps.Adapt.extensions] @@ -102,12 +102,6 @@ weakdeps = ["SparseArrays"] [[deps.Base64]] uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" -[[deps.BenchmarkTools]] -deps = ["JSON", "Logging", "Printf", "Profile", "Statistics", "UUIDs"] -git-tree-sha1 = "f1dff6729bc61f4d49e140da1af55dcd1ac97b2f" -uuid = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" -version = "1.5.0" - [[deps.Bijections]] git-tree-sha1 = "c9b163bd832e023571e86d0b90d9de92a9879088" uuid = "e2ed5e7c-b2de-5872-ae92-c73ca462fb04" @@ -189,12 +183,6 @@ git-tree-sha1 = "70232f82ffaab9dc52585e0dd043b5e0c6b714f1" uuid = "fb6a15b2-703c-40df-9091-08a04967cfa9" version = "0.1.12" -[[deps.CodecBzip2]] -deps = ["Bzip2_jll", "Libdl", "TranscodingStreams"] -git-tree-sha1 = "9b1ca1aa6ce3f71b3d1840c538a8210a043625eb" -uuid = "523fee87-0ab8-5b00-afb7-3ecf72e48cfd" -version = "0.8.2" - [[deps.CodecZlib]] deps = ["TranscodingStreams", "Zlib_jll"] git-tree-sha1 = "59939d8a997469ee05c4b4944560a820f9ba0d73" @@ -1186,12 +1174,6 @@ git-tree-sha1 = "465a70f0fc7d443a00dcdc3267a497397b8a3899" uuid = "d0879d2d-cac2-40c8-9cee-1863dc0c7391" version = "0.1.2" -[[deps.MathOptInterface]] -deps = ["BenchmarkTools", "CodecBzip2", "CodecZlib", "DataStructures", "ForwardDiff", "JSON", "LinearAlgebra", "MutableArithmetics", "NaNMath", "OrderedCollections", "PrecompileTools", "Printf", "SparseArrays", "SpecialFunctions", "Test", "Unicode"] -git-tree-sha1 = "679c1aec6934d322783bd15db4d18f898653be4f" -uuid = "b8f27783-ece8-5eb3-8dc8-9495eed66fee" -version = "1.27.0" - [[deps.MatrixEquations]] deps = ["LinearAlgebra", "LinearMaps"] git-tree-sha1 = "f765b4eda3ea9be8e644b9127809ca5151f3d9ea" @@ -1243,9 +1225,9 @@ uuid = "a63ad114-7e13-5084-954f-fe012c677804" [[deps.ModelingToolkit]] deps = ["AbstractTrees", "ArrayInterface", "Combinatorics", "Compat", "ConstructionBase", "DataStructures", "DiffEqBase", "DiffEqCallbacks", "DiffRules", "Distributed", "Distributions", "DocStringExtensions", "DomainSets", "DynamicQuantities", "ExprTools", "FindFirstFunctions", "ForwardDiff", "FunctionWrappersWrappers", "Graphs", "InteractiveUtils", "JuliaFormatter", "JumpProcesses", "LabelledArrays", "Latexify", "Libdl", "LinearAlgebra", "MLStyle", "NaNMath", "OrdinaryDiffEq", "PrecompileTools", "RecursiveArrayTools", "Reexport", "RuntimeGeneratedFunctions", "SciMLBase", "SciMLStructures", "Serialization", "Setfield", "SimpleNonlinearSolve", "SparseArrays", "SpecialFunctions", "StaticArrays", "SymbolicIndexingInterface", "SymbolicUtils", "Symbolics", "URIs", "UnPack", "Unitful"] -git-tree-sha1 = "7f4a6dbb9c936bb0b092a53631ccb3efa7b619f0" +git-tree-sha1 = "7d14b2163fee826b3d56c3e85c107f90757bbe75" uuid = "961ee093-0014-501f-94e3-6117800e7a78" -version = "9.5.0" +version = "9.6.1" [deps.ModelingToolkit.extensions] MTKBifurcationKitExt = "BifurcationKit" @@ -1306,9 +1288,9 @@ version = "1.2.0" [[deps.NonlinearSolve]] deps = ["ADTypes", "ArrayInterface", "ConcreteStructs", "DiffEqBase", "FastBroadcast", "FastClosures", "FiniteDiff", "ForwardDiff", "LazyArrays", "LineSearches", "LinearAlgebra", "LinearSolve", "MaybeInplace", "PrecompileTools", "Preferences", "Printf", "RecursiveArrayTools", "Reexport", "SciMLBase", "SimpleNonlinearSolve", "SparseArrays", "SparseDiffTools", "StaticArraysCore", "TimerOutputs"] -git-tree-sha1 = "d52bac2b94358b4b960cbfb896d5193d67f3ff09" +git-tree-sha1 = "13232c70f50a05f98c7206190ab33dd48fa39c5b" uuid = "8913a72c-1f9b-4ce2-8d82-65094dcecaec" -version = "3.8.0" +version = "3.8.1" [deps.NonlinearSolve.extensions] NonlinearSolveBandedMatricesExt = "BandedMatrices" @@ -1380,10 +1362,16 @@ uuid = "efe28fd5-8261-553b-a9e1-b2916fc3738e" version = "0.5.5+0" [[deps.Optim]] -deps = ["Compat", "FillArrays", "ForwardDiff", "LineSearches", "LinearAlgebra", "MathOptInterface", "NLSolversBase", "NaNMath", "Parameters", "PositiveFactorizations", "Printf", "SparseArrays", "StatsBase"] -git-tree-sha1 = "d024bfb56144d947d4fafcd9cb5cafbe3410b133" +deps = ["Compat", "FillArrays", "ForwardDiff", "LineSearches", "LinearAlgebra", "NLSolversBase", "NaNMath", "PackageExtensionCompat", "Parameters", "PositiveFactorizations", "Printf", "SparseArrays", "StatsBase"] +git-tree-sha1 = "d1223e69af90b6d26cea5b6f3b289b3148ba702c" uuid = "429524aa-4258-5aef-a3af-852621145aeb" -version = "1.9.2" +version = "1.9.3" + + [deps.Optim.extensions] + OptimMOIExt = "MathOptInterface" + + [deps.Optim.weakdeps] + MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee" [[deps.Opus_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] @@ -1398,9 +1386,9 @@ version = "1.6.3" [[deps.OrdinaryDiffEq]] deps = ["ADTypes", "Adapt", "ArrayInterface", "DataStructures", "DiffEqBase", "DocStringExtensions", "ExponentialUtilities", "FastBroadcast", "FastClosures", "FillArrays", "FiniteDiff", "ForwardDiff", "FunctionWrappersWrappers", "IfElse", "InteractiveUtils", "LineSearches", "LinearAlgebra", "LinearSolve", "Logging", "MacroTools", "MuladdMacro", "NonlinearSolve", "Polyester", "PreallocationTools", "PrecompileTools", "Preferences", "RecursiveArrayTools", "Reexport", "SciMLBase", "SciMLOperators", "SimpleNonlinearSolve", "SimpleUnPack", "SparseArrays", "SparseDiffTools", "StaticArrayInterface", "StaticArrays", "TruncatedStacktraces"] -git-tree-sha1 = "287159684e32db56c82dbf545004a7884c6e5198" +git-tree-sha1 = "91079af18db922354197eeae2a17b177079e24c1" uuid = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed" -version = "6.74.0" +version = "6.74.1" [[deps.PCRE2_jll]] deps = ["Artifacts", "Libdl"] @@ -1549,10 +1537,6 @@ version = "1.4.3" deps = ["Unicode"] uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" -[[deps.Profile]] -deps = ["Printf"] -uuid = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79" - [[deps.Qt6Base_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "Fontconfig_jll", "Glib_jll", "JLLWrappers", "Libdl", "Libglvnd_jll", "OpenSSL_jll", "Vulkan_Loader_jll", "Xorg_libSM_jll", "Xorg_libXext_jll", "Xorg_libXrender_jll", "Xorg_libxcb_jll", "Xorg_xcb_util_cursor_jll", "Xorg_xcb_util_image_jll", "Xorg_xcb_util_keysyms_jll", "Xorg_xcb_util_renderutil_jll", "Xorg_xcb_util_wm_jll", "Zlib_jll", "libinput_jll", "xkbcommon_jll"] git-tree-sha1 = "37b7bb7aabf9a085e0044307e1717436117f2b3b" @@ -1691,9 +1675,9 @@ version = "0.6.42" [[deps.SciMLBase]] deps = ["ADTypes", "ArrayInterface", "CommonSolve", "ConstructionBase", "Distributed", "DocStringExtensions", "EnumX", "FunctionWrappersWrappers", "IteratorInterfaceExtensions", "LinearAlgebra", "Logging", "Markdown", "PrecompileTools", "Preferences", "Printf", "RecipesBase", "RecursiveArrayTools", "Reexport", "RuntimeGeneratedFunctions", "SciMLOperators", "SciMLStructures", "StaticArraysCore", "Statistics", "SymbolicIndexingInterface", "Tables"] -git-tree-sha1 = "48f724c6a3355f11dae5f762983073d367c8b934" +git-tree-sha1 = "088123999a9a8fa7ff386a82048c6ed24b2b7d07" uuid = "0bca4576-84f4-4d90-8ffe-ffa030f20462" -version = "2.30.1" +version = "2.30.2" [deps.SciMLBase.extensions] SciMLBaseChainRulesCoreExt = "ChainRulesCore" diff --git a/dev/connectors/connections/1937296f.svg b/dev/connectors/connections/36d9ec33.svg similarity index 92% rename from dev/connectors/connections/1937296f.svg rename to dev/connectors/connections/36d9ec33.svg index 3cbb66d88..cb7d47a62 100644 --- a/dev/connectors/connections/1937296f.svg +++ b/dev/connectors/connections/36d9ec33.svg @@ -1,48 +1,48 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/connectors/connections/10c3ae5b.svg b/dev/connectors/connections/5ba0ab6b.svg similarity index 89% rename from dev/connectors/connections/10c3ae5b.svg rename to dev/connectors/connections/5ba0ab6b.svg index ca4ae0801..70a3916e5 100644 --- a/dev/connectors/connections/10c3ae5b.svg +++ b/dev/connectors/connections/5ba0ab6b.svg @@ -1,82 +1,82 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/connectors/connections/25910cf7.svg b/dev/connectors/connections/861a5613.svg similarity index 85% rename from dev/connectors/connections/25910cf7.svg rename to dev/connectors/connections/861a5613.svg index 0d8f72769..36c8225b7 100644 --- a/dev/connectors/connections/25910cf7.svg +++ b/dev/connectors/connections/861a5613.svg @@ -1,43 +1,43 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/connectors/connections/8d6d9b9a.svg b/dev/connectors/connections/a9a3019e.svg similarity index 89% rename from dev/connectors/connections/8d6d9b9a.svg rename to dev/connectors/connections/a9a3019e.svg index 7f98444e8..6f3dde910 100644 --- a/dev/connectors/connections/8d6d9b9a.svg +++ b/dev/connectors/connections/a9a3019e.svg @@ -1,82 +1,82 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/connectors/connections/5583bbeb.svg b/dev/connectors/connections/c9ef0a40.svg similarity index 91% rename from dev/connectors/connections/5583bbeb.svg rename to dev/connectors/connections/c9ef0a40.svg index 4435329a4..2eb400aeb 100644 --- a/dev/connectors/connections/5583bbeb.svg +++ b/dev/connectors/connections/c9ef0a40.svg @@ -1,56 +1,56 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/connectors/connections/f8c9463f.svg b/dev/connectors/connections/e635af09.svg similarity index 89% rename from dev/connectors/connections/f8c9463f.svg rename to dev/connectors/connections/e635af09.svg index 46ebf5d7f..23dc69ca4 100644 --- a/dev/connectors/connections/f8c9463f.svg +++ b/dev/connectors/connections/e635af09.svg @@ -1,116 +1,116 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/connectors/connections/index.html b/dev/connectors/connections/index.html index 7d3a86703..1d23bedb5 100644 --- a/dev/connectors/connections/index.html +++ b/dev/connectors/connections/index.html @@ -22,7 +22,7 @@ p1 = plot(sol, idxs = [capacitor.v]) p2 = plot(sol, idxs = [resistor.i]) -plot(p1, p2)Example block output

Mechanical Translational Domain

Across Variable = velocity

Now using the Translational library based on velocity, we can see the same relationship with a system reduced to a single equation, using the components:

  • Body (i.e. moving mass): for kinetic energy storage with an initial velocity = 1m/s
  • Damper: for energy flow
  • Fixed: for energy sink
using ModelingToolkitStandardLibrary
+plot(p1, p2)
Example block output

Mechanical Translational Domain

Across Variable = velocity

Now using the Translational library based on velocity, we can see the same relationship with a system reduced to a single equation, using the components:

  • Body (i.e. moving mass): for kinetic energy storage with an initial velocity = 1m/s
  • Damper: for energy flow
  • Fixed: for energy sink
using ModelingToolkitStandardLibrary
 const TV = ModelingToolkitStandardLibrary.Mechanical.Translational
 
 @named damping = TV.Damper(d = 1, flange_a.v = 1)
@@ -41,7 +41,7 @@
 
 p1 = plot(sol_v, idxs = [body.v])
 p2 = plot(sol_v, idxs = [damping.f])
-plot(p1, p2)
Example block output

Across Variable = position

Now, let's consider the position-based approach. We can build the same model with the same components. As can be seen, we now end of up with 2 equations, because we need to relate the lower derivative (position) to force (with acceleration).

const TP = ModelingToolkitStandardLibrary.Mechanical.TranslationalPosition
+plot(p1, p2)
Example block output

Across Variable = position

Now, let's consider the position-based approach. We can build the same model with the same components. As can be seen, we now end of up with 2 equations, because we need to relate the lower derivative (position) to force (with acceleration).

const TP = ModelingToolkitStandardLibrary.Mechanical.TranslationalPosition
 
 @named damping = TP.Damper(d = 1, va = 1, vb = 0.0)
 @named body = TP.Mass(m = 1, v = 1)
@@ -62,7 +62,7 @@
 p2 = plot(sol_p, idxs = [damping.f])
 p3 = plot(sol_p, idxs = [body.s])
 
-plot(p1, p2, p3)
Example block output

The question then arises, can the position be plotted when using the Mechanical Translational Domain based on the Velocity Across variable? Yes, we can! There are 2 solutions:

  1. the Mass component will add the position variable when the s parameter is used to set an initial position. Otherwise, the component does not track the position.
@named body = TV.Mass(m = 1, v = 1, s = 0)
  1. implement a PositionSensor TODO: Implement Translation Sensors

Either option will produce the same result regardless of which across variable is used. If the same result is given, why are both options included in the Standard Library, what are the differences? These differences will be discussed next so that an informed decision can be made about which domain is best for your model.

Mechanical/Translational Library Differences (Velocity vs. Position Connectors)

Initialization

The main difference between ModelingToolkitStandardLibrary.Mechanical.Translational and ModelingToolkitStandardLibrary.Mechanical.TranslationalPosition is how they are initialized. In the ModelingToolkitStandardLibrary initialization, parameters are defined at the component level, so we simply need to be careful to set the correct initial conditions for the domain that it used. Let's use the following example problem to explain the differences.

Example Mechanical Model

In this problem, we have a mass, spring, and damper which are connected to a fixed point. Let's see how each component is defined.

Damper

The damper will connect the flange/flange 1 (flange_a) to the mass, and flange/flange 2 (flange_b) to the fixed point. For both position- and velocity-based domains, we set the damping constant d=1 and va=1 and leave the default for v_b_0 at 0. For the position domain, we also need to set the initial positions for flange_a and flange_b.

@named dv = TV.Damper(d = 1, flange_a.v = 1)
+plot(p1, p2, p3)
Example block output

The question then arises, can the position be plotted when using the Mechanical Translational Domain based on the Velocity Across variable? Yes, we can! There are 2 solutions:

  1. the Mass component will add the position variable when the s parameter is used to set an initial position. Otherwise, the component does not track the position.
@named body = TV.Mass(m = 1, v = 1, s = 0)
  1. implement a PositionSensor TODO: Implement Translation Sensors

Either option will produce the same result regardless of which across variable is used. If the same result is given, why are both options included in the Standard Library, what are the differences? These differences will be discussed next so that an informed decision can be made about which domain is best for your model.

Mechanical/Translational Library Differences (Velocity vs. Position Connectors)

Initialization

The main difference between ModelingToolkitStandardLibrary.Mechanical.Translational and ModelingToolkitStandardLibrary.Mechanical.TranslationalPosition is how they are initialized. In the ModelingToolkitStandardLibrary initialization, parameters are defined at the component level, so we simply need to be careful to set the correct initial conditions for the domain that it used. Let's use the following example problem to explain the differences.

Example Mechanical Model

In this problem, we have a mass, spring, and damper which are connected to a fixed point. Let's see how each component is defined.

Damper

The damper will connect the flange/flange 1 (flange_a) to the mass, and flange/flange 2 (flange_b) to the fixed point. For both position- and velocity-based domains, we set the damping constant d=1 and va=1 and leave the default for v_b_0 at 0. For the position domain, we also need to set the initial positions for flange_a and flange_b.

@named dv = TV.Damper(d = 1, flange_a.v = 1)
 @named dp = TP.Damper(d = 1, va = 1, vb = 0.0, flange_a__s = 3, flange_b__s = 1)

Spring

The spring will connect the flange/flange 1 (flange_a) to the mass, and flange/flange 2 (flange_b) to the fixed point. For both position- and velocity-based domains, we set the spring constant k=1. The velocity domain then requires the initial velocity va and initial spring stretch delta_s. The position domain instead needs the initial positions for flange_a and flange_b and the natural spring length l.

@named sv = TV.Spring(k = 1, flange_a__v = 1, delta_s = 1)
 @named sp = TP.Spring(k = 1, flange_a__s = 3, flange_b__s = 1, l = 1)

Mass

For both position- and velocity-based domains, we set the mass m=1 and initial velocity v=1. Like the damper, the position domain requires the position initial conditions set as well.

@named bv = TV.Mass(m = 1, v = 1)
 @named bp = TP.Mass(m = 1, v = 1, s = 3)

Fixed

Here the velocity domain requires no initial condition, but for our model to work as defined we must set the position domain component to the correct initial position.

@named gv = TV.Fixed()
@@ -84,9 +84,9 @@
 Differential(t)(sv₊delta_s(t)) ~ bv₊v(t)

And the position domain model

solp = simplify_and_solve(dp, sp, bp, gp);
Differential(t)(bp₊s(t)) ~ bp₊v(t)
 Differential(t)(bp₊v(t)) ~ (-dp₊d*bp₊v(t) - (-gp₊s_0 - sp₊l + bp₊s(t))*sp₊k) / bp₊m

Now we can plot the comparison of the 2 models and see they give the same result.

plot(ylabel = "mass velocity [m/s]")
 plot!(solv, idxs = [bv.v])
-plot!(solp, idxs = [bp.v])
Example block output

But, what if we wanted to plot the mass position? This is easy for the position-based domain, we have the state bp₊s(t), but for the velocity-based domain we have sv₊delta_s(t) which is the spring stretch. To get the absolute position, we add the spring natural length (1m) and the fixed position (1m). As can be seen, we then get the same result.

plot(ylabel = "mass position [m]")
+plot!(solp, idxs = [bp.v])
Example block output

But, what if we wanted to plot the mass position? This is easy for the position-based domain, we have the state bp₊s(t), but for the velocity-based domain we have sv₊delta_s(t) which is the spring stretch. To get the absolute position, we add the spring natural length (1m) and the fixed position (1m). As can be seen, we then get the same result.

plot(ylabel = "mass position [m]")
 plot!(solv, idxs = [sv.delta_s + 1 + 1])
-plot!(solp, idxs = [bp.s])
Example block output

So in conclusion, the position based domain gives easier access to absolute position information, but requires more initial condition information.

Accuracy

One may then ask, what the trade-off in terms of numerical accuracy is. When we look at the simplified equations, we can see that actually both systems solve the same equations. The differential equations of the velocity domain are

\[\begin{aligned} +plot!(solp, idxs = [bp.s])Example block output

So in conclusion, the position based domain gives easier access to absolute position information, but requires more initial condition information.

Accuracy

One may then ask, what the trade-off in terms of numerical accuracy is. When we look at the simplified equations, we can see that actually both systems solve the same equations. The differential equations of the velocity domain are

\[\begin{aligned} m \cdot \dot{v} + d \cdot v + k \cdot \Delta s = 0 \\ \dot{\Delta s} = v \end{aligned}\]

And for the position domain are

\[\begin{aligned} @@ -96,4 +96,4 @@ ylabel = "solv[bv.v] .- solp[bp.v]") time = 0:0.1:10 plot!(time, (solv(time)[bv.v] .- solp(time)[bp.v]), label = "") -Plots.ylims!(-1e-15, 1e-15)Example block output

+Plots.ylims!(-1e-15, 1e-15)Example block output diff --git a/dev/index.html b/dev/index.html index a35169afc..8a2c2d6b0 100644 --- a/dev/index.html +++ b/dev/index.html @@ -5,9 +5,9 @@ [0c46a032] DifferentialEquations v7.13.0 [e30172f5] Documenter v1.3.0 [615f187c] IfElse v0.1.1 - [961ee093] ModelingToolkit v9.5.0 + [961ee093] ModelingToolkit v9.6.1 [16a59e39] ModelingToolkitStandardLibrary v2.6.0 `~/work/ModelingToolkitStandardLibrary.jl/ModelingToolkitStandardLibrary.jl` - [1dea7af3] OrdinaryDiffEq v6.74.0 + [1dea7af3] OrdinaryDiffEq v6.74.1 [91a5bcdd] Plots v1.40.2
and using this machine and Julia version.
Julia Version 1.10.2
 Commit bd47eca2c8a (2024-03-01 10:14 UTC)
 Build Info:
@@ -23,12 +23,11 @@
   [a4c015fc] ANSIColoredPrinters v0.0.1
   [621f4979] AbstractFFTs v1.5.0
   [1520ce14] AbstractTrees v0.4.5
-  [79e6a3ab] Adapt v4.0.3
+  [79e6a3ab] Adapt v4.0.4
 ⌅ [ec485272] ArnoldiMethod v0.2.0
   [4fba245c] ArrayInterface v7.9.0
   [4c555306] ArrayLayouts v1.7.0
   [aae01518] BandedMatrices v1.6.1
-  [6e4b80f9] BenchmarkTools v1.5.0
   [e2ed5e7c] Bijections v0.1.6
   [d1d4a3ce] BitFlags v0.1.8
   [62783981] BitTwiddlingConvenienceFunctions v0.1.5
@@ -39,7 +38,6 @@
   [49dc2e85] Calculus v0.5.1
   [d360d2e6] ChainRulesCore v1.23.0
   [fb6a15b2] CloseOpenIntervals v0.1.12
-  [523fee87] CodecBzip2 v0.8.2
   [944b1d66] CodecZlib v0.7.4
   [35d6a980] ColorSchemes v3.24.0
   [3da002f7] ColorTypes v0.11.4
@@ -140,7 +138,6 @@
   [1914dd2f] MacroTools v0.5.13
   [d125e4d3] ManualMemory v0.1.8
   [d0879d2d] MarkdownAST v0.1.2
-  [b8f27783] MathOptInterface v1.27.0
   [99c1a7ee] MatrixEquations v2.4.2
   [a3b82374] MatrixFactorizations v2.1.0
   [48965c70] MatrixPencils v1.8.0
@@ -148,7 +145,7 @@
   [739be429] MbedTLS v1.1.9
   [442fdcdd] Measures v0.3.2
   [e1d29d7a] Missings v1.1.0
-  [961ee093] ModelingToolkit v9.5.0
+  [961ee093] ModelingToolkit v9.6.1
   [16a59e39] ModelingToolkitStandardLibrary v2.6.0 `~/work/ModelingToolkitStandardLibrary.jl/ModelingToolkitStandardLibrary.jl`
   [46d2c3a1] MuladdMacro v0.2.4
   [102ac46a] MultivariatePolynomials v0.5.4
@@ -156,12 +153,12 @@
   [d41bc354] NLSolversBase v7.8.3
   [2774e3e8] NLsolve v4.5.1
   [77ba4419] NaNMath v1.0.2
-  [8913a72c] NonlinearSolve v3.8.0
+  [8913a72c] NonlinearSolve v3.8.1
   [6fe1bfb0] OffsetArrays v1.13.0
   [4d8831e6] OpenSSL v1.4.2
-  [429524aa] Optim v1.9.2
+  [429524aa] Optim v1.9.3
   [bac558e1] OrderedCollections v1.6.3
-  [1dea7af3] OrdinaryDiffEq v6.74.0
+  [1dea7af3] OrdinaryDiffEq v6.74.1
   [90014a1f] PDMats v0.11.31
   [65ce6f38] PackageExtensionCompat v1.0.2
   [d96e819e] Parameters v0.12.3
@@ -194,7 +191,7 @@
   [7e49a35a] RuntimeGeneratedFunctions v0.5.12
   [94e857df] SIMDTypes v0.1.0
   [476501e8] SLEEFPirates v0.6.42
-  [0bca4576] SciMLBase v2.30.1
+  [0bca4576] SciMLBase v2.30.2
   [c0aeaf25] SciMLOperators v0.3.8
   [53ae85a6] SciMLStructures v1.1.0
   [6c6a2e73] Scratch v1.2.1
@@ -345,7 +342,6 @@
   [ca575930] NetworkOptions v1.2.0
   [44cfe95a] Pkg v1.10.0
   [de0858da] Printf
-  [9abbd945] Profile
   [3fa0cd96] REPL
   [9a3f8284] Random
   [ea8e919c] SHA v0.7.0
@@ -374,4 +370,4 @@
   [8e850b90] libblastrampoline_jll v5.8.0+1
   [8e850ede] nghttp2_jll v1.52.0+1
   [3f19e933] p7zip_jll v17.4.0+2
-Info Packages marked with ⌃ and ⌅ have new versions available. Those with ⌃ may be upgradable, but those with ⌅ are restricted by compatibility constraints from upgrading. To see why use `status --outdated -m`

You can also download the manifest file and the project file.

+Info Packages marked with ⌃ and ⌅ have new versions available. Those with ⌃ may be upgradable, but those with ⌅ are restricted by compatibility constraints from upgrading. To see why use `status --outdated -m`

You can also download the manifest file and the project file.

diff --git a/dev/objects.inv b/dev/objects.inv index 23322e4e3cec7a0fda971e4bca5b480a12f6ea36..572799a07b8d9867d0b90a6dbbb88d0484eb0767 100644 GIT binary patch delta 2763 zcmV;+3N-bV7n>K5mVe)G<2Dk0_g_Ka8sM%t+1>P^cLDCfv6HQV&Blm*d%(Q}w8S`U zY0;&mByQ3Fy+e_dD4DWkiGFDvi8CbU$H)1GS{g^>10`v66Y&rQpAdTB5n(jmt~qDF z(sY&LIKm?OLN@}7!}u3=gQmzlMfx#%;i4`%O0$#;idixd;eT^TMVQglp33!pf}Un* zrhZ!r!YoPo?m6VUJ&#G;pr$@*f@b*>G&4^UOK18@#16CPom{qCVP(h!t<|5PE{?J= zr94)9wvWav${z6W`gd@QI-?ss2$$MBn6!{Y4d!79?XckBne+}?3%fJ z1JdQFn!JvRy0Ct1he<{3^$-c1vEvmNFDB^cVoXgK@_&k8@r+~44hcQ7a_#j5@=`uP zQ~hA1@{|%K$?yh39%TRa9STMdIH^5u2mm#@4IdmceC4rPVQ^apNioC<6Bu2LHNi5c zTbg1PlomM_w?YO~XbIbfpD~RCSZT0-#R&;^SZrzRP*gW0Xp^D{L{Tn^wCLzFiHX3h zyWysx;D1RHd;>S&4I{yxCp5>9jvACaGVydmM1r~G^G9&ft&>;@>NVBEd&I7ac zpfGX?7$-y3!kD_8ML<%F(e7PfFA1iKoVNE1rqa6##Zhe1}R2q$NhOCZci1 zv!p}fmV-_1-m~l@SZ5n@Dhi9b0aQo~rll7vcwHEyar)j^?KxY(b` zuqIvZ4Aa6U!%l&YBgHIGs782Wo>$#e4KQJo?)7+jGf~|8kTV)aE4s_%e0`6VQr)QO!Z^j3?tXJ1x4|+fI`{1Sx-6&e=yk-agysd?$;ojGr?(4 zva{3Mu97>@C#8?MU0ZEsEx&7p+FowCm9|x1Zn9L%?rtDl%WfUDrWEf8RHhCu#DR|z zan3=dkgah#2dovSNOuHKEH1r}T;0TrCkh3Xq=tWv z({*HlFYV#vQrH$uF7~WgWiYi_Xd8X1Gtt7SO|a*3ss=n0f1h#MJ^J#&qq~nigJm5% z>hz%@X1G+% zYQ*&dA$KG1ag)NKm)AoQt${iOFB+n{rDmZ383m|NP&+odTcCP!SVnjv`y4CjMiFaQ zBMKbaUW&D z;gUAjXob~P2&&VcSAkkRmg+)uJ-RmDbOifdwg2785%XD)-xnz8TP}jIxGd-xM%5dK ziiRrS3DOt!1hKPTqkJbkDq4R{-CMny3pbX#ohV7wcPdp2hS!za9V6yhCaec?)r!@- zgJ$$;Zwoqa81l=Rpd__T7;JA`UFej|)-YrGK_YLr31xzf%NQHy7iFp@M8B{bPznqc z4pf(2Tc=R#9#^C z&*cZ!U~^d7D~U5Mx~4FNsb%_2p=)IG|0e<JRAYD?I3H!rm72r%s>+ASyhzi0ka>z3B{)AKVh3;rd zTzbzixz_naFk482YJ3k*~B?Yy;ugJC{y1PTiiUZN#T?d$xA9b{6LI=W` zRWnEUlxW|~>GaPTpG>%r;eh)ctJ-i+~Q6)f3Wg+|+UKAJy zhCK1&z*S22o)mvUx~%p%99V0WMVr6#*3@Pfpf1(3_nwQexm@oF9DM7=qBB7Lp@ndX zWhzs>xaYIrS?prKXL`lZhb5fIp`aUYyu?r^`bHCX`P*;f%@yjIJ2yF#?YyAyTKD>k z>r7vs)*JSfhI+XV7-T;3k1z-AzO}&1xvq?^1W38BDsO)_6v!RN&ibAEsOxOcVL*23 zKIZ#*ZA;V@)^h^UAWKqrPo__iV}QVD8+T zKx;LUH*kM<2jn!~GH>zNp(&Z)yD%|^>h|69XE+VMOKFd!CFM)rlYA@Wpff#=y!rhuauW9Psi?7%| z=EDBav@sIPyW3%zqeGGJN&K9D3AN7ljQlZ;5C24~!*0XbpK_8NNnd%?#1neWarM(J z%yM--ySn~C&2;tCyt}pY;0Pshd%6s6_+lXMU3yFTY2+du{Yv{9kQOhR=xFZ}Tz|W} zbhdv9`xW6|`1aEeewvpA_8EC#Uk*I_O19Yd1&-m2z{NIL6$BS-qs$L6-qFx=$+$K% zF-970!-r?y(M`hoovUn2yj~?71Inq|%1;^L^)sXyPX^vyT5Tf#9imhH0&g~0s(<+5 z`}-?@)TKxnKcQv7?>8~9H&&LS-pbI2jHQ3{!e6eb?7!3p7xk-Ze>I{cD5v_n=fps# zHq?c>D~p&&6J3xPPQwsFMPRR=*EF|rmS8^O^U@d|Uweb2g*UQqmbdY9r9CG&`ah2c ze&ASqkudjkpS`_whqoADO2R=o)_pn%TT|+RcJ{fT>L{XKb4jZ7_v|ExSy(~8wdy8!p#*vZzwW@E&@J>XsfT4Efw zwCGY&61V7o?@%NqN~SDXqF-7^;ta{*%s2B5wKR^%2TIcDCgLFqJ|XnLBf@CBU31QU zrRgfgafC(mg>D2Ehw(4$22GK9iu7aj!bM$jlx8Ux6tiR^!hh$GiZG+8J(cVI1U=2r zO#QYLgjtgE-E+uydmfXxK}~(s1kLg%Xl9-ymd^B*h#h9nJGpGP!pe{dTB|=nT^wa$ zN_njIY$=UG7z}?r@2Oj*HDH3~Gf)73pm&4s-1nua(_loiaY(R8_(Y#0xJt>`JA zPS7n*Xozm}zw+UPfv}(><*qpU-eqjq>3lN5B;q|NgQdN3pEk|cb^v1{h? z4M>-xYVz7E>caZ5?Isnm*Fz+5#*SB9yqKV$i!n7}h<_`B#WRjEJ0$eT%C*-Mh)ekZ zP4$D3ic?CIB*PnUd650vcPJP=;H37r!2#6hHhgf*@Ri4Eg~4svLLs8w3piPP*5JkBt(xRi!Bqjp0 z?uMI&f`2DT@C}XuZx{*oJfS&;bkv~ak&#FLK}JK%ncTEm{j~hmk5i+eWg>HAw;5#- z3=1G8f`LBaqerTf#u_-;^@gb={MXy}*KwLT03X9Xj}-9%;5z+j(HN z9u!6{0pp~rS{PHe`;k&F##mxDX6{8>~p2!233{tICToG?gkiZdP^dQ=%<0Pu5hM;t68!xefzy)b`<9G@r4Ex= z12%t-MDT3;n!{lol;8k3tfZqZttm&xIy@;&qbHsk)2(IP6D1&|c59C49w?Wi(_1W6Jq4c54+GOL3^w{WpP z6Jbrd+!3aQO@y5S9Y=^+piuSj#yGDYQ`InqO}N+n>CJd??<8k5j8=4)$@%)Gl~UeH zEXs%-yh;r`_NZp3cKVY!G&?N1+1n12Jp?I#SkBo;KHkplbH0Zl!J2mzylrqPrUi*P>f{ttrJj0+p%53vuA1 zM4XeT6tXo==YX{W73q!uiX6aP_gNh3bZqlyhfCBMwA6d7$Kuip$<>X&c%o2HNoweS zI9*2;_|oo9E`@E*XemA0@;!Z?mki?By8k8r0!8u@4Kl6 zm(hl#HaL;IJ#|Lw;VFw_nf~+bC2EC#bDD&Lq~zQcYF)}yiCUl0rPgO9wyu1xlHDxh zT8+3~Amnc3J#JD+dU-u0(Hf{j@S-8ATWA&vkWqjN1+}!%-2&CjVHx3x>~pN78%3;L zjVL(K_EJm^tJCtF%p|(PYYuU{`zkeQ>72ln(oMB~Lw(bw(pRO;w`pON z3zxLHMk}nYLQtLlyb9Fnu~ZkL>(RA2O^37JRr}wa4q`qF^7{e>eal4<7MBGb-Kcuw zP|;8YJVE-Ro*;JAYn1PVM@6fDse7webK%Bvw-Y6)o}CKSg5h>QT(x5L z?w}cc+S`K88;1OHCMZd569(HGR~I@Zvo*|^evru9Z9*Af2AjjuUJ0CW(KUrBOfA!I3SA?c|347`snls1i?DRpN+cD=X(pO2evV%4A9Et; z8`$EF4D$=K%-nlrU*w+gcTZafpW6ZIe46{&@(LosaoXnuu12-71hX8<$1}Yw^J>Xc zSTZEkvPJK5VhbKyXDxt#cD)!pVU`I&oVw3C1-;ZYj)(b>1*A*rGGTxCtOA@VX?>-?2CpFOB1x8!_a~f^FLXy! z;?jGD$+gZWg4se+=3xie8jkWS34?-z;;?kNSMRu`yyK0OxFrUEhlmRvC7WtUp_i4sex{y(dL~5H71d4hPm+Wzps@-ixkUOfO>tC75c zyW1hB@s@di^T!UI#QehK(l*Pp;y2E+-Egy2TESM^dLVXNp$mMiAvN}_Hg9=!c)}6I z4eiW6U2D@fxKQK1{AhV5ANVWp)aQ(szR}TN_Fe8?C;vA}-tKf{71H2x=bYVXqUenx z-hJ$cUvg9k^E(ljz2{p*P?LR@-~C+zQ`KI$c>_Lw{zinmpL|}Y)43O4zJ1Jv{h?{2 zCzcnk!y-q!BHxqvIsbfVo$VRUwr{ z{ezn6>Zf^kYv;}pO62x*gWGV;pEn%6h5R&fk&b?)eGN#97fp1ucL}aPxLrDXd;N;= zFMRud=?6a@M*{ndJg_eZ9(^TS?EBWma7N%_8>|X~3${__hZyf@=(%KEo0%9R4OiI1 zBk!pFzkcT`8WXSm|6@QoRa^NfBfNe)G~>y@3rDL>+rj4EX&f2KL6vQq)@+`jD}dUifn}75$fg`bwgHzwEC@lmz8efA<_8=+uU~P|<>ZGYI& L26%q~A@ciTUiEx= diff --git a/dev/search_index.js b/dev/search_index.js index ba2944415..bd8f06610 100644 --- a/dev/search_index.js +++ b/dev/search_index.js @@ -1,3 +1,3 @@ var documenterSearchIndex = {"docs": -[{"location":"API/magnetic/#ModelingToolkitStandardLibrary:-Magnetic-Components","page":"Magnetic Components","title":"ModelingToolkitStandardLibrary: Magnetic Components","text":"","category":"section"},{"location":"API/magnetic/","page":"Magnetic Components","title":"Magnetic Components","text":"Pages = [\"magnetic.md\"]","category":"page"},{"location":"API/magnetic/#Index","page":"Magnetic Components","title":"Index","text":"","category":"section"},{"location":"API/magnetic/","page":"Magnetic Components","title":"Magnetic Components","text":"Pages = [\"magnetic.md\"]","category":"page"},{"location":"API/magnetic/#Flux-Tubes","page":"Magnetic Components","title":"Flux Tubes","text":"","category":"section"},{"location":"API/magnetic/","page":"Magnetic Components","title":"Magnetic Components","text":"CurrentModule = ModelingToolkitStandardLibrary.Magnetic.FluxTubes","category":"page"},{"location":"API/magnetic/#Flux-Tube-Utilities","page":"Magnetic Components","title":"Flux Tube Utilities","text":"","category":"section"},{"location":"API/magnetic/","page":"Magnetic Components","title":"Magnetic Components","text":"PositiveMagneticPort\nNegativeMagneticPort\nTwoPort","category":"page"},{"location":"API/magnetic/#ModelingToolkitStandardLibrary.Magnetic.FluxTubes.PositiveMagneticPort","page":"Magnetic Components","title":"ModelingToolkitStandardLibrary.Magnetic.FluxTubes.PositiveMagneticPort","text":"Positive magnetic port\n\n\n\n\n\n","category":"constant"},{"location":"API/magnetic/#ModelingToolkitStandardLibrary.Magnetic.FluxTubes.NegativeMagneticPort","page":"Magnetic Components","title":"ModelingToolkitStandardLibrary.Magnetic.FluxTubes.NegativeMagneticPort","text":"Negative magnetic port\n\n\n\n\n\n","category":"constant"},{"location":"API/magnetic/#ModelingToolkitStandardLibrary.Magnetic.FluxTubes.TwoPort","page":"Magnetic Components","title":"ModelingToolkitStandardLibrary.Magnetic.FluxTubes.TwoPort","text":"TwoPort(; name, V_m = 0.0, Phi = 0.0)\n\nPartial component with magnetic potential difference between two magnetic ports p and n and magnetic flux Phi from p to n.\n\nParameters:\n\nV_m: Initial magnetic potential difference between both ports\nPhi: Initial magnetic flux from portp to portn\n\n\n\n\n\n","category":"constant"},{"location":"API/magnetic/#Basic-Flux-Tube-Blocks","page":"Magnetic Components","title":"Basic Flux Tube Blocks","text":"","category":"section"},{"location":"API/magnetic/","page":"Magnetic Components","title":"Magnetic Components","text":"Ground\nIdle\nShort\nCrossing\nConstantPermeance\nConstantReluctance\nEddyCurrent\nElectroMagneticConverter","category":"page"},{"location":"API/magnetic/#ModelingToolkitStandardLibrary.Magnetic.FluxTubes.Ground","page":"Magnetic Components","title":"ModelingToolkitStandardLibrary.Magnetic.FluxTubes.Ground","text":"Ground(; name)\n\nZero magnetic potential.\n\n\n\n\n\n","category":"constant"},{"location":"API/magnetic/#ModelingToolkitStandardLibrary.Magnetic.FluxTubes.Idle","page":"Magnetic Components","title":"ModelingToolkitStandardLibrary.Magnetic.FluxTubes.Idle","text":"Idle(;name)\n\nIdle running branch.\n\n\n\n\n\n","category":"constant"},{"location":"API/magnetic/#ModelingToolkitStandardLibrary.Magnetic.FluxTubes.Short","page":"Magnetic Components","title":"ModelingToolkitStandardLibrary.Magnetic.FluxTubes.Short","text":"Short(;name)\n\nShort cut branch.\n\n\n\n\n\n","category":"constant"},{"location":"API/magnetic/#ModelingToolkitStandardLibrary.Magnetic.FluxTubes.Crossing","page":"Magnetic Components","title":"ModelingToolkitStandardLibrary.Magnetic.FluxTubes.Crossing","text":"Crossing(;name)\n\nCrossing of two branches.\n\nThis is a simple crossing of two branches. The ports portp1 and portp2 are connected, as well as portn1 and portn2.\n\n\n\n\n\n","category":"constant"},{"location":"API/magnetic/#ModelingToolkitStandardLibrary.Magnetic.FluxTubes.ConstantPermeance","page":"Magnetic Components","title":"ModelingToolkitStandardLibrary.Magnetic.FluxTubes.ConstantPermeance","text":"ConstantPermeance(; name, G_m = 1.0)\n\nConstant permeance.\n\nParameters:\n\nG_m: [H] Magnetic permeance\n\n\n\n\n\n","category":"constant"},{"location":"API/magnetic/#ModelingToolkitStandardLibrary.Magnetic.FluxTubes.ConstantReluctance","page":"Magnetic Components","title":"ModelingToolkitStandardLibrary.Magnetic.FluxTubes.ConstantReluctance","text":"ConstantReluctance(; name, R_m = 1.0)\n\nConstant reluctance.\n\nParameters:\n\nR_m: [H^-1] Magnetic reluctance\n\n\n\n\n\n","category":"constant"},{"location":"API/magnetic/#ModelingToolkitStandardLibrary.Magnetic.FluxTubes.EddyCurrent","page":"Magnetic Components","title":"ModelingToolkitStandardLibrary.Magnetic.FluxTubes.EddyCurrent","text":"EddyCurrent(;name, Phi, rho = 0.098e-6, l = 1, A = 1)\n\nFor modelling of eddy current in a conductive magnetic flux tube. Initial magnetic flux flowing into the port_p can be set with Phi ([Wb])\n\nParameters:\n\nrho: [ohm * m] Resistivity of flux tube material (default: Iron at 20degC)\nl: [m] Average length of eddy current path\nA: [m^2] Cross sectional area of eddy current path\n\n\n\n\n\n","category":"constant"},{"location":"API/magnetic/#ModelingToolkitStandardLibrary.Magnetic.FluxTubes.ElectroMagneticConverter","page":"Magnetic Components","title":"ModelingToolkitStandardLibrary.Magnetic.FluxTubes.ElectroMagneticConverter","text":"ElectroMagneticConverter(; name, N, Phi)\n\nIdeal electromagnetic energy conversion.\n\nThe electromagnetic energy conversion is given by Ampere's law and Faraday's law respectively V_m = N * i N * dΦ/dt = -v\n\nInitial magnetic flux flowing into the port_p can be set with Phi ([Wb])\n\nParameters:\n\nN: Number of turns\n\n\n\n\n\n","category":"constant"},{"location":"API/magnetic/#Flux-Tube-Sources","page":"Magnetic Components","title":"Flux Tube Sources","text":"","category":"section"},{"location":"API/magnetic/","page":"Magnetic Components","title":"Magnetic Components","text":"ConstantMagneticPotentialDifference\nConstantMagneticFlux","category":"page"},{"location":"API/magnetic/#ModelingToolkitStandardLibrary.Magnetic.FluxTubes.ConstantMagneticPotentialDifference","page":"Magnetic Components","title":"ModelingToolkitStandardLibrary.Magnetic.FluxTubes.ConstantMagneticPotentialDifference","text":"ConstantMagneticPotentialDifference(; name, V_m = 0.0)\n\nConstant magnetomotive force.\n\nParameters:\n\nV_m: [A] Magnetic potential difference\n\n\n\n\n\n","category":"constant"},{"location":"API/magnetic/#ModelingToolkitStandardLibrary.Magnetic.FluxTubes.ConstantMagneticFlux","page":"Magnetic Components","title":"ModelingToolkitStandardLibrary.Magnetic.FluxTubes.ConstantMagneticFlux","text":"ConstantMagneticFlux(; name, Phi = 0.0)\n\nSource of constant magnetic flux.\n\nParameters:\n\nPhi: [Wb] Magnetic flux\n\n\n\n\n\n","category":"constant"},{"location":"tutorials/thermal_model/#Heat-Conduction-Model","page":"Thermal Conduction Model","title":"Heat Conduction Model","text":"","category":"section"},{"location":"tutorials/thermal_model/","page":"Thermal Conduction Model","title":"Thermal Conduction Model","text":"This example demonstrates the thermal response of two masses connected by a conducting element. The two masses have the same heat capacity but different initial temperatures (T1=100 [°C], T2=0 [°C]). The mass with the higher temperature will cool off, while the mass with the lower temperature heats up. They will each asymptotically approach the calculated temperature TfinalK that results from dividing the total initial energy in the system by the sum of the heat capacities of each element.","category":"page"},{"location":"tutorials/thermal_model/","page":"Thermal Conduction Model","title":"Thermal Conduction Model","text":"using ModelingToolkitStandardLibrary.Thermal, ModelingToolkit, OrdinaryDiffEq, Plots\nusing ModelingToolkit: t_nounits as t\n\nC1 = 15\nC2 = 15\n@named mass1 = HeatCapacitor(C = C1, T = 373.15)\n@named mass2 = HeatCapacitor(C = C2, T = 273.15)\n@named conduction = ThermalConductor(G = 10)\n@named Tsensor1 = TemperatureSensor()\n@named Tsensor2 = TemperatureSensor()\n\nconnections = [\n connect(mass1.port, conduction.port_a),\n connect(conduction.port_b, mass2.port),\n connect(mass1.port, Tsensor1.port),\n connect(mass2.port, Tsensor2.port)\n]\n\n@named model = ODESystem(connections, t,\n systems = [mass1, mass2, conduction, Tsensor1, Tsensor2])\nsys = structural_simplify(model)\nprob = ODEProblem(sys, Pair[], (0, 5.0))\nsol = solve(prob, Tsit5())\n\nT_final_K = sol[(mass1.T * C1 + mass2.T * C2) / (C1 + C2)]\n\nplot(title = \"Thermal Conduction Demonstration\")\nplot!(sol, idxs = [mass1.T, mass2.T], labels = [\"Mass 1 Temperature\" \"Mass 2 Temperature\"])\nplot!(sol.t, T_final_K, label = \"Steady-State Temperature\")\nsavefig(\"thermal_plot.png\");\nnothing; # hide","category":"page"},{"location":"tutorials/thermal_model/","page":"Thermal Conduction Model","title":"Thermal Conduction Model","text":"(Image: Plot of Temperatures)","category":"page"},{"location":"API/hydraulic/#hydraulic","page":"Hydraulic Components","title":"ModelingToolkit Standard Library: Hydraulic Components","text":"","category":"section"},{"location":"API/hydraulic/","page":"Hydraulic Components","title":"Hydraulic Components","text":"Pages = [\"hydraulic.md\"]\nDepth = 3","category":"page"},{"location":"API/hydraulic/#Index","page":"Hydraulic Components","title":"Index","text":"","category":"section"},{"location":"API/hydraulic/","page":"Hydraulic Components","title":"Hydraulic Components","text":"Pages = [\"hydraulic.md\"]","category":"page"},{"location":"API/hydraulic/#IsothermalCompressible-Components","page":"Hydraulic Components","title":"IsothermalCompressible Components","text":"","category":"section"},{"location":"API/hydraulic/","page":"Hydraulic Components","title":"Hydraulic Components","text":"CurrentModule = ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible","category":"page"},{"location":"API/hydraulic/#IsothermalCompressible-Utils","page":"Hydraulic Components","title":"IsothermalCompressible Utils","text":"","category":"section"},{"location":"API/hydraulic/","page":"Hydraulic Components","title":"Hydraulic Components","text":"HydraulicPort\nHydraulicFluid\nfriction_factor","category":"page"},{"location":"API/hydraulic/#ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.HydraulicPort","page":"Hydraulic Components","title":"ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.HydraulicPort","text":"HydraulicPort(;p_int, name)\n\nConnector port for hydraulic components.\n\nArguments:\n\np_int: [Pa] initial gauge pressure\n\nStates:\n\np: [Pa] gauge total pressure\ndm: [kg/s] mass flow\n\n\n\n\n\n","category":"function"},{"location":"API/hydraulic/#ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.HydraulicFluid","page":"Hydraulic Components","title":"ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.HydraulicFluid","text":"HydraulicFluid(; density = 997, bulk_modulus = 2.09e9, viscosity = 0.0010016, gas_density = 0.0073955, gas_pressure = -1000, n = 1, let_gas = 1, name)\n\nFluid parameter setter for isothermal compressible fluid domain. Defaults given for water at 20°C and 0Pa gage (1atm absolute) reference pressure. Density is modeled using the Tait equation of state. For pressures below the reference pressure, density is linearly interpolated to the gas state (when let_gas is set to 1), this helps prevent pressures from going below the reference pressure. \n\nParameters:\n\nρ: [kg/m^3] fluid density at 0Pa reference gage pressure (set by density argument)\nΒ: [Pa] fluid bulk modulus describing the compressibility (set by bulk_modulus argument)\nμ: [Pa*s] or [kg/m-s] fluid dynamic viscosity (set by viscosity argument)\nn: density exponent\nlet_gas: set to 1 to allow fluid to transition from liquid to gas (for density calculation only) \nρ_gas: [kg/m^3] density of fluid in gas state at reference gage pressure p_gas (set by gas_density argument)\np_gas: [Pa] reference pressure (set by gas_pressure argument)\n\n\n\n\n\n","category":"function"},{"location":"API/hydraulic/#ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.friction_factor","page":"Hydraulic Components","title":"ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.friction_factor","text":"friction_factor(dm, area, d_h, viscosity, shape_factor)\n\nCalculates the friction factor f for fully developed flow in a tube such that Δp = f cdot rho fracu^22 fracld_h where \n\nΔp: [Pa] is the pressure difference over the tube length l\nrho: [kg/m^3] is the average fluid density\nu: [m/s] is the average fluid velocity\nl: [m] is the tube length \n\nThe friction factor is calculated for laminar and turbulent flow with a transition region between Reynolds number 2000 to 3000. Turbulent flow equation is for smooth tubes, valid for the Reynolds number range up to 5e6.\n\nArguments:\n\ndm: [kg/s] mass flow\narea: [m^2] tube cross sectional area\nd_h: [m] tube hydraulic diameter. For circular tubes d_h is the tube diameter, otherwise it can be found from 4*area/perimeter\ndensity: [kg/m^3] fluid density\nviscosity: [Pa*s] or [kg/m-s] fluid dynamic viscosity\nshape_factor: the constant defining the laminar fully developed constant f*Re related to the shape of the tube cross section\n\nReference: Introduction to Fluid Mechanics, Fox & McDonald, 5th Edition, equations 8.19 and 8.21\n\n\n\n\n\n","category":"function"},{"location":"API/hydraulic/#IsothermalCompressible-Components-2","page":"Hydraulic Components","title":"IsothermalCompressible Components","text":"","category":"section"},{"location":"API/hydraulic/","page":"Hydraulic Components","title":"Hydraulic Components","text":"Cap\nTubeBase\nTube\nFixedVolume\nDynamicVolume","category":"page"},{"location":"API/hydraulic/#ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Cap","page":"Hydraulic Components","title":"ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Cap","text":"Cap(; p_int, name)\n\nCaps a hydraulic port to prevent mass flow in or out.\n\nParameters:\n\np_int: [Pa] initial pressure (set by p_int argument)\n\nConnectors:\n\nport: hydraulic port\n\n\n\n\n\n","category":"function"},{"location":"API/hydraulic/#ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.TubeBase","page":"Hydraulic Components","title":"ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.TubeBase","text":"TubeBase(add_inertia = true; p_int, area, length_int, head_factor = 1, perimeter = 2 * sqrt(area * pi), shape_factor = 64, name)\n\nVariable length internal flow model of the fully developed incompressible flow friction. Includes optional inertia term when add_inertia = true to model wave propagation. Hydraulic ports have equal flow but variable pressure. Density is averaged over the pressures, used to calculated average flow velocity and flow friction.\n\nStates:\n\nx: [m] length of the pipe\nddm: [kg/s^2] Rate of change of mass flow rate in control volume.\n\nParameters:\n\np_int: [Pa] initial pressure\narea: [m^2] tube cross sectional area\nlength_int: [m] initial tube length\nperimeter: [m] perimeter of the pipe cross section (needed only for non-circular pipes)\nshape_factor: shape factor, see friction_factor function\nhead_factor: effective length multiplier, used to account for addition friction from flow development and additional friction such as pipe bends, entrance/exit lossses, etc.\n\nConnectors:\n\nport_a: hydraulic port\nport_b: hydraulic port\n\n\n\n\n\n","category":"function"},{"location":"API/hydraulic/#ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Tube","page":"Hydraulic Components","title":"ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Tube","text":"Tube(N, add_inertia=true; p_int, area, length, head_factor=1, perimeter = 2 * sqrt(area * pi), shape_factor = 64, name)\n\nConstant length internal flow model discretized by N (FixedVolume: N, TubeBase:N-1) which models the fully developed flow friction, compressibility (when N>1), and inertia effects when add_inertia = true. See TubeBase and FixedVolume for more information.\n\nParameters:\n\np_int: [Pa] initial pressure\narea: [m^2] tube cross sectional area\nlength: [m] real length of the tube\nperimeter: [m] perimeter of the pipe cross section (needed only for non-circular pipes)\nshape_factor: shape factor, see friction_factor function\nhead_factor: effective length multiplier, used to account for addition friction from flow development and additional friction such as pipe bends, entrance/exit lossses, etc.\n\nConnectors:\n\nport_a: hydraulic port\nport_b: hydraulic port\n\n\n\n\n\n","category":"function"},{"location":"API/hydraulic/#ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.FixedVolume","page":"Hydraulic Components","title":"ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.FixedVolume","text":"FixedVolume(; vol, p_int, name)\n\nFixed fluid volume.\n\nParameters:\n\nvol: [m^3] fixed volume\np_int: [Pa] initial pressure\n\nConnectors:\n\nport: hydraulic port\n\n\n\n\n\n","category":"function"},{"location":"API/hydraulic/#ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.DynamicVolume","page":"Hydraulic Components","title":"ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.DynamicVolume","text":"DynamicVolume(N, addinertia=true; pint, area, xint = 0, xmax, xmin = 0, xdamp = xmin, direction = +1, perimeter = 2 * sqrt(area * pi), shapefactor = 64, headfactor = 1, Cd = 1e2, Cdreverse = Cd, name)\n\nVolume with moving wall with flange connector for converting hydraulic energy to 1D mechanical. The direction argument aligns the mechanical port with the hydraulic port, useful when connecting two dynamic volumes together in oppsing directions to create an actuator.\n\n ┌─────────────────┐ ───\n │ │ ▲\n │ │\ndm ────► │ │ area\n │ │\n │ │ ▼\n └─────────────────┤ ───\n │\n └─► x (= ∫ flange.v * direction)\n\nFeatures:\n\nvolume discretization with flow resistance and inertia: use N to control number of volume and resistance elements. Set N=0 to turn off volume discretization. See TubeBase for more information about flow resistance.\nminimum volume flow shutoff with damping and directional resistance. Use reversible=false when problem defines volume position x and solves for dm to prevent numerical instability.\n\nParameters:\n\nvolume\n\np_int: [Pa] initial pressure\narea: [m^2] moving wall area\nx_int: [m] initial wall position\nx_max: [m] max wall position, needed for volume discretization to apply the correct volume sizing as a function of x\nx_min: [m] wall position that shuts off flow and prevents negative volume.\nx_damp: [m] wall position that initiates a linear damping region before reaching full flow shut off. Helps provide a smooth end stop.\ndirection: [+/-1] applies the direction conversion from the flange to x\n\nflow resistance\n\nperimeter: [m] perimeter of the cross section (needed only for non-circular volumes)\nshape_factor: shape factor, see friction_factor function\nhead_factor: effective length multiplier, used to account for addition friction from flow development and additional friction such as pipe bends, entrance/exit lossses, etc.\n\nflow shut off and damping\n\nCd: discharge coefficient for flow out of the volume. Note: area is 1m² when valve is fully open. Ensure this does not induce unwanted flow resistance.\nCd_reverse: discharge coefficient for flow into the volume. Use a lower value to allow easy wall release, in some cases the wall can \"stick\".\n\nConnectors:\n\nport: hydraulic port\nflange: mechanical translational port\n\n\n\n\n\n","category":"function"},{"location":"API/hydraulic/#IsothermalCompressible-Sources","page":"Hydraulic Components","title":"IsothermalCompressible Sources","text":"","category":"section"},{"location":"API/hydraulic/","page":"Hydraulic Components","title":"Hydraulic Components","text":"MassFlow\nPressure\nFixedPressure","category":"page"},{"location":"API/hydraulic/#ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.MassFlow","page":"Hydraulic Components","title":"ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.MassFlow","text":"MassFlow(; name, p_int)\n\nHydraulic mass flow input source\n\nConnectors:\n\nport: hydraulic port\ndm: real input \n\n\n\n\n\n","category":"function"},{"location":"API/hydraulic/#ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Pressure","page":"Hydraulic Components","title":"ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Pressure","text":"Pressure(; p_int, name)\n\ninput pressure source\n\nParameters:\n\np_int: [Pa] initial pressure (set by p_int argument)\n\nConnectors:\n\nport: hydraulic port\np: real input \n\n\n\n\n\n","category":"function"},{"location":"API/hydraulic/#ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.FixedPressure","page":"Hydraulic Components","title":"ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.FixedPressure","text":"FixedPressure(; p, name)\n\nFixed pressure source\n\nParameters:\n\np: [Pa] set pressure (set by p argument)\n\nConnectors:\n\nport: hydraulic port\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary:-Blocks","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary: Blocks","text":"","category":"section"},{"location":"API/blocks/","page":"Basic Blocks","title":"Basic Blocks","text":"CurrentModule = ModelingToolkitStandardLibrary.Blocks","category":"page"},{"location":"API/blocks/","page":"Basic Blocks","title":"Basic Blocks","text":"Pages = [\"blocks.md\"]","category":"page"},{"location":"API/blocks/#Index","page":"Basic Blocks","title":"Index","text":"","category":"section"},{"location":"API/blocks/","page":"Basic Blocks","title":"Basic Blocks","text":"Pages = [\"blocks.md\"]","category":"page"},{"location":"API/blocks/#Utility-Blocks","page":"Basic Blocks","title":"Utility Blocks","text":"","category":"section"},{"location":"API/blocks/","page":"Basic Blocks","title":"Basic Blocks","text":"RealInput\nRealOutput\nSISO","category":"page"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.RealInput","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.RealInput","text":"RealInput(;name, nin, u_start)\n\nConnector with one input signal of type Real.\n\nParameters:\n\nnin=1: Number of inputs\nu_start=0: Initial value for u\n\nStates:\n\nu: Value of the connector; if nin=1 this is a scalar\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.RealOutput","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.RealOutput","text":"RealOutput(;name, nout, u_start)\n\nConnector with one output signal of type Real.\n\nParameters:\n\nnout=1: Number of inputs\nu_start=0: Initial value for u\n\nStates:\n\nu: Value of the connector; if nout=1 this is a scalar\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.SISO","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.SISO","text":"SISO(;name, u_start = 0.0, y_start = 0.0)\n\nSingle input single output (SISO) continuous system block.\n\nParameters:\n\nu: Initial value for the input\ny: Initial value for the output\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#Math-Blocks","page":"Basic Blocks","title":"Math Blocks","text":"","category":"section"},{"location":"API/blocks/","page":"Basic Blocks","title":"Basic Blocks","text":"Gain\nMatrixGain\nSum\nFeedback\nAdd\nAdd3\nProduct\nDivision\nStaticNonLinearity\nAbs\nSign\nSqrt\nSin\nCos\nTan\nAsin\nAcos\nAtan\nAtan2\nSinh\nCosh\nTanh\nExp\nLog\nLog10","category":"page"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Gain","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Gain","text":"Gain(; name, k)\n\nOutput the product of a gain value with the input signal.\n\nParameters:\n\nk: Scalar gain\n\nConnectors:\n\ninput\noutput\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.MatrixGain","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.MatrixGain","text":"MatrixGain(; K::AbstractArray, name)\n\nOutput the product of a gain matrix with the input signal vector.\n\nStructural parameters:\n\nK: Matrix gain\n\nConnectors:\n\ninput\noutput\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Sum","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Sum","text":"Sum(; input__nin::Int, name)\n\nOutput the sum of the elements of the input port vector. Input port dimension can be set with input__nin\n\nConnectors:\n\ninput\noutput\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Feedback","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Feedback","text":"Feedback(; name)\n\nOutput difference between reference input (input1) and feedback input (input2).\n\nConnectors:\n\ninput1\ninput2\noutput\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Add","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Add","text":"Add(; name, k1 = 1, k2 = 1)\n\nOutput the sum of the two scalar inputs.\n\nParameters:\n\nk1: Gain for first input\nk2: Gain for second input\n\nConnectors:\n\ninput1\ninput2\noutput\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Add3","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Add3","text":"Add(; name, k1 = 1, k2 = 1, k3 = 1)\n\nOutput the sum of the three scalar inputs.\n\nParameters:\n\nk1: Gain for first input\nk2: Gain for second input\nk3: Gain for third input\n\nConnectors:\n\ninput1\ninput2\ninput3\noutput\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Product","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Product","text":"Product(; name)\n\nOutput product of the two inputs.\n\nConnectors:\n\ninput1\ninput2\noutput\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Division","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Division","text":"Division(; name)\n\nOutput first input divided by second input.\n\nConnectors:\n\ninput1\ninput2\noutput\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.StaticNonLinearity","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.StaticNonLinearity","text":"StaticNonLinearity(func; name)\n\nApplies the given function to the input.\n\nIf the given function is not composed of simple core methods (e.g. sin, abs, ...), it has to be registered via @register_symbolic func(u)\n\nConnectors:\n\ninput\noutput\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Abs","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Abs","text":"Abs(; name)\n\nOutput the absolute value of the input.\n\nConnectors:\n\nSee StaticNonLinearity\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Sign","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Sign","text":"Sign(; name)\n\nOutput the sign of the input\n\nConnectors:\n\nSee StaticNonLinearity\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Sqrt","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Sqrt","text":"Sqrt(; name)\n\nOutput the square root of the input (input >= 0 required).\n\nConnectors:\n\nSee StaticNonLinearity\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Sin","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Sin","text":"Sin(; name)\n\nOutput the sine of the input.\n\nConnectors:\n\nSee StaticNonLinearity\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Cos","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Cos","text":"Cos(; name)\n\nOutput the cosine of the input.\n\nConnectors:\n\nSee StaticNonLinearity\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Tan","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Tan","text":"Tan(; name)\n\nOutput the tangent of the input.\n\nConnectors:\n\nSee StaticNonLinearity\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Asin","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Asin","text":"Asin(; name)\n\nOutput the arc sine of the input.\n\nConnectors:\n\nSee StaticNonLinearity\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Acos","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Acos","text":"Acos(; name)\n\nOutput the arc cosine of the input.\n\nConnectors:\n\nSee StaticNonLinearity\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Atan","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Atan","text":"Atan(; name)\n\nOutput the arc tangent of the input.\n\nConnectors:\n\nSee StaticNonLinearity\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Atan2","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Atan2","text":"Atan2(; name)\n\nOutput the arc tangent of the input.\n\nConnectors:\n\ninput1\ninput2\noutput\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Sinh","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Sinh","text":"Sinh(; name)\n\nOutput the hyperbolic sine of the input.\n\nConnectors:\n\nSee StaticNonLinearity\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Cosh","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Cosh","text":"Cosh(; name)\n\nOutput the hyperbolic cosine of the input.\n\nConnectors:\n\nSee StaticNonLinearity\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Tanh","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Tanh","text":"Tanh(; name)\n\nOutput the hyperbolic tangent of the input.\n\nConnectors:\n\nSee StaticNonLinearity\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Exp","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Exp","text":"Exp(; name)\n\nOutput the exponential (base e) of the input.\n\nConnectors:\n\nSee StaticNonLinearity\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Log","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Log","text":"Log(; name)\n\nOutput the natural (base e) logarithm of the input.\n\nConnectors:\n\nSee StaticNonLinearity\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Log10","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Log10","text":"Log10(; name)\n\nOutput the base 10 logarithm of the input.\n\nConnectors:\n\nSee StaticNonLinearity\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#Source-Blocks","page":"Basic Blocks","title":"Source Blocks","text":"","category":"section"},{"location":"API/blocks/","page":"Basic Blocks","title":"Basic Blocks","text":"Constant\nSine\nCosine\nContinuousClock\nRamp\nStep\nExpSine","category":"page"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Constant","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Constant","text":"Constant(; name, k = 0.0)\n\nGenerate constant signal.\n\nParameters:\n\nk: Constant output value\n\nConnectors:\n\noutput\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Sine","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Sine","text":"Sine(; name, frequency, amplitude = 1, phase = 0, offset = 0, start_time = 0,\nsmooth = false)\n\nGenerate sine signal.\n\nParameters:\n\nfrequency: [Hz] Frequency of sine wave\namplitude: Amplitude of sine wave\nphase: [rad] Phase of sine wave\noffset: Offset of output signal\nstart_time: [s] Output y = offset for t < start_time\nsmooth: If true, returns a smooth wave. Defaults to false It uses a default smoothing factor of δ=1e-5, but this can be changed by supplying smooth=δ.\n\nConnectors:\n\noutput\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.ContinuousClock","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.ContinuousClock","text":"ContinuousClock(; name, offset = 0, start_time = 0)\n\nGenerate current time signal.\n\nParameters:\n\noffset: Offset of output signal\nstart_time: [s] Output y = offset for t < start_time\n\nConnectors:\n\noutput\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Ramp","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Ramp","text":"Ramp(; name, height = 1, duration = 1, offset = 0, start_time = 0, smooth = false)\n\nGenerate ramp signal.\n\nParameters:\n\nheight: Height of ramp\nduration: [s] Duration of ramp (= 0.0 gives a Step)\noffset: Offset of output signal\nstart_time: [s] Output y = offset for t < start_time\nsmooth: If true, returns a smooth wave. Defaults to false It uses a default smoothing factor of δ=1e-5, but this can be changed by supplying smooth=δ.\n\nConnectors:\n\noutput\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Step","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Step","text":"Step(;name, height=1, offset=0, start_time=0, duration=Inf, smooth=true)\n\nGenerate step signal.\n\nParameters:\n\nheight: Height of step\noffset: Offset of output signal\nstart_time: [s] Output y = offset for t < start_time and thereafter offset+height.\nduration: [s] If duration < Inf is supplied, the output will revert to offset after duration seconds.\nsmooth: If true, returns a smooth wave. Defaults to true It uses a default smoothing factor of δ=1e-5, but this can be changed by supplying smooth=δ.\n\nConnectors:\n\noutput\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.ExpSine","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.ExpSine","text":"ExpSine(; name, frequency, amplitude = 1, damping = 0.1, phase = 0, offset = 0, start_time = 0, smooth = false)\n\nExponentially damped sine signal.\n\nParameters:\n\nfrequency: [Hz] Frequency of sine wave\namplitude: Amplitude of sine wave\ndamping: [1/s] Damping coefficient of sine wave\nphase: [rad] Phase of sine wave\noffset: Offset of output signal\nstart_time: [s] Output y = offset for t < start_time\nsmooth: If true, returns a smooth wave. Defaults to false It uses a default smoothing factor of δ=1e-5, but this can be changed by supplying smooth=δ.\n\nConnectors:\n\noutput\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#Nonlinear-Blocks","page":"Basic Blocks","title":"Nonlinear Blocks","text":"","category":"section"},{"location":"API/blocks/","page":"Basic Blocks","title":"Basic Blocks","text":"Limiter\nDeadZone\nSlewRateLimiter","category":"page"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Limiter","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Limiter","text":"Limiter(;name, y_max, y_min = y_max > 0 ? -y_max : -Inf)\n\nLimit the range of a signal.\n\nParameters:\n\ny_max: Maximum of output signal\ny_min: Minimum of output signal\n\nConnectors:\n\ninput\noutput\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.DeadZone","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.DeadZone","text":"DeadZone(; name, u_max, u_min = -u_max)\n\nThe DeadZone block defines a region of zero output. If the input is within u_min ... u_max, the output is zero. Outside of this zone, the output is a linear function of the input with a slope of 1.\n\n y▲\n │ /\n │ /\n u_min │ /\n─────|──┼──|───────► u\n / │ u_max\n / │\n / │\n\nParameters:\n\nu_max: Upper limit of dead zone\nu_min: Lower limit of dead zone\n\nConnectors:\n\ninput\noutput\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.SlewRateLimiter","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.SlewRateLimiter","text":"SlewRateLimiter(; name, y_start, rising = 1.0, falling = -rising, Td = 0.001)\n\nLimits the slew rate of a signal. Initial value of state Y can be set with int.y\n\nParameters:\n\nrising: Maximum rising slew rate\nfalling: Maximum falling slew rate\nTd: [s] Derivative time constant\ny_start: Initial value of y state of SISO\n\nConnectors:\n\ninput\noutput\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#Continuous-Blocks","page":"Basic Blocks","title":"Continuous Blocks","text":"","category":"section"},{"location":"API/blocks/","page":"Basic Blocks","title":"Basic Blocks","text":"Integrator\nDerivative\nFirstOrder\nSecondOrder\nStateSpace\nTransferFunction\nPI\nLimPI\nPID\nLimPID","category":"page"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Integrator","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Integrator","text":"Integrator(;name, k = 1, x = 0.0)\n\nOutputs y = ∫k*u dt, corresponding to the transfer function 1s. Initial value of integrator state x can be set with x\n\nConnectors:\n\ninput\noutput\n\nParameters:\n\nk: Gain of integrator\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Derivative","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Derivative","text":"Derivative(; name, k = 1, T, x = 0.0)\n\nOutputs an approximate derivative of the input. The transfer function of this block is Initial value of the state x can be set with x\n\nk k\n─ - ──────────\nT 2 ⎛ 1⎞\n T ⋅⎜s + ─⎟\n ⎝ T⎠\n\nand a state-space realization is given by ss(-1/T, 1/T, -k/T, k/T) where T is the time constant of the filter. A smaller T leads to a more ideal approximation of the derivative.\n\nParameters:\n\nk: Gain\nT: [s] Time constants (T>0 required; T=0 is ideal derivative block)\n\nConnectors:\n\ninput\noutput\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.FirstOrder","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.FirstOrder","text":"FirstOrder(; name, k = 1.0, T, x = 0.0, lowpass = true)\n\nA first-order filter with a single real pole in s = -T and gain k. If lowpass=true (default), the transfer function is given by Y(s)U(s) =\n\n k\n───────\nsT + 1\n\nand if lowpass=false, by\n\nsT + 1 - k\n──────────\n sT + 1\n\nInitial value of the state x can be set with x\n\nParameters:\n\nk: Gain\nT: [s] Time constant (T>0 required)\n\nConnectors:\n\ninput\noutput\n\nSee also SecondOrder\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.SecondOrder","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.SecondOrder","text":"SecondOrder(; name, k = 1.0, w = 1.0, d = 1.0, x = 0.0, xd = 0.0)\n\nA second-order filter with gain k, a bandwidth of w rad/s and relative damping d. The transfer function is given by Y(s)/U(s) =\n\n k*w^2\n─────────────────\ns² + 2d*w*s + w^2\n\nCritical damping corresponds to d=1, which yields the fastest step response without overshoot, d < 1 results in an underdamped filter while d > 1 results in an overdamped filter. d = 1/√2 corresponds to a Butterworth filter of order 2 (maximally flat frequency response). Initial value of the state x can be set with x, and of derivative state xd with xd.\n\nParameters:\n\nk: Gain\nw: [rad/s] Angular frequency\nd: Damping\n\nConnectors:\n\ninput\noutput\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.StateSpace","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.StateSpace","text":"StateSpace(A, B, C, D = 0; x = zeros(size(A,1)), u0 = zeros(size(B,2)), y0 = zeros(size(C,1)), name)\n\nA linear, time-invariant state-space system on the form.\n\nbeginaligned\nx = Ax + Bu \ny = Cx + Du\nendaligned\n\nTransfer functions can also be simulated by converting them to a StateSpace form.\n\ny0 and u0 can be used to set an operating point, providing them changes the dynamics from an LTI system to the affine system\n\nbeginaligned\nx = Ax + B(u - u0) \ny = Cx + D(u - u0) + y0\nendaligned\n\nFor a nonlinear system\n\nbeginaligned\nx = f(x u) \ny = h(x u)\nendaligned\n\nlinearized around the operating point x₀, u₀, we have y0, u0 = h(x₀, u₀), u₀.\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.TransferFunction","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.TransferFunction","text":"TransferFunction(; b, a, name)\n\nA single input, single output, linear time-invariant system provided as a transfer-function.\n\nY(s) = b(s) / a(s) U(s)\n\nwhere b and a are vectors of coefficients of the numerator and denominator polynomials, respectively, ordered such that the coefficient of the highest power of s is first.\n\nThe internal state realization is on controller canonical form, with state variable x, output variable y and input variable u. For numerical robustness, the realization used by the integrator is scaled by the last entry of the a parameter. The internally scaled state variable is available as x_scaled.\n\nTo set the initial state, it's recommended to set the initial condition for x, and let that of x_scaled be computed automatically.\n\nParameters:\n\nb: Numerator polynomial coefficients, e.g., 2s + 3 is specified as [2, 3]\na: Denominator polynomial coefficients, e.g., s² + 2ωs + ω^2 is specified as [1, 2ω, ω^2]\n\nConnectors:\n\ninput\noutput\n\nSee also StateSpace which handles MIMO systems, as well as ControlSystemsMTK.jl for an interface between ControlSystems.jl and ModelingToolkit.jl for advanced manipulation of transfer functions and linear statespace systems. For linearization, see linearize and Linear Analysis.\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.PI","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.PI","text":"PI(;name, k = 1.0, T = 1.0, int.x = 0.0)\n\nTextbook version of a PI-controller without actuator saturation and anti-windup measure. The proportional gain can be set with k Initial value of integrator state x can be set with int.x\n\nThe PI controller is implemented on standard form:\n\nU(s) = k (1 + dfrac1sT) E(S)\n\nParameters:\n\nk: Proportional gain\nT: [s] Integrator time constant (T>0 required)\n\nConnectors:\n\nerr_input\nctr_output\n\nSee also LimPI\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.LimPI","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.LimPI","text":"LimPI(; name, k = 1.0, T, Ta, int__x = 0.0, u_max = 1.0, u_min = -u_max)\n\nText-book version of a PI-controller with actuator saturation and anti-windup measure.\n\nThe PI controller is implemented on standard form\n\nu(t) = sat(k (e(t) + dfrac1Te(t) dt) )\n\nThe simplified expression above is given without the anti-windup protection.\n\nParameters:\n\nk: Proportional gain\nT: [s] Integrator time constant (T>0 required)\nTa: [s] Tracking time constant (Ta>0 required)\n\nConnectors:\n\nerr_input\nctr_output\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.PID","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.PID","text":"PID(;name, k=1, Ti=false, Td=false, Nd=10, int__x=0, der__x=0)\n\nText-book version of a PID-controller without actuator saturation and anti-windup measure.\n\nParameters:\n\nk: Gain\nTi: [s] Integrator time constant (Ti>0 required). If set to false, no integral action is used.\nTd: [s] Derivative time constant (Td>0 required). If set to false, no derivative action is used.\nNd: [s] Time constant for the derivative approximation (Nd>0 required; Nd=0 is ideal derivative).\nint__x: Initial value for the integrator.\nder__x: Initial value for the derivative state.\n\nConnectors:\n\nerr_input\nctr_output\n\nSee also LimPID\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.LimPID","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.LimPID","text":"LimPID(; k, Ti=false, Td=false, wp=1, wd=1, Ni, Nd=12, u_max=Inf, u_min=-u_max, gains = false, name)\n\nProportional-Integral-Derivative (PID) controller with output saturation, set-point weighting and integrator anti-windup.\n\nThe equation for the control signal is roughly\n\nk(ep + 1/Ti * ∫e + Td * d/dt(ed))\ne = u_r - u_y\nep = wp*u_r - u_y\ned = wd*u_r - u_y\n\nwhere the transfer function for the derivative includes additional filtering, see ? Derivative for more details.\n\nParameters:\n\nk: Proportional gain\nTi: [s] Integrator time constant. Set to false to turn off integral action.\nTd: [s] Derivative time constant. Set to false to turn off derivative action.\nwp: [0,1] Set-point weighting in the proportional part.\nwd: [0,1] Set-point weighting in the derivative part.\nNd: [1/s] Derivative limit, limits the derivative gain to Nd/Td. Reasonable values are ∈ [8, 20]. A higher value gives a better approximation of an ideal derivative at the expense of higher noise amplification.\nNi: Ni*Ti controls the time constant Ta of anti-windup tracking. A common (default) choice is Ta = √(Ti*Td) which is realized by Ni = √(Td / Ti). Anti-windup can be effectively turned off by setting Ni = Inf.\ngains: If gains = true, Ti and Td will be interpreted as gains with a fundamental PID transfer function on parallel form ki=Ti, kd=Td, k + ki/s + kd*s.\n\nConnectors:\n\nreference\nmeasurement\nctr_output\n\n\n\n\n\n","category":"function"},{"location":"API/thermal/#ModelingToolkitStandardLibrary:-Thermal-Components","page":"Thermal Components","title":"ModelingToolkitStandardLibrary: Thermal Components","text":"","category":"section"},{"location":"API/thermal/","page":"Thermal Components","title":"Thermal Components","text":"CurrentModule = ModelingToolkitStandardLibrary.Thermal","category":"page"},{"location":"API/thermal/","page":"Thermal Components","title":"Thermal Components","text":"Pages = [\"thermal.md\"]","category":"page"},{"location":"API/thermal/#Index","page":"Thermal Components","title":"Index","text":"","category":"section"},{"location":"API/thermal/","page":"Thermal Components","title":"Thermal Components","text":"Pages = [\"thermal.md\"]","category":"page"},{"location":"API/thermal/#Thermal-Utilities","page":"Thermal Components","title":"Thermal Utilities","text":"","category":"section"},{"location":"API/thermal/","page":"Thermal Components","title":"Thermal Components","text":"HeatPort\nElement1D","category":"page"},{"location":"API/thermal/#ModelingToolkitStandardLibrary.Thermal.HeatPort","page":"Thermal Components","title":"ModelingToolkitStandardLibrary.Thermal.HeatPort","text":"HeatPort(; name, T = 273.15 + 20.0, Q_flow = 0.0)\n\nPort for a thermal system.\n\nStates:\n\nT: [K] Temperature of the port. It accepts an initial value, which defaults to 273.15 + 20.\nQ_flow: [W] Heat flow rate at the port. It accepts an initial value, which defaults to 0.0.\n\n\n\n\n\n","category":"constant"},{"location":"API/thermal/#ModelingToolkitStandardLibrary.Thermal.Element1D","page":"Thermal Components","title":"ModelingToolkitStandardLibrary.Thermal.Element1D","text":"Element1D(; name, dT = 0.0, Q_flow = 0.0)\n\nThis partial model contains the basic connectors and variables to allow heat transfer models to be created that do not store energy. This model defines and includes equations for the temperature drop across the element, dT, and the heat flow rate through the element from port_a to port_b, Q_flow.\n\nStates:\n\ndT: [K] Temperature difference across the component a.T - b.T. It accepts an initial value, which defaults to 0.0.\nQ_flow: [W] Heat flow rate from port a -> port b. It accepts an initial value, which defaults to 0.0.\n\nConnectors:\n\nport_a port_b\n\n\n\n\n\n","category":"constant"},{"location":"API/thermal/#Thermal-Components","page":"Thermal Components","title":"Thermal Components","text":"","category":"section"},{"location":"API/thermal/","page":"Thermal Components","title":"Thermal Components","text":"BodyRadiation\nConvectiveConductor\nConvectiveResistor\nHeatCapacitor\nThermalConductor\nThermalResistor\nThermalCollector","category":"page"},{"location":"API/thermal/#ModelingToolkitStandardLibrary.Thermal.BodyRadiation","page":"Thermal Components","title":"ModelingToolkitStandardLibrary.Thermal.BodyRadiation","text":"BodyRadiation(; name, G)\n\nLumped thermal element for radiation heat transfer.\n\nStates:\n\ndT: [K] Temperature difference across the component a.T - b.T\nQ_flow: [W] Heat flow rate from port a -> port b\n\nConnectors:\n\nport_a\nport_b\n\nParameters:\n\nG: [m^2] Net radiation conductance between two surfaces # Stefan-Boltzmann constant TODO: extract into physical constants module or use existing one\n\n\n\n\n\n","category":"constant"},{"location":"API/thermal/#ModelingToolkitStandardLibrary.Thermal.ConvectiveConductor","page":"Thermal Components","title":"ModelingToolkitStandardLibrary.Thermal.ConvectiveConductor","text":"ConvectiveConductor(; name, G)\n\nLumped thermal element for heat convection.\n\nStates:\n\ndT: [K] Temperature difference across the component solid.T - fluid.T\nQ_flow: [W] Heat flow rate from solid -> fluid\n\nConnectors:\n\nsolid\nfluid\n\nParameters:\n\nG: [W/K] Convective thermal conductance\n\n\n\n\n\n","category":"constant"},{"location":"API/thermal/#ModelingToolkitStandardLibrary.Thermal.ConvectiveResistor","page":"Thermal Components","title":"ModelingToolkitStandardLibrary.Thermal.ConvectiveResistor","text":"ConvectiveResistor(; name, R)\n\nLumped thermal element for heat convection.\n\nStates:\n\ndT: [K] Temperature difference across the component solid.T - fluid.T\nQ_flow: [W] Heat flow rate from solid -> fluid\n\nConnectors:\n\nsolid\nfluid\n\nParameters:\n\nR: [K/W] Constant thermal resistance of material\n\n\n\n\n\n","category":"constant"},{"location":"API/thermal/#ModelingToolkitStandardLibrary.Thermal.HeatCapacitor","page":"Thermal Components","title":"ModelingToolkitStandardLibrary.Thermal.HeatCapacitor","text":"HeatCapacitor(; name, C, T = 273.15 + 20)\n\nLumped thermal element storing heat\n\nStates:\n\nT: [K] Temperature of element. It accepts an initial value, which defaults to 273.15 + 20.\nder_T: [K/s] Time derivative of temperature\n\nConnectors:\n\nport\n\nParameters:\n\nC: [J/K] Heat capacity of element (= cp*m)\n\n\n\n\n\n","category":"constant"},{"location":"API/thermal/#ModelingToolkitStandardLibrary.Thermal.ThermalConductor","page":"Thermal Components","title":"ModelingToolkitStandardLibrary.Thermal.ThermalConductor","text":"ThermalConductor(; name, G)\n\nLumped thermal element transporting heat without storing it.\n\nStates:\n\nsee Element1D\n\nConnectors:\n\nport_a port_b\n\nParameters:\n\nG: [W/K] Constant thermal conductance of material\n\n\n\n\n\n","category":"constant"},{"location":"API/thermal/#ModelingToolkitStandardLibrary.Thermal.ThermalResistor","page":"Thermal Components","title":"ModelingToolkitStandardLibrary.Thermal.ThermalResistor","text":"ThermalResistor(; name, R)\n\nLumped thermal element transporting heat without storing it.\n\nStates:\n\ndT: [K] Temperature difference across the component a.T - b.T\nQ_flow: [W] Heat flow rate from port a -> port b\n\nConnectors:\n\nport_a\nport_b\n\nParameters:\n\nR: [K/W] Constant thermal resistance of material\n\n\n\n\n\n","category":"constant"},{"location":"API/thermal/#ModelingToolkitStandardLibrary.Thermal.ThermalCollector","page":"Thermal Components","title":"ModelingToolkitStandardLibrary.Thermal.ThermalCollector","text":"ThermalCollector(; name, m = 1)\n\nCollects m heat flows\n\nThis is a model to collect the heat flows from m heatports to one single heatport.\n\nStates:\n\nConnectors:\n\nport_a1 to port_am\nport_b\n\nParameters:\n\nm: Number of heat ports (e.g. m=2: port_a1, port_a2)\n\n\n\n\n\n","category":"function"},{"location":"API/thermal/#Thermal-Sensors","page":"Thermal Components","title":"Thermal Sensors","text":"","category":"section"},{"location":"API/thermal/","page":"Thermal Components","title":"Thermal Components","text":"RelativeTemperatureSensor\nHeatFlowSensor\nTemperatureSensor","category":"page"},{"location":"API/thermal/#ModelingToolkitStandardLibrary.Thermal.RelativeTemperatureSensor","page":"Thermal Components","title":"ModelingToolkitStandardLibrary.Thermal.RelativeTemperatureSensor","text":"RelativeTemperatureSensor(; name)\n\nRelative Temperature sensor.\n\nThe relative temperature port_a.T - port_b.T is determined between the two ports of this component and is provided as output signal in kelvin.\n\nStates:\n\nT(t): [K] Relative temperature a.T - b.T\n\nConnectors:\n\nport_a\nport_b\n\n\n\n\n\n","category":"constant"},{"location":"API/thermal/#ModelingToolkitStandardLibrary.Thermal.HeatFlowSensor","page":"Thermal Components","title":"ModelingToolkitStandardLibrary.Thermal.HeatFlowSensor","text":"HeatFlowSensor(; name)\n\nHeat flow rate sensor.\n\nThis model is capable of monitoring the heat flow rate flowing through this component. The sensed value of heat flow rate is the amount that passes through this sensor while keeping the temperature drop across the sensor zero. This is an ideal model, so it does not absorb any energy, and it has no direct effect on the thermal response of a system it is included in. The output signal is positive, if the heat flows from port_a to port_b.\n\nStates:\n\nQ_flow(t): [W] Heat flow from port_a to port_b\n\nConnectors:\n\nport_a\nport_b\n\n\n\n\n\n","category":"constant"},{"location":"API/thermal/#ModelingToolkitStandardLibrary.Thermal.TemperatureSensor","page":"Thermal Components","title":"ModelingToolkitStandardLibrary.Thermal.TemperatureSensor","text":"TemperatureSensor(; name)\n\nAbsolute temperature sensor in kelvin.\n\nThis is an ideal absolute temperature sensor which returns the temperature of the connected port in kelvin as an output signal. The sensor itself has no thermal interaction with whatever it is connected to. Furthermore, no thermocouple-like lags are associated with this sensor model.\n\nStates:\n\nT(t): [K] Absolute temperature\n\nConnectors:\n\nport\n\n\n\n\n\n","category":"constant"},{"location":"API/thermal/#Thermal-Sources","page":"Thermal Components","title":"Thermal Sources","text":"","category":"section"},{"location":"API/thermal/","page":"Thermal Components","title":"Thermal Components","text":"FixedHeatFlow\nFixedTemperature\nPrescribedHeatFlow\nPrescribedTemperature ","category":"page"},{"location":"API/thermal/#ModelingToolkitStandardLibrary.Thermal.FixedHeatFlow","page":"Thermal Components","title":"ModelingToolkitStandardLibrary.Thermal.FixedHeatFlow","text":"FixedHeatFlow(; name, Q_flow = 1.0, T_ref = 293.15, alpha = 0.0)\n\nFixed heat flow boundary condition.\n\nThis model allows a specified amount of heat flow rate to be \"injected\" into a thermal system at a given port. The constant amount of heat flow rate Q_flow is given as a parameter. The heat flows into the component to which the component FixedHeatFlow is connected, if parameter Q_flow is positive.\n\nConnectors:\n\nport\n\nParameters:\n\nQ_flow: [W] Fixed heat flow rate at port\nT_ref: [K] Reference temperature\nalpha: [1/K] Temperature coefficient of heat flow rate\n\n\n\n\n\n","category":"constant"},{"location":"API/thermal/#ModelingToolkitStandardLibrary.Thermal.FixedTemperature","page":"Thermal Components","title":"ModelingToolkitStandardLibrary.Thermal.FixedTemperature","text":"FixedTemperature(; name, T)\n\nFixed temperature boundary condition in kelvin.\n\nThis model defines a fixed temperature T at its port in kelvin, i.e., it defines a fixed temperature as a boundary condition.\n\nConnectors:\n\nport\n\nParameters:\n\nT: [K] Fixed temperature boundary condition\n\n\n\n\n\n","category":"constant"},{"location":"API/thermal/#ModelingToolkitStandardLibrary.Thermal.PrescribedHeatFlow","page":"Thermal Components","title":"ModelingToolkitStandardLibrary.Thermal.PrescribedHeatFlow","text":"PrescribedHeatFlow(; name, T_ref = 293.15, alpha = 0.0)\n\nPrescribed heat flow boundary condition.\n\nThis model allows a specified amount of heat flow rate to be \"injected\" into a thermal system at a given port. The amount of heat is given by the input signal Q_flow into the model. The heat flows into the component to which the component PrescribedHeatFlow is connected, if the input signal is positive. If parameter alpha is > 0, the heat flow is multiplied by 1 + alpha*(port.T - T_ref) in order to simulate temperature dependent losses (which are given a reference temperature T_ref).\n\nConnectors:\n\nport\nRealInput Q_flow Input for the heat flow\n\nParameters:\n\nT_ref: [K] Reference temperature\nalpha: [1/K] Temperature coefficient of heat flow rate\n\n\n\n\n\n","category":"constant"},{"location":"API/thermal/#ModelingToolkitStandardLibrary.Thermal.PrescribedTemperature","page":"Thermal Components","title":"ModelingToolkitStandardLibrary.Thermal.PrescribedTemperature","text":"PrescribedTemperature(; name)\n\nThis model represents a variable temperature boundary condition.\n\nThe temperature in kelvin is given as input signal to the RealInput T. The effect is that an instance of this model acts as an infinite reservoir, able to absorb or generate as much energy as required to keep the temperature at the specified value.\n\nConnectors:\n\nport\nRealInput T input for the temperature\n\n\n\n\n\n","category":"constant"},{"location":"tutorials/dc_motor_pi/#DC-Motor-with-PI-controller","page":"DC Motor with Speed Controller","title":"DC Motor with PI-controller","text":"","category":"section"},{"location":"tutorials/dc_motor_pi/","page":"DC Motor with Speed Controller","title":"DC Motor with Speed Controller","text":"In this example, a PI-controller is set up for speed control of a DC-motor. An equivalent circuit diagram is depicted below.","category":"page"},{"location":"tutorials/dc_motor_pi/","page":"DC Motor with Speed Controller","title":"DC Motor with Speed Controller","text":"(Image: DC-motor)","category":"page"},{"location":"tutorials/dc_motor_pi/#Modeling-and-simulation","page":"DC Motor with Speed Controller","title":"Modeling and simulation","text":"","category":"section"},{"location":"tutorials/dc_motor_pi/","page":"DC Motor with Speed Controller","title":"DC Motor with Speed Controller","text":"The electrical part consists of a resistance and inductance. The coupling between the electrical and rotational domain is done via an electro-motive force (EMF) component. The voltage across the EMF is proportional to the angular velocity and the current is proportional to the torque. On the mechanical side, viscous friction in, e.g., a bearing and the inertia of the shaft is modelled.","category":"page"},{"location":"tutorials/dc_motor_pi/","page":"DC Motor with Speed Controller","title":"DC Motor with Speed Controller","text":"A PI-controller with anti-windup measure should be used as a speed controller. A simulation is performed to verify the tracking performance of the controller and the disturbance rejection capabilities.","category":"page"},{"location":"tutorials/dc_motor_pi/","page":"DC Motor with Speed Controller","title":"DC Motor with Speed Controller","text":"First, the needed packages are imported and the parameters of the model defined.","category":"page"},{"location":"tutorials/dc_motor_pi/","page":"DC Motor with Speed Controller","title":"DC Motor with Speed Controller","text":"using ModelingToolkit\nusing ModelingToolkit: t_nounits as t\nusing ModelingToolkitStandardLibrary.Electrical\nusing ModelingToolkitStandardLibrary.Mechanical.Rotational\nusing ModelingToolkitStandardLibrary.Blocks\nusing OrdinaryDiffEq\nusing Plots\n\nR = 0.5 # [Ohm] armature resistance\nL = 4.5e-3 # [H] armature inductance\nk = 0.5 # [N.m/A] motor constant\nJ = 0.02 # [kg.m²] inertia\nf = 0.01 # [N.m.s/rad] friction factor\ntau_L_step = -0.3 # [N.m] amplitude of the load torque step\nnothing # hide","category":"page"},{"location":"tutorials/dc_motor_pi/","page":"DC Motor with Speed Controller","title":"DC Motor with Speed Controller","text":"The actual model can now be composed.","category":"page"},{"location":"tutorials/dc_motor_pi/","page":"DC Motor with Speed Controller","title":"DC Motor with Speed Controller","text":"@named ground = Ground()\n@named source = Voltage()\n@named ref = Blocks.Step(height = 1, start_time = 0)\n@named pi_controller = Blocks.LimPI(k = 1.1, T = 0.035, u_max = 10, Ta = 0.035)\n@named feedback = Blocks.Feedback()\n@named R1 = Resistor(R = R)\n@named L1 = Inductor(L = L)\n@named emf = EMF(k = k)\n@named fixed = Fixed()\n@named load = Torque()\n@named load_step = Blocks.Step(height = tau_L_step, start_time = 3)\n@named inertia = Inertia(J = J)\n@named friction = Damper(d = f)\n@named speed_sensor = SpeedSensor()\n\nconnections = [connect(fixed.flange, emf.support, friction.flange_b)\n connect(emf.flange, friction.flange_a, inertia.flange_a)\n connect(inertia.flange_b, load.flange)\n connect(inertia.flange_b, speed_sensor.flange)\n connect(load_step.output, load.tau)\n connect(ref.output, feedback.input1)\n connect(speed_sensor.w, :y, feedback.input2)\n connect(feedback.output, pi_controller.err_input)\n connect(pi_controller.ctr_output, :u, source.V)\n connect(source.p, R1.p)\n connect(R1.n, L1.p)\n connect(L1.n, emf.p)\n connect(emf.n, source.n, ground.g)]\n\n@named model = ODESystem(connections, t,\n systems = [\n ground,\n ref,\n pi_controller,\n feedback,\n source,\n R1,\n L1,\n emf,\n fixed,\n load,\n load_step,\n inertia,\n friction,\n speed_sensor\n ])\nnothing # hide","category":"page"},{"location":"tutorials/dc_motor_pi/","page":"DC Motor with Speed Controller","title":"DC Motor with Speed Controller","text":"Now the model can be simulated. Typical rotational mechanical systems are described via DAE (differential algebraic equations), however in this case, ModelingToolkit can simplify the model enough so that it can be represented as a system of ODEs (ordinary differential equations).","category":"page"},{"location":"tutorials/dc_motor_pi/","page":"DC Motor with Speed Controller","title":"DC Motor with Speed Controller","text":"sys = structural_simplify(model)\nprob = ODEProblem(sys, [], (0, 6.0))\nsol = solve(prob, Rodas4())\n\np1 = Plots.plot(sol.t, sol[inertia.w], ylabel = \"Angular Vel. in rad/s\",\n label = \"Measurement\", title = \"DC Motor with Speed Controller\")\nPlots.plot!(sol.t, sol[ref.output.u], label = \"Reference\")\np2 = Plots.plot(sol.t, sol[load.tau.u], ylabel = \"Disturbance in Nm\", label = \"\")\nPlots.plot(p1, p2, layout = (2, 1))","category":"page"},{"location":"tutorials/dc_motor_pi/#Closed-loop-analysis","page":"DC Motor with Speed Controller","title":"Closed-loop analysis","text":"","category":"section"},{"location":"tutorials/dc_motor_pi/","page":"DC Motor with Speed Controller","title":"DC Motor with Speed Controller","text":"When implementing and tuning a control system in simulation, it is a good practice to analyze the closed-loop properties and verify robustness of the closed-loop with respect to, e.g., modeling errors. To facilitate this, we added two analysis points to the set of connections above, more specifically, we added the analysis points named :y and :u to the connections (for more details on analysis points, see Linear Analysis)","category":"page"},{"location":"tutorials/dc_motor_pi/","page":"DC Motor with Speed Controller","title":"DC Motor with Speed Controller","text":"connect(speed_sensor.w, :y, feedback.input2)\nconnect(pi_controller.ctr_output, :u, source.V)","category":"page"},{"location":"tutorials/dc_motor_pi/","page":"DC Motor with Speed Controller","title":"DC Motor with Speed Controller","text":"one at the plant output (:y) and one at the plant input (:u). We may use these analysis points to calculate, e.g., sensitivity functions, illustrated below. Here, we calculate the sensitivity function S(s) and the complimentary sensitivity function T(s) = I - S(s), defined as","category":"page"},{"location":"tutorials/dc_motor_pi/","page":"DC Motor with Speed Controller","title":"DC Motor with Speed Controller","text":"beginaligned\nS(s) = dfrac1I + P(s)C(s) \nT(s) = dfracP(s)C(s)I + P(s)C(s)\nendaligned","category":"page"},{"location":"tutorials/dc_motor_pi/","page":"DC Motor with Speed Controller","title":"DC Motor with Speed Controller","text":"using ControlSystemsBase\nmatrices_S, simplified_sys = Blocks.get_sensitivity(model, :y)\nSo = ss(matrices_S...) |> minreal # The output-sensitivity function as a StateSpace system\nmatrices_T, simplified_sys = Blocks.get_comp_sensitivity(model, :y)\nTo = ss(matrices_T...)# The output complementary sensitivity function as a StateSpace system\nbodeplot([So, To], label = [\"S\" \"T\"], plot_title = \"Sensitivity functions\",\n plotphase = false)","category":"page"},{"location":"tutorials/dc_motor_pi/","page":"DC Motor with Speed Controller","title":"DC Motor with Speed Controller","text":"Similarly, we may compute the loop-transfer function and plot its Nyquist curve","category":"page"},{"location":"tutorials/dc_motor_pi/","page":"DC Motor with Speed Controller","title":"DC Motor with Speed Controller","text":"matrices_L, simplified_sys = Blocks.get_looptransfer(model, :y)\nL = -ss(matrices_L...) # The loop-transfer function as a StateSpace system. The negative sign is to negate the built-in negative feedback\nMs, ωMs = hinfnorm(So) # Compute the peak of the sensitivity function to draw a circle in the Nyquist plot\nnyquistplot(L, label = \"\\$L(s)\\$\", ylims = (-2.5, 0.5), xlims = (-1.2, 0.1),\n Ms_circles = Ms)","category":"page"},{"location":"API/electrical/#ModelingToolkitStandardLibrary:-Electrical-Components","page":"Electrical Components","title":"ModelingToolkitStandardLibrary: Electrical Components","text":"","category":"section"},{"location":"API/electrical/","page":"Electrical Components","title":"Electrical Components","text":"CurrentModule = ModelingToolkitStandardLibrary.Electrical","category":"page"},{"location":"API/electrical/","page":"Electrical Components","title":"Electrical Components","text":"Pages = [\"electrical.md\"]","category":"page"},{"location":"API/electrical/#Index","page":"Electrical Components","title":"Index","text":"","category":"section"},{"location":"API/electrical/","page":"Electrical Components","title":"Electrical Components","text":"Pages = [\"electrical.md\"]","category":"page"},{"location":"API/electrical/#Electrical-Utilities","page":"Electrical Components","title":"Electrical Utilities","text":"","category":"section"},{"location":"API/electrical/","page":"Electrical Components","title":"Electrical Components","text":"Pin\nOnePort\nDigitalPin","category":"page"},{"location":"API/electrical/#ModelingToolkitStandardLibrary.Electrical.Pin","page":"Electrical Components","title":"ModelingToolkitStandardLibrary.Electrical.Pin","text":"Pin(; name)\n\nA pin in an analog circuit.\n\nStates:\n\nv(t): [V] The voltage at this pin\ni(t): [A] The current passing through this pin\n\n\n\n\n\n","category":"constant"},{"location":"API/electrical/#ModelingToolkitStandardLibrary.Electrical.OnePort","page":"Electrical Components","title":"ModelingToolkitStandardLibrary.Electrical.OnePort","text":"OnePort(; name, v = 0.0, i = 0.0)\n\nComponent with two electrical pins p and n and current i flows from p to n.\n\nStates:\n\nv(t): [V] The voltage across component p.v - n.v\ni(t): [A] The current passing through positive pin\n\nConnectors:\n\np Positive pin\nn Negative pin\n\n\n\n\n\n","category":"constant"},{"location":"API/electrical/#ModelingToolkitStandardLibrary.Electrical.DigitalPin","page":"Electrical Components","title":"ModelingToolkitStandardLibrary.Electrical.DigitalPin","text":"DigitalPin(; name)\n\nA pin in a digital circuit.\n\nStates:\n\nv(t): [V] The voltage at this pin\ni(t): [A] The current passing through this pin\nval(t): The binary value of the pin at this point. A voltage from 0V to 0.8V is a binary value of 0.\n\nA voltage in the range 2.0V to 5.0V is 1. Any other value is X.\n\n\n\n\n\n","category":"function"},{"location":"API/electrical/#Analog-Components","page":"Electrical Components","title":"Analog Components","text":"","category":"section"},{"location":"API/electrical/","page":"Electrical Components","title":"Electrical Components","text":"Ground\nResistor\nConductor\nCapacitor\nInductor\nIdealOpAmp","category":"page"},{"location":"API/electrical/#ModelingToolkitStandardLibrary.Electrical.Ground","page":"Electrical Components","title":"ModelingToolkitStandardLibrary.Electrical.Ground","text":"Ground(; name)\n\nGround node with the potential of zero and connector g. Every circuit must have one ground node.\n\nConnectors:\n\ng\n\n\n\n\n\n","category":"constant"},{"location":"API/electrical/#ModelingToolkitStandardLibrary.Electrical.Resistor","page":"Electrical Components","title":"ModelingToolkitStandardLibrary.Electrical.Resistor","text":"Resistor(; name, R)\n\nCreates an ideal Resistor following Ohm's Law.\n\nStates:\n\nSee OnePort\n\nConnectors:\n\np Positive pin\nn Negative pin\n\nParameters:\n\nR: [Ohm] Resistance\n\n\n\n\n\n","category":"constant"},{"location":"API/electrical/#ModelingToolkitStandardLibrary.Electrical.Conductor","page":"Electrical Components","title":"ModelingToolkitStandardLibrary.Electrical.Conductor","text":"Conductor(; name, G)\n\nCreates an ideal conductor.\n\nStates:\n\nSee OnePort\n\nConnectors:\n\np Positive pin\nn Negative pin\n\nParameters:\n\nG: [S] Conductance\n\n\n\n\n\n","category":"constant"},{"location":"API/electrical/#ModelingToolkitStandardLibrary.Electrical.Capacitor","page":"Electrical Components","title":"ModelingToolkitStandardLibrary.Electrical.Capacitor","text":"Capacitor(; name, C, v)\n\nCreates an ideal capacitor. Initial voltage of capacitor can be set with v ([V])\n\nStates:\n\nSee OnePort\n\nConnectors:\n\np Positive pin\nn Negative pin\n\nParameters:\n\nC: [F] Capacitance\n\n\n\n\n\n","category":"constant"},{"location":"API/electrical/#ModelingToolkitStandardLibrary.Electrical.Inductor","page":"Electrical Components","title":"ModelingToolkitStandardLibrary.Electrical.Inductor","text":"Inductor(; name, L, i)\n\nCreates an ideal Inductor. Initial current through inductor can be set with i ([A]).\n\nStates:\n\nSee OnePort\n\nConnectors:\n\np Positive pin\nn Negative pin\n\nParameters:\n\nL: [H] Inductance\n\n\n\n\n\n","category":"constant"},{"location":"API/electrical/#ModelingToolkitStandardLibrary.Electrical.IdealOpAmp","page":"Electrical Components","title":"ModelingToolkitStandardLibrary.Electrical.IdealOpAmp","text":"IdealOpAmp(; name)\n\nIdeal operational amplifier (norator-nullator pair). The ideal OpAmp is a two-port. The left port is fixed to v1 = 0 and i1 = 0 (nullator). At the right port both any voltage v2 and any current i2 are possible (norator).\n\nStates:\n\nSee TwoPort\n\nConnectors:\n\np1 Positive pin (left port)\np2 Positive pin (right port)\nn1 Negative pin (left port)\nn2 Negative pin (right port)\n\n\n\n\n\n","category":"constant"},{"location":"API/electrical/#Analog-Sensors","page":"Electrical Components","title":"Analog Sensors","text":"","category":"section"},{"location":"API/electrical/","page":"Electrical Components","title":"Electrical Components","text":"CurrentSensor\nPotentialSensor\nVoltageSensor\nPowerSensor\nMultiSensor","category":"page"},{"location":"API/electrical/#ModelingToolkitStandardLibrary.Electrical.CurrentSensor","page":"Electrical Components","title":"ModelingToolkitStandardLibrary.Electrical.CurrentSensor","text":"CurrentSensor(; name)\n\nCreates a circuit component that measures the current flowing through it. Analogous to an ideal ammeter.\n\nStates:\n\ni(t): [A] Current through the sensor\n\nConnectors:\n\np Positive pin\nn Negative pin\n\n\n\n\n\n","category":"constant"},{"location":"API/electrical/#ModelingToolkitStandardLibrary.Electrical.PotentialSensor","page":"Electrical Components","title":"ModelingToolkitStandardLibrary.Electrical.PotentialSensor","text":"PotentialSensor(; name)\n\nCreates a circuit component which measures the potential at a pin.\n\nStates:\n\nphi(t): [V] The measured potential at this point\n\nConnectors:\n\np Pin at which potential is to be measured\n\n\n\n\n\n","category":"constant"},{"location":"API/electrical/#ModelingToolkitStandardLibrary.Electrical.VoltageSensor","page":"Electrical Components","title":"ModelingToolkitStandardLibrary.Electrical.VoltageSensor","text":"VoltageSensor(; name)\n\nCreates a circuit component that measures the voltage across it. Analogous to an ideal voltmeter.\n\nStates:\n\nv(t): [V] The voltage difference from positive to negative pin p.v - n.v\n\nConnectors:\n\np Positive pin\nn Negative pin\n\n\n\n\n\n","category":"constant"},{"location":"API/electrical/#ModelingToolkitStandardLibrary.Electrical.PowerSensor","page":"Electrical Components","title":"ModelingToolkitStandardLibrary.Electrical.PowerSensor","text":"PowerSensor(; name)\n\nCombines a VoltageSensor and a CurrentSensor to measure the power being consumed by a circuit.\n\nStates:\n\npower(t): [W] The power being consumed, given by the product of voltage and current\nSee VoltageSensor\nSee CurrentSensor\n\nConnectors:\n\npc Corresponds to the p pin of the CurrentSensor\nnc Corresponds to the n pin of the CurrentSensor\npv Corresponds to the p pin of the VoltageSensor\nnv Corresponds to the n pin of the VoltageSensor\n\n\n\n\n\n","category":"constant"},{"location":"API/electrical/#ModelingToolkitStandardLibrary.Electrical.MultiSensor","page":"Electrical Components","title":"ModelingToolkitStandardLibrary.Electrical.MultiSensor","text":"MultiSensor(; name)\n\nCombines a VoltageSensor and a CurrentSensor.\n\nStates:\n\nv(t): [V] The voltage across the VoltageSensor. Defaults to 1.0.\ni(t): [A] The current across the CurrentSensor. Defaults to 1.0.\n\nConnectors:\n\npc Corresponds to the p pin of the CurrentSensor\nnc Corresponds to the n pin of the CurrentSensor\npv Corresponds to the p pin of the VoltageSensor\nnv Corresponds to the n pin of the VoltageSensor\n\n\n\n\n\n","category":"constant"},{"location":"API/electrical/#Analog-Sources","page":"Electrical Components","title":"Analog Sources","text":"","category":"section"},{"location":"API/electrical/","page":"Electrical Components","title":"Electrical Components","text":"Voltage\nCurrent","category":"page"},{"location":"API/electrical/#ModelingToolkitStandardLibrary.Electrical.Voltage","page":"Electrical Components","title":"ModelingToolkitStandardLibrary.Electrical.Voltage","text":"Voltage(; name)\n\nActs as an ideal voltage source with no internal resistance.\n\nStates:\n\nSee OnePort\n\nConnectors:\n\np Positive pin\nn Negative pin\nV RealInput Input for the voltage control signal, i.e. V ~ p.v - n.v\n\n\n\n\n\n","category":"constant"},{"location":"API/electrical/#ModelingToolkitStandardLibrary.Electrical.Current","page":"Electrical Components","title":"ModelingToolkitStandardLibrary.Electrical.Current","text":"Current(; name)\n\nActs as an ideal current source with no internal resistance.\n\nStates:\n\nSee OnePort\n\nConnectors:\n\np Positive pin\nn Negative pin\nI RealInput Input for the current control signal, i.e. `I ~ p.i\n\n\n\n\n\n","category":"constant"},{"location":"API/electrical/#Digital-Gates","page":"Electrical Components","title":"Digital Gates","text":"","category":"section"},{"location":"API/electrical/","page":"Electrical Components","title":"Electrical Components","text":"Not\nAnd\nNand\nOr\nNor\nXor\nXnor","category":"page"},{"location":"API/electrical/#Digital-Components","page":"Electrical Components","title":"Digital Components","text":"","category":"section"},{"location":"API/electrical/","page":"Electrical Components","title":"Electrical Components","text":"HalfAdder\nFullAdder\nMUX\nDEMUX\nEncoder\nDecoder","category":"page"},{"location":"API/electrical/#Digital-Sources","page":"Electrical Components","title":"Digital Sources","text":"","category":"section"},{"location":"API/electrical/","page":"Electrical Components","title":"Electrical Components","text":"PulseDiff\nSet\nReset\nPulse","category":"page"},{"location":"connectors/connections/#Introduction","page":"About Acausal Connections","title":"Introduction","text":"","category":"section"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"In Physical Network Acausal modeling, each physical domain must define a connector to combine model components. Each physical domain connector defines a minimum of 2 variables, one which is called a Through variable, and one which is called an Across variable. Both Modelica and SimScape define these variables in the same way:","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Modelica Connectors\nSimScape Connectors","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"However, the standard libraries differ on the selection of the Across variable for the Mechanical Translation and Rotation libraries, Modelica choosing position and angle and SimScape choosing velocity and angular velocity, respectively for Translation and Rotation. Modelica describes their decision here. In summary, they would like to provide less integration in the model to avoid lossy numerical behavior, but this decision assumes the lowest order derivative is needed by the model. Numerically it is possible to define the connector either way, but there are some consequences of this decision, and therefore we will study them in detail here as they relate to ModelingToolkit.","category":"page"},{"location":"connectors/connections/#Through-and-Across-Variable-Theory","page":"About Acausal Connections","title":"Through and Across Variable Theory","text":"","category":"section"},{"location":"connectors/connections/#General","page":"About Acausal Connections","title":"General","text":"","category":"section"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"The idea behind the selection of the through variable is that it should be a time derivative of some conserved quantity. The conserved quantity should be expressed by the across variable. In general terms, the physical system is given by","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Energy Dissipation & Flow:","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"beginaligned\n partial colorblueacross partial t cdot c_1 = colorgreenthrough \n colorgreenthrough cdot c_2 = colorblueacross\nendaligned","category":"page"},{"location":"connectors/connections/#Electrical","page":"About Acausal Connections","title":"Electrical","text":"","category":"section"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"For the Electrical domain, the across variable is voltage and the through variable current. Therefore","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Energy Dissipation:","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"partial colorbluevoltage partial t cdot capacitance = colorgreencurrent","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Flow:","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"colorgreencurrent cdot resistance = colorbluevoltage","category":"page"},{"location":"connectors/connections/#Translational","page":"About Acausal Connections","title":"Translational","text":"","category":"section"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"For the translation domain, choosing velocity for the across variable and force for the through gives","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Energy Dissipation:","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"partial colorbluevelocity partial t cdot mass = colorgreenforce","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Flow:","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"colorgreenforce cdot (1damping) = colorbluevelocity","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"The diagram here shows the similarity of problems in different physical domains.","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"(Image: Through and Across Variables)","category":"page"},{"location":"connectors/connections/#Translational-Connector-using-*Position*-Across-Variable","page":"About Acausal Connections","title":"Translational Connector using Position Across Variable","text":"","category":"section"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Now, if we choose position for the across variable, a similar relationship can be established, but the pattern must be broken.","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Energy Dissipation:","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"partial^2 colorblueposition partial t^2 cdot mass = colorgreenforce","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Flow:","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"colorgreenforce cdot (1damping) = partial colorblueposition partial t","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"As can be seen, we must now establish a higher order derivative to define the Energy Dissipation and Flow equations, requiring an extra equation, as will be shown in the example below.","category":"page"},{"location":"connectors/connections/#Examples","page":"About Acausal Connections","title":"Examples","text":"","category":"section"},{"location":"connectors/connections/#Electrical-Domain","page":"About Acausal Connections","title":"Electrical Domain","text":"","category":"section"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"We can generate the above relationship with ModelingToolkit and the ModelingToolkitStandardLibrary using 3 blocks:","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Capacitor: for energy storage with initial voltage = 1V\nResistor: for energy flow\nGround: for energy sink","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"As can be seen, this will give a 1 equation model matching our energy dissipation relationship","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"using ModelingToolkitStandardLibrary.Electrical, ModelingToolkit, DifferentialEquations\nusing ModelingToolkit: t_nounits as t\nusing Plots\n\n@named resistor = Resistor(R = 1)\n@named capacitor = Capacitor(C = 1)\n@named ground = Ground()\n\neqs = [connect(capacitor.p, resistor.p)\n connect(resistor.n, ground.g, capacitor.n)]\n\n@named model = ODESystem(eqs, t; systems = [resistor, capacitor, ground])\n\nsys = structural_simplify(model)\n\nprintln.(equations(sys))\nnothing # hide","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"The solution shows what we would expect, a non-linear dissipation of voltage and related decrease in current flow…","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"prob = ODEProblem(sys, [1.0], (0, 10.0), [])\nsol = solve(prob)\n\np1 = plot(sol, idxs = [capacitor.v])\np2 = plot(sol, idxs = [resistor.i])\nplot(p1, p2)","category":"page"},{"location":"connectors/connections/#Mechanical-Translational-Domain","page":"About Acausal Connections","title":"Mechanical Translational Domain","text":"","category":"section"},{"location":"connectors/connections/#Across-Variable-velocity","page":"About Acausal Connections","title":"Across Variable = velocity","text":"","category":"section"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Now using the Translational library based on velocity, we can see the same relationship with a system reduced to a single equation, using the components:","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Body (i.e. moving mass): for kinetic energy storage with an initial velocity = 1m/s\nDamper: for energy flow\nFixed: for energy sink","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"using ModelingToolkitStandardLibrary\nconst TV = ModelingToolkitStandardLibrary.Mechanical.Translational\n\n@named damping = TV.Damper(d = 1, flange_a.v = 1)\n@named body = TV.Mass(m = 1, v = 1)\n@named ground = TV.Fixed()\n\neqs = [connect(damping.flange_a, body.flange)\n connect(ground.flange, damping.flange_b)]\n\n@named model = ODESystem(eqs, t; systems = [damping, body, ground])\n\nsys = structural_simplify(model)\n\nprintln.(full_equations(sys))\nnothing # hide","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"As expected, we have a similar solution…","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"prob = ODEProblem(sys, [], (0, 10.0), [])\nsol_v = solve(prob)\n\np1 = plot(sol_v, idxs = [body.v])\np2 = plot(sol_v, idxs = [damping.f])\nplot(p1, p2)","category":"page"},{"location":"connectors/connections/#Across-Variable-position","page":"About Acausal Connections","title":"Across Variable = position","text":"","category":"section"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Now, let's consider the position-based approach. We can build the same model with the same components. As can be seen, we now end of up with 2 equations, because we need to relate the lower derivative (position) to force (with acceleration).","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"const TP = ModelingToolkitStandardLibrary.Mechanical.TranslationalPosition\n\n@named damping = TP.Damper(d = 1, va = 1, vb = 0.0)\n@named body = TP.Mass(m = 1, v = 1)\n@named ground = TP.Fixed(s_0 = 0)\n\neqs = [connect(damping.flange_a, body.flange)\n connect(ground.flange, damping.flange_b)]\n\n@named model = ODESystem(eqs, t; systems = [damping, body, ground])\n\nsys = structural_simplify(model)\n\nprintln.(full_equations(sys))\nnothing # hide","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"As can be seen, we get exactly the same result. The only difference here is that we are solving an extra equation, which allows us to plot the body position as well.","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"prob = ODEProblem(sys, [], (0, 10.0), [])\nsol_p = solve(prob)\n\np1 = plot(sol_p, idxs = [body.v])\np2 = plot(sol_p, idxs = [damping.f])\np3 = plot(sol_p, idxs = [body.s])\n\nplot(p1, p2, p3)","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"The question then arises, can the position be plotted when using the Mechanical Translational Domain based on the Velocity Across variable? Yes, we can! There are 2 solutions:","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"the Mass component will add the position variable when the s parameter is used to set an initial position. Otherwise, the component does not track the position.","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"@named body = TV.Mass(m = 1, v = 1, s = 0)","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"implement a PositionSensor TODO: Implement Translation Sensors","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Either option will produce the same result regardless of which across variable is used. If the same result is given, why are both options included in the Standard Library, what are the differences? These differences will be discussed next so that an informed decision can be made about which domain is best for your model.","category":"page"},{"location":"connectors/connections/#Mechanical/Translational-Library-Differences-(Velocity-vs.-Position-Connectors)","page":"About Acausal Connections","title":"Mechanical/Translational Library Differences (Velocity vs. Position Connectors)","text":"","category":"section"},{"location":"connectors/connections/#Initialization","page":"About Acausal Connections","title":"Initialization","text":"","category":"section"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"The main difference between ModelingToolkitStandardLibrary.Mechanical.Translational and ModelingToolkitStandardLibrary.Mechanical.TranslationalPosition is how they are initialized. In the ModelingToolkitStandardLibrary initialization, parameters are defined at the component level, so we simply need to be careful to set the correct initial conditions for the domain that it used. Let's use the following example problem to explain the differences.","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"(Image: Example Mechanical Model)","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"In this problem, we have a mass, spring, and damper which are connected to a fixed point. Let's see how each component is defined.","category":"page"},{"location":"connectors/connections/#Damper","page":"About Acausal Connections","title":"Damper","text":"","category":"section"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"The damper will connect the flange/flange 1 (flange_a) to the mass, and flange/flange 2 (flange_b) to the fixed point. For both position- and velocity-based domains, we set the damping constant d=1 and va=1 and leave the default for v_b_0 at 0. For the position domain, we also need to set the initial positions for flange_a and flange_b.","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"@named dv = TV.Damper(d = 1, flange_a.v = 1)\n@named dp = TP.Damper(d = 1, va = 1, vb = 0.0, flange_a__s = 3, flange_b__s = 1)\nnothing # hide","category":"page"},{"location":"connectors/connections/#Spring","page":"About Acausal Connections","title":"Spring","text":"","category":"section"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"The spring will connect the flange/flange 1 (flange_a) to the mass, and flange/flange 2 (flange_b) to the fixed point. For both position- and velocity-based domains, we set the spring constant k=1. The velocity domain then requires the initial velocity va and initial spring stretch delta_s. The position domain instead needs the initial positions for flange_a and flange_b and the natural spring length l.","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"@named sv = TV.Spring(k = 1, flange_a__v = 1, delta_s = 1)\n@named sp = TP.Spring(k = 1, flange_a__s = 3, flange_b__s = 1, l = 1)\nnothing # hide","category":"page"},{"location":"connectors/connections/#Mass","page":"About Acausal Connections","title":"Mass","text":"","category":"section"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"For both position- and velocity-based domains, we set the mass m=1 and initial velocity v=1. Like the damper, the position domain requires the position initial conditions set as well.","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"@named bv = TV.Mass(m = 1, v = 1)\n@named bp = TP.Mass(m = 1, v = 1, s = 3)\nnothing # hide","category":"page"},{"location":"connectors/connections/#Fixed","page":"About Acausal Connections","title":"Fixed","text":"","category":"section"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Here the velocity domain requires no initial condition, but for our model to work as defined we must set the position domain component to the correct initial position.","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"@named gv = TV.Fixed()\n@named gp = TP.Fixed(s_0 = 1)\nnothing # hide","category":"page"},{"location":"connectors/connections/#Comparison","page":"About Acausal Connections","title":"Comparison","text":"","category":"section"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"As can be seen, the position-based domain requires more initial condition information to be properly defined, since the absolute position information is required. Therefore, based on the model being described, it may be more natural to choose one domain over the other.","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Let's define a quick function to simplify and solve the 2 different systems. Note, we will solve with a fixed time step and a set tolerance to compare the numerical differences.","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"function simplify_and_solve(damping, spring, body, ground)\n eqs = [connect(spring.flange_a, body.flange, damping.flange_a)\n connect(spring.flange_b, damping.flange_b, ground.flange)]\n\n @named model = ODESystem(eqs, t; systems = [ground, body, spring, damping])\n\n sys = structural_simplify(model)\n\n println.(full_equations(sys))\n\n prob = ODEProblem(sys, [], (0, 10.0), [])\n sol = solve(prob; dt = 0.1, adaptive = false, reltol = 1e-9, abstol = 1e-9)\n\n return sol\nend\nnothing # hide","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Now let's solve the velocity domain model","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"solv = simplify_and_solve(dv, sv, bv, gv);\nnothing # hide","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"And the position domain model","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"solp = simplify_and_solve(dp, sp, bp, gp);\nnothing # hide","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Now we can plot the comparison of the 2 models and see they give the same result.","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"plot(ylabel = \"mass velocity [m/s]\")\nplot!(solv, idxs = [bv.v])\nplot!(solp, idxs = [bp.v])","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"But, what if we wanted to plot the mass position? This is easy for the position-based domain, we have the state bp₊s(t), but for the velocity-based domain we have sv₊delta_s(t) which is the spring stretch. To get the absolute position, we add the spring natural length (1m) and the fixed position (1m). As can be seen, we then get the same result.","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"plot(ylabel = \"mass position [m]\")\nplot!(solv, idxs = [sv.delta_s + 1 + 1])\nplot!(solp, idxs = [bp.s])","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"So in conclusion, the position based domain gives easier access to absolute position information, but requires more initial condition information.","category":"page"},{"location":"connectors/connections/#Accuracy","page":"About Acausal Connections","title":"Accuracy","text":"","category":"section"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"One may then ask, what the trade-off in terms of numerical accuracy is. When we look at the simplified equations, we can see that actually both systems solve the same equations. The differential equations of the velocity domain are","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"beginaligned\nm cdot dotv + d cdot v + k cdot Delta s = 0 \ndotDelta s = v\nendaligned","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"And for the position domain are","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"beginaligned\nm cdot dotv + d cdot v + k cdot (s - s_b_0 - l) = 0 \ndots = v\nendaligned","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"By definition, the spring stretch is","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Delta s = s - s_b_0 - l","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Which means both systems are actually solving the same exact system. We can plot the numerical difference between the 2 systems and see the result is negligible.","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"plot(title = \"numerical difference: vel. vs. pos. domain\", xlabel = \"time [s]\",\n ylabel = \"solv[bv.v] .- solp[bp.v]\")\ntime = 0:0.1:10\nplot!(time, (solv(time)[bv.v] .- solp(time)[bp.v]), label = \"\")\nPlots.ylims!(-1e-15, 1e-15)","category":"page"},{"location":"tutorials/custom_component/#Custom-Component","page":"Custom Components","title":"Custom Component","text":"","category":"section"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"In this tutorial, the creation of a custom component is demonstrated via the Chua's circuit. The circuit is a simple circuit that shows chaotic behavior. Except for a non-linear resistor, every other component already is part of ModelingToolkitStandardLibrary.Electrical.","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"First, we need to make some imports.","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"using ModelingToolkit\nusing ModelingToolkit: t_nounits as t\nusing ModelingToolkitStandardLibrary.Electrical\nusing ModelingToolkitStandardLibrary.Electrical: OnePort\nusing OrdinaryDiffEq\nusing IfElse: ifelse\nusing Plots","category":"page"},{"location":"tutorials/custom_component/#Custom-Component-2","page":"Custom Components","title":"Custom Component","text":"","category":"section"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"Now the custom component can be defined. The Modelica implementation of the NonlinearResistor looks as follows:","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"model NonlinearResistor \"Chua's resistor\"\n extends Interfaces.OnePort;\n\n parameter SI.Conductance Ga \"conductance in inner voltage range\";\n parameter SI.Conductance Gb \"conductance in outer voltage range\";\n parameter SI.Voltage Ve \"inner voltage range limit\";\nequation\n i = if (v < -Ve) then Gb*(v + Ve) - Ga*Ve else if (v > Ve) then Gb*(v - Ve) + Ga*Ve else Ga*v;\nend NonlinearResistor;","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"this can almost be directly translated to the syntax of ModelingToolkit.","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"function NonlinearResistor(; name, Ga, Gb, Ve)\n @named oneport = OnePort()\n @unpack v, i = oneport\n pars = @parameters Ga=Ga Gb=Gb Ve=Ve\n eqs = [\n i ~ ifelse(v < -Ve,\n Gb * (v + Ve) - Ga * Ve,\n ifelse(v > Ve,\n Gb * (v - Ve) + Ga * Ve,\n Ga * v))\n ]\n extend(ODESystem(eqs, t, [], pars; name = name), oneport)\nend\nnothing # hide","category":"page"},{"location":"tutorials/custom_component/#Explanation","page":"Custom Components","title":"Explanation","text":"","category":"section"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"All components in ModelingToolkit are created via a function that serves as the constructor and returns some form of system, in this case, an ODESystem. Since the non-linear resistor is essentially a standard electrical component with two ports, we can extend from the OnePort component of the library.","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"@named oneport = OnePort()","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"This creates a OnePort with the name = :oneport. For easier notation, we can unpack the states of the component","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"@unpack v, i = oneport","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"It might be a good idea to create parameters for the constants of the NonlinearResistor.","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"pars = @parameters Ga=Ga Gb=Gb Ve=Ve","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"The syntax looks funny but it simply creates symbolic parameters with the name Ga where its default value is set from the function's argument Ga. While this is not strictly necessary it allows the user to remake the problem easily with different parameters or allow for auto-tuning or parameter optimization without having to do all the costly steps that may be involved with building and simplifying a model. The non-linear (in this case piece-wise constant) equation for the current can be implemented using IfElse.ifelse. Finally, the created oneport component is extended with the created equations and parameters. In this case, no extra state variables are added, hence an empty vector is supplied. The independent variable t needs to be supplied as the second argument.","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"extend(ODESystem(eqs, t, [], pars; name = name), oneport)","category":"page"},{"location":"tutorials/custom_component/#Building-the-Model","page":"Custom Components","title":"Building the Model","text":"","category":"section"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"The final model can now be created with the components from the library and the new custom component.","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"@named L = Inductor(L = 18)\n@named Ro = Resistor(R = 12.5e-3)\n@named G = Conductor(G = 0.565)\n@named C1 = Capacitor(C = 10, v = 4)\n@named C2 = Capacitor(C = 100)\n@named Nr = NonlinearResistor(Ga = -0.757576,\n Gb = -0.409091,\n Ve = 1)\n@named Gnd = Ground()\n\nconnections = [connect(L.p, G.p)\n connect(G.n, Nr.p)\n connect(Nr.n, Gnd.g)\n connect(C1.p, G.n)\n connect(L.n, Ro.p)\n connect(G.p, C2.p)\n connect(C1.n, Gnd.g)\n connect(C2.n, Gnd.g)\n connect(Ro.n, Gnd.g)]\n\n@named model = ODESystem(connections, t, systems = [L, Ro, G, C1, C2, Nr, Gnd])\nnothing # hide","category":"page"},{"location":"tutorials/custom_component/#Simulating-the-Model","page":"Custom Components","title":"Simulating the Model","text":"","category":"section"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"Now the model can be simulated. First, structural_simplify is called on the model and an ODEProblem is built from the result. Since the initial voltage of the first capacitor was already specified via v, no initial condition is given and an empty pair is supplied.","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"sys = structural_simplify(model)\nprob = ODEProblem(sys, Pair[], (0, 5e4), saveat = 0.01)\nsol = solve(prob, Rodas4())\n\nPlots.plot(sol[C1.v], sol[C2.v], title = \"Chaotic Attractor\", label = \"\",\n ylabel = \"C1 Voltage in V\", xlabel = \"C2 Voltage in V\")\nPlots.savefig(\"chua_phase_plane.png\")\nnothing # hide\n\nPlots.plot(sol; idxs = [C1.v, C2.v, L.i],\n labels = [\"C1 Voltage in V\" \"C2 Voltage in V\" \"Inductor Current in A\"])\nPlots.savefig(\"chua.png\")\nnothing # hide","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"(Image: Time series plot of C1.v, C2.v and L.i)","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"(Image: Phase plane plot of C1.v and C2.v)","category":"page"},{"location":"tutorials/rc_circuit/#RC-Circuit-Model","page":"RC Circuit","title":"RC Circuit Model","text":"","category":"section"},{"location":"tutorials/rc_circuit/","page":"RC Circuit","title":"RC Circuit","text":"This tutorial is a simplified version of the RC circuit tutorial in the ModelingToolkit.jl documentation. In that tutorial, the full RC circuit is built from scratch. Here, we will use the components of the Electrical model in the ModelingToolkit Standard Library to simply connect pre-made components and simulate the model.","category":"page"},{"location":"tutorials/rc_circuit/","page":"RC Circuit","title":"RC Circuit","text":"using ModelingToolkit, OrdinaryDiffEq, Plots\nusing ModelingToolkitStandardLibrary.Electrical\nusing ModelingToolkitStandardLibrary.Blocks: Constant\nusing ModelingToolkit: t_nounits as t\n\nR = 1.0\nC = 1.0\nV = 1.0\n@named resistor = Resistor(R = R)\n@named capacitor = Capacitor(C = C, v = 0.0)\n@named source = Voltage()\n@named constant = Constant(k = V)\n@named ground = Ground()\n\nrc_eqs = [connect(constant.output, source.V)\n connect(source.p, resistor.p)\n connect(resistor.n, capacitor.p)\n connect(capacitor.n, source.n, ground.g)]\n\n@named rc_model = ODESystem(rc_eqs, t,\n systems = [resistor, capacitor, constant, source, ground])\nsys = structural_simplify(rc_model)\nprob = ODEProblem(sys, Pair[], (0, 10.0))\nsol = solve(prob, Tsit5())\nplot(sol, idxs = [capacitor.v, resistor.i],\n title = \"RC Circuit Demonstration\",\n labels = [\"Capacitor Voltage\" \"Resistor Current\"])\nsavefig(\"plot.png\");\nnothing; # hide","category":"page"},{"location":"tutorials/rc_circuit/","page":"RC Circuit","title":"RC Circuit","text":"(Image: )","category":"page"},{"location":"API/mechanical/#ModelingToolkit-Standard-Library:-Mechanical-Components","page":"Mechanical Components","title":"ModelingToolkit Standard Library: Mechanical Components","text":"","category":"section"},{"location":"API/mechanical/","page":"Mechanical Components","title":"Mechanical Components","text":"Pages = [\"mechanical.md\"]\nDepth = 3","category":"page"},{"location":"API/mechanical/#Index","page":"Mechanical Components","title":"Index","text":"","category":"section"},{"location":"API/mechanical/","page":"Mechanical Components","title":"Mechanical Components","text":"Pages = [\"mechanical.md\"]","category":"page"},{"location":"API/mechanical/#Rotational-Components","page":"Mechanical Components","title":"Rotational Components","text":"","category":"section"},{"location":"API/mechanical/","page":"Mechanical Components","title":"Mechanical Components","text":"CurrentModule = ModelingToolkitStandardLibrary.Mechanical.Rotational","category":"page"},{"location":"API/mechanical/#Rotational-Utils","page":"Mechanical Components","title":"Rotational Utils","text":"","category":"section"},{"location":"API/mechanical/","page":"Mechanical Components","title":"Mechanical Components","text":"Flange\nSupport\nPartialCompliantWithRelativeStates\nPartialElementaryOneFlangeAndSupport2\nPartialElementaryTwoFlangesAndSupport2\nPartialCompliant","category":"page"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.Flange","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.Flange","text":"Support(;name)\n\n1-dim. rotational flange of a shaft.\n\nStates:\n\nphi(t): [rad] Absolute rotation angle of flange\ntau(t): [N.m] Cut torque in the flange\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.Support","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.Support","text":"Support(;name)\n\nSupport/housing of a 1-dim. rotational shaft\n\nStates:\n\nphi(t): [rad] Absolute rotation angle of the support/housing\ntau(t): [N.m] Cut torque in the support/housing\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.PartialCompliantWithRelativeStates","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.PartialCompliantWithRelativeStates","text":"PartialCompliantWithRelativeStates(; name, phi_rel = 0.0, tau = 0.0)\n\nPartial model for the compliant connection of two rotational 1-dim. shaft flanges where the relative angle and speed are used as preferred states\n\nStates:\n\nphi_rel(t): [rad] Relative rotation angle (= flangeb.phi - flangea.phi). It accepts an initial value, which defaults to 0.0.\nw_rel(t): [rad/s] Relative angular velocity (= D(phi_rel)). It accepts an initial value, which defaults to 0.0.\na_rel(t): [rad/s²] Relative angular acceleration (= D(w_rel)). It accepts an initial value, which defaults to 0.0.\ntau(t): [N.m] Torque between flanges (= flange_b.tau). It accepts an initial value, which defaults to 0.0.\n\nConnectors:\n\nflange_a Flange\nflange_b Flange\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.PartialElementaryOneFlangeAndSupport2","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.PartialElementaryOneFlangeAndSupport2","text":"PartialElementaryOneFlangeAndSupport2(; name, use_support = false)\n\nPartial model for a component with one rotational 1-dim. shaft flange and a support used for textual modeling, i.e., for elementary models\n\nStates:\n\nphi_support(t): [rad] Absolute angle of support flange\"\n\nConnectors:\n\nflange Flange\n\nParameters:\n\nuse_support: If support flange enabled, otherwise implicitly grounded\n\n\n\n\n\n","category":"function"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.PartialElementaryTwoFlangesAndSupport2","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.PartialElementaryTwoFlangesAndSupport2","text":"PartialElementaryTwoFlangesAndSupport2(;name, use_support=false)\n\nPartial model for a component with two rotational 1-dim. shaft flanges and a support used for textual modeling, i.e., for elementary models\n\nStates:\n\nphi_support(t): [rad] Absolute angle of support flange\n\nConnectors:\n\nflange_a Flange\nflange_b Flange\nsupport Support if use_support == true\n\nParameters:\n\nuse_support: If support flange enabled, otherwise implicitly grounded\n\n\n\n\n\n","category":"function"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.PartialCompliant","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.PartialCompliant","text":"PartialCompliant(; name, phi_rel = 0.0, tau = 0.0)\n\nPartial model for the compliant connection of two rotational 1-dim. shaft flanges.\n\nStates:\n\nphi_rel(t): [rad] Relative rotation angle (flange_b.phi - flange_a.phi). It accepts an initial value, which defaults to 0.0.\ntau(t): [N.m] Torque between flanges (flange_b.tau). It accepts an initial value, which defaults to 0.0.\n\nConnectors:\n\nflange_a Flange\nflange_b Flange\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#Rotational-Core-Components","page":"Mechanical Components","title":"Rotational Core Components","text":"","category":"section"},{"location":"API/mechanical/","page":"Mechanical Components","title":"Mechanical Components","text":"Fixed\nInertia\nSpring\nDamper\nSpringDamper\nIdealGear\nRotationalFriction","category":"page"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.Fixed","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.Fixed","text":"Fixed(;name, phi0 = 0.0)\n\nFlange fixed in housing at a given angle.\n\nConnectors:\n\nflange Flange\n\nParameters:\n\nphi0: [rad] Fixed offset angle of housing\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.Inertia","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.Inertia","text":"Inertia(;name, J, phi = 0.0, w = 0.0, a = 0.0)\n\n1D-rotational component with inertia.\n\nStates:\n\nphi: [rad] Absolute rotation angle of component\nw: [rad/s] Absolute angular velocity of component (= D(phi))\na: [rad/s²] Absolute angular acceleration of component (= D(w))\n\nConnectors:\n\nflange_a Flange Left flange\nflange_b Flange Right flange\n\nParameters:\n\nJ: [kg·m²] Moment of inertia\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.Spring","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.Spring","text":"Spring(; name, c, phi_rel0 = 0.0)\n\nLinear 1D rotational spring\n\nStates:\n\nphi_rel(t): [rad] Relative rotation angle (flange_b.phi - flange_a.phi)\ntau(t): [N.m] Torque between flanges (flange_b.tau)\n\nConnectors:\n\nflange_a Flange\nflange_b Flange\n\nParameters:\n\nc: [N.m/rad] Spring constant\nphi_rel0: [rad] Unstretched spring angle\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.Damper","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.Damper","text":"Damper(; name, d)\n\nLinear 1D rotational damper\n\nStates:\n\nphi_rel(t): [rad] Relative rotation angle (= flangeb.phi - flangea.phi)\nw_rel(t): [rad/s] Relative angular velocity (= D(phi_rel))\na_rel(t): [rad/s²] Relative angular acceleration (= D(w_rel))\ntau(t): [N.m] Torque between flanges (= flange_b.tau)\n\nConnectors:\n\nflange_a Flange\nflange_b Flange\n\nParameters:\n\nd: [N.m.s/rad] Damping constant\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.SpringDamper","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.SpringDamper","text":"SpringDamper(; name, d)\n\nLinear 1D rotational spring and damper\n\nStates:\n\nphi_rel(t): [rad] Relative rotation angle (= flangeb.phi - flangea.phi)\nw_rel(t): [rad/s] Relative angular velocity (= D(phi_rel))\na_rel(t): [rad/s²] Relative angular acceleration (= D(w_rel))\ntau(t): [N.m] Torque between flanges (= flange_b.tau)\n\nConnectors:\n\nflange_a Flange\nflange_b Flange\n\nParameters:\n\nd: [N.m.s/rad] Damping constant\nc: [N.m/rad] Spring constant\nphi_rel0: [rad] Unstretched spring angle\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.IdealGear","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.IdealGear","text":"IdealGear(; name, ratio, use_support = false)\n\nIdeal gear without inertia.\n\nThis element characterizes any type of gear box which is fixed in the ground and which has one driving shaft and one driven shaft.\n\nStates:\n\nphi_a(t): [rad] Relative angle between shaft a and the support\nphi_b(t): [rad] Relative angle between shaft b and the support\n\nConnectors:\n\nflange_a Flange\nflange_b Flange\nsupport Support if use_support == true\n\nParameters:\n\nratio: Transmission ratio (flangea.phi/flangeb.phi)\nuse_support: If support flange enabled, otherwise implicitly grounded. By default it is false\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.RotationalFriction","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.RotationalFriction","text":"RotationalFriction(; name, f, tau_c, w_brk, tau_brk)\n\nModels rotational friction with Stribeck effect, Coulomb friction and viscous friction between the two flanges. The friction torque is a function of the relative angular velocity between flange_a and flange_b.\n\nFriction model: \"Armstrong, B. and C.C. de Wit, Friction Modeling and Compensation, The Control Handbook, CRC Press, 1995.\"\n\nStates:\n\nphi_rel(t): [rad] Relative rotation angle (= flange_b.phi - flange_a.phi)\nw_rel(t): [rad/s] Relative angular velocity (= D(phi_rel))\na_rel(t): [rad/s²] Relative angular acceleration (= D(w_rel))\ntau(t): [N.m] Torque between flanges (= flange_b.tau)\n\nConnectors:\n\nflange_a Flange\nflange_b Flange\n\nParameters:\n\nf: [N⋅m/(rad/s)] Viscous friction coefficient\ntau_c: [N⋅m] Coulomb friction torque\nw_brk: [rad/s] Breakaway friction velocity\ntau_brk: [N⋅m] Breakaway friction torque\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#Rotational-Sources","page":"Mechanical Components","title":"Rotational Sources","text":"","category":"section"},{"location":"API/mechanical/","page":"Mechanical Components","title":"Mechanical Components","text":"Torque\nSpeed","category":"page"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.Torque","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.Torque","text":"Torque(; name, use_support = false)\n\nInput signal acting as external torque on a flange\n\nStates:\n\nphi_support(t): [rad] Absolute angle of support flange\n\nConnectors:\n\nflange Flange\ntau RealInput Accelerating torque acting at flange -flange.tau\n\nParameters:\n\nuse_support\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.Speed","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.Speed","text":"Speed(; name, use_support = false, exact = false, f_crit = 50)\n\nForced movement of a flange according to a reference angular velocity signal\n\nStates:\n\nphi_support(t): [rad] Absolute angle of support flange\"\n\nConnectors:\n\nflange Flange\nw_ref RealInput Reference angular velocity of flange with respect to support as input signal needs to be continuously differential\n\nParameters:\n\nuse_support: If support flange enabled, otherwise implicitly grounded\nexact: true/false exact treatment/filtering the input signal\ntau_filt: [rad/s] if exact=false, Time constant of low-pass filter to filter input signal\n\n\n\n\n\n","category":"function"},{"location":"API/mechanical/#Rotational-Sensors","page":"Mechanical Components","title":"Rotational Sensors","text":"","category":"section"},{"location":"API/mechanical/","page":"Mechanical Components","title":"Mechanical Components","text":"AngleSensor\nSpeedSensor\nTorqueSensor\nRelSpeedSensor","category":"page"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.AngleSensor","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.AngleSensor","text":"AngleSensor(; name)\n\nIdeal sensor to measure the absolute flange angle\n\nConnectors:\n\nflange: Flange Flange of shaft from which sensor information shall be measured\nphi: RealOutput Absolute angle of flange\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.SpeedSensor","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.SpeedSensor","text":"SpeedSensor(; name)\n\nIdeal sensor to measure the absolute flange angular velocity\n\nConnectors:\n\nflange: Flange Flange of shaft from which sensor information shall be measured\nw: RealOutput Absolute angular velocity of flange\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.TorqueSensor","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.TorqueSensor","text":"TorqueSensor(;name)\n\nIdeal sensor to measure the torque between two flanges (= flange_a.tau)\n\nConnectors:\n\nflange_a: Flange Left flange of shaft\nflange_b: Flange Left flange of shaft\ntau: RealOutput Torque in flange flangea and flangeb (tau = flange_a.tau = -flange_b.tau)\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.RelSpeedSensor","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.RelSpeedSensor","text":"RelSpeedSensor(; name)\n\nIdeal sensor to measure the relative angular velocity\n\nConnectors:\n\nflange_a: Flange Flange of shaft from which sensor information shall be measured\nflange_b: Flange Flange of shaft from which sensor information shall be measured\nw: RealOutput Absolute angular velocity of flange\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#Translational-Components","page":"Mechanical Components","title":"Translational Components","text":"","category":"section"},{"location":"API/mechanical/","page":"Mechanical Components","title":"Mechanical Components","text":"CurrentModule = ModelingToolkitStandardLibrary.Mechanical.Translational","category":"page"},{"location":"API/mechanical/#Translational-Utils","page":"Mechanical Components","title":"Translational Utils","text":"","category":"section"},{"location":"API/mechanical/","page":"Mechanical Components","title":"Mechanical Components","text":"MechanicalPort","category":"page"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Translational.MechanicalPort","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Translational.MechanicalPort","text":"MechanicalPort(;name)\n\n1-dim. rotational flange of a shaft.\n\nStates:\n\nv: [m/s] velocity of the node\nf: [N] force entering the node\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#Translational-Core-Components","page":"Mechanical Components","title":"Translational Core Components","text":"","category":"section"},{"location":"API/mechanical/","page":"Mechanical Components","title":"Mechanical Components","text":"Mass\nSpring\nDamper\nFixed","category":"page"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Translational.Mass","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Translational.Mass","text":"Mass(; name, v_0 = 0.0, m, s = nothing, g = nothing)\n\nSliding mass with inertia\n\nParameters:\n\nm: [kg] mass of sliding body\nv_0: [m/s] Initial value of absolute linear velocity of sliding mass (default 0 m/s)\ns: [m] initial value of absolute position of sliding mass (optional)\ng: [m/s²] gravity field acting on the mass, positive value acts in the positive direction (optional)\n\nStates:\n\nv: [m/s] absolute linear velocity of sliding mass\ns: [m] absolute position of sliding mass (optional with parameter s)\n\nConnectors:\n\nflange: 1-dim. translational flange\n\n\n\n\n\n","category":"function"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Translational.Spring","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Translational.Spring","text":"Spring(; name, k, delta_s = 0.0, va=0.0, v_b_0=0.0)\n\nLinear 1D translational spring\n\nParameters:\n\nk: [N/m] Spring constant\ndelta_s: initial spring stretch\nva: [m/s] Initial value of absolute linear velocity at flange_a (default 0 m/s)\nv_b_0: [m/s] Initial value of absolute linear velocity at flange_b (default 0 m/s)\n\nConnectors:\n\nflange_a: 1-dim. translational flange on one side of spring\nflange_b: 1-dim. translational flange on opposite side of spring\n\n\n\n\n\n","category":"function"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Translational.Damper","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Translational.Damper","text":"Damper(; name, d, flange_a.v = 0.0, flange_b.v = 0.0)\n\nLinear 1D translational damper\n\nParameters:\n\nd: [N.s/m] Damping constant\n\nConnectors:\n\nflange_a: 1-dim. translational flange on one side of damper. Initial value of state v is set to 0.0 m/s.\nflange_b: 1-dim. translational flange on opposite side of damper. Initial value of state v is set to 0.0 m/s.\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Translational.Fixed","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Translational.Fixed","text":"Fixed(; name)\n\nFixes a flange position (velocity = 0)\n\nConnectors:\n\nflange: 1-dim. translational flange\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#Translational-Sources","page":"Mechanical Components","title":"Translational Sources","text":"","category":"section"},{"location":"API/mechanical/","page":"Mechanical Components","title":"Mechanical Components","text":"Force\nPosition\nVelocity\nAcceleration","category":"page"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Translational.Force","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Translational.Force","text":"Force(; name)\n\nLinear 1D force input source\n\nConnectors:\n\nflange: 1-dim. translational flange\nf: real input\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Translational.Position","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Translational.Position","text":"Position(solves_force = true; name)\n\nLinear 1D position input source. Set solves_force=false to force input force to 0 (i.e. only the position is given, the respective force needed is already provided elsewhere in the model). \n\nConnectors:\n\nflange: 1-dim. translational flange\ns: real input\n\n\n\n\n\n","category":"function"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Translational.Velocity","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Translational.Velocity","text":"Velocity(solves_force = true; name)\n\nLinear 1D position input source. Set solves_force=false to force input force to 0 (i.e. only the velocity is given, the respective force needed is already provided elsewhere in the model). \n\nConnectors:\n\nflange: 1-dim. translational flange\nv: real input\n\n\n\n\n\n","category":"function"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Translational.Acceleration","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Translational.Acceleration","text":"Acceleration(solves_force = true; name)\n\nLinear 1D position input source. Set solves_force=false to force input force to 0 (i.e. only the acceleration is given, the respective force needed is already provided elsewhere in the model). \n\nConnectors:\n\nflange: 1-dim. translational flange\na: real input\n\n\n\n\n\n","category":"function"},{"location":"API/mechanical/#Translational-Sensors","page":"Mechanical Components","title":"Translational Sensors","text":"","category":"section"},{"location":"API/mechanical/","page":"Mechanical Components","title":"Mechanical Components","text":"ForceSensor\nPositionSensor\nAccelerationSensor","category":"page"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Translational.ForceSensor","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Translational.ForceSensor","text":"ForceSensor(; name)\n\nLinear 1D force input sensor.\n\nConnectors:\n\nflange: 1-dim. translational flange\noutput: real output\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Translational.PositionSensor","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Translational.PositionSensor","text":"PositionSensor(; s = 0, name)\n\nLinear 1D position input sensor.\n\nStates:\n\ns: [m] absolute position (with initial value of 0.0)\n\nConnectors:\n\nflange: 1-dim. translational flange\noutput: real output\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Translational.AccelerationSensor","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Translational.AccelerationSensor","text":"AccelerationSensor(; name)\n\nLinear 1D position input sensor.\n\nStates:\n\na: [m/s^2] measured acceleration\n\nConnectors:\n\nflange: 1-dim. translational flange\noutput: real output\n\n\n\n\n\n","category":"constant"},{"location":"API/linear_analysis/#Linear-Analysis","page":"Linear Analysis","title":"Linear Analysis","text":"","category":"section"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"danger: Experimental\nThe interface described here is currently experimental and at any time subject to breaking changes not respecting semantic versioning.","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"Linear analysis refers to the process of linearizing a nonlinear model and analysing the resulting linear dynamical system. To facilitate linear analysis, ModelingToolkitStandardLibrary provides the concept of an AnalysisPoint, which can be inserted in-between two causal blocks (such as those from the Blocks sub module). Once a model containing analysis points is built, several operations are available:","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"get_sensitivity get the sensitivity function (wiki), S(s), as defined in the field of control theory.\nget_comp_sensitivity get the complementary sensitivity function T(s) S(s)+T(s)=1.\nget_looptransfer get the (open) loop-transfer function where the loop starts and ends in the analysis point. For a typical simple feedback connection with a plant P(s) and a controller C(s), the loop-transfer function at the plant output is P(s)C(s).\nlinearize can be called with two analysis points denoting the input and output of the linearized system.\nopen_loop return a new (nonlinear) system where the loop has been broken in the analysis point, i.e., the connection the analysis point usually implies has been removed.","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"An analysis point can be created explicitly using the constructor AnalysisPoint, or automatically when connecting two causal components using connect:","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"connect(comp1.output, :analysis_point_name, comp2.input)","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"warning: Causality\nAnalysis points are causal, i.e., they imply a directionality for the flow of information. The order of the connections in the connect statement is thus important, i.e., connect(out, :name, in) is different from connect(in, :name, out).","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"The directionality of an analysis point can be thought of as an arrow in a block diagram, where the name of the analysis point applies to the arrow itself.","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"┌─────┐ ┌─────┐\n│ │ name │ │\n│ out├────────►│in │\n│ │ │ │\n└─────┘ └─────┘","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"This is signified by the name being the middle argument to connect.","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"Of the above mentioned functions, all except for open_loop return the output of ModelingToolkit.linearize, which is","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"matrices, simplified_sys = linearize(...)\n# matrices = (; A, B, C, D)","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"i.e., matrices is a named tuple containing the matrices of a linear state-space system on the form","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"beginaligned\ndot x = Ax + Bu\ny = Cx + Du\nendaligned","category":"page"},{"location":"API/linear_analysis/#Example","page":"Linear Analysis","title":"Example","text":"","category":"section"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"The following example builds a simple closed-loop system with a plant P and a controller C. Two analysis points are inserted, one before and one after P. We then derive a number of sensitivity functions and show the corresponding code using the package ControlSystemBase.jl","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"using ModelingToolkitStandardLibrary.Blocks, ModelingToolkit\n@named P = FirstOrder(k = 1, T = 1) # A first-order system with pole in -1\n@named C = Gain(-1) # A P controller\nt = ModelingToolkit.get_iv(P)\neqs = [connect(P.output, :plant_output, C.input) # Connect with an automatically created analysis point called :plant_output\n connect(C.output, :plant_input, P.input)]\nsys = ODESystem(eqs, t, systems = [P, C], name = :feedback_system)\n\nmatrices_S = get_sensitivity(sys, :plant_input)[1] # Compute the matrices of a state-space representation of the (input)sensitivity function.\nmatrices_T = get_comp_sensitivity(sys, :plant_input)[1]","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"Continued linear analysis and design can be performed using ControlSystemsBase.jl. We create ControlSystemsBase.StateSpace objects using","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"using ControlSystemsBase, Plots\nS = ss(matrices_S...)\nT = ss(matrices_T...)\nbodeplot([S, T], lab = [\"S\" \"\" \"T\" \"\"], plot_title = \"Bode plot of sensitivity functions\",\n margin = 5Plots.mm)","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"The sensitivity functions obtained this way should be equivalent to the ones obtained with the code below","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"using ControlSystemsBase\nP = tf(1.0, [1, 1]) |> ss\nC = 1 # Negative feedback assumed in ControlSystems\nS = sensitivity(P, C) # or feedback(1, P*C)\nT = comp_sensitivity(P, C) # or feedback(P*C)","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"We may also derive the loop-transfer function L(s) = P(s)C(s) using","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"matrices_L = get_looptransfer(sys, :plant_output)[1]\nL = ss(matrices_L...)","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"which is equivalent to the following with ControlSystems","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"L = P * (-C) # Add the minus sign to build the negative feedback into the controller","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"To obtain the transfer function between two analysis points, we call linearize","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"using ModelingToolkit # hide\nmatrices_PS = linearize(sys, :plant_input, :plant_output)[1]","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"this particular transfer function should be equivalent to the linear system P(s)S(s), i.e., equivalent to","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"feedback(P, C)","category":"page"},{"location":"API/linear_analysis/#Obtaining-transfer-functions","page":"Linear Analysis","title":"Obtaining transfer functions","text":"","category":"section"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"A statespace system from ControlSystemsBase can be converted to a transfer function using the function tf:","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"tf(S)","category":"page"},{"location":"API/linear_analysis/#Gain-and-phase-margins","page":"Linear Analysis","title":"Gain and phase margins","text":"","category":"section"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"Further linear analysis can be performed using the analysis methods from ControlSystemsBase. For example, calculating the gain and phase margins of a system can be done using","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"margin(P)","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"(they are infinite for this system). A Nyquist plot can be produced using","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"nyquistplot(P)","category":"page"},{"location":"API/linear_analysis/#Index","page":"Linear Analysis","title":"Index","text":"","category":"section"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"Pages = [\"linear_analysis.md\"]","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"Modules = [ModelingToolkitStandardLibrary.Blocks]\nPages = [\"Blocks/analysis_points.jl\"]\nOrder = [:function, :type]\nPrivate = false","category":"page"},{"location":"API/linear_analysis/#ModelingToolkitStandardLibrary.Blocks.get_comp_sensitivity","page":"Linear Analysis","title":"ModelingToolkitStandardLibrary.Blocks.get_comp_sensitivity","text":"get_comp_sensitivity(sys, ap::AnalysisPoint; kwargs)\nget_comp_sensitivity(sys, ap_name::Symbol; kwargs)\n\nCompute the complementary sensitivity function in analysis point ap. The complementary sensitivity function is obtained by introducing an infinitesimal perturbation d at the output of ap, linearizing the system and computing the transfer function between d and the input of ap.\n\ndanger: Experimental\nThe analysis-point interface is currently experimental and at any time subject to breaking changes not respecting semantic versioning.\n\nArguments:\n\nkwargs: Are sent to ModelingToolkit.linearize\n\nSee also get_sensitivity, get_looptransfer.\n\n\n\n\n\n","category":"function"},{"location":"API/linear_analysis/#ModelingToolkitStandardLibrary.Blocks.get_looptransfer","page":"Linear Analysis","title":"ModelingToolkitStandardLibrary.Blocks.get_looptransfer","text":"get_looptransfer(sys, ap::AnalysisPoint; kwargs)\nget_looptransfer(sys, ap_name::Symbol; kwargs)\n\nCompute the (linearized) loop-transfer function in analysis point ap, from ap.out to ap.in.\n\ninfo: Negative feedback\nFeedback loops often use negative feedback, and the computed loop-transfer function will in this case have the negative feedback included. Standard analysis tools often assume a loop-transfer function without the negative gain built in, and the result of this function may thus need negation before use.\n\ndanger: Experimental\nThe analysis-point interface is currently experimental and at any time subject to breaking changes not respecting semantic versioning.\n\nArguments:\n\nkwargs: Are sent to ModelingToolkit.linearize\n\nSee also get_sensitivity, get_comp_sensitivity, open_loop.\n\n\n\n\n\n","category":"function"},{"location":"API/linear_analysis/#ModelingToolkitStandardLibrary.Blocks.get_sensitivity","page":"Linear Analysis","title":"ModelingToolkitStandardLibrary.Blocks.get_sensitivity","text":"get_sensitivity(sys, ap::AnalysisPoint; kwargs)\nget_sensitivity(sys, ap_name::Symbol; kwargs)\n\nCompute the sensitivity function in analysis point ap. The sensitivity function is obtained by introducing an infinitesimal perturbation d at the input of ap, linearizing the system and computing the transfer function between d and the output of ap.\n\ndanger: Experimental\nThe analysis-point interface is currently experimental and at any time subject to breaking changes not respecting semantic versioning.\n\nArguments:\n\nkwargs: Are sent to ModelingToolkit.linearize\n\nSee also get_comp_sensitivity, get_looptransfer.\n\n\n\n\n\n","category":"function"},{"location":"API/linear_analysis/#ModelingToolkitStandardLibrary.Blocks.open_loop-Tuple{Any, Symbol}","page":"Linear Analysis","title":"ModelingToolkitStandardLibrary.Blocks.open_loop","text":"open_sys = open_loop(sys, ap::AnalysisPoint; kwargs)\nopen_sys = open_loop(sys, ap_name::Symbol; kwargs)\n\nOpen the loop at analysis point ap by breaking the connection through ap.\n\nopen_sys will have u ~ ap.out as input and y ~ ap.in as output.\n\ndanger: Experimental\nThe analysis-point interface is currently experimental and at any time subject to breaking changes not respecting semantic versioning.\n\nArguments:\n\nkwargs: Are sent to ModelingToolkit.linearize\n\nSee also get_sensitivity, get_comp_sensitivity, get_looptransfer.\n\n\n\n\n\n","category":"method"},{"location":"API/linear_analysis/#ModelingToolkitStandardLibrary.Blocks.AnalysisPoint-Tuple{Any, Any}","page":"Linear Analysis","title":"ModelingToolkitStandardLibrary.Blocks.AnalysisPoint","text":"AnalysisPoint(in, out, name::Symbol)\nAnalysisPoint(in, out; name::Symbol)\nAnalysisPoint(name::Symbol)\n\nCreate an AnalysisPoint for linear analysis. Analysis points can also be created automatically by calling\n\nconnect(in, :ap_name, out)\n\ndanger: Experimental\nThe analysis-point interface is currently experimental and at any time subject to breaking changes not respecting semantic versioning.\n\nArguments:\n\nin: A connector of type RealOutput.\nout: A connector of type RealInput.\nname: The name of the analysis point.\n\nSee also get_sensitivity, get_comp_sensitivity, get_looptransfer, open_loop\n\nExample\n\nusing ModelingToolkitStandardLibrary.Blocks\n@named P = FirstOrder(k = 1, T = 1)\n@named C = Gain(; k = -1)\nt = ModelingToolkit.get_iv(P)\neqs = [connect(P.output, C.input)\n connect(C.output, :plant_input, P.input)]\nsys = ODESystem(eqs, t, systems = [P, C], name = :feedback_system)\n\nmatrices_S, _ = get_sensitivity(sys, :plant_input) # Compute the matrices of a state-space representation of the (input) sensitivity function.\nmatrices_T, _ = get_comp_sensitivity(sys, :plant_input)\n\nContinued linear analysis and design can be performed using ControlSystemsBase.jl. Create ControlSystemsBase.StateSpace objects using\n\nusing ControlSystemsBase, Plots\nS = ss(matrices_S...)\nT = ss(matrices_T...)\nbodeplot([S, T], lab = [\"S\" \"T\"])\n\nThe sensitivity functions obtained this way should be equivalent to the ones obtained with the code below\n\nusing ControlSystemsBase\nP = tf(1.0, [1, 1])\nC = 1 # Negative feedback assumed in ControlSystems\nS = sensitivity(P, C) # or feedback(1, P*C)\nT = comp_sensitivity(P, C) # or feedback(P*C)\n\n\n\n\n\n","category":"method"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"ModelingToolkit.linearize","category":"page"},{"location":"API/linear_analysis/#ModelingToolkit.linearize","page":"Linear Analysis","title":"ModelingToolkit.linearize","text":"(; A, B, C, D), simplified_sys = linearize(sys, inputs, outputs; t=0.0, op = Dict(), allow_input_derivatives = false, zero_dummy_der=false, kwargs...)\n(; A, B, C, D) = linearize(simplified_sys, lin_fun; t=0.0, op = Dict(), allow_input_derivatives = false, zero_dummy_der=false)\n\nLinearize sys between inputs and outputs, both vectors of variables. Return a NamedTuple with the matrices of a linear statespace representation on the form\n\nbeginaligned\nx = Ax + Bu\ny = Cx + Du\nendaligned\n\nThe first signature automatically calls linearization_function internally, while the second signature expects the outputs of linearization_function as input.\n\nop denotes the operating point around which to linearize. If none is provided, the default values of sys are used.\n\nIf allow_input_derivatives = false, an error will be thrown if input derivatives (u) appear as inputs in the linearized equations. If input derivatives are allowed, the returned B matrix will be of double width, corresponding to the input [u; u̇].\n\nzero_dummy_der can be set to automatically set the operating point to zero for all dummy derivatives.\n\nSee also linearization_function which provides a lower-level interface, linearize_symbolic and ModelingToolkit.reorder_unknowns.\n\nSee extended help for an example.\n\nThe implementation and notation follows that of \"Linear Analysis Approach for Modelica Models\", Allain et al. 2009\n\nExtended help\n\nThis example builds the following feedback interconnection and linearizes it from the input of F to the output of P.\n\n\n r ┌─────┐ ┌─────┐ ┌─────┐\n───►│ ├──────►│ │ u │ │\n │ F │ │ C ├────►│ P │ y\n └─────┘ ┌►│ │ │ ├─┬─►\n │ └─────┘ └─────┘ │\n │ │\n └─────────────────────┘\n\nusing ModelingToolkit\n@variables t\nfunction plant(; name)\n @variables x(t) = 1\n @variables u(t)=0 y(t)=0\n D = Differential(t)\n eqs = [D(x) ~ -x + u\n y ~ x]\n ODESystem(eqs, t; name = name)\nend\n\nfunction ref_filt(; name)\n @variables x(t)=0 y(t)=0\n @variables u(t)=0 [input = true]\n D = Differential(t)\n eqs = [D(x) ~ -2 * x + u\n y ~ x]\n ODESystem(eqs, t, name = name)\nend\n\nfunction controller(kp; name)\n @variables y(t)=0 r(t)=0 u(t)=0\n @parameters kp = kp\n eqs = [\n u ~ kp * (r - y),\n ]\n ODESystem(eqs, t; name = name)\nend\n\n@named f = ref_filt()\n@named c = controller(1)\n@named p = plant()\n\nconnections = [f.y ~ c.r # filtered reference to controller reference\n c.u ~ p.u # controller output to plant input\n p.y ~ c.y]\n\n@named cl = ODESystem(connections, t, systems = [f, c, p])\n\nlsys0, ssys = linearize(cl, [f.u], [p.x])\ndesired_order = [f.x, p.x]\nlsys = ModelingToolkit.reorder_unknowns(lsys0, unknowns(ssys), desired_order)\n\n@assert lsys.A == [-2 0; 1 -2]\n@assert lsys.B == [1; 0;;]\n@assert lsys.C == [0 1]\n@assert lsys.D[] == 0\n\n## Symbolic linearization\nlsys_sym, _ = ModelingToolkit.linearize_symbolic(cl, [f.u], [p.x])\n\n@assert substitute(lsys_sym.A, ModelingToolkit.defaults(cl)) == lsys.A\n\n\n\n\n\nModelingToolkit.linearize(sys, input_name::Symbol, output_name; kwargs...)\n\nLinearize a system between two analysis points. To get a loop-transfer function, see get_looptransfer.\n\nThe output is allowed to be either an analysis-point name, or a vector of symbolic variables like the standard interface to linearize. The input must be an analysis-point name.\n\n\n\n\n\n","category":"function"},{"location":"tutorials/input_component/#Running-Models-with-Discrete-Data","page":"SampledData Component","title":"Running Models with Discrete Data","text":"","category":"section"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"There are 3 ways to include data as part of a model.","category":"page"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"using ModelingToolkitStandardLibrary.Blocks.TimeVaryingFunction\nusing a custom component with external data\nusing ModelingToolkitStandardLibrary.Blocks.SampledData","category":"page"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"This tutorial demonstrate each case and explain the pros and cons of each.","category":"page"},{"location":"tutorials/input_component/#TimeVaryingFunction-Component","page":"SampledData Component","title":"TimeVaryingFunction Component","text":"","category":"section"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"The ModelingToolkitStandardLibrary.Blocks.TimeVaryingFunction component is easy to use and is performant. However the data is locked to the ODESystem and can only be changed by building a new ODESystem. Therefore, running a batch of data would not be efficient. Below is an example of how to use the TimeVaryingFunction with DataInterpolations to build the function from sampled discrete data.","category":"page"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"using ModelingToolkit\nusing ModelingToolkit: t_nounits as t, D_nounits as D\nusing ModelingToolkitStandardLibrary.Blocks\nusing DataInterpolations\nusing OrdinaryDiffEq\n\nfunction System(f; name)\n src = TimeVaryingFunction(f)\n\n vars = @variables f(t)=0 x(t)=0 dx(t)=0 ddx(t)=0\n pars = @parameters m=10 k=1000 d=1\n\n eqs = [f ~ src.output.u\n ddx * 10 ~ k * x + d * dx + f\n D(x) ~ dx\n D(dx) ~ ddx]\n\n ODESystem(eqs, t, vars, pars; systems = [src], name)\nend\n\ndt = 4e-4\ntime = 0:dt:0.1\ndata = sin.(2 * pi * time * 100) # example data\n\nf = LinearInterpolation(data, time)\n\n@named system = System(f)\nsys = structural_simplify(system)\nprob = ODEProblem(sys, [], (0, time[end]))\nsol = solve(prob, ImplicitEuler())","category":"page"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"If we want to run a new data set, this requires building a new LinearInterpolation and ODESystem followed by running structural_simplify, all of which takes time. Therefore, to run several pieces of data it's better to re-use an ODESystem. The next couple methods will demonstrate how to do this.","category":"page"},{"location":"tutorials/input_component/#Custom-Component-with-External-Data","page":"SampledData Component","title":"Custom Component with External Data","text":"","category":"section"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"The below code shows how to include data using a Ref and registered get_sampled_data function. This example uses a very basic function which requires non-adaptive solving and sampled data. As can be seen, the data can easily be set and changed before solving.","category":"page"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"const rdata = Ref{Vector{Float64}}()\n\n# Data Sets\ndata1 = sin.(2 * pi * time * 100)\ndata2 = cos.(2 * pi * time * 50)\n\nfunction get_sampled_data(t)\n i = floor(Int, t / dt) + 1\n x = rdata[][i]\n\n return x\nend\n\nSymbolics.@register_symbolic get_sampled_data(t)\n\nfunction System(; name)\n vars = @variables f(t)=0 x(t)=0 dx(t)=0 ddx(t)=0\n pars = @parameters m=10 k=1000 d=1\n\n eqs = [f ~ get_sampled_data(t)\n ddx * 10 ~ k * x + d * dx + f\n D(x) ~ dx\n D(dx) ~ ddx]\n\n ODESystem(eqs, t, vars, pars; name)\nend\n\n@named system = System()\nsys = structural_simplify(system)\nprob = ODEProblem(sys, [], (0, time[end]))\n\nrdata[] = data1\nsol1 = solve(prob, ImplicitEuler(); dt, adaptive = false)\nddx1 = sol1[sys.ddx]\n\nrdata[] = data2\nsol2 = solve(prob, ImplicitEuler(); dt, adaptive = false)\nddx2 = sol2[sys.ddx]","category":"page"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"The drawback of this method is that the solution observables can be linked to the data Ref, which means that if the data changes then the observables are no longer valid. In this case ddx is an observable that is derived directly from the data. Therefore, sol1[sys.ddx] is no longer correct after the data is changed for sol2.","category":"page"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"# the following test will fail\n@test all(ddx1 .== sol1[sys.ddx]) #returns false","category":"page"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"Additional code could be added to resolve this issue, for example by using a Ref{Dict} that could link a parameter of the model to the data source. This would also be necessary for parallel processing.","category":"page"},{"location":"tutorials/input_component/#SampledData-Component","page":"SampledData Component","title":"SampledData Component","text":"","category":"section"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"To resolve the issues presented above, the ModelingToolkitStandardLibrary.Blocks.SampledData component can be used which allows for a resusable ODESystem and self contained data which ensures a solution which remains valid for it's lifetime. Now it's possible to also parallelize the call to solve().","category":"page"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"function System(; name)\n src = SampledData(Float64)\n\n vars = @variables f(t)=0 x(t)=0 dx(t)=0 ddx(t)=0\n pars = @parameters m=10 k=1000 d=1\n\n eqs = [f ~ src.output.u\n ddx * 10 ~ k * x + d * dx + f\n D(x) ~ dx\n D(dx) ~ ddx]\n\n ODESystem(eqs, t, vars, pars; systems = [src], name)\nend\n\n@named system = System()\nsys = structural_simplify(system)\ns = complete(system)\nprob = ODEProblem(sys, [], (0, time[end]); tofloat = false)\ndefs = ModelingToolkit.defaults(sys)\n\nfunction get_prob(data)\n defs[s.src.buffer] = Parameter(data, dt)\n # ensure p is a uniform type of Vector{Parameter{Float64}} (converting from Vector{Any})\n p = Parameter.(ModelingToolkit.varmap_to_vars(defs, parameters(sys); tofloat = false))\n remake(prob; p)\nend\n\nprob1 = get_prob(data1)\nprob2 = get_prob(data2)\n\nsol1 = Ref{ODESolution}()\nsol2 = Ref{ODESolution}()\n@sync begin\n @async sol1[] = solve(prob1, ImplicitEuler())\n @async sol2[] = solve(prob2, ImplicitEuler())\nend","category":"page"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"Note, in the above example, we can build the system with an empty SampledData component, only setting the expected data type: @named src = SampledData(Float64). It's also possible to initialize the component with real sampled data: @named src = SampledData(data, dt). Additionally note that before running an ODEProblem using the SampledData component, one must be careful about the parameter vector Type. The SampledData component contains a buffer parameter of type Parameter, therefore we must generate the problem using tofloat=false. This will initially give a parameter vector of type Vector{Any} with a mix of numbers and Parameter type. We can convert the vector to a uniform Parameter type by running p = Parameter.(p). This will wrap all the single values in a Parameter which will be mathematically equivalent to a Number.","category":"page"},{"location":"#ModelingToolkitStandardLibrary.jl","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"ModelingToolkitStandardLibrary.jl","text":"","category":"section"},{"location":"","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","text":"ModelingToolkitStandardLibrary.jl is a standard library for the ModelingToolkit acausal modeling system.","category":"page"},{"location":"#Installation","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"Installation","text":"","category":"section"},{"location":"","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","text":"To install ModelingToolkitStandardLibrary.jl, use the Julia package manager:","category":"page"},{"location":"","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","text":"using Pkg\nPkg.add(\"ModelingToolkitStandardLibrary\")","category":"page"},{"location":"#Tutorials","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"Tutorials","text":"","category":"section"},{"location":"","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","text":"RC Circuit\nCustom Component\nThermal Model\nDC Motor with PI-controller","category":"page"},{"location":"#Libraries","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"Libraries","text":"","category":"section"},{"location":"","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","text":"The following are the constituent libraries of the ModelingToolkit Standard Library.","category":"page"},{"location":"","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","text":"Basic Blocks\nMechanical Components\nElectrical Components\nMagnetic Components\nThermal Components\nHydraulic Components","category":"page"},{"location":"#Contributing","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"Contributing","text":"","category":"section"},{"location":"","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","text":"Please refer to the SciML ColPrac: Contributor's Guide on Collaborative Practices for Community Packages for guidance on PRs, issues, and other matters relating to contributing to SciML.\nSee the SciML Style Guide for common coding practices and other style decisions.\nThere are a few community forums:\nThe #diffeq-bridged and #sciml-bridged channels in the Julia Slack\nThe #diffeq-bridged and #sciml-bridged channels in the Julia Zulip\nOn the Julia Discourse forums\nSee also SciML Community page","category":"page"},{"location":"#Reproducibility","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"Reproducibility","text":"","category":"section"},{"location":"","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","text":"
The documentation of this SciML package was built using these direct dependencies,","category":"page"},{"location":"","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","text":"using Pkg # hide\nPkg.status() # hide","category":"page"},{"location":"","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","text":"
","category":"page"},{"location":"","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","text":"
and using this machine and Julia version.","category":"page"},{"location":"","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","text":"using InteractiveUtils # hide\nversioninfo() # hide","category":"page"},{"location":"","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","text":"
","category":"page"},{"location":"","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","text":"
A more complete overview of all dependencies and their versions is also provided.","category":"page"},{"location":"","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","text":"using Pkg # hide\nPkg.status(; mode = PKGMODE_MANIFEST) # hide","category":"page"},{"location":"","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","text":"
","category":"page"},{"location":"","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","text":"using TOML\nusing Markdown\nversion = TOML.parse(read(\"../../Project.toml\", String))[\"version\"]\nname = TOML.parse(read(\"../../Project.toml\", String))[\"name\"]\nlink_manifest = \"https://github.com/SciML/\" * name * \".jl/tree/gh-pages/v\" * version *\n \"/assets/Manifest.toml\"\nlink_project = \"https://github.com/SciML/\" * name * \".jl/tree/gh-pages/v\" * version *\n \"/assets/Project.toml\"\nMarkdown.parse(\"\"\"You can also download the\n[manifest]($link_manifest)\nfile and the\n[project]($link_project)\nfile.\n\"\"\")","category":"page"}] +[{"location":"API/magnetic/#ModelingToolkitStandardLibrary:-Magnetic-Components","page":"Magnetic Components","title":"ModelingToolkitStandardLibrary: Magnetic Components","text":"","category":"section"},{"location":"API/magnetic/","page":"Magnetic Components","title":"Magnetic Components","text":"Pages = [\"magnetic.md\"]","category":"page"},{"location":"API/magnetic/#Index","page":"Magnetic Components","title":"Index","text":"","category":"section"},{"location":"API/magnetic/","page":"Magnetic Components","title":"Magnetic Components","text":"Pages = [\"magnetic.md\"]","category":"page"},{"location":"API/magnetic/#Flux-Tubes","page":"Magnetic Components","title":"Flux Tubes","text":"","category":"section"},{"location":"API/magnetic/","page":"Magnetic Components","title":"Magnetic Components","text":"CurrentModule = ModelingToolkitStandardLibrary.Magnetic.FluxTubes","category":"page"},{"location":"API/magnetic/#Flux-Tube-Utilities","page":"Magnetic Components","title":"Flux Tube Utilities","text":"","category":"section"},{"location":"API/magnetic/","page":"Magnetic Components","title":"Magnetic Components","text":"PositiveMagneticPort\nNegativeMagneticPort\nTwoPort","category":"page"},{"location":"API/magnetic/#ModelingToolkitStandardLibrary.Magnetic.FluxTubes.PositiveMagneticPort","page":"Magnetic Components","title":"ModelingToolkitStandardLibrary.Magnetic.FluxTubes.PositiveMagneticPort","text":"Positive magnetic port\n\n\n\n\n\n","category":"constant"},{"location":"API/magnetic/#ModelingToolkitStandardLibrary.Magnetic.FluxTubes.NegativeMagneticPort","page":"Magnetic Components","title":"ModelingToolkitStandardLibrary.Magnetic.FluxTubes.NegativeMagneticPort","text":"Negative magnetic port\n\n\n\n\n\n","category":"constant"},{"location":"API/magnetic/#ModelingToolkitStandardLibrary.Magnetic.FluxTubes.TwoPort","page":"Magnetic Components","title":"ModelingToolkitStandardLibrary.Magnetic.FluxTubes.TwoPort","text":"TwoPort(; name, V_m = 0.0, Phi = 0.0)\n\nPartial component with magnetic potential difference between two magnetic ports p and n and magnetic flux Phi from p to n.\n\nParameters:\n\nV_m: Initial magnetic potential difference between both ports\nPhi: Initial magnetic flux from portp to portn\n\n\n\n\n\n","category":"constant"},{"location":"API/magnetic/#Basic-Flux-Tube-Blocks","page":"Magnetic Components","title":"Basic Flux Tube Blocks","text":"","category":"section"},{"location":"API/magnetic/","page":"Magnetic Components","title":"Magnetic Components","text":"Ground\nIdle\nShort\nCrossing\nConstantPermeance\nConstantReluctance\nEddyCurrent\nElectroMagneticConverter","category":"page"},{"location":"API/magnetic/#ModelingToolkitStandardLibrary.Magnetic.FluxTubes.Ground","page":"Magnetic Components","title":"ModelingToolkitStandardLibrary.Magnetic.FluxTubes.Ground","text":"Ground(; name)\n\nZero magnetic potential.\n\n\n\n\n\n","category":"constant"},{"location":"API/magnetic/#ModelingToolkitStandardLibrary.Magnetic.FluxTubes.Idle","page":"Magnetic Components","title":"ModelingToolkitStandardLibrary.Magnetic.FluxTubes.Idle","text":"Idle(;name)\n\nIdle running branch.\n\n\n\n\n\n","category":"constant"},{"location":"API/magnetic/#ModelingToolkitStandardLibrary.Magnetic.FluxTubes.Short","page":"Magnetic Components","title":"ModelingToolkitStandardLibrary.Magnetic.FluxTubes.Short","text":"Short(;name)\n\nShort cut branch.\n\n\n\n\n\n","category":"constant"},{"location":"API/magnetic/#ModelingToolkitStandardLibrary.Magnetic.FluxTubes.Crossing","page":"Magnetic Components","title":"ModelingToolkitStandardLibrary.Magnetic.FluxTubes.Crossing","text":"Crossing(;name)\n\nCrossing of two branches.\n\nThis is a simple crossing of two branches. The ports portp1 and portp2 are connected, as well as portn1 and portn2.\n\n\n\n\n\n","category":"constant"},{"location":"API/magnetic/#ModelingToolkitStandardLibrary.Magnetic.FluxTubes.ConstantPermeance","page":"Magnetic Components","title":"ModelingToolkitStandardLibrary.Magnetic.FluxTubes.ConstantPermeance","text":"ConstantPermeance(; name, G_m = 1.0)\n\nConstant permeance.\n\nParameters:\n\nG_m: [H] Magnetic permeance\n\n\n\n\n\n","category":"constant"},{"location":"API/magnetic/#ModelingToolkitStandardLibrary.Magnetic.FluxTubes.ConstantReluctance","page":"Magnetic Components","title":"ModelingToolkitStandardLibrary.Magnetic.FluxTubes.ConstantReluctance","text":"ConstantReluctance(; name, R_m = 1.0)\n\nConstant reluctance.\n\nParameters:\n\nR_m: [H^-1] Magnetic reluctance\n\n\n\n\n\n","category":"constant"},{"location":"API/magnetic/#ModelingToolkitStandardLibrary.Magnetic.FluxTubes.EddyCurrent","page":"Magnetic Components","title":"ModelingToolkitStandardLibrary.Magnetic.FluxTubes.EddyCurrent","text":"EddyCurrent(;name, Phi, rho = 0.098e-6, l = 1, A = 1)\n\nFor modelling of eddy current in a conductive magnetic flux tube. Initial magnetic flux flowing into the port_p can be set with Phi ([Wb])\n\nParameters:\n\nrho: [ohm * m] Resistivity of flux tube material (default: Iron at 20degC)\nl: [m] Average length of eddy current path\nA: [m^2] Cross sectional area of eddy current path\n\n\n\n\n\n","category":"constant"},{"location":"API/magnetic/#ModelingToolkitStandardLibrary.Magnetic.FluxTubes.ElectroMagneticConverter","page":"Magnetic Components","title":"ModelingToolkitStandardLibrary.Magnetic.FluxTubes.ElectroMagneticConverter","text":"ElectroMagneticConverter(; name, N, Phi)\n\nIdeal electromagnetic energy conversion.\n\nThe electromagnetic energy conversion is given by Ampere's law and Faraday's law respectively V_m = N * i N * dΦ/dt = -v\n\nInitial magnetic flux flowing into the port_p can be set with Phi ([Wb])\n\nParameters:\n\nN: Number of turns\n\n\n\n\n\n","category":"constant"},{"location":"API/magnetic/#Flux-Tube-Sources","page":"Magnetic Components","title":"Flux Tube Sources","text":"","category":"section"},{"location":"API/magnetic/","page":"Magnetic Components","title":"Magnetic Components","text":"ConstantMagneticPotentialDifference\nConstantMagneticFlux","category":"page"},{"location":"API/magnetic/#ModelingToolkitStandardLibrary.Magnetic.FluxTubes.ConstantMagneticPotentialDifference","page":"Magnetic Components","title":"ModelingToolkitStandardLibrary.Magnetic.FluxTubes.ConstantMagneticPotentialDifference","text":"ConstantMagneticPotentialDifference(; name, V_m = 0.0)\n\nConstant magnetomotive force.\n\nParameters:\n\nV_m: [A] Magnetic potential difference\n\n\n\n\n\n","category":"constant"},{"location":"API/magnetic/#ModelingToolkitStandardLibrary.Magnetic.FluxTubes.ConstantMagneticFlux","page":"Magnetic Components","title":"ModelingToolkitStandardLibrary.Magnetic.FluxTubes.ConstantMagneticFlux","text":"ConstantMagneticFlux(; name, Phi = 0.0)\n\nSource of constant magnetic flux.\n\nParameters:\n\nPhi: [Wb] Magnetic flux\n\n\n\n\n\n","category":"constant"},{"location":"tutorials/thermal_model/#Heat-Conduction-Model","page":"Thermal Conduction Model","title":"Heat Conduction Model","text":"","category":"section"},{"location":"tutorials/thermal_model/","page":"Thermal Conduction Model","title":"Thermal Conduction Model","text":"This example demonstrates the thermal response of two masses connected by a conducting element. The two masses have the same heat capacity but different initial temperatures (T1=100 [°C], T2=0 [°C]). The mass with the higher temperature will cool off, while the mass with the lower temperature heats up. They will each asymptotically approach the calculated temperature TfinalK that results from dividing the total initial energy in the system by the sum of the heat capacities of each element.","category":"page"},{"location":"tutorials/thermal_model/","page":"Thermal Conduction Model","title":"Thermal Conduction Model","text":"using ModelingToolkitStandardLibrary.Thermal, ModelingToolkit, OrdinaryDiffEq, Plots\nusing ModelingToolkit: t_nounits as t\n\nC1 = 15\nC2 = 15\n@named mass1 = HeatCapacitor(C = C1, T = 373.15)\n@named mass2 = HeatCapacitor(C = C2, T = 273.15)\n@named conduction = ThermalConductor(G = 10)\n@named Tsensor1 = TemperatureSensor()\n@named Tsensor2 = TemperatureSensor()\n\nconnections = [\n connect(mass1.port, conduction.port_a),\n connect(conduction.port_b, mass2.port),\n connect(mass1.port, Tsensor1.port),\n connect(mass2.port, Tsensor2.port)\n]\n\n@named model = ODESystem(connections, t,\n systems = [mass1, mass2, conduction, Tsensor1, Tsensor2])\nsys = structural_simplify(model)\nprob = ODEProblem(sys, Pair[], (0, 5.0))\nsol = solve(prob, Tsit5())\n\nT_final_K = sol[(mass1.T * C1 + mass2.T * C2) / (C1 + C2)]\n\nplot(title = \"Thermal Conduction Demonstration\")\nplot!(sol, idxs = [mass1.T, mass2.T], labels = [\"Mass 1 Temperature\" \"Mass 2 Temperature\"])\nplot!(sol.t, T_final_K, label = \"Steady-State Temperature\")\nsavefig(\"thermal_plot.png\");\nnothing; # hide","category":"page"},{"location":"tutorials/thermal_model/","page":"Thermal Conduction Model","title":"Thermal Conduction Model","text":"(Image: Plot of Temperatures)","category":"page"},{"location":"API/hydraulic/#hydraulic","page":"Hydraulic Components","title":"ModelingToolkit Standard Library: Hydraulic Components","text":"","category":"section"},{"location":"API/hydraulic/","page":"Hydraulic Components","title":"Hydraulic Components","text":"Pages = [\"hydraulic.md\"]\nDepth = 3","category":"page"},{"location":"API/hydraulic/#Index","page":"Hydraulic Components","title":"Index","text":"","category":"section"},{"location":"API/hydraulic/","page":"Hydraulic Components","title":"Hydraulic Components","text":"Pages = [\"hydraulic.md\"]","category":"page"},{"location":"API/hydraulic/#IsothermalCompressible-Components","page":"Hydraulic Components","title":"IsothermalCompressible Components","text":"","category":"section"},{"location":"API/hydraulic/","page":"Hydraulic Components","title":"Hydraulic Components","text":"CurrentModule = ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible","category":"page"},{"location":"API/hydraulic/#IsothermalCompressible-Utils","page":"Hydraulic Components","title":"IsothermalCompressible Utils","text":"","category":"section"},{"location":"API/hydraulic/","page":"Hydraulic Components","title":"Hydraulic Components","text":"HydraulicPort\nHydraulicFluid\nfriction_factor","category":"page"},{"location":"API/hydraulic/#ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.HydraulicPort","page":"Hydraulic Components","title":"ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.HydraulicPort","text":"HydraulicPort(;p_int, name)\n\nConnector port for hydraulic components.\n\nArguments:\n\np_int: [Pa] initial gauge pressure\n\nStates:\n\np: [Pa] gauge total pressure\ndm: [kg/s] mass flow\n\n\n\n\n\n","category":"function"},{"location":"API/hydraulic/#ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.HydraulicFluid","page":"Hydraulic Components","title":"ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.HydraulicFluid","text":"HydraulicFluid(; density = 997, bulk_modulus = 2.09e9, viscosity = 0.0010016, gas_density = 0.0073955, gas_pressure = -1000, n = 1, let_gas = 1, name)\n\nFluid parameter setter for isothermal compressible fluid domain. Defaults given for water at 20°C and 0Pa gage (1atm absolute) reference pressure. Density is modeled using the Tait equation of state. For pressures below the reference pressure, density is linearly interpolated to the gas state (when let_gas is set to 1), this helps prevent pressures from going below the reference pressure. \n\nParameters:\n\nρ: [kg/m^3] fluid density at 0Pa reference gage pressure (set by density argument)\nΒ: [Pa] fluid bulk modulus describing the compressibility (set by bulk_modulus argument)\nμ: [Pa*s] or [kg/m-s] fluid dynamic viscosity (set by viscosity argument)\nn: density exponent\nlet_gas: set to 1 to allow fluid to transition from liquid to gas (for density calculation only) \nρ_gas: [kg/m^3] density of fluid in gas state at reference gage pressure p_gas (set by gas_density argument)\np_gas: [Pa] reference pressure (set by gas_pressure argument)\n\n\n\n\n\n","category":"function"},{"location":"API/hydraulic/#ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.friction_factor","page":"Hydraulic Components","title":"ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.friction_factor","text":"friction_factor(dm, area, d_h, viscosity, shape_factor)\n\nCalculates the friction factor f for fully developed flow in a tube such that Δp = f cdot rho fracu^22 fracld_h where \n\nΔp: [Pa] is the pressure difference over the tube length l\nrho: [kg/m^3] is the average fluid density\nu: [m/s] is the average fluid velocity\nl: [m] is the tube length \n\nThe friction factor is calculated for laminar and turbulent flow with a transition region between Reynolds number 2000 to 3000. Turbulent flow equation is for smooth tubes, valid for the Reynolds number range up to 5e6.\n\nArguments:\n\ndm: [kg/s] mass flow\narea: [m^2] tube cross sectional area\nd_h: [m] tube hydraulic diameter. For circular tubes d_h is the tube diameter, otherwise it can be found from 4*area/perimeter\ndensity: [kg/m^3] fluid density\nviscosity: [Pa*s] or [kg/m-s] fluid dynamic viscosity\nshape_factor: the constant defining the laminar fully developed constant f*Re related to the shape of the tube cross section\n\nReference: Introduction to Fluid Mechanics, Fox & McDonald, 5th Edition, equations 8.19 and 8.21\n\n\n\n\n\n","category":"function"},{"location":"API/hydraulic/#IsothermalCompressible-Components-2","page":"Hydraulic Components","title":"IsothermalCompressible Components","text":"","category":"section"},{"location":"API/hydraulic/","page":"Hydraulic Components","title":"Hydraulic Components","text":"Cap\nTubeBase\nTube\nFixedVolume\nDynamicVolume","category":"page"},{"location":"API/hydraulic/#ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Cap","page":"Hydraulic Components","title":"ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Cap","text":"Cap(; p_int, name)\n\nCaps a hydraulic port to prevent mass flow in or out.\n\nParameters:\n\np_int: [Pa] initial pressure (set by p_int argument)\n\nConnectors:\n\nport: hydraulic port\n\n\n\n\n\n","category":"function"},{"location":"API/hydraulic/#ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.TubeBase","page":"Hydraulic Components","title":"ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.TubeBase","text":"TubeBase(add_inertia = true; p_int, area, length_int, head_factor = 1, perimeter = 2 * sqrt(area * pi), shape_factor = 64, name)\n\nVariable length internal flow model of the fully developed incompressible flow friction. Includes optional inertia term when add_inertia = true to model wave propagation. Hydraulic ports have equal flow but variable pressure. Density is averaged over the pressures, used to calculated average flow velocity and flow friction.\n\nStates:\n\nx: [m] length of the pipe\nddm: [kg/s^2] Rate of change of mass flow rate in control volume.\n\nParameters:\n\np_int: [Pa] initial pressure\narea: [m^2] tube cross sectional area\nlength_int: [m] initial tube length\nperimeter: [m] perimeter of the pipe cross section (needed only for non-circular pipes)\nshape_factor: shape factor, see friction_factor function\nhead_factor: effective length multiplier, used to account for addition friction from flow development and additional friction such as pipe bends, entrance/exit lossses, etc.\n\nConnectors:\n\nport_a: hydraulic port\nport_b: hydraulic port\n\n\n\n\n\n","category":"function"},{"location":"API/hydraulic/#ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Tube","page":"Hydraulic Components","title":"ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Tube","text":"Tube(N, add_inertia=true; p_int, area, length, head_factor=1, perimeter = 2 * sqrt(area * pi), shape_factor = 64, name)\n\nConstant length internal flow model discretized by N (FixedVolume: N, TubeBase:N-1) which models the fully developed flow friction, compressibility (when N>1), and inertia effects when add_inertia = true. See TubeBase and FixedVolume for more information.\n\nParameters:\n\np_int: [Pa] initial pressure\narea: [m^2] tube cross sectional area\nlength: [m] real length of the tube\nperimeter: [m] perimeter of the pipe cross section (needed only for non-circular pipes)\nshape_factor: shape factor, see friction_factor function\nhead_factor: effective length multiplier, used to account for addition friction from flow development and additional friction such as pipe bends, entrance/exit lossses, etc.\n\nConnectors:\n\nport_a: hydraulic port\nport_b: hydraulic port\n\n\n\n\n\n","category":"function"},{"location":"API/hydraulic/#ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.FixedVolume","page":"Hydraulic Components","title":"ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.FixedVolume","text":"FixedVolume(; vol, p_int, name)\n\nFixed fluid volume.\n\nParameters:\n\nvol: [m^3] fixed volume\np_int: [Pa] initial pressure\n\nConnectors:\n\nport: hydraulic port\n\n\n\n\n\n","category":"function"},{"location":"API/hydraulic/#ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.DynamicVolume","page":"Hydraulic Components","title":"ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.DynamicVolume","text":"DynamicVolume(N, addinertia=true; pint, area, xint = 0, xmax, xmin = 0, xdamp = xmin, direction = +1, perimeter = 2 * sqrt(area * pi), shapefactor = 64, headfactor = 1, Cd = 1e2, Cdreverse = Cd, name)\n\nVolume with moving wall with flange connector for converting hydraulic energy to 1D mechanical. The direction argument aligns the mechanical port with the hydraulic port, useful when connecting two dynamic volumes together in oppsing directions to create an actuator.\n\n ┌─────────────────┐ ───\n │ │ ▲\n │ │\ndm ────► │ │ area\n │ │\n │ │ ▼\n └─────────────────┤ ───\n │\n └─► x (= ∫ flange.v * direction)\n\nFeatures:\n\nvolume discretization with flow resistance and inertia: use N to control number of volume and resistance elements. Set N=0 to turn off volume discretization. See TubeBase for more information about flow resistance.\nminimum volume flow shutoff with damping and directional resistance. Use reversible=false when problem defines volume position x and solves for dm to prevent numerical instability.\n\nParameters:\n\nvolume\n\np_int: [Pa] initial pressure\narea: [m^2] moving wall area\nx_int: [m] initial wall position\nx_max: [m] max wall position, needed for volume discretization to apply the correct volume sizing as a function of x\nx_min: [m] wall position that shuts off flow and prevents negative volume.\nx_damp: [m] wall position that initiates a linear damping region before reaching full flow shut off. Helps provide a smooth end stop.\ndirection: [+/-1] applies the direction conversion from the flange to x\n\nflow resistance\n\nperimeter: [m] perimeter of the cross section (needed only for non-circular volumes)\nshape_factor: shape factor, see friction_factor function\nhead_factor: effective length multiplier, used to account for addition friction from flow development and additional friction such as pipe bends, entrance/exit lossses, etc.\n\nflow shut off and damping\n\nCd: discharge coefficient for flow out of the volume. Note: area is 1m² when valve is fully open. Ensure this does not induce unwanted flow resistance.\nCd_reverse: discharge coefficient for flow into the volume. Use a lower value to allow easy wall release, in some cases the wall can \"stick\".\n\nConnectors:\n\nport: hydraulic port\nflange: mechanical translational port\n\n\n\n\n\n","category":"function"},{"location":"API/hydraulic/#IsothermalCompressible-Sources","page":"Hydraulic Components","title":"IsothermalCompressible Sources","text":"","category":"section"},{"location":"API/hydraulic/","page":"Hydraulic Components","title":"Hydraulic Components","text":"MassFlow\nPressure\nFixedPressure","category":"page"},{"location":"API/hydraulic/#ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.MassFlow","page":"Hydraulic Components","title":"ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.MassFlow","text":"MassFlow(; name, p_int)\n\nHydraulic mass flow input source\n\nConnectors:\n\nport: hydraulic port\ndm: real input \n\n\n\n\n\n","category":"function"},{"location":"API/hydraulic/#ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Pressure","page":"Hydraulic Components","title":"ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Pressure","text":"Pressure(; p_int, name)\n\ninput pressure source\n\nParameters:\n\np_int: [Pa] initial pressure (set by p_int argument)\n\nConnectors:\n\nport: hydraulic port\np: real input \n\n\n\n\n\n","category":"function"},{"location":"API/hydraulic/#ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.FixedPressure","page":"Hydraulic Components","title":"ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.FixedPressure","text":"FixedPressure(; p, name)\n\nFixed pressure source\n\nParameters:\n\np: [Pa] set pressure (set by p argument)\n\nConnectors:\n\nport: hydraulic port\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary:-Blocks","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary: Blocks","text":"","category":"section"},{"location":"API/blocks/","page":"Basic Blocks","title":"Basic Blocks","text":"CurrentModule = ModelingToolkitStandardLibrary.Blocks","category":"page"},{"location":"API/blocks/","page":"Basic Blocks","title":"Basic Blocks","text":"Pages = [\"blocks.md\"]","category":"page"},{"location":"API/blocks/#Index","page":"Basic Blocks","title":"Index","text":"","category":"section"},{"location":"API/blocks/","page":"Basic Blocks","title":"Basic Blocks","text":"Pages = [\"blocks.md\"]","category":"page"},{"location":"API/blocks/#Utility-Blocks","page":"Basic Blocks","title":"Utility Blocks","text":"","category":"section"},{"location":"API/blocks/","page":"Basic Blocks","title":"Basic Blocks","text":"RealInput\nRealOutput\nSISO","category":"page"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.RealInput","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.RealInput","text":"RealInput(;name, nin, u_start)\n\nConnector with one input signal of type Real.\n\nParameters:\n\nnin=1: Number of inputs\nu_start=0: Initial value for u\n\nStates:\n\nu: Value of the connector; if nin=1 this is a scalar\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.RealOutput","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.RealOutput","text":"RealOutput(;name, nout, u_start)\n\nConnector with one output signal of type Real.\n\nParameters:\n\nnout=1: Number of outputs\nu_start=0: Initial value for u\n\nStates:\n\nu: Value of the connector; if nout=1 this is a scalar\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.SISO","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.SISO","text":"SISO(;name, u_start = 0.0, y_start = 0.0)\n\nSingle input single output (SISO) continuous system block.\n\nParameters:\n\nu_start: Initial value for the input\ny_start: Initial value for the output\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#Math-Blocks","page":"Basic Blocks","title":"Math Blocks","text":"","category":"section"},{"location":"API/blocks/","page":"Basic Blocks","title":"Basic Blocks","text":"Gain\nMatrixGain\nSum\nFeedback\nAdd\nAdd3\nProduct\nDivision\nStaticNonLinearity\nAbs\nSign\nSqrt\nSin\nCos\nTan\nAsin\nAcos\nAtan\nAtan2\nSinh\nCosh\nTanh\nExp\nLog\nLog10","category":"page"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Gain","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Gain","text":"Gain(; name, k)\n\nOutput the product of a gain value with the input signal.\n\nParameters:\n\nk: Scalar gain\n\nConnectors:\n\ninput\noutput\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.MatrixGain","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.MatrixGain","text":"MatrixGain(; K::AbstractArray, name)\n\nOutput the product of a gain matrix with the input signal vector.\n\nStructural parameters:\n\nK: Matrix gain\n\nConnectors:\n\ninput\noutput\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Sum","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Sum","text":"Sum(; input__nin::Int, name)\n\nOutput the sum of the elements of the input port vector. Input port dimension can be set with input__nin\n\nConnectors:\n\ninput\noutput\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Feedback","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Feedback","text":"Feedback(; name)\n\nOutput difference between reference input (input1) and feedback input (input2).\n\nConnectors:\n\ninput1\ninput2\noutput\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Add","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Add","text":"Add(; name, k1 = 1.0, k2 = 1.0)\n\nOutput the sum of the two scalar inputs.\n\nParameters:\n\nk1: Gain for first input\nk2: Gain for second input\n\nConnectors:\n\ninput1\ninput2\noutput\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Add3","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Add3","text":"Add(; name, k1 = 1.0, k2 = 1.0, k3 = 1.0)\n\nOutput the sum of the three scalar inputs.\n\nParameters:\n\nk1: Gain for first input\nk2: Gain for second input\nk3: Gain for third input\n\nConnectors:\n\ninput1\ninput2\ninput3\noutput\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Product","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Product","text":"Product(; name)\n\nOutput product of the two inputs.\n\nConnectors:\n\ninput1\ninput2\noutput\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Division","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Division","text":"Division(; name)\n\nOutput first input divided by second input.\n\nConnectors:\n\ninput1\ninput2\noutput\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.StaticNonLinearity","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.StaticNonLinearity","text":"StaticNonLinearity(func; name)\n\nApplies the given function to the input.\n\nIf the given function is not composed of simple core methods (e.g. sin, abs, ...), it has to be registered via @register_symbolic func(u)\n\nConnectors:\n\ninput\noutput\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Abs","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Abs","text":"Abs(; name)\n\nOutput the absolute value of the input.\n\nConnectors:\n\nSee StaticNonLinearity\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Sign","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Sign","text":"Sign(; name)\n\nOutput the sign of the input\n\nConnectors:\n\nSee StaticNonLinearity\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Sqrt","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Sqrt","text":"Sqrt(; name)\n\nOutput the square root of the input (input >= 0 required).\n\nConnectors:\n\nSee StaticNonLinearity\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Sin","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Sin","text":"Sin(; name)\n\nOutput the sine of the input.\n\nConnectors:\n\nSee StaticNonLinearity\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Cos","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Cos","text":"Cos(; name)\n\nOutput the cosine of the input.\n\nConnectors:\n\nSee StaticNonLinearity\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Tan","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Tan","text":"Tan(; name)\n\nOutput the tangent of the input.\n\nConnectors:\n\nSee StaticNonLinearity\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Asin","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Asin","text":"Asin(; name)\n\nOutput the arc sine of the input.\n\nConnectors:\n\nSee StaticNonLinearity\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Acos","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Acos","text":"Acos(; name)\n\nOutput the arc cosine of the input.\n\nConnectors:\n\nSee StaticNonLinearity\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Atan","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Atan","text":"Atan(; name)\n\nOutput the arc tangent of the input.\n\nConnectors:\n\nSee StaticNonLinearity\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Atan2","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Atan2","text":"Atan2(; name)\n\nOutput the arc tangent of the input.\n\nConnectors:\n\ninput1\ninput2\noutput\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Sinh","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Sinh","text":"Sinh(; name)\n\nOutput the hyperbolic sine of the input.\n\nConnectors:\n\nSee StaticNonLinearity\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Cosh","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Cosh","text":"Cosh(; name)\n\nOutput the hyperbolic cosine of the input.\n\nConnectors:\n\nSee StaticNonLinearity\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Tanh","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Tanh","text":"Tanh(; name)\n\nOutput the hyperbolic tangent of the input.\n\nConnectors:\n\nSee StaticNonLinearity\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Exp","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Exp","text":"Exp(; name)\n\nOutput the exponential (base e) of the input.\n\nConnectors:\n\nSee StaticNonLinearity\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Log","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Log","text":"Log(; name)\n\nOutput the natural (base e) logarithm of the input.\n\nConnectors:\n\nSee StaticNonLinearity\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Log10","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Log10","text":"Log10(; name)\n\nOutput the base 10 logarithm of the input.\n\nConnectors:\n\nSee StaticNonLinearity\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#Source-Blocks","page":"Basic Blocks","title":"Source Blocks","text":"","category":"section"},{"location":"API/blocks/","page":"Basic Blocks","title":"Basic Blocks","text":"Constant\nSine\nCosine\nContinuousClock\nRamp\nStep\nExpSine","category":"page"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Constant","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Constant","text":"Constant(; name, k = 0.0)\n\nGenerate constant signal.\n\nParameters:\n\nk: Constant output value\n\nConnectors:\n\noutput\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Sine","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Sine","text":"Sine(; name, frequency, amplitude = 1, phase = 0, offset = 0, start_time = 0,\nsmooth = false)\n\nGenerate sine signal.\n\nParameters:\n\nfrequency: [Hz] Frequency of sine wave\namplitude: Amplitude of sine wave\nphase: [rad] Phase of sine wave\noffset: Offset of output signal\nstart_time: [s] Output y = offset for t < start_time\nsmooth: If true, returns a smooth wave. Defaults to false It uses a default smoothing factor of δ=1e-5, but this can be changed by supplying smooth=δ.\n\nConnectors:\n\noutput\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Cosine","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Cosine","text":"Cosine(; name, frequency, amplitude = 1, phase = 0, offset = 0, start_time = 0,\nsmooth = false)\n\nGenerate cosine signal.\n\nParameters:\n\nfrequency: [Hz] Frequency of cosine wave\namplitude: Amplitude of cosine wave\nphase: [rad] Phase of cosine wave\noffset: Offset of output signal\nstart_time: [s] Output y = offset for t < start_time\nsmooth: If true, returns a smooth wave. Defaults to false It uses a default smoothing factor of δ=1e-5, but this can be changed by supplying smooth=δ.\n\nConnectors:\n\noutput\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.ContinuousClock","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.ContinuousClock","text":"ContinuousClock(; name, offset = 0, start_time = 0)\n\nGenerate current time signal.\n\nParameters:\n\noffset: Offset of output signal\nstart_time: [s] Output y = offset for t < start_time\n\nConnectors:\n\noutput\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Ramp","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Ramp","text":"Ramp(; name, height = 1, duration = 1, offset = 0, start_time = 0, smooth = false)\n\nGenerate ramp signal.\n\nParameters:\n\nheight: Height of ramp\nduration: [s] Duration of ramp (= 0.0 gives a Step)\noffset: Offset of output signal\nstart_time: [s] Output y = offset for t < start_time\nsmooth: If true, returns a smooth wave. Defaults to false It uses a default smoothing factor of δ=1e-5, but this can be changed by supplying smooth=δ.\n\nConnectors:\n\noutput\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Step","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Step","text":"Step(;name, height=1, offset=0, start_time=0, duration=Inf, smooth=true)\n\nGenerate step signal.\n\nParameters:\n\nheight: Height of step\noffset: Offset of output signal\nstart_time: [s] Output y = offset for t < start_time and thereafter offset+height.\nduration: [s] If duration < Inf is supplied, the output will revert to offset after duration seconds.\nsmooth: If true, returns a smooth wave. Defaults to true It uses a default smoothing factor of δ=1e-5, but this can be changed by supplying smooth=δ.\n\nConnectors:\n\noutput\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.ExpSine","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.ExpSine","text":"ExpSine(; name, frequency, amplitude = 1, damping = 0.1, phase = 0, offset = 0, start_time = 0, smooth = false)\n\nExponentially damped sine signal.\n\nParameters:\n\nfrequency: [Hz] Frequency of sine wave\namplitude: Amplitude of sine wave\ndamping: [1/s] Damping coefficient of sine wave\nphase: [rad] Phase of sine wave\noffset: Offset of output signal\nstart_time: [s] Output y = offset for t < start_time\nsmooth: If true, returns a smooth wave. Defaults to false It uses a default smoothing factor of δ=1e-5, but this can be changed by supplying smooth=δ.\n\nConnectors:\n\noutput\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#Nonlinear-Blocks","page":"Basic Blocks","title":"Nonlinear Blocks","text":"","category":"section"},{"location":"API/blocks/","page":"Basic Blocks","title":"Basic Blocks","text":"Limiter\nDeadZone\nSlewRateLimiter","category":"page"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Limiter","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Limiter","text":"Limiter(;name, y_max, y_min = y_max > 0 ? -y_max : -Inf)\n\nLimit the range of a signal.\n\nParameters:\n\ny_max: Maximum of output signal\ny_min: Minimum of output signal\n\nConnectors:\n\ninput\noutput\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.DeadZone","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.DeadZone","text":"DeadZone(; name, u_max, u_min = -u_max)\n\nThe DeadZone block defines a region of zero output. If the input is within u_min ... u_max, the output is zero. Outside of this zone, the output is a linear function of the input with a slope of 1.\n\n y▲\n │ /\n │ /\n u_min │ /\n─────|──┼──|───────► u\n / │ u_max\n / │\n / │\n\nParameters:\n\nu_max: Upper limit of dead zone\nu_min: Lower limit of dead zone\n\nConnectors:\n\ninput\noutput\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.SlewRateLimiter","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.SlewRateLimiter","text":"SlewRateLimiter(; name, y_start, rising = 1.0, falling = -rising, Td = 0.001)\n\nLimits the slew rate of a signal. Initial value of state Y can be set with int.y\n\nParameters:\n\nrising: Maximum rising slew rate\nfalling: Maximum falling slew rate\nTd: [s] Derivative time constant\ny_start: Initial value of y state of SISO\n\nConnectors:\n\ninput\noutput\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#Continuous-Blocks","page":"Basic Blocks","title":"Continuous Blocks","text":"","category":"section"},{"location":"API/blocks/","page":"Basic Blocks","title":"Basic Blocks","text":"Integrator\nDerivative\nFirstOrder\nSecondOrder\nStateSpace\nTransferFunction\nPI\nLimPI\nPID\nLimPID","category":"page"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Integrator","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Integrator","text":"Integrator(;name, k = 1, x = 0.0)\n\nOutputs y = ∫k*u dt, corresponding to the transfer function 1s. Initial value of integrator state x can be set with x\n\nConnectors:\n\ninput\noutput\n\nParameters:\n\nk: Gain of integrator\n\nUnknowns:\n\nx: State of Integrator. Defaults to 0.0.\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.Derivative","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.Derivative","text":"Derivative(; name, k = 1, T, x = 0.0)\n\nOutputs an approximate derivative of the input. The transfer function of this block is\n\nk k ks \n─ - ─────── = ────── \nT sT² + T sT + 1\n\nand a state-space realization is given by ss(-1/T, 1/T, -k/T, k/T) where T is the time constant of the filter. A smaller T leads to a more ideal approximation of the derivative.\n\nInitial value of the state x can be set with x.\n\nParameters:\n\nk: Gain\nT: [s] Time constant (T>0 required; T=0 is ideal derivative block)\n\nUnknowns:\n\nx: Unknown of Derivative. Defaults to 0.0.\n\nConnectors:\n\ninput\noutput\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.FirstOrder","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.FirstOrder","text":"FirstOrder(; name, k = 1.0, T, x = 0.0, lowpass = true)\n\nA first-order filter with a single real pole at s = -1/T and gain k. If lowpass=true (default), the transfer function is given by Y(s)U(s) =\n\n k\n───────\nsT + 1\n\nand if lowpass=false, by\n\nsT + 1 - k\n──────────\n sT + 1\n\nInitial value of the state x can be set with x\n\nParameters:\n\nk: Gain\nT: [s] Time constant (T>0 required)\n\nConnectors:\n\ninput\noutput\n\nSee also SecondOrder\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.SecondOrder","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.SecondOrder","text":"SecondOrder(; name, k = 1.0, w = 1.0, d = 1.0, x = 0.0, xd = 0.0)\n\nA second-order filter with gain k, a bandwidth of w rad/s and relative damping d. The transfer function is given by Y(s)/U(s) =\n\n k*w^2\n─────────────────\ns² + 2d*w*s + w^2\n\nCritical damping corresponds to d=1, which yields the fastest step response without overshoot, d < 1 results in an underdamped filter while d > 1 results in an overdamped filter. d = 1/√2 corresponds to a Butterworth filter of order 2 (maximally flat frequency response). Initial value of the state x can be set with x, and of derivative state xd with xd.\n\nParameters:\n\nk: Gain\nw: [rad/s] Angular frequency\nd: Damping\n\nConnectors:\n\ninput\noutput\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.StateSpace","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.StateSpace","text":"StateSpace(A, B, C, D = 0; x = zeros(size(A,1)), u0 = zeros(size(B,2)), y0 = zeros(size(C,1)), name)\n\nA linear, time-invariant state-space system on the form.\n\nbeginaligned\nx = Ax + Bu \ny = Cx + Du\nendaligned\n\nTransfer functions can also be simulated by converting them to a StateSpace form.\n\ny0 and u0 can be used to set an operating point, providing them changes the dynamics from an LTI system to the affine system\n\nbeginaligned\nx = Ax + B(u - u0) \ny = Cx + D(u - u0) + y0\nendaligned\n\nFor a nonlinear system\n\nbeginaligned\nx = f(x u) \ny = h(x u)\nendaligned\n\nlinearized around the operating point x₀, u₀, we have y0, u0 = h(x₀, u₀), u₀.\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.TransferFunction","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.TransferFunction","text":"TransferFunction(; b, a, name)\n\nA single input, single output, linear time-invariant system provided as a transfer-function.\n\nY(s) = b(s) / a(s) U(s)\n\nwhere b and a are vectors of coefficients of the numerator and denominator polynomials, respectively, ordered such that the coefficient of the highest power of s is first.\n\nThe internal state realization is on controller canonical form, with state variable x, output variable y and input variable u. For numerical robustness, the realization used by the integrator is scaled by the last entry of the a parameter. The internally scaled state variable is available as x_scaled.\n\nTo set the initial state, it's recommended to set the initial condition for x, and let that of x_scaled be computed automatically.\n\nParameters:\n\nb: Numerator polynomial coefficients, e.g., 2s + 3 is specified as [2, 3]\na: Denominator polynomial coefficients, e.g., s² + 2ωs + ω^2 is specified as [1, 2ω, ω^2]\n\nConnectors:\n\ninput\noutput\n\nSee also StateSpace which handles MIMO systems, as well as ControlSystemsMTK.jl for an interface between ControlSystems.jl and ModelingToolkit.jl for advanced manipulation of transfer functions and linear statespace systems. For linearization, see linearize and Linear Analysis.\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.PI","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.PI","text":"PI(;name, k = 1.0, T = 1.0, int.x = 0.0)\n\nTextbook version of a PI-controller without actuator saturation and anti-windup measure. The proportional gain can be set with k Initial value of integrator state x can be set with int.x\n\nThe PI controller is implemented on standard form:\n\nU(s) = k (1 + dfrac1sT) E(S)\n\nParameters:\n\nk: Proportional gain\nT: [s] Integrator time constant (T>0 required)\n\nConnectors:\n\nerr_input\nctr_output\n\nSee also LimPI\n\n\n\n\n\n","category":"constant"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.LimPI","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.LimPI","text":"LimPI(; name, k = 1.0, T, Ta, int__x = 0.0, u_max = 1.0, u_min = -u_max)\n\nText-book version of a PI-controller with actuator saturation and anti-windup measure.\n\nThe PI controller is implemented on standard form\n\nu(t) = sat(k (e(t) + dfrac1Te(t) dt) )\n\nThe simplified expression above is given without the anti-windup protection.\n\nParameters:\n\nk: Proportional gain\nT: [s] Integrator time constant (T>0 required)\nTa: [s] Tracking time constant (Ta>0 required)\n\nConnectors:\n\nerr_input\nctr_output\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.PID","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.PID","text":"PID(;name, k=1, Ti=false, Td=false, Nd=10, int__x=0, der__x=0)\n\nText-book version of a PID-controller without actuator saturation and anti-windup measure.\n\nParameters:\n\nk: Gain\nTi: [s] Integrator time constant (Ti>0 required). If set to false, no integral action is used.\nTd: [s] Derivative time constant (Td>0 required). If set to false, no derivative action is used.\nNd: [s] Time constant for the derivative approximation (Nd>0 required; Nd=0 is ideal derivative).\nint__x: Initial value for the integrator.\nder__x: Initial value for the derivative state.\n\nConnectors:\n\nerr_input\nctr_output\n\nSee also LimPID\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.LimPID","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.LimPID","text":"LimPID(; k, Ti=false, Td=false, wp=1, wd=1, Ni, Nd=12, u_max=Inf, u_min=-u_max, gains = false, name)\n\nProportional-Integral-Derivative (PID) controller with output saturation, set-point weighting and integrator anti-windup.\n\nThe equation for the control signal is roughly\n\nk(ep + 1/Ti * ∫e + Td * d/dt(ed))\ne = u_r - u_y\nep = wp*u_r - u_y\ned = wd*u_r - u_y\n\nwhere the transfer function for the derivative includes additional filtering, see ? Derivative for more details.\n\nParameters:\n\nk: Proportional gain\nTi: [s] Integrator time constant. Set to false to turn off integral action.\nTd: [s] Derivative time constant. Set to false to turn off derivative action.\nwp: [0,1] Set-point weighting in the proportional part.\nwd: [0,1] Set-point weighting in the derivative part.\nNd: [1/s] Derivative limit, limits the derivative gain to Nd/Td. Reasonable values are ∈ [8, 20]. A higher value gives a better approximation of an ideal derivative at the expense of higher noise amplification.\nNi: Ni*Ti controls the time constant Ta of anti-windup tracking. A common (default) choice is Ta = √(Ti*Td) which is realized by Ni = √(Td / Ti). Anti-windup can be effectively turned off by setting Ni = Inf.\ngains: If gains = true, Ti and Td will be interpreted as gains with a fundamental PID transfer function on parallel form ki=Ti, kd=Td, k + ki/s + kd*s.\n\nConnectors:\n\nreference\nmeasurement\nctr_output\n\n\n\n\n\n","category":"function"},{"location":"API/thermal/#ModelingToolkitStandardLibrary:-Thermal-Components","page":"Thermal Components","title":"ModelingToolkitStandardLibrary: Thermal Components","text":"","category":"section"},{"location":"API/thermal/","page":"Thermal Components","title":"Thermal Components","text":"CurrentModule = ModelingToolkitStandardLibrary.Thermal","category":"page"},{"location":"API/thermal/","page":"Thermal Components","title":"Thermal Components","text":"Pages = [\"thermal.md\"]","category":"page"},{"location":"API/thermal/#Index","page":"Thermal Components","title":"Index","text":"","category":"section"},{"location":"API/thermal/","page":"Thermal Components","title":"Thermal Components","text":"Pages = [\"thermal.md\"]","category":"page"},{"location":"API/thermal/#Thermal-Utilities","page":"Thermal Components","title":"Thermal Utilities","text":"","category":"section"},{"location":"API/thermal/","page":"Thermal Components","title":"Thermal Components","text":"HeatPort\nElement1D","category":"page"},{"location":"API/thermal/#ModelingToolkitStandardLibrary.Thermal.HeatPort","page":"Thermal Components","title":"ModelingToolkitStandardLibrary.Thermal.HeatPort","text":"HeatPort(; name, T = 273.15 + 20.0, Q_flow = 0.0)\n\nPort for a thermal system.\n\nStates:\n\nT: [K] Temperature of the port. It accepts an initial value, which defaults to 273.15 + 20.\nQ_flow: [W] Heat flow rate at the port. It accepts an initial value, which defaults to 0.0.\n\n\n\n\n\n","category":"constant"},{"location":"API/thermal/#ModelingToolkitStandardLibrary.Thermal.Element1D","page":"Thermal Components","title":"ModelingToolkitStandardLibrary.Thermal.Element1D","text":"Element1D(; name, dT = 0.0, Q_flow = 0.0)\n\nThis partial model contains the basic connectors and variables to allow heat transfer models to be created that do not store energy. This model defines and includes equations for the temperature drop across the element, dT, and the heat flow rate through the element from port_a to port_b, Q_flow.\n\nStates:\n\ndT: [K] Temperature difference across the component a.T - b.T. It accepts an initial value, which defaults to 0.0.\nQ_flow: [W] Heat flow rate from port a -> port b. It accepts an initial value, which defaults to 0.0.\n\nConnectors:\n\nport_a port_b\n\n\n\n\n\n","category":"constant"},{"location":"API/thermal/#Thermal-Components","page":"Thermal Components","title":"Thermal Components","text":"","category":"section"},{"location":"API/thermal/","page":"Thermal Components","title":"Thermal Components","text":"BodyRadiation\nConvectiveConductor\nConvectiveResistor\nHeatCapacitor\nThermalConductor\nThermalResistor\nThermalCollector","category":"page"},{"location":"API/thermal/#ModelingToolkitStandardLibrary.Thermal.BodyRadiation","page":"Thermal Components","title":"ModelingToolkitStandardLibrary.Thermal.BodyRadiation","text":"BodyRadiation(; name, G)\n\nLumped thermal element for radiation heat transfer.\n\nStates:\n\ndT: [K] Temperature difference across the component a.T - b.T\nQ_flow: [W] Heat flow rate from port a -> port b\n\nConnectors:\n\nport_a\nport_b\n\nParameters:\n\nG: [m^2] Net radiation conductance between two surfaces # Stefan-Boltzmann constant TODO: extract into physical constants module or use existing one\n\n\n\n\n\n","category":"constant"},{"location":"API/thermal/#ModelingToolkitStandardLibrary.Thermal.ConvectiveConductor","page":"Thermal Components","title":"ModelingToolkitStandardLibrary.Thermal.ConvectiveConductor","text":"ConvectiveConductor(; name, G)\n\nLumped thermal element for heat convection.\n\nStates:\n\ndT: [K] Temperature difference across the component solid.T - fluid.T\nQ_flow: [W] Heat flow rate from solid -> fluid\n\nConnectors:\n\nsolid\nfluid\n\nParameters:\n\nG: [W/K] Convective thermal conductance\n\n\n\n\n\n","category":"constant"},{"location":"API/thermal/#ModelingToolkitStandardLibrary.Thermal.ConvectiveResistor","page":"Thermal Components","title":"ModelingToolkitStandardLibrary.Thermal.ConvectiveResistor","text":"ConvectiveResistor(; name, R)\n\nLumped thermal element for heat convection.\n\nStates:\n\ndT: [K] Temperature difference across the component solid.T - fluid.T\nQ_flow: [W] Heat flow rate from solid -> fluid\n\nConnectors:\n\nsolid\nfluid\n\nParameters:\n\nR: [K/W] Constant thermal resistance of material\n\n\n\n\n\n","category":"constant"},{"location":"API/thermal/#ModelingToolkitStandardLibrary.Thermal.HeatCapacitor","page":"Thermal Components","title":"ModelingToolkitStandardLibrary.Thermal.HeatCapacitor","text":"HeatCapacitor(; name, C, T = 273.15 + 20)\n\nLumped thermal element storing heat\n\nStates:\n\nT: [K] Temperature of element. It accepts an initial value, which defaults to 273.15 + 20.\nder_T: [K/s] Time derivative of temperature\n\nConnectors:\n\nport\n\nParameters:\n\nC: [J/K] Heat capacity of element (= cp*m)\n\n\n\n\n\n","category":"constant"},{"location":"API/thermal/#ModelingToolkitStandardLibrary.Thermal.ThermalConductor","page":"Thermal Components","title":"ModelingToolkitStandardLibrary.Thermal.ThermalConductor","text":"ThermalConductor(; name, G)\n\nLumped thermal element transporting heat without storing it.\n\nStates:\n\nsee Element1D\n\nConnectors:\n\nport_a port_b\n\nParameters:\n\nG: [W/K] Constant thermal conductance of material\n\n\n\n\n\n","category":"constant"},{"location":"API/thermal/#ModelingToolkitStandardLibrary.Thermal.ThermalResistor","page":"Thermal Components","title":"ModelingToolkitStandardLibrary.Thermal.ThermalResistor","text":"ThermalResistor(; name, R)\n\nLumped thermal element transporting heat without storing it.\n\nStates:\n\ndT: [K] Temperature difference across the component a.T - b.T\nQ_flow: [W] Heat flow rate from port a -> port b\n\nConnectors:\n\nport_a\nport_b\n\nParameters:\n\nR: [K/W] Constant thermal resistance of material\n\n\n\n\n\n","category":"constant"},{"location":"API/thermal/#ModelingToolkitStandardLibrary.Thermal.ThermalCollector","page":"Thermal Components","title":"ModelingToolkitStandardLibrary.Thermal.ThermalCollector","text":"ThermalCollector(; name, m = 1)\n\nCollects m heat flows\n\nThis is a model to collect the heat flows from m heatports to one single heatport.\n\nStates:\n\nConnectors:\n\nport_a1 to port_am\nport_b\n\nParameters:\n\nm: Number of heat ports (e.g. m=2: port_a1, port_a2)\n\n\n\n\n\n","category":"function"},{"location":"API/thermal/#Thermal-Sensors","page":"Thermal Components","title":"Thermal Sensors","text":"","category":"section"},{"location":"API/thermal/","page":"Thermal Components","title":"Thermal Components","text":"RelativeTemperatureSensor\nHeatFlowSensor\nTemperatureSensor","category":"page"},{"location":"API/thermal/#ModelingToolkitStandardLibrary.Thermal.RelativeTemperatureSensor","page":"Thermal Components","title":"ModelingToolkitStandardLibrary.Thermal.RelativeTemperatureSensor","text":"RelativeTemperatureSensor(; name)\n\nRelative Temperature sensor.\n\nThe relative temperature port_a.T - port_b.T is determined between the two ports of this component and is provided as output signal in kelvin.\n\nStates:\n\nT(t): [K] Relative temperature a.T - b.T\n\nConnectors:\n\nport_a\nport_b\n\n\n\n\n\n","category":"constant"},{"location":"API/thermal/#ModelingToolkitStandardLibrary.Thermal.HeatFlowSensor","page":"Thermal Components","title":"ModelingToolkitStandardLibrary.Thermal.HeatFlowSensor","text":"HeatFlowSensor(; name)\n\nHeat flow rate sensor.\n\nThis model is capable of monitoring the heat flow rate flowing through this component. The sensed value of heat flow rate is the amount that passes through this sensor while keeping the temperature drop across the sensor zero. This is an ideal model, so it does not absorb any energy, and it has no direct effect on the thermal response of a system it is included in. The output signal is positive, if the heat flows from port_a to port_b.\n\nStates:\n\nQ_flow(t): [W] Heat flow from port_a to port_b\n\nConnectors:\n\nport_a\nport_b\n\n\n\n\n\n","category":"constant"},{"location":"API/thermal/#ModelingToolkitStandardLibrary.Thermal.TemperatureSensor","page":"Thermal Components","title":"ModelingToolkitStandardLibrary.Thermal.TemperatureSensor","text":"TemperatureSensor(; name)\n\nAbsolute temperature sensor in kelvin.\n\nThis is an ideal absolute temperature sensor which returns the temperature of the connected port in kelvin as an output signal. The sensor itself has no thermal interaction with whatever it is connected to. Furthermore, no thermocouple-like lags are associated with this sensor model.\n\nStates:\n\nT(t): [K] Absolute temperature\n\nConnectors:\n\nport\n\n\n\n\n\n","category":"constant"},{"location":"API/thermal/#Thermal-Sources","page":"Thermal Components","title":"Thermal Sources","text":"","category":"section"},{"location":"API/thermal/","page":"Thermal Components","title":"Thermal Components","text":"FixedHeatFlow\nFixedTemperature\nPrescribedHeatFlow\nPrescribedTemperature ","category":"page"},{"location":"API/thermal/#ModelingToolkitStandardLibrary.Thermal.FixedHeatFlow","page":"Thermal Components","title":"ModelingToolkitStandardLibrary.Thermal.FixedHeatFlow","text":"FixedHeatFlow(; name, Q_flow = 1.0, T_ref = 293.15, alpha = 0.0)\n\nFixed heat flow boundary condition.\n\nThis model allows a specified amount of heat flow rate to be \"injected\" into a thermal system at a given port. The constant amount of heat flow rate Q_flow is given as a parameter. The heat flows into the component to which the component FixedHeatFlow is connected, if parameter Q_flow is positive.\n\nConnectors:\n\nport\n\nParameters:\n\nQ_flow: [W] Fixed heat flow rate at port\nT_ref: [K] Reference temperature\nalpha: [1/K] Temperature coefficient of heat flow rate\n\n\n\n\n\n","category":"constant"},{"location":"API/thermal/#ModelingToolkitStandardLibrary.Thermal.FixedTemperature","page":"Thermal Components","title":"ModelingToolkitStandardLibrary.Thermal.FixedTemperature","text":"FixedTemperature(; name, T)\n\nFixed temperature boundary condition in kelvin.\n\nThis model defines a fixed temperature T at its port in kelvin, i.e., it defines a fixed temperature as a boundary condition.\n\nConnectors:\n\nport\n\nParameters:\n\nT: [K] Fixed temperature boundary condition\n\n\n\n\n\n","category":"constant"},{"location":"API/thermal/#ModelingToolkitStandardLibrary.Thermal.PrescribedHeatFlow","page":"Thermal Components","title":"ModelingToolkitStandardLibrary.Thermal.PrescribedHeatFlow","text":"PrescribedHeatFlow(; name, T_ref = 293.15, alpha = 0.0)\n\nPrescribed heat flow boundary condition.\n\nThis model allows a specified amount of heat flow rate to be \"injected\" into a thermal system at a given port. The amount of heat is given by the input signal Q_flow into the model. The heat flows into the component to which the component PrescribedHeatFlow is connected, if the input signal is positive. If parameter alpha is > 0, the heat flow is multiplied by 1 + alpha*(port.T - T_ref) in order to simulate temperature dependent losses (which are given a reference temperature T_ref).\n\nConnectors:\n\nport\nRealInput Q_flow Input for the heat flow\n\nParameters:\n\nT_ref: [K] Reference temperature\nalpha: [1/K] Temperature coefficient of heat flow rate\n\n\n\n\n\n","category":"constant"},{"location":"API/thermal/#ModelingToolkitStandardLibrary.Thermal.PrescribedTemperature","page":"Thermal Components","title":"ModelingToolkitStandardLibrary.Thermal.PrescribedTemperature","text":"PrescribedTemperature(; name)\n\nThis model represents a variable temperature boundary condition.\n\nThe temperature in kelvin is given as input signal to the RealInput T. The effect is that an instance of this model acts as an infinite reservoir, able to absorb or generate as much energy as required to keep the temperature at the specified value.\n\nConnectors:\n\nport\nRealInput T input for the temperature\n\n\n\n\n\n","category":"constant"},{"location":"tutorials/dc_motor_pi/#DC-Motor-with-PI-controller","page":"DC Motor with Speed Controller","title":"DC Motor with PI-controller","text":"","category":"section"},{"location":"tutorials/dc_motor_pi/","page":"DC Motor with Speed Controller","title":"DC Motor with Speed Controller","text":"In this example, a PI-controller is set up for speed control of a DC-motor. An equivalent circuit diagram is depicted below.","category":"page"},{"location":"tutorials/dc_motor_pi/","page":"DC Motor with Speed Controller","title":"DC Motor with Speed Controller","text":"(Image: DC-motor)","category":"page"},{"location":"tutorials/dc_motor_pi/#Modeling-and-simulation","page":"DC Motor with Speed Controller","title":"Modeling and simulation","text":"","category":"section"},{"location":"tutorials/dc_motor_pi/","page":"DC Motor with Speed Controller","title":"DC Motor with Speed Controller","text":"The electrical part consists of a resistance and inductance. The coupling between the electrical and rotational domain is done via an electro-motive force (EMF) component. The voltage across the EMF is proportional to the angular velocity and the current is proportional to the torque. On the mechanical side, viscous friction in, e.g., a bearing and the inertia of the shaft is modelled.","category":"page"},{"location":"tutorials/dc_motor_pi/","page":"DC Motor with Speed Controller","title":"DC Motor with Speed Controller","text":"A PI-controller with anti-windup measure should be used as a speed controller. A simulation is performed to verify the tracking performance of the controller and the disturbance rejection capabilities.","category":"page"},{"location":"tutorials/dc_motor_pi/","page":"DC Motor with Speed Controller","title":"DC Motor with Speed Controller","text":"First, the needed packages are imported and the parameters of the model defined.","category":"page"},{"location":"tutorials/dc_motor_pi/","page":"DC Motor with Speed Controller","title":"DC Motor with Speed Controller","text":"using ModelingToolkit\nusing ModelingToolkit: t_nounits as t\nusing ModelingToolkitStandardLibrary.Electrical\nusing ModelingToolkitStandardLibrary.Mechanical.Rotational\nusing ModelingToolkitStandardLibrary.Blocks\nusing OrdinaryDiffEq\nusing Plots\n\nR = 0.5 # [Ohm] armature resistance\nL = 4.5e-3 # [H] armature inductance\nk = 0.5 # [N.m/A] motor constant\nJ = 0.02 # [kg.m²] inertia\nf = 0.01 # [N.m.s/rad] friction factor\ntau_L_step = -0.3 # [N.m] amplitude of the load torque step\nnothing # hide","category":"page"},{"location":"tutorials/dc_motor_pi/","page":"DC Motor with Speed Controller","title":"DC Motor with Speed Controller","text":"The actual model can now be composed.","category":"page"},{"location":"tutorials/dc_motor_pi/","page":"DC Motor with Speed Controller","title":"DC Motor with Speed Controller","text":"@named ground = Ground()\n@named source = Voltage()\n@named ref = Blocks.Step(height = 1, start_time = 0)\n@named pi_controller = Blocks.LimPI(k = 1.1, T = 0.035, u_max = 10, Ta = 0.035)\n@named feedback = Blocks.Feedback()\n@named R1 = Resistor(R = R)\n@named L1 = Inductor(L = L)\n@named emf = EMF(k = k)\n@named fixed = Fixed()\n@named load = Torque()\n@named load_step = Blocks.Step(height = tau_L_step, start_time = 3)\n@named inertia = Inertia(J = J)\n@named friction = Damper(d = f)\n@named speed_sensor = SpeedSensor()\n\nconnections = [connect(fixed.flange, emf.support, friction.flange_b)\n connect(emf.flange, friction.flange_a, inertia.flange_a)\n connect(inertia.flange_b, load.flange)\n connect(inertia.flange_b, speed_sensor.flange)\n connect(load_step.output, load.tau)\n connect(ref.output, feedback.input1)\n connect(speed_sensor.w, :y, feedback.input2)\n connect(feedback.output, pi_controller.err_input)\n connect(pi_controller.ctr_output, :u, source.V)\n connect(source.p, R1.p)\n connect(R1.n, L1.p)\n connect(L1.n, emf.p)\n connect(emf.n, source.n, ground.g)]\n\n@named model = ODESystem(connections, t,\n systems = [\n ground,\n ref,\n pi_controller,\n feedback,\n source,\n R1,\n L1,\n emf,\n fixed,\n load,\n load_step,\n inertia,\n friction,\n speed_sensor\n ])\nnothing # hide","category":"page"},{"location":"tutorials/dc_motor_pi/","page":"DC Motor with Speed Controller","title":"DC Motor with Speed Controller","text":"Now the model can be simulated. Typical rotational mechanical systems are described via DAE (differential algebraic equations), however in this case, ModelingToolkit can simplify the model enough so that it can be represented as a system of ODEs (ordinary differential equations).","category":"page"},{"location":"tutorials/dc_motor_pi/","page":"DC Motor with Speed Controller","title":"DC Motor with Speed Controller","text":"sys = structural_simplify(model)\nprob = ODEProblem(sys, unknowns(sys) .=> 0.0, (0, 6.0))\nsol = solve(prob, Rodas4())\n\np1 = Plots.plot(sol.t, sol[inertia.w], ylabel = \"Angular Vel. in rad/s\",\n label = \"Measurement\", title = \"DC Motor with Speed Controller\")\nPlots.plot!(sol.t, sol[ref.output.u], label = \"Reference\")\np2 = Plots.plot(sol.t, sol[load.tau.u], ylabel = \"Disturbance in Nm\", label = \"\")\nPlots.plot(p1, p2, layout = (2, 1))","category":"page"},{"location":"tutorials/dc_motor_pi/#Closed-loop-analysis","page":"DC Motor with Speed Controller","title":"Closed-loop analysis","text":"","category":"section"},{"location":"tutorials/dc_motor_pi/","page":"DC Motor with Speed Controller","title":"DC Motor with Speed Controller","text":"When implementing and tuning a control system in simulation, it is a good practice to analyze the closed-loop properties and verify robustness of the closed-loop with respect to, e.g., modeling errors. To facilitate this, we added two analysis points to the set of connections above, more specifically, we added the analysis points named :y and :u to the connections (for more details on analysis points, see Linear Analysis)","category":"page"},{"location":"tutorials/dc_motor_pi/","page":"DC Motor with Speed Controller","title":"DC Motor with Speed Controller","text":"connect(speed_sensor.w, :y, feedback.input2)\nconnect(pi_controller.ctr_output, :u, source.V)","category":"page"},{"location":"tutorials/dc_motor_pi/","page":"DC Motor with Speed Controller","title":"DC Motor with Speed Controller","text":"one at the plant output (:y) and one at the plant input (:u). We may use these analysis points to calculate, e.g., sensitivity functions, illustrated below. Here, we calculate the sensitivity function S(s) and the complimentary sensitivity function T(s) = I - S(s), defined as","category":"page"},{"location":"tutorials/dc_motor_pi/","page":"DC Motor with Speed Controller","title":"DC Motor with Speed Controller","text":"beginaligned\nS(s) = dfrac1I + P(s)C(s) \nT(s) = dfracP(s)C(s)I + P(s)C(s)\nendaligned","category":"page"},{"location":"tutorials/dc_motor_pi/","page":"DC Motor with Speed Controller","title":"DC Motor with Speed Controller","text":"using ControlSystemsBase\nmatrices_S, simplified_sys = Blocks.get_sensitivity(\n model, :y, op = Dict(unknowns(sys) .=> 0.0))\nSo = ss(matrices_S...) |> minreal # The output-sensitivity function as a StateSpace system\nmatrices_T, simplified_sys = Blocks.get_comp_sensitivity(\n model, :y, op = Dict(inertia.phi => 0.0, inertia.w => 0.0))\nTo = ss(matrices_T...)# The output complementary sensitivity function as a StateSpace system\nbodeplot([So, To], label = [\"S\" \"T\"], plot_title = \"Sensitivity functions\",\n plotphase = false)","category":"page"},{"location":"tutorials/dc_motor_pi/","page":"DC Motor with Speed Controller","title":"DC Motor with Speed Controller","text":"Similarly, we may compute the loop-transfer function and plot its Nyquist curve","category":"page"},{"location":"tutorials/dc_motor_pi/","page":"DC Motor with Speed Controller","title":"DC Motor with Speed Controller","text":"matrices_L, simplified_sys = Blocks.get_looptransfer(\n model, :y, op = Dict(unknowns(sys) .=> 0.0))\nL = -ss(matrices_L...) # The loop-transfer function as a StateSpace system. The negative sign is to negate the built-in negative feedback\nMs, ωMs = hinfnorm(So) # Compute the peak of the sensitivity function to draw a circle in the Nyquist plot\nnyquistplot(L, label = \"\\$L(s)\\$\", ylims = (-2.5, 0.5), xlims = (-1.2, 0.1),\n Ms_circles = Ms)","category":"page"},{"location":"API/electrical/#ModelingToolkitStandardLibrary:-Electrical-Components","page":"Electrical Components","title":"ModelingToolkitStandardLibrary: Electrical Components","text":"","category":"section"},{"location":"API/electrical/","page":"Electrical Components","title":"Electrical Components","text":"CurrentModule = ModelingToolkitStandardLibrary.Electrical","category":"page"},{"location":"API/electrical/","page":"Electrical Components","title":"Electrical Components","text":"Pages = [\"electrical.md\"]","category":"page"},{"location":"API/electrical/#Index","page":"Electrical Components","title":"Index","text":"","category":"section"},{"location":"API/electrical/","page":"Electrical Components","title":"Electrical Components","text":"Pages = [\"electrical.md\"]","category":"page"},{"location":"API/electrical/#Electrical-Utilities","page":"Electrical Components","title":"Electrical Utilities","text":"","category":"section"},{"location":"API/electrical/","page":"Electrical Components","title":"Electrical Components","text":"Pin\nOnePort\nDigitalPin","category":"page"},{"location":"API/electrical/#ModelingToolkitStandardLibrary.Electrical.Pin","page":"Electrical Components","title":"ModelingToolkitStandardLibrary.Electrical.Pin","text":"Pin(; name)\n\nA pin in an analog circuit.\n\nStates:\n\nv(t): [V] The voltage at this pin\ni(t): [A] The current passing through this pin\n\n\n\n\n\n","category":"constant"},{"location":"API/electrical/#ModelingToolkitStandardLibrary.Electrical.OnePort","page":"Electrical Components","title":"ModelingToolkitStandardLibrary.Electrical.OnePort","text":"OnePort(; name, v = 0.0, i = 0.0)\n\nComponent with two electrical pins p and n and current i flows from p to n.\n\nStates:\n\nv(t): [V] The voltage across component p.v - n.v\ni(t): [A] The current passing through positive pin\n\nConnectors:\n\np Positive pin\nn Negative pin\n\n\n\n\n\n","category":"constant"},{"location":"API/electrical/#ModelingToolkitStandardLibrary.Electrical.DigitalPin","page":"Electrical Components","title":"ModelingToolkitStandardLibrary.Electrical.DigitalPin","text":"DigitalPin(; name)\n\nA pin in a digital circuit.\n\nStates:\n\nv(t): [V] The voltage at this pin\ni(t): [A] The current passing through this pin\nval(t): The binary value of the pin at this point. A voltage from 0V to 0.8V is a binary value of 0.\n\nA voltage in the range 2.0V to 5.0V is 1. Any other value is X.\n\n\n\n\n\n","category":"function"},{"location":"API/electrical/#Analog-Components","page":"Electrical Components","title":"Analog Components","text":"","category":"section"},{"location":"API/electrical/","page":"Electrical Components","title":"Electrical Components","text":"Ground\nResistor\nConductor\nCapacitor\nInductor\nIdealOpAmp","category":"page"},{"location":"API/electrical/#ModelingToolkitStandardLibrary.Electrical.Ground","page":"Electrical Components","title":"ModelingToolkitStandardLibrary.Electrical.Ground","text":"Ground(; name)\n\nGround node with the potential of zero and connector g. Every circuit must have one ground node.\n\nConnectors:\n\ng\n\n\n\n\n\n","category":"constant"},{"location":"API/electrical/#ModelingToolkitStandardLibrary.Electrical.Resistor","page":"Electrical Components","title":"ModelingToolkitStandardLibrary.Electrical.Resistor","text":"Resistor(; name, R)\n\nCreates an ideal Resistor following Ohm's Law.\n\nStates:\n\nSee OnePort\n\nConnectors:\n\np Positive pin\nn Negative pin\n\nParameters:\n\nR: [Ohm] Resistance\n\n\n\n\n\n","category":"constant"},{"location":"API/electrical/#ModelingToolkitStandardLibrary.Electrical.Conductor","page":"Electrical Components","title":"ModelingToolkitStandardLibrary.Electrical.Conductor","text":"Conductor(; name, G)\n\nCreates an ideal conductor.\n\nStates:\n\nSee OnePort\n\nConnectors:\n\np Positive pin\nn Negative pin\n\nParameters:\n\nG: [S] Conductance\n\n\n\n\n\n","category":"constant"},{"location":"API/electrical/#ModelingToolkitStandardLibrary.Electrical.Capacitor","page":"Electrical Components","title":"ModelingToolkitStandardLibrary.Electrical.Capacitor","text":"Capacitor(; name, C, v)\n\nCreates an ideal capacitor. Initial voltage of capacitor can be set with v ([V])\n\nStates:\n\nSee OnePort\n\nConnectors:\n\np Positive pin\nn Negative pin\n\nParameters:\n\nC: [F] Capacitance\n\n\n\n\n\n","category":"constant"},{"location":"API/electrical/#ModelingToolkitStandardLibrary.Electrical.Inductor","page":"Electrical Components","title":"ModelingToolkitStandardLibrary.Electrical.Inductor","text":"Inductor(; name, L, i)\n\nCreates an ideal Inductor. Initial current through inductor can be set with i ([A]).\n\nStates:\n\nSee OnePort\n\nConnectors:\n\np Positive pin\nn Negative pin\n\nParameters:\n\nL: [H] Inductance\n\n\n\n\n\n","category":"constant"},{"location":"API/electrical/#ModelingToolkitStandardLibrary.Electrical.IdealOpAmp","page":"Electrical Components","title":"ModelingToolkitStandardLibrary.Electrical.IdealOpAmp","text":"IdealOpAmp(; name)\n\nIdeal operational amplifier (norator-nullator pair). The ideal OpAmp is a two-port. The left port is fixed to v1 = 0 and i1 = 0 (nullator). At the right port both any voltage v2 and any current i2 are possible (norator).\n\nStates:\n\nSee TwoPort\n\nConnectors:\n\np1 Positive pin (left port)\np2 Positive pin (right port)\nn1 Negative pin (left port)\nn2 Negative pin (right port)\n\n\n\n\n\n","category":"constant"},{"location":"API/electrical/#Analog-Sensors","page":"Electrical Components","title":"Analog Sensors","text":"","category":"section"},{"location":"API/electrical/","page":"Electrical Components","title":"Electrical Components","text":"CurrentSensor\nPotentialSensor\nVoltageSensor\nPowerSensor\nMultiSensor","category":"page"},{"location":"API/electrical/#ModelingToolkitStandardLibrary.Electrical.CurrentSensor","page":"Electrical Components","title":"ModelingToolkitStandardLibrary.Electrical.CurrentSensor","text":"CurrentSensor(; name)\n\nCreates a circuit component that measures the current flowing through it. Analogous to an ideal ammeter.\n\nStates:\n\ni(t): [A] Current through the sensor\n\nConnectors:\n\np Positive pin\nn Negative pin\n\n\n\n\n\n","category":"constant"},{"location":"API/electrical/#ModelingToolkitStandardLibrary.Electrical.PotentialSensor","page":"Electrical Components","title":"ModelingToolkitStandardLibrary.Electrical.PotentialSensor","text":"PotentialSensor(; name)\n\nCreates a circuit component which measures the potential at a pin.\n\nStates:\n\nphi(t): [V] The measured potential at this point\n\nConnectors:\n\np Pin at which potential is to be measured\n\n\n\n\n\n","category":"constant"},{"location":"API/electrical/#ModelingToolkitStandardLibrary.Electrical.VoltageSensor","page":"Electrical Components","title":"ModelingToolkitStandardLibrary.Electrical.VoltageSensor","text":"VoltageSensor(; name)\n\nCreates a circuit component that measures the voltage across it. Analogous to an ideal voltmeter.\n\nStates:\n\nv(t): [V] The voltage difference from positive to negative pin p.v - n.v\n\nConnectors:\n\np Positive pin\nn Negative pin\n\n\n\n\n\n","category":"constant"},{"location":"API/electrical/#ModelingToolkitStandardLibrary.Electrical.PowerSensor","page":"Electrical Components","title":"ModelingToolkitStandardLibrary.Electrical.PowerSensor","text":"PowerSensor(; name)\n\nCombines a VoltageSensor and a CurrentSensor to measure the power being consumed by a circuit.\n\nStates:\n\npower(t): [W] The power being consumed, given by the product of voltage and current\nSee VoltageSensor\nSee CurrentSensor\n\nConnectors:\n\npc Corresponds to the p pin of the CurrentSensor\nnc Corresponds to the n pin of the CurrentSensor\npv Corresponds to the p pin of the VoltageSensor\nnv Corresponds to the n pin of the VoltageSensor\n\n\n\n\n\n","category":"constant"},{"location":"API/electrical/#ModelingToolkitStandardLibrary.Electrical.MultiSensor","page":"Electrical Components","title":"ModelingToolkitStandardLibrary.Electrical.MultiSensor","text":"MultiSensor(; name)\n\nCombines a VoltageSensor and a CurrentSensor.\n\nStates:\n\nv(t): [V] The voltage across the VoltageSensor. Defaults to 1.0.\ni(t): [A] The current across the CurrentSensor. Defaults to 1.0.\n\nConnectors:\n\npc Corresponds to the p pin of the CurrentSensor\nnc Corresponds to the n pin of the CurrentSensor\npv Corresponds to the p pin of the VoltageSensor\nnv Corresponds to the n pin of the VoltageSensor\n\n\n\n\n\n","category":"constant"},{"location":"API/electrical/#Analog-Sources","page":"Electrical Components","title":"Analog Sources","text":"","category":"section"},{"location":"API/electrical/","page":"Electrical Components","title":"Electrical Components","text":"Voltage\nCurrent","category":"page"},{"location":"API/electrical/#ModelingToolkitStandardLibrary.Electrical.Voltage","page":"Electrical Components","title":"ModelingToolkitStandardLibrary.Electrical.Voltage","text":"Voltage(; name)\n\nActs as an ideal voltage source with no internal resistance.\n\nStates:\n\nSee OnePort\n\nConnectors:\n\np Positive pin\nn Negative pin\nV RealInput Input for the voltage control signal, i.e. V ~ p.v - n.v\n\n\n\n\n\n","category":"constant"},{"location":"API/electrical/#ModelingToolkitStandardLibrary.Electrical.Current","page":"Electrical Components","title":"ModelingToolkitStandardLibrary.Electrical.Current","text":"Current(; name)\n\nActs as an ideal current source with no internal resistance.\n\nStates:\n\nSee OnePort\n\nConnectors:\n\np Positive pin\nn Negative pin\nI RealInput Input for the current control signal, i.e. `I ~ p.i\n\n\n\n\n\n","category":"constant"},{"location":"API/electrical/#Digital-Gates","page":"Electrical Components","title":"Digital Gates","text":"","category":"section"},{"location":"API/electrical/","page":"Electrical Components","title":"Electrical Components","text":"Not\nAnd\nNand\nOr\nNor\nXor\nXnor","category":"page"},{"location":"API/electrical/#Digital-Components","page":"Electrical Components","title":"Digital Components","text":"","category":"section"},{"location":"API/electrical/","page":"Electrical Components","title":"Electrical Components","text":"HalfAdder\nFullAdder\nMUX\nDEMUX\nEncoder\nDecoder","category":"page"},{"location":"API/electrical/#Digital-Sources","page":"Electrical Components","title":"Digital Sources","text":"","category":"section"},{"location":"API/electrical/","page":"Electrical Components","title":"Electrical Components","text":"PulseDiff\nSet\nReset\nPulse","category":"page"},{"location":"connectors/connections/#Introduction","page":"About Acausal Connections","title":"Introduction","text":"","category":"section"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"In Physical Network Acausal modeling, each physical domain must define a connector to combine model components. Each physical domain connector defines a minimum of 2 variables, one which is called a Through variable, and one which is called an Across variable. Both Modelica and SimScape define these variables in the same way:","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Modelica Connectors\nSimScape Connectors","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"However, the standard libraries differ on the selection of the Across variable for the Mechanical Translation and Rotation libraries, Modelica choosing position and angle and SimScape choosing velocity and angular velocity, respectively for Translation and Rotation. Modelica describes their decision here. In summary, they would like to provide less integration in the model to avoid lossy numerical behavior, but this decision assumes the lowest order derivative is needed by the model. Numerically it is possible to define the connector either way, but there are some consequences of this decision, and therefore we will study them in detail here as they relate to ModelingToolkit.","category":"page"},{"location":"connectors/connections/#Through-and-Across-Variable-Theory","page":"About Acausal Connections","title":"Through and Across Variable Theory","text":"","category":"section"},{"location":"connectors/connections/#General","page":"About Acausal Connections","title":"General","text":"","category":"section"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"The idea behind the selection of the through variable is that it should be a time derivative of some conserved quantity. The conserved quantity should be expressed by the across variable. In general terms, the physical system is given by","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Energy Dissipation & Flow:","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"beginaligned\n partial colorblueacross partial t cdot c_1 = colorgreenthrough \n colorgreenthrough cdot c_2 = colorblueacross\nendaligned","category":"page"},{"location":"connectors/connections/#Electrical","page":"About Acausal Connections","title":"Electrical","text":"","category":"section"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"For the Electrical domain, the across variable is voltage and the through variable current. Therefore","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Energy Dissipation:","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"partial colorbluevoltage partial t cdot capacitance = colorgreencurrent","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Flow:","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"colorgreencurrent cdot resistance = colorbluevoltage","category":"page"},{"location":"connectors/connections/#Translational","page":"About Acausal Connections","title":"Translational","text":"","category":"section"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"For the translation domain, choosing velocity for the across variable and force for the through gives","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Energy Dissipation:","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"partial colorbluevelocity partial t cdot mass = colorgreenforce","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Flow:","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"colorgreenforce cdot (1damping) = colorbluevelocity","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"The diagram here shows the similarity of problems in different physical domains.","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"(Image: Through and Across Variables)","category":"page"},{"location":"connectors/connections/#Translational-Connector-using-*Position*-Across-Variable","page":"About Acausal Connections","title":"Translational Connector using Position Across Variable","text":"","category":"section"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Now, if we choose position for the across variable, a similar relationship can be established, but the pattern must be broken.","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Energy Dissipation:","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"partial^2 colorblueposition partial t^2 cdot mass = colorgreenforce","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Flow:","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"colorgreenforce cdot (1damping) = partial colorblueposition partial t","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"As can be seen, we must now establish a higher order derivative to define the Energy Dissipation and Flow equations, requiring an extra equation, as will be shown in the example below.","category":"page"},{"location":"connectors/connections/#Examples","page":"About Acausal Connections","title":"Examples","text":"","category":"section"},{"location":"connectors/connections/#Electrical-Domain","page":"About Acausal Connections","title":"Electrical Domain","text":"","category":"section"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"We can generate the above relationship with ModelingToolkit and the ModelingToolkitStandardLibrary using 3 blocks:","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Capacitor: for energy storage with initial voltage = 1V\nResistor: for energy flow\nGround: for energy sink","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"As can be seen, this will give a 1 equation model matching our energy dissipation relationship","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"using ModelingToolkitStandardLibrary.Electrical, ModelingToolkit, DifferentialEquations\nusing ModelingToolkit: t_nounits as t\nusing Plots\n\n@named resistor = Resistor(R = 1)\n@named capacitor = Capacitor(C = 1)\n@named ground = Ground()\n\neqs = [connect(capacitor.p, resistor.p)\n connect(resistor.n, ground.g, capacitor.n)]\n\n@named model = ODESystem(eqs, t; systems = [resistor, capacitor, ground])\n\nsys = structural_simplify(model)\n\nprintln.(equations(sys))\nnothing # hide","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"The solution shows what we would expect, a non-linear dissipation of voltage and related decrease in current flow…","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"prob = ODEProblem(sys, [1.0], (0, 10.0), [])\nsol = solve(prob)\n\np1 = plot(sol, idxs = [capacitor.v])\np2 = plot(sol, idxs = [resistor.i])\nplot(p1, p2)","category":"page"},{"location":"connectors/connections/#Mechanical-Translational-Domain","page":"About Acausal Connections","title":"Mechanical Translational Domain","text":"","category":"section"},{"location":"connectors/connections/#Across-Variable-velocity","page":"About Acausal Connections","title":"Across Variable = velocity","text":"","category":"section"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Now using the Translational library based on velocity, we can see the same relationship with a system reduced to a single equation, using the components:","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Body (i.e. moving mass): for kinetic energy storage with an initial velocity = 1m/s\nDamper: for energy flow\nFixed: for energy sink","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"using ModelingToolkitStandardLibrary\nconst TV = ModelingToolkitStandardLibrary.Mechanical.Translational\n\n@named damping = TV.Damper(d = 1, flange_a.v = 1)\n@named body = TV.Mass(m = 1, v = 1)\n@named ground = TV.Fixed()\n\neqs = [connect(damping.flange_a, body.flange)\n connect(ground.flange, damping.flange_b)]\n\n@named model = ODESystem(eqs, t; systems = [damping, body, ground])\n\nsys = structural_simplify(model)\n\nprintln.(full_equations(sys))\nnothing # hide","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"As expected, we have a similar solution…","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"prob = ODEProblem(sys, [], (0, 10.0), [])\nsol_v = solve(prob)\n\np1 = plot(sol_v, idxs = [body.v])\np2 = plot(sol_v, idxs = [damping.f])\nplot(p1, p2)","category":"page"},{"location":"connectors/connections/#Across-Variable-position","page":"About Acausal Connections","title":"Across Variable = position","text":"","category":"section"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Now, let's consider the position-based approach. We can build the same model with the same components. As can be seen, we now end of up with 2 equations, because we need to relate the lower derivative (position) to force (with acceleration).","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"const TP = ModelingToolkitStandardLibrary.Mechanical.TranslationalPosition\n\n@named damping = TP.Damper(d = 1, va = 1, vb = 0.0)\n@named body = TP.Mass(m = 1, v = 1)\n@named ground = TP.Fixed(s_0 = 0)\n\neqs = [connect(damping.flange_a, body.flange)\n connect(ground.flange, damping.flange_b)]\n\n@named model = ODESystem(eqs, t; systems = [damping, body, ground])\n\nsys = structural_simplify(model)\n\nprintln.(full_equations(sys))\nnothing # hide","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"As can be seen, we get exactly the same result. The only difference here is that we are solving an extra equation, which allows us to plot the body position as well.","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"prob = ODEProblem(sys, [], (0, 10.0), [])\nsol_p = solve(prob)\n\np1 = plot(sol_p, idxs = [body.v])\np2 = plot(sol_p, idxs = [damping.f])\np3 = plot(sol_p, idxs = [body.s])\n\nplot(p1, p2, p3)","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"The question then arises, can the position be plotted when using the Mechanical Translational Domain based on the Velocity Across variable? Yes, we can! There are 2 solutions:","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"the Mass component will add the position variable when the s parameter is used to set an initial position. Otherwise, the component does not track the position.","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"@named body = TV.Mass(m = 1, v = 1, s = 0)","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"implement a PositionSensor TODO: Implement Translation Sensors","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Either option will produce the same result regardless of which across variable is used. If the same result is given, why are both options included in the Standard Library, what are the differences? These differences will be discussed next so that an informed decision can be made about which domain is best for your model.","category":"page"},{"location":"connectors/connections/#Mechanical/Translational-Library-Differences-(Velocity-vs.-Position-Connectors)","page":"About Acausal Connections","title":"Mechanical/Translational Library Differences (Velocity vs. Position Connectors)","text":"","category":"section"},{"location":"connectors/connections/#Initialization","page":"About Acausal Connections","title":"Initialization","text":"","category":"section"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"The main difference between ModelingToolkitStandardLibrary.Mechanical.Translational and ModelingToolkitStandardLibrary.Mechanical.TranslationalPosition is how they are initialized. In the ModelingToolkitStandardLibrary initialization, parameters are defined at the component level, so we simply need to be careful to set the correct initial conditions for the domain that it used. Let's use the following example problem to explain the differences.","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"(Image: Example Mechanical Model)","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"In this problem, we have a mass, spring, and damper which are connected to a fixed point. Let's see how each component is defined.","category":"page"},{"location":"connectors/connections/#Damper","page":"About Acausal Connections","title":"Damper","text":"","category":"section"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"The damper will connect the flange/flange 1 (flange_a) to the mass, and flange/flange 2 (flange_b) to the fixed point. For both position- and velocity-based domains, we set the damping constant d=1 and va=1 and leave the default for v_b_0 at 0. For the position domain, we also need to set the initial positions for flange_a and flange_b.","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"@named dv = TV.Damper(d = 1, flange_a.v = 1)\n@named dp = TP.Damper(d = 1, va = 1, vb = 0.0, flange_a__s = 3, flange_b__s = 1)\nnothing # hide","category":"page"},{"location":"connectors/connections/#Spring","page":"About Acausal Connections","title":"Spring","text":"","category":"section"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"The spring will connect the flange/flange 1 (flange_a) to the mass, and flange/flange 2 (flange_b) to the fixed point. For both position- and velocity-based domains, we set the spring constant k=1. The velocity domain then requires the initial velocity va and initial spring stretch delta_s. The position domain instead needs the initial positions for flange_a and flange_b and the natural spring length l.","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"@named sv = TV.Spring(k = 1, flange_a__v = 1, delta_s = 1)\n@named sp = TP.Spring(k = 1, flange_a__s = 3, flange_b__s = 1, l = 1)\nnothing # hide","category":"page"},{"location":"connectors/connections/#Mass","page":"About Acausal Connections","title":"Mass","text":"","category":"section"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"For both position- and velocity-based domains, we set the mass m=1 and initial velocity v=1. Like the damper, the position domain requires the position initial conditions set as well.","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"@named bv = TV.Mass(m = 1, v = 1)\n@named bp = TP.Mass(m = 1, v = 1, s = 3)\nnothing # hide","category":"page"},{"location":"connectors/connections/#Fixed","page":"About Acausal Connections","title":"Fixed","text":"","category":"section"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Here the velocity domain requires no initial condition, but for our model to work as defined we must set the position domain component to the correct initial position.","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"@named gv = TV.Fixed()\n@named gp = TP.Fixed(s_0 = 1)\nnothing # hide","category":"page"},{"location":"connectors/connections/#Comparison","page":"About Acausal Connections","title":"Comparison","text":"","category":"section"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"As can be seen, the position-based domain requires more initial condition information to be properly defined, since the absolute position information is required. Therefore, based on the model being described, it may be more natural to choose one domain over the other.","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Let's define a quick function to simplify and solve the 2 different systems. Note, we will solve with a fixed time step and a set tolerance to compare the numerical differences.","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"function simplify_and_solve(damping, spring, body, ground)\n eqs = [connect(spring.flange_a, body.flange, damping.flange_a)\n connect(spring.flange_b, damping.flange_b, ground.flange)]\n\n @named model = ODESystem(eqs, t; systems = [ground, body, spring, damping])\n\n sys = structural_simplify(model)\n\n println.(full_equations(sys))\n\n prob = ODEProblem(sys, [], (0, 10.0), [])\n sol = solve(prob; dt = 0.1, adaptive = false, reltol = 1e-9, abstol = 1e-9)\n\n return sol\nend\nnothing # hide","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Now let's solve the velocity domain model","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"solv = simplify_and_solve(dv, sv, bv, gv);\nnothing # hide","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"And the position domain model","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"solp = simplify_and_solve(dp, sp, bp, gp);\nnothing # hide","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Now we can plot the comparison of the 2 models and see they give the same result.","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"plot(ylabel = \"mass velocity [m/s]\")\nplot!(solv, idxs = [bv.v])\nplot!(solp, idxs = [bp.v])","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"But, what if we wanted to plot the mass position? This is easy for the position-based domain, we have the state bp₊s(t), but for the velocity-based domain we have sv₊delta_s(t) which is the spring stretch. To get the absolute position, we add the spring natural length (1m) and the fixed position (1m). As can be seen, we then get the same result.","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"plot(ylabel = \"mass position [m]\")\nplot!(solv, idxs = [sv.delta_s + 1 + 1])\nplot!(solp, idxs = [bp.s])","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"So in conclusion, the position based domain gives easier access to absolute position information, but requires more initial condition information.","category":"page"},{"location":"connectors/connections/#Accuracy","page":"About Acausal Connections","title":"Accuracy","text":"","category":"section"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"One may then ask, what the trade-off in terms of numerical accuracy is. When we look at the simplified equations, we can see that actually both systems solve the same equations. The differential equations of the velocity domain are","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"beginaligned\nm cdot dotv + d cdot v + k cdot Delta s = 0 \ndotDelta s = v\nendaligned","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"And for the position domain are","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"beginaligned\nm cdot dotv + d cdot v + k cdot (s - s_b_0 - l) = 0 \ndots = v\nendaligned","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"By definition, the spring stretch is","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Delta s = s - s_b_0 - l","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"Which means both systems are actually solving the same exact system. We can plot the numerical difference between the 2 systems and see the result is negligible.","category":"page"},{"location":"connectors/connections/","page":"About Acausal Connections","title":"About Acausal Connections","text":"plot(title = \"numerical difference: vel. vs. pos. domain\", xlabel = \"time [s]\",\n ylabel = \"solv[bv.v] .- solp[bp.v]\")\ntime = 0:0.1:10\nplot!(time, (solv(time)[bv.v] .- solp(time)[bp.v]), label = \"\")\nPlots.ylims!(-1e-15, 1e-15)","category":"page"},{"location":"tutorials/custom_component/#Custom-Component","page":"Custom Components","title":"Custom Component","text":"","category":"section"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"In this tutorial, the creation of a custom component is demonstrated via the Chua's circuit. The circuit is a simple circuit that shows chaotic behavior. Except for a non-linear resistor, every other component already is part of ModelingToolkitStandardLibrary.Electrical.","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"First, we need to make some imports.","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"using ModelingToolkit\nusing ModelingToolkit: t_nounits as t\nusing ModelingToolkitStandardLibrary.Electrical\nusing ModelingToolkitStandardLibrary.Electrical: OnePort\nusing OrdinaryDiffEq\nusing IfElse: ifelse\nusing Plots","category":"page"},{"location":"tutorials/custom_component/#Custom-Component-2","page":"Custom Components","title":"Custom Component","text":"","category":"section"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"Now the custom component can be defined. The Modelica implementation of the NonlinearResistor looks as follows:","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"model NonlinearResistor \"Chua's resistor\"\n extends Interfaces.OnePort;\n\n parameter SI.Conductance Ga \"conductance in inner voltage range\";\n parameter SI.Conductance Gb \"conductance in outer voltage range\";\n parameter SI.Voltage Ve \"inner voltage range limit\";\nequation\n i = if (v < -Ve) then Gb*(v + Ve) - Ga*Ve else if (v > Ve) then Gb*(v - Ve) + Ga*Ve else Ga*v;\nend NonlinearResistor;","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"this can almost be directly translated to the syntax of ModelingToolkit.","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"function NonlinearResistor(; name, Ga, Gb, Ve)\n @named oneport = OnePort()\n @unpack v, i = oneport\n pars = @parameters Ga=Ga Gb=Gb Ve=Ve\n eqs = [\n i ~ ifelse(v < -Ve,\n Gb * (v + Ve) - Ga * Ve,\n ifelse(v > Ve,\n Gb * (v - Ve) + Ga * Ve,\n Ga * v))\n ]\n extend(ODESystem(eqs, t, [], pars; name = name), oneport)\nend\nnothing # hide","category":"page"},{"location":"tutorials/custom_component/#Explanation","page":"Custom Components","title":"Explanation","text":"","category":"section"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"All components in ModelingToolkit are created via a function that serves as the constructor and returns some form of system, in this case, an ODESystem. Since the non-linear resistor is essentially a standard electrical component with two ports, we can extend from the OnePort component of the library.","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"@named oneport = OnePort()","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"This creates a OnePort with the name = :oneport. For easier notation, we can unpack the states of the component","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"@unpack v, i = oneport","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"It might be a good idea to create parameters for the constants of the NonlinearResistor.","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"pars = @parameters Ga=Ga Gb=Gb Ve=Ve","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"The syntax looks funny but it simply creates symbolic parameters with the name Ga where its default value is set from the function's argument Ga. While this is not strictly necessary it allows the user to remake the problem easily with different parameters or allow for auto-tuning or parameter optimization without having to do all the costly steps that may be involved with building and simplifying a model. The non-linear (in this case piece-wise constant) equation for the current can be implemented using IfElse.ifelse. Finally, the created oneport component is extended with the created equations and parameters. In this case, no extra state variables are added, hence an empty vector is supplied. The independent variable t needs to be supplied as the second argument.","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"extend(ODESystem(eqs, t, [], pars; name = name), oneport)","category":"page"},{"location":"tutorials/custom_component/#Building-the-Model","page":"Custom Components","title":"Building the Model","text":"","category":"section"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"The final model can now be created with the components from the library and the new custom component.","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"@named L = Inductor(L = 18)\n@named Ro = Resistor(R = 12.5e-3)\n@named G = Conductor(G = 0.565)\n@named C1 = Capacitor(C = 10, v = 4)\n@named C2 = Capacitor(C = 100)\n@named Nr = NonlinearResistor(Ga = -0.757576,\n Gb = -0.409091,\n Ve = 1)\n@named Gnd = Ground()\n\nconnections = [connect(L.p, G.p)\n connect(G.n, Nr.p)\n connect(Nr.n, Gnd.g)\n connect(C1.p, G.n)\n connect(L.n, Ro.p)\n connect(G.p, C2.p)\n connect(C1.n, Gnd.g)\n connect(C2.n, Gnd.g)\n connect(Ro.n, Gnd.g)]\n\n@named model = ODESystem(connections, t, systems = [L, Ro, G, C1, C2, Nr, Gnd])\nnothing # hide","category":"page"},{"location":"tutorials/custom_component/#Simulating-the-Model","page":"Custom Components","title":"Simulating the Model","text":"","category":"section"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"Now the model can be simulated. First, structural_simplify is called on the model and an ODEProblem is built from the result. Since the initial voltage of the first capacitor was already specified via v, no initial condition is given and an empty pair is supplied.","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"sys = structural_simplify(model)\nprob = ODEProblem(sys, Pair[], (0, 5e4), saveat = 0.01)\nsol = solve(prob, Rodas4())\n\nPlots.plot(sol[C1.v], sol[C2.v], title = \"Chaotic Attractor\", label = \"\",\n ylabel = \"C1 Voltage in V\", xlabel = \"C2 Voltage in V\")\nPlots.savefig(\"chua_phase_plane.png\")\nnothing # hide\n\nPlots.plot(sol; idxs = [C1.v, C2.v, L.i],\n labels = [\"C1 Voltage in V\" \"C2 Voltage in V\" \"Inductor Current in A\"])\nPlots.savefig(\"chua.png\")\nnothing # hide","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"(Image: Time series plot of C1.v, C2.v and L.i)","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"(Image: Phase plane plot of C1.v and C2.v)","category":"page"},{"location":"tutorials/rc_circuit/#RC-Circuit-Model","page":"RC Circuit","title":"RC Circuit Model","text":"","category":"section"},{"location":"tutorials/rc_circuit/","page":"RC Circuit","title":"RC Circuit","text":"This tutorial is a simplified version of the RC circuit tutorial in the ModelingToolkit.jl documentation. In that tutorial, the full RC circuit is built from scratch. Here, we will use the components of the Electrical model in the ModelingToolkit Standard Library to simply connect pre-made components and simulate the model.","category":"page"},{"location":"tutorials/rc_circuit/","page":"RC Circuit","title":"RC Circuit","text":"using ModelingToolkit, OrdinaryDiffEq, Plots\nusing ModelingToolkitStandardLibrary.Electrical\nusing ModelingToolkitStandardLibrary.Blocks: Constant\nusing ModelingToolkit: t_nounits as t\n\nR = 1.0\nC = 1.0\nV = 1.0\n@named resistor = Resistor(R = R)\n@named capacitor = Capacitor(C = C, v = 0.0)\n@named source = Voltage()\n@named constant = Constant(k = V)\n@named ground = Ground()\n\nrc_eqs = [connect(constant.output, source.V)\n connect(source.p, resistor.p)\n connect(resistor.n, capacitor.p)\n connect(capacitor.n, source.n, ground.g)]\n\n@named rc_model = ODESystem(rc_eqs, t,\n systems = [resistor, capacitor, constant, source, ground])\nsys = structural_simplify(rc_model)\nprob = ODEProblem(sys, Pair[], (0, 10.0))\nsol = solve(prob, Tsit5())\nplot(sol, idxs = [capacitor.v, resistor.i],\n title = \"RC Circuit Demonstration\",\n labels = [\"Capacitor Voltage\" \"Resistor Current\"])\nsavefig(\"plot.png\");\nnothing; # hide","category":"page"},{"location":"tutorials/rc_circuit/","page":"RC Circuit","title":"RC Circuit","text":"(Image: )","category":"page"},{"location":"API/mechanical/#ModelingToolkit-Standard-Library:-Mechanical-Components","page":"Mechanical Components","title":"ModelingToolkit Standard Library: Mechanical Components","text":"","category":"section"},{"location":"API/mechanical/","page":"Mechanical Components","title":"Mechanical Components","text":"Pages = [\"mechanical.md\"]\nDepth = 3","category":"page"},{"location":"API/mechanical/#Index","page":"Mechanical Components","title":"Index","text":"","category":"section"},{"location":"API/mechanical/","page":"Mechanical Components","title":"Mechanical Components","text":"Pages = [\"mechanical.md\"]","category":"page"},{"location":"API/mechanical/#Rotational-Components","page":"Mechanical Components","title":"Rotational Components","text":"","category":"section"},{"location":"API/mechanical/","page":"Mechanical Components","title":"Mechanical Components","text":"CurrentModule = ModelingToolkitStandardLibrary.Mechanical.Rotational","category":"page"},{"location":"API/mechanical/#Rotational-Utils","page":"Mechanical Components","title":"Rotational Utils","text":"","category":"section"},{"location":"API/mechanical/","page":"Mechanical Components","title":"Mechanical Components","text":"Flange\nSupport\nPartialCompliantWithRelativeStates\nPartialElementaryOneFlangeAndSupport2\nPartialElementaryTwoFlangesAndSupport2\nPartialCompliant","category":"page"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.Flange","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.Flange","text":"Support(;name)\n\n1-dim. rotational flange of a shaft.\n\nStates:\n\nphi(t): [rad] Absolute rotation angle of flange\ntau(t): [N.m] Cut torque in the flange\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.Support","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.Support","text":"Support(;name)\n\nSupport/housing of a 1-dim. rotational shaft\n\nStates:\n\nphi(t): [rad] Absolute rotation angle of the support/housing\ntau(t): [N.m] Cut torque in the support/housing\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.PartialCompliantWithRelativeStates","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.PartialCompliantWithRelativeStates","text":"PartialCompliantWithRelativeStates(; name, phi_rel = 0.0, tau = 0.0)\n\nPartial model for the compliant connection of two rotational 1-dim. shaft flanges where the relative angle and speed are used as preferred states\n\nStates:\n\nphi_rel(t): [rad] Relative rotation angle (= flangeb.phi - flangea.phi). It accepts an initial value, which defaults to 0.0.\nw_rel(t): [rad/s] Relative angular velocity (= D(phi_rel)). It accepts an initial value, which defaults to 0.0.\na_rel(t): [rad/s²] Relative angular acceleration (= D(w_rel)). It accepts an initial value, which defaults to 0.0.\ntau(t): [N.m] Torque between flanges (= flange_b.tau). It accepts an initial value, which defaults to 0.0.\n\nConnectors:\n\nflange_a Flange\nflange_b Flange\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.PartialElementaryOneFlangeAndSupport2","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.PartialElementaryOneFlangeAndSupport2","text":"PartialElementaryOneFlangeAndSupport2(; name, use_support = false)\n\nPartial model for a component with one rotational 1-dim. shaft flange and a support used for textual modeling, i.e., for elementary models\n\nStates:\n\nphi_support(t): [rad] Absolute angle of support flange\"\n\nConnectors:\n\nflange Flange\n\nParameters:\n\nuse_support: If support flange enabled, otherwise implicitly grounded\n\n\n\n\n\n","category":"function"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.PartialElementaryTwoFlangesAndSupport2","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.PartialElementaryTwoFlangesAndSupport2","text":"PartialElementaryTwoFlangesAndSupport2(;name, use_support=false)\n\nPartial model for a component with two rotational 1-dim. shaft flanges and a support used for textual modeling, i.e., for elementary models\n\nStates:\n\nphi_support(t): [rad] Absolute angle of support flange\n\nConnectors:\n\nflange_a Flange\nflange_b Flange\nsupport Support if use_support == true\n\nParameters:\n\nuse_support: If support flange enabled, otherwise implicitly grounded\n\n\n\n\n\n","category":"function"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.PartialCompliant","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.PartialCompliant","text":"PartialCompliant(; name, phi_rel = 0.0, tau = 0.0)\n\nPartial model for the compliant connection of two rotational 1-dim. shaft flanges.\n\nStates:\n\nphi_rel(t): [rad] Relative rotation angle (flange_b.phi - flange_a.phi). It accepts an initial value, which defaults to 0.0.\ntau(t): [N.m] Torque between flanges (flange_b.tau). It accepts an initial value, which defaults to 0.0.\n\nConnectors:\n\nflange_a Flange\nflange_b Flange\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#Rotational-Core-Components","page":"Mechanical Components","title":"Rotational Core Components","text":"","category":"section"},{"location":"API/mechanical/","page":"Mechanical Components","title":"Mechanical Components","text":"Fixed\nInertia\nSpring\nDamper\nSpringDamper\nIdealGear\nRotationalFriction","category":"page"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.Fixed","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.Fixed","text":"Fixed(;name, phi0 = 0.0)\n\nFlange fixed in housing at a given angle.\n\nConnectors:\n\nflange Flange\n\nParameters:\n\nphi0: [rad] Fixed offset angle of housing\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.Inertia","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.Inertia","text":"Inertia(;name, J, phi = 0.0, w = 0.0, a = 0.0)\n\n1D-rotational component with inertia.\n\nStates:\n\nphi: [rad] Absolute rotation angle of component\nw: [rad/s] Absolute angular velocity of component (= D(phi))\na: [rad/s²] Absolute angular acceleration of component (= D(w))\n\nConnectors:\n\nflange_a Flange Left flange\nflange_b Flange Right flange\n\nParameters:\n\nJ: [kg·m²] Moment of inertia\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.Spring","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.Spring","text":"Spring(; name, c, phi_rel0 = 0.0)\n\nLinear 1D rotational spring\n\nStates:\n\nphi_rel(t): [rad] Relative rotation angle (flange_b.phi - flange_a.phi)\ntau(t): [N.m] Torque between flanges (flange_b.tau)\n\nConnectors:\n\nflange_a Flange\nflange_b Flange\n\nParameters:\n\nc: [N.m/rad] Spring constant\nphi_rel0: [rad] Unstretched spring angle. Defaults to 0.0.\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.Damper","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.Damper","text":"Damper(; name, d)\n\nLinear 1D rotational damper\n\nStates:\n\nphi_rel(t): [rad] Relative rotation angle (= flangeb.phi - flangea.phi)\nw_rel(t): [rad/s] Relative angular velocity (= D(phi_rel))\na_rel(t): [rad/s²] Relative angular acceleration (= D(w_rel))\ntau(t): [N.m] Torque between flanges (= flange_b.tau)\n\nConnectors:\n\nflange_a Flange\nflange_b Flange\n\nParameters:\n\nd: [N.m.s/rad] Damping constant\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.SpringDamper","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.SpringDamper","text":"SpringDamper(; name, d)\n\nLinear 1D rotational spring and damper\n\nStates:\n\nphi_rel(t): [rad] Relative rotation angle (= flangeb.phi - flangea.phi)\nw_rel(t): [rad/s] Relative angular velocity (= D(phi_rel))\na_rel(t): [rad/s²] Relative angular acceleration (= D(w_rel))\ntau(t): [N.m] Torque between flanges (= flange_b.tau)\n\nConnectors:\n\nflange_a Flange\nflange_b Flange\n\nParameters:\n\nd: [N.m.s/rad] Damping constant\nc: [N.m/rad] Spring constant\nphi_rel0: [rad] Unstretched spring angle. Defaults to 0.0\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.IdealGear","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.IdealGear","text":"IdealGear(; name, ratio, use_support = false)\n\nIdeal gear without inertia.\n\nThis element characterizes any type of gear box which is fixed in the ground and which has one driving shaft and one driven shaft.\n\nStates:\n\nphi_a(t): [rad] Relative angle between shaft a and the support\nphi_b(t): [rad] Relative angle between shaft b and the support\n\nConnectors:\n\nflange_a Flange\nflange_b Flange\nsupport Support if use_support == true\n\nParameters:\n\nratio: Transmission ratio (flangea.phi/flangeb.phi)\nuse_support: If support flange enabled, otherwise implicitly grounded. By default it is false\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.RotationalFriction","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.RotationalFriction","text":"RotationalFriction(; name, f, tau_c, w_brk, tau_brk)\n\nModels rotational friction with Stribeck effect, Coulomb friction and viscous friction between the two flanges. The friction torque is a function of the relative angular velocity between flange_a and flange_b.\n\nFriction model: \"Armstrong, B. and C.C. de Wit, Friction Modeling and Compensation, The Control Handbook, CRC Press, 1995.\"\n\nStates:\n\nphi_rel(t): [rad] Relative rotation angle (= flange_b.phi - flange_a.phi)\nw_rel(t): [rad/s] Relative angular velocity (= D(phi_rel))\na_rel(t): [rad/s²] Relative angular acceleration (= D(w_rel))\ntau(t): [N.m] Torque between flanges (= flange_b.tau)\n\nConnectors:\n\nflange_a Flange\nflange_b Flange\n\nParameters:\n\nf: [N⋅m/(rad/s)] Viscous friction coefficient\ntau_c: [N⋅m] Coulomb friction torque\nw_brk: [rad/s] Breakaway friction velocity\ntau_brk: [N⋅m] Breakaway friction torque\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#Rotational-Sources","page":"Mechanical Components","title":"Rotational Sources","text":"","category":"section"},{"location":"API/mechanical/","page":"Mechanical Components","title":"Mechanical Components","text":"Torque\nSpeed","category":"page"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.Torque","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.Torque","text":"Torque(; name, use_support = false)\n\nInput signal acting as external torque on a flange\n\nStates:\n\nphi_support(t): [rad] Absolute angle of support flange\n\nConnectors:\n\nflange Flange\ntau RealInput Accelerating torque acting at flange -flange.tau\n\nParameters:\n\nuse_support\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.Speed","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.Speed","text":"Speed(; name, use_support = false, exact = false, f_crit = 50)\n\nForced movement of a flange according to a reference angular velocity signal\n\nStates:\n\nphi_support(t): [rad] Absolute angle of support flange\"\n\nConnectors:\n\nflange Flange\nw_ref RealInput Reference angular velocity of flange with respect to support as input signal needs to be continuously differential\n\nParameters:\n\nuse_support: If support flange enabled, otherwise implicitly grounded\nexact: true/false exact treatment/filtering the input signal\ntau_filt: [rad/s] if exact=false, Time constant of low-pass filter to filter input signal\n\n\n\n\n\n","category":"function"},{"location":"API/mechanical/#Rotational-Sensors","page":"Mechanical Components","title":"Rotational Sensors","text":"","category":"section"},{"location":"API/mechanical/","page":"Mechanical Components","title":"Mechanical Components","text":"AngleSensor\nSpeedSensor\nTorqueSensor\nRelSpeedSensor","category":"page"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.AngleSensor","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.AngleSensor","text":"AngleSensor(; name)\n\nIdeal sensor to measure the absolute flange angle\n\nConnectors:\n\nflange: Flange Flange of shaft from which sensor information shall be measured\nphi: RealOutput Absolute angle of flange\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.SpeedSensor","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.SpeedSensor","text":"SpeedSensor(; name)\n\nIdeal sensor to measure the absolute flange angular velocity\n\nConnectors:\n\nflange: Flange Flange of shaft from which sensor information shall be measured\nw: RealOutput Absolute angular velocity of flange\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.TorqueSensor","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.TorqueSensor","text":"TorqueSensor(;name)\n\nIdeal sensor to measure the torque between two flanges (= flange_a.tau)\n\nConnectors:\n\nflange_a: Flange Left flange of shaft\nflange_b: Flange Left flange of shaft\ntau: RealOutput Torque in flange flangea and flangeb (tau = flange_a.tau = -flange_b.tau)\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Rotational.RelSpeedSensor","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.RelSpeedSensor","text":"RelSpeedSensor(; name)\n\nIdeal sensor to measure the relative angular velocity\n\nConnectors:\n\nflange_a: Flange Flange of shaft from which sensor information shall be measured\nflange_b: Flange Flange of shaft from which sensor information shall be measured\nw: RealOutput Absolute angular velocity of flange\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#Translational-Components","page":"Mechanical Components","title":"Translational Components","text":"","category":"section"},{"location":"API/mechanical/","page":"Mechanical Components","title":"Mechanical Components","text":"CurrentModule = ModelingToolkitStandardLibrary.Mechanical.Translational","category":"page"},{"location":"API/mechanical/#Translational-Utils","page":"Mechanical Components","title":"Translational Utils","text":"","category":"section"},{"location":"API/mechanical/","page":"Mechanical Components","title":"Mechanical Components","text":"MechanicalPort","category":"page"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Translational.MechanicalPort","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Translational.MechanicalPort","text":"MechanicalPort(;name)\n\n1-dim. rotational flange of a shaft.\n\nStates:\n\nv: [m/s] velocity of the node\nf: [N] force entering the node\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#Translational-Core-Components","page":"Mechanical Components","title":"Translational Core Components","text":"","category":"section"},{"location":"API/mechanical/","page":"Mechanical Components","title":"Mechanical Components","text":"Mass\nSpring\nDamper\nFixed","category":"page"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Translational.Mass","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Translational.Mass","text":"Mass(; name, v_0 = 0.0, m, s = nothing, g = nothing)\n\nSliding mass with inertia\n\nParameters:\n\nm: [kg] mass of sliding body\nv_0: [m/s] Initial value of absolute linear velocity of sliding mass (default 0 m/s)\ns: [m] initial value of absolute position of sliding mass (optional)\ng: [m/s²] gravity field acting on the mass, positive value acts in the positive direction (optional)\n\nStates:\n\nv: [m/s] absolute linear velocity of sliding mass\ns: [m] absolute position of sliding mass (optional with parameter s)\n\nConnectors:\n\nflange: 1-dim. translational flange\n\n\n\n\n\n","category":"function"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Translational.Spring","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Translational.Spring","text":"Spring(; name, k, delta_s = 0.0, va=0.0, v_b_0=0.0)\n\nLinear 1D translational spring\n\nParameters:\n\nk: [N/m] Spring constant\ndelta_s: initial spring stretch\nva: [m/s] Initial value of absolute linear velocity at flange_a (default 0 m/s)\nv_b_0: [m/s] Initial value of absolute linear velocity at flange_b (default 0 m/s)\n\nConnectors:\n\nflange_a: 1-dim. translational flange on one side of spring\nflange_b: 1-dim. translational flange on opposite side of spring\n\n\n\n\n\n","category":"function"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Translational.Damper","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Translational.Damper","text":"Damper(; name, d, flange_a.v = 0.0, flange_b.v = 0.0)\n\nLinear 1D translational damper\n\nParameters:\n\nd: [N.s/m] Damping constant\n\nConnectors:\n\nflange_a: 1-dim. translational flange on one side of damper. Initial value of state v is set to 0.0 m/s.\nflange_b: 1-dim. translational flange on opposite side of damper. Initial value of state v is set to 0.0 m/s.\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Translational.Fixed","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Translational.Fixed","text":"Fixed(; name)\n\nFixes a flange position (velocity = 0)\n\nConnectors:\n\nflange: 1-dim. translational flange\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#Translational-Sources","page":"Mechanical Components","title":"Translational Sources","text":"","category":"section"},{"location":"API/mechanical/","page":"Mechanical Components","title":"Mechanical Components","text":"Force\nPosition\nVelocity\nAcceleration","category":"page"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Translational.Force","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Translational.Force","text":"Force(; name)\n\nLinear 1D force input source\n\nConnectors:\n\nflange: 1-dim. translational flange\nf: real input\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Translational.Position","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Translational.Position","text":"Position(solves_force = true; name)\n\nLinear 1D position input source. Set solves_force=false to force input force to 0 (i.e. only the position is given, the respective force needed is already provided elsewhere in the model). \n\nConnectors:\n\nflange: 1-dim. translational flange\ns: real input\n\n\n\n\n\n","category":"function"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Translational.Velocity","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Translational.Velocity","text":"Velocity(solves_force = true; name)\n\nLinear 1D position input source. Set solves_force=false to force input force to 0 (i.e. only the velocity is given, the respective force needed is already provided elsewhere in the model). \n\nConnectors:\n\nflange: 1-dim. translational flange\nv: real input\n\n\n\n\n\n","category":"function"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Translational.Acceleration","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Translational.Acceleration","text":"Acceleration(solves_force = true; name)\n\nLinear 1D position input source. Set solves_force=false to force input force to 0 (i.e. only the acceleration is given, the respective force needed is already provided elsewhere in the model). \n\nConnectors:\n\nflange: 1-dim. translational flange\na: real input\n\n\n\n\n\n","category":"function"},{"location":"API/mechanical/#Translational-Sensors","page":"Mechanical Components","title":"Translational Sensors","text":"","category":"section"},{"location":"API/mechanical/","page":"Mechanical Components","title":"Mechanical Components","text":"ForceSensor\nPositionSensor\nAccelerationSensor","category":"page"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Translational.ForceSensor","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Translational.ForceSensor","text":"ForceSensor(; name)\n\nLinear 1D force input sensor.\n\nConnectors:\n\nflange: 1-dim. translational flange\noutput: real output\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Translational.PositionSensor","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Translational.PositionSensor","text":"PositionSensor(; s = 0, name)\n\nLinear 1D position input sensor.\n\nStates:\n\ns: [m] absolute position (with initial value of 0.0)\n\nConnectors:\n\nflange: 1-dim. translational flange\noutput: real output\n\n\n\n\n\n","category":"constant"},{"location":"API/mechanical/#ModelingToolkitStandardLibrary.Mechanical.Translational.AccelerationSensor","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Translational.AccelerationSensor","text":"AccelerationSensor(; name)\n\nLinear 1D position input sensor.\n\nStates:\n\na: [m/s^2] measured acceleration\n\nConnectors:\n\nflange: 1-dim. translational flange\noutput: real output\n\n\n\n\n\n","category":"constant"},{"location":"API/linear_analysis/#Linear-Analysis","page":"Linear Analysis","title":"Linear Analysis","text":"","category":"section"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"danger: Experimental\nThe interface described here is currently experimental and at any time subject to breaking changes not respecting semantic versioning.","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"Linear analysis refers to the process of linearizing a nonlinear model and analysing the resulting linear dynamical system. To facilitate linear analysis, ModelingToolkitStandardLibrary provides the concept of an AnalysisPoint, which can be inserted in-between two causal blocks (such as those from the Blocks sub module). Once a model containing analysis points is built, several operations are available:","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"get_sensitivity get the sensitivity function (wiki), S(s), as defined in the field of control theory.\nget_comp_sensitivity get the complementary sensitivity function T(s) S(s)+T(s)=1.\nget_looptransfer get the (open) loop-transfer function where the loop starts and ends in the analysis point. For a typical simple feedback connection with a plant P(s) and a controller C(s), the loop-transfer function at the plant output is P(s)C(s).\nlinearize can be called with two analysis points denoting the input and output of the linearized system.\nopen_loop return a new (nonlinear) system where the loop has been broken in the analysis point, i.e., the connection the analysis point usually implies has been removed.","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"An analysis point can be created explicitly using the constructor AnalysisPoint, or automatically when connecting two causal components using connect:","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"connect(comp1.output, :analysis_point_name, comp2.input)","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"warning: Causality\nAnalysis points are causal, i.e., they imply a directionality for the flow of information. The order of the connections in the connect statement is thus important, i.e., connect(out, :name, in) is different from connect(in, :name, out).","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"The directionality of an analysis point can be thought of as an arrow in a block diagram, where the name of the analysis point applies to the arrow itself.","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"┌─────┐ ┌─────┐\n│ │ name │ │\n│ out├────────►│in │\n│ │ │ │\n└─────┘ └─────┘","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"This is signified by the name being the middle argument to connect.","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"Of the above mentioned functions, all except for open_loop return the output of ModelingToolkit.linearize, which is","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"matrices, simplified_sys = linearize(...)\n# matrices = (; A, B, C, D)","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"i.e., matrices is a named tuple containing the matrices of a linear state-space system on the form","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"beginaligned\ndot x = Ax + Bu\ny = Cx + Du\nendaligned","category":"page"},{"location":"API/linear_analysis/#Example","page":"Linear Analysis","title":"Example","text":"","category":"section"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"The following example builds a simple closed-loop system with a plant P and a controller C. Two analysis points are inserted, one before and one after P. We then derive a number of sensitivity functions and show the corresponding code using the package ControlSystemBase.jl","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"using ModelingToolkitStandardLibrary.Blocks, ModelingToolkit\n@named P = FirstOrder(k = 1, T = 1) # A first-order system with pole in -1\n@named C = Gain(-1) # A P controller\nt = ModelingToolkit.get_iv(P)\neqs = [connect(P.output, :plant_output, C.input) # Connect with an automatically created analysis point called :plant_output\n connect(C.output, :plant_input, P.input)]\nsys = ODESystem(eqs, t, systems = [P, C], name = :feedback_system)\n\nmatrices_S = get_sensitivity(sys, :plant_input)[1] # Compute the matrices of a state-space representation of the (input)sensitivity function.\nmatrices_T = get_comp_sensitivity(sys, :plant_input)[1]","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"Continued linear analysis and design can be performed using ControlSystemsBase.jl. We create ControlSystemsBase.StateSpace objects using","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"using ControlSystemsBase, Plots\nS = ss(matrices_S...)\nT = ss(matrices_T...)\nbodeplot([S, T], lab = [\"S\" \"\" \"T\" \"\"], plot_title = \"Bode plot of sensitivity functions\",\n margin = 5Plots.mm)","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"The sensitivity functions obtained this way should be equivalent to the ones obtained with the code below","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"using ControlSystemsBase\nP = tf(1.0, [1, 1]) |> ss\nC = 1 # Negative feedback assumed in ControlSystems\nS = sensitivity(P, C) # or feedback(1, P*C)\nT = comp_sensitivity(P, C) # or feedback(P*C)","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"We may also derive the loop-transfer function L(s) = P(s)C(s) using","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"matrices_L = get_looptransfer(sys, :plant_output)[1]\nL = ss(matrices_L...)","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"which is equivalent to the following with ControlSystems","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"L = P * (-C) # Add the minus sign to build the negative feedback into the controller","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"To obtain the transfer function between two analysis points, we call linearize","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"using ModelingToolkit # hide\nmatrices_PS = linearize(sys, :plant_input, :plant_output)[1]","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"this particular transfer function should be equivalent to the linear system P(s)S(s), i.e., equivalent to","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"feedback(P, C)","category":"page"},{"location":"API/linear_analysis/#Obtaining-transfer-functions","page":"Linear Analysis","title":"Obtaining transfer functions","text":"","category":"section"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"A statespace system from ControlSystemsBase can be converted to a transfer function using the function tf:","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"tf(S)","category":"page"},{"location":"API/linear_analysis/#Gain-and-phase-margins","page":"Linear Analysis","title":"Gain and phase margins","text":"","category":"section"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"Further linear analysis can be performed using the analysis methods from ControlSystemsBase. For example, calculating the gain and phase margins of a system can be done using","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"margin(P)","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"(they are infinite for this system). A Nyquist plot can be produced using","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"nyquistplot(P)","category":"page"},{"location":"API/linear_analysis/#Index","page":"Linear Analysis","title":"Index","text":"","category":"section"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"Pages = [\"linear_analysis.md\"]","category":"page"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"Modules = [ModelingToolkitStandardLibrary.Blocks]\nPages = [\"Blocks/analysis_points.jl\"]\nOrder = [:function, :type]\nPrivate = false","category":"page"},{"location":"API/linear_analysis/#ModelingToolkitStandardLibrary.Blocks.get_comp_sensitivity","page":"Linear Analysis","title":"ModelingToolkitStandardLibrary.Blocks.get_comp_sensitivity","text":"get_comp_sensitivity(sys, ap::AnalysisPoint; kwargs)\nget_comp_sensitivity(sys, ap_name::Symbol; kwargs)\n\nCompute the complementary sensitivity function in analysis point ap. The complementary sensitivity function is obtained by introducing an infinitesimal perturbation d at the output of ap, linearizing the system and computing the transfer function between d and the input of ap.\n\ndanger: Experimental\nThe analysis-point interface is currently experimental and at any time subject to breaking changes not respecting semantic versioning.\n\nArguments:\n\nkwargs: Are sent to ModelingToolkit.linearize\n\nSee also get_sensitivity, get_looptransfer.\n\n\n\n\n\n","category":"function"},{"location":"API/linear_analysis/#ModelingToolkitStandardLibrary.Blocks.get_looptransfer","page":"Linear Analysis","title":"ModelingToolkitStandardLibrary.Blocks.get_looptransfer","text":"get_looptransfer(sys, ap::AnalysisPoint; kwargs)\nget_looptransfer(sys, ap_name::Symbol; kwargs)\n\nCompute the (linearized) loop-transfer function in analysis point ap, from ap.out to ap.in.\n\ninfo: Negative feedback\nFeedback loops often use negative feedback, and the computed loop-transfer function will in this case have the negative feedback included. Standard analysis tools often assume a loop-transfer function without the negative gain built in, and the result of this function may thus need negation before use.\n\ndanger: Experimental\nThe analysis-point interface is currently experimental and at any time subject to breaking changes not respecting semantic versioning.\n\nArguments:\n\nkwargs: Are sent to ModelingToolkit.linearize\n\nSee also get_sensitivity, get_comp_sensitivity, open_loop.\n\n\n\n\n\n","category":"function"},{"location":"API/linear_analysis/#ModelingToolkitStandardLibrary.Blocks.get_sensitivity","page":"Linear Analysis","title":"ModelingToolkitStandardLibrary.Blocks.get_sensitivity","text":"get_sensitivity(sys, ap::AnalysisPoint; kwargs)\nget_sensitivity(sys, ap_name::Symbol; kwargs)\n\nCompute the sensitivity function in analysis point ap. The sensitivity function is obtained by introducing an infinitesimal perturbation d at the input of ap, linearizing the system and computing the transfer function between d and the output of ap.\n\ndanger: Experimental\nThe analysis-point interface is currently experimental and at any time subject to breaking changes not respecting semantic versioning.\n\nArguments:\n\nkwargs: Are sent to ModelingToolkit.linearize\n\nSee also get_comp_sensitivity, get_looptransfer.\n\n\n\n\n\n","category":"function"},{"location":"API/linear_analysis/#ModelingToolkitStandardLibrary.Blocks.open_loop-Tuple{Any, Symbol}","page":"Linear Analysis","title":"ModelingToolkitStandardLibrary.Blocks.open_loop","text":"open_sys = open_loop(sys, ap::AnalysisPoint; kwargs)\nopen_sys = open_loop(sys, ap_name::Symbol; kwargs)\n\nOpen the loop at analysis point ap by breaking the connection through ap.\n\nopen_sys will have u ~ ap.out as input and y ~ ap.in as output.\n\ndanger: Experimental\nThe analysis-point interface is currently experimental and at any time subject to breaking changes not respecting semantic versioning.\n\nArguments:\n\nkwargs: Are sent to ModelingToolkit.linearize\n\nSee also get_sensitivity, get_comp_sensitivity, get_looptransfer.\n\n\n\n\n\n","category":"method"},{"location":"API/linear_analysis/#ModelingToolkitStandardLibrary.Blocks.AnalysisPoint-Tuple{Any, Any}","page":"Linear Analysis","title":"ModelingToolkitStandardLibrary.Blocks.AnalysisPoint","text":"AnalysisPoint(in, out, name::Symbol)\nAnalysisPoint(in, out; name::Symbol)\nAnalysisPoint(name::Symbol)\n\nCreate an AnalysisPoint for linear analysis. Analysis points can also be created automatically by calling\n\nconnect(in, :ap_name, out)\n\ndanger: Experimental\nThe analysis-point interface is currently experimental and at any time subject to breaking changes not respecting semantic versioning.\n\nArguments:\n\nin: A connector of type RealOutput.\nout: A connector of type RealInput.\nname: The name of the analysis point.\n\nSee also get_sensitivity, get_comp_sensitivity, get_looptransfer, open_loop\n\nExample\n\nusing ModelingToolkitStandardLibrary.Blocks\n@named P = FirstOrder(k = 1, T = 1)\n@named C = Gain(; k = -1)\nt = ModelingToolkit.get_iv(P)\neqs = [connect(P.output, C.input)\n connect(C.output, :plant_input, P.input)]\nsys = ODESystem(eqs, t, systems = [P, C], name = :feedback_system)\n\nmatrices_S, _ = get_sensitivity(sys, :plant_input) # Compute the matrices of a state-space representation of the (input) sensitivity function.\nmatrices_T, _ = get_comp_sensitivity(sys, :plant_input)\n\nContinued linear analysis and design can be performed using ControlSystemsBase.jl. Create ControlSystemsBase.StateSpace objects using\n\nusing ControlSystemsBase, Plots\nS = ss(matrices_S...)\nT = ss(matrices_T...)\nbodeplot([S, T], lab = [\"S\" \"T\"])\n\nThe sensitivity functions obtained this way should be equivalent to the ones obtained with the code below\n\nusing ControlSystemsBase\nP = tf(1.0, [1, 1])\nC = 1 # Negative feedback assumed in ControlSystems\nS = sensitivity(P, C) # or feedback(1, P*C)\nT = comp_sensitivity(P, C) # or feedback(P*C)\n\n\n\n\n\n","category":"method"},{"location":"API/linear_analysis/","page":"Linear Analysis","title":"Linear Analysis","text":"ModelingToolkit.linearize","category":"page"},{"location":"API/linear_analysis/#ModelingToolkit.linearize","page":"Linear Analysis","title":"ModelingToolkit.linearize","text":"(; A, B, C, D), simplified_sys = linearize(sys, inputs, outputs; t=0.0, op = Dict(), allow_input_derivatives = false, zero_dummy_der=false, kwargs...)\n(; A, B, C, D) = linearize(simplified_sys, lin_fun; t=0.0, op = Dict(), allow_input_derivatives = false, zero_dummy_der=false)\n\nLinearize sys between inputs and outputs, both vectors of variables. Return a NamedTuple with the matrices of a linear statespace representation on the form\n\nbeginaligned\nx = Ax + Bu\ny = Cx + Du\nendaligned\n\nThe first signature automatically calls linearization_function internally, while the second signature expects the outputs of linearization_function as input.\n\nop denotes the operating point around which to linearize. If none is provided, the default values of sys are used.\n\nIf allow_input_derivatives = false, an error will be thrown if input derivatives (u) appear as inputs in the linearized equations. If input derivatives are allowed, the returned B matrix will be of double width, corresponding to the input [u; u̇].\n\nzero_dummy_der can be set to automatically set the operating point to zero for all dummy derivatives.\n\nSee also linearization_function which provides a lower-level interface, linearize_symbolic and ModelingToolkit.reorder_unknowns.\n\nSee extended help for an example.\n\nThe implementation and notation follows that of \"Linear Analysis Approach for Modelica Models\", Allain et al. 2009\n\nExtended help\n\nThis example builds the following feedback interconnection and linearizes it from the input of F to the output of P.\n\n\n r ┌─────┐ ┌─────┐ ┌─────┐\n───►│ ├──────►│ │ u │ │\n │ F │ │ C ├────►│ P │ y\n └─────┘ ┌►│ │ │ ├─┬─►\n │ └─────┘ └─────┘ │\n │ │\n └─────────────────────┘\n\nusing ModelingToolkit\n@variables t\nfunction plant(; name)\n @variables x(t) = 1\n @variables u(t)=0 y(t)=0\n D = Differential(t)\n eqs = [D(x) ~ -x + u\n y ~ x]\n ODESystem(eqs, t; name = name)\nend\n\nfunction ref_filt(; name)\n @variables x(t)=0 y(t)=0\n @variables u(t)=0 [input = true]\n D = Differential(t)\n eqs = [D(x) ~ -2 * x + u\n y ~ x]\n ODESystem(eqs, t, name = name)\nend\n\nfunction controller(kp; name)\n @variables y(t)=0 r(t)=0 u(t)=0\n @parameters kp = kp\n eqs = [\n u ~ kp * (r - y),\n ]\n ODESystem(eqs, t; name = name)\nend\n\n@named f = ref_filt()\n@named c = controller(1)\n@named p = plant()\n\nconnections = [f.y ~ c.r # filtered reference to controller reference\n c.u ~ p.u # controller output to plant input\n p.y ~ c.y]\n\n@named cl = ODESystem(connections, t, systems = [f, c, p])\n\nlsys0, ssys = linearize(cl, [f.u], [p.x])\ndesired_order = [f.x, p.x]\nlsys = ModelingToolkit.reorder_unknowns(lsys0, unknowns(ssys), desired_order)\n\n@assert lsys.A == [-2 0; 1 -2]\n@assert lsys.B == [1; 0;;]\n@assert lsys.C == [0 1]\n@assert lsys.D[] == 0\n\n## Symbolic linearization\nlsys_sym, _ = ModelingToolkit.linearize_symbolic(cl, [f.u], [p.x])\n\n@assert substitute(lsys_sym.A, ModelingToolkit.defaults(cl)) == lsys.A\n\n\n\n\n\nModelingToolkit.linearize(sys, input_name::Symbol, output_name; kwargs...)\n\nLinearize a system between two analysis points. To get a loop-transfer function, see get_looptransfer.\n\nThe output is allowed to be either an analysis-point name, or a vector of symbolic variables like the standard interface to linearize. The input must be an analysis-point name.\n\n\n\n\n\n","category":"function"},{"location":"tutorials/input_component/#Running-Models-with-Discrete-Data","page":"SampledData Component","title":"Running Models with Discrete Data","text":"","category":"section"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"There are 3 ways to include data as part of a model.","category":"page"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"using ModelingToolkitStandardLibrary.Blocks.TimeVaryingFunction\nusing a custom component with external data\nusing ModelingToolkitStandardLibrary.Blocks.SampledData","category":"page"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"This tutorial demonstrate each case and explain the pros and cons of each.","category":"page"},{"location":"tutorials/input_component/#TimeVaryingFunction-Component","page":"SampledData Component","title":"TimeVaryingFunction Component","text":"","category":"section"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"The ModelingToolkitStandardLibrary.Blocks.TimeVaryingFunction component is easy to use and is performant. However the data is locked to the ODESystem and can only be changed by building a new ODESystem. Therefore, running a batch of data would not be efficient. Below is an example of how to use the TimeVaryingFunction with DataInterpolations to build the function from sampled discrete data.","category":"page"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"using ModelingToolkit\nusing ModelingToolkit: t_nounits as t, D_nounits as D\nusing ModelingToolkitStandardLibrary.Blocks\nusing DataInterpolations\nusing OrdinaryDiffEq\n\nfunction System(f; name)\n src = TimeVaryingFunction(f)\n\n vars = @variables f(t)=0 x(t)=0 dx(t)=0 ddx(t)=0\n pars = @parameters m=10 k=1000 d=1\n\n eqs = [f ~ src.output.u\n ddx * 10 ~ k * x + d * dx + f\n D(x) ~ dx\n D(dx) ~ ddx]\n\n ODESystem(eqs, t, vars, pars; systems = [src], name)\nend\n\ndt = 4e-4\ntime = 0:dt:0.1\ndata = sin.(2 * pi * time * 100) # example data\n\nf = LinearInterpolation(data, time)\n\n@named system = System(f)\nsys = structural_simplify(system)\nprob = ODEProblem(sys, [], (0, time[end]))\nsol = solve(prob, ImplicitEuler())","category":"page"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"If we want to run a new data set, this requires building a new LinearInterpolation and ODESystem followed by running structural_simplify, all of which takes time. Therefore, to run several pieces of data it's better to re-use an ODESystem. The next couple methods will demonstrate how to do this.","category":"page"},{"location":"tutorials/input_component/#Custom-Component-with-External-Data","page":"SampledData Component","title":"Custom Component with External Data","text":"","category":"section"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"The below code shows how to include data using a Ref and registered get_sampled_data function. This example uses a very basic function which requires non-adaptive solving and sampled data. As can be seen, the data can easily be set and changed before solving.","category":"page"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"const rdata = Ref{Vector{Float64}}()\n\n# Data Sets\ndata1 = sin.(2 * pi * time * 100)\ndata2 = cos.(2 * pi * time * 50)\n\nfunction get_sampled_data(t)\n i = floor(Int, t / dt) + 1\n x = rdata[][i]\n\n return x\nend\n\nSymbolics.@register_symbolic get_sampled_data(t)\n\nfunction System(; name)\n vars = @variables f(t)=0 x(t)=0 dx(t)=0 ddx(t)=0\n pars = @parameters m=10 k=1000 d=1\n\n eqs = [f ~ get_sampled_data(t)\n ddx * 10 ~ k * x + d * dx + f\n D(x) ~ dx\n D(dx) ~ ddx]\n\n ODESystem(eqs, t, vars, pars; name)\nend\n\n@named system = System()\nsys = structural_simplify(system)\nprob = ODEProblem(sys, [], (0, time[end]))\n\nrdata[] = data1\nsol1 = solve(prob, ImplicitEuler(); dt, adaptive = false)\nddx1 = sol1[sys.ddx]\n\nrdata[] = data2\nsol2 = solve(prob, ImplicitEuler(); dt, adaptive = false)\nddx2 = sol2[sys.ddx]","category":"page"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"The drawback of this method is that the solution observables can be linked to the data Ref, which means that if the data changes then the observables are no longer valid. In this case ddx is an observable that is derived directly from the data. Therefore, sol1[sys.ddx] is no longer correct after the data is changed for sol2.","category":"page"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"# the following test will fail\n@test all(ddx1 .== sol1[sys.ddx]) #returns false","category":"page"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"Additional code could be added to resolve this issue, for example by using a Ref{Dict} that could link a parameter of the model to the data source. This would also be necessary for parallel processing.","category":"page"},{"location":"tutorials/input_component/#SampledData-Component","page":"SampledData Component","title":"SampledData Component","text":"","category":"section"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"To resolve the issues presented above, the ModelingToolkitStandardLibrary.Blocks.SampledData component can be used which allows for a resusable ODESystem and self contained data which ensures a solution which remains valid for it's lifetime. Now it's possible to also parallelize the call to solve().","category":"page"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"function System(; name)\n src = SampledData(Float64)\n\n vars = @variables f(t)=0 x(t)=0 dx(t)=0 ddx(t)=0\n pars = @parameters m=10 k=1000 d=1\n\n eqs = [f ~ src.output.u\n ddx * 10 ~ k * x + d * dx + f\n D(x) ~ dx\n D(dx) ~ ddx]\n\n ODESystem(eqs, t, vars, pars; systems = [src], name)\nend\n\n@named system = System()\nsys = structural_simplify(system)\ns = complete(system)\nprob = ODEProblem(sys, [], (0, time[end]); tofloat = false)\ndefs = ModelingToolkit.defaults(sys)\n\nfunction get_prob(data)\n defs[s.src.buffer] = Parameter(data, dt)\n # ensure p is a uniform type of Vector{Parameter{Float64}} (converting from Vector{Any})\n p = Parameter.(ModelingToolkit.varmap_to_vars(defs, parameters(sys); tofloat = false))\n remake(prob; p)\nend\n\nprob1 = get_prob(data1)\nprob2 = get_prob(data2)\n\nsol1 = Ref{ODESolution}()\nsol2 = Ref{ODESolution}()\n@sync begin\n @async sol1[] = solve(prob1, ImplicitEuler())\n @async sol2[] = solve(prob2, ImplicitEuler())\nend","category":"page"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"Note, in the above example, we can build the system with an empty SampledData component, only setting the expected data type: @named src = SampledData(Float64). It's also possible to initialize the component with real sampled data: @named src = SampledData(data, dt). Additionally note that before running an ODEProblem using the SampledData component, one must be careful about the parameter vector Type. The SampledData component contains a buffer parameter of type Parameter, therefore we must generate the problem using tofloat=false. This will initially give a parameter vector of type Vector{Any} with a mix of numbers and Parameter type. We can convert the vector to a uniform Parameter type by running p = Parameter.(p). This will wrap all the single values in a Parameter which will be mathematically equivalent to a Number.","category":"page"},{"location":"#ModelingToolkitStandardLibrary.jl","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"ModelingToolkitStandardLibrary.jl","text":"","category":"section"},{"location":"","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","text":"ModelingToolkitStandardLibrary.jl is a standard library for the ModelingToolkit acausal modeling system.","category":"page"},{"location":"#Installation","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"Installation","text":"","category":"section"},{"location":"","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","text":"To install ModelingToolkitStandardLibrary.jl, use the Julia package manager:","category":"page"},{"location":"","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","text":"using Pkg\nPkg.add(\"ModelingToolkitStandardLibrary\")","category":"page"},{"location":"#Tutorials","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"Tutorials","text":"","category":"section"},{"location":"","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","text":"RC Circuit\nCustom Component\nThermal Model\nDC Motor with PI-controller","category":"page"},{"location":"#Libraries","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"Libraries","text":"","category":"section"},{"location":"","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","text":"The following are the constituent libraries of the ModelingToolkit Standard Library.","category":"page"},{"location":"","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","text":"Basic Blocks\nMechanical Components\nElectrical Components\nMagnetic Components\nThermal Components\nHydraulic Components","category":"page"},{"location":"#Contributing","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"Contributing","text":"","category":"section"},{"location":"","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","text":"Please refer to the SciML ColPrac: Contributor's Guide on Collaborative Practices for Community Packages for guidance on PRs, issues, and other matters relating to contributing to SciML.\nSee the SciML Style Guide for common coding practices and other style decisions.\nThere are a few community forums:\nThe #diffeq-bridged and #sciml-bridged channels in the Julia Slack\nThe #diffeq-bridged and #sciml-bridged channels in the Julia Zulip\nOn the Julia Discourse forums\nSee also SciML Community page","category":"page"},{"location":"#Reproducibility","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"Reproducibility","text":"","category":"section"},{"location":"","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","text":"
The documentation of this SciML package was built using these direct dependencies,","category":"page"},{"location":"","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","text":"using Pkg # hide\nPkg.status() # hide","category":"page"},{"location":"","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","text":"
","category":"page"},{"location":"","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","text":"
and using this machine and Julia version.","category":"page"},{"location":"","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","text":"using InteractiveUtils # hide\nversioninfo() # hide","category":"page"},{"location":"","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","text":"
","category":"page"},{"location":"","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","text":"
A more complete overview of all dependencies and their versions is also provided.","category":"page"},{"location":"","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","text":"using Pkg # hide\nPkg.status(; mode = PKGMODE_MANIFEST) # hide","category":"page"},{"location":"","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","text":"
","category":"page"},{"location":"","page":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","title":"ModelingToolkitStandardLibrary.jl: A Standard Library for ModelingToolkit","text":"using TOML\nusing Markdown\nversion = TOML.parse(read(\"../../Project.toml\", String))[\"version\"]\nname = TOML.parse(read(\"../../Project.toml\", String))[\"name\"]\nlink_manifest = \"https://github.com/SciML/\" * name * \".jl/tree/gh-pages/v\" * version *\n \"/assets/Manifest.toml\"\nlink_project = \"https://github.com/SciML/\" * name * \".jl/tree/gh-pages/v\" * version *\n \"/assets/Project.toml\"\nMarkdown.parse(\"\"\"You can also download the\n[manifest]($link_manifest)\nfile and the\n[project]($link_project)\nfile.\n\"\"\")","category":"page"}] } diff --git a/dev/tutorials/custom_component/index.html b/dev/tutorials/custom_component/index.html index 4227962e8..0bba9d1c9 100644 --- a/dev/tutorials/custom_component/index.html +++ b/dev/tutorials/custom_component/index.html @@ -55,4 +55,4 @@ Plots.plot(sol; idxs = [C1.v, C2.v, L.i], labels = ["C1 Voltage in V" "C2 Voltage in V" "Inductor Current in A"]) -Plots.savefig("chua.png")

Time series plot of C1.v, C2.v and L.i

Phase plane plot of C1.v and C2.v

+Plots.savefig("chua.png")

Time series plot of C1.v, C2.v and L.i

Phase plane plot of C1.v and C2.v

diff --git a/dev/tutorials/dc_motor_pi/d83c12b9.svg b/dev/tutorials/dc_motor_pi/4778243c.svg similarity index 86% rename from dev/tutorials/dc_motor_pi/d83c12b9.svg rename to dev/tutorials/dc_motor_pi/4778243c.svg index 5309c81e5..cd6ee430c 100644 --- a/dev/tutorials/dc_motor_pi/d83c12b9.svg +++ b/dev/tutorials/dc_motor_pi/4778243c.svg @@ -1,54 +1,54 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + diff --git a/dev/tutorials/dc_motor_pi/cc6ffa09.svg b/dev/tutorials/dc_motor_pi/87508734.svg similarity index 85% rename from dev/tutorials/dc_motor_pi/cc6ffa09.svg rename to dev/tutorials/dc_motor_pi/87508734.svg index 225ecab79..dbbf366ff 100644 --- a/dev/tutorials/dc_motor_pi/cc6ffa09.svg +++ b/dev/tutorials/dc_motor_pi/87508734.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/tutorials/dc_motor_pi/679f584b.svg b/dev/tutorials/dc_motor_pi/d0c422d0.svg similarity index 85% rename from dev/tutorials/dc_motor_pi/679f584b.svg rename to dev/tutorials/dc_motor_pi/d0c422d0.svg index 44f815c37..93ba6bfa7 100644 --- a/dev/tutorials/dc_motor_pi/679f584b.svg +++ b/dev/tutorials/dc_motor_pi/d0c422d0.svg @@ -1,83 +1,83 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/tutorials/dc_motor_pi/index.html b/dev/tutorials/dc_motor_pi/index.html index 107a494d1..4409ad75a 100644 --- a/dev/tutorials/dc_motor_pi/index.html +++ b/dev/tutorials/dc_motor_pi/index.html @@ -58,25 +58,28 @@ friction, speed_sensor ])

Now the model can be simulated. Typical rotational mechanical systems are described via DAE (differential algebraic equations), however in this case, ModelingToolkit can simplify the model enough so that it can be represented as a system of ODEs (ordinary differential equations).

sys = structural_simplify(model)
-prob = ODEProblem(sys, [], (0, 6.0))
+prob = ODEProblem(sys, unknowns(sys) .=> 0.0, (0, 6.0))
 sol = solve(prob, Rodas4())
 
 p1 = Plots.plot(sol.t, sol[inertia.w], ylabel = "Angular Vel. in rad/s",
     label = "Measurement", title = "DC Motor with Speed Controller")
 Plots.plot!(sol.t, sol[ref.output.u], label = "Reference")
 p2 = Plots.plot(sol.t, sol[load.tau.u], ylabel = "Disturbance in Nm", label = "")
-Plots.plot(p1, p2, layout = (2, 1))
Example block output

Closed-loop analysis

When implementing and tuning a control system in simulation, it is a good practice to analyze the closed-loop properties and verify robustness of the closed-loop with respect to, e.g., modeling errors. To facilitate this, we added two analysis points to the set of connections above, more specifically, we added the analysis points named :y and :u to the connections (for more details on analysis points, see Linear Analysis)

connect(speed_sensor.w, :y, feedback.input2)
+Plots.plot(p1, p2, layout = (2, 1))
Example block output

Closed-loop analysis

When implementing and tuning a control system in simulation, it is a good practice to analyze the closed-loop properties and verify robustness of the closed-loop with respect to, e.g., modeling errors. To facilitate this, we added two analysis points to the set of connections above, more specifically, we added the analysis points named :y and :u to the connections (for more details on analysis points, see Linear Analysis)

connect(speed_sensor.w, :y, feedback.input2)
 connect(pi_controller.ctr_output, :u, source.V)

one at the plant output (:y) and one at the plant input (:u). We may use these analysis points to calculate, e.g., sensitivity functions, illustrated below. Here, we calculate the sensitivity function $S(s)$ and the complimentary sensitivity function $T(s) = I - S(s)$, defined as

\[\begin{aligned} S(s) &= \dfrac{1}{I + P(s)C(s)} \\ T(s) &= \dfrac{P(s)C(s)}{I + P(s)C(s)} \end{aligned}\]

using ControlSystemsBase
-matrices_S, simplified_sys = Blocks.get_sensitivity(model, :y)
+matrices_S, simplified_sys = Blocks.get_sensitivity(
+    model, :y, op = Dict(unknowns(sys) .=> 0.0))
 So = ss(matrices_S...) |> minreal # The output-sensitivity function as a StateSpace system
-matrices_T, simplified_sys = Blocks.get_comp_sensitivity(model, :y)
+matrices_T, simplified_sys = Blocks.get_comp_sensitivity(
+    model, :y, op = Dict(inertia.phi => 0.0, inertia.w => 0.0))
 To = ss(matrices_T...)# The output complementary sensitivity function as a StateSpace system
 bodeplot([So, To], label = ["S" "T"], plot_title = "Sensitivity functions",
-    plotphase = false)
Example block output

Similarly, we may compute the loop-transfer function and plot its Nyquist curve

matrices_L, simplified_sys = Blocks.get_looptransfer(model, :y)
+    plotphase = false)
Example block output

Similarly, we may compute the loop-transfer function and plot its Nyquist curve

matrices_L, simplified_sys = Blocks.get_looptransfer(
+    model, :y, op = Dict(unknowns(sys) .=> 0.0))
 L = -ss(matrices_L...) # The loop-transfer function as a StateSpace system. The negative sign is to negate the built-in negative feedback
 Ms, ωMs = hinfnorm(So) # Compute the peak of the sensitivity function to draw a circle in the Nyquist plot
 nyquistplot(L, label = "\$L(s)\$", ylims = (-2.5, 0.5), xlims = (-1.2, 0.1),
-    Ms_circles = Ms)
Example block output + Ms_circles = Ms)Example block output diff --git a/dev/tutorials/input_component/index.html b/dev/tutorials/input_component/index.html index 7a30157a5..250f5e926 100644 --- a/dev/tutorials/input_component/index.html +++ b/dev/tutorials/input_component/index.html @@ -101,4 +101,4 @@ @sync begin @async sol1[] = solve(prob1, ImplicitEuler()) @async sol2[] = solve(prob2, ImplicitEuler()) -end

Note, in the above example, we can build the system with an empty SampledData component, only setting the expected data type: @named src = SampledData(Float64). It's also possible to initialize the component with real sampled data: @named src = SampledData(data, dt). Additionally note that before running an ODEProblem using the SampledData component, one must be careful about the parameter vector Type. The SampledData component contains a buffer parameter of type Parameter, therefore we must generate the problem using tofloat=false. This will initially give a parameter vector of type Vector{Any} with a mix of numbers and Parameter type. We can convert the vector to a uniform Parameter type by running p = Parameter.(p). This will wrap all the single values in a Parameter which will be mathematically equivalent to a Number.

+end

Note, in the above example, we can build the system with an empty SampledData component, only setting the expected data type: @named src = SampledData(Float64). It's also possible to initialize the component with real sampled data: @named src = SampledData(data, dt). Additionally note that before running an ODEProblem using the SampledData component, one must be careful about the parameter vector Type. The SampledData component contains a buffer parameter of type Parameter, therefore we must generate the problem using tofloat=false. This will initially give a parameter vector of type Vector{Any} with a mix of numbers and Parameter type. We can convert the vector to a uniform Parameter type by running p = Parameter.(p). This will wrap all the single values in a Parameter which will be mathematically equivalent to a Number.

diff --git a/dev/tutorials/rc_circuit/index.html b/dev/tutorials/rc_circuit/index.html index cd8e0b1e8..48e7a4637 100644 --- a/dev/tutorials/rc_circuit/index.html +++ b/dev/tutorials/rc_circuit/index.html @@ -26,4 +26,4 @@ plot(sol, idxs = [capacitor.v, resistor.i], title = "RC Circuit Demonstration", labels = ["Capacitor Voltage" "Resistor Current"]) -savefig("plot.png");

+savefig("plot.png");

diff --git a/dev/tutorials/thermal_model/index.html b/dev/tutorials/thermal_model/index.html index 5c4144953..bd961b785 100644 --- a/dev/tutorials/thermal_model/index.html +++ b/dev/tutorials/thermal_model/index.html @@ -28,4 +28,4 @@ plot(title = "Thermal Conduction Demonstration") plot!(sol, idxs = [mass1.T, mass2.T], labels = ["Mass 1 Temperature" "Mass 2 Temperature"]) plot!(sol.t, T_final_K, label = "Steady-State Temperature") -savefig("thermal_plot.png");

Plot of Temperatures

+savefig("thermal_plot.png");

Plot of Temperatures