$(instance)MultiSensorTest Icon

MultiSensorTest

A test circuit designed to verify the behavior of a MultiSensor component within a series R-C circuit driven by a sinusoidal voltage source.

This component models an electrical test bench. A VoltageSource, whose voltage $V_{in}(t)$ is dictated by a BlockComponents.Sine signal generator, applies a sinusoidal voltage to a circuit. This circuit comprises a Resistor (R) in series with a Capacitor (C). The MultiSensor component, which is the device under test, is placed to measure the current $i(t)$ flowing through the resistor and capacitor, and the voltage $v_C(t)$ across the capacitor. The Ground component provides a common reference potential (0 V). The circuit dynamics are governed by the differential equation for the capacitor voltage $v_C(t)$: $R C \frac{d v_C(t)}{dt} + v_C(t) = V_{in}(t)$ and the current is $i(t) = C \frac{d v_C(t)}{dt}$. The MultiSensor is expected to report $v_C(t)$ as its voltage measurement and $i(t)$ as its current measurement.

Usage

MultiSensorTest()

Behavior

\[ \begin{equation} \left[ \begin{array}{c} \mathtt{source.y}\left( t \right) = \mathtt{voltage.V}\left( t \right) \\ \mathrm{connect}\left( voltage_{+}p, resistor_{+}p \right) \\ \mathrm{connect}\left( resistor_{+}n, multi_{sensor_{+}pc} \right) \\ \mathrm{connect}\left( multi_{sensor_{+}nc}, capacitor_{+}p \right) \\ \mathrm{connect}\left( capacitor_{+}n, voltage_{+}n, ground_{+}g \right) \\ \mathrm{connect}\left( capacitor_{+}p, multi_{sensor_{+}pv} \right) \\ \mathrm{connect}\left( capacitor_{+}n, multi_{sensor_{+}nv} \right) \\ \mathtt{source.y}\left( t \right) = ifelse\left( \mathtt{source.start\_time} < t, \mathtt{source.offset} + \mathtt{source.amplitude} \sin\left( \mathtt{source.phase} + 6.2832 \mathtt{source.frequency} \left( - \mathtt{source.start\_time} + t \right) \right), \mathtt{source.offset} \right) \\ \mathtt{voltage.v}\left( t \right) = \mathtt{voltage.p.v}\left( t \right) - \mathtt{voltage.n.v}\left( t \right) \\ \mathtt{voltage.i}\left( t \right) = \mathtt{voltage.p.i}\left( t \right) \\ \mathtt{voltage.p.i}\left( t \right) + \mathtt{voltage.n.i}\left( t \right) = 0 \\ \mathtt{voltage.v}\left( t \right) = \mathtt{voltage.uV} \mathtt{voltage.V}\left( t \right) \\ \mathtt{resistor.v}\left( t \right) = - \mathtt{resistor.n.v}\left( t \right) + \mathtt{resistor.p.v}\left( t \right) \\ \mathtt{resistor.i}\left( t \right) = \mathtt{resistor.p.i}\left( t \right) \\ \mathtt{resistor.p.i}\left( t \right) + \mathtt{resistor.n.i}\left( t \right) = 0 \\ \mathtt{resistor.v}\left( t \right) = \mathtt{resistor.R} \mathtt{resistor.i}\left( t \right) \\ \mathtt{capacitor.v}\left( t \right) = \mathtt{capacitor.p.v}\left( t \right) - \mathtt{capacitor.n.v}\left( t \right) \\ \mathtt{capacitor.i}\left( t \right) = \mathtt{capacitor.p.i}\left( t \right) \\ \mathtt{capacitor.p.i}\left( t \right) + \mathtt{capacitor.n.i}\left( t \right) = 0 \\ \mathtt{capacitor.C} \frac{\mathrm{d} \mathtt{capacitor.v}\left( t \right)}{\mathrm{d}t} = \mathtt{capacitor.i}\left( t \right) \\ \mathtt{ground.g.v}\left( t \right) = 0 \\ \mathtt{multi\_sensor.power}\left( t \right) = \mathtt{multi\_sensor.voltage\_sensor.v}\left( t \right) \mathtt{multi\_sensor.current\_sensor.i}\left( t \right) \\ \mathtt{multi\_sensor.i}\left( t \right) = \mathtt{multi\_sensor.current\_sensor.i}\left( t \right) \\ \mathtt{multi\_sensor.v}\left( t \right) = \mathtt{multi\_sensor.voltage\_sensor.v}\left( t \right) \\ \mathrm{connect}\left( pv, voltage_{sensor_{+}p} \right) \\ \mathrm{connect}\left( voltage_{sensor_{+}n}, nv \right) \\ \mathrm{connect}\left( pc, current_{sensor_{+}p} \right) \\ \mathrm{connect}\left( current_{sensor_{+}n}, nc \right) \\ \mathtt{multi\_sensor.voltage\_sensor.p.i}\left( t \right) = 0 \\ \mathtt{multi\_sensor.voltage\_sensor.n.i}\left( t \right) = 0 \\ \mathtt{multi\_sensor.voltage\_sensor.v}\left( t \right) = - \mathtt{multi\_sensor.voltage\_sensor.n.v}\left( t \right) + \mathtt{multi\_sensor.voltage\_sensor.p.v}\left( t \right) \\ \mathtt{multi\_sensor.current\_sensor.p.v}\left( t \right) = \mathtt{multi\_sensor.current\_sensor.n.v}\left( t \right) \\ \mathtt{multi\_sensor.current\_sensor.p.i}\left( t \right) = \mathtt{multi\_sensor.current\_sensor.i}\left( t \right) \\ \mathtt{multi\_sensor.current\_sensor.n.i}\left( t \right) = - \mathtt{multi\_sensor.current\_sensor.i}\left( t \right) \\ \end{array} \right] \end{equation} \]

