From 1668605f0f158ee09e4ce86de1f60b36e8021038 Mon Sep 17 00:00:00 2001 From: "Documenter.jl" Date: Fri, 22 Nov 2024 01:23:53 +0000 Subject: [PATCH] build based on 1827d63 --- dev/.documenter-siteinfo.json | 2 +- dev/API/blocks/index.html | 18 +- dev/API/electrical/index.html | 8 +- dev/API/hydraulic/index.html | 8 +- .../{b188e800.svg => 88cc5538.svg} | 72 ++--- .../{d87aafa7.svg => e0917cd7.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 | 178 ++++++----- dev/assets/documenter.js | 302 ++++++++++-------- .../{bdf865b5.svg => 2ab38419.svg} | 84 ++--- .../{598e6130.svg => 538e538d.svg} | 188 +++++------ .../{c3c8e7ed.svg => 8c9910fa.svg} | 128 ++++---- .../{a299a362.svg => b9df26e7.svg} | 128 ++++---- .../{654e8212.svg => cccdf3c5.svg} | 68 ++-- .../{0125b4a2.svg => e472509d.svg} | 56 ++-- dev/connectors/connections/index.html | 12 +- dev/connectors/sign_convention/index.html | 2 +- dev/index.html | 68 ++-- dev/objects.inv | Bin 3188 -> 3203 bytes dev/search_index.js | 2 +- .../{ddc47e41.svg => 83c5f194.svg} | 76 ++--- .../{e01d3e9d.svg => bad07661.svg} | 64 ++-- dev/tutorials/custom_component/index.html | 4 +- .../{427b02ca.svg => 75b0ce2f.svg} | 128 ++++---- .../{681e5378.svg => 82eaf873.svg} | 82 ++--- .../{1f6b1c64.svg => c429a4a0.svg} | 72 ++--- dev/tutorials/dc_motor_pi/index.html | 6 +- .../{3dfbedad.svg => 65591bac.svg} | 68 ++-- .../{f488a43f.svg => 76834609.svg} | 68 ++-- .../{0143378c.svg => f717a7f7.svg} | 68 ++-- dev/tutorials/input_component/index.html | 10 +- .../rc_circuit/{ea65d569.svg => 6fed4423.svg} | 72 ++--- dev/tutorials/rc_circuit/index.html | 2 +- .../{0d01ce33.svg => dfb30897.svg} | 76 ++--- dev/tutorials/thermal_model/index.html | 2 +- 38 files changed, 1150 insertions(+), 1106 deletions(-) rename dev/API/linear_analysis/{b188e800.svg => 88cc5538.svg} (84%) rename dev/API/linear_analysis/{d87aafa7.svg => e0917cd7.svg} (87%) rename dev/connectors/connections/{bdf865b5.svg => 2ab38419.svg} (91%) rename dev/connectors/connections/{598e6130.svg => 538e538d.svg} (89%) rename dev/connectors/connections/{c3c8e7ed.svg => 8c9910fa.svg} (89%) rename dev/connectors/connections/{a299a362.svg => b9df26e7.svg} (89%) rename dev/connectors/connections/{654e8212.svg => cccdf3c5.svg} (92%) rename dev/connectors/connections/{0125b4a2.svg => e472509d.svg} (84%) rename dev/tutorials/custom_component/{ddc47e41.svg => 83c5f194.svg} (99%) rename dev/tutorials/custom_component/{e01d3e9d.svg => bad07661.svg} (99%) rename dev/tutorials/dc_motor_pi/{427b02ca.svg => 75b0ce2f.svg} (85%) rename dev/tutorials/dc_motor_pi/{681e5378.svg => 82eaf873.svg} (85%) rename dev/tutorials/dc_motor_pi/{1f6b1c64.svg => c429a4a0.svg} (86%) rename dev/tutorials/input_component/{3dfbedad.svg => 65591bac.svg} (91%) rename dev/tutorials/input_component/{f488a43f.svg => 76834609.svg} (91%) rename dev/tutorials/input_component/{0143378c.svg => f717a7f7.svg} (91%) rename dev/tutorials/rc_circuit/{ea65d569.svg => 6fed4423.svg} (91%) rename dev/tutorials/thermal_model/{0d01ce33.svg => dfb30897.svg} (91%) diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index 3bd25c4b1..ba2570300 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.11.1","generation_timestamp":"2024-11-18T07:11:01","documenter_version":"1.7.0"}} \ No newline at end of file +{"documenter":{"julia_version":"1.11.1","generation_timestamp":"2024-11-22T01:23:44","documenter_version":"1.8.0"}} \ No newline at end of file diff --git a/dev/API/blocks/index.html b/dev/API/blocks/index.html index 904a4e4f2..8692c52e9 100644 --- a/dev/API/blocks/index.html +++ b/dev/API/blocks/index.html @@ -1,22 +1,22 @@ -Basic Blocks · ModelingToolkitStandardLibrary.jl

ModelingToolkitStandardLibrary: Blocks

Index

Utility Blocks

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
ModelingToolkitStandardLibrary.Blocks.MIMOFunction
MIMO(; name, nin = 1, nout = 1, u_start = zeros(nin), y_start = zeros(nout))

Base class for a multiple input multiple output (MIMO) continuous system block.

Parameters:

  • nin: Input dimension
  • nout: Output dimension
  • 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▲
+Basic Blocks · ModelingToolkitStandardLibrary.jl

ModelingToolkitStandardLibrary: Blocks

Index

Utility Blocks

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
ModelingToolkitStandardLibrary.Blocks.MIMOFunction
MIMO(; name, nin = 1, nout = 1, u_start = zeros(nin), y_start = zeros(nout))

Base class for a multiple input multiple output (MIMO) continuous system block.

Parameters:

  • nin: Input dimension
  • nout: Output dimension
  • 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.SlewRateLimiterFunction
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  
+  /     │

Parameters:

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

Connectors:

  • input
  • output
source
ModelingToolkitStandardLibrary.Blocks.SlewRateLimiterFunction
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
+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} @@ -25,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 1225b7bbe..361c95f32 100644 --- a/dev/API/electrical/index.html +++ b/dev/API/electrical/index.html @@ -1,2 +1,8 @@ -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
ModelingToolkitStandardLibrary.Electrical.DiodeConstant
    Diode(; name, Is = 1e-6, n = 1, T = 300.15)

Ideal diode based on the Shockley diode equation.

States

- See [OnePort](@ref)

Connectors

- `p` Positive pin
+- `n` Negative pin

Parameters

- `Is`: [`A`] Saturation current
+- `n`: Ideality factor
+- `T`: [K] Ambient temperature
source
ModelingToolkitStandardLibrary.Electrical.HeatingDiodeConstant
HeatingDiode(; name, Is = 1e-6, n = 1)

Temperature dependent diode based on the Shockley diode equation.

States

- See [OnePort](@ref)

Connectors

- `p` Positive pin
+- `n` Negative pin
+- `port` [HeatPort](@ref) Heat port to model the temperature dependency

Parameters:

- `Is`: [`A`] Saturation current
+- `n`: Ideality factor
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 fd56a32d8..c9a5787e5 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.OpenFunction
Open(; p_int, name)

Provides an "open" boundary condition for a hydraulic port such that mass flow dm is non-zero. This is opposite from an un-connected hydraulic port or the Cap boundary component which sets the mass flow dm to zero.

Parameters:

  • p_int: [Pa] initial pressure (set by p_int argument)

Connectors:

  • port: hydraulic port
