Skip to content
SeriesResonance.md

SeriesResonance

Models two series RLC circuits, one driven by a sine voltage and the other by a cosine voltage, where both sources have their frequency controlled by a common ramp input and their amplitude by a common constant input.

This component simulates a pair of series RLC circuits. The first circuit is excited by a sinusoidal voltage source, while the second is driven by a cosinusoidal voltage source. Both voltage sources share common control inputs for their frequency and amplitude. A Ramp component provides a linearly changing frequency signal, and a Constant component provides a fixed amplitude signal. This setup is typically used to analyze the frequency response and resonance phenomena of the RLC circuits. The ramp input sweeps the frequency of the voltage sources from 0 Hz up to 200 Hz over 1 second (based on default Ramp parameters of offset=0, height=200, duration=1), allowing observation of the circuit's response across a range that includes its resonant frequency. With the default R=0.5 Ohm, L=0.1/(2_pi) H, and C=0.001/(2_pi) F, the resonant frequency (f0) is 100 Hz.

Usage

SeriesResonance()

Behavior

[ramp.y(t)=input_signal1.frequency(t)input_signal1.frequency(t)=input_signal2.frequency(t)const_signal.y(t)=input_signal1.amplitude(t)input_signal1.amplitude(t)=input_signal2.amplitude(t)input_signal1.y(t)=voltage_source1.V(t)input_signal2.y(t)=voltage_source2.V(t)connect(voltagesource1+p,inductor1+p)connect(inductor1+n,capacitor1+p)connect(capacitor1+n,resistor1+p)connect(voltagesource1+n,ground1+g)connect(currentsensor1+p,resistor1+n)connect(ground1+g,currentsensor1+n)connect(voltagesource2+p,inductor2+p)connect(inductor2+n,capacitor2+p)connect(capacitor2+n,resistor2+p)connect(voltagesource2+n,ground2+g)connect(currentsensor2+p,resistor2+n)connect(ground2+g,currentsensor2+n)voltage_source1.v(t)=voltage_source1.p.v(t)voltage_source1.n.v(t)voltage_source1.i(t)=voltage_source1.p.i(t)voltage_source1.n.i(t)+voltage_source1.p.i(t)=0voltage_source1.v(t)=voltage_source1.uVvoltage_source1.V(t)ground1.g.v(t)=0resistor1.v(t)=resistor1.n.v(t)+resistor1.p.v(t)resistor1.i(t)=resistor1.p.i(t)resistor1.n.i(t)+resistor1.p.i(t)=0resistor1.v(t)=resistor1.Rresistor1.i(t)inductor1.v(t)=inductor1.n.v(t)+inductor1.p.v(t)inductor1.i(t)=inductor1.p.i(t)inductor1.n.i(t)+inductor1.p.i(t)=0inductor1.Ldinductor1.i(t)dt=inductor1.v(t)capacitor1.v(t)=capacitor1.n.v(t)+capacitor1.p.v(t)capacitor1.i(t)=capacitor1.p.i(t)capacitor1.n.i(t)+capacitor1.p.i(t)=0capacitor1.Cdcapacitor1.v(t)dt=capacitor1.i(t)current_sensor1.p.v(t)=current_sensor1.n.v(t)current_sensor1.p.i(t)=current_sensor1.i(t)current_sensor1.n.i(t)=current_sensor1.i(t)dinput_signal1.phi(t)dt=6.2832input_signal1.frequency(t)input_signal1.y(t)=input_signal1.offset+input_signal1.amplitude(t)sin(input_signal1.phi(t))dinput_signal2.phi(t)dt=6.2832input_signal2.frequency(t)input_signal2.y(t)=input_signal2.offset+input_signal2.amplitude(t)cos(input_signal2.phi(t))ramp.y(t)=ifelse(ramp.start_time<t,ifelse(t<ramp.duration+ramp.start_time,ramp.offset+ramp.height(ramp.start_time+t)ramp.duration,ramp.height+ramp.offset),ramp.offset)const_signal.y(t)=const_signal.kvoltage_source2.v(t)=voltage_source2.n.v(t)+voltage_source2.p.v(t)voltage_source2.i(t)=voltage_source2.p.i(t)voltage_source2.p.i(t)+voltage_source2.n.i(t)=0voltage_source2.v(t)=voltage_source2.uVvoltage_source2.V(t)ground2.g.v(t)=0resistor2.v(t)=resistor2.n.v(t)+resistor2.p.v(t)resistor2.i(t)=resistor2.p.i(t)resistor2.p.i(t)+resistor2.n.i(t)=0resistor2.v(t)=resistor2.Rresistor2.i(t)inductor2.v(t)=inductor2.n.v(t)+inductor2.p.v(t)inductor2.i(t)=inductor2.p.i(t)inductor2.n.i(t)+inductor2.p.i(t)=0inductor2.Ldinductor2.i(t)dt=inductor2.v(t)capacitor2.v(t)=capacitor2.p.v(t)capacitor2.n.v(t)capacitor2.i(t)=capacitor2.p.i(t)capacitor2.n.i(t)+capacitor2.p.i(t)=0capacitor2.Cdcapacitor2.v(t)dt=capacitor2.i(t)current_sensor2.p.v(t)=current_sensor2.n.v(t)current_sensor2.p.i(t)=current_sensor2.i(t)current_sensor2.n.i(t)=current_sensor2.i(t)]

