LIBRARY
Analog.Basic.Tests.VariableInductor
Test circuit for VariableInductor.
A sine voltage source (1 V, 1 Hz) drives an RL circuit where the inductance ramps from 0.1 H to 0.6 H over 2 s. A 10 Ω series resistor provides damping.
The flux-based formulation should produce smooth voltage despite the time-varying inductance.
Usage
ElectricalComponents.Analog.Basic.Tests.VariableInductor()
Behavior
Source
dyad
"""
Test circuit for VariableInductor.
A sine voltage source (1 V, 1 Hz) drives an RL circuit where the
inductance ramps from 0.1 H to 0.6 H over 2 s. A 10 Ω series
resistor provides damping.
The flux-based formulation should produce smooth voltage despite
the time-varying inductance.
"""
test component VariableInductor
"Sine signal source: 1 V amplitude, 1 Hz"
sine = BlockComponents.Sources.Sine(amplitude = 1, frequency = 1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 40, "y1": 400, "x2": 140, "y2": 500, "rot": 0}
},
"tags": []
}
}
"Voltage source driven by the sine signal"
vs = ElectricalComponents.Analog.Sources.VoltageSource() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 250, "y1": 500, "x2": 350, "y2": 400, "rot": 90}
},
"tags": []
}
}
"Series resistor (10 Ω)"
R1 = ElectricalComponents.Analog.Basic.Resistor(R = 10) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 450, "y1": 280, "x2": 550, "y2": 380, "rot": 0}
},
"tags": []
}
}
"Variable inductor under test"
vl = ElectricalComponents.Analog.Basic.VariableInductor() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 740, "y1": 500, "x2": 640, "y2": 400, "rot": 270}
},
"tags": []
}
}
"Ramp for inductance: 0.1 H to 0.6 H over 2 s"
ramp = BlockComponents.Sources.Ramp(height = 0.5, offset = 0.1, duration = 2) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 950, "y1": 400, "x2": 850, "y2": 500, "rot": 0}
},
"tags": []
}
}
"Ground reference"
ground = ElectricalComponents.Analog.Basic.Ground() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 450, "y1": 600, "x2": 550, "y2": 700, "rot": 0}
},
"tags": []
}
}
relations
initial vl.i = 0
connect(sine.y, vs.V) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(vs.p, R1.p) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 300, "y": 330}], "E": 2}],
"renderStyle": "standard"
}
}
connect(R1.n, vl.p) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 690, "y": 330}], "E": 2}],
"renderStyle": "standard"
}
}
connect(vl.n, ground.g) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 690, "y": 540}, {"x": 500, "y": 540}], "E": 2}],
"renderStyle": "standard"
}
}
connect(vs.n, ground.g) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 300, "y": 540}, {"x": 500, "y": 540}], "E": 2}],
"renderStyle": "standard"
}
}
connect(ramp.y, vl.L) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
metadata {
"Dyad": {
"tests": {
"case1": {
"stop": 1,
"atol": {"vl.v": 0.0001},
"expect": {"signals": ["vl.v", "vl.i", "vl.Psi"]}
}
}
}
}
endFlattened Source
dyad
"""
Test circuit for VariableInductor.
A sine voltage source (1 V, 1 Hz) drives an RL circuit where the
inductance ramps from 0.1 H to 0.6 H over 2 s. A 10 Ω series
resistor provides damping.
The flux-based formulation should produce smooth voltage despite
the time-varying inductance.
"""
test component VariableInductor
"Sine signal source: 1 V amplitude, 1 Hz"
sine = BlockComponents.Sources.Sine(amplitude = 1, frequency = 1) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 40, "y1": 400, "x2": 140, "y2": 500, "rot": 0}
},
"tags": []
}
}
"Voltage source driven by the sine signal"
vs = ElectricalComponents.Analog.Sources.VoltageSource() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 250, "y1": 500, "x2": 350, "y2": 400, "rot": 90}
},
"tags": []
}
}
"Series resistor (10 Ω)"
R1 = ElectricalComponents.Analog.Basic.Resistor(R = 10) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 450, "y1": 280, "x2": 550, "y2": 380, "rot": 0}
},
"tags": []
}
}
"Variable inductor under test"
vl = ElectricalComponents.Analog.Basic.VariableInductor() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 740, "y1": 500, "x2": 640, "y2": 400, "rot": 270}
},
"tags": []
}
}
"Ramp for inductance: 0.1 H to 0.6 H over 2 s"
ramp = BlockComponents.Sources.Ramp(height = 0.5, offset = 0.1, duration = 2) {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 950, "y1": 400, "x2": 850, "y2": 500, "rot": 0}
},
"tags": []
}
}
"Ground reference"
ground = ElectricalComponents.Analog.Basic.Ground() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 450, "y1": 600, "x2": 550, "y2": 700, "rot": 0}
},
"tags": []
}
}
relations
initial vl.i = 0
connect(sine.y, vs.V) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
connect(vs.p, R1.p) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 300, "y": 330}], "E": 2}],
"renderStyle": "standard"
}
}
connect(R1.n, vl.p) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 690, "y": 330}], "E": 2}],
"renderStyle": "standard"
}
}
connect(vl.n, ground.g) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 690, "y": 540}, {"x": 500, "y": 540}], "E": 2}],
"renderStyle": "standard"
}
}
connect(vs.n, ground.g) {
"Dyad": {
"edges": [{"S": 1, "M": [{"x": 300, "y": 540}, {"x": 500, "y": 540}], "E": 2}],
"renderStyle": "standard"
}
}
connect(ramp.y, vl.L) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
metadata {
"Dyad": {
"tests": {
"case1": {
"stop": 1,
"atol": {"vl.v": 0.0001},
"expect": {"signals": ["vl.v", "vl.i", "vl.Psi"]}
}
}
}
}
endTest Cases
Test Case case1
julia
pltjulia
pltjulia
pltRelated
Examples
Experiments
Analyses
Tests