ParallelResonance
IconParallelResonance
Parallel resonance circuit
Usage
ParallelResonance()
Behavior
\[ \begin{equation} \left[ \begin{array}{c} \mathrm{connect}\left( ramp_{+}y(t), input_{signal1_{+}frequency(t)}, input_{signal2_{+}frequency(t)} \right) \\ \mathrm{connect}\left( const_{signal_{+}y(t)}, input_{signal1_{+}amplitude(t)}, input_{signal2_{+}amplitude(t)} \right) \\ \mathrm{connect}\left( input_{signal1_{+}y(t)}, current_{source1_{+}I(t)} \right) \\ \mathrm{connect}\left( input_{signal2_{+}y(t)}, current_{source2_{+}I(t)} \right) \\ \mathrm{connect}\left( current_{source1_{+}n}, resistor1_{+}p, inductor1_{+}p, capacitor1_{+}p, voltage_{sensor1_{+}p} \right) \\ \mathrm{connect}\left( ground1_{+}g, current_{source1_{+}p}, resistor1_{+}n, inductor1_{+}n, capacitor1_{+}n, voltage_{sensor1_{+}n} \right) \\ \mathrm{connect}\left( current_{source2_{+}n}, resistor2_{+}p, inductor2_{+}p, capacitor2_{+}p, voltage_{sensor2_{+}p} \right) \\ \mathrm{connect}\left( ground2_{+}g, current_{source2_{+}p}, resistor2_{+}n, inductor2_{+}n, capacitor2_{+}n, voltage_{sensor2_{+}n} \right) \\ \mathtt{current\_source1.v}\left( t \right) = \mathtt{current\_source1.p.v}\left( t \right) - \mathtt{current\_source1.n.v}\left( t \right) \\ \mathtt{current\_source1.i}\left( t \right) = \mathtt{current\_source1.p.i}\left( t \right) \\ \mathtt{current\_source1.p.i}\left( t \right) + \mathtt{current\_source1.n.i}\left( t \right) = 0 \\ \mathtt{current\_source1.i}\left( t \right) = \mathtt{current\_source1.uI} \mathtt{current\_source1.I}\left( t \right) \\ \mathtt{ground1.g.v}\left( t \right) = 0 \\ \mathtt{resistor1.v}\left( t \right) = - \mathtt{resistor1.n.v}\left( t \right) + \mathtt{resistor1.p.v}\left( t \right) \\ \mathtt{resistor1.i}\left( t \right) = \mathtt{resistor1.p.i}\left( t \right) \\ \mathtt{resistor1.n.i}\left( t \right) + \mathtt{resistor1.p.i}\left( t \right) = 0 \\ \mathtt{resistor1.v}\left( t \right) = \mathtt{resistor1.R} \mathtt{resistor1.i}\left( t \right) \\ \mathtt{inductor1.v}\left( t \right) = - \mathtt{inductor1.n.v}\left( t \right) + \mathtt{inductor1.p.v}\left( t \right) \\ \mathtt{inductor1.i}\left( t \right) = \mathtt{inductor1.p.i}\left( t \right) \\ \mathtt{inductor1.n.i}\left( t \right) + \mathtt{inductor1.p.i}\left( t \right) = 0 \\ \mathtt{inductor1.L} \frac{\mathrm{d} \mathtt{inductor1.i}\left( t \right)}{\mathrm{d}t} = \mathtt{inductor1.v}\left( t \right) \\ \mathtt{capacitor1.v}\left( t \right) = - \mathtt{capacitor1.n.v}\left( t \right) + \mathtt{capacitor1.p.v}\left( t \right) \\ \mathtt{capacitor1.i}\left( t \right) = \mathtt{capacitor1.p.i}\left( t \right) \\ \mathtt{capacitor1.n.i}\left( t \right) + \mathtt{capacitor1.p.i}\left( t \right) = 0 \\ \mathtt{capacitor1.C} \frac{\mathrm{d} \mathtt{capacitor1.v}\left( t \right)}{\mathrm{d}t} = \mathtt{capacitor1.i}\left( t \right) \\ \mathtt{voltage\_sensor1.p.i}\left( t \right) = 0 \\ \mathtt{voltage\_sensor1.n.i}\left( t \right) = 0 \\ \mathtt{voltage\_sensor1.v}\left( t \right) = \mathtt{voltage\_sensor1.p.v}\left( t \right) - \mathtt{voltage\_sensor1.n.v}\left( t \right) \\ \frac{\mathrm{d} \mathtt{input\_signal1.phi}\left( t \right)}{\mathrm{d}t} = 6.2832 \mathtt{input\_signal1.frequency}\left( t \right) \\ \mathtt{input\_signal1.y}\left( t \right) = \mathtt{input\_signal1.offset} + \mathtt{input\_signal1.amplitude}\left( t \right) \sin\left( \mathtt{input\_signal1.phi}\left( t \right) \right) \\ \frac{\mathrm{d} \mathtt{input\_signal2.phi}\left( t \right)}{\mathrm{d}t} = 6.2832 \mathtt{input\_signal2.frequency}\left( t \right) \\ \mathtt{input\_signal2.y}\left( t \right) = \mathtt{input\_signal2.offset} + \mathtt{input\_signal2.amplitude}\left( t \right) \cos\left( \mathtt{input\_signal2.phi}\left( t \right) \right) \\ \mathtt{ramp.y}\left( t \right) = ifelse\left( \mathtt{ramp.start\_time} < t, ifelse\left( t < \mathtt{ramp.duration} + \mathtt{ramp.start\_time}, \mathtt{ramp.offset} + \frac{\mathtt{ramp.height} \left( - \mathtt{ramp.start\_time} + t \right)}{\mathtt{ramp.duration}}, \mathtt{ramp.height} + \mathtt{ramp.offset} \right), \mathtt{ramp.offset} \right) \\ \mathtt{const\_signal.y}\left( t \right) = \mathtt{const\_signal.k} \\ \mathtt{current\_source2.v}\left( t \right) = - \mathtt{current\_source2.n.v}\left( t \right) + \mathtt{current\_source2.p.v}\left( t \right) \\ \mathtt{current\_source2.i}\left( t \right) = \mathtt{current\_source2.p.i}\left( t \right) \\ \mathtt{current\_source2.p.i}\left( t \right) + \mathtt{current\_source2.n.i}\left( t \right) = 0 \\ \mathtt{current\_source2.i}\left( t \right) = \mathtt{current\_source2.uI} \mathtt{current\_source2.I}\left( t \right) \\ \mathtt{ground2.g.v}\left( t \right) = 0 \\ \mathtt{resistor2.v}\left( t \right) = - \mathtt{resistor2.n.v}\left( t \right) + \mathtt{resistor2.p.v}\left( t \right) \\ \mathtt{resistor2.i}\left( t \right) = \mathtt{resistor2.p.i}\left( t \right) \\ \mathtt{resistor2.p.i}\left( t \right) + \mathtt{resistor2.n.i}\left( t \right) = 0 \\ \mathtt{resistor2.v}\left( t \right) = \mathtt{resistor2.R} \mathtt{resistor2.i}\left( t \right) \\ \mathtt{inductor2.v}\left( t \right) = - \mathtt{inductor2.n.v}\left( t \right) + \mathtt{inductor2.p.v}\left( t \right) \\ \mathtt{inductor2.i}\left( t \right) = \mathtt{inductor2.p.i}\left( t \right) \\ \mathtt{inductor2.n.i}\left( t \right) + \mathtt{inductor2.p.i}\left( t \right) = 0 \\ \mathtt{inductor2.L} \frac{\mathrm{d} \mathtt{inductor2.i}\left( t \right)}{\mathrm{d}t} = \mathtt{inductor2.v}\left( t \right) \\ \mathtt{capacitor2.v}\left( t \right) = \mathtt{capacitor2.p.v}\left( t \right) - \mathtt{capacitor2.n.v}\left( t \right) \\ \mathtt{capacitor2.i}\left( t \right) = \mathtt{capacitor2.p.i}\left( t \right) \\ \mathtt{capacitor2.n.i}\left( t \right) + \mathtt{capacitor2.p.i}\left( t \right) = 0 \\ \mathtt{capacitor2.C} \frac{\mathrm{d} \mathtt{capacitor2.v}\left( t \right)}{\mathrm{d}t} = \mathtt{capacitor2.i}\left( t \right) \\ \mathtt{voltage\_sensor2.p.i}\left( t \right) = 0 \\ \mathtt{voltage\_sensor2.n.i}\left( t \right) = 0 \\ \mathtt{voltage\_sensor2.v}\left( t \right) = - \mathtt{voltage\_sensor2.n.v}\left( t \right) + \mathtt{voltage\_sensor2.p.v}\left( t \right) \\ \end{array} \right] \end{equation} \]
Source
# Parallel resonance circuit
example component ParallelResonance
# Sine
current_source1 = CurrentSource() [{
"JuliaSim": {
"placement": {"icon": {"x1": 100, "y1": 100, "x2": 300, "y2": 300, "rot": 270}}
}
}]
ground1 = Ground() [{
"JuliaSim": {"placement": {"icon": {"x1": 100, "y1": 400, "x2": 300, "y2": 600, "rot": 0}}}
}]
resistor1 = Resistor(R=0.5) [{
"JuliaSim": {"placement": {"icon": {"x1": 400, "y1": 100, "x2": 600, "y2": 300, "rot": 90}}}
}]
inductor1 = Inductor(L=0.1/(2*pi)) [{
"JuliaSim": {"placement": {"icon": {"x1": 700, "y1": 100, "x2": 900, "y2": 300, "rot": 90}}}
}]
capacitor1 = Capacitor(C=0.001/(2*pi)) [{
"JuliaSim": {
"placement": {"icon": {"x1": 1000, "y1": 100, "x2": 1200, "y2": 300, "rot": 90}}
}
}]
voltage_sensor1 = VoltageSensor() [{
"JuliaSim": {
"placement": {"icon": {"x1": 1300, "y1": 100, "x2": 1500, "y2": 300, "rot": 90}}
}
}]
# Input controllers
input_signal1 = BlockComponents.SineVariableFrequencyAndAmplitude() [{
"JuliaSim": {"placement": {"icon": {"x1": -200, "y1": 100, "x2": 0, "y2": 300, "rot": 0}}}
}]
input_signal2 = BlockComponents.CosineVariableFrequencyAndAmplitude() [{
"JuliaSim": {"placement": {"icon": {"x1": -200, "y1": 700, "x2": 0, "y2": 900, "rot": 0}}}
}]
ramp = BlockComponents.Ramp(start_time=0, duration=1, offset=0, height=200) [{
"JuliaSim": {
"placement": {"icon": {"x1": -600, "y1": 250, "x2": -400, "y2": 450, "rot": 0}}
}
}]
const_signal = BlockComponents.Constant(k=1) [{
"JuliaSim": {
"placement": {"icon": {"x1": -600, "y1": 550, "x2": -400, "y2": 750, "rot": 0}}
}
}]
# Cosine
current_source2 = CurrentSource() [{
"JuliaSim": {
"placement": {"icon": {"x1": 100, "y1": 700, "x2": 300, "y2": 900, "rot": 270}}
}
}]
ground2 = Ground() [{
"JuliaSim": {
"placement": {"icon": {"x1": 100, "y1": 1000, "x2": 300, "y2": 1200, "rot": 0}}
}
}]
resistor2 = Resistor(R=0.5) [{
"JuliaSim": {"placement": {"icon": {"x1": 400, "y1": 700, "x2": 600, "y2": 900, "rot": 90}}}
}]
inductor2 = Inductor(L=0.1/(2*pi)) [{
"JuliaSim": {"placement": {"icon": {"x1": 700, "y1": 700, "x2": 900, "y2": 900, "rot": 90}}}
}]
capacitor2 = Capacitor(C=0.001/(2*pi)) [{
"JuliaSim": {
"placement": {"icon": {"x1": 1000, "y1": 700, "x2": 1200, "y2": 900, "rot": 90}}
}
}]
voltage_sensor2 = VoltageSensor() [{
"JuliaSim": {
"placement": {"icon": {"x1": 1300, "y1": 700, "x2": 1500, "y2": 900, "rot": 90}}
}
}]
relations
initial inductor1.i = 0
initial inductor2.i = 0
initial capacitor1.v = 0
initial capacitor2.v = 0
# inputs
connect(ramp.y, input_signal1.frequency, input_signal2.frequency) [{
"JuliaSim": {
"edges": [
{"S": -1, "E": 1},
{"S": -1, "M": [{"x": -350, "y": 240}], "E": 2},
{"S": -1, "M": [{"x": -350, "y": 840}], "E": 3}
],
"junctions": [{"x": -350, "y": 350}]
}
}]
connect(const_signal.y, input_signal1.amplitude, input_signal2.amplitude) [{
"JuliaSim": {
"edges": [
{"S": -1, "E": 1},
{"S": -1, "M": [{"x": -300, "y": 160}], "E": 2},
{"S": -1, "M": [{"x": -300, "y": 760}], "E": 3}
],
"junctions": [{"x": -300, "y": 650}]
}
}]
connect(input_signal1.y, current_source1.I) [{"JuliaSim": {"edges": [{"S": 1, "E": 2}]}}]
connect(input_signal2.y, current_source2.I) [{"JuliaSim": {"edges": [{"S": 1, "E": 2}]}}]
# Sine
connect(current_source1.n, resistor1.p, inductor1.p, capacitor1.p, voltage_sensor1.p) [{
"JuliaSim": {
"edges": [
{"S": 1, "M": [{"x": 200, "y": 50}], "E": -1},
{"S": -1, "E": 2},
{"S": -1, "M": [{"x": 800, "y": 50}], "E": 3},
{"S": -1, "M": [{"x": 1100, "y": 50}], "E": 4},
{"S": -1, "M": [{"x": 1400, "y": 50}], "E": 5}
],
"junctions": [{"x": 500, "y": 50}]
}
}]
connect(ground1.g, current_source1.p, resistor1.n, inductor1.n, capacitor1.n, voltage_sensor1.n) [{
"JuliaSim": {
"edges": [
{"S": 1, "E": -1},
{"S": 2, "E": -1},
{"S": -1, "M": [{"x": 500, "y": 350}], "E": 3},
{"S": -1, "M": [{"x": 800, "y": 350}], "E": 4},
{"S": -1, "M": [{"x": 1100, "y": 350}], "E": 5},
{"S": -1, "M": [{"x": 1400, "y": 350}], "E": 6}
],
"junctions": [{"x": 200, "y": 350}]
}
}]
# Cosine
connect(current_source2.n, resistor2.p, inductor2.p, capacitor2.p, voltage_sensor2.p) [{
"JuliaSim": {
"edges": [
{"S": -1, "M": [{"x": 200, "y": 650}], "E": 1},
{"S": -1, "E": 2},
{"S": -1, "M": [{"x": 800, "y": 650}], "E": 3},
{"S": -1, "M": [{"x": 1100, "y": 650}], "E": 4},
{"S": -1, "M": [{"x": 1400, "y": 650}], "E": 5}
],
"junctions": [{"x": 500, "y": 650}]
}
}]
connect(ground2.g, current_source2.p, resistor2.n, inductor2.n, capacitor2.n, voltage_sensor2.n) [{
"JuliaSim": {
"edges": [
{"S": -1, "E": 1},
{"S": -1, "E": 2},
{"S": -1, "M": [{"x": 500, "y": 950}], "E": 3},
{"S": -1, "M": [{"x": 800, "y": 950}], "E": 4},
{"S": -1, "M": [{"x": 1100, "y": 950}], "E": 5},
{"S": -1, "M": [{"x": 1400, "y": 950}], "E": 6}
],
"junctions": [{"x": 200, "y": 950}]
}
}]
metadata {
"JuliaSim": {
"tests": {
"case1": {"stop": 1, "expect": {"signals": ["voltage_sensor1.v", "voltage_sensor2.v"]}}
}
}
}
end
Flattened Source
# Parallel resonance circuit example component ParallelResonance # Sine current_source1 = CurrentSource() [{ "JuliaSim": { "placement": {"icon": {"x1": 100, "y1": 100, "x2": 300, "y2": 300, "rot": 270}} } }] ground1 = Ground() [{ "JuliaSim": {"placement": {"icon": {"x1": 100, "y1": 400, "x2": 300, "y2": 600, "rot": 0}}} }] resistor1 = Resistor(R=0.5) [{ "JuliaSim": {"placement": {"icon": {"x1": 400, "y1": 100, "x2": 600, "y2": 300, "rot": 90}}} }] inductor1 = Inductor(L=0.1/(2*pi)) [{ "JuliaSim": {"placement": {"icon": {"x1": 700, "y1": 100, "x2": 900, "y2": 300, "rot": 90}}} }] capacitor1 = Capacitor(C=0.001/(2*pi)) [{ "JuliaSim": { "placement": {"icon": {"x1": 1000, "y1": 100, "x2": 1200, "y2": 300, "rot": 90}} } }] voltage_sensor1 = VoltageSensor() [{ "JuliaSim": { "placement": {"icon": {"x1": 1300, "y1": 100, "x2": 1500, "y2": 300, "rot": 90}} } }] # Input controllers input_signal1 = BlockComponents.SineVariableFrequencyAndAmplitude() [{ "JuliaSim": {"placement": {"icon": {"x1": -200, "y1": 100, "x2": 0, "y2": 300, "rot": 0}}} }] input_signal2 = BlockComponents.CosineVariableFrequencyAndAmplitude() [{ "JuliaSim": {"placement": {"icon": {"x1": -200, "y1": 700, "x2": 0, "y2": 900, "rot": 0}}} }] ramp = BlockComponents.Ramp(start_time=0, duration=1, offset=0, height=200) [{ "JuliaSim": { "placement": {"icon": {"x1": -600, "y1": 250, "x2": -400, "y2": 450, "rot": 0}} } }] const_signal = BlockComponents.Constant(k=1) [{ "JuliaSim": { "placement": {"icon": {"x1": -600, "y1": 550, "x2": -400, "y2": 750, "rot": 0}} } }] # Cosine current_source2 = CurrentSource() [{ "JuliaSim": { "placement": {"icon": {"x1": 100, "y1": 700, "x2": 300, "y2": 900, "rot": 270}} } }] ground2 = Ground() [{ "JuliaSim": { "placement": {"icon": {"x1": 100, "y1": 1000, "x2": 300, "y2": 1200, "rot": 0}} } }] resistor2 = Resistor(R=0.5) [{ "JuliaSim": {"placement": {"icon": {"x1": 400, "y1": 700, "x2": 600, "y2": 900, "rot": 90}}} }] inductor2 = Inductor(L=0.1/(2*pi)) [{ "JuliaSim": {"placement": {"icon": {"x1": 700, "y1": 700, "x2": 900, "y2": 900, "rot": 90}}} }] capacitor2 = Capacitor(C=0.001/(2*pi)) [{ "JuliaSim": { "placement": {"icon": {"x1": 1000, "y1": 700, "x2": 1200, "y2": 900, "rot": 90}} } }] voltage_sensor2 = VoltageSensor() [{ "JuliaSim": { "placement": {"icon": {"x1": 1300, "y1": 700, "x2": 1500, "y2": 900, "rot": 90}} } }] relations initial inductor1.i = 0 initial inductor2.i = 0 initial capacitor1.v = 0 initial capacitor2.v = 0 # inputs connect(ramp.y, input_signal1.frequency, input_signal2.frequency) [{ "JuliaSim": { "edges": [ {"S": -1, "E": 1}, {"S": -1, "M": [{"x": -350, "y": 240}], "E": 2}, {"S": -1, "M": [{"x": -350, "y": 840}], "E": 3} ], "junctions": [{"x": -350, "y": 350}] } }] connect(const_signal.y, input_signal1.amplitude, input_signal2.amplitude) [{ "JuliaSim": { "edges": [ {"S": -1, "E": 1}, {"S": -1, "M": [{"x": -300, "y": 160}], "E": 2}, {"S": -1, "M": [{"x": -300, "y": 760}], "E": 3} ], "junctions": [{"x": -300, "y": 650}] } }] connect(input_signal1.y, current_source1.I) [{"JuliaSim": {"edges": [{"S": 1, "E": 2}]}}] connect(input_signal2.y, current_source2.I) [{"JuliaSim": {"edges": [{"S": 1, "E": 2}]}}] # Sine connect(current_source1.n, resistor1.p, inductor1.p, capacitor1.p, voltage_sensor1.p) [{ "JuliaSim": { "edges": [ {"S": 1, "M": [{"x": 200, "y": 50}], "E": -1}, {"S": -1, "E": 2}, {"S": -1, "M": [{"x": 800, "y": 50}], "E": 3}, {"S": -1, "M": [{"x": 1100, "y": 50}], "E": 4}, {"S": -1, "M": [{"x": 1400, "y": 50}], "E": 5} ], "junctions": [{"x": 500, "y": 50}] } }] connect(ground1.g, current_source1.p, resistor1.n, inductor1.n, capacitor1.n, voltage_sensor1.n) [{ "JuliaSim": { "edges": [ {"S": 1, "E": -1}, {"S": 2, "E": -1}, {"S": -1, "M": [{"x": 500, "y": 350}], "E": 3}, {"S": -1, "M": [{"x": 800, "y": 350}], "E": 4}, {"S": -1, "M": [{"x": 1100, "y": 350}], "E": 5}, {"S": -1, "M": [{"x": 1400, "y": 350}], "E": 6} ], "junctions": [{"x": 200, "y": 350}] } }] # Cosine connect(current_source2.n, resistor2.p, inductor2.p, capacitor2.p, voltage_sensor2.p) [{ "JuliaSim": { "edges": [ {"S": -1, "M": [{"x": 200, "y": 650}], "E": 1}, {"S": -1, "E": 2}, {"S": -1, "M": [{"x": 800, "y": 650}], "E": 3}, {"S": -1, "M": [{"x": 1100, "y": 650}], "E": 4}, {"S": -1, "M": [{"x": 1400, "y": 650}], "E": 5} ], "junctions": [{"x": 500, "y": 650}] } }] connect(ground2.g, current_source2.p, resistor2.n, inductor2.n, capacitor2.n, voltage_sensor2.n) [{ "JuliaSim": { "edges": [ {"S": -1, "E": 1}, {"S": -1, "E": 2}, {"S": -1, "M": [{"x": 500, "y": 950}], "E": 3}, {"S": -1, "M": [{"x": 800, "y": 950}], "E": 4}, {"S": -1, "M": [{"x": 1100, "y": 950}], "E": 5}, {"S": -1, "M": [{"x": 1400, "y": 950}], "E": 6} ], "junctions": [{"x": 200, "y": 950}] } }] metadata { "JuliaSim": { "tests": { "case1": {"stop": 1, "expect": {"signals": ["voltage_sensor1.v", "voltage_sensor2.v"]}} } } } end