Source

dyad
# Models two series RLC circuits, one driven by a sine voltage and the other by a cosine voltage, where both sources have their frequency controlled by a common ramp input and their amplitude by a common constant input.
#
# This component simulates a pair of series RLC circuits. The first circuit is excited
# by a sinusoidal voltage source, while the second is driven by a cosinusoidal voltage
# source. Both voltage sources share common control inputs for their frequency and
# amplitude. A `Ramp` component provides a linearly changing frequency signal, and a
# `Constant` component provides a fixed amplitude signal. This setup is typically used
# to analyze the frequency response and resonance phenomena of the RLC circuits. The
# ramp input sweeps the frequency of the voltage sources from 0 Hz up to 200 Hz over 1
# second (based on default `Ramp` parameters of offset=0, height=200, duration=1),
# allowing observation of the circuit's response across a range that includes its resonant frequency.
# With the default R=0.5 Ohm, L=0.1/(2*pi) H, and C=0.001/(2*pi) F, the resonant
# frequency ($f_0$) is 100 Hz.
example component SeriesResonance
  # Voltage source for the first RLC circuit (sine wave input).
  voltage_source1 = VoltageSource() [{
    "Dyad": {
      "placement": {"icon": {"x1": 100, "y1": 100, "x2": 300, "y2": 300, "rot": 180}}
    }
  }]
  # Ground connection for the first RLC circuit.
  ground1 = Ground() [{
    "Dyad": {"placement": {"icon": {"x1": 400, "y1": 400, "x2": 600, "y2": 600, "rot": 0}}}
  }]
  # Resistor in the first RLC circuit with R=0.5 Ohm.
  resistor1 = Resistor(R=0.5) [{
    "Dyad": {
      "placement": {"icon": {"x1": 1000, "y1": 100, "x2": 1200, "y2": 300, "rot": 0}}
    }
  }]
  # Inductor in the first RLC circuit with L=0.1/(2*pi) Henry.
  inductor1 = Inductor(L=0.1/(2*pi)) [{
    "Dyad": {"placement": {"icon": {"x1": 400, "y1": 100, "x2": 600, "y2": 300, "rot": 0}}}
  }]
  # Capacitor in the first RLC circuit with C=0.001/(2*pi) Farad.
  capacitor1 = Capacitor(C=0.001/(2*pi)) [{
    "Dyad": {"placement": {"icon": {"x1": 700, "y1": 100, "x2": 900, "y2": 300, "rot": 0}}}
  }]
  # Current sensor to measure the current in the first RLC circuit.
  current_sensor1 = CurrentSensor() [{
    "Dyad": {
      "placement": {"icon": {"x1": 1300, "y1": 100, "x2": 1500, "y2": 300, "rot": 0}}
    }
  }]
  # Input signal generator for a sine wave with variable frequency and amplitude.
  input_signal1 = BlockComponents.SineVariableFrequencyAndAmplitude() [{
    "Dyad": {"placement": {"icon": {"x1": -200, "y1": 400, "x2": 0, "y2": 600, "rot": 0}}}
  }]
  # Input signal generator for a cosine wave with variable frequency and amplitude.
  input_signal2 = BlockComponents.CosineVariableFrequencyAndAmplitude() [{
    "Dyad": {"placement": {"icon": {"x1": -200, "y1": 1000, "x2": 0, "y2": 1200, "rot": 0}}}
  }]
  # Ramp signal generator to control the frequency of input_signal1 and input_signal2.
  ramp = BlockComponents.Ramp(start_time=0, duration=1, offset=0, height=200) [{
    "Dyad": {
      "placement": {"icon": {"x1": -600, "y1": 250, "x2": -400, "y2": 450, "rot": 0}}
    }
  }]
  # Constant signal generator to control the amplitude of input_signal1 and input_signal2.
  const_signal = BlockComponents.Constant(k=1) [{
    "Dyad": {
      "placement": {"icon": {"x1": -600, "y1": 550, "x2": -400, "y2": 750, "rot": 0}}
    }
  }]
  # Voltage source for the second RLC circuit (cosine wave input).
  voltage_source2 = VoltageSource() [{
    "Dyad": {
      "placement": {"icon": {"x1": 100, "y1": 700, "x2": 300, "y2": 900, "rot": 180}}
    }
  }]
  # Ground connection for the second RLC circuit.
  ground2 = Ground() [{
    "Dyad": {
      "placement": {"icon": {"x1": 400, "y1": 1000, "x2": 600, "y2": 1200, "rot": 0}}
    }
  }]
  # Resistor in the second RLC circuit with R=0.5 Ohm.
  resistor2 = Resistor(R=0.5) [{
    "Dyad": {
      "placement": {"icon": {"x1": 1000, "y1": 700, "x2": 1200, "y2": 900, "rot": 0}}
    }
  }]
  # Inductor in the second RLC circuit with L=0.1/(2*pi) Henry.
  inductor2 = Inductor(L=0.1/(2*pi)) [{
    "Dyad": {"placement": {"icon": {"x1": 400, "y1": 700, "x2": 600, "y2": 900, "rot": 0}}}
  }]
  # Capacitor in the second RLC circuit with C=0.001/(2*pi) Farad.
  capacitor2 = Capacitor(C=0.001/(2*pi)) [{
    "Dyad": {"placement": {"icon": {"x1": 700, "y1": 700, "x2": 900, "y2": 900, "rot": 0}}}
  }]
  # Current sensor to measure the current in the second RLC circuit.
  current_sensor2 = CurrentSensor() [{
    "Dyad": {
      "placement": {"icon": {"x1": 1300, "y1": 700, "x2": 1500, "y2": 900, "rot": 0}}
    }
  }]
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) [{
    "Dyad": {
      "edges": [
        {"S": -1, "M": [{"x": -350, "y": 350}], "E": 1},
        {"S": -1, "E": 2},
        {"S": -1, "M": [{"x": -350, "y": 1140}], "E": 3}
      ],
      "junctions": [{"x": -350, "y": 540}]
    }
  }]
  connect(const_signal.y, input_signal1.amplitude, input_signal2.amplitude) [{
    "Dyad": {
      "edges": [
        {"S": -1, "E": 1},
        {"S": -1, "M": [{"x": -300, "y": 460}], "E": 2},
        {"S": -1, "M": [{"x": -300, "y": 1060}], "E": 3}
      ],
      "junctions": [{"x": -300, "y": 650}]
    }
  }]
  connect(input_signal1.y, voltage_source1.V) [{"Dyad": {"edges": [{"S": 1, "M": [{"x": 200, "y": 500}], "E": 2}]}}]
  connect(input_signal2.y, voltage_source2.V) [{"Dyad": {"edges": [{"S": 1, "M": [{"x": 200, "y": 1100}], "E": 2}]}}]
  # sine
  connect(voltage_source1.p, inductor1.p) [{"Dyad": {"edges": [{"S": 1, "E": 2}]}}]
  connect(inductor1.n, capacitor1.p) [{"Dyad": {"edges": [{"S": 1, "E": 2}]}}]
  connect(capacitor1.n, resistor1.p) [{"Dyad": {"edges": [{"S": 1, "E": 2}]}}]
  connect(voltage_source1.n, ground1.g) [{
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [{"x": 50, "y": 200}, {"x": 50, "y": 350}, {"x": 500, "y": 350}],
          "E": 2
        }
      ]
    }
  }]
  connect(current_sensor1.p, resistor1.n) [{"Dyad": {"edges": [{"S": 1, "E": 2}]}}]
  connect(ground1.g, current_sensor1.n) [{
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [{"x": 500, "y": 350}, {"x": 1550, "y": 350}, {"x": 1550, "y": 200}],
          "E": 2
        }
      ]
    }
  }]
  # cosine
  connect(voltage_source2.p, inductor2.p) [{"Dyad": {"edges": [{"S": 1, "E": 2}]}}]
  connect(inductor2.n, capacitor2.p) [{"Dyad": {"edges": [{"S": 1, "E": 2}]}}]
  connect(capacitor2.n, resistor2.p) [{"Dyad": {"edges": [{"S": 1, "E": 2}]}}]
  connect(voltage_source2.n, ground2.g) [{
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [{"x": 50, "y": 800}, {"x": 50, "y": 950}, {"x": 500, "y": 950}],
          "E": 2
        }
      ]
    }
  }]
  connect(current_sensor2.p, resistor2.n) [{"Dyad": {"edges": [{"S": 1, "E": 2}]}}]
  connect(ground2.g, current_sensor2.n) [{
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [{"x": 500, "y": 950}, {"x": 1550, "y": 950}, {"x": 1550, "y": 800}],
          "E": 2
        }
      ]
    }
  }]