source
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.TubeBaseFunction
TubeBase(add_inertia = true; 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:

  • 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; 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:

  • 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.FlowDividerFunction
FlowDivider(;p_int, n, name)

Reduces the flow from port_a to port_b by n. Useful for modeling parallel tubes efficiently by placing a FlowDivider on each end of a tube.

Parameters:

  • p_int: [Pa] initial pressure
  • n: divide flow from port_a to port_b by n

Connectors:

  • port_a: full flow hydraulic port
  • port_b: part flow hydraulic port
source
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.ValveFunction
Valve(reversible = false; p_a_int, p_b_int, area_int, Cd, Cd_reverse = Cd, minimum_area = 0, name)

Valve with area input and discharge coefficient Cd defined by https://en.wikipedia.org/wiki/Dischargecoefficient. The `Cdreverse` parameter allows for directional flow restriction, making it possible to define a check valve.

Parameters:

  • p_a_int: [Pa] initial pressure for port_a
  • p_b_int: [Pa] initial pressure for port_b
  • area_int: [m^2] initial valve opening
  • Cd: discharge coefficient flowing from a → b
  • Cd_reverse: discharge coefficient flowing from b → a
  • minimum_area: when reversible = false applies a forced minimum area

Connectors:

  • port_a: hydraulic port
  • port_b: hydraulic port
  • area: real input setting the valve area. When reversible = true, negative input reverses flow direction, otherwise a floor of minimum_area is enforced.
source
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.VolumeFunction
Volume(; x, dx=0, p, drho=0, dm=0, area, direction = +1, 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.OpenFunction
Open(; p_int, name)

Provides an "open" boundary condition for a hydraulic port such that mass flow dm is non-zero. This is opposite from an un-connected hydraulic port or the Cap boundary component which sets the mass flow dm to zero.

Parameters:

  • p_int: [Pa] initial pressure (set by p_int argument)

Connectors:

  • port: hydraulic port
source
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.TubeBaseFunction
TubeBase(add_inertia = true; 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:

  • 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; 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:

  • 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.FlowDividerFunction
FlowDivider(;p_int, n, name)

Reduces the flow from port_a to port_b by n. Useful for modeling parallel tubes efficiently by placing a FlowDivider on each end of a tube.

Parameters:

  • p_int: [Pa] initial pressure
  • n: divide flow from port_a to port_b by n

Connectors:

  • port_a: full flow hydraulic port
  • port_b: part flow hydraulic port
source
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.ValveFunction
Valve(reversible = false; p_a_int, p_b_int, area_int, Cd, Cd_reverse = Cd, minimum_area = 0, name)

Valve with area input and discharge coefficient Cd defined by https://en.wikipedia.org/wiki/Dischargecoefficient. The `Cdreverse` parameter allows for directional flow restriction, making it possible to define a check valve.

Parameters:

  • p_a_int: [Pa] initial pressure for port_a
  • p_b_int: [Pa] initial pressure for port_b
  • area_int: [m^2] initial valve opening
  • Cd: discharge coefficient flowing from a → b
  • Cd_reverse: discharge coefficient flowing from b → a
  • minimum_area: when reversible = false applies a forced minimum area

Connectors:

  • port_a: hydraulic port
  • port_b: hydraulic port
  • area: real input setting the valve area. When reversible = true, negative input reverses flow direction, otherwise a floor of minimum_area is enforced.
source
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.VolumeFunction
Volume(; x, dx=0, p, drho=0, dm=0, area, direction = +1, 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,7 +7,7 @@
      │                 │  ▼
      └─────────────────┤ ───
                        │
-                       └─► 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: [Pa] initial pressure

  • area: [m^2] moving wall area

  • x: [m] initial wall position

  • dx=0: [m/s] initial wall velocity

  • drho=0: [kg/m^3/s] initial density derivative

  • dm=0: [kg/s] initial flow

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

Connectors:

  • port: hydraulic port
  • flange: mechanical translational port

See also FixedVolume, DynamicVolume

source
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.DynamicVolumeFunction
DynamicVolume(N, add_inertia=true; p_int,  area, x_int = 0, x_max, x_min = 0, x_damp = x_min, direction = +1, perimeter = 2 * sqrt(area * pi), shape_factor = 64, head_factor = 1, Cd = 1e2, Cd_reverse = 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.

     ┌─────────────────┐ ───
+                       └─► 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: [Pa] initial pressure

  • area: [m^2] moving wall area

  • x: [m] initial wall position

  • dx=0: [m/s] initial wall velocity

  • drho=0: [kg/m^3/s] initial density derivative

  • dm=0: [kg/s] initial flow

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

Connectors:

  • port: hydraulic port
  • flange: mechanical translational port

See also FixedVolume, DynamicVolume

source
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.DynamicVolumeFunction
DynamicVolume(N, add_inertia=true; p_int,  area, x_int = 0, x_max, x_min = 0, x_damp = x_min, direction = +1, perimeter = 2 * sqrt(area * pi), shape_factor = 64, head_factor = 1, Cd = 1e2, Cd_reverse = 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
@@ -15,7 +15,7 @@
      │                 │  ▼
      └─────────────────┤ ───
                        │
-                       └─► 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

  • area: [m^2] moving wall area

  • 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
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.SpoolValveFunction
SpoolValve(reversible = false; p_a_int, p_b_int, x_int, Cd, d, name)

Spool valve with x valve opening input as mechanical flange port and d diameter of orifice. See Valve for more information.

Parameters:

  • p_a_int: [Pa] initial pressure for port_a
  • p_b_int: [Pa] initial pressure for port_b
  • x_int: [m] initial valve opening
  • d: [m] orifice diameter
  • Cd: discharge coefficient flowing from a → b

Connectors:

  • port_a: hydraulic port
  • port_b: hydraulic port
  • flange: mechanical translational port

See Valve for more information.

source
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.SpoolValve2WayFunction
SpoolValve2Way(reversible = false; p_s_int, p_a_int, p_b_int, p_r_int, m, g, x_int, Cd, d, name)

2-ways spool valve with 4 ports and spool mass. Fluid flow direction S → A and B → R when x is positive and S → B and A → R when x is negative.

Parameters:

  • p_s_int: [Pa] initial pressure for port_s
  • p_a_int: [Pa] initial pressure for port_a
  • p_b_int: [Pa] initial pressure for port_b
  • p_r_int: [Pa] initial pressure for port_r
  • m: [kg] mass of the spool
  • g: [m/s²] gravity field acting on the spool, positive value acts in the positive direction
  • x_int: [m] initial valve opening
  • d: [m] orifice diameter
  • Cd: discharge coefficient flowing from s → a and b → r

Connectors:

  • port_s: hydraulic port
  • port_a: hydraulic port
  • port_b: hydraulic port
  • port_r: hydraulic port
  • flange: mechanical translational port

See SpoolValve for more information.

source
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.ActuatorFunction
Actuator(N, add_inertia = true, reversible = false;
+                       └─► 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

  • area: [m^2] moving wall area

  • 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
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.SpoolValveFunction
SpoolValve(reversible = false; p_a_int, p_b_int, x_int, Cd, d, name)

Spool valve with x valve opening input as mechanical flange port and d diameter of orifice. See Valve for more information.

Parameters:

  • p_a_int: [Pa] initial pressure for port_a
  • p_b_int: [Pa] initial pressure for port_b
  • x_int: [m] initial valve opening
  • d: [m] orifice diameter
  • Cd: discharge coefficient flowing from a → b

Connectors:

  • port_a: hydraulic port
  • port_b: hydraulic port
  • flange: mechanical translational port

See Valve for more information.

source
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.SpoolValve2WayFunction
SpoolValve2Way(reversible = false; p_s_int, p_a_int, p_b_int, p_r_int, m, g, x_int, Cd, d, name)

2-ways spool valve with 4 ports and spool mass. Fluid flow direction S → A and B → R when x is positive and S → B and A → R when x is negative.

Parameters:

  • p_s_int: [Pa] initial pressure for port_s
  • p_a_int: [Pa] initial pressure for port_a
  • p_b_int: [Pa] initial pressure for port_b
  • p_r_int: [Pa] initial pressure for port_r
  • m: [kg] mass of the spool
  • g: [m/s²] gravity field acting on the spool, positive value acts in the positive direction
  • x_int: [m] initial valve opening
  • d: [m] orifice diameter
  • Cd: discharge coefficient flowing from s → a and b → r

Connectors:

  • port_s: hydraulic port
  • port_a: hydraulic port
  • port_b: hydraulic port
  • port_r: hydraulic port
  • flange: mechanical translational port

See SpoolValve for more information.

source
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.ActuatorFunction
Actuator(N, add_inertia = true, reversible = false;
     p_a_int,
     p_b_int,
     area_a,
@@ -37,4 +37,4 @@
     damping_volume_b = minimum_volume_b,
     Cd = 1e4,
     Cd_reverse = Cd,
-    name)

Actuator made of two DynamicVolumes connected in opposite direction with body mass attached.

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_a_int: [Pa] initial pressure for port_a
  • p_b_int: [Pa] initial pressure for port_b
  • area_a: [m^2] moving wall area of volume A
  • area_b: [m^2] moving wall area of volume B
  • length_a_int: [m] initial wall position for A
  • length_b_int: [m] initial wall position for b

mass

  • m: [kg] mass of the body
  • g: [m/s²] gravity field acting on the mass, positive value acts in the positive direction
  • x_int: [m] initial flange position

flow resistance

  • perimeter_a: [m] perimeter of the cross section A (needed only for non-circular volumes)
  • perimeter_b: [m] perimeter of the cross section B (needed only for non-circular volumes)
  • shape_factor_a: shape factor of A, see friction_factor function
  • shape_factor_b: shape factor of B, see friction_factor function
  • head_factor_a: effective length multiplier for A, used to account for addition friction from flow development and additional friction such as pipe bends, entrance/exit lossses, etc.
  • head_factor_b: effective length multiplier for B, 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

  • minimum_volume_a: [m^3] minimum volume A that shuts off flow and prevents negative volume.
  • minimum_volume_b: [m^3] minimum volume B that shuts off flow and prevents negative volume.
  • damping_volume_a: [m^3] volume of A that initiates a linear damping region before reaching full flow shut off. Helps provide a smooth end stop.
  • damping_volume_b: [m^3] volume of B that initiates a linear damping region before reaching full flow shut off. Helps provide a smooth end stop.
  • 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_a: hydraulic port
  • port_b: hydraulic port
  • flange: mechanical translational port
source

IsothermalCompressible Sources

+ name)

Actuator made of two DynamicVolumes connected in opposite direction with body mass attached.

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_a_int: [Pa] initial pressure for port_a
  • p_b_int: [Pa] initial pressure for port_b
  • area_a: [m^2] moving wall area of volume A
  • area_b: [m^2] moving wall area of volume B
  • length_a_int: [m] initial wall position for A
  • length_b_int: [m] initial wall position for b

mass

  • m: [kg] mass of the body
  • g: [m/s²] gravity field acting on the mass, positive value acts in the positive direction
  • x_int: [m] initial flange position

flow resistance

  • perimeter_a: [m] perimeter of the cross section A (needed only for non-circular volumes)
  • perimeter_b: [m] perimeter of the cross section B (needed only for non-circular volumes)
  • shape_factor_a: shape factor of A, see friction_factor function
  • shape_factor_b: shape factor of B, see friction_factor function
  • head_factor_a: effective length multiplier for A, used to account for addition friction from flow development and additional friction such as pipe bends, entrance/exit lossses, etc.
  • head_factor_b: effective length multiplier for B, 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

  • minimum_volume_a: [m^3] minimum volume A that shuts off flow and prevents negative volume.
  • minimum_volume_b: [m^3] minimum volume B that shuts off flow and prevents negative volume.
  • damping_volume_a: [m^3] volume of A that initiates a linear damping region before reaching full flow shut off. Helps provide a smooth end stop.
  • damping_volume_b: [m^3] volume of B that initiates a linear damping region before reaching full flow shut off. Helps provide a smooth end stop.
  • 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_a: hydraulic port
  • port_b: hydraulic port
  • flange: mechanical translational port
source

IsothermalCompressible Sources

diff --git a/dev/API/linear_analysis/b188e800.svg b/dev/API/linear_analysis/88cc5538.svg similarity index 84% rename from dev/API/linear_analysis/b188e800.svg rename to dev/API/linear_analysis/88cc5538.svg index 1e3905a48..3d0169eda 100644 --- a/dev/API/linear_analysis/b188e800.svg +++ b/dev/API/linear_analysis/88cc5538.svg @@ -1,50 +1,50 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/API/linear_analysis/d87aafa7.svg b/dev/API/linear_analysis/e0917cd7.svg similarity index 87% rename from dev/API/linear_analysis/d87aafa7.svg rename to dev/API/linear_analysis/e0917cd7.svg index 13d8f86f1..b47307f7b 100644 --- a/dev/API/linear_analysis/d87aafa7.svg +++ b/dev/API/linear_analysis/e0917cd7.svg @@ -1,78 +1,78 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - + - + diff --git a/dev/API/linear_analysis/index.html b/dev/API/linear_analysis/index.html index eecc41ade..65152859d 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 @@ -152,4 +152,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 63a27e30f..70775e32a 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 35f6dc917..4d4a525fd 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. 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
ModelingToolkitStandardLibrary.Mechanical.Rotational.PositionFunction
Position(; name, exact = false, f_crit = 50, use_support = false)

Forced movement of a flange according to a reference angle signal.

The input signal phi_ref defines the reference angle in [rad]. Flange is forced to move according to this reference motion relative to flange support. According to parameter exact (default = false), this is done in the following way:

  • exact=true: The reference angle is treated exactly. This is only possible if the input signal is defined by an analytical function that can be differentiated at least twice in order to compute the acceleration.
  • exact=false: The reference angle is filtered and the second derivative of the filtered curve is used to compute the reference acceleration of the flange. This second derivative is not computed by numerical differentiation but by an appropriate realization of the filter. For filtering, a second-order Bessel filter is used. The critical frequency (also called cut-off frequency) of the filter is defined via parameter f_crit in [Hz]. This value should be selected in such a way that it is higher than the essential low frequencies in the signal.

Connectors

  • flange::Flange: Flange to be moved
  • phi_ref::RealInput: Reference angle of flange with respect to support

Variables

  • phi(t): Rotation angle of flange with respect to support
  • w(t): If exact=false, Angular velocity of flange with respect to support
  • a(t): If exact=false, Angular acceleration of flange with respect to support

Parameters

  • exact: (structural) true/false exact treatment/filtering the input signal
  • f_crit: [Hz] if exact=false, Critical frequency of filter to filter input signal
source

Rotational Sensors

Translational Components

Translational Utils

Translational Core Components

ModelingToolkitStandardLibrary.Mechanical.Translational.MassFunction
Mass(; name, m, g = 0)

Sliding mass with inertia

Parameters:

  • m: [kg] mass of sliding body
  • g = 0: [m/s^2] [m/s²] gravity field acting on the mass, positive value acts in the positive direction

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
ModelingToolkitStandardLibrary.Mechanical.Rotational.PositionFunction
Position(; name, exact = false, f_crit = 50, use_support = false)

Forced movement of a flange according to a reference angle signal.

The input signal phi_ref defines the reference angle in [rad]. Flange is forced to move according to this reference motion relative to flange support. According to parameter exact (default = false), this is done in the following way:

  • exact=true: The reference angle is treated exactly. This is only possible if the input signal is defined by an analytical function that can be differentiated at least twice in order to compute the acceleration.
  • exact=false: The reference angle is filtered and the second derivative of the filtered curve is used to compute the reference acceleration of the flange. This second derivative is not computed by numerical differentiation but by an appropriate realization of the filter. For filtering, a second-order Bessel filter is used. The critical frequency (also called cut-off frequency) of the filter is defined via parameter f_crit in [Hz]. This value should be selected in such a way that it is higher than the essential low frequencies in the signal.

Connectors

  • flange::Flange: Flange to be moved
  • phi_ref::RealInput: Reference angle of flange with respect to support

Variables

  • phi(t): Rotation angle of flange with respect to support
  • w(t): If exact=false, Angular velocity of flange with respect to support
  • a(t): If exact=false, Angular acceleration of flange with respect to support

Parameters

  • exact: (structural) true/false exact treatment/filtering the input signal
  • f_crit: [Hz] if exact=false, Critical frequency of filter to filter input signal
source

Rotational Sensors

Translational Components

Translational Utils

Translational Core Components

ModelingToolkitStandardLibrary.Mechanical.Translational.MassFunction
Mass(; name, m, g = 0)

Sliding mass with inertia

Parameters:

  • m: [kg] mass of sliding body
  • g = 0: [m/s^2] [m/s²] gravity field acting on the mass, positive value acts in the positive direction

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 6ef0460df..0e8f42625 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 fbde75d17..695b98de1 100644 --- a/dev/assets/Manifest.toml +++ b/dev/assets/Manifest.toml @@ -5,13 +5,14 @@ manifest_format = "2.0" project_hash = "1f86b0f398028590ac9f5ec2389940898237f8ad" [[deps.ADTypes]] -git-tree-sha1 = "eea5d80188827b35333801ef97a40c2ed653b081" +git-tree-sha1 = "30bb95a372787af850addf28ac937f1be7b79173" uuid = "47edcb42-4c32-4615-8424-f2b9edc5f35b" -version = "1.9.0" -weakdeps = ["ChainRulesCore", "EnzymeCore"] +version = "1.10.0" +weakdeps = ["ChainRulesCore", "ConstructionBase", "EnzymeCore"] [deps.ADTypes.extensions] ADTypesChainRulesCoreExt = "ChainRulesCore" + ADTypesConstructionBaseExt = "ConstructionBase" ADTypesEnzymeCoreExt = "EnzymeCore" [[deps.ANSIColoredPrinters]] @@ -185,28 +186,28 @@ version = "5.12.0" ODEInterface = "54ca160b-1b9f-5127-a996-1867f4bc2a2c" [[deps.BoundaryValueDiffEqCore]] -deps = ["ADTypes", "Adapt", "ArrayInterface", "ConcreteStructs", "DiffEqBase", "ForwardDiff", "LineSearch", "LineSearches", "LinearAlgebra", "LinearSolve", "Logging", "NonlinearSolve", "PreallocationTools", "RecursiveArrayTools", "Reexport", "SciMLBase", "Setfield", "SparseArrays", "SparseDiffTools"] -git-tree-sha1 = "b4556571d1e80faa5f62ac8732a07bae0ee24dc6" +deps = ["ADTypes", "Adapt", "ArrayInterface", "ConcreteStructs", "DiffEqBase", "ForwardDiff", "LineSearch", "LinearAlgebra", "LinearSolve", "Logging", "NonlinearSolveFirstOrder", "PreallocationTools", "RecursiveArrayTools", "Reexport", "SciMLBase", "Setfield", "SparseArrays", "SparseDiffTools"] +git-tree-sha1 = "bdb7c5ebcbf36f6ef0ae3117219fe766177e829c" uuid = "56b672f2-a5fe-4263-ab2d-da677488eb3a" -version = "1.0.2" +version = "1.1.0" [[deps.BoundaryValueDiffEqFIRK]] -deps = ["ADTypes", "Adapt", "ArrayInterface", "BandedMatrices", "BoundaryValueDiffEqCore", "ConcreteStructs", "DiffEqBase", "FastAlmostBandedMatrices", "FastClosures", "ForwardDiff", "LineSearch", "LineSearches", "LinearAlgebra", "LinearSolve", "Logging", "NonlinearSolve", "PreallocationTools", "PrecompileTools", "Preferences", "RecursiveArrayTools", "Reexport", "SciMLBase", "Setfield", "SparseArrays", "SparseDiffTools"] -git-tree-sha1 = "35e1e7822d1c77d85ecf568606ca64d60fbd39de" +deps = ["ADTypes", "Adapt", "ArrayInterface", "BandedMatrices", "BoundaryValueDiffEqCore", "ConcreteStructs", "DiffEqBase", "FastAlmostBandedMatrices", "FastClosures", "ForwardDiff", "LinearAlgebra", "LinearSolve", "Logging", "PreallocationTools", "PrecompileTools", "Preferences", "RecursiveArrayTools", "Reexport", "SciMLBase", "Setfield", "SparseArrays", "SparseDiffTools"] +git-tree-sha1 = "7c7be9eeaa84cf46e30bd942ab30bcbaa2287510" uuid = "85d9eb09-370e-4000-bb32-543851f73618" -version = "1.0.2" +version = "1.1.0" [[deps.BoundaryValueDiffEqMIRK]] -deps = ["ADTypes", "Adapt", "ArrayInterface", "BandedMatrices", "BoundaryValueDiffEqCore", "ConcreteStructs", "DiffEqBase", "FastAlmostBandedMatrices", "FastClosures", "ForwardDiff", "LineSearch", "LineSearches", "LinearAlgebra", "LinearSolve", "Logging", "NonlinearSolve", "PreallocationTools", "PrecompileTools", "Preferences", "RecursiveArrayTools", "Reexport", "SciMLBase", "Setfield", "SparseArrays", "SparseDiffTools"] -git-tree-sha1 = "e1fa0dee3d8eca528ab96e765a52760fd7466ffa" +deps = ["ADTypes", "Adapt", "ArrayInterface", "BandedMatrices", "BoundaryValueDiffEqCore", "ConcreteStructs", "DiffEqBase", "FastAlmostBandedMatrices", "FastClosures", "ForwardDiff", "LinearAlgebra", "LinearSolve", "Logging", "PreallocationTools", "PrecompileTools", "Preferences", "RecursiveArrayTools", "Reexport", "SciMLBase", "Setfield", "SparseArrays", "SparseDiffTools"] +git-tree-sha1 = "b55ef58a2bdc6c0cc6947aa80e7e1d2ccc98ff00" uuid = "1a22d4ce-7765-49ea-b6f2-13c8438986a6" -version = "1.0.1" +version = "1.1.0" [[deps.BoundaryValueDiffEqShooting]] -deps = ["ADTypes", "Adapt", "ArrayInterface", "BandedMatrices", "BoundaryValueDiffEqCore", "ConcreteStructs", "DiffEqBase", "FastAlmostBandedMatrices", "FastClosures", "ForwardDiff", "LineSearch", "LineSearches", "LinearAlgebra", "LinearSolve", "Logging", "NonlinearSolve", "OrdinaryDiffEq", "PreallocationTools", "PrecompileTools", "Preferences", "RecursiveArrayTools", "Reexport", "SciMLBase", "Setfield", "SparseArrays", "SparseDiffTools"] -git-tree-sha1 = "fac04445ab0fdfa29b62d84e1af6b21334753a94" +deps = ["ADTypes", "Adapt", "ArrayInterface", "BandedMatrices", "BoundaryValueDiffEqCore", "ConcreteStructs", "DiffEqBase", "FastAlmostBandedMatrices", "FastClosures", "ForwardDiff", "LinearAlgebra", "LinearSolve", "Logging", "OrdinaryDiffEq", "PreallocationTools", "PrecompileTools", "Preferences", "RecursiveArrayTools", "Reexport", "SciMLBase", "Setfield", "SparseArrays", "SparseDiffTools"] +git-tree-sha1 = "90a2b6d928dbf3fd0adc63dce1a0f5fd39582448" uuid = "ed55bfe0-3725-4db6-871e-a1dc9f42a757" -version = "1.0.2" +version = "1.1.0" [[deps.Bzip2_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] @@ -237,6 +238,11 @@ git-tree-sha1 = "009060c9a6168704143100f36ab08f06c2af4642" uuid = "83423d85-b0ee-5818-9007-b63ccbeb887a" version = "1.18.2+1" +[[deps.Cassette]] +git-tree-sha1 = "f8764df8d9d2aec2812f009a1ac39e46c33354b8" +uuid = "7057c7e9-c182-5462-911a-8362d720325c" +version = "0.3.14" + [[deps.ChainRulesCore]] deps = ["Compat", "LinearAlgebra"] git-tree-sha1 = "3e4b134270b372f2ed4d4d0e936aabaefc1802bc" @@ -417,9 +423,9 @@ version = "1.7.0" [[deps.DataInterpolations]] deps = ["FindFirstFunctions", "ForwardDiff", "LinearAlgebra", "PrettyTables", "RecipesBase", "Reexport"] -git-tree-sha1 = "3d81cd1fcba530122a5d6c725aa53521d869816a" +git-tree-sha1 = "78d06458ec13b53b3b0016daebe53f832d42ff44" uuid = "82cc6244-b520-54b8-b5a6-8a565e85f1d0" -version = "6.5.2" +version = "6.6.0" [deps.DataInterpolations.extensions] DataInterpolationsChainRulesCoreExt = "ChainRulesCore" @@ -457,10 +463,10 @@ uuid = "ee1fde0b-3d02-5ea6-8484-8dfef6360eab" version = "1.14.10+0" [[deps.DelayDiffEq]] -deps = ["ArrayInterface", "DataStructures", "DiffEqBase", "LinearAlgebra", "Logging", "OrdinaryDiffEq", "Printf", "RecursiveArrayTools", "Reexport", "SciMLBase", "SimpleNonlinearSolve", "SimpleUnPack"] -git-tree-sha1 = "066f60231c1b0ae2905ffd2651e207accd91f627" +deps = ["ArrayInterface", "DataStructures", "DiffEqBase", "LinearAlgebra", "Logging", "OrdinaryDiffEq", "OrdinaryDiffEqCore", "OrdinaryDiffEqDefault", "OrdinaryDiffEqDifferentiation", "OrdinaryDiffEqNonlinearSolve", "OrdinaryDiffEqRosenbrock", "Printf", "RecursiveArrayTools", "Reexport", "SciMLBase", "SimpleNonlinearSolve", "SimpleUnPack"] +git-tree-sha1 = "cfcd0d368d6950473eab154560b22ae7a99b63be" uuid = "bcd4f6db-9728-5f36-b5f7-82caef46ccdb" -version = "5.48.1" +version = "5.49.0" [[deps.DelimitedFiles]] deps = ["Mmap"] @@ -469,10 +475,10 @@ uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab" version = "1.9.1" [[deps.DiffEqBase]] -deps = ["ArrayInterface", "ConcreteStructs", "DataStructures", "DocStringExtensions", "EnumX", "EnzymeCore", "FastBroadcast", "FastClosures", "ForwardDiff", "FunctionWrappers", "FunctionWrappersWrappers", "LinearAlgebra", "Logging", "Markdown", "MuladdMacro", "Parameters", "PreallocationTools", "PrecompileTools", "Printf", "RecursiveArrayTools", "Reexport", "SciMLBase", "SciMLOperators", "SciMLStructures", "Setfield", "Static", "StaticArraysCore", "Statistics", "TruncatedStacktraces"] -git-tree-sha1 = "f8eefbb7e910f59087c4bb09ce670f235758ee4a" +deps = ["ArrayInterface", "ConcreteStructs", "DataStructures", "DocStringExtensions", "EnumX", "EnzymeCore", "FastBroadcast", "FastClosures", "FastPower", "ForwardDiff", "FunctionWrappers", "FunctionWrappersWrappers", "LinearAlgebra", "Logging", "Markdown", "MuladdMacro", "Parameters", "PreallocationTools", "PrecompileTools", "Printf", "RecursiveArrayTools", "Reexport", "SciMLBase", "SciMLOperators", "SciMLStructures", "Setfield", "Static", "StaticArraysCore", "Statistics", "TruncatedStacktraces"] +git-tree-sha1 = "b7dbeaa770bad0980ddddf606de814cff2acb3bc" uuid = "2b5f629d-d688-5b77-993f-72d75c75574e" -version = "6.158.3" +version = "6.160.0" [deps.DiffEqBase.extensions] DiffEqBaseCUDAExt = "CUDA" @@ -504,9 +510,9 @@ version = "6.158.3" [[deps.DiffEqCallbacks]] deps = ["ConcreteStructs", "DataStructures", "DiffEqBase", "DifferentiationInterface", "Functors", "LinearAlgebra", "Markdown", "RecipesBase", "RecursiveArrayTools", "SciMLBase", "StaticArraysCore"] -git-tree-sha1 = "b1f970a2873a2cf76ce35fb0ed2b755a11b31052" +git-tree-sha1 = "0b99b7d5b938a3f09b1552c304ff70e8d0379efd" uuid = "459566f4-90b8-5000-8ac3-15dfb0a30def" -version = "4.1.0" +version = "4.2.1" [[deps.DiffEqNoiseProcess]] deps = ["DiffEqBase", "Distributions", "GPUArraysCore", "LinearAlgebra", "Markdown", "Optim", "PoissonRandom", "QuadGK", "Random", "Random123", "RandomNumbers", "RecipesBase", "RecursiveArrayTools", "ResettableStacks", "SciMLBase", "StaticArraysCore", "Statistics"] @@ -631,9 +637,9 @@ version = "0.9.3" [[deps.Documenter]] deps = ["ANSIColoredPrinters", "AbstractTrees", "Base64", "CodecZlib", "Dates", "DocStringExtensions", "Downloads", "Git", "IOCapture", "InteractiveUtils", "JSON", "LibGit2", "Logging", "Markdown", "MarkdownAST", "Pkg", "PrecompileTools", "REPL", "RegistryInstances", "SHA", "TOML", "Test", "Unicode"] -git-tree-sha1 = "5a1ee886566f2fa9318df1273d8b778b9d42712d" +git-tree-sha1 = "d0ea2c044963ed6f37703cead7e29f70cba13d7e" uuid = "e30172f5-a6a5-5a46-863b-614d45cd2de4" -version = "1.7.0" +version = "1.8.0" [[deps.DomainSets]] deps = ["CompositeTypes", "IntervalSets", "LinearAlgebra", "Random", "StaticArrays"] @@ -682,9 +688,9 @@ uuid = "4e289a0a-7415-4d19-859d-a7e5c4648b56" version = "1.0.4" [[deps.EnzymeCore]] -git-tree-sha1 = "04c777af6ef65530a96ab68f0a81a4608113aa1d" +git-tree-sha1 = "e333ffd38ecffcf5c6c2dafd10788404ac46fb9f" uuid = "f151be2c-9106-41f4-ab19-57ee4f262869" -version = "0.8.5" +version = "0.8.6" weakdeps = ["Adapt"] [deps.EnzymeCore.extensions] @@ -704,9 +710,9 @@ version = "0.1.10" [[deps.Expat_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] -git-tree-sha1 = "1c6317308b9dc757616f0b5cb379db10494443a7" +git-tree-sha1 = "cc5231d52eb1771251fbd37171dbc408bcc8a1b6" uuid = "2e619515-83b5-522b-bb60-26c02a35a201" -version = "2.6.2+0" +version = "2.6.4+0" [[deps.ExponentialUtilities]] deps = ["Adapt", "ArrayInterface", "GPUArraysCore", "GenericSchur", "LinearAlgebra", "PrecompileTools", "Printf", "SparseArrays", "libblastrampoline_jll"] @@ -871,6 +877,12 @@ git-tree-sha1 = "1ed150b39aebcc805c26b93a8d0122c940f64ce2" uuid = "559328eb-81f9-559d-9380-de523a88c83c" version = "1.0.14+0" +[[deps.FunctionProperties]] +deps = ["Cassette", "DiffRules"] +git-tree-sha1 = "bf7c740307eb0ee80e05d8aafbd0c5a901578398" +uuid = "f62d2435-5019-4c03-9749-2d4c77af0cbc" +version = "0.1.2" + [[deps.FunctionWrappers]] git-tree-sha1 = "d62485945ce5ae9c0c48f124a84998d755bae00e" uuid = "069b7b12-0de2-55c6-9aab-29f3d0a68a2e" @@ -883,10 +895,10 @@ uuid = "77dc65aa-8811-40c2-897b-53d922fa7daf" version = "0.1.3" [[deps.Functors]] -deps = ["LinearAlgebra"] -git-tree-sha1 = "64d8e93700c7a3f28f717d265382d52fac9fa1c1" +deps = ["Compat", "ConstructionBase", "LinearAlgebra", "Random"] +git-tree-sha1 = "15e5397dd1cea034c7c772d9748cdee461fb5496" uuid = "d9f16b24-f501-4c13-a1f2-28368ffc5196" -version = "0.4.12" +version = "0.5.1" [[deps.Future]] deps = ["Random"] @@ -917,12 +929,6 @@ git-tree-sha1 = "f31929b9e67066bee48eec8b03c0df47d31a74b3" uuid = "d2c73de3-f751-5644-a686-071e5b155ba9" version = "0.73.8+0" -[[deps.GenericLinearAlgebra]] -deps = ["LinearAlgebra", "Printf", "Random", "libblastrampoline_jll"] -git-tree-sha1 = "c4f9c87b74aedf20920034bd4db81d0bffc527d2" -uuid = "14197337-ba66-59df-a3e3-ca00e7dcff7a" -version = "0.3.14" - [[deps.GenericSchur]] deps = ["LinearAlgebra", "Printf"] git-tree-sha1 = "af49a0851f8113fcfae2ef5027c6d49d0acec39b" @@ -1192,9 +1198,9 @@ version = "1.3.0" [[deps.LazyArrays]] deps = ["ArrayLayouts", "FillArrays", "LinearAlgebra", "MacroTools", "SparseArrays"] -git-tree-sha1 = "360f6039babd6e4d6364eff0d4fc9120834a2d9a" +git-tree-sha1 = "376bc148ae72e68a08f0d5d8a69e287025a37687" uuid = "5078a376-72f3-5289-bfd5-ec5146d43c02" -version = "2.2.1" +version = "2.2.2" [deps.LazyArrays.extensions] LazyArraysBandedMatricesExt = "BandedMatrices" @@ -1331,9 +1337,9 @@ weakdeps = ["ChainRulesCore", "SparseArrays", "Statistics"] [[deps.LinearSolve]] deps = ["ArrayInterface", "ChainRulesCore", "ConcreteStructs", "DocStringExtensions", "EnumX", "FastLapackInterface", "GPUArraysCore", "InteractiveUtils", "KLU", "Krylov", "LazyArrays", "Libdl", "LinearAlgebra", "MKL_jll", "Markdown", "PrecompileTools", "Preferences", "RecursiveFactorization", "Reexport", "SciMLBase", "SciMLOperators", "Setfield", "SparseArrays", "Sparspak", "StaticArraysCore", "UnPack"] -git-tree-sha1 = "591de175461afd8323aa24b7686062574527aa3a" +git-tree-sha1 = "6b79df6e803fb62b79a364b86c790e7e21bd38ce" uuid = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae" -version = "2.36.2" +version = "2.37.0" [deps.LinearSolve.extensions] LinearSolveBandedMatricesExt = "BandedMatrices" @@ -1536,9 +1542,9 @@ version = "0.5.7" [[deps.MutableArithmetics]] deps = ["LinearAlgebra", "SparseArrays", "Test"] -git-tree-sha1 = "90077f1e79de8c9c7c8a90644494411111f4e07b" +git-tree-sha1 = "a2710df6b0931f987530f59427441b21245d8f5e" uuid = "d8a4904e-b15c-11e9-3269-09a3773c0cb0" -version = "1.5.2" +version = "1.6.0" [[deps.NLSolversBase]] deps = ["DiffResults", "Distributed", "FiniteDiff", "ForwardDiff"] @@ -1590,6 +1596,28 @@ version = "3.15.1" SIAMFANLEquations = "084e46ad-d928-497d-ad5e-07fa361a48c4" SpeedMapping = "f1835b91-879b-4a3f-a438-e4baacf14412" +[[deps.NonlinearSolveBase]] +deps = ["ADTypes", "Adapt", "ArrayInterface", "CommonSolve", "Compat", "ConcreteStructs", "DifferentiationInterface", "EnzymeCore", "FastClosures", "FunctionProperties", "LinearAlgebra", "Markdown", "MaybeInplace", "Preferences", "Printf", "RecursiveArrayTools", "SciMLBase", "SciMLJacobianOperators", "SciMLOperators", "StaticArraysCore", "SymbolicIndexingInterface", "TimerOutputs"] +git-tree-sha1 = "46772fc296d9f16c3ab78a8ef00008ab075de677" +uuid = "be0214bd-f91f-a760-ac4e-3421ce2b2da0" +version = "1.3.3" +weakdeps = ["BandedMatrices", "DiffEqBase", "ForwardDiff", "LineSearch", "LinearSolve", "SparseArrays", "SparseMatrixColorings"] + + [deps.NonlinearSolveBase.extensions] + NonlinearSolveBaseBandedMatricesExt = "BandedMatrices" + NonlinearSolveBaseDiffEqBaseExt = "DiffEqBase" + NonlinearSolveBaseForwardDiffExt = "ForwardDiff" + NonlinearSolveBaseLineSearchExt = "LineSearch" + NonlinearSolveBaseLinearSolveExt = "LinearSolve" + NonlinearSolveBaseSparseArraysExt = "SparseArrays" + NonlinearSolveBaseSparseMatrixColoringsExt = "SparseMatrixColorings" + +[[deps.NonlinearSolveFirstOrder]] +deps = ["ADTypes", "ArrayInterface", "CommonSolve", "ConcreteStructs", "DiffEqBase", "FiniteDiff", "ForwardDiff", "LinearAlgebra", "LinearSolve", "MaybeInplace", "NonlinearSolveBase", "PrecompileTools", "Reexport", "SciMLBase", "SciMLJacobianOperators", "Setfield", "StaticArraysCore"] +git-tree-sha1 = "dc8535cecb0f9d978019e44b7144b9e84ab85424" +uuid = "5959db7a-ea39-4486-b5fe-2dd0bf03d60d" +version = "1.0.0" + [[deps.OffsetArrays]] git-tree-sha1 = "1a27764e945a152f7ca7efa04de513d473e9542e" uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" @@ -1635,9 +1663,9 @@ version = "0.5.5+0" [[deps.Optim]] deps = ["Compat", "FillArrays", "ForwardDiff", "LineSearches", "LinearAlgebra", "NLSolversBase", "NaNMath", "Parameters", "PositiveFactorizations", "Printf", "SparseArrays", "StatsBase"] -git-tree-sha1 = "d9b79c4eed437421ac4285148fcadf42e0700e89" +git-tree-sha1 = "ab7edad78cdef22099f43c54ef77ac63c2c9cc64" uuid = "429524aa-4258-5aef-a3af-852621145aeb" -version = "1.9.4" +version = "1.10.0" [deps.Optim.extensions] OptimMOIExt = "MathOptInterface" @@ -1676,9 +1704,9 @@ version = "1.1.2" [[deps.OrdinaryDiffEqCore]] deps = ["ADTypes", "Accessors", "Adapt", "ArrayInterface", "DataStructures", "DiffEqBase", "DocStringExtensions", "EnumX", "FastBroadcast", "FastClosures", "FastPower", "FillArrays", "FunctionWrappersWrappers", "InteractiveUtils", "LinearAlgebra", "Logging", "MacroTools", "MuladdMacro", "Polyester", "PrecompileTools", "Preferences", "RecursiveArrayTools", "Reexport", "SciMLBase", "SciMLOperators", "SciMLStructures", "SimpleUnPack", "Static", "StaticArrayInterface", "StaticArraysCore", "SymbolicIndexingInterface", "TruncatedStacktraces"] -git-tree-sha1 = "5e8c500a80674850543394ce3c745b73ad51fea0" +git-tree-sha1 = "c738f18c561f369115a30c5c25a51f3a61a437b5" uuid = "bbf590c4-e513-4bbe-9b18-05decba2e5d8" -version = "1.10.0" +version = "1.11.0" weakdeps = ["EnzymeCore"] [deps.OrdinaryDiffEqCore.extensions] @@ -1715,10 +1743,10 @@ uuid = "becaefa8-8ca2-5cf9-886d-c06f3d2bd2c4" version = "1.2.1" [[deps.OrdinaryDiffEqFIRK]] -deps = ["DiffEqBase", "FastBroadcast", "FastPower", "GenericLinearAlgebra", "GenericSchur", "LinearAlgebra", "LinearSolve", "MuladdMacro", "OrdinaryDiffEqCore", "OrdinaryDiffEqDifferentiation", "OrdinaryDiffEqNonlinearSolve", "Polynomials", "RecursiveArrayTools", "Reexport", "RootedTrees", "SciMLOperators", "Symbolics"] -git-tree-sha1 = "5735f4c094dff311f5064d1a351da9669e4647e3" +deps = ["DiffEqBase", "FastBroadcast", "FastPower", "LinearAlgebra", "LinearSolve", "MuladdMacro", "OrdinaryDiffEqCore", "OrdinaryDiffEqDifferentiation", "OrdinaryDiffEqNonlinearSolve", "RecursiveArrayTools", "Reexport", "SciMLOperators"] +git-tree-sha1 = "ffdf43f7d8635cdb1b04fd68ba588d760a039b68" uuid = "5960d6e9-dd7a-4743-88e7-cf307b64f125" -version = "1.2.0" +version = "1.4.0" [[deps.OrdinaryDiffEqFeagin]] deps = ["DiffEqBase", "FastBroadcast", "MuladdMacro", "OrdinaryDiffEqCore", "Polyester", "RecursiveArrayTools", "Reexport", "Static"] @@ -1800,9 +1828,9 @@ version = "1.1.0" [[deps.OrdinaryDiffEqRosenbrock]] deps = ["ADTypes", "DiffEqBase", "FastBroadcast", "FiniteDiff", "ForwardDiff", "LinearAlgebra", "LinearSolve", "MacroTools", "MuladdMacro", "OrdinaryDiffEqCore", "OrdinaryDiffEqDifferentiation", "Polyester", "PrecompileTools", "Preferences", "RecursiveArrayTools", "Reexport", "Static"] -git-tree-sha1 = "56cbbdc43bd0e88083fcef3efa296501b5a435da" +git-tree-sha1 = "760a51a626d0065455847e4a3f788b07e86e5090" uuid = "43230ef6-c299-4910-a778-202eb28ce4ce" -version = "1.3.0" +version = "1.3.1" [[deps.OrdinaryDiffEqSDIRK]] deps = ["DiffEqBase", "FastBroadcast", "LinearAlgebra", "MacroTools", "MuladdMacro", "OrdinaryDiffEqCore", "OrdinaryDiffEqDifferentiation", "OrdinaryDiffEqNonlinearSolve", "RecursiveArrayTools", "Reexport", "SciMLBase", "TruncatedStacktraces"] @@ -1915,9 +1943,9 @@ version = "1.4.3" [[deps.Plots]] deps = ["Base64", "Contour", "Dates", "Downloads", "FFMPEG", "FixedPointNumbers", "GR", "JLFzf", "JSON", "LaTeXStrings", "Latexify", "LinearAlgebra", "Measures", "NaNMath", "Pkg", "PlotThemes", "PlotUtils", "PrecompileTools", "Printf", "REPL", "Random", "RecipesBase", "RecipesPipeline", "Reexport", "RelocatableFolders", "Requires", "Scratch", "Showoff", "SparseArrays", "Statistics", "StatsBase", "TOML", "UUIDs", "UnicodeFun", "UnitfulLatexify", "Unzip"] -git-tree-sha1 = "45470145863035bb124ca51b320ed35d071cc6c2" +git-tree-sha1 = "dae01f8c2e069a683d3a6e17bbae5070ab94786f" uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" -version = "1.40.8" +version = "1.40.9" [deps.Plots.extensions] FileIOExt = "FileIO" @@ -1952,10 +1980,10 @@ uuid = "1d0040c9-8b98-4ee7-8388-3f51789ca0ad" version = "0.2.2" [[deps.Polynomials]] -deps = ["LinearAlgebra", "RecipesBase", "Requires", "Setfield", "SparseArrays"] -git-tree-sha1 = "1a9cfb2dc2c2f1bd63f1906d72af39a79b49b736" +deps = ["LinearAlgebra", "OrderedCollections", "RecipesBase", "Requires", "Setfield", "SparseArrays"] +git-tree-sha1 = "adc25dbd4d13f148f3256b6d4743fe7e63a71c4a" uuid = "f27b6e38-b328-58d1-80ce-0feddd5e7a45" -version = "4.0.11" +version = "4.0.12" [deps.Polynomials.extensions] PolynomialsChainRulesCoreExt = "ChainRulesCore" @@ -2170,16 +2198,6 @@ git-tree-sha1 = "58cdd8fb2201a6267e1db87ff148dd6c1dbd8ad8" uuid = "f50d1b31-88e8-58de-be2c-1cc44531875f" version = "0.5.1+0" -[[deps.RootedTrees]] -deps = ["LaTeXStrings", "Latexify", "LinearAlgebra", "Preferences", "RecipesBase", "Requires"] -git-tree-sha1 = "c0c464d3063e46e4128d21fd677ca575ace44fdc" -uuid = "47965b36-3f3e-11e9-0dcf-4570dfd42a8c" -version = "2.23.1" -weakdeps = ["Plots"] - - [deps.RootedTrees.extensions] - PlotsExt = "Plots" - [[deps.RuntimeGeneratedFunctions]] deps = ["ExprTools", "SHA", "Serialization"] git-tree-sha1 = "04c968137612c4a5629fa531334bb81ad5680f00" @@ -2203,9 +2221,9 @@ version = "0.6.43" [[deps.SciMLBase]] deps = ["ADTypes", "Accessors", "ArrayInterface", "CommonSolve", "ConstructionBase", "Distributed", "DocStringExtensions", "EnumX", "Expronicon", "FunctionWrappersWrappers", "IteratorInterfaceExtensions", "LinearAlgebra", "Logging", "Markdown", "PrecompileTools", "Preferences", "Printf", "RecipesBase", "RecursiveArrayTools", "Reexport", "RuntimeGeneratedFunctions", "SciMLOperators", "SciMLStructures", "StaticArraysCore", "Statistics", "SymbolicIndexingInterface"] -git-tree-sha1 = "7527b9adb22904f0f51d8ab85d826f81ebb6f78d" +git-tree-sha1 = "cacc7bc54bab8749b1fc1032c4911fe80cffb959" uuid = "0bca4576-84f4-4d90-8ffe-ffa030f20462" -version = "2.59.2" +version = "2.61.0" [deps.SciMLBase.extensions] SciMLBaseChainRulesCoreExt = "ChainRulesCore" @@ -2477,9 +2495,9 @@ version = "2.4.1" [[deps.StochasticDiffEq]] deps = ["Adapt", "ArrayInterface", "DataStructures", "DiffEqBase", "DiffEqNoiseProcess", "DocStringExtensions", "FastPower", "FiniteDiff", "ForwardDiff", "JumpProcesses", "LevyArea", "LinearAlgebra", "Logging", "MuladdMacro", "NLsolve", "OrdinaryDiffEq", "Random", "RandomNumbers", "RecursiveArrayTools", "Reexport", "SciMLBase", "SciMLOperators", "SparseArrays", "SparseDiffTools", "StaticArrays", "UnPack"] -git-tree-sha1 = "bf4bad73c80e058b1d53788ff520e10c8bad7c9d" +git-tree-sha1 = "b1464027197ae535fd21e0c482ba23f768be72ff" uuid = "789caeaf-c7a9-5a7d-9973-96adeb23e2a0" -version = "6.70.0" +version = "6.71.0" [[deps.StrideArraysCore]] deps = ["ArrayInterface", "CloseOpenIntervals", "IfElse", "LayoutPointers", "LinearAlgebra", "ManualMemory", "SIMDTypes", "Static", "StaticArrayInterface", "ThreadingUtilities"] @@ -2520,9 +2538,9 @@ version = "5.2.3+0" [[deps.SymbolicIndexingInterface]] deps = ["Accessors", "ArrayInterface", "RuntimeGeneratedFunctions", "StaticArraysCore"] -git-tree-sha1 = "20cf607cafb31f922bce84d60379203e7a126911" +git-tree-sha1 = "6c6761e08bf5a270905cdd065be633abfa1b155b" uuid = "2efcf032-c050-4f8e-a9bb-153293bab1f5" -version = "0.3.34" +version = "0.3.35" [[deps.SymbolicLimits]] deps = ["SymbolicUtils"] @@ -2546,9 +2564,9 @@ version = "3.7.2" [[deps.Symbolics]] deps = ["ADTypes", "ArrayInterface", "Bijections", "CommonWorldInvalidations", "ConstructionBase", "DataStructures", "DiffRules", "Distributions", "DocStringExtensions", "DomainSets", "DynamicPolynomials", "IfElse", "LaTeXStrings", "Latexify", "Libdl", "LinearAlgebra", "LogExpFunctions", "MacroTools", "Markdown", "NaNMath", "PrecompileTools", "Primes", "RecipesBase", "Reexport", "RuntimeGeneratedFunctions", "SciMLBase", "Setfield", "SparseArrays", "SpecialFunctions", "StaticArraysCore", "SymbolicIndexingInterface", "SymbolicLimits", "SymbolicUtils", "TermInterface"] -git-tree-sha1 = "0caef7687abf7094132fa3112bf5514c36a99226" +git-tree-sha1 = "d5c0ea92aa7b14b0ffca575e07af48ecb9e83f7b" uuid = "0c5d862f-8b57-4792-8d23-62f2024744c7" -version = "6.18.3" +version = "6.21.0" [deps.Symbolics.extensions] SymbolicsForwardDiffExt = "ForwardDiff" @@ -2733,9 +2751,9 @@ version = "1.31.0+0" [[deps.XML2_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Libiconv_jll", "Zlib_jll"] -git-tree-sha1 = "6a451c6f33a176150f315726eba8b92fbfdb9ae7" +git-tree-sha1 = "a2fccc6559132927d4c5dc183e3e01048c6dcbd6" uuid = "02c8fc9c-b97f-50b9-bbe4-9be30ff0a78a" -version = "2.13.4+0" +version = "2.13.5+0" [[deps.XSLT_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Libgcrypt_jll", "Libgpg_error_jll", "Libiconv_jll", "XML2_jll", "Zlib_jll"] diff --git a/dev/assets/documenter.js b/dev/assets/documenter.js index 82252a11d..7d68cd808 100644 --- a/dev/assets/documenter.js +++ b/dev/assets/documenter.js @@ -612,176 +612,194 @@ function worker_function(documenterSearchIndex, documenterBaseURL, filters) { }; } -// `worker = Threads.@spawn worker_function(documenterSearchIndex)`, but in JavaScript! -const filters = [ - ...new Set(documenterSearchIndex["docs"].map((x) => x.category)), -]; -const worker_str = - "(" + - worker_function.toString() + - ")(" + - JSON.stringify(documenterSearchIndex["docs"]) + - "," + - JSON.stringify(documenterBaseURL) + - "," + - JSON.stringify(filters) + - ")"; -const worker_blob = new Blob([worker_str], { type: "text/javascript" }); -const worker = new Worker(URL.createObjectURL(worker_blob)); - /////// SEARCH MAIN /////// -// Whether the worker is currently handling a search. This is a boolean -// as the worker only ever handles 1 or 0 searches at a time. -var worker_is_running = false; - -// The last search text that was sent to the worker. This is used to determine -// if the worker should be launched again when it reports back results. -var last_search_text = ""; - -// The results of the last search. This, in combination with the state of the filters -// in the DOM, is used compute the results to display on calls to update_search. -var unfiltered_results = []; - -// Which filter is currently selected -var selected_filter = ""; - -$(document).on("input", ".documenter-search-input", function (event) { - if (!worker_is_running) { - launch_search(); - } -}); - -function launch_search() { - worker_is_running = true; - last_search_text = $(".documenter-search-input").val(); - worker.postMessage(last_search_text); -} - -worker.onmessage = function (e) { - if (last_search_text !== $(".documenter-search-input").val()) { - launch_search(); - } else { - worker_is_running = false; - } - - unfiltered_results = e.data; - update_search(); -}; +function runSearchMainCode() { + // `worker = Threads.@spawn worker_function(documenterSearchIndex)`, but in JavaScript! + const filters = [ + ...new Set(documenterSearchIndex["docs"].map((x) => x.category)), + ]; + const worker_str = + "(" + + worker_function.toString() + + ")(" + + JSON.stringify(documenterSearchIndex["docs"]) + + "," + + JSON.stringify(documenterBaseURL) + + "," + + JSON.stringify(filters) + + ")"; + const worker_blob = new Blob([worker_str], { type: "text/javascript" }); + const worker = new Worker(URL.createObjectURL(worker_blob)); + + // Whether the worker is currently handling a search. This is a boolean + // as the worker only ever handles 1 or 0 searches at a time. + var worker_is_running = false; + + // The last search text that was sent to the worker. This is used to determine + // if the worker should be launched again when it reports back results. + var last_search_text = ""; + + // The results of the last search. This, in combination with the state of the filters + // in the DOM, is used compute the results to display on calls to update_search. + var unfiltered_results = []; + + // Which filter is currently selected + var selected_filter = ""; + + $(document).on("input", ".documenter-search-input", function (event) { + if (!worker_is_running) { + launch_search(); + } + }); -$(document).on("click", ".search-filter", function () { - if ($(this).hasClass("search-filter-selected")) { - selected_filter = ""; - } else { - selected_filter = $(this).text().toLowerCase(); + function launch_search() { + worker_is_running = true; + last_search_text = $(".documenter-search-input").val(); + worker.postMessage(last_search_text); } - // This updates search results and toggles classes for UI: - update_search(); -}); + worker.onmessage = function (e) { + if (last_search_text !== $(".documenter-search-input").val()) { + launch_search(); + } else { + worker_is_running = false; + } -/** - * Make/Update the search component - */ -function update_search() { - let querystring = $(".documenter-search-input").val(); + unfiltered_results = e.data; + update_search(); + }; - if (querystring.trim()) { - if (selected_filter == "") { - results = unfiltered_results; + $(document).on("click", ".search-filter", function () { + if ($(this).hasClass("search-filter-selected")) { + selected_filter = ""; } else { - results = unfiltered_results.filter((result) => { - return selected_filter == result.category.toLowerCase(); - }); + selected_filter = $(this).text().toLowerCase(); } - let search_result_container = ``; - let modal_filters = make_modal_body_filters(); - let search_divider = `
`; + // This updates search results and toggles classes for UI: + update_search(); + }); - if (results.length) { - let links = []; - let count = 0; - let search_results = ""; - - for (var i = 0, n = results.length; i < n && count < 200; ++i) { - let result = results[i]; - if (result.location && !links.includes(result.location)) { - search_results += result.div; - count++; - links.push(result.location); - } - } + /** + * Make/Update the search component + */ + function update_search() { + let querystring = $(".documenter-search-input").val(); - if (count == 1) { - count_str = "1 result"; - } else if (count == 200) { - count_str = "200+ results"; + if (querystring.trim()) { + if (selected_filter == "") { + results = unfiltered_results; } else { - count_str = count + " results"; + results = unfiltered_results.filter((result) => { + return selected_filter == result.category.toLowerCase(); + }); } - let result_count = `
${count_str}
`; - search_result_container = ` + let search_result_container = ``; + let modal_filters = make_modal_body_filters(); + let search_divider = `
`; + + if (results.length) { + let links = []; + let count = 0; + let search_results = ""; + + for (var i = 0, n = results.length; i < n && count < 200; ++i) { + let result = results[i]; + if (result.location && !links.includes(result.location)) { + search_results += result.div; + count++; + links.push(result.location); + } + } + + if (count == 1) { + count_str = "1 result"; + } else if (count == 200) { + count_str = "200+ results"; + } else { + count_str = count + " results"; + } + let result_count = `
${count_str}
`; + + search_result_container = ` +
+ ${modal_filters} + ${search_divider} + ${result_count} +
+ ${search_results} +
+
+ `; + } else { + search_result_container = `
${modal_filters} ${search_divider} - ${result_count} -
- ${search_results} -
-
+
0 result(s)
+ +
No result found!
`; - } else { - search_result_container = ` -
- ${modal_filters} - ${search_divider} -
0 result(s)
-
-
No result found!
- `; - } + } - if ($(".search-modal-card-body").hasClass("is-justify-content-center")) { - $(".search-modal-card-body").removeClass("is-justify-content-center"); - } + if ($(".search-modal-card-body").hasClass("is-justify-content-center")) { + $(".search-modal-card-body").removeClass("is-justify-content-center"); + } - $(".search-modal-card-body").html(search_result_container); - } else { - if (!$(".search-modal-card-body").hasClass("is-justify-content-center")) { - $(".search-modal-card-body").addClass("is-justify-content-center"); + $(".search-modal-card-body").html(search_result_container); + } else { + if (!$(".search-modal-card-body").hasClass("is-justify-content-center")) { + $(".search-modal-card-body").addClass("is-justify-content-center"); + } + + $(".search-modal-card-body").html(` +
Type something to get started!
+ `); } + } - $(".search-modal-card-body").html(` -
Type something to get started!
- `); + /** + * Make the modal filter html + * + * @returns string + */ + function make_modal_body_filters() { + let str = filters + .map((val) => { + if (selected_filter == val.toLowerCase()) { + return `${val}`; + } else { + return `${val}`; + } + }) + .join(""); + + return ` +
+ Filters: + ${str} +
`; } } -/** - * Make the modal filter html - * - * @returns string - */ -function make_modal_body_filters() { - let str = filters - .map((val) => { - if (selected_filter == val.toLowerCase()) { - return `${val}`; - } else { - return `${val}`; - } - }) - .join(""); - - return ` -
- Filters: - ${str} -
`; +function waitUntilSearchIndexAvailable() { + // It is possible that the documenter.js script runs before the page + // has finished loading and documenterSearchIndex gets defined. + // So we need to wait until the search index actually loads before setting + // up all the search-related stuff. + if (typeof documenterSearchIndex !== "undefined") { + runSearchMainCode(); + } else { + console.warn("Search Index not available, waiting"); + setTimeout(waitUntilSearchIndexAvailable, 1000); + } } +// The actual entry point to the search code +waitUntilSearchIndexAvailable(); + }) //////////////////////////////////////////////////////////////////////////////// require(['jquery'], function($) { diff --git a/dev/connectors/connections/bdf865b5.svg b/dev/connectors/connections/2ab38419.svg similarity index 91% rename from dev/connectors/connections/bdf865b5.svg rename to dev/connectors/connections/2ab38419.svg index 7a6436d2b..979b09ffd 100644 --- a/dev/connectors/connections/bdf865b5.svg +++ b/dev/connectors/connections/2ab38419.svg @@ -1,56 +1,56 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/connectors/connections/598e6130.svg b/dev/connectors/connections/538e538d.svg similarity index 89% rename from dev/connectors/connections/598e6130.svg rename to dev/connectors/connections/538e538d.svg index 32d6ddec6..c9afad1ad 100644 --- a/dev/connectors/connections/598e6130.svg +++ b/dev/connectors/connections/538e538d.svg @@ -1,116 +1,116 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/connectors/connections/c3c8e7ed.svg b/dev/connectors/connections/8c9910fa.svg similarity index 89% rename from dev/connectors/connections/c3c8e7ed.svg rename to dev/connectors/connections/8c9910fa.svg index 292a93aa8..0756fd0c3 100644 --- a/dev/connectors/connections/c3c8e7ed.svg +++ b/dev/connectors/connections/8c9910fa.svg @@ -1,82 +1,82 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/connectors/connections/a299a362.svg b/dev/connectors/connections/b9df26e7.svg similarity index 89% rename from dev/connectors/connections/a299a362.svg rename to dev/connectors/connections/b9df26e7.svg index 63e818f57..b8e1e465c 100644 --- a/dev/connectors/connections/a299a362.svg +++ b/dev/connectors/connections/b9df26e7.svg @@ -1,82 +1,82 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/connectors/connections/654e8212.svg b/dev/connectors/connections/cccdf3c5.svg similarity index 92% rename from dev/connectors/connections/654e8212.svg rename to dev/connectors/connections/cccdf3c5.svg index 26baa1a36..99da5851a 100644 --- a/dev/connectors/connections/654e8212.svg +++ b/dev/connectors/connections/cccdf3c5.svg @@ -1,48 +1,48 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/connectors/connections/0125b4a2.svg b/dev/connectors/connections/e472509d.svg similarity index 84% rename from dev/connectors/connections/0125b4a2.svg rename to dev/connectors/connections/e472509d.svg index aa62202c3..4102df50e 100644 --- a/dev/connectors/connections/0125b4a2.svg +++ b/dev/connectors/connections/e472509d.svg @@ -1,43 +1,43 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/connectors/connections/index.html b/dev/connectors/connections/index.html index aab17b691..647b26392 100644 --- a/dev/connectors/connections/index.html +++ b/dev/connectors/connections/index.html @@ -24,7 +24,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
 
 systems = @named begin
@@ -47,7 +47,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
 
 systems = @named begin
     damping = TP.Damper(d = 1, va = 1, vb = 0.0)
@@ -70,7 +70,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)
+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)
 @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)
 @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)
 @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()
@@ -98,9 +98,9 @@
 ┌ Warning: Initialization system is overdetermined. 12 equations for 0 unknowns. Initialization will default to using least squares. To suppress this warning pass warn_initialize_determined = false. To make this warning into an error, pass fully_determined = true
 └ @ ModelingToolkit ~/.julia/packages/ModelingToolkit/zfOUk/src/systems/diffeqs/abstractodesystem.jl:1291

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} @@ -109,4 +109,4 @@ \end{aligned}\]

