Skip to content
Analog.ControlledIdealTwoWaySwitch.md

Analog.ControlledIdealTwoWaySwitch ​

This component extends from ConditionalHeatPort

Usage ​

TranslatedComponents.Analog.ControlledIdealTwoWaySwitch(T=293.15, unitVoltage=1, unitCurrent=1, level=0.5, Ron=1.0e-5, Goff=1.0e-5)

Parameters: ​

NameDescriptionUnitsDefault value
useHeatPort–false
TK293.15
unitVoltageV1
unitCurrentA1
levelV0.5
RonΩ0.00001
GoffS0.00001

Connectors ​

  • heatPort - (HeatPort)

  • p - This connector represents an electrical pin with voltage and current as the potential and flow variables, respectively. (Pin)

  • n2 - This connector represents an electrical pin with voltage and current as the potential and flow variables, respectively. (Pin)

  • n1 - This connector represents an electrical pin with voltage and current as the potential and flow variables, respectively. (Pin)

  • control - This connector represents an electrical pin with voltage and current as the potential and flow variables, respectively. (Pin)

Variables ​

NameDescriptionUnits
LossPowerW
T_heatPortK
s1–
s2–

Behavior ​

julia
using TranslatedComponents #hide
using ModelingToolkit #hide
@variables T #hide
@variables unitVoltage #hide
@variables unitCurrent #hide
@variables level #hide
@variables Ron #hide
@variables Goff #hide
@named sys = TranslatedComponents.Analog.ControlledIdealTwoWaySwitch(T=T, unitVoltage=unitVoltage, unitCurrent=unitCurrent, level=level, Ron=Ron, Goff=Goff) #hide
full_equations(sys) #hide
<< @example-block not executed in draft mode >>

Source ​

dyad
component ControlledIdealTwoWaySwitch
  extends ConditionalHeatPort(T = 293.15)
  p = Pin()
  n2 = Pin()
  n1 = Pin()
  control = Pin()
  parameter unitVoltage::Dyad.Voltage = 1
  parameter unitCurrent::Dyad.Current = 1
  parameter level::Dyad.Voltage = 0.5
  parameter Ron::Dyad.Resistance(final min = 0) = 1.0e-5
  parameter Goff::Dyad.Conductance(final min = 0) = 1.0e-5
  variable s1::Real
  variable s2::Real
relations
  control.i = 0
  0 = p.i + n2.i + n1.i
  p.v - n1.v = s1 * (control.v > level ? unitVoltage : Ron * unitCurrent)
  n1.i = -s1 * (control.v > level ? Goff * unitVoltage : unitCurrent)
  p.v - n2.v = s2 * (control.v > level ? Ron * unitCurrent : unitVoltage)
  n2.i = -s2 * (control.v > level ? unitCurrent : Goff * unitVoltage)
  LossPower = p.i * p.v + n1.i * n1.v + n2.i * n2.v
end
Flattened Source
dyad
component ControlledIdealTwoWaySwitch
  heatPort = TranslatedComponents.HeatTransfer.HeatPort() if useHeatPort
  structural parameter useHeatPort::Boolean = false
  parameter T::Dyad.Temperature = 293.15
  variable LossPower::Dyad.Power
  variable T_heatPort::Dyad.Temperature
  p = Pin()
  n2 = Pin()
  n1 = Pin()
  control = Pin()
  parameter unitVoltage::Dyad.Voltage = 1
  parameter unitCurrent::Dyad.Current = 1
  parameter level::Dyad.Voltage = 0.5
  parameter Ron::Dyad.Resistance(final min = 0) = 1.0e-5
  parameter Goff::Dyad.Conductance(final min = 0) = 1.0e-5
  variable s1::Real
  variable s2::Real
relations
  if !(useHeatPort)
    T_heatPort = T
  else
    initial heatPort.T = T_heatPort
    initial heatPort.Q_flow = -LossPower
  end
  control.i = 0
  0 = p.i + n2.i + n1.i
  p.v - n1.v = s1 * (control.v > level ? unitVoltage : Ron * unitCurrent)
  n1.i = -s1 * (control.v > level ? Goff * unitVoltage : unitCurrent)
  p.v - n2.v = s2 * (control.v > level ? Ron * unitCurrent : unitVoltage)
  n2.i = -s2 * (control.v > level ? unitCurrent : Goff * unitVoltage)
  LossPower = p.i * p.v + n1.i * n1.v + n2.i * n2.v
metadata {}
end


Test Cases ​

No test cases defined.

  • Examples

  • Experiments

  • Analyses