ParallelGLC
Represents an electrical circuit with a conductor, inductor, and capacitor in parallel, driven by a sinusoidal current source.
This component models a parallel GLC (conductor, inductor, capacitor) circuit. An internal sinusoidal signal generator dictates the behavior of an ideal current source which, in turn, energizes the parallel combination of the conductor, inductor, and capacitor. The conductor exhibits a constant conductance G, the inductor a constant inductance L, and the capacitor a constant capacitance C. The voltage across the parallel elements is measured by a voltage sensor. All components share a common ground reference. The key equations governing the ideal passive components are: For the conductor: BlockComponents.Sine
sub-component. By Kirchhoff's Current Law, the sum of currents leaving the top node is zero:
Usage
ParallelGLC()
Behavior
Source
# Represents an electrical circuit with a conductor, inductor, and capacitor in parallel, driven by a sinusoidal current source.
#
# This component models a parallel GLC (conductor, inductor, capacitor) circuit. An internal sinusoidal signal generator dictates the behavior
# of an ideal current source which, in turn, energizes the parallel combination of the conductor, inductor, and capacitor. The conductor exhibits
# a constant conductance G, the inductor a constant inductance L, and the capacitor a constant capacitance C. The voltage across the parallel
# elements is measured by a voltage sensor. All components share a common ground reference.
# The key equations governing the ideal passive components are:
# For the conductor: $i_G = G \cdot v$
# For the inductor: $v_L = L \cdot \frac{di_L}{dt}$
# For the capacitor: $i_C = C \cdot \frac{dv_C}{dt}$
# The current source provides a current $I_s(t) = A \sin(2\pi f t + \phi)$, where A is amplitude, f is frequency, and $\phi$ is phase, as defined
# by the `BlockComponents.Sine` sub-component.
# By Kirchhoff's Current Law, the sum of currents leaving the top node is zero: $I_s(t) - i_G(t) - i_L(t) - i_C(t) = 0$.
# All parallel components share the same voltage: $v = v_G = v_L = v_C$.
component ParallelGLC
# Sine wave generator providing the input waveform for the current source.
signal = BlockComponents.Sine(frequency=1, amplitude=1, phase=0) [{"Dyad": {"placement": {"diagram": {"x1": 0, "y1": 400, "x2": 100, "y2": 500}}}}]
# Ideal current source that injects current into the parallel circuit.
source = CurrentSource() [{
"Dyad": {
"placement": {"diagram": {"x1": 150, "y1": 400, "x2": 250, "y2": 500, "rot": 90}}
}
}]
# Inductor component with a specified inductance L.
inductor = Inductor(L=1) [{
"Dyad": {
"placement": {"diagram": {"x1": 350, "y1": 400, "x2": 450, "y2": 500, "rot": 90}}
}
}]
# Capacitor component with a specified capacitance C.
capacitor = Capacitor(C=1) [{
"Dyad": {
"placement": {"diagram": {"x1": 550, "y1": 400, "x2": 650, "y2": 500, "rot": 90}}
}
}]
# Conductor component with a specified conductance G.
conductor = Conductor(G=0.1) [{
"Dyad": {
"placement": {"diagram": {"x1": 750, "y1": 400, "x2": 850, "y2": 500, "rot": 90}}
}
}]
# Sensor to measure the voltage across the parallel branches.
voltage_sensor = VoltageSensor() [{
"Dyad": {
"placement": {"diagram": {"x1": 950, "y1": 400, "x2": 1050, "y2": 500, "rot": 90}}
}
}]
# Ground component providing a common zero-voltage reference.
ground = Ground() [{
"Dyad": {"placement": {"diagram": {"x1": 550, "y1": 700, "x2": 650, "y2": 800}}}
}]
relations
initial capacitor.v = 0.0
connect(signal.y, source.I) [{"Dyad": {"edges": [{"S": 1, "E": 2}]}}]
connect(source.p, inductor.p, capacitor.p, conductor.p, voltage_sensor.p) [{
"Dyad": {
"edges": [
{"S": 1, "M": [{"x": 200, "y": 300}], "E": -1},
{"S": 2, "M": [{"x": 400, "y": 300}], "E": -1},
{"S": 3, "E": -1},
{"S": 4, "M": [{"x": 800, "y": 300}], "E": -1},
{"S": 5, "M": [{"x": 1000, "y": 300}], "E": -1}
],
"junctions": [{"x": 600, "y": 300}]
}
}]
connect(source.n, inductor.n, capacitor.n, conductor.n, voltage_sensor.n, ground.g) [{
"Dyad": {
"edges": [
{"S": 1, "M": [{"x": 200, "y": 600}], "E": -1},
{"S": 2, "M": [{"x": 400, "y": 600}], "E": -1},
{"S": 3, "E": -1},
{"S": 4, "M": [{"x": 800, "y": 600}], "E": -1},
{"S": 5, "M": [{"x": 1000, "y": 600}], "E": -1},
{"S": 6, "E": -1}
],
"junctions": [{"x": 600, "y": 600}]
}
}]
metadata {
"Dyad": {
"tests": {
"case1": {
"stop": 10,
"expect": {
"final": {
"capacitor.i": "-0.0779787323",
"inductor.i": "0.053556296",
"capacitor.v": "0.2442243622",
"inductor.v": "0.2442243622",
"voltage_sensor.v": "0.2442243622"
}
}
}
}
}
}
end
Flattened Source
# Represents an electrical circuit with a conductor, inductor, and capacitor in parallel, driven by a sinusoidal current source.
#
# This component models a parallel GLC (conductor, inductor, capacitor) circuit. An internal sinusoidal signal generator dictates the behavior
# of an ideal current source which, in turn, energizes the parallel combination of the conductor, inductor, and capacitor. The conductor exhibits
# a constant conductance G, the inductor a constant inductance L, and the capacitor a constant capacitance C. The voltage across the parallel
# elements is measured by a voltage sensor. All components share a common ground reference.
# The key equations governing the ideal passive components are:
# For the conductor: $i_G = G \cdot v$
# For the inductor: $v_L = L \cdot \frac{di_L}{dt}$
# For the capacitor: $i_C = C \cdot \frac{dv_C}{dt}$
# The current source provides a current $I_s(t) = A \sin(2\pi f t + \phi)$, where A is amplitude, f is frequency, and $\phi$ is phase, as defined
# by the `BlockComponents.Sine` sub-component.
# By Kirchhoff's Current Law, the sum of currents leaving the top node is zero: $I_s(t) - i_G(t) - i_L(t) - i_C(t) = 0$.
# All parallel components share the same voltage: $v = v_G = v_L = v_C$.
component ParallelGLC
# Sine wave generator providing the input waveform for the current source.
signal = BlockComponents.Sine(frequency=1, amplitude=1, phase=0) [{"Dyad": {"placement": {"diagram": {"x1": 0, "y1": 400, "x2": 100, "y2": 500}}}}]
# Ideal current source that injects current into the parallel circuit.
source = CurrentSource() [{
"Dyad": {
"placement": {"diagram": {"x1": 150, "y1": 400, "x2": 250, "y2": 500, "rot": 90}}
}
}]
# Inductor component with a specified inductance L.
inductor = Inductor(L=1) [{
"Dyad": {
"placement": {"diagram": {"x1": 350, "y1": 400, "x2": 450, "y2": 500, "rot": 90}}
}
}]
# Capacitor component with a specified capacitance C.
capacitor = Capacitor(C=1) [{
"Dyad": {
"placement": {"diagram": {"x1": 550, "y1": 400, "x2": 650, "y2": 500, "rot": 90}}
}
}]
# Conductor component with a specified conductance G.
conductor = Conductor(G=0.1) [{
"Dyad": {
"placement": {"diagram": {"x1": 750, "y1": 400, "x2": 850, "y2": 500, "rot": 90}}
}
}]
# Sensor to measure the voltage across the parallel branches.
voltage_sensor = VoltageSensor() [{
"Dyad": {
"placement": {"diagram": {"x1": 950, "y1": 400, "x2": 1050, "y2": 500, "rot": 90}}
}
}]
# Ground component providing a common zero-voltage reference.
ground = Ground() [{
"Dyad": {"placement": {"diagram": {"x1": 550, "y1": 700, "x2": 650, "y2": 800}}}
}]
relations
initial capacitor.v = 0.0
connect(signal.y, source.I) [{"Dyad": {"edges": [{"S": 1, "E": 2}]}}]
connect(source.p, inductor.p, capacitor.p, conductor.p, voltage_sensor.p) [{
"Dyad": {
"edges": [
{"S": 1, "M": [{"x": 200, "y": 300}], "E": -1},
{"S": 2, "M": [{"x": 400, "y": 300}], "E": -1},
{"S": 3, "E": -1},
{"S": 4, "M": [{"x": 800, "y": 300}], "E": -1},
{"S": 5, "M": [{"x": 1000, "y": 300}], "E": -1}
],
"junctions": [{"x": 600, "y": 300}]
}
}]
connect(source.n, inductor.n, capacitor.n, conductor.n, voltage_sensor.n, ground.g) [{
"Dyad": {
"edges": [
{"S": 1, "M": [{"x": 200, "y": 600}], "E": -1},
{"S": 2, "M": [{"x": 400, "y": 600}], "E": -1},
{"S": 3, "E": -1},
{"S": 4, "M": [{"x": 800, "y": 600}], "E": -1},
{"S": 5, "M": [{"x": 1000, "y": 600}], "E": -1},
{"S": 6, "E": -1}
],
"junctions": [{"x": 600, "y": 600}]
}
}]
metadata {
"Dyad": {
"tests": {
"case1": {
"stop": 10,
"expect": {
"final": {
"capacitor.i": "-0.0779787323",
"inductor.i": "0.053556296",
"capacitor.v": "0.2442243622",
"inductor.v": "0.2442243622",
"voltage_sensor.v": "0.2442243622"
}
}
}
}
}
}
end
Test Cases
This is setup code, that must be run before each test case.
using ElectricalComponents
using ModelingToolkit, OrdinaryDiffEqDefault
using Plots
using CSV, DataFrames
snapshotsdir = joinpath(dirname(dirname(pathof(ElectricalComponents))), "test", "snapshots")
"/home/actions-runner-10/.julia/packages/ElectricalComponents/bmmPM/test/snapshots"
Test Case case1
@mtkbuild model_case1 = ParallelGLC()
u0_case1 = []
prob_case1 = ODEProblem(model_case1, u0_case1, (0, 10))
sol_case1 = solve(prob_case1)
retcode: Success
Interpolation: 3rd order Hermite
t: 51-element Vector{Float64}:
0.0
9.999999999999999e-5
0.0010999999999999998
0.011099999999999997
0.03904495519444739
0.0774725373924739
0.12556935229808527
0.18950892831280508
0.2750693878632105
0.4014169987550922
⋮
8.222028571852821
8.472695694712288
8.730540593161106
8.97221990248555
9.246566787028412
9.481891975797163
9.680395988856095
9.875899532590019
10.0
u: 51-element Vector{Vector{Float64}}:
[0.0, -0.0]
[-3.14158207566843e-8, -1.047194912013536e-12]
[-3.8011722176599276e-6, -1.3937781981178959e-9]
[-0.00038677164192524733, -1.4314254619489815e-6]
[-0.004758597245205992, -6.208104671238104e-5]
[-0.018429073447343167, -0.0004801204223411498]
[-0.046754973392646906, -0.002001836814150193]
[-0.09912988373848983, -0.006594280588755753]
[-0.18091963353829316, -0.018551017312450836]
[-0.27849434401438633, -0.04817401338018504]
⋮
[0.06916855218779601, -0.07576025384560467]
[-0.09560894005907128, -0.08366630246701647]
[0.06668925662134678, -0.09411503183174492]
[0.2569201171362495, -0.05054456443964521]
[0.10287119103846044, 0.006833833340995549]
[-0.06120551615273703, 0.007404828238706502]
[0.02965666609537611, 0.0008423052626068271]
[0.2059360352052903, 0.02466974201358202]
[0.24422436213498327, 0.05355629613476903]
Related
Examples
Experiments
Analyses