metadata {
  "Dyad": {
    "tests": {
      "case1": {"stop": 1, "expect": {"signals": ["current_sensor1.i", "current_sensor2.i"]}}
    }
  }
}
end
Flattened Source
dyad
# Models two series RLC circuits, one driven by a sine voltage and the other by a cosine voltage, where both sources have their frequency controlled by a common ramp input and their amplitude by a common constant input.
#
# This component simulates a pair of series RLC circuits. The first circuit is excited
# by a sinusoidal voltage source, while the second is driven by a cosinusoidal voltage
# source. Both voltage sources share common control inputs for their frequency and
# amplitude. A `Ramp` component provides a linearly changing frequency signal, and a
# `Constant` component provides a fixed amplitude signal. This setup is typically used
# to analyze the frequency response and resonance phenomena of the RLC circuits. The
# ramp input sweeps the frequency of the voltage sources from 0 Hz up to 200 Hz over 1
# second (based on default `Ramp` parameters of offset=0, height=200, duration=1),
# allowing observation of the circuit's response across a range that includes its resonant frequency.
# With the default R=0.5 Ohm, L=0.1/(2*pi) H, and C=0.001/(2*pi) F, the resonant
# frequency ($f_0$) is 100 Hz.
example component SeriesResonance
  # Voltage source for the first RLC circuit (sine wave input).
  voltage_source1 = VoltageSource() [{
    "Dyad": {
      "placement": {"icon": {"x1": 100, "y1": 100, "x2": 300, "y2": 300, "rot": 180}}
    }
  }]
  # Ground connection for the first RLC circuit.
  ground1 = Ground() [{
    "Dyad": {"placement": {"icon": {"x1": 400, "y1": 400, "x2": 600, "y2": 600, "rot": 0}}}
  }]
  # Resistor in the first RLC circuit with R=0.5 Ohm.
  resistor1 = Resistor(R=0.5) [{
    "Dyad": {
      "placement": {"icon": {"x1": 1000, "y1": 100, "x2": 1200, "y2": 300, "rot": 0}}
    }
  }]
  # Inductor in the first RLC circuit with L=0.1/(2*pi) Henry.
  inductor1 = Inductor(L=0.1/(2*pi)) [{
    "Dyad": {"placement": {"icon": {"x1": 400, "y1": 100, "x2": 600, "y2": 300, "rot": 0}}}
  }]
  # Capacitor in the first RLC circuit with C=0.001/(2*pi) Farad.
  capacitor1 = Capacitor(C=0.001/(2*pi)) [{
    "Dyad": {"placement": {"icon": {"x1": 700, "y1": 100, "x2": 900, "y2": 300, "rot": 0}}}
  }]
  # Current sensor to measure the current in the first RLC circuit.
  current_sensor1 = CurrentSensor() [{
    "Dyad": {
      "placement": {"icon": {"x1": 1300, "y1": 100, "x2": 1500, "y2": 300, "rot": 0}}
    }
  }]
  # Input signal generator for a sine wave with variable frequency and amplitude.
  input_signal1 = BlockComponents.SineVariableFrequencyAndAmplitude() [{
    "Dyad": {"placement": {"icon": {"x1": -200, "y1": 400, "x2": 0, "y2": 600, "rot": 0}}}
  }]
  # Input signal generator for a cosine wave with variable frequency and amplitude.
  input_signal2 = BlockComponents.CosineVariableFrequencyAndAmplitude() [{
    "Dyad": {"placement": {"icon": {"x1": -200, "y1": 1000, "x2": 0, "y2": 1200, "rot": 0}}}
  }]
  # Ramp signal generator to control the frequency of input_signal1 and input_signal2.
  ramp = BlockComponents.Ramp(start_time=0, duration=1, offset=0, height=200) [{
    "Dyad": {
      "placement": {"icon": {"x1": -600, "y1": 250, "x2": -400, "y2": 450, "rot": 0}}
    }
  }]
  # Constant signal generator to control the amplitude of input_signal1 and input_signal2.
  const_signal = BlockComponents.Constant(k=1) [{
    "Dyad": {
      "placement": {"icon": {"x1": -600, "y1": 550, "x2": -400, "y2": 750, "rot": 0}}
    }
  }]
  # Voltage source for the second RLC circuit (cosine wave input).
  voltage_source2 = VoltageSource() [{
    "Dyad": {
      "placement": {"icon": {"x1": 100, "y1": 700, "x2": 300, "y2": 900, "rot": 180}}
    }
  }]
  # Ground connection for the second RLC circuit.
  ground2 = Ground() [{
    "Dyad": {
      "placement": {"icon": {"x1": 400, "y1": 1000, "x2": 600, "y2": 1200, "rot": 0}}
    }
  }]
  # Resistor in the second RLC circuit with R=0.5 Ohm.
  resistor2 = Resistor(R=0.5) [{
    "Dyad": {
      "placement": {"icon": {"x1": 1000, "y1": 700, "x2": 1200, "y2": 900, "rot": 0}}
    }
  }]
  # Inductor in the second RLC circuit with L=0.1/(2*pi) Henry.
  inductor2 = Inductor(L=0.1/(2*pi)) [{
    "Dyad": {"placement": {"icon": {"x1": 400, "y1": 700, "x2": 600, "y2": 900, "rot": 0}}}
  }]
  # Capacitor in the second RLC circuit with C=0.001/(2*pi) Farad.
  capacitor2 = Capacitor(C=0.001/(2*pi)) [{
    "Dyad": {"placement": {"icon": {"x1": 700, "y1": 700, "x2": 900, "y2": 900, "rot": 0}}}
  }]
  # Current sensor to measure the current in the second RLC circuit.
  current_sensor2 = CurrentSensor() [{
    "Dyad": {
      "placement": {"icon": {"x1": 1300, "y1": 700, "x2": 1500, "y2": 900, "rot": 0}}
    }
  }]
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) [{
    "Dyad": {
      "edges": [
        {"S": -1, "M": [{"x": -350, "y": 350}], "E": 1},
        {"S": -1, "E": 2},
        {"S": -1, "M": [{"x": -350, "y": 1140}], "E": 3}
      ],
      "junctions": [{"x": -350, "y": 540}]
    }
  }]
  connect(const_signal.y, input_signal1.amplitude, input_signal2.amplitude) [{
    "Dyad": {
      "edges": [
        {"S": -1, "E": 1},
        {"S": -1, "M": [{"x": -300, "y": 460}], "E": 2},
        {"S": -1, "M": [{"x": -300, "y": 1060}], "E": 3}
      ],
      "junctions": [{"x": -300, "y": 650}]
    }
  }]
  connect(input_signal1.y, voltage_source1.V) [{"Dyad": {"edges": [{"S": 1, "M": [{"x": 200, "y": 500}], "E": 2}]}}]
  connect(input_signal2.y, voltage_source2.V) [{"Dyad": {"edges": [{"S": 1, "M": [{"x": 200, "y": 1100}], "E": 2}]}}]
  # sine
  connect(voltage_source1.p, inductor1.p) [{"Dyad": {"edges": [{"S": 1, "E": 2}]}}]
  connect(inductor1.n, capacitor1.p) [{"Dyad": {"edges": [{"S": 1, "E": 2}]}}]
  connect(capacitor1.n, resistor1.p) [{"Dyad": {"edges": [{"S": 1, "E": 2}]}}]
  connect(voltage_source1.n, ground1.g) [{
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [{"x": 50, "y": 200}, {"x": 50, "y": 350}, {"x": 500, "y": 350}],
          "E": 2
        }
      ]
    }
  }]
  connect(current_sensor1.p, resistor1.n) [{"Dyad": {"edges": [{"S": 1, "E": 2}]}}]
  connect(ground1.g, current_sensor1.n) [{
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [{"x": 500, "y": 350}, {"x": 1550, "y": 350}, {"x": 1550, "y": 200}],
          "E": 2
        }
      ]
    }
  }]
  # cosine
  connect(voltage_source2.p, inductor2.p) [{"Dyad": {"edges": [{"S": 1, "E": 2}]}}]
  connect(inductor2.n, capacitor2.p) [{"Dyad": {"edges": [{"S": 1, "E": 2}]}}]
  connect(capacitor2.n, resistor2.p) [{"Dyad": {"edges": [{"S": 1, "E": 2}]}}]
  connect(voltage_source2.n, ground2.g) [{
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [{"x": 50, "y": 800}, {"x": 50, "y": 950}, {"x": 500, "y": 950}],
          "E": 2
        }
      ]
    }
  }]
  connect(current_sensor2.p, resistor2.n) [{"Dyad": {"edges": [{"S": 1, "E": 2}]}}]
  connect(ground2.g, current_sensor2.n) [{
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [{"x": 500, "y": 950}, {"x": 1550, "y": 950}, {"x": 1550, "y": 800}],
          "E": 2
        }
      ]
    }
  }]
