Analog.Sensors.Tests.MultiSensor
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 BlockComponents.Sources.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 Ground component provides a common reference potential (0 V). The circuit dynamics are governed by the differential equation for the capacitor voltage MultiSensor is expected to report
Usage
ElectricalComponents.Analog.Sensors.Tests.MultiSensor()
Behavior
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.Sources.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 MultiSensor
"Signal generator providing a sinusoidal input waveform with specified offset, amplitude, and frequency."
source = BlockComponents.Sources.Sine(offset = 1, amplitude = 10, frequency = 5) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 30, "y1": 70, "x2": 130, "y2": 170, "rot": 0}
},
"tags": []
}
}
"Ideal voltage source component; its voltage is controlled by an external signal."
voltage = ElectricalComponents.Analog.Sources.VoltageSource() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 175, "y1": 175, "x2": 275, "y2": 275, "rot": 0}
},
"tags": []
}
}
"Resistor component with a resistance value R=1 Ohm."
resistor = ElectricalComponents.Analog.Basic.Resistor(R = 1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 305, "y1": 400, "x2": 405, "y2": 500, "rot": 0}
},
"tags": []
}
}
"Capacitor component with a capacitance value C=1 Farad."
capacitor = ElectricalComponents.Analog.Basic.Capacitor(C = 1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 35, "y1": 275, "x2": 135, "y2": 375, "rot": 0}
},
"tags": []
}
}
"Electrical ground component, providing a zero-volt reference potential."
ground = ElectricalComponents.Analog.Basic.Ground() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 305, "y1": 280, "x2": 405, "y2": 380, "rot": 0}
},
"tags": []
}
}
"The multi-functional sensor component under test; it measures voltage, current and calculates power."
multi_sensor = ElectricalComponents.Analog.Sensors.MultiSensor() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 435, "y1": 400, "x2": 535, "y2": 500, "rot": 0}
},
"tags": []
}
}
relations
connect(source.y, voltage.V) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 225, "y": 120}], "E": 2}],
"renderStyle": "standard"
}
}
connect(voltage.p, resistor.p) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 160, "y": 225}, {"x": 160, "y": 450}], "E": 2}],
"renderStyle": "standard"
}
}
connect(resistor.n, multi_sensor.pc) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(multi_sensor.nc, capacitor.p) {
"Dyad": {
"edges": [
{
"S": 1,
"M": [
{"x": 550, "y": 450},
{"x": 550, "y": 566},
{"x": 20, "y": 566},
{"x": 20, "y": 325}
],
"E": 2
}
],
"renderStyle": "standard"
}
}
connect(capacitor.n, voltage.n, ground.g) {
"Dyad": {
"edges": [
{"S": 1, "M": [{"x": 290, "y": 325}], "E": -1},
{"S": -1, "M": [], "E": 2},
{"S": -1, "M": [{"x": 355, "y": 225}], "E": 3}
],
"junctions": [{"x": 290, "y": 225}],
"renderStyle": "standard"
}
}
connect(capacitor.p, multi_sensor.pv) {
"Dyad": {
"edges": [
{"S": 1, "M": [], "E": -1},
{"S": -1, "M": [{"x": 20, "y": 20}, {"x": 485, "y": 20}], "E": 2}
],
"junctions": [{"x": 20, "y": 325}],
"renderStyle": "standard"
}
}
connect(capacitor.n, multi_sensor.nv) {
"Dyad": {
"edges": [
{"S": 1, "M": [], "E": -1},
{"S": -1, "M": [{"x": 150, "y": 555}, {"x": 485, "y": 555}], "E": 2}
],
"junctions": [{"x": 150, "y": 325}],
"renderStyle": "standard"
}
}
metadata {
"Dyad": {
"icons": {"default": "dyad://ElectricalComponents/Example.svg"},
"tests": {
"case1": {
"stop": 20,
"initial": {"capacitor.v": 10},
"expect": {
"final": {
"multi_sensor.i": "0.31798707833424167",
"multi_sensor.v": "0.6820129216657976",
"multi_sensor.power": "0.21687129634670702"
}
}
}
}
}
}
endFlattened 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.Sources.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 MultiSensor
"Signal generator providing a sinusoidal input waveform with specified offset, amplitude, and frequency."
source = BlockComponents.Sources.Sine(offset = 1, amplitude = 10, frequency = 5) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 30, "y1": 70, "x2": 130, "y2": 170, "rot": 0}
},
"tags": []
}
}
"Ideal voltage source component; its voltage is controlled by an external signal."
voltage = ElectricalComponents.Analog.Sources.VoltageSource() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 175, "y1": 175, "x2": 275, "y2": 275, "rot": 0}
},
"tags": []
}
}
"Resistor component with a resistance value R=1 Ohm."
resistor = ElectricalComponents.Analog.Basic.Resistor(R = 1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 305, "y1": 400, "x2": 405, "y2": 500, "rot": 0}
},
"tags": []
}
}
"Capacitor component with a capacitance value C=1 Farad."
capacitor = ElectricalComponents.Analog.Basic.Capacitor(C = 1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 35, "y1": 275, "x2": 135, "y2": 375, "rot": 0}
},
"tags": []
}
}
"Electrical ground component, providing a zero-volt reference potential."
ground = ElectricalComponents.Analog.Basic.Ground() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 305, "y1": 280, "x2": 405, "y2": 380, "rot": 0}
},
"tags": []
}
}
"The multi-functional sensor component under test; it measures voltage, current and calculates power."
multi_sensor = ElectricalComponents.Analog.Sensors.MultiSensor() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 435, "y1": 400, "x2": 535, "y2": 500, "rot": 0}
},
"tags": []
}
}
relations
connect(source.y, voltage.V) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 225, "y": 120}], "E": 2}],
"renderStyle": "standard"
}
}
connect(voltage.p, resistor.p) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 160, "y": 225}, {"x": 160, "y": 450}], "E": 2}],
"renderStyle": "standard"
}
}
connect(resistor.n, multi_sensor.pc) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(multi_sensor.nc, capacitor.p) {
"Dyad": {
"edges": [
{
"S": 1,
"M": [
{"x": 550, "y": 450},
{"x": 550, "y": 566},
{"x": 20, "y": 566},
{"x": 20, "y": 325}
],
"E": 2
}
],
"renderStyle": "standard"
}
}
connect(capacitor.n, voltage.n, ground.g) {
"Dyad": {
"edges": [
{"S": 1, "M": [{"x": 290, "y": 325}], "E": -1},
{"S": -1, "M": [], "E": 2},
{"S": -1, "M": [{"x": 355, "y": 225}], "E": 3}
],
"junctions": [{"x": 290, "y": 225}],
"renderStyle": "standard"
}
}
connect(capacitor.p, multi_sensor.pv) {
"Dyad": {
"edges": [
{"S": 1, "M": [], "E": -1},
{"S": -1, "M": [{"x": 20, "y": 20}, {"x": 485, "y": 20}], "E": 2}
],
"junctions": [{"x": 20, "y": 325}],
"renderStyle": "standard"
}
}
connect(capacitor.n, multi_sensor.nv) {
"Dyad": {
"edges": [
{"S": 1, "M": [], "E": -1},
{"S": -1, "M": [{"x": 150, "y": 555}, {"x": 485, "y": 555}], "E": 2}
],
"junctions": [{"x": 150, "y": 325}],
"renderStyle": "standard"
}
}
metadata {
"Dyad": {
"icons": {"default": "dyad://ElectricalComponents/Example.svg"},
"tests": {
"case1": {
"stop": 20,
"initial": {"capacitor.v": 10},
"expect": {
"final": {
"multi_sensor.i": "0.31798707833424167",
"multi_sensor.v": "0.6820129216657976",
"multi_sensor.power": "0.21687129634670702"
}
}
}
}
}
}
endTest Cases
Test Case case1
Related
Examples
Experiments
Analyses
Tests