Domain API Reference

ModelingToolkitStandardLibrary.Mechanical.Rotational.ConstantTorqueMethod
ConstantTorque(; name, tau_constant, use_support = false)

Constant torque source

State variables:

  • phi_support(t): [rad] Absolute angle of support flange, only available if use_support = true
  • tau: Accelerating torque acting at flange (= -flange.tau)
  • w: Angular velocity of flange with respect to support (= der(phi))

Connectors:

Arguments:

  • tau_constant: The constant torque applied by the source
  • use_support: Whether or not an internal support flange is added. By default, it is false
source
ModelingToolkitStandardLibrary.Mechanical.Rotational.DamperMethod
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.IdealGearMethod
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.InertiaMethod
Inertia(;name, J, phi = nothing, w = nothing, a = nothing)

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.PositionMethod
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
ModelingToolkitStandardLibrary.Mechanical.Rotational.RotationalFrictionMethod
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
ModelingToolkitStandardLibrary.Mechanical.Rotational.SpeedMethod
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:

  • flangeFlange
  • w_refRealInput 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.SpringMethod
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.SpringDamperMethod
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.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
ModelingToolkitStandardLibrary.Mechanical.Translational.DamperMethod
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
ModelingToolkitStandardLibrary.Mechanical.Translational.MassMethod
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.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.SpringMethod
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.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.TranslationalModelica.MassMethod
Mass(; name, m, s, v = 0.0)

Sliding mass with inertia

Parameters:

  • m: [kg] Mass of sliding mass

States:

  • s: [m] Absolute position of sliding mass. It accepts an initial value, which defaults to 0.0.
  • v: [m/s] Absolute linear velocity of sliding mass (= D(s)). It accepts an initial value, which defaults to 0.0.

Connectors:

  • flange: 1-dim. translational flange of mass
source
ModelingToolkitStandardLibrary.Mechanical.TranslationalModelica.PositionMethod
Position(; name, exact = false, f_crit = 50)

Forced movement of a flange according to a reference position

The input signal s_ref defines the reference position in [m]. Flange flange is forced to move relative to the support connector according to this reference motion. According to parameter exact, this is done in the following way:

  • exact=true: The reference position is treated exactly. This is only possible, if the input signal is defined by an analytical function which can be differentiated at least twice. If this prerequisite is fulfilled, the Modelica translator will differentiate the input signal twice in order to compute the reference acceleration of the flange.
  • exact=false: The reference position 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 as the essential low frequencies in the signal.

The input signal can be provided from one of the signal generator blocks of the block library Blocks.Sources.

source
ModelingToolkitStandardLibrary.Mechanical.TranslationalModelica.SpringDamperMethod
SpringDamper(; name, c = 0.0, d = 0.0, s_rel0 = 0.0)

Linear 1D translational spring and damper in parallel

Parameters:

  • c: [N/m] Spring constant
  • d: [N.s/m] Damping constant
  • s_rel0: Unstretched spring length

Connectors:

  • flange_a: 1-dim. translational flange on one side of spring
  • flange_b: 1-dim. translational flange on opposite side of spring

Variables:

  • lossPower: [W] Power dissipated by the damper
  • f: [N] Total force
source
ModelingToolkitStandardLibrary.Mechanical.TranslationalPosition.DamperMethod
Damper(; name, d, va =0.0, vb = 0.0, flange_a.s = 0, flange_b.s = 0)

Linear 1D translational damper

Parameters:

  • d: [N.s/m] Damping constant
  • flange_a__s: [m] Initial value of absolute position of flange_a
  • flange_b__s: [m] Initial value of absolute position of flange_b

Connectors:

  • flange_a: 1-dim. translational flange on one side of damper
  • flange_b: 1-dim. translational flange on opposite side of damper
source
ModelingToolkitStandardLibrary.Mechanical.TranslationalPosition.MassMethod
Mass(; name, m, s = 0.0, v = 0.0)

Sliding mass with inertia

Parameters:

  • m: [kg] Mass of sliding mass
  • s_0: [m] Initial value of absolute position of sliding mass
  • v_0: [m/s] Initial value of absolute linear velocity of sliding mass

States:

  • s: [m] Absolute position of sliding mass
  • v: [m/s] Absolute linear velocity of sliding mass (= der(s))

Connectors:

  • flange: 1-dim. translational flange of mass