metadata {
  "Dyad": {
    "tests": {
      "case1": {"stop": 1, "expect": {"signals": ["current_sensor1.i", "current_sensor2.i"]}}
    }
  }
}
end


Test Cases

This is setup code, that must be run before each test case.

julia
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

julia
@mtkbuild model_case1 = SeriesResonance()
u0_case1 = []
prob_case1 = ODEProblem(model_case1, u0_case1, (0, 1))
sol_case1 = solve(prob_case1)
retcode: Success
Interpolation: 3rd order Hermite
t: 751-element Vector{Float64}:
 0.0
 9.999999999999999e-5
 0.0003378966646822892
 0.0007191170987346105
 0.001204313955856896
 0.0018161534920167312
 0.0025312657854854076
 0.0033665013291654775
 0.004344836124409957
 0.005450064597474674

 0.9933652500691713
 0.9943068458953436
 0.9952223288147531
 0.9961644551965757
 0.997115523083239
 0.9980511759773798
 0.9989569443589585
 0.9998953843706564
 1.0
u: 751-element Vector{Vector{Float64}}:
 [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
 [6.283185307179582e-6, 6.283185307179582e-6, 2.065506523083523e-9, 0.0019712069271423135, 1.3146548828883822e-8, 0.0062691991623969705]
 [7.173773794602897e-5, 7.173773794602897e-5, 2.684837008035613e-7, 0.022373372286655265, 5.051967433327421e-7, 0.020960094478614355]
 [0.0003249219858624782, 0.0003249219858624782, 5.465697669541273e-6, 0.09960352436542735, 4.816843950750888e-6, 0.043172185624124684]
 [0.0009112956695502994, 0.0009112956695502994, 4.234290145172508e-5, 0.2695135627916461, 2.2128852678765637e-5, 0.06736971898958834]
 [0.0020724543281449175, 0.0020724543281449175, 0.00021296152690545393, 0.5727357419856711, 7.283595921170218e-5, 0.08836646427924794]
 [0.004025829391343193, 0.004025829391343193, 0.0007683990233253838, 0.9943721572344495, 0.00018448567554639323, 0.09611405768217361]
 [0.007120942007267163, 0.007120942007267163, 0.002244692701477176, 1.4704250561998065, 0.00039144930168890686, 0.08119246962057897]
 [0.011861146491113313, 0.011861146491113313, 0.005623912565799171, 1.8463061820789957, 0.0007203448707543966, 0.0374532949027714]
 [0.018663073568187128, 0.018663073568187128, 0.012082113447992761, 1.8880902313581083, 0.0011411815261134512, -0.025538619819881016]

 [620.0087165845855, 620.0087165845855, 0.31817014910065, 0.14257011961432023, 0.027954523775644263, -0.062340721418013]
 [621.1846673360984, 621.1846673360984, 0.25663474812832804, -0.2338027469448987, -0.04628446297782958, -0.05004579057637369]
 [622.3290741271979, 622.3290741271979, -0.10153416617364819, -0.32765230298760206, -0.06443502630177558, 0.020906921542150687]
 [623.5078864148858, 623.5078864148858, -0.33554442359800873, -0.03252050540798391, -0.005428395966735799, 0.06690749003075706]
 [624.6990178617905, 624.6990178617905, -0.15063701829452122, 0.2948592562216997, 0.05962930707885369, 0.029443277393094627]
 [625.871952525335, 625.871952525335, 0.21366864672935332, 0.24734595229054657, 0.0496572117012443, -0.04356049416855524]
 [627.0084719309008, 627.0084719309008, 0.311539647087052, -0.09409953715544178, -0.019040184700517014, -0.0630725051900871]
 [628.1870737175084, 628.1870737175084, 0.027758190255501088, -0.3257527000578541, -0.0657145947322741, -0.006068890134120599]
 [628.3185307179589, 628.3185307179589, -0.015583903016836275, -0.3268818744058203, -0.06596941988765621, 0.002639116689197291]
julia
df_case1 = DataFrame(:t => sol_case1[:t], :actual => sol_case1[model_case1.current_sensor1.i])
dfr_case1 = try CSV.read(joinpath(snapshotsdir, "SeriesResonance_case1_sig0.ref"), DataFrame); catch e; nothing; end
plt = plot(sol_case1, idxs=[model_case1.current_sensor1.i], width=2, label="Actual value of current_sensor1.i")
if !isnothing(dfr_case1)
  scatter!(plt, dfr_case1.t, dfr_case1.expected, mc=:red, ms=3, label="Expected value of current_sensor1.i")
end

plt

julia
df_case1 = DataFrame(:t => sol_case1[:t], :actual => sol_case1[model_case1.current_sensor2.i])
dfr_case1 = try CSV.read(joinpath(snapshotsdir, "SeriesResonance_case1_sig1.ref"), DataFrame); catch e; nothing; end
plt = plot(sol_case1, idxs=[model_case1.current_sensor2.i], width=2, label="Actual value of current_sensor2.i")
if !isnothing(dfr_case1)
  scatter!(plt, dfr_case1.t, dfr_case1.expected, mc=:red, ms=3, label="Expected value of current_sensor2.i")
end

plt

  • Examples

  • Experiments

  • Analyses