By definition, the spring stretch is

\[\Delta s = s - s_{b_0} - l\]

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 (much less than the tolerance of 1e-9).

plot(title = "numerical difference: vel. vs. pos. domain", xlabel = "time [s]",
     ylabel = "solv[bv.v] .- solp[bp.v]")
 time = 0:0.1:10
-plot!(time, (solv(time)[bv.v] .- solp(time)[bp.v]), label = "")
Example block output +plot!(time, (solv(time)[bv.v] .- solp(time)[bp.v]), label = "")Example block output diff --git a/dev/connectors/sign_convention/index.html b/dev/connectors/sign_convention/index.html index a9391bace..7492a521a 100644 --- a/dev/connectors/sign_convention/index.html +++ b/dev/connectors/sign_convention/index.html @@ -113,4 +113,4 @@ full_equations(sys) |> first

\[ \begin{equation} \frac{\mathrm{d} \mathtt{volume.rho}\left( t \right)}{\mathrm{d}t} = \frac{\mathtt{flow.dm}}{\mathtt{volume.vol}} \end{equation} - \]

+ \]

diff --git a/dev/index.html b/dev/index.html index 19ebf06e5..02552716a 100644 --- a/dev/index.html +++ b/dev/index.html @@ -3,14 +3,14 @@ Pkg.add("ModelingToolkitStandardLibrary")

Tutorials

Libraries

The following are the constituent libraries of the ModelingToolkit Standard Library.

Contributing

Reproducibility

The documentation of this SciML package was built using these direct dependencies,
Status `~/work/ModelingToolkitStandardLibrary.jl/ModelingToolkitStandardLibrary.jl/docs/Project.toml`
   [aaaaaaaa] ControlSystemsBase v1.11.1
   [a93c6f00] DataFrames v1.7.0