Source

# A test circuit designed to verify the behavior of a MultiSensor component within
# a series R-C circuit driven by a sinusoidal voltage source.
#
# This component models an electrical test bench. A `VoltageSource`, whose voltage
# $V_{in}(t)$ is dictated by a `BlockComponents.Sine` signal generator, applies a
# sinusoidal voltage to a circuit.
# This circuit comprises a `Resistor` (R) in series with a `Capacitor` (C).
# The `MultiSensor` component, which is the device under test, is placed to measure
# the current $i(t)$ flowing through the resistor and capacitor, and the voltage
# $v_C(t)$ across the capacitor. The `Ground` component provides a common reference
# potential (0 V).
# The circuit dynamics are governed by the differential equation for the capacitor
# voltage $v_C(t)$: $R C \frac{d v_C(t)}{dt} + v_C(t) = V_{in}(t)$ and
# the current is $i(t) = C \frac{d v_C(t)}{dt}$.
# The `MultiSensor` is expected to report $v_C(t)$ as its voltage measurement and
# $i(t)$ as its current measurement.
test component MultiSensorTest
  # Signal generator providing a sinusoidal input waveform with specified offset, amplitude, and frequency.
  source = BlockComponents.Sine(offset=1, amplitude=10, frequency=5)
  # Ideal voltage source component; its voltage is controlled by an external signal.
  voltage = VoltageSource()
  # Resistor component with a resistance value R=1 Ohm.
  resistor = Resistor(R=1)
  # Capacitor component with a capacitance value C=1 Farad.
  capacitor = Capacitor(C=1)
  # Electrical ground component, providing a zero-volt reference potential.
  ground = Ground()
  # The multi-functional sensor component under test; it measures voltage, current and calculates power.
  multi_sensor = MultiSensor()
relations
  connect(source.y, voltage.V)
  connect(voltage.p, resistor.p)
  connect(resistor.n, multi_sensor.pc)
  connect(multi_sensor.nc, capacitor.p)
  connect(capacitor.n, voltage.n, ground.g)
  connect(capacitor.p, multi_sensor.pv)
  connect(capacitor.n, multi_sensor.nv)
metadata {
  "Dyad": {
    "tests": {
      "case1": {
        "stop": 20,
        "initial": {"capacitor.v": 10},
        "expect": {
          "final": {
            "multi_sensor.i": "0.31784799",
            "multi_sensor.v": "0.682152",
            "multi_sensor.power": "0.216820646"
          }
        }
      }
    }
  }
}
end
Flattened Source
# A test circuit designed to verify the behavior of a MultiSensor component within
# a series R-C circuit driven by a sinusoidal voltage source.
#
# This component models an electrical test bench. A `VoltageSource`, whose voltage
# $V_{in}(t)$ is dictated by a `BlockComponents.Sine` signal generator, applies a
# sinusoidal voltage to a circuit.
# This circuit comprises a `Resistor` (R) in series with a `Capacitor` (C).
# The `MultiSensor` component, which is the device under test, is placed to measure
# the current $i(t)$ flowing through the resistor and capacitor, and the voltage
# $v_C(t)$ across the capacitor. The `Ground` component provides a common reference
# potential (0 V).
# The circuit dynamics are governed by the differential equation for the capacitor
# voltage $v_C(t)$: $R C \frac{d v_C(t)}{dt} + v_C(t) = V_{in}(t)$ and
# the current is $i(t) = C \frac{d v_C(t)}{dt}$.
# The `MultiSensor` is expected to report $v_C(t)$ as its voltage measurement and
# $i(t)$ as its current measurement.
test component MultiSensorTest
  # Signal generator providing a sinusoidal input waveform with specified offset, amplitude, and frequency.
  source = BlockComponents.Sine(offset=1, amplitude=10, frequency=5)
  # Ideal voltage source component; its voltage is controlled by an external signal.
  voltage = VoltageSource()
  # Resistor component with a resistance value R=1 Ohm.
  resistor = Resistor(R=1)
  # Capacitor component with a capacitance value C=1 Farad.
  capacitor = Capacitor(C=1)
  # Electrical ground component, providing a zero-volt reference potential.
  ground = Ground()
  # The multi-functional sensor component under test; it measures voltage, current and calculates power.
  multi_sensor = MultiSensor()
relations
  connect(source.y, voltage.V)
  connect(voltage.p, resistor.p)
  connect(resistor.n, multi_sensor.pc)
  connect(multi_sensor.nc, capacitor.p)
  connect(capacitor.n, voltage.n, ground.g)
  connect(capacitor.p, multi_sensor.pv)
  connect(capacitor.n, multi_sensor.nv)
metadata {
  "Dyad": {
    "tests": {
      "case1": {
        "stop": 20,
        "initial": {"capacitor.v": 10},
        "expect": {
          "final": {
            "multi_sensor.i": "0.31784799",
            "multi_sensor.v": "0.682152",
            "multi_sensor.power": "0.216820646"
          }
        }
      }
    }
  }
}
end


Test Cases

Test Case case1