LIBRARY
Analog.Examples.ShowVariableResistor
MSL validation test: ShowVariableResistor.
Recreates Modelica.Electrical.Analog.Examples.ShowVariableResistor from MSL v4.0.0. A sine voltage source drives two parallel branches: a fixed 3-resistor chain (R1-R2-R3, each 1 Ohm) and a variable-resistor chain (R4-VR-R5). The variable resistor's value is swept by a ramp from 2 to 7 Ohm over 2 s. The VariableResistor branch should be compared with R2 in the fixed branch.
MSL reference: tolerance=1e-6, StopTime=1.
Usage
ElectricalComponents.Analog.Examples.ShowVariableResistor()
Behavior
Source
dyad
"""
MSL validation test: ShowVariableResistor.
Recreates `Modelica.Electrical.Analog.Examples.ShowVariableResistor` from MSL v4.0.0.
A sine voltage source drives two parallel branches: a fixed 3-resistor chain
(R1-R2-R3, each 1 Ohm) and a variable-resistor chain (R4-VR-R5).
The variable resistor's value is swept by a ramp from 2 to 7 Ohm over 2 s.
The VariableResistor branch should be compared with R2 in the fixed branch.
MSL reference: tolerance=1e-6, StopTime=1.
"""
example component ShowVariableResistor
"Sine voltage source: V=1 V, f=1 Hz"
sine = BlockComponents.Sources.Sine(amplitude = 1, frequency = 1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 20, "y1": 20, "x2": 120, "y2": 120, "rot": 0}
},
"tags": []
}
}
"Voltage source driven by the sine signal"
voltage_source = ElectricalComponents.Analog.Sources.VoltageSource() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 100, "y1": 230, "x2": 200, "y2": 330, "rot": 0}
},
"tags": []
}
}
"Ground at source negative terminal"
ground1 = ElectricalComponents.Analog.Basic.Ground() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 10, "y1": 660, "x2": 110, "y2": 760, "rot": 0}
},
"tags": []
}
}
"Ground at return path (right side)"
ground2 = ElectricalComponents.Analog.Basic.Ground() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 900, "y1": 690, "x2": 1000, "y2": 790, "rot": 0}
},
"tags": []
}
}
"Fixed resistor chain (top branch)"
R1 = ElectricalComponents.Analog.Basic.Resistor(R = 1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 300, "y1": 230, "x2": 400, "y2": 330, "rot": 0}
},
"tags": []
}
}
R2 = ElectricalComponents.Analog.Basic.Resistor(R = 1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 500, "y1": 230, "x2": 600, "y2": 330, "rot": 0}
},
"tags": []
}
}
R3 = ElectricalComponents.Analog.Basic.Resistor(R = 1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 700, "y1": 230, "x2": 800, "y2": 330, "rot": 0}
},
"tags": []
}
}
"Variable resistor chain (bottom branch)"
R4 = ElectricalComponents.Analog.Basic.Resistor(R = 1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 290, "y1": 530, "x2": 390, "y2": 630, "rot": 0}
},
"tags": []
}
}
variable_resistor = ElectricalComponents.Analog.Basic.VariableResistor() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 500, "y1": 530, "x2": 600, "y2": 630, "rot": 0}
},
"tags": []
}
}
R5 = ElectricalComponents.Analog.Basic.Resistor(R = 1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 700, "y1": 530, "x2": 800, "y2": 630, "rot": 0}
},
"tags": []
}
}
"Ramp signal for variable resistance: offset=2, height=5, duration=2 s"
ramp = BlockComponents.Sources.Ramp(height = 5, offset = 2, duration = 2) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 380, "y1": 370, "x2": 480, "y2": 470, "rot": 0}
},
"tags": []
}
}
"Fixed temperature to ground the thermal port (alpha=0, so T is irrelevant)"
fixed_temp = ThermalComponents.Sources.FixedTemperature(T = 300.15) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 320, "y1": 740, "x2": 420, "y2": 840, "rot": 0}
},
"tags": []
}
}
relations
guess variable_resistor.i = 0
"Signal to voltage source"
connect(sine.y, voltage_source.V) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 150, "y": 70}], "E": 2}],
"renderStyle": "standard"
}
}
"Source positive to ground1 (matches MSL SineVoltage1.p -> Ground1)"
connect(voltage_source.p, ground1.g) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 60, "y": 280}], "E": 2}],
"renderStyle": "standard"
}
}
"Source negative to both branches (matches MSL SineVoltage1.n -> R1.p, R4.p)"
connect(voltage_source.n, R1.p) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(voltage_source.n, R4.p) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 270, "y": 280}, {"x": 270, "y": 580}], "E": 2}],
"renderStyle": "standard"
}
}
"Top branch: R1 -> R2 -> R3 -> ground2"
connect(R1.n, R2.p) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(R2.n, R3.p) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(R3.n, ground2.g) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 950, "y": 280}], "E": 2}],
"renderStyle": "standard"
}
}
"Bottom branch: R4 -> VR -> R5 -> ground2"
connect(R4.n, variable_resistor.p) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(R5.n, ground2.g) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 950, "y": 580}], "E": 2}],
"renderStyle": "standard"
}
}
connect(variable_resistor.n, R5.p) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
connect(ramp.y, variable_resistor.R) {
"Dyad": {
"renderStyle": "standard",
"edges": [{"S": 1, "M": [{"x": 550, "y": 420}], "E": 2}]
}
}
connect(fixed_temp.port, variable_resistor.heat_port) {
"Dyad": {
"renderStyle": "standard",
"edges": [{"S": 1, "M": [{"x": 551, "y": 790}], "E": 2}]
}
}
endFlattened Source
dyad
"""
MSL validation test: ShowVariableResistor.
Recreates `Modelica.Electrical.Analog.Examples.ShowVariableResistor` from MSL v4.0.0.
A sine voltage source drives two parallel branches: a fixed 3-resistor chain
(R1-R2-R3, each 1 Ohm) and a variable-resistor chain (R4-VR-R5).
The variable resistor's value is swept by a ramp from 2 to 7 Ohm over 2 s.
The VariableResistor branch should be compared with R2 in the fixed branch.
MSL reference: tolerance=1e-6, StopTime=1.
"""
example component ShowVariableResistor
"Sine voltage source: V=1 V, f=1 Hz"
sine = BlockComponents.Sources.Sine(amplitude = 1, frequency = 1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 20, "y1": 20, "x2": 120, "y2": 120, "rot": 0}
},
"tags": []
}
}
"Voltage source driven by the sine signal"
voltage_source = ElectricalComponents.Analog.Sources.VoltageSource() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 100, "y1": 230, "x2": 200, "y2": 330, "rot": 0}
},
"tags": []
}
}
"Ground at source negative terminal"
ground1 = ElectricalComponents.Analog.Basic.Ground() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 10, "y1": 660, "x2": 110, "y2": 760, "rot": 0}
},
"tags": []
}
}
"Ground at return path (right side)"
ground2 = ElectricalComponents.Analog.Basic.Ground() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 900, "y1": 690, "x2": 1000, "y2": 790, "rot": 0}
},
"tags": []
}
}
"Fixed resistor chain (top branch)"
R1 = ElectricalComponents.Analog.Basic.Resistor(R = 1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 300, "y1": 230, "x2": 400, "y2": 330, "rot": 0}
},
"tags": []
}
}
R2 = ElectricalComponents.Analog.Basic.Resistor(R = 1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 500, "y1": 230, "x2": 600, "y2": 330, "rot": 0}
},
"tags": []
}
}
R3 = ElectricalComponents.Analog.Basic.Resistor(R = 1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 700, "y1": 230, "x2": 800, "y2": 330, "rot": 0}
},
"tags": []
}
}
"Variable resistor chain (bottom branch)"
R4 = ElectricalComponents.Analog.Basic.Resistor(R = 1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 290, "y1": 530, "x2": 390, "y2": 630, "rot": 0}
},
"tags": []
}
}
variable_resistor = ElectricalComponents.Analog.Basic.VariableResistor() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 500, "y1": 530, "x2": 600, "y2": 630, "rot": 0}
},
"tags": []
}
}
R5 = ElectricalComponents.Analog.Basic.Resistor(R = 1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 700, "y1": 530, "x2": 800, "y2": 630, "rot": 0}
},
"tags": []
}
}
"Ramp signal for variable resistance: offset=2, height=5, duration=2 s"
ramp = BlockComponents.Sources.Ramp(height = 5, offset = 2, duration = 2) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 380, "y1": 370, "x2": 480, "y2": 470, "rot": 0}
},
"tags": []
}
}
"Fixed temperature to ground the thermal port (alpha=0, so T is irrelevant)"
fixed_temp = ThermalComponents.Sources.FixedTemperature(T = 300.15) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 320, "y1": 740, "x2": 420, "y2": 840, "rot": 0}
},
"tags": []
}
}
relations
guess variable_resistor.i = 0
"Signal to voltage source"
connect(sine.y, voltage_source.V) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 150, "y": 70}], "E": 2}],
"renderStyle": "standard"
}
}
"Source positive to ground1 (matches MSL SineVoltage1.p -> Ground1)"
connect(voltage_source.p, ground1.g) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 60, "y": 280}], "E": 2}],
"renderStyle": "standard"
}
}
"Source negative to both branches (matches MSL SineVoltage1.n -> R1.p, R4.p)"
connect(voltage_source.n, R1.p) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(voltage_source.n, R4.p) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 270, "y": 280}, {"x": 270, "y": 580}], "E": 2}],
"renderStyle": "standard"
}
}
"Top branch: R1 -> R2 -> R3 -> ground2"
connect(R1.n, R2.p) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(R2.n, R3.p) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(R3.n, ground2.g) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 950, "y": 280}], "E": 2}],
"renderStyle": "standard"
}
}
"Bottom branch: R4 -> VR -> R5 -> ground2"
connect(R4.n, variable_resistor.p) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(R5.n, ground2.g) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 950, "y": 580}], "E": 2}],
"renderStyle": "standard"
}
}
connect(variable_resistor.n, R5.p) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
connect(ramp.y, variable_resistor.R) {
"Dyad": {
"renderStyle": "standard",
"edges": [{"S": 1, "M": [{"x": 550, "y": 420}], "E": 2}]
}
}
connect(fixed_temp.port, variable_resistor.heat_port) {
"Dyad": {
"renderStyle": "standard",
"edges": [{"S": 1, "M": [{"x": 551, "y": 790}], "E": 2}]
}
}
metadata {}
endTest Cases
No test cases defined.
Related
Examples
Experiments
Analyses