-  [82cc6244] DataInterpolations v6.5.2
+  [82cc6244] DataInterpolations v6.6.0
   [0c46a032] DifferentialEquations v7.15.0
-  [e30172f5] Documenter v1.7.0
+  [e30172f5] Documenter v1.8.0
   [615f187c] IfElse v0.1.1
   [961ee093] ModelingToolkit v9.50.0
   [16a59e39] ModelingToolkitStandardLibrary v2.17.0 `~/work/ModelingToolkitStandardLibrary.jl/ModelingToolkitStandardLibrary.jl`
   [1dea7af3] OrdinaryDiffEq v6.90.1
-  [91a5bcdd] Plots v1.40.8
and using this machine and Julia version.
Julia Version 1.11.1
+  [91a5bcdd] Plots v1.40.9
and using this machine and Julia version.
Julia Version 1.11.1
 Commit 8f5b7ca12ad (2024-10-16 10:53 UTC)
 Build Info:
   Official https://julialang.org/ release
@@ -20,7 +20,7 @@
   WORD_SIZE: 64
   LLVM: libLLVM-16.0.6 (ORCJIT, znver3)
 Threads: 1 default, 0 interactive, 1 GC (on 4 virtual cores)
A more complete overview of all dependencies and their versions is also provided.
Status `~/work/ModelingToolkitStandardLibrary.jl/ModelingToolkitStandardLibrary.jl/docs/Manifest.toml`
-  [47edcb42] ADTypes v1.9.0
+  [47edcb42] ADTypes v1.10.0
   [a4c015fc] ANSIColoredPrinters v0.0.1
   [621f4979] AbstractFFTs v1.5.0
   [1520ce14] AbstractTrees v0.4.5
@@ -36,13 +36,14 @@
   [62783981] BitTwiddlingConvenienceFunctions v0.1.6
   [8e7c35d0] BlockArrays v1.1.1
   [764a87c0] BoundaryValueDiffEq v5.12.0
-  [56b672f2] BoundaryValueDiffEqCore v1.0.2
-  [85d9eb09] BoundaryValueDiffEqFIRK v1.0.2
-  [1a22d4ce] BoundaryValueDiffEqMIRK v1.0.1
-  [ed55bfe0] BoundaryValueDiffEqShooting v1.0.2
+  [56b672f2] BoundaryValueDiffEqCore v1.1.0
+  [85d9eb09] BoundaryValueDiffEqFIRK v1.1.0
+  [1a22d4ce] BoundaryValueDiffEqMIRK v1.1.0
+  [ed55bfe0] BoundaryValueDiffEqShooting v1.1.0
   [fa961155] CEnum v0.5.0
   [2a0fbf3d] CPUSummary v0.2.6
   [00ebfdb7] CSTParser v3.4.3
+  [7057c7e9] Cassette v0.3.14
   [d360d2e6] ChainRulesCore v1.25.0
   [fb6a15b2] CloseOpenIntervals v0.1.13
   [944b1d66] CodecZlib v0.7.6
@@ -68,13 +69,13 @@
   [717857b8] DSP v0.7.10
   [9a962f9c] DataAPI v1.16.0
   [a93c6f00] DataFrames v1.7.0
-  [82cc6244] DataInterpolations v6.5.2
+  [82cc6244] DataInterpolations v6.6.0
   [864edb3b] DataStructures v0.18.20
   [e2d170a0] DataValueInterfaces v1.0.0
-  [bcd4f6db] DelayDiffEq v5.48.1
+  [bcd4f6db] DelayDiffEq v5.49.0
   [8bb1440f] DelimitedFiles v1.9.1
-  [2b5f629d] DiffEqBase v6.158.3
-  [459566f4] DiffEqCallbacks v4.1.0
+  [2b5f629d] DiffEqBase v6.160.0
+  [459566f4] DiffEqCallbacks v4.2.1
   [77a26b50] DiffEqNoiseProcess v5.23.0
   [163ba53b] DiffResults v1.1.0
   [b552c78f] DiffRules v1.15.1
@@ -84,12 +85,12 @@
   [b4f34e82] Distances v0.10.12
   [31c24e10] Distributions v0.25.113
   [ffbed154] DocStringExtensions v0.9.3
-  [e30172f5] Documenter v1.7.0
+  [e30172f5] Documenter v1.8.0
   [5b8099bc] DomainSets v0.7.14
   [7c1d4256] DynamicPolynomials v0.6.0
   [06fc5a27] DynamicQuantities v1.3.0
   [4e289a0a] EnumX v1.0.4
-  [f151be2c] EnzymeCore v0.8.5
+  [f151be2c] EnzymeCore v0.8.6
   [460bff9d] ExceptionUnwrapping v0.1.10
   [d4d017d3] ExponentialUtilities v1.26.1
   [e2ba6199] ExprTools v0.1.10
@@ -107,12 +108,12 @@
   [53c48c17] FixedPointNumbers v0.8.5
   [1fa38f19] Format v1.3.7
   [f6369f11] ForwardDiff v0.10.38
+  [f62d2435] FunctionProperties v0.1.2
   [069b7b12] FunctionWrappers v1.1.3
   [77dc65aa] FunctionWrappersWrappers v0.1.3
-⌅ [d9f16b24] Functors v0.4.12
+  [d9f16b24] Functors v0.5.1
 ⌅ [46192b85] GPUArraysCore v0.1.6
   [28b8d3ca] GR v0.73.8
-  [14197337] GenericLinearAlgebra v0.3.14
   [c145ed77] GenericSchur v0.5.4
   [d7ba0133] Git v1.3.1
   [c27321d9] Glob v1.3.1
@@ -143,12 +144,12 @@
   [23fbe1c1] Latexify v0.16.5
   [10f19ff3] LayoutPointers v0.1.17
   [0e77f7df] LazilyInitializedFields v1.3.0
-  [5078a376] LazyArrays v2.2.1
+  [5078a376] LazyArrays v2.2.2
   [2d8b4e74] LevyArea v1.0.0
   [87fe0de2] LineSearch v0.1.4
   [d3d80556] LineSearches v7.3.0
   [7a12625a] LinearMaps v3.11.3
-  [7ed4a6bd] LinearSolve v2.36.2
+  [7ed4a6bd] LinearSolve v2.37.0
   [2ab3a3ac] LogExpFunctions v0.3.28
   [e6f89c97] LoggingExtras v1.1.0
   [bdcacae8] LoopVectorization v0.12.171
@@ -167,25 +168,27 @@
   [16a59e39] ModelingToolkitStandardLibrary v2.17.0 `~/work/ModelingToolkitStandardLibrary.jl/ModelingToolkitStandardLibrary.jl`
   [46d2c3a1] MuladdMacro v0.2.4
   [102ac46a] MultivariatePolynomials v0.5.7
-  [d8a4904e] MutableArithmetics v1.5.2
+  [d8a4904e] MutableArithmetics v1.6.0
   [d41bc354] NLSolversBase v7.8.3
   [2774e3e8] NLsolve v4.5.1
   [77ba4419] NaNMath v1.0.2
 ⌅ [8913a72c] NonlinearSolve v3.15.1
+  [be0214bd] NonlinearSolveBase v1.3.3
+  [5959db7a] NonlinearSolveFirstOrder v1.0.0
   [6fe1bfb0] OffsetArrays v1.14.1
   [4d8831e6] OpenSSL v1.4.3
-  [429524aa] Optim v1.9.4
+  [429524aa] Optim v1.10.0
   [bac558e1] OrderedCollections v1.6.3
   [1dea7af3] OrdinaryDiffEq v6.90.1
   [89bda076] OrdinaryDiffEqAdamsBashforthMoulton v1.1.0
   [6ad6398a] OrdinaryDiffEqBDF v1.1.2
-  [bbf590c4] OrdinaryDiffEqCore v1.10.0
+  [bbf590c4] OrdinaryDiffEqCore v1.11.0
   [50262376] OrdinaryDiffEqDefault v1.1.0
   [4302a76b] OrdinaryDiffEqDifferentiation v1.2.0
   [9286f039] OrdinaryDiffEqExplicitRK v1.1.0
   [e0540318] OrdinaryDiffEqExponentialRK v1.1.0
   [becaefa8] OrdinaryDiffEqExtrapolation v1.2.1
-  [5960d6e9] OrdinaryDiffEqFIRK v1.2.0
+  [5960d6e9] OrdinaryDiffEqFIRK v1.4.0
   [101fe9f7] OrdinaryDiffEqFeagin v1.1.0
   [d3585ca7] OrdinaryDiffEqFunctionMap v1.1.1
   [d28bc4f8] OrdinaryDiffEqHighOrderRK v1.1.0
@@ -199,7 +202,7 @@
   [5b33eab2] OrdinaryDiffEqPRK v1.1.0
   [04162be5] OrdinaryDiffEqQPRK v1.1.0
   [af6ede74] OrdinaryDiffEqRKN v1.1.0
-  [43230ef6] OrdinaryDiffEqRosenbrock v1.3.0
+  [43230ef6] OrdinaryDiffEqRosenbrock v1.3.1
   [2d112036] OrdinaryDiffEqSDIRK v1.1.0
   [669c94d9] OrdinaryDiffEqSSPRK v1.2.0
   [e3e12d00] OrdinaryDiffEqStabilizedIRK v1.1.0
@@ -214,11 +217,11 @@
   [b98c9c47] Pipe v1.3.0
   [ccf2f8ad] PlotThemes v3.3.0
   [995b91a9] PlotUtils v1.4.3
-  [91a5bcdd] Plots v1.40.8
+  [91a5bcdd] Plots v1.40.9
   [e409e4f3] PoissonRandom v0.4.4
   [f517fe37] Polyester v0.7.16
   [1d0040c9] PolyesterWeave v0.2.2
-  [f27b6e38] Polynomials v4.0.11
+  [f27b6e38] Polynomials v4.0.12
   [2dfb63ee] PooledArrays v1.4.3
   [85a6dd25] PositiveFactorizations v0.2.4
   [d236fae5] PreallocationTools v0.4.24
@@ -240,11 +243,10 @@
   [ae029012] Requires v1.3.0
   [ae5879a3] ResettableStacks v1.1.1
   [79098fc4] Rmath v0.8.0
-  [47965b36] RootedTrees v2.23.1
   [7e49a35a] RuntimeGeneratedFunctions v0.5.13
   [94e857df] SIMDTypes v0.1.0
   [476501e8] SLEEFPirates v0.6.43
-  [0bca4576] SciMLBase v2.59.2
+  [0bca4576] SciMLBase v2.61.0
   [19f34311] SciMLJacobianOperators v0.1.1
   [c0aeaf25] SciMLOperators v0.3.12
   [53ae85a6] SciMLStructures v1.5.0
@@ -272,14 +274,14 @@
   [2913bbd2] StatsBase v0.34.3
   [4c63d2b9] StatsFuns v1.3.2
   [9672c7b4] SteadyStateDiffEq v2.4.1
-  [789caeaf] StochasticDiffEq v6.70.0
+  [789caeaf] StochasticDiffEq v6.71.0
   [7792a7ef] StrideArraysCore v0.5.7
   [892a3eda] StringManipulation v0.4.0
   [c3572dad] Sundials v4.26.1
-  [2efcf032] SymbolicIndexingInterface v0.3.34
+  [2efcf032] SymbolicIndexingInterface v0.3.35
   [19f23fe9] SymbolicLimits v0.2.2
   [d1185830] SymbolicUtils v3.7.2
-  [0c5d862f] Symbolics v6.18.3
+  [0c5d862f] Symbolics v6.21.0
   [3783bdb8] TableTraits v1.0.1
   [bd369af6] Tables v1.12.0
   [62fd8b95] TensorCore v0.1.1
@@ -305,7 +307,7 @@
   [83423d85] Cairo_jll v1.18.2+1
   [ee1fde0b] Dbus_jll v1.14.10+0
   [2702e6a9] EpollShim_jll v0.0.20230411+0
-  [2e619515] Expat_jll v2.6.2+0
+  [2e619515] Expat_jll v2.6.4+0
 ⌅ [b22a6f82] FFMPEG_jll v4.4.4+1
   [f5851436] FFTW_jll v3.3.10+1
   [a3f928ae] Fontconfig_jll v2.13.96+0
@@ -348,7 +350,7 @@
   [a44049a8] Vulkan_Loader_jll v1.3.243+0
   [a2964d1f] Wayland_jll v1.21.0+1
   [2381bf8a] Wayland_protocols_jll v1.31.0+0
-  [02c8fc9c] XML2_jll v2.13.4+0
+  [02c8fc9c] XML2_jll v2.13.5+0
   [aed1982a] XSLT_jll v1.1.41+0
   [ffd25f8a] XZ_jll v5.6.3+0
   [f67eecfb] Xorg_libICE_jll v1.1.1+0
@@ -440,4 +442,4 @@
   [8e850b90] libblastrampoline_jll v5.11.0+0
   [8e850ede] nghttp2_jll v1.59.0+0
   [3f19e933] p7zip_jll v17.4.0+2
-Info Packages marked with ⌅ have new versions available but compatibility constraints restrict them from upgrading. To see why use `status --outdated -m`

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