source
ModelingToolkitStandardLibrary.Thermal.BodyRadiationMethod
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.ConvectiveConductorMethod
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.ConvectiveResistorMethod
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.Element1DMethod
Element1D(; name, dT_guess = 0.0, Q_flow_guess = 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 (algebraically constrained).
  • Q_flow: [W] Heat flow rate from port a -> port b (algebraically constrained).

Connectors:

port_aport_b

source
ModelingToolkitStandardLibrary.Thermal.FixedHeatFlowMethod
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.FixedTemperatureMethod
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.HeatCapacitorMethod
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.HeatFlowSensorMethod
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.

Connectors:

  • port_a: HeatPort Thermal port from which sensor information shall be measured
  • port_b: HeatPort Thermal port from which sensor information shall be measured
  • Q_flow: RealOutput [W] Heat flow from port_a to port_b
source
ModelingToolkitStandardLibrary.Thermal.HeatPortMethod
HeatPort(; name, T = nothing, T_guess = 293.15, Q_flow = nothing, Q_flow_guess = 0.0)

Port for a thermal system.

Keyword Arguments

  • T_guess: [K] Initial temperature guess.
  • Q_flow_guess: [W] Initial heat-flow guess.
  • T: Default value for the temperature state.
  • Q_flow: Default value for the heat-flow state.
source
ModelingToolkitStandardLibrary.Thermal.PrescribedHeatFlowMethod
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
  • RealInputQ_flow Input for the heat flow

Parameters:

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

This model represents a variable temperature boundary condition.

The temperature in kelvin is given as input signal to the RealInputT. 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
  • RealInputT input for the temperature
source
ModelingToolkitStandardLibrary.Thermal.RelativeTemperatureSensorMethod
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.

Connectors:

  • port_a: HeatPort Thermal port from which sensor information shall be measured
  • port_b: HeatPort Thermal port from which sensor information shall be measured
  • T: RealOutput [K] Relative temperature a.T - b.T
source
ModelingToolkitStandardLibrary.Thermal.TemperatureSensorMethod
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.

Connectors:

  • port: HeatPort Thermal port from which sensor information shall be measured
  • T: RealOutput [K] Absolute temperature of port
source
ModelingToolkitStandardLibrary.Thermal.ThermalCollectorMethod
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
ModelingToolkitStandardLibrary.Thermal.ThermalResistorMethod
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.Electrical.DiodeMethod
Diode(; name, Is = 1e-6, n = 1, T = 300.15, T_dep = false)

Generic diode with optional temperature dependency.

States

- See [`OnePort`](@ref)

Connectors

- `p` Positive pin
- `n` Negative pin
- `port` [`HeatPort`](@ref) (only if `T_dep = true`) Heat port to model variable temperature dependency

Parameters:

- `Is`: [`A`] Saturation current
- `n`: Ideality factor
- `T`: [K] Constant ambient temperature - only used if T_dep=false
- `T_dep`: [bool] Temperature dependency
source
ModelingToolkitStandardLibrary.Electrical.EMFMethod
EMF(; name, k)

Electromotoric force (electric/mechanic transformer)

States

  • v(t): [V] The voltage across component p.v - n.v
  • i(t): [A] The current passing through positive pin
  • phi: [rad] Rotation angle (=flange.phi - support.phi)
  • w: [rad/s] Angular velocity (= der(phi))

Connectors

  • pPin Positive pin
  • nPin Negative pin
  • flangeFlange Shaft of EMF shaft
  • supportSupport Support/housing of emf shaft

Parameters:

  • k: [N⋅m/A] Transformation coefficient
source
ModelingToolkitStandardLibrary.Electrical.IdealOpAmpMethod
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 ModelingToolkitStandardLibrary.Magnetic.FluxTubes.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.NMOSMethod
NMOS(;name, V_tn, R_DS, lambda)

Creates an N-type MOSFET transistor

# Structural Parameters
    - `use_transconductance`: If `true` the parameter `k_n` needs to be provided, and is used in the calculation of the current
    through the transistor. Otherwise, `mu_n`, `C_ox`, `W`, and `L` need to be provided and are used to calculate the transconductance.

    - `use_channel_length_modulation`: If `true` the channel length modulation effect is taken in to account. In essence this gives
    the drain-source current has a small dependency on the drains-source voltage in the saturation region of operation.

# Connectors
    - `d` Drain Pin
    - `g` Gate Pin
    - `s` Source Pin

# Parameters
    - `mu_n`: Electron mobility
    - `C_ox`: Oxide capacitance (F/m^2)
    - `W`: Channel width (m)
    - `L`: Channel length
    - `k_n`: MOSFET transconductance parameter

Based on the MOSFET models in (Sedra, A. S., Smith, K. C., Carusone, T. C., & Gaudet, V. C. (2021). Microelectronic circuits (8th ed.). Oxford University Press.)

source
ModelingToolkitStandardLibrary.Electrical.NPNMethod
NPN(;name, B_F, B_R, Is, V_T, V_A, phi_C, phi_E, Z_C, Z_E, Tau_f, Tau_r, C_jC0, C_jE0, C_CS, gamma_C, gamma_E, NF, NR)

Creates an NPN Bipolar Junction Transistor following a modified Ebers-Moll model. Includes an optional substrate pin and optional Early voltage effect.

# Structural Parameters
    - `use_substrate`: If `true`, a substrate pin connector is available. If `false` it is 
    assumed the substrate is connected to the collector pin.

    - `use_Early`: If `true`, the Early effect is modeled, which takes in to account the effect 
    collector-base voltage variations have on the collector-base depletion region. In many cases this
    effectively means that the collector current has a dependency on the collector-emitter voltage.

    - `use_advanced_continuation`: When false, the `C_jC` and `C_jE` non-linear capacitance curves use 
    a simplified linear continuation starting when `V_BC` and `V_BE` are 0, respectively. If `true`, the `Z_C` and `Z_E` parameters 
    are used to start the linear continuation at `Phi_C - Z_C` and `Phi_E - Z_E`. 

# Connectors
    - `b` Base Pin
    - `c` Collector Pin
    - `e` Emitter Pin
    - `s` Substrate Pin, only available when `use_substrate = true`

# Parameters
    - `B_F`: Forward beta
    - `B_R`: Reverse beta
    - `Is`: Saturation current
    - `V_T`: Thermal voltage at 300K
    - `V_A`: Inverse Early voltage
    - `phi_C`: Collector junction exponent
    - `phi_E`: Emitter junction exponent
    - `Z_C`: Collector junction offset
    - `Z_E`: Emitter junction offset 
    - `Tau_f`: Forward transit time
    - `Tau_r`: Reverse transit time
    - `C_jC0`: Collector junction capacitance coefficient
    - `C_jE0`: Emitter junction capacitance coefficient
    - `C_CS`: Collector-substrate capacitance
    - `gamma_C`: Collector junction exponent
    - `gamma_E`: Emitter junction exponent
    - `NF`: Forward emission coefficient
    - `NR`: Reverse emission coefficient
source
ModelingToolkitStandardLibrary.Electrical.OnePortMethod
OnePort(; name, v = nothing, i = nothing)

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.PMOSMethod
PMOS(;name, V_tp, R_DS, lambda)

Creates an N-type MOSFET transistor

# Structural Parameters
    - `use_transconductance`: If `true` the parameter `k_p` needs to be provided, and is used in the calculation of the current
    through the transistor. Otherwise, `mu_n`, `C_ox`, `W`, and `L` need to be provided and are used to calculate the transconductance.

    - `use_channel_length_modulation`: If `true` the channel length modulation effect is taken in to account. In essence this gives
    the drain-source current has a small dependency on the drains-source voltage in the saturation region of operation.

# Connectors
    - `d` Drain Pin
    - `g` Gate Pin
    - `s` Source Pin

# Parameters
    - `mu_p`: Electron mobility
    - `C_ox`: Oxide capacitance (F/m^2)
    - `W`: Channel width (m)
    - `L`: Channel length
    - `k_p`: MOSFET transconductance parameter

Based on the MOSFET models in (Sedra, A. S., Smith, K. C., Carusone, T. C., & Gaudet, V. C. (2021). Microelectronic circuits (8th ed.). Oxford University Press.)

source
ModelingToolkitStandardLibrary.Electrical.PNPMethod
PNP(;name, B_F, B_R, Is, V_T, V_A, phi_C, phi_E, Z_C, Z_E, Tau_f, Tau_r, C_jC0, C_jE0, C_CS, gamma_C, gamma_E, NF, NR)

Creates a PNP Bipolar Junction Transistor following a modified Ebers-Moll model. Includes an optional substrate pin and optional Early voltage effect.

# Structural Parameters
    - `use_substrate`: If `true`, a substrate pin connector is available. If `false` it is 
    assumed the substrate is connected to the collector pin.

    - `use_Early`: If `true`, the Early effect is modeled, which takes in to account the effect 
    collector-base voltage variations have on the collector-base depletion region. In many cases this
    effectively means that the collector current has a dependency on the collector-emitter voltage.

    - `use_advanced_continuation`: When false, the `C_jC` and `C_jE` non-linear capacitance curves use 
    a simplified linear continuation starting when `V_CB` and `V_EB` are 0, respectively. If `true`, the `Z_C` and `Z_E` parameters 
    are used to start the linear continuation at `Phi_C - Z_C` and `Phi_E - Z_E`. 

# Connectors
    - `b` Base Pin
    - `c` Collector Pin
    - `e` Emitter Pin
    - `s` Substrate Pin, only available when `use_substrate = true`

# Parameters
    - `B_F`: Forward beta
    - `B_R`: Reverse beta
    - `Is`: Saturation current
    - `V_T`: Thermal voltage at 300K
    - `V_A`: Inverse Early voltage
    - `phi_C`: Collector junction exponent
    - `phi_E`: Emitter junction exponent
    - `Z_C`: Collector junction offset
    - `Z_E`: Emitter junction offset 
    - `Tau_f`: Forward transit time
    - `Tau_r`: Reverse transit time
    - `C_jC0`: Collector junction capacitance coefficient
    - `C_jE0`: Emitter junction capacitance coefficient
    - `C_CS`: Collector-substrate capacitance
    - `gamma_C`: Collector junction exponent
    - `gamma_E`: Emitter junction exponent
    - `NF`: Forward emission coefficient
    - `NR`: Reverse emission coefficient
source
ModelingToolkitStandardLibrary.Electrical.PowerSensorMethod

PowerSensor(; name)

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

States:

Connectors:

source
ModelingToolkitStandardLibrary.Electrical.ResistorMethod
Resistor(; name, R = 1.0, T_ref = 300.15, alpha = 0, T_dep = false)

Generic resistor with optional temperature dependency.

States:

  • See OnePort
  • R(t): [Ω] Resistance (temperature dependent if T_dep = true)

Connectors:

  • p Positive pin
  • n Negative pin
  • heat_portHeatPort (only if T_dep = true) Heat port to model the temperature dependency

Parameters:

  • R: [Ω] Reference resistance
  • T_ref: [K] Reference temperature
  • alpha: [K⁻¹] Temperature coefficient of resistance
  • T_dep: [bool] Temperature dependency
source
ModelingToolkitStandardLibrary.Electrical.VariableResistorMethod
VariableResistor(; name, R_ref = 1.0, T_ref = 300.15, R_const = 1e-3, T_dep = false)

Variable resistor with optional temperature dependency.

The total resistance R ∈ [Rconst, Rconst + Rref], where pos is the position of the wiper and Rref is the variable resistance between p and n. The total resistance is then:

R = Rconst + pos * Rref

If T_dep is true, then R also depends on the temperature of the heat port with temperature coefficient alpha. The total resistance is then:

R = Rconst + pos * Rref * (1 + alpha * (port.T - T_ref))

States

- See [`OnePort`](@ref)
- `pos(t)`: Position of the wiper (normally 0-1)
- `R(t)`: Resistance

Connectors

    - `p` Positive pin
    - `n` Negative pin
    - `position` RealInput to set the position of the wiper
    - `port` [`HeatPort`](@ref) Heat port to model the temperature dependency

Parameters

    - `R_ref`: [`Ω`] Resistance at temperature T_ref when fully closed (pos=1.0)
    - `T_ref`: [K] Reference temperature
    - `R_const`: [`Ω`] Constant resistance between p and n
    - `T_dep`: Temperature dependency
    - `alpha`: [K⁻¹] Temperature coefficient of resistance
    - `enforce_bounds`: Enforce bounds for the position of the wiper (0-1)
source
ModelingToolkitStandardLibrary.Electrical.VoltageSensorMethod

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.Hydraulic.IsothermalCompressible.ActuatorFunction
Actuator(N, add_inertia = true, reversible = false;
    p_a_int,
    p_b_int,
    area_a,
    area_b,
    perimeter_a = 2 * sqrt(area_a * pi),
    perimeter_b = 2 * sqrt(area_b * pi),
    length_a_int,
    length_b_int,
    shape_factor_a = 64,
    shape_factor_b = 64,
    head_factor_a = 1,
    head_factor_b = 1,
    m,
    g,
    x_int = 0,
    minimum_volume_a = 0,
    minimum_volume_b = 0,
    damping_volume_a = minimum_volume_a,
    damping_volume_b = minimum_volume_b,
    Cd = 1e4,
    Cd_reverse = Cd,
    p_a_int,
    p_b_int,
    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
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.DynamicVolumeFunction
DynamicVolume(reversible = false; 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
                       │  │
     │                 │  ▼
     └─────────────────┤ ───
                       │
                       └─► x (= ∫ flange.v * direction)

Features:

  • minimum volume flow shutoff with damping and directional resistance. Use reversible=false when problem defines volume position x and solves for dm to prevent numerical instability.

Parameters:

volume

  • p_int: [Pa] initial pressure

  • area: [m^2] moving wall area

  • x_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.HydraulicFluidMethod
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.SpoolValveFunction
SpoolValve(reversible = false; 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:

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

  • 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.TubeFunction
Tube(N, add_inertia=true; p_int, area, length, head_factor=1, perimeter = 2 * sqrt(area * pi), shape_factor = 64, name)

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

Parameters:

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

Connectors:

  • port_a: hydraulic port
  • port_b: hydraulic port
source
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.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.VolumeMethod
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
                       │  │
     │                 │  ▼
     └─────────────────┤ ───
                       │
                       └─► 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