+Info Packages marked with ⌅ have new versions available but compatibility constraints restrict them 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 3f93fdffdfb094a2d51f9f952bdeaf815d2f3775..aaba82862fecdd4867075786ec4463fe11d13dc3 100644 GIT binary patch delta 3015 zcmV;&3pn)j7=sy*%70|a`l9!xRV2>vYvwoe8`3li$SX?H;3{A~@;)GR%K{S8XuoAF z{7%zNilYGY;0xVx%-^PegjZ;e^joA}qesT;l9Mz`8K*c*X54@9Dfcs)nqAqx&(Qq> zE#$MIz|WGD9Ugpkh*?CU1~v6oGqlLxpoM;u7&_A@!VfrnIDd#?+Z9%t%+OZ;3F@LC z^Ha(qIcGy@;6r2h;~}PYl}3XZS}s5V{DEF*`h+$yA%Reyau$Y!8)|73XKCB?YmH`T zgAZ{?f+bFIxdaoRMG^5q2o_8}!bB2NrM*Qyf5zWT1qt0p&|~xrip6r+mDF0nz~F_L zsCqG(uUE5O$bbCrm0^@`XXqLy)JNC(UwLy9f^trM9M(n3FEjM9Y-QMhXm!B*h@_yi zCavGk(5-G!mn8lZj%+=bUqHHSRg+gnRToyTO)IO2J-r1SXW{XPiw`sOxoA@p2Dc=b zKi~+5ZwWnG<=W>NxV3nJ=IX^nx;Z6MGQ>OZ7?Azx9e?sBw>YW2Zm=KOx(!||J$z-6 z9HDnz8cET_FcWB9wAIG4q8X3gBA0-1(o_wMsjvHyQnB)OwKd73cz)G@U*ZuADCur? zV7TB6Z0~JIl)(44WtXjyYCTb4cxu};aDuRg&VO>l%4y8D97jor#mGRRny9y=kB@|t z$R~;Sw{HY?OYHA+GWFKVJz(ARcT!f1;+T6gilo6BScI zpb=?}$e7Ax6~Q|k(jT}FjCimmoMro`91iQCBr}Arx|F6I9qaIL zSgG!A)nhce)Xn!>tySQA``V()C zdn{4`sY%i-tqJAhMzwM0U?jC5silG?-K@>T5@l*Rt)sgv-_hd~_kQ6i)_dAi41cC9 z`YE`wGLTi2K;{}+5WS9y0%7{hBX4geQcHFanQcc;F|sKsIQdL)>Xl6T^t7u)9P|n4 zV;RM*Z-YuMH;a@DX+`K;zW9noEr9xW~?y0@q@`;HJ@XZK5d zhzakLV93bQIC4u^(ZjBIvjob{xPSAmiUkrqCu_{{fxtrjAi+58jha+XD^d8-2JMJY z1FulXewtMj@ZWClHid20ZmXrp8iO}CYZ7f_x?YzkOr;5zZKk3SSv$xloOXAQyz%7Y zYaGI`jyLLbOcx~H&p7rwCm7yDM5_$)wtgj7bFxAK z(h5+apcbLJuRt|O8H;dF;vDtpP8LjT1x7G}_MBHVtCw5yoG?+TbhERXMR}n~N$0s> zDc!`y8d9k)OiX4~i;yKG@IuC74_o1|aj1qU(xQ`1%#X6nlL5D~H^aorVuhC_V < zMTej3Rf29koYsDEIoJB(@u+`?y0s}`lna;TkQ#q8stsPX`+mu;QM9NIM5Vr4y_*(e zUoO1-NJv88dgb}Wc~D1_s2(a+G*rQhlc5O4iRr-#LpxzhQ4Z{0j#qVu#w@uLld0~5 zbi0BUcjd#!=+|or>qc2!#V30;1Ns+a1P7P44824y`r3S6S9|)gVQv3DljvT7}JH)ra!G&Drg!G%hMX05gRBx z-VYzar^O;YJYruN-Wfcye7sTpIm1M~h$GSacy~Sq!P_F^oLGN#yWNFN41zf%UjB}4 zu+nc6)Y5EmG|mr<_^_t7E$bN-8Ua;j-L9f~gB6nSEV)BSUhZ*9zR&|riOq$2EVKn)bTqg*GP$R5L$-LLw2o&|;v^sKk~TONgs&lS=%ZRK#XJap9S2H= zE!<@(7{i=%D>{Gl*XhJoTdnIZCN=~bWLfisjzlx1NR-$2ki}RLpuf8Hs-K#vWWMx= zEl07k;z3xq#$03)Vmm?#1N$8aKj2@U4GJ0o#P&=mt9n*R9kjcP$W4f&J()+rCW~Y6 z-plcsa~&w%`NrI5i4#Sel*En{!G>*O?2pWA%LLh7UZ8(-R#(jNM4k-xoB8nY7o^2N zhqHrIep*dms{v`&on6K7duE6en>Rm~IE zU^hOeJ7;836L|Ve6FXTNHt}XY({tt;NwR~JAi7nDNjG|TUG21*uq$xVo`yl@HNU+* zYWA%#lox*>gmonuACE?*TRKnCw=c{^R&MSbhImKqS=z8&+Y@<4`jCJ%2tr}6;0?*a zG!SU_cTyfZO8=ejS|bh);X5~!C+Qszh?~6n9v?;~PbW?f#;2clQve|(L{A7fU^G%tiZWK1axr8^iRM z{60KS?atKeP{TSGSB`pI?QjQ)jc!%m<#19iW-*B#^2?OlEDp(k=h54Hw0S%1SolBD z$$_L#ENEhagZjAm?HYQyxLjOZ{vvz2_-%jLeYJDr@I`cUbUCEqqEcR=cZOf{z(y;F zk+)h@C_Xe590rptb&-EsymDiL*)b2)## zUAbV%$h!+hq0xPf@l?gh*&3|nugqLuD|JU73zuYer>87}r5Lhn{Iy!!FRk6^1qtdK3qfu%SfB454>$h}bGJo;V zh4vdMq$nX2zp{0cLz?I$DqMH*T%NL?>0Y-P51iF-HuMa4j8{SEDvFH17h(%udTK-0 J{{!M--D3*N;DZ1F delta 2999 zcmV;o3rO^X8T1&C%6}xvk|layT1Davzh-_jzadSdfV`q44Xy&_Bku!3w=5tbjrLo{ z!tXTQq&NyN55CYH$NX*jM|g$iNWVquHF{*cE;&iFlyQo~WXAmmpK?E=so9n7`wZPL z&_X^N3j8cd+2O%whnPhqYEe^fHA9R14O-|oiJ>!nBK&~Ehkt_@wq0SR$qa4fpP()Z zGC!p(l5;kc20k=~KOSOgS7|huq2&S;z#r&^rcY=S6A}pJDQ96wxS^Itah7&Xzt(7m zHuw;SBv|4UmrF45Sric;gkZtsBTOVQRoYwR^Jo0cRFKep1U*L2pja%2T}iDK3=Cd~ ziK-Wq`Fb_mg@4TdUKvLDc80ETLVa|d|CKik6$6;Nh{4zry%T|UBh*k%@k4OqS zYts7t4BhG$bxGns;mFo=`30oQRyBELRCQtX+O)EY*wb6UaTYd5Tzr_J&qbS>Ft{bb z`~gQed`oC!m2018;MU>=nyVKR>E@J3$q?_rV?g$&cYny6+~TD6y2XBE>n?b)^zfBM za)jP>X(UAx!%U!c(N-JFlJ04WL$6$srnq4;ph8KQYxoJ%$b*r3@e@vncffp4Ba5Q? zLV`9Sia-?QqDYBOK9PuU9QI$hxzAaWc;8?f@Gc}?%o1AoTn`OW9%*^>FQhee?8#N< zsvnoX_fajv`BZv8X3gBA0-1)Km?OsjquOsaSct+L~k|o?o@#mv{sNO8T1} z7%n&i+j|=lCGfp#*=1{_T2B-h9@{nzoFJ^Bvwz&MavHNO$59euF)~o7Ch9He<0IiD z@=4iFXFpQvprMGj`@M8#AP zXhd2gGNv+FMeq)X^anl#Mm*RO&a(Ye4u^G6k{Lo@T}o4qj&*oaxyEfZ*xHoVvx|I? z_kS$aOTJ+l_ict_y3#vTN+2aM5vdrBGL|Jh9KLLMgM~bon~-M)fy%nddNh7Lw}=KDR0Cvx%NGbQ8sKEV!JO`%~0=k5s>p? zB%Yuv0AY#GNlHAyFW!5rC?z~*a*dPsIXrw}?0Xh_Td_Dv+wAMK<)`l6E-n|f{=}PR zk3}jVHA$MKHKBams5b5#jHDJMwN$XApS77-qD(EPb##~IJK9Wf?-!n8y~j<(V1LS@ zpMonZ16f50WUiqF(d(!v5ayJ5KR}I^g&uZS&6WulG(c*%ldy6Ww?+MX$cE7}j znDA2)3>jHkM{Wr#de{|jmO$AXcYoehu|T5dWQ{pK5Ll=mBp9c?Rg>yzB?>>w8|iFJIw{V&Ell=t=lLp>bh*gk`c;sZ7``shW?MQ z;41koafMR}n~N$0s> zDc#1!T2iS#OiX4~i;yKG@IuC74_o1|b*P3Y(xQ`1%o|ze(STdon_*&QvBJv|vGPCb zqQlSiDnY*)P3c9QSmy+T2-`l@Vm%Smk;+8>P_ee`S%( zbwx-VHRh6NPQS4*#e34atX043)Lhuv)E?cY-*EU$L_a!xKo)x*Y#@1z8@=j=_KJT_ zivoIc{3mvy5?%fOJpq3#OsyMWu$8{%vLu{7!yxykVKGmoMyb;PEHx7)(d8M z03iCXbTjP@IEQ6t2242jUQtfE3E9iY!D*U16_}YvjOjvY)1THX6*LWp@V3Y}Csu#mZg*i5gJ2Gcm%n2h ztemz9YH7AO8s`T_d{|T4mYo}Mnx=tsy+G$;PF|i@gAj_I3bR?Q7MWVdEhb+d50H>>4uTE1lmCTp^ zu;nOLRy+vn)|iV-LTpD!VPL-l;RpQ7vq3>4fY_c1WmV5Ase^WR5xEI*v?uc@*ko}G z-g`MdbFKrWJKvc5EODY}laknxBG|A^jQx>$ZJ8ju%L{*W&gzOe9?6rzels5){(`g^ z=x}y$%1^5a&kf^#JBb?R3b(7CPEh)C8VB)5K1ehE2Sk&zv}OjU?H@Nf6zt!=xL%yRLRxP1qGUX-~r-^P1n@ z9yR+;7|MSO5W>2WjE_g7(k-2*=-U_OA}cp{4nw@7_AG7KuI-6DBYjA~8U&%RSMY}9 zU>XRt`#UL*HPV0QyVi<>L-@`O1=$-SCDZ zh2de&Fi*!8hdRMa*x0rBUCY_BsN%48{B|~-WAlIH0MI%Y$r-qJ_B8j?44<#WJCF9E zGt2K$EYFV~&%HZ&{B^_yDu)WjQOd|DVSoe>?Uo=sFt5F4!P`9!C~m3P4>|17MF`i2 zN#${X`l-btzk=y3k(Bp|oiN-ZhnDI-?D>u^^Iv2-JGK=0PK(K%bT)RBCOad@A7A6~ zXM=y0+Q$pwj;TfU@^5vdM=$)jJcK$^h*$-X%6<};bk7kW8;AfdkTN!K1Hak6oWyYN`zsc86tl6OI=OGaJ@FsgU%3wM9V z$~ex}U@d>T<@&CsJDyj#j2qL^;QA*YS+Xqic4s;JZ5F1~*;%EX$w}`&^Z9ylvhOYj z6>RQU*?oWwwEwR0FQqp574y@s};kn?zmc`hUatpa~tm;|~A; diff --git a/dev/search_index.js b/dev/search_index.js index a6537c8d6..0dbebc0d9 100644 --- a/dev/search_index.js +++ b/dev/search_index.js @@ -1,3 +1,3 @@ var documenterSearchIndex = {"docs": -[{"location":"connectors/sign_convention/#Sign-Convention","page":"Sign Convention","title":"Sign Convention","text":"","category":"section"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"A sign convention is recommended for this library that implements the following rule:","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"An input component that specifies the through variable should be such that an oppossite equality is written such that when connected to a conserved quantity component (i.e. a mass or capacitor component) a positive value for a flow variable represents the accumulation of that conserved quantity over time in the component.","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"Note: that this implements the same convention as applied in Modelica Standard Library.","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"For example, the following would be the correct sign convention for the Mechanical.Translational force variable f","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"@mtkmodel ConstantForce begin\n @parameters begin\n f = 0\n end\n @components begin\n flange = MechanicalPort()\n end\n @equations begin\n # connectors\n flange.f ~ -f # <-- force is leaving\n end\nend","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"And writing the following would be the incorrect sign convention.","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"@equations begin\n # connectors\n flange.f ~ f # <-- wrong through variable input sign!\nend","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"","category":"page"},{"location":"connectors/sign_convention/#Discussion","page":"Sign Convention","title":"Discussion","text":"","category":"section"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"The energy dissipation equation that governs the acausal connection definitions should be such that a positive through variable input will lead to an increasing across variable value.","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"fracpartial blue acrosspartial t = text green through input","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"This is demonstrated in the following domains of Mechanical, Electrical, and Hydraulic.","category":"page"},{"location":"connectors/sign_convention/#Mechanical","page":"Sign Convention","title":"Mechanical","text":"","category":"section"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"The flow variable (i.e. force) input component for the Mechanical domain is","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"using ModelingToolkit\nusing ModelingToolkitStandardLibrary.Mechanical.Translational\nusing ModelingToolkit: t_nounits as t\n\n@mtkmodel ConstantForce begin\n @parameters begin\n f\n end\n @components begin\n flange = MechanicalPort()\n end\n @equations begin\n # connectors\n flange.f ~ -f\n end\nend","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"Here we can see that a positive input force results in an increasing velocity.","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"@mtkmodel System begin\n @components begin\n mass = Mass(; m = 10)\n force = ConstantForce(; f = 1)\n end\n @equations begin\n connect(mass.flange, force.flange)\n end\nend\n@mtkbuild sys = System()\nfull_equations(sys)","category":"page"},{"location":"connectors/sign_convention/#Electrical","page":"Sign Convention","title":"Electrical","text":"","category":"section"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"The flow variable (i.e. current) input component for the Electrical domain is","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"using ModelingToolkitStandardLibrary.Electrical\n\n@mtkmodel ConstantCurrent begin\n @parameters begin\n i\n end\n @components begin\n p = Pin()\n n = Pin()\n end\n @equations begin\n 0 ~ p.i + n.i\n i ~ -n.i # can also be written as i ~ p.i\n end\nend","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"Here we can see that a positive input current results in an increasing voltage. Note that the electrical domain uses pins p and n at each side of the source and energy storage components. The direction of connection is not important here, only that a positive connector p connects with a negative connector n.","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"@mtkmodel System begin\n @components begin\n capacitor = Capacitor(; C = 10)\n current = ConstantCurrent(; i = 1)\n ground = Ground()\n end\n @equations begin\n connect(current.n, capacitor.p)\n connect(capacitor.n, current.p, ground.g)\n end\nend\n@mtkbuild sys = System()\nfull_equations(sys)","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"Reversing the pins gives the same result","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"@mtkmodel System begin\n @components begin\n capacitor = Capacitor(; C = 10)\n current = ConstantCurrent(; i = 1)\n ground = Ground()\n end\n @equations begin\n connect(current.p, capacitor.n)\n connect(capacitor.p, current.n, ground.g)\n end\nend\n@mtkbuild sys = System()\nfull_equations(sys)","category":"page"},{"location":"connectors/sign_convention/#Hydraulic","page":"Sign Convention","title":"Hydraulic","text":"","category":"section"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"The flow variable (i.e. mass flow) input component for the Hydraulic domain is","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"using ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible\n\n@mtkmodel ConstantMassFlow begin\n @parameters begin\n dm\n end\n @components begin\n port = HydraulicPort()\n end\n @equations begin\n port.dm ~ -dm\n end\nend","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"A positive input mass flow leads to an increasing pressure (in this case we get increasing density (rho), which is directly related to an increasing pressure).","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"@mtkmodel System begin\n @components begin\n volume = FixedVolume(; vol = 10.0)\n flow = ConstantMassFlow(; dm = 1)\n fluid = HydraulicFluid()\n end\n @equations begin\n connect(flow.port, volume.port)\n connect(fluid, flow.port)\n end\nend\n@mtkbuild sys = System()\nfull_equations(sys) |> first","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\n@mtkmodel HeatConductionModel begin\n @parameters begin\n C1 = 15\n C2 = 15\n end\n @components begin\n mass1 = HeatCapacitor(C = C1, T = 373.15)\n mass2 = HeatCapacitor(C = C2, T = 273.15)\n conduction = ThermalConductor(G = 10)\n Tsensor1 = TemperatureSensor()\n Tsensor2 = TemperatureSensor()\n end\n @equations begin\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 end\nend\n\n@mtkbuild sys = HeatConductionModel()\nprob = ODEProblem(sys, Pair[], (0, 5.0))\nsol = solve(prob)\n\nT_final_K = sol[(sys.mass1.T * sys.C1 + sys.mass2.T * sys.C2) / (sys.C1 + sys.C2)]\n\nplot(title = \"Thermal Conduction Demonstration\")\nplot!(sol, idxs = [sys.mass1.T, sys.mass2.T],\n labels = [\"Mass 1 Temperature\" \"Mass 2 Temperature\"])\nplot!(sol.t, T_final_K, label = \"Steady-State Temperature\")","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\nOpen\nTubeBase\nTube\nFlowDivider\nValve\nFixedVolume\nVolume\nDynamicVolume\nSpoolValve\nSpoolValve2Way\nActuator","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.Open","page":"Hydraulic Components","title":"ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Open","text":"Open(; p_int, name)\n\nProvides an \"open\" boundary condition for a hydraulic port such that mass flow dm is non-zero. This is opposite from an un-connected hydraulic port or the Cap boundary component which sets the mass flow dm to zero. \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; 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\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; 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\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.FlowDivider","page":"Hydraulic Components","title":"ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.FlowDivider","text":"FlowDivider(;p_int, n, name)\n\nReduces the flow from port_a to port_b by n. Useful for modeling parallel tubes efficiently by placing a FlowDivider on each end of a tube.\n\nParameters:\n\np_int: [Pa] initial pressure\nn: divide flow from port_a to port_b by n\n\nConnectors:\n\nport_a: full flow hydraulic port\nport_b: part flow hydraulic port\n\n\n\n\n\n","category":"function"},{"location":"API/hydraulic/#ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Valve","page":"Hydraulic Components","title":"ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Valve","text":"Valve(reversible = false; p_a_int, p_b_int, area_int, Cd, Cd_reverse = Cd, minimum_area = 0, name)\n\nValve with area input and discharge coefficient Cd defined by https://en.wikipedia.org/wiki/Dischargecoefficient. The `Cdreverse` parameter allows for directional flow restriction, making it possible to define a check valve.\n\nParameters:\n\np_a_int: [Pa] initial pressure for port_a\np_b_int: [Pa] initial pressure for port_b\narea_int: [m^2] initial valve opening\nCd: discharge coefficient flowing from a → b\nCd_reverse: discharge coefficient flowing from b → a\nminimum_area: when reversible = false applies a forced minimum area\n\nConnectors:\n\nport_a: hydraulic port\nport_b: hydraulic port\narea: real input setting the valve area. When reversible = true, negative input reverses flow direction, otherwise a floor of minimum_area is enforced.\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, name)\n\nFixed fluid volume.\n\nParameters:\n\nvol: [m^3] fixed volume\n\nConnectors:\n\nport: hydraulic port\n\n\n\n\n\n","category":"function"},{"location":"API/hydraulic/#ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Volume","page":"Hydraulic Components","title":"ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Volume","text":"Volume(; x, dx=0, p, drho=0, dm=0, area, direction = +1, 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: [Pa] initial pressure\narea: [m^2] moving wall area\nx: [m] initial wall position\ndx=0: [m/s] initial wall velocity\ndrho=0: [kg/m^3/s] initial density derivative\ndm=0: [kg/s] initial flow\ndirection: [+/-1] applies the direction conversion from the flange to x\n\nConnectors:\n\nport: hydraulic port\nflange: mechanical translational port\n\nSee also FixedVolume, DynamicVolume\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, add_inertia=true; p_int, area, x_int = 0, x_max, x_min = 0, x_damp = x_min, direction = +1, perimeter = 2 * sqrt(area * pi), shape_factor = 64, head_factor = 1, Cd = 1e2, Cd_reverse = 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\narea: [m^2] moving wall area\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/#ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.SpoolValve","page":"Hydraulic Components","title":"ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.SpoolValve","text":"SpoolValve(reversible = false; p_a_int, p_b_int, x_int, Cd, d, name)\n\nSpool valve with x valve opening input as mechanical flange port and d diameter of orifice. See Valve for more information.\n\nParameters:\n\np_a_int: [Pa] initial pressure for port_a\np_b_int: [Pa] initial pressure for port_b\nx_int: [m] initial valve opening\nd: [m] orifice diameter\nCd: discharge coefficient flowing from a → b\n\nConnectors:\n\nport_a: hydraulic port\nport_b: hydraulic port\nflange: mechanical translational port\n\nSee Valve for more information.\n\n\n\n\n\n","category":"function"},{"location":"API/hydraulic/#ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.SpoolValve2Way","page":"Hydraulic Components","title":"ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.SpoolValve2Way","text":"SpoolValve2Way(reversible = false; p_s_int, p_a_int, p_b_int, p_r_int, m, g, x_int, Cd, d, name)\n\n2-ways spool valve with 4 ports and spool mass. Fluid flow direction S → A and B → R when x is positive and S → B and A → R when x is negative. \n\nParameters:\n\np_s_int: [Pa] initial pressure for port_s\np_a_int: [Pa] initial pressure for port_a\np_b_int: [Pa] initial pressure for port_b\np_r_int: [Pa] initial pressure for port_r\nm: [kg] mass of the spool\ng: [m/s²] gravity field acting on the spool, positive value acts in the positive direction\nx_int: [m] initial valve opening\nd: [m] orifice diameter\nCd: discharge coefficient flowing from s → a and b → r\n\nConnectors:\n\nport_s: hydraulic port\nport_a: hydraulic port\nport_b: hydraulic port\nport_r: hydraulic port\nflange: mechanical translational port\n\nSee SpoolValve for more information.\n\n\n\n\n\n","category":"function"},{"location":"API/hydraulic/#ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Actuator","page":"Hydraulic Components","title":"ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Actuator","text":"Actuator(N, add_inertia = true, reversible = false;\n p_a_int,\n p_b_int,\n area_a,\n area_b,\n perimeter_a = 2 * sqrt(area_a * pi),\n perimeter_b = 2 * sqrt(area_b * pi),\n length_a_int,\n length_b_int,\n shape_factor_a = 64,\n shape_factor_b = 64,\n head_factor_a = 1,\n head_factor_b = 1,\n m,\n g,\n x_int = 0,\n minimum_volume_a = 0,\n minimum_volume_b = 0,\n damping_volume_a = minimum_volume_a,\n damping_volume_b = minimum_volume_b,\n Cd = 1e4,\n Cd_reverse = Cd,\n name)\n\nActuator made of two DynamicVolumes connected in opposite direction with body mass attached.\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_a_int: [Pa] initial pressure for port_a\np_b_int: [Pa] initial pressure for port_b\narea_a: [m^2] moving wall area of volume A\narea_b: [m^2] moving wall area of volume B\nlength_a_int: [m] initial wall position for A\nlength_b_int: [m] initial wall position for b\n\nmass\n\nm: [kg] mass of the body\ng: [m/s²] gravity field acting on the mass, positive value acts in the positive direction\nx_int: [m] initial flange position\n\nflow resistance\n\nperimeter_a: [m] perimeter of the cross section A (needed only for non-circular volumes)\nperimeter_b: [m] perimeter of the cross section B (needed only for non-circular volumes)\nshape_factor_a: shape factor of A, see friction_factor function\nshape_factor_b: shape factor of B, see friction_factor function\nhead_factor_a: effective length multiplier for A, used to account for addition friction from flow development and additional friction such as pipe bends, entrance/exit lossses, etc.\nhead_factor_b: effective length multiplier for B, 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\nminimum_volume_a: [m^3] minimum volume A that shuts off flow and prevents negative volume.\nminimum_volume_b: [m^3] minimum volume B that shuts off flow and prevents negative volume.\ndamping_volume_a: [m^3] volume of A that initiates a linear damping region before reaching full flow shut off. Helps provide a smooth end stop.\ndamping_volume_b: [m^3] volume of B that initiates a linear damping region before reaching full flow shut off. Helps provide a smooth end stop.\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_a: hydraulic port\nport_b: 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(; name)\n\ninput pressure source\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\nRealInputArray\nRealOutputArray\nSISO\nMIMO","category":"page"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.RealInput","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.RealInput","text":"RealInput(;name, guess)\n\nConnector with one input signal of type Real.\n\nParameters:\n\nguess=0: Guess value for u.\n\nStates:\n\nu: Value of the connector which 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, guess)\n\nConnector with one output signal of type Real.\n\nParameters:\n\nguess=0: Guess value for u.\n\nStates:\n\nu: Value of the connector which is a scalar.\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.RealInputArray","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.RealInputArray","text":"RealInputArray(;name, nin, guess)\n\nConnector with an array of input signals of type Real.\n\nParameters:\n\nnin: Number of inputs.\nguess=zeros(nin): Guess value for u.\n\nStates:\n\nu: Value of the connector which is an array.\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.RealOutputArray","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.RealOutputArray","text":"RealOutputArray(;name, nout, guess)\n\nConnector with an array of output signals of type Real.\n\nParameters:\n\nnout: Number of outputs.\nguess=zeros(nout): Guess value for u.\n\nStates:\n\nu: Value of the connector which is an array.\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/#ModelingToolkitStandardLibrary.Blocks.MIMO","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.MIMO","text":"MIMO(; name, nin = 1, nout = 1, u_start = zeros(nin), y_start = zeros(nout))\n\nBase class for a multiple input multiple output (MIMO) continuous system block.\n\nParameters:\n\nnin: Input dimension\nnout: Output dimension\nu_start: Initial value for the input\ny_start: Initial value for the output\n\n\n\n\n\n","category":"function"},{"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":"function"},{"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","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":"@mtkmodel DCMotor begin\n @parameters begin\n R = 0.5, [description = \"Armature resistance\"] # Ohm\n L = 4.5e-3, [description = \"Armature inductance\"] # H\n k = 0.5, [description = \"Motor constant\"] # N.m/A\n J = 0.02, [description = \"Inertia\"] # kg.m²\n f = 0.01, [description = \"Friction factor\"] # N.m.s/rad\n tau_L_step = -0.3, [description = \"Amplitude of the load torque step\"] # N.m\n end\n @components begin\n ground = Ground()\n source = Voltage()\n ref = Blocks.Step(height = 1, start_time = 0)\n pi_controller = Blocks.LimPI(k = 1.1, T = 0.035, u_max = 10, Ta = 0.035)\n feedback = Blocks.Feedback()\n R1 = Resistor(R = R)\n L1 = Inductor(L = L)\n emf = EMF(k = k)\n fixed = Fixed()\n load = Torque()\n load_step = Blocks.Step(height = tau_L_step, start_time = 3)\n inertia = Inertia(J = J)\n friction = Damper(d = f)\n speed_sensor = SpeedSensor()\n end\n @equations begin\n 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 end\nend\n\n@named model = DCMotor()\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, [sys.L1.i => 0.0], (0, 6.0))\nsol = solve(prob)\n\np1 = plot(sol.t, sol[sys.inertia.w], ylabel = \"Angular Vel. in rad/s\",\n label = \"Measurement\", title = \"DC Motor with Speed Controller\")\nplot!(sol.t, sol[sys.ref.output.u], label = \"Reference\")\np2 = plot(sol.t, sol[sys.load.tau.u], ylabel = \"Disturbance in Nm\", label = \"\")\nplot(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(sys.speed_sensor.w, :y, sys.feedback.input2)\nconnect(sys.pi_controller.ctr_output, :u, sys.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(sys.inertia.phi => 0.0, sys.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":"Theory","title":"Introduction","text":"","category":"section"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Theory","text":"Modelica Connectors\nSimScape Connectors","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Through and Across Variable Theory","text":"","category":"section"},{"location":"connectors/connections/#General","page":"Theory","title":"General","text":"","category":"section"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Theory","text":"Energy Dissipation & Flow:","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Electrical","text":"","category":"section"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"For the Electrical domain, the across variable is voltage and the through variable current. Therefore","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"Energy Dissipation:","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"partial colorbluevoltage partial t cdot capacitance = colorgreencurrent","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"Flow:","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"colorgreencurrent cdot resistance = colorbluevoltage","category":"page"},{"location":"connectors/connections/#Translational","page":"Theory","title":"Translational","text":"","category":"section"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"For the translation domain, choosing velocity for the across variable and force for the through gives","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"Energy Dissipation:","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"partial colorbluevelocity partial t cdot mass = colorgreenforce","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"Flow:","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"colorgreenforce cdot (1damping) = colorbluevelocity","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"The diagram here shows the similarity of problems in different physical domains.","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"(Image: Through and Across Variables)","category":"page"},{"location":"connectors/connections/#Translational-Connector-using-*Position*-Across-Variable","page":"Theory","title":"Translational Connector using Position Across Variable","text":"","category":"section"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Theory","text":"Energy Dissipation:","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"partial^2 colorblueposition partial t^2 cdot mass = colorgreenforce","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"Flow:","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"colorgreenforce cdot (1damping) = partial colorblueposition partial t","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Examples","text":"","category":"section"},{"location":"connectors/connections/#Electrical-Domain","page":"Theory","title":"Electrical Domain","text":"","category":"section"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"We can generate the above relationship with ModelingToolkit and the ModelingToolkitStandardLibrary using 3 blocks:","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"Capacitor: for energy storage with initial voltage = 1V\nResistor: for energy flow\nGround: for energy sink","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"As can be seen, this will give a 1 equation model matching our energy dissipation relationship","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"using ModelingToolkitStandardLibrary.Electrical, ModelingToolkit, DifferentialEquations\nusing ModelingToolkit: t_nounits as t\nusing Plots\n\nsystems = @named begin\n resistor = Resistor(R = 1)\n capacitor = Capacitor(C = 1)\n ground = Ground()\nend\n\neqs = [connect(capacitor.p, resistor.p)\n connect(resistor.n, ground.g, capacitor.n)]\n\n@named model = ODESystem(eqs, t; systems)\n\nsys = structural_simplify(model)\n\nprintln.(equations(sys))\nnothing # hide","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Theory","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":"Theory","title":"Mechanical Translational Domain","text":"","category":"section"},{"location":"connectors/connections/#Across-Variable-velocity","page":"Theory","title":"Across Variable = velocity","text":"","category":"section"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Theory","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":"Theory","title":"Theory","text":"using ModelingToolkitStandardLibrary\nconst TV = ModelingToolkitStandardLibrary.Mechanical.Translational\n\nsystems = @named begin\n damping = TV.Damper(d = 1)\n body = TV.Mass(m = 1)\n ground = TV.Fixed()\nend\n\neqs = [connect(damping.flange_a, body.flange)\n connect(ground.flange, damping.flange_b)]\n\n@named model = ODESystem(eqs, t; systems)\n\nsys = structural_simplify(model)\n\nprintln.(full_equations(sys))\nnothing # hide","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"As expected, we have a similar solution…","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"prob = ODEProblem(\n sys, [], (0, 10.0), []; initialization_eqs = [sys.body.s ~ 0, sys.body.v ~ 1])\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":"Theory","title":"Across Variable = position","text":"","category":"section"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Theory","text":"const TP = ModelingToolkitStandardLibrary.Mechanical.TranslationalPosition\n\nsystems = @named begin\n damping = TP.Damper(d = 1, va = 1, vb = 0.0)\n body = TP.Mass(m = 1, v = 1)\n ground = TP.Fixed(s_0 = 0)\nend\n\neqs = [connect(damping.flange_a, body.flange)\n connect(ground.flange, damping.flange_b)]\n\n@named model = ODESystem(eqs, t; systems)\n\nsys = structural_simplify(model)\n\nprintln.(full_equations(sys))\nnothing # hide","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Theory","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":"Theory","title":"Theory","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":"Theory","title":"Theory","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":"Theory","title":"Theory","text":"@named body = TV.Mass(m = 1, v = 1, s = 0)","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"implement a PositionSensor TODO: Implement Translation Sensors","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Mechanical/Translational Library Differences (Velocity vs. Position Connectors)","text":"","category":"section"},{"location":"connectors/connections/#Initialization","page":"Theory","title":"Initialization","text":"","category":"section"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Theory","text":"(Image: Example Mechanical Model)","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Damper","text":"","category":"section"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Theory","text":"@named dv = TV.Damper(d = 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":"Theory","title":"Spring","text":"","category":"section"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Theory","text":"@named sv = TV.Spring(k = 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":"Theory","title":"Mass","text":"","category":"section"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Theory","text":"@named bv = TV.Mass(m = 1)\n@named bp = TP.Mass(m = 1, v = 1, s = 3)\nnothing # hide","category":"page"},{"location":"connectors/connections/#Fixed","page":"Theory","title":"Fixed","text":"","category":"section"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Theory","text":"@named gv = TV.Fixed()\n@named gp = TP.Fixed(s_0 = 1)\nnothing # hide","category":"page"},{"location":"connectors/connections/#Comparison","page":"Theory","title":"Comparison","text":"","category":"section"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Theory","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":"Theory","title":"Theory","text":"function simplify_and_solve(damping, spring, body, ground; initialization_eqs = Equation[])\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), []; initialization_eqs)\n sol = solve(prob; abstol = 1e-9, reltol = 1e-9)\n\n return sol\nend\nnothing # hide","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"Now let's solve the velocity domain model","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"initialization_eqs = [bv.s ~ 3\n bv.v ~ 1\n sv.delta_s ~ 1]\nsolv = simplify_and_solve(dv, sv, bv, gv; initialization_eqs);\nnothing # hide","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"And the position domain model","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"solp = simplify_and_solve(dp, sp, bp, gp);\nnothing # hide","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"Now we can plot the comparison of the 2 models and see they give the same result.","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"plot(ylabel = \"mass velocity [m/s]\")\nplot!(solv, idxs = [bv.v])\nplot!(solp, idxs = [bp.v])","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Theory","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":"Theory","title":"Theory","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":"Theory","title":"Accuracy","text":"","category":"section"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Theory","text":"beginaligned\nm cdot dotv + d cdot v + k cdot Delta s = 0 \ndotDelta s = v\nendaligned","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"And for the position domain are","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Theory","text":"By definition, the spring stretch is","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"Delta s = s - s_b_0 - l","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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 (much less than the tolerance of 1e-9).","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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 = \"\")","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 OrdinaryDiffEq\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":"@mtkmodel NonlinearResistor begin\n @extend OnePort()\n @parameters begin\n Ga\n Gb\n Ve\n end\n @equations begin\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 end\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":"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":"@extend OnePort()","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"This extends OnePort and unpacks v and i variables.","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":"@parameters begin\n Ga\n Gb\n Ve\nend","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"This creates symbolic parameters with the name Ga, Gb and Ve whose default values are set from the function's arguments Ga, Gb and Ve, respectively. This 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.","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":"@mtkmodel ChaoticAttractor begin\n @components begin\n inductor = Inductor(L = 18, i = 0)\n resistor = Resistor(R = 12.5e-3)\n conductor = Conductor(G = 0.565)\n capacitor1 = Capacitor(C = 10, v = 4)\n capacitor2 = Capacitor(C = 100, v = 0)\n non_linear_resistor = NonlinearResistor(\n Ga = -0.757576,\n Gb = -0.409091,\n Ve = 1\n )\n ground = Ground()\n end\n @equations begin\n connect(inductor.p, conductor.p)\n connect(conductor.n, non_linear_resistor.p)\n connect(capacitor1.p, conductor.n)\n connect(inductor.n, resistor.p)\n connect(conductor.p, capacitor2.p)\n connect(capacitor1.n, capacitor2.n, non_linear_resistor.n, resistor.n, ground.g)\n end\nend\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":"@mtkbuild builds a structurally simplified ChaoticAttractor model. Since the initial voltage of the capacitors was already specified via v and the initial current of inductor via i, no initial condition is given and an empty pair is supplied.","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"@mtkbuild sys = ChaoticAttractor()\nprob = ODEProblem(sys, Pair[], (0, 5e4))\nsol = solve(prob; saveat = 1.0)\n\nplot(sol[sys.capacitor1.v], sol[sys.capacitor2.v], title = \"Chaotic Attractor\", label = \"\",\n ylabel = \"C1 Voltage in V\", xlabel = \"C2 Voltage in V\")","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"plot(sol; idxs = [sys.capacitor1.v, sys.capacitor2.v, sys.inductor.i],\n labels = [\"C1 Voltage in V\" \"C2 Voltage in V\" \"Inductor Current in A\"])","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\n@mtkmodel RC begin\n @parameters begin\n R = 1.0\n C = 1.0\n V = 1.0\n end\n @components begin\n resistor = Resistor(R = R)\n capacitor = Capacitor(C = C, v = 0.0)\n source = Voltage()\n constant = Constant(k = V)\n ground = Ground()\n end\n @equations begin\n 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 end\nend\n\n@mtkbuild sys = RC()\nprob = ODEProblem(sys, Pair[], (0, 10.0))\nsol = solve(prob)\n\nplot(sol, idxs = [sys.capacitor.v, sys.resistor.i],\n title = \"RC Circuit Demonstration\",\n labels = [\"Capacitor Voltage\" \"Resistor Current\"])","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\nPosition","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/#ModelingToolkitStandardLibrary.Mechanical.Rotational.Position","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.Position","text":"Position(; name, exact = false, f_crit = 50, use_support = false)\n\nForced movement of a flange according to a reference angle signal.\n\nThe input signal phi_ref defines the reference angle in [rad]. Flange is forced to move according to this reference motion relative to flange support. According to parameter exact (default = false), this is done in the following way:\n\nexact=true: The reference angle is treated exactly. This is only possible if the input signal is defined by an analytical function that can be differentiated at least twice in order to compute the acceleration.\nexact=false: The reference angle is filtered and the second derivative of the filtered curve is used to compute the reference acceleration of the flange. This second derivative is not computed by numerical differentiation but by an appropriate realization of the filter. For filtering, a second-order Bessel filter is used. The critical frequency (also called cut-off frequency) of the filter is defined via parameter f_crit in [Hz]. This value should be selected in such a way that it is higher than the essential low frequencies in the signal.\n\nConnectors\n\nflange::Flange: Flange to be moved\nphi_ref::RealInput: Reference angle of flange with respect to support\n\nVariables\n\nphi(t): Rotation angle of flange with respect to support\nw(t): If exact=false, Angular velocity of flange with respect to support\na(t): If exact=false, Angular acceleration of flange with respect to support\n\nParameters\n\nexact: (structural) true/false exact treatment/filtering the input signal\nf_crit: [Hz] if exact=false, Critical frequency of 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, m, g = 0)\n\nSliding mass with inertia\n\nParameters:\n\nm: [kg] mass of sliding body\ng = 0: [m/s^2] [m/s²] gravity field acting on the mass, positive value acts in the positive direction\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 sensor, measures the force between two flanges.\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 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 acceleration 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\nusing ModelingToolkit: t_nounits as t, D_nounits as D\nfunction plant(; name)\n @variables x(t) = 1\n @variables u(t)=0 y(t)=0\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 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/#Building-Models-with-Discrete-Data,-Interpolations,-and-Lookup-Tables","page":"SampledData Component","title":"Building Models with Discrete Data, Interpolations, and Lookup Tables","text":"","category":"section"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"There are 4 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.Interpolation\nusing ModelingToolkitStandardLibrary.Blocks.ParametrizedInterpolation\nusing a custom component with external data (not recommended)\nusing ModelingToolkitStandardLibrary.Blocks.SampledData (legacy)","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/#Interpolation-Block","page":"SampledData Component","title":"Interpolation Block","text":"","category":"section"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"The ModelingToolkitStandardLibrary.Blocks.Interpolation component is easy to use and is performant. It is similar to using callable parameters, but it provides a block interface with RealInput and RealOutput connectors. The Interpolation is compatible with interpolation types from DataInterpolation.","category":"page"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"ModelingToolkitStandardLibrary.Blocks.Interpolation","category":"page"},{"location":"tutorials/input_component/#ModelingToolkitStandardLibrary.Blocks.Interpolation","page":"SampledData Component","title":"ModelingToolkitStandardLibrary.Blocks.Interpolation","text":"Interpolation(interp_type, u, x, args...; name)\n\nRepresent function interpolation symbolically as a block component. By default interpolation types from DataInterpolations.jl are supported, but in general any callable type that builds the interpolation object via itp = interpolation_type(u, x, args...) and calls the interpolation with itp(t) should work. This does not need to represent an interpolation, it can be any type that satisfies the interface, such as lookup tables.\n\nArguments:\n\ninterp_type: the type of the interpolation. For DataInterpolations,\n\nthese would be any of the available interpolations, such as LinearInterpolation, ConstantInterpolation or CubicSpline.\n\nu: the data used for interpolation. For DataInterpolations this will be an AbstractVector\nx: the values that each data points correspond to, usually the times corresponding to each value in u.\nargs: any other arguments needed to build the interpolation\n\nKeyword arguments:\n\nname: the name of the component\n\nParameters:\n\ninterpolator: the symbolic representation of the interpolation object, callable as interpolator(t)\n\nConnectors:\n\ninput: a RealInput connector corresponding to the input variable\noutput: a RealOutput connector corresponding to the interpolated value\n\n\n\n\n\n","category":"function"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"Here is an example on how to use it. Let's consider a mass-spring-damper system, where we have an external force as an input. We then generate some example data in a DataFrame that would represent a measurement of the input. In a more realistic case, this DataFrame would be read from a file.","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\nusing DataFrames\nusing Plots\n\nfunction MassSpringDamper(; name)\n @named input = RealInput()\n @variables f(t)=0 x(t)=0 dx(t)=0 ddx(t)=0\n @parameters m=10 k=1000 d=1\n\n eqs = [\n f ~ input.u\n ddx * 10 ~ k * x + d * dx + f\n D(x) ~ dx\n D(dx) ~ ddx]\n\n ODESystem(eqs, t; name, systems = [input])\nend\n\nfunction MassSpringDamperSystem(data, time; name)\n @named src = Interpolation(LinearInterpolation, data, time)\n @named clk = ContinuousClock()\n @named model = MassSpringDamper()\n\n eqs = [\n connect(src.input, clk.output)\n connect(src.output, model.input)\n ]\n\n ODESystem(eqs, t, [], []; name, systems = [src, clk, model])\nend\n\nfunction generate_data()\n dt = 4e-4\n time = 0:dt:0.1\n data = sin.(2 * pi * time * 100)\n\n return DataFrame(; time, data)\nend\n\ndf = generate_data() # example data\n\n@named system = MassSpringDamperSystem(df.data, df.time)\nsys = structural_simplify(system)\nprob = ODEProblem(sys, [], (0, df.time[end]))\nsol = solve(prob)\nplot(sol)","category":"page"},{"location":"tutorials/input_component/#ParametrizedInterpolation-Block","page":"SampledData Component","title":"ParametrizedInterpolation Block","text":"","category":"section"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"The ModelingToolkitStandardLibrary.Blocks.ParametrizedInterpolation component is similar to Interpolation, but as the name suggests, it is parametrized by the data, allowing one to change the underlying data without rebuilding the model as the data is represented via vector parameters. The main advantage of this block over the Interpolation one is that one can use it for optimization problems. Currently, this supports forward mode AD via ForwardDiff, but due to the increased flexibility of the types in the component, this is not as fast as the Interpolation block, so it is recommended to use only when the added flexibility is required.","category":"page"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"ModelingToolkitStandardLibrary.Blocks.ParametrizedInterpolation","category":"page"},{"location":"tutorials/input_component/#ModelingToolkitStandardLibrary.Blocks.ParametrizedInterpolation","page":"SampledData Component","title":"ModelingToolkitStandardLibrary.Blocks.ParametrizedInterpolation","text":"ParametrizedInterpolation(interp_type, u, x, args...; name, t = ModelingToolkit.t_nounits)\n\nRepresent function interpolation symbolically as a block component, with the interpolation data represented parametrically. By default interpolation types from DataInterpolations.jl are supported, but in general any callable type that builds the interpolation object via itp = interpolation_type(u, x, args...) and calls the interpolation with itp(t) should work. This does not need to represent an interpolation, it can be any type that satisfies the interface, such as lookup tables.\n\nArguments:\n\ninterp_type: the type of the interpolation. For DataInterpolations,\n\nthese would be any of the available interpolations, such as LinearInterpolation, ConstantInterpolation or CubicSpline.\n\nu: the data used for interpolation. For DataInterpolations this will be an AbstractVector\nx: the values that each data points correspond to, usually the times corresponding to each value in u.\nargs: any other arguments beeded to build the interpolation\n\nKeyword arguments:\n\nname: the name of the component\n\nParameters:\n\ndata: the symbolic representation of the data passed at construction time via u.\nts: the symbolic representation of times corresponding to the data passed at construction time via x.\n\nConnectors:\n\ninput: a RealInput connector corresponding to the independent variable\noutput: a RealOutput connector corresponding to the interpolated value\n\n\n\n\n\n","category":"function"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"Here is an example on how to use it","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\nusing DataFrames\nusing Plots\n\nfunction MassSpringDamper(; name)\n @named input = RealInput()\n vars = @variables f(t) x(t)=0 dx(t) [guess=0] ddx(t)\n pars = @parameters m=10 k=1000 d=1\n\n eqs = [\n f ~ input.u\n ddx * 10 ~ k * x + d * dx + f\n D(x) ~ dx\n D(dx) ~ ddx]\n\n ODESystem(eqs, t, vars, pars; name, systems = [input])\nend\n\nfunction MassSpringDamperSystem(data, time; name)\n @named src = ParametrizedInterpolation(LinearInterpolation, data, time)\n @named clk = ContinuousClock()\n @named model = MassSpringDamper()\n\n eqs = [\n connect(model.input, src.output)\n connect(src.input, clk.output)\n ]\n\n ODESystem(eqs, t; name, systems = [src, clk, model])\nend\n\nfunction generate_data()\n dt = 4e-4\n time = 0:dt:0.1\n data = sin.(2 * pi * time * 100)\n\n return DataFrame(; time, data)\nend\n\ndf = generate_data() # example data\n\n@named system = MassSpringDamperSystem(df.data, df.time)\nsys = structural_simplify(system)\nprob = ODEProblem(sys, [], (0, df.time[end]))\nsol = solve(prob)\nplot(sol)","category":"page"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"If we want to run a new data set, this requires only remaking the problem and solving again","category":"page"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"prob2 = remake(prob, p = [sys.src.data => ones(length(df.data))])\nsol2 = solve(prob2)\nplot(sol2)","category":"page"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"note: Note\nNote that when changing the data, the length of the new data must be the same as the length of the original data.","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":"using ModelingToolkit\nusing ModelingToolkit: t_nounits as t, D_nounits as D\nusing ModelingToolkitStandardLibrary.Blocks\nusing OrdinaryDiffEq\n\nconst rdata = Ref{Vector{Float64}}()\n\ndt = 4e-4\ntime = 0:dt:0.1\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":"using ModelingToolkit\nusing ModelingToolkit: t_nounits as t, D_nounits as D\nusing ModelingToolkitStandardLibrary.Blocks\nusing OrdinaryDiffEq\n\nfunction System(; name)\n src = SampledData(Float64, name=:src)\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, split=false)\ns = complete(system)\n\ndt = 4e-4\ntime = 0:dt:0.1\ndata1 = sin.(2 * pi * time * 100)\ndata2 = cos.(2 * pi * time * 50)\n\nprob = ODEProblem(sys, [], (0, time[end]); split=false, tofloat = false, use_union=true)\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, build_initializeprob=false)\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":"connectors/sign_convention/#Sign-Convention","page":"Sign Convention","title":"Sign Convention","text":"","category":"section"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"A sign convention is recommended for this library that implements the following rule:","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"An input component that specifies the through variable should be such that an oppossite equality is written such that when connected to a conserved quantity component (i.e. a mass or capacitor component) a positive value for a flow variable represents the accumulation of that conserved quantity over time in the component.","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"Note: that this implements the same convention as applied in Modelica Standard Library.","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"For example, the following would be the correct sign convention for the Mechanical.Translational force variable f","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"@mtkmodel ConstantForce begin\n @parameters begin\n f = 0\n end\n @components begin\n flange = MechanicalPort()\n end\n @equations begin\n # connectors\n flange.f ~ -f # <-- force is leaving\n end\nend","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"And writing the following would be the incorrect sign convention.","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"@equations begin\n # connectors\n flange.f ~ f # <-- wrong through variable input sign!\nend","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"","category":"page"},{"location":"connectors/sign_convention/#Discussion","page":"Sign Convention","title":"Discussion","text":"","category":"section"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"The energy dissipation equation that governs the acausal connection definitions should be such that a positive through variable input will lead to an increasing across variable value.","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"fracpartial blue acrosspartial t = text green through input","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"This is demonstrated in the following domains of Mechanical, Electrical, and Hydraulic.","category":"page"},{"location":"connectors/sign_convention/#Mechanical","page":"Sign Convention","title":"Mechanical","text":"","category":"section"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"The flow variable (i.e. force) input component for the Mechanical domain is","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"using ModelingToolkit\nusing ModelingToolkitStandardLibrary.Mechanical.Translational\nusing ModelingToolkit: t_nounits as t\n\n@mtkmodel ConstantForce begin\n @parameters begin\n f\n end\n @components begin\n flange = MechanicalPort()\n end\n @equations begin\n # connectors\n flange.f ~ -f\n end\nend","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"Here we can see that a positive input force results in an increasing velocity.","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"@mtkmodel System begin\n @components begin\n mass = Mass(; m = 10)\n force = ConstantForce(; f = 1)\n end\n @equations begin\n connect(mass.flange, force.flange)\n end\nend\n@mtkbuild sys = System()\nfull_equations(sys)","category":"page"},{"location":"connectors/sign_convention/#Electrical","page":"Sign Convention","title":"Electrical","text":"","category":"section"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"The flow variable (i.e. current) input component for the Electrical domain is","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"using ModelingToolkitStandardLibrary.Electrical\n\n@mtkmodel ConstantCurrent begin\n @parameters begin\n i\n end\n @components begin\n p = Pin()\n n = Pin()\n end\n @equations begin\n 0 ~ p.i + n.i\n i ~ -n.i # can also be written as i ~ p.i\n end\nend","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"Here we can see that a positive input current results in an increasing voltage. Note that the electrical domain uses pins p and n at each side of the source and energy storage components. The direction of connection is not important here, only that a positive connector p connects with a negative connector n.","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"@mtkmodel System begin\n @components begin\n capacitor = Capacitor(; C = 10)\n current = ConstantCurrent(; i = 1)\n ground = Ground()\n end\n @equations begin\n connect(current.n, capacitor.p)\n connect(capacitor.n, current.p, ground.g)\n end\nend\n@mtkbuild sys = System()\nfull_equations(sys)","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"Reversing the pins gives the same result","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"@mtkmodel System begin\n @components begin\n capacitor = Capacitor(; C = 10)\n current = ConstantCurrent(; i = 1)\n ground = Ground()\n end\n @equations begin\n connect(current.p, capacitor.n)\n connect(capacitor.p, current.n, ground.g)\n end\nend\n@mtkbuild sys = System()\nfull_equations(sys)","category":"page"},{"location":"connectors/sign_convention/#Hydraulic","page":"Sign Convention","title":"Hydraulic","text":"","category":"section"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"The flow variable (i.e. mass flow) input component for the Hydraulic domain is","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"using ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible\n\n@mtkmodel ConstantMassFlow begin\n @parameters begin\n dm\n end\n @components begin\n port = HydraulicPort()\n end\n @equations begin\n port.dm ~ -dm\n end\nend","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"A positive input mass flow leads to an increasing pressure (in this case we get increasing density (rho), which is directly related to an increasing pressure).","category":"page"},{"location":"connectors/sign_convention/","page":"Sign Convention","title":"Sign Convention","text":"@mtkmodel System begin\n @components begin\n volume = FixedVolume(; vol = 10.0)\n flow = ConstantMassFlow(; dm = 1)\n fluid = HydraulicFluid()\n end\n @equations begin\n connect(flow.port, volume.port)\n connect(fluid, flow.port)\n end\nend\n@mtkbuild sys = System()\nfull_equations(sys) |> first","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\n@mtkmodel HeatConductionModel begin\n @parameters begin\n C1 = 15\n C2 = 15\n end\n @components begin\n mass1 = HeatCapacitor(C = C1, T = 373.15)\n mass2 = HeatCapacitor(C = C2, T = 273.15)\n conduction = ThermalConductor(G = 10)\n Tsensor1 = TemperatureSensor()\n Tsensor2 = TemperatureSensor()\n end\n @equations begin\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 end\nend\n\n@mtkbuild sys = HeatConductionModel()\nprob = ODEProblem(sys, Pair[], (0, 5.0))\nsol = solve(prob)\n\nT_final_K = sol[(sys.mass1.T * sys.C1 + sys.mass2.T * sys.C2) / (sys.C1 + sys.C2)]\n\nplot(title = \"Thermal Conduction Demonstration\")\nplot!(sol, idxs = [sys.mass1.T, sys.mass2.T],\n labels = [\"Mass 1 Temperature\" \"Mass 2 Temperature\"])\nplot!(sol.t, T_final_K, label = \"Steady-State Temperature\")","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\nOpen\nTubeBase\nTube\nFlowDivider\nValve\nFixedVolume\nVolume\nDynamicVolume\nSpoolValve\nSpoolValve2Way\nActuator","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.Open","page":"Hydraulic Components","title":"ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Open","text":"Open(; p_int, name)\n\nProvides an \"open\" boundary condition for a hydraulic port such that mass flow dm is non-zero. This is opposite from an un-connected hydraulic port or the Cap boundary component which sets the mass flow dm to zero. \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; 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\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; 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\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.FlowDivider","page":"Hydraulic Components","title":"ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.FlowDivider","text":"FlowDivider(;p_int, n, name)\n\nReduces the flow from port_a to port_b by n. Useful for modeling parallel tubes efficiently by placing a FlowDivider on each end of a tube.\n\nParameters:\n\np_int: [Pa] initial pressure\nn: divide flow from port_a to port_b by n\n\nConnectors:\n\nport_a: full flow hydraulic port\nport_b: part flow hydraulic port\n\n\n\n\n\n","category":"function"},{"location":"API/hydraulic/#ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Valve","page":"Hydraulic Components","title":"ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Valve","text":"Valve(reversible = false; p_a_int, p_b_int, area_int, Cd, Cd_reverse = Cd, minimum_area = 0, name)\n\nValve with area input and discharge coefficient Cd defined by https://en.wikipedia.org/wiki/Dischargecoefficient. The `Cdreverse` parameter allows for directional flow restriction, making it possible to define a check valve.\n\nParameters:\n\np_a_int: [Pa] initial pressure for port_a\np_b_int: [Pa] initial pressure for port_b\narea_int: [m^2] initial valve opening\nCd: discharge coefficient flowing from a → b\nCd_reverse: discharge coefficient flowing from b → a\nminimum_area: when reversible = false applies a forced minimum area\n\nConnectors:\n\nport_a: hydraulic port\nport_b: hydraulic port\narea: real input setting the valve area. When reversible = true, negative input reverses flow direction, otherwise a floor of minimum_area is enforced.\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, name)\n\nFixed fluid volume.\n\nParameters:\n\nvol: [m^3] fixed volume\n\nConnectors:\n\nport: hydraulic port\n\n\n\n\n\n","category":"function"},{"location":"API/hydraulic/#ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Volume","page":"Hydraulic Components","title":"ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Volume","text":"Volume(; x, dx=0, p, drho=0, dm=0, area, direction = +1, 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: [Pa] initial pressure\narea: [m^2] moving wall area\nx: [m] initial wall position\ndx=0: [m/s] initial wall velocity\ndrho=0: [kg/m^3/s] initial density derivative\ndm=0: [kg/s] initial flow\ndirection: [+/-1] applies the direction conversion from the flange to x\n\nConnectors:\n\nport: hydraulic port\nflange: mechanical translational port\n\nSee also FixedVolume, DynamicVolume\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, add_inertia=true; p_int, area, x_int = 0, x_max, x_min = 0, x_damp = x_min, direction = +1, perimeter = 2 * sqrt(area * pi), shape_factor = 64, head_factor = 1, Cd = 1e2, Cd_reverse = 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\narea: [m^2] moving wall area\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/#ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.SpoolValve","page":"Hydraulic Components","title":"ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.SpoolValve","text":"SpoolValve(reversible = false; p_a_int, p_b_int, x_int, Cd, d, name)\n\nSpool valve with x valve opening input as mechanical flange port and d diameter of orifice. See Valve for more information.\n\nParameters:\n\np_a_int: [Pa] initial pressure for port_a\np_b_int: [Pa] initial pressure for port_b\nx_int: [m] initial valve opening\nd: [m] orifice diameter\nCd: discharge coefficient flowing from a → b\n\nConnectors:\n\nport_a: hydraulic port\nport_b: hydraulic port\nflange: mechanical translational port\n\nSee Valve for more information.\n\n\n\n\n\n","category":"function"},{"location":"API/hydraulic/#ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.SpoolValve2Way","page":"Hydraulic Components","title":"ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.SpoolValve2Way","text":"SpoolValve2Way(reversible = false; p_s_int, p_a_int, p_b_int, p_r_int, m, g, x_int, Cd, d, name)\n\n2-ways spool valve with 4 ports and spool mass. Fluid flow direction S → A and B → R when x is positive and S → B and A → R when x is negative. \n\nParameters:\n\np_s_int: [Pa] initial pressure for port_s\np_a_int: [Pa] initial pressure for port_a\np_b_int: [Pa] initial pressure for port_b\np_r_int: [Pa] initial pressure for port_r\nm: [kg] mass of the spool\ng: [m/s²] gravity field acting on the spool, positive value acts in the positive direction\nx_int: [m] initial valve opening\nd: [m] orifice diameter\nCd: discharge coefficient flowing from s → a and b → r\n\nConnectors:\n\nport_s: hydraulic port\nport_a: hydraulic port\nport_b: hydraulic port\nport_r: hydraulic port\nflange: mechanical translational port\n\nSee SpoolValve for more information.\n\n\n\n\n\n","category":"function"},{"location":"API/hydraulic/#ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Actuator","page":"Hydraulic Components","title":"ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Actuator","text":"Actuator(N, add_inertia = true, reversible = false;\n p_a_int,\n p_b_int,\n area_a,\n area_b,\n perimeter_a = 2 * sqrt(area_a * pi),\n perimeter_b = 2 * sqrt(area_b * pi),\n length_a_int,\n length_b_int,\n shape_factor_a = 64,\n shape_factor_b = 64,\n head_factor_a = 1,\n head_factor_b = 1,\n m,\n g,\n x_int = 0,\n minimum_volume_a = 0,\n minimum_volume_b = 0,\n damping_volume_a = minimum_volume_a,\n damping_volume_b = minimum_volume_b,\n Cd = 1e4,\n Cd_reverse = Cd,\n name)\n\nActuator made of two DynamicVolumes connected in opposite direction with body mass attached.\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_a_int: [Pa] initial pressure for port_a\np_b_int: [Pa] initial pressure for port_b\narea_a: [m^2] moving wall area of volume A\narea_b: [m^2] moving wall area of volume B\nlength_a_int: [m] initial wall position for A\nlength_b_int: [m] initial wall position for b\n\nmass\n\nm: [kg] mass of the body\ng: [m/s²] gravity field acting on the mass, positive value acts in the positive direction\nx_int: [m] initial flange position\n\nflow resistance\n\nperimeter_a: [m] perimeter of the cross section A (needed only for non-circular volumes)\nperimeter_b: [m] perimeter of the cross section B (needed only for non-circular volumes)\nshape_factor_a: shape factor of A, see friction_factor function\nshape_factor_b: shape factor of B, see friction_factor function\nhead_factor_a: effective length multiplier for A, used to account for addition friction from flow development and additional friction such as pipe bends, entrance/exit lossses, etc.\nhead_factor_b: effective length multiplier for B, 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\nminimum_volume_a: [m^3] minimum volume A that shuts off flow and prevents negative volume.\nminimum_volume_b: [m^3] minimum volume B that shuts off flow and prevents negative volume.\ndamping_volume_a: [m^3] volume of A that initiates a linear damping region before reaching full flow shut off. Helps provide a smooth end stop.\ndamping_volume_b: [m^3] volume of B that initiates a linear damping region before reaching full flow shut off. Helps provide a smooth end stop.\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_a: hydraulic port\nport_b: 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(; name)\n\ninput pressure source\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\nRealInputArray\nRealOutputArray\nSISO\nMIMO","category":"page"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.RealInput","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.RealInput","text":"RealInput(;name, guess)\n\nConnector with one input signal of type Real.\n\nParameters:\n\nguess=0: Guess value for u.\n\nStates:\n\nu: Value of the connector which 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, guess)\n\nConnector with one output signal of type Real.\n\nParameters:\n\nguess=0: Guess value for u.\n\nStates:\n\nu: Value of the connector which is a scalar.\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.RealInputArray","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.RealInputArray","text":"RealInputArray(;name, nin, guess)\n\nConnector with an array of input signals of type Real.\n\nParameters:\n\nnin: Number of inputs.\nguess=zeros(nin): Guess value for u.\n\nStates:\n\nu: Value of the connector which is an array.\n\n\n\n\n\n","category":"function"},{"location":"API/blocks/#ModelingToolkitStandardLibrary.Blocks.RealOutputArray","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.RealOutputArray","text":"RealOutputArray(;name, nout, guess)\n\nConnector with an array of output signals of type Real.\n\nParameters:\n\nnout: Number of outputs.\nguess=zeros(nout): Guess value for u.\n\nStates:\n\nu: Value of the connector which is an array.\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/#ModelingToolkitStandardLibrary.Blocks.MIMO","page":"Basic Blocks","title":"ModelingToolkitStandardLibrary.Blocks.MIMO","text":"MIMO(; name, nin = 1, nout = 1, u_start = zeros(nin), y_start = zeros(nout))\n\nBase class for a multiple input multiple output (MIMO) continuous system block.\n\nParameters:\n\nnin: Input dimension\nnout: Output dimension\nu_start: Initial value for the input\ny_start: Initial value for the output\n\n\n\n\n\n","category":"function"},{"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":"function"},{"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","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":"@mtkmodel DCMotor begin\n @parameters begin\n R = 0.5, [description = \"Armature resistance\"] # Ohm\n L = 4.5e-3, [description = \"Armature inductance\"] # H\n k = 0.5, [description = \"Motor constant\"] # N.m/A\n J = 0.02, [description = \"Inertia\"] # kg.m²\n f = 0.01, [description = \"Friction factor\"] # N.m.s/rad\n tau_L_step = -0.3, [description = \"Amplitude of the load torque step\"] # N.m\n end\n @components begin\n ground = Ground()\n source = Voltage()\n ref = Blocks.Step(height = 1, start_time = 0)\n pi_controller = Blocks.LimPI(k = 1.1, T = 0.035, u_max = 10, Ta = 0.035)\n feedback = Blocks.Feedback()\n R1 = Resistor(R = R)\n L1 = Inductor(L = L)\n emf = EMF(k = k)\n fixed = Fixed()\n load = Torque()\n load_step = Blocks.Step(height = tau_L_step, start_time = 3)\n inertia = Inertia(J = J)\n friction = Damper(d = f)\n speed_sensor = SpeedSensor()\n end\n @equations begin\n 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 end\nend\n\n@named model = DCMotor()\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, [sys.L1.i => 0.0], (0, 6.0))\nsol = solve(prob)\n\np1 = plot(sol.t, sol[sys.inertia.w], ylabel = \"Angular Vel. in rad/s\",\n label = \"Measurement\", title = \"DC Motor with Speed Controller\")\nplot!(sol.t, sol[sys.ref.output.u], label = \"Reference\")\np2 = plot(sol.t, sol[sys.load.tau.u], ylabel = \"Disturbance in Nm\", label = \"\")\nplot(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(sys.speed_sensor.w, :y, sys.feedback.input2)\nconnect(sys.pi_controller.ctr_output, :u, sys.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(sys.inertia.phi => 0.0, sys.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\nDiode\nHeatingDiode","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/#ModelingToolkitStandardLibrary.Electrical.Diode","page":"Electrical Components","title":"ModelingToolkitStandardLibrary.Electrical.Diode","text":" Diode(; name, Is = 1e-6, n = 1, T = 300.15)\n\nIdeal diode based on the Shockley diode equation.\n\nStates\n\n- See [OnePort](@ref)\n\nConnectors\n\n- `p` Positive pin\n- `n` Negative pin\n\nParameters\n\n- `Is`: [`A`] Saturation current\n- `n`: Ideality factor\n- `T`: [K] Ambient temperature\n\n\n\n\n\n","category":"constant"},{"location":"API/electrical/#ModelingToolkitStandardLibrary.Electrical.HeatingDiode","page":"Electrical Components","title":"ModelingToolkitStandardLibrary.Electrical.HeatingDiode","text":"HeatingDiode(; name, Is = 1e-6, n = 1)\n\nTemperature dependent diode based on the Shockley diode equation.\n\nStates\n\n- See [OnePort](@ref)\n\nConnectors\n\n- `p` Positive pin\n- `n` Negative pin\n- `port` [HeatPort](@ref) Heat port to model the temperature dependency\n\nParameters:\n\n- `Is`: [`A`] Saturation current\n- `n`: Ideality factor\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":"Theory","title":"Introduction","text":"","category":"section"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Theory","text":"Modelica Connectors\nSimScape Connectors","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Through and Across Variable Theory","text":"","category":"section"},{"location":"connectors/connections/#General","page":"Theory","title":"General","text":"","category":"section"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Theory","text":"Energy Dissipation & Flow:","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Electrical","text":"","category":"section"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"For the Electrical domain, the across variable is voltage and the through variable current. Therefore","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"Energy Dissipation:","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"partial colorbluevoltage partial t cdot capacitance = colorgreencurrent","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"Flow:","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"colorgreencurrent cdot resistance = colorbluevoltage","category":"page"},{"location":"connectors/connections/#Translational","page":"Theory","title":"Translational","text":"","category":"section"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"For the translation domain, choosing velocity for the across variable and force for the through gives","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"Energy Dissipation:","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"partial colorbluevelocity partial t cdot mass = colorgreenforce","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"Flow:","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"colorgreenforce cdot (1damping) = colorbluevelocity","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"The diagram here shows the similarity of problems in different physical domains.","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"(Image: Through and Across Variables)","category":"page"},{"location":"connectors/connections/#Translational-Connector-using-*Position*-Across-Variable","page":"Theory","title":"Translational Connector using Position Across Variable","text":"","category":"section"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Theory","text":"Energy Dissipation:","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"partial^2 colorblueposition partial t^2 cdot mass = colorgreenforce","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"Flow:","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"colorgreenforce cdot (1damping) = partial colorblueposition partial t","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Examples","text":"","category":"section"},{"location":"connectors/connections/#Electrical-Domain","page":"Theory","title":"Electrical Domain","text":"","category":"section"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"We can generate the above relationship with ModelingToolkit and the ModelingToolkitStandardLibrary using 3 blocks:","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"Capacitor: for energy storage with initial voltage = 1V\nResistor: for energy flow\nGround: for energy sink","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"As can be seen, this will give a 1 equation model matching our energy dissipation relationship","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"using ModelingToolkitStandardLibrary.Electrical, ModelingToolkit, DifferentialEquations\nusing ModelingToolkit: t_nounits as t\nusing Plots\n\nsystems = @named begin\n resistor = Resistor(R = 1)\n capacitor = Capacitor(C = 1)\n ground = Ground()\nend\n\neqs = [connect(capacitor.p, resistor.p)\n connect(resistor.n, ground.g, capacitor.n)]\n\n@named model = ODESystem(eqs, t; systems)\n\nsys = structural_simplify(model)\n\nprintln.(equations(sys))\nnothing # hide","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Theory","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":"Theory","title":"Mechanical Translational Domain","text":"","category":"section"},{"location":"connectors/connections/#Across-Variable-velocity","page":"Theory","title":"Across Variable = velocity","text":"","category":"section"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Theory","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":"Theory","title":"Theory","text":"using ModelingToolkitStandardLibrary\nconst TV = ModelingToolkitStandardLibrary.Mechanical.Translational\n\nsystems = @named begin\n damping = TV.Damper(d = 1)\n body = TV.Mass(m = 1)\n ground = TV.Fixed()\nend\n\neqs = [connect(damping.flange_a, body.flange)\n connect(ground.flange, damping.flange_b)]\n\n@named model = ODESystem(eqs, t; systems)\n\nsys = structural_simplify(model)\n\nprintln.(full_equations(sys))\nnothing # hide","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"As expected, we have a similar solution…","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"prob = ODEProblem(\n sys, [], (0, 10.0), []; initialization_eqs = [sys.body.s ~ 0, sys.body.v ~ 1])\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":"Theory","title":"Across Variable = position","text":"","category":"section"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Theory","text":"const TP = ModelingToolkitStandardLibrary.Mechanical.TranslationalPosition\n\nsystems = @named begin\n damping = TP.Damper(d = 1, va = 1, vb = 0.0)\n body = TP.Mass(m = 1, v = 1)\n ground = TP.Fixed(s_0 = 0)\nend\n\neqs = [connect(damping.flange_a, body.flange)\n connect(ground.flange, damping.flange_b)]\n\n@named model = ODESystem(eqs, t; systems)\n\nsys = structural_simplify(model)\n\nprintln.(full_equations(sys))\nnothing # hide","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Theory","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":"Theory","title":"Theory","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":"Theory","title":"Theory","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":"Theory","title":"Theory","text":"@named body = TV.Mass(m = 1, v = 1, s = 0)","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"implement a PositionSensor TODO: Implement Translation Sensors","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Mechanical/Translational Library Differences (Velocity vs. Position Connectors)","text":"","category":"section"},{"location":"connectors/connections/#Initialization","page":"Theory","title":"Initialization","text":"","category":"section"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Theory","text":"(Image: Example Mechanical Model)","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Damper","text":"","category":"section"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Theory","text":"@named dv = TV.Damper(d = 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":"Theory","title":"Spring","text":"","category":"section"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Theory","text":"@named sv = TV.Spring(k = 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":"Theory","title":"Mass","text":"","category":"section"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Theory","text":"@named bv = TV.Mass(m = 1)\n@named bp = TP.Mass(m = 1, v = 1, s = 3)\nnothing # hide","category":"page"},{"location":"connectors/connections/#Fixed","page":"Theory","title":"Fixed","text":"","category":"section"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Theory","text":"@named gv = TV.Fixed()\n@named gp = TP.Fixed(s_0 = 1)\nnothing # hide","category":"page"},{"location":"connectors/connections/#Comparison","page":"Theory","title":"Comparison","text":"","category":"section"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Theory","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":"Theory","title":"Theory","text":"function simplify_and_solve(damping, spring, body, ground; initialization_eqs = Equation[])\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), []; initialization_eqs)\n sol = solve(prob; abstol = 1e-9, reltol = 1e-9)\n\n return sol\nend\nnothing # hide","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"Now let's solve the velocity domain model","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"initialization_eqs = [bv.s ~ 3\n bv.v ~ 1\n sv.delta_s ~ 1]\nsolv = simplify_and_solve(dv, sv, bv, gv; initialization_eqs);\nnothing # hide","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"And the position domain model","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"solp = simplify_and_solve(dp, sp, bp, gp);\nnothing # hide","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"Now we can plot the comparison of the 2 models and see they give the same result.","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"plot(ylabel = \"mass velocity [m/s]\")\nplot!(solv, idxs = [bv.v])\nplot!(solp, idxs = [bp.v])","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Theory","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":"Theory","title":"Theory","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":"Theory","title":"Accuracy","text":"","category":"section"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Theory","text":"beginaligned\nm cdot dotv + d cdot v + k cdot Delta s = 0 \ndotDelta s = v\nendaligned","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"And for the position domain are","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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":"Theory","title":"Theory","text":"By definition, the spring stretch is","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","text":"Delta s = s - s_b_0 - l","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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 (much less than the tolerance of 1e-9).","category":"page"},{"location":"connectors/connections/","page":"Theory","title":"Theory","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 = \"\")","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 OrdinaryDiffEq\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":"@mtkmodel NonlinearResistor begin\n @extend OnePort()\n @parameters begin\n Ga\n Gb\n Ve\n end\n @equations begin\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 end\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":"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":"@extend OnePort()","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"This extends OnePort and unpacks v and i variables.","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":"@parameters begin\n Ga\n Gb\n Ve\nend","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"This creates symbolic parameters with the name Ga, Gb and Ve whose default values are set from the function's arguments Ga, Gb and Ve, respectively. This 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.","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":"@mtkmodel ChaoticAttractor begin\n @components begin\n inductor = Inductor(L = 18, i = 0)\n resistor = Resistor(R = 12.5e-3)\n conductor = Conductor(G = 0.565)\n capacitor1 = Capacitor(C = 10, v = 4)\n capacitor2 = Capacitor(C = 100, v = 0)\n non_linear_resistor = NonlinearResistor(\n Ga = -0.757576,\n Gb = -0.409091,\n Ve = 1\n )\n ground = Ground()\n end\n @equations begin\n connect(inductor.p, conductor.p)\n connect(conductor.n, non_linear_resistor.p)\n connect(capacitor1.p, conductor.n)\n connect(inductor.n, resistor.p)\n connect(conductor.p, capacitor2.p)\n connect(capacitor1.n, capacitor2.n, non_linear_resistor.n, resistor.n, ground.g)\n end\nend\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":"@mtkbuild builds a structurally simplified ChaoticAttractor model. Since the initial voltage of the capacitors was already specified via v and the initial current of inductor via i, no initial condition is given and an empty pair is supplied.","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"@mtkbuild sys = ChaoticAttractor()\nprob = ODEProblem(sys, Pair[], (0, 5e4))\nsol = solve(prob; saveat = 1.0)\n\nplot(sol[sys.capacitor1.v], sol[sys.capacitor2.v], title = \"Chaotic Attractor\", label = \"\",\n ylabel = \"C1 Voltage in V\", xlabel = \"C2 Voltage in V\")","category":"page"},{"location":"tutorials/custom_component/","page":"Custom Components","title":"Custom Components","text":"plot(sol; idxs = [sys.capacitor1.v, sys.capacitor2.v, sys.inductor.i],\n labels = [\"C1 Voltage in V\" \"C2 Voltage in V\" \"Inductor Current in A\"])","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\n@mtkmodel RC begin\n @parameters begin\n R = 1.0\n C = 1.0\n V = 1.0\n end\n @components begin\n resistor = Resistor(R = R)\n capacitor = Capacitor(C = C, v = 0.0)\n source = Voltage()\n constant = Constant(k = V)\n ground = Ground()\n end\n @equations begin\n 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 end\nend\n\n@mtkbuild sys = RC()\nprob = ODEProblem(sys, Pair[], (0, 10.0))\nsol = solve(prob)\n\nplot(sol, idxs = [sys.capacitor.v, sys.resistor.i],\n title = \"RC Circuit Demonstration\",\n labels = [\"Capacitor Voltage\" \"Resistor Current\"])","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\nPosition","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/#ModelingToolkitStandardLibrary.Mechanical.Rotational.Position","page":"Mechanical Components","title":"ModelingToolkitStandardLibrary.Mechanical.Rotational.Position","text":"Position(; name, exact = false, f_crit = 50, use_support = false)\n\nForced movement of a flange according to a reference angle signal.\n\nThe input signal phi_ref defines the reference angle in [rad]. Flange is forced to move according to this reference motion relative to flange support. According to parameter exact (default = false), this is done in the following way:\n\nexact=true: The reference angle is treated exactly. This is only possible if the input signal is defined by an analytical function that can be differentiated at least twice in order to compute the acceleration.\nexact=false: The reference angle is filtered and the second derivative of the filtered curve is used to compute the reference acceleration of the flange. This second derivative is not computed by numerical differentiation but by an appropriate realization of the filter. For filtering, a second-order Bessel filter is used. The critical frequency (also called cut-off frequency) of the filter is defined via parameter f_crit in [Hz]. This value should be selected in such a way that it is higher than the essential low frequencies in the signal.\n\nConnectors\n\nflange::Flange: Flange to be moved\nphi_ref::RealInput: Reference angle of flange with respect to support\n\nVariables\n\nphi(t): Rotation angle of flange with respect to support\nw(t): If exact=false, Angular velocity of flange with respect to support\na(t): If exact=false, Angular acceleration of flange with respect to support\n\nParameters\n\nexact: (structural) true/false exact treatment/filtering the input signal\nf_crit: [Hz] if exact=false, Critical frequency of 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, m, g = 0)\n\nSliding mass with inertia\n\nParameters:\n\nm: [kg] mass of sliding body\ng = 0: [m/s^2] [m/s²] gravity field acting on the mass, positive value acts in the positive direction\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 sensor, measures the force between two flanges.\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 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 acceleration 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\nusing ModelingToolkit: t_nounits as t, D_nounits as D\nfunction plant(; name)\n @variables x(t) = 1\n @variables u(t)=0 y(t)=0\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 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/#Building-Models-with-Discrete-Data,-Interpolations,-and-Lookup-Tables","page":"SampledData Component","title":"Building Models with Discrete Data, Interpolations, and Lookup Tables","text":"","category":"section"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"There are 4 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.Interpolation\nusing ModelingToolkitStandardLibrary.Blocks.ParametrizedInterpolation\nusing a custom component with external data (not recommended)\nusing ModelingToolkitStandardLibrary.Blocks.SampledData (legacy)","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/#Interpolation-Block","page":"SampledData Component","title":"Interpolation Block","text":"","category":"section"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"The ModelingToolkitStandardLibrary.Blocks.Interpolation component is easy to use and is performant. It is similar to using callable parameters, but it provides a block interface with RealInput and RealOutput connectors. The Interpolation is compatible with interpolation types from DataInterpolation.","category":"page"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"ModelingToolkitStandardLibrary.Blocks.Interpolation","category":"page"},{"location":"tutorials/input_component/#ModelingToolkitStandardLibrary.Blocks.Interpolation","page":"SampledData Component","title":"ModelingToolkitStandardLibrary.Blocks.Interpolation","text":"Interpolation(interp_type, u, x, args...; name)\n\nRepresent function interpolation symbolically as a block component. By default interpolation types from DataInterpolations.jl are supported, but in general any callable type that builds the interpolation object via itp = interpolation_type(u, x, args...) and calls the interpolation with itp(t) should work. This does not need to represent an interpolation, it can be any type that satisfies the interface, such as lookup tables.\n\nArguments:\n\ninterp_type: the type of the interpolation. For DataInterpolations,\n\nthese would be any of the available interpolations, such as LinearInterpolation, ConstantInterpolation or CubicSpline.\n\nu: the data used for interpolation. For DataInterpolations this will be an AbstractVector\nx: the values that each data points correspond to, usually the times corresponding to each value in u.\nargs: any other arguments needed to build the interpolation\n\nKeyword arguments:\n\nname: the name of the component\n\nParameters:\n\ninterpolator: the symbolic representation of the interpolation object, callable as interpolator(t)\n\nConnectors:\n\ninput: a RealInput connector corresponding to the input variable\noutput: a RealOutput connector corresponding to the interpolated value\n\n\n\n\n\n","category":"function"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"Here is an example on how to use it. Let's consider a mass-spring-damper system, where we have an external force as an input. We then generate some example data in a DataFrame that would represent a measurement of the input. In a more realistic case, this DataFrame would be read from a file.","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\nusing DataFrames\nusing Plots\n\nfunction MassSpringDamper(; name)\n @named input = RealInput()\n @variables f(t)=0 x(t)=0 dx(t)=0 ddx(t)=0\n @parameters m=10 k=1000 d=1\n\n eqs = [\n f ~ input.u\n ddx * 10 ~ k * x + d * dx + f\n D(x) ~ dx\n D(dx) ~ ddx]\n\n ODESystem(eqs, t; name, systems = [input])\nend\n\nfunction MassSpringDamperSystem(data, time; name)\n @named src = Interpolation(LinearInterpolation, data, time)\n @named clk = ContinuousClock()\n @named model = MassSpringDamper()\n\n eqs = [\n connect(src.input, clk.output)\n connect(src.output, model.input)\n ]\n\n ODESystem(eqs, t, [], []; name, systems = [src, clk, model])\nend\n\nfunction generate_data()\n dt = 4e-4\n time = 0:dt:0.1\n data = sin.(2 * pi * time * 100)\n\n return DataFrame(; time, data)\nend\n\ndf = generate_data() # example data\n\n@named system = MassSpringDamperSystem(df.data, df.time)\nsys = structural_simplify(system)\nprob = ODEProblem(sys, [], (0, df.time[end]))\nsol = solve(prob)\nplot(sol)","category":"page"},{"location":"tutorials/input_component/#ParametrizedInterpolation-Block","page":"SampledData Component","title":"ParametrizedInterpolation Block","text":"","category":"section"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"The ModelingToolkitStandardLibrary.Blocks.ParametrizedInterpolation component is similar to Interpolation, but as the name suggests, it is parametrized by the data, allowing one to change the underlying data without rebuilding the model as the data is represented via vector parameters. The main advantage of this block over the Interpolation one is that one can use it for optimization problems. Currently, this supports forward mode AD via ForwardDiff, but due to the increased flexibility of the types in the component, this is not as fast as the Interpolation block, so it is recommended to use only when the added flexibility is required.","category":"page"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"ModelingToolkitStandardLibrary.Blocks.ParametrizedInterpolation","category":"page"},{"location":"tutorials/input_component/#ModelingToolkitStandardLibrary.Blocks.ParametrizedInterpolation","page":"SampledData Component","title":"ModelingToolkitStandardLibrary.Blocks.ParametrizedInterpolation","text":"ParametrizedInterpolation(interp_type, u, x, args...; name, t = ModelingToolkit.t_nounits)\n\nRepresent function interpolation symbolically as a block component, with the interpolation data represented parametrically. By default interpolation types from DataInterpolations.jl are supported, but in general any callable type that builds the interpolation object via itp = interpolation_type(u, x, args...) and calls the interpolation with itp(t) should work. This does not need to represent an interpolation, it can be any type that satisfies the interface, such as lookup tables.\n\nArguments:\n\ninterp_type: the type of the interpolation. For DataInterpolations,\n\nthese would be any of the available interpolations, such as LinearInterpolation, ConstantInterpolation or CubicSpline.\n\nu: the data used for interpolation. For DataInterpolations this will be an AbstractVector\nx: the values that each data points correspond to, usually the times corresponding to each value in u.\nargs: any other arguments beeded to build the interpolation\n\nKeyword arguments:\n\nname: the name of the component\n\nParameters:\n\ndata: the symbolic representation of the data passed at construction time via u.\nts: the symbolic representation of times corresponding to the data passed at construction time via x.\n\nConnectors:\n\ninput: a RealInput connector corresponding to the independent variable\noutput: a RealOutput connector corresponding to the interpolated value\n\n\n\n\n\n","category":"function"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"Here is an example on how to use it","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\nusing DataFrames\nusing Plots\n\nfunction MassSpringDamper(; name)\n @named input = RealInput()\n vars = @variables f(t) x(t)=0 dx(t) [guess=0] ddx(t)\n pars = @parameters m=10 k=1000 d=1\n\n eqs = [\n f ~ input.u\n ddx * 10 ~ k * x + d * dx + f\n D(x) ~ dx\n D(dx) ~ ddx]\n\n ODESystem(eqs, t, vars, pars; name, systems = [input])\nend\n\nfunction MassSpringDamperSystem(data, time; name)\n @named src = ParametrizedInterpolation(LinearInterpolation, data, time)\n @named clk = ContinuousClock()\n @named model = MassSpringDamper()\n\n eqs = [\n connect(model.input, src.output)\n connect(src.input, clk.output)\n ]\n\n ODESystem(eqs, t; name, systems = [src, clk, model])\nend\n\nfunction generate_data()\n dt = 4e-4\n time = 0:dt:0.1\n data = sin.(2 * pi * time * 100)\n\n return DataFrame(; time, data)\nend\n\ndf = generate_data() # example data\n\n@named system = MassSpringDamperSystem(df.data, df.time)\nsys = structural_simplify(system)\nprob = ODEProblem(sys, [], (0, df.time[end]))\nsol = solve(prob)\nplot(sol)","category":"page"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"If we want to run a new data set, this requires only remaking the problem and solving again","category":"page"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"prob2 = remake(prob, p = [sys.src.data => ones(length(df.data))])\nsol2 = solve(prob2)\nplot(sol2)","category":"page"},{"location":"tutorials/input_component/","page":"SampledData Component","title":"SampledData Component","text":"note: Note\nNote that when changing the data, the length of the new data must be the same as the length of the original data.","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":"using ModelingToolkit\nusing ModelingToolkit: t_nounits as t, D_nounits as D\nusing ModelingToolkitStandardLibrary.Blocks\nusing OrdinaryDiffEq\n\nconst rdata = Ref{Vector{Float64}}()\n\ndt = 4e-4\ntime = 0:dt:0.1\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":"using ModelingToolkit\nusing ModelingToolkit: t_nounits as t, D_nounits as D\nusing ModelingToolkitStandardLibrary.Blocks\nusing OrdinaryDiffEq\n\nfunction System(; name)\n src = SampledData(Float64, name=:src)\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, split=false)\ns = complete(system)\n\ndt = 4e-4\ntime = 0:dt:0.1\ndata1 = sin.(2 * pi * time * 100)\ndata2 = cos.(2 * pi * time * 50)\n\nprob = ODEProblem(sys, [], (0, time[end]); split=false, tofloat = false, use_union=true)\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, build_initializeprob=false)\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/ddc47e41.svg b/dev/tutorials/custom_component/83c5f194.svg similarity index 99% rename from dev/tutorials/custom_component/ddc47e41.svg rename to dev/tutorials/custom_component/83c5f194.svg index 4097b35e1..ad3e9cdc0 100644 --- a/dev/tutorials/custom_component/ddc47e41.svg +++ b/dev/tutorials/custom_component/83c5f194.svg @@ -1,52 +1,52 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/tutorials/custom_component/e01d3e9d.svg b/dev/tutorials/custom_component/bad07661.svg similarity index 99% rename from dev/tutorials/custom_component/e01d3e9d.svg rename to dev/tutorials/custom_component/bad07661.svg index 1e0648aad..2bcf70622 100644 --- a/dev/tutorials/custom_component/e01d3e9d.svg +++ b/dev/tutorials/custom_component/bad07661.svg @@ -1,47 +1,47 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/tutorials/custom_component/index.html b/dev/tutorials/custom_component/index.html index d8ee78722..19f513810 100644 --- a/dev/tutorials/custom_component/index.html +++ b/dev/tutorials/custom_component/index.html @@ -56,5 +56,5 @@ sol = solve(prob; saveat = 1.0) plot(sol[sys.capacitor1.v], sol[sys.capacitor2.v], title = "Chaotic Attractor", label = "", - ylabel = "C1 Voltage in V", xlabel = "C2 Voltage in V")Example block output
plot(sol; idxs = [sys.capacitor1.v, sys.capacitor2.v, sys.inductor.i],
-    labels = ["C1 Voltage in V" "C2 Voltage in V" "Inductor Current in A"])
Example block output + ylabel = "C1 Voltage in V", xlabel = "C2 Voltage in V")Example block output
plot(sol; idxs = [sys.capacitor1.v, sys.capacitor2.v, sys.inductor.i],
+    labels = ["C1 Voltage in V" "C2 Voltage in V" "Inductor Current in A"])
Example block output diff --git a/dev/tutorials/dc_motor_pi/427b02ca.svg b/dev/tutorials/dc_motor_pi/75b0ce2f.svg similarity index 85% rename from dev/tutorials/dc_motor_pi/427b02ca.svg rename to dev/tutorials/dc_motor_pi/75b0ce2f.svg index 30da0b61f..773501c56 100644 --- a/dev/tutorials/dc_motor_pi/427b02ca.svg +++ b/dev/tutorials/dc_motor_pi/75b0ce2f.svg @@ -1,83 +1,83 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/tutorials/dc_motor_pi/681e5378.svg b/dev/tutorials/dc_motor_pi/82eaf873.svg similarity index 85% rename from dev/tutorials/dc_motor_pi/681e5378.svg rename to dev/tutorials/dc_motor_pi/82eaf873.svg index 40a1c4445..a9ebad15b 100644 --- a/dev/tutorials/dc_motor_pi/681e5378.svg +++ b/dev/tutorials/dc_motor_pi/82eaf873.svg @@ -1,55 +1,55 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/tutorials/dc_motor_pi/1f6b1c64.svg b/dev/tutorials/dc_motor_pi/c429a4a0.svg similarity index 86% rename from dev/tutorials/dc_motor_pi/1f6b1c64.svg rename to dev/tutorials/dc_motor_pi/c429a4a0.svg index 3f9c044d5..4ecf0e4dc 100644 --- a/dev/tutorials/dc_motor_pi/1f6b1c64.svg +++ b/dev/tutorials/dc_motor_pi/c429a4a0.svg @@ -1,54 +1,54 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + diff --git a/dev/tutorials/dc_motor_pi/index.html b/dev/tutorials/dc_motor_pi/index.html index 92681863f..97ed2abcb 100644 --- a/dev/tutorials/dc_motor_pi/index.html +++ b/dev/tutorials/dc_motor_pi/index.html @@ -55,7 +55,7 @@ label = "Measurement", title = "DC Motor with Speed Controller") plot!(sol.t, sol[sys.ref.output.u], label = "Reference") p2 = plot(sol.t, sol[sys.load.tau.u], ylabel = "Disturbance in Nm", label = "") -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(sys.speed_sensor.w, :y, sys.feedback.input2)
+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(sys.speed_sensor.w, :y, sys.feedback.input2)
 connect(sys.pi_controller.ctr_output, :u, sys.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)} @@ -67,9 +67,9 @@ model, :y, op = Dict(sys.inertia.phi => 0.0, sys.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(
+    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/3dfbedad.svg b/dev/tutorials/input_component/65591bac.svg similarity index 91% rename from dev/tutorials/input_component/3dfbedad.svg rename to dev/tutorials/input_component/65591bac.svg index cd782505b..842a33c6f 100644 --- a/dev/tutorials/input_component/3dfbedad.svg +++ b/dev/tutorials/input_component/65591bac.svg @@ -1,48 +1,48 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/tutorials/input_component/f488a43f.svg b/dev/tutorials/input_component/76834609.svg similarity index 91% rename from dev/tutorials/input_component/f488a43f.svg rename to dev/tutorials/input_component/76834609.svg index bf22ca091..334299a88 100644 --- a/dev/tutorials/input_component/f488a43f.svg +++ b/dev/tutorials/input_component/76834609.svg @@ -1,48 +1,48 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/tutorials/input_component/0143378c.svg b/dev/tutorials/input_component/f717a7f7.svg similarity index 91% rename from dev/tutorials/input_component/0143378c.svg rename to dev/tutorials/input_component/f717a7f7.svg index e9cd32d0f..08337420a 100644 --- a/dev/tutorials/input_component/0143378c.svg +++ b/dev/tutorials/input_component/f717a7f7.svg @@ -1,48 +1,48 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/tutorials/input_component/index.html b/dev/tutorials/input_component/index.html index fc4803dee..caaba52a1 100644 --- a/dev/tutorials/input_component/index.html +++ b/dev/tutorials/input_component/index.html @@ -1,5 +1,5 @@ -SampledData Component · ModelingToolkitStandardLibrary.jl

Building Models with Discrete Data, Interpolations, and Lookup Tables

There are 4 ways to include data as part of a model.

  1. using ModelingToolkitStandardLibrary.Blocks.Interpolation
  2. using ModelingToolkitStandardLibrary.Blocks.ParametrizedInterpolation
  3. using a custom component with external data (not recommended)
  4. using ModelingToolkitStandardLibrary.Blocks.SampledData (legacy)

This tutorial demonstrate each case and explain the pros and cons of each.

Interpolation Block

The ModelingToolkitStandardLibrary.Blocks.Interpolation component is easy to use and is performant. It is similar to using callable parameters, but it provides a block interface with RealInput and RealOutput connectors. The Interpolation is compatible with interpolation types from DataInterpolation.

ModelingToolkitStandardLibrary.Blocks.InterpolationFunction
Interpolation(interp_type, u, x, args...; name)

Represent function interpolation symbolically as a block component. By default interpolation types from DataInterpolations.jl are supported, but in general any callable type that builds the interpolation object via itp = interpolation_type(u, x, args...) and calls the interpolation with itp(t) should work. This does not need to represent an interpolation, it can be any type that satisfies the interface, such as lookup tables.

Arguments:

  • interp_type: the type of the interpolation. For DataInterpolations,

these would be any of the available interpolations, such as LinearInterpolation, ConstantInterpolation or CubicSpline.

  • u: the data used for interpolation. For DataInterpolations this will be an AbstractVector
  • x: the values that each data points correspond to, usually the times corresponding to each value in u.
  • args: any other arguments needed to build the interpolation

Keyword arguments:

  • name: the name of the component

Parameters:

  • interpolator: the symbolic representation of the interpolation object, callable as interpolator(t)

Connectors:

  • input: a RealInput connector corresponding to the input variable
  • output: a RealOutput connector corresponding to the interpolated value
source

Here is an example on how to use it. Let's consider a mass-spring-damper system, where we have an external force as an input. We then generate some example data in a DataFrame that would represent a measurement of the input. In a more realistic case, this DataFrame would be read from a file.

using ModelingToolkit
+SampledData Component · ModelingToolkitStandardLibrary.jl

Building Models with Discrete Data, Interpolations, and Lookup Tables

There are 4 ways to include data as part of a model.

  1. using ModelingToolkitStandardLibrary.Blocks.Interpolation
  2. using ModelingToolkitStandardLibrary.Blocks.ParametrizedInterpolation
  3. using a custom component with external data (not recommended)
  4. using ModelingToolkitStandardLibrary.Blocks.SampledData (legacy)

This tutorial demonstrate each case and explain the pros and cons of each.

Interpolation Block

The ModelingToolkitStandardLibrary.Blocks.Interpolation component is easy to use and is performant. It is similar to using callable parameters, but it provides a block interface with RealInput and RealOutput connectors. The Interpolation is compatible with interpolation types from DataInterpolation.

ModelingToolkitStandardLibrary.Blocks.InterpolationFunction
Interpolation(interp_type, u, x, args...; name)

Represent function interpolation symbolically as a block component. By default interpolation types from DataInterpolations.jl are supported, but in general any callable type that builds the interpolation object via itp = interpolation_type(u, x, args...) and calls the interpolation with itp(t) should work. This does not need to represent an interpolation, it can be any type that satisfies the interface, such as lookup tables.

Arguments:

  • interp_type: the type of the interpolation. For DataInterpolations,

these would be any of the available interpolations, such as LinearInterpolation, ConstantInterpolation or CubicSpline.

  • u: the data used for interpolation. For DataInterpolations this will be an AbstractVector
  • x: the values that each data points correspond to, usually the times corresponding to each value in u.
  • args: any other arguments needed to build the interpolation

Keyword arguments:

  • name: the name of the component

Parameters:

  • interpolator: the symbolic representation of the interpolation object, callable as interpolator(t)

Connectors:

  • input: a RealInput connector corresponding to the input variable
  • output: a RealOutput connector corresponding to the interpolated value
source

Here is an example on how to use it. Let's consider a mass-spring-damper system, where we have an external force as an input. We then generate some example data in a DataFrame that would represent a measurement of the input. In a more realistic case, this DataFrame would be read from a file.

using ModelingToolkit
 using ModelingToolkit: t_nounits as t, D_nounits as D
 using ModelingToolkitStandardLibrary.Blocks
 using DataInterpolations
@@ -48,7 +48,7 @@
 sys = structural_simplify(system)
 prob = ODEProblem(sys, [], (0, df.time[end]))
 sol = solve(prob)
-plot(sol)
Example block output

ParametrizedInterpolation Block

The ModelingToolkitStandardLibrary.Blocks.ParametrizedInterpolation component is similar to Interpolation, but as the name suggests, it is parametrized by the data, allowing one to change the underlying data without rebuilding the model as the data is represented via vector parameters. The main advantage of this block over the Interpolation one is that one can use it for optimization problems. Currently, this supports forward mode AD via ForwardDiff, but due to the increased flexibility of the types in the component, this is not as fast as the Interpolation block, so it is recommended to use only when the added flexibility is required.

ModelingToolkitStandardLibrary.Blocks.ParametrizedInterpolationFunction
ParametrizedInterpolation(interp_type, u, x, args...; name, t = ModelingToolkit.t_nounits)

Represent function interpolation symbolically as a block component, with the interpolation data represented parametrically. By default interpolation types from DataInterpolations.jl are supported, but in general any callable type that builds the interpolation object via itp = interpolation_type(u, x, args...) and calls the interpolation with itp(t) should work. This does not need to represent an interpolation, it can be any type that satisfies the interface, such as lookup tables.

Arguments:

  • interp_type: the type of the interpolation. For DataInterpolations,

these would be any of the available interpolations, such as LinearInterpolation, ConstantInterpolation or CubicSpline.

  • u: the data used for interpolation. For DataInterpolations this will be an AbstractVector
  • x: the values that each data points correspond to, usually the times corresponding to each value in u.
  • args: any other arguments beeded to build the interpolation

Keyword arguments:

  • name: the name of the component

Parameters:

  • data: the symbolic representation of the data passed at construction time via u.
  • ts: the symbolic representation of times corresponding to the data passed at construction time via x.

Connectors:

  • input: a RealInput connector corresponding to the independent variable
  • output: a RealOutput connector corresponding to the interpolated value
source

Here is an example on how to use it

using ModelingToolkit
+plot(sol)
Example block output

ParametrizedInterpolation Block

The ModelingToolkitStandardLibrary.Blocks.ParametrizedInterpolation component is similar to Interpolation, but as the name suggests, it is parametrized by the data, allowing one to change the underlying data without rebuilding the model as the data is represented via vector parameters. The main advantage of this block over the Interpolation one is that one can use it for optimization problems. Currently, this supports forward mode AD via ForwardDiff, but due to the increased flexibility of the types in the component, this is not as fast as the Interpolation block, so it is recommended to use only when the added flexibility is required.

ModelingToolkitStandardLibrary.Blocks.ParametrizedInterpolationFunction
ParametrizedInterpolation(interp_type, u, x, args...; name, t = ModelingToolkit.t_nounits)

Represent function interpolation symbolically as a block component, with the interpolation data represented parametrically. By default interpolation types from DataInterpolations.jl are supported, but in general any callable type that builds the interpolation object via itp = interpolation_type(u, x, args...) and calls the interpolation with itp(t) should work. This does not need to represent an interpolation, it can be any type that satisfies the interface, such as lookup tables.

Arguments:

  • interp_type: the type of the interpolation. For DataInterpolations,

these would be any of the available interpolations, such as LinearInterpolation, ConstantInterpolation or CubicSpline.

  • u: the data used for interpolation. For DataInterpolations this will be an AbstractVector
  • x: the values that each data points correspond to, usually the times corresponding to each value in u.
  • args: any other arguments beeded to build the interpolation

Keyword arguments:

  • name: the name of the component

Parameters:

  • data: the symbolic representation of the data passed at construction time via u.
  • ts: the symbolic representation of times corresponding to the data passed at construction time via x.

Connectors:

  • input: a RealInput connector corresponding to the independent variable
  • output: a RealOutput connector corresponding to the interpolated value
source

Here is an example on how to use it

using ModelingToolkit
 using ModelingToolkit: t_nounits as t, D_nounits as D
 using ModelingToolkitStandardLibrary.Blocks
 using DataInterpolations
@@ -97,9 +97,9 @@
 sys = structural_simplify(system)
 prob = ODEProblem(sys, [], (0, df.time[end]))
 sol = solve(prob)
-plot(sol)
Example block output

If we want to run a new data set, this requires only remaking the problem and solving again

prob2 = remake(prob, p = [sys.src.data => ones(length(df.data))])
+plot(sol)
Example block output

If we want to run a new data set, this requires only remaking the problem and solving again

prob2 = remake(prob, p = [sys.src.data => ones(length(df.data))])
 sol2 = solve(prob2)
-plot(sol2)
Example block output
Note

Note that when changing the data, the length of the new data must be the same as the length of the original data.

Custom Component with External Data

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.

using ModelingToolkit
+plot(sol2)
Example block output
Note

Note that when changing the data, the length of the new data must be the same as the length of the original data.

Custom Component with External Data

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.

using ModelingToolkit
 using ModelingToolkit: t_nounits as t, D_nounits as D
 using ModelingToolkitStandardLibrary.Blocks
 using OrdinaryDiffEq
@@ -191,4 +191,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/ea65d569.svg b/dev/tutorials/rc_circuit/6fed4423.svg similarity index 91% rename from dev/tutorials/rc_circuit/ea65d569.svg rename to dev/tutorials/rc_circuit/6fed4423.svg index db78f307f..3a2447ea6 100644 --- a/dev/tutorials/rc_circuit/ea65d569.svg +++ b/dev/tutorials/rc_circuit/6fed4423.svg @@ -1,50 +1,50 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/tutorials/rc_circuit/index.html b/dev/tutorials/rc_circuit/index.html index 439346a78..9dbd25f76 100644 --- a/dev/tutorials/rc_circuit/index.html +++ b/dev/tutorials/rc_circuit/index.html @@ -31,4 +31,4 @@ plot(sol, idxs = [sys.capacitor.v, sys.resistor.i], title = "RC Circuit Demonstration", - labels = ["Capacitor Voltage" "Resistor Current"])Example block output + labels = ["Capacitor Voltage" "Resistor Current"])Example block output diff --git a/dev/tutorials/thermal_model/0d01ce33.svg b/dev/tutorials/thermal_model/dfb30897.svg similarity index 91% rename from dev/tutorials/thermal_model/0d01ce33.svg rename to dev/tutorials/thermal_model/dfb30897.svg index c530fcf36..ee2c531d2 100644 --- a/dev/tutorials/thermal_model/0d01ce33.svg +++ b/dev/tutorials/thermal_model/dfb30897.svg @@ -1,52 +1,52 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/tutorials/thermal_model/index.html b/dev/tutorials/thermal_model/index.html index 127a248bf..744a35257 100644 --- a/dev/tutorials/thermal_model/index.html +++ b/dev/tutorials/thermal_model/index.html @@ -31,4 +31,4 @@ plot(title = "Thermal Conduction Demonstration") plot!(sol, idxs = [sys.mass1.T, sys.mass2.T], labels = ["Mass 1 Temperature" "Mass 2 Temperature"]) -plot!(sol.t, T_final_K, label = "Steady-State Temperature")Example block output +plot!(sol.t, T_final_K, label = "Steady-State Temperature")Example block output