$(instance)SinRLC Icon

SinRLC

An RLC circuit with Sine voltage input

Usage

SinRLC()

Behavior

\[ \begin{equation} \left[ \begin{array}{c} \mathrm{connect}\left( sine_{+}y(t), source_{+}V(t) \right) \\ \mathrm{connect}\left( source_{+}n, inductor_{+}p \right) \\ \mathrm{connect}\left( inductor_{+}n, resistor_{+}n, capacitor_{+}n \right) \\ \mathrm{connect}\left( resistor_{+}p, ground_{+}g, capacitor_{+}p, source_{+}p \right) \\ \mathtt{resistor.v}\left( t \right) = - \mathtt{resistor.n.v}\left( t \right) + \mathtt{resistor.p.v}\left( t \right) \\ \mathtt{resistor.i}\left( t \right) = \mathtt{resistor.p.i}\left( t \right) \\ \mathtt{resistor.p.i}\left( t \right) + \mathtt{resistor.n.i}\left( t \right) = 0 \\ \mathtt{resistor.v}\left( t \right) = \mathtt{resistor.R} \mathtt{resistor.i}\left( t \right) \\ \mathtt{capacitor.v}\left( t \right) = \mathtt{capacitor.p.v}\left( t \right) - \mathtt{capacitor.n.v}\left( t \right) \\ \mathtt{capacitor.i}\left( t \right) = \mathtt{capacitor.p.i}\left( t \right) \\ \mathtt{capacitor.p.i}\left( t \right) + \mathtt{capacitor.n.i}\left( t \right) = 0 \\ \mathtt{capacitor.C} \frac{\mathrm{d} \mathtt{capacitor.v}\left( t \right)}{\mathrm{d}t} = \mathtt{capacitor.i}\left( t \right) \\ \mathtt{inductor.v}\left( t \right) = - \mathtt{inductor.n.v}\left( t \right) + \mathtt{inductor.p.v}\left( t \right) \\ \mathtt{inductor.i}\left( t \right) = \mathtt{inductor.p.i}\left( t \right) \\ \mathtt{inductor.p.i}\left( t \right) + \mathtt{inductor.n.i}\left( t \right) = 0 \\ \mathtt{inductor.L} \frac{\mathrm{d} \mathtt{inductor.i}\left( t \right)}{\mathrm{d}t} = \mathtt{inductor.v}\left( t \right) \\ \mathtt{source.v}\left( t \right) = - \mathtt{source.n.v}\left( t \right) + \mathtt{source.p.v}\left( t \right) \\ \mathtt{source.i}\left( t \right) = \mathtt{source.p.i}\left( t \right) \\ \mathtt{source.p.i}\left( t \right) + \mathtt{source.n.i}\left( t \right) = 0 \\ \mathtt{source.v}\left( t \right) = \mathtt{source.uV} \mathtt{source.V}\left( t \right) \\ \mathtt{sine.y}\left( t \right) = ifelse\left( \mathtt{sine.start\_time} < t, \mathtt{sine.offset} + \mathtt{sine.amplitude} \sin\left( \mathtt{sine.phase} + 6.2832 \mathtt{sine.frequency} \left( - \mathtt{sine.start\_time} + t \right) \right), \mathtt{sine.offset} \right) \\ \mathtt{ground.g.v}\left( t \right) = 0 \\ \end{array} \right] \end{equation} \]

Source

# An RLC circuit with Sine voltage input
example component SinRLC
  resistor = Resistor(R=100) [{
    "JuliaSim": {
      "placement": {"icon": {"x1": 1100, "y1": 400, "x2": 1300, "y2": 600, "rot": -90}}
    }
  }]
  capacitor = Capacitor(C=1m) [{
    "JuliaSim": {
      "placement": {"icon": {"x1": 800, "y1": 400, "x2": 1000, "y2": 600, "rot": -90}}
    }
  }]
  inductor = Inductor(L=1) [{
    "JuliaSim": {"placement": {"icon": {"x1": 600, "y1": 100, "x2": 800, "y2": 300}}}
  }]
  source = VoltageSource() [{
    "JuliaSim": {
      "placement": {"icon": {"x1": 400, "y1": 400, "x2": 600, "y2": 600, "rot": -90}}
    }
  }]
  sine = BlockComponents.Sine(frequency=1, amplitude=1, phase=0) [{
    "JuliaSim": {"placement": {"icon": {"x1": 100, "y1": 400, "x2": 300, "y2": 600}}}
  }]
  ground = Ground() [{
    "JuliaSim": {"placement": {"icon": {"x1": 800, "y1": 900, "x2": 1000, "y2": 1100}}}
  }]
relations
  initial inductor.i = 0
  initial capacitor.v = 10
  connect(sine.y, source.V) [{"JuliaSim": {"edges": [{"S": 1, "E": 2}]}}]
  connect(source.n, inductor.p) [{"JuliaSim": {"edges": [{"S": 1, "M": [{"x": 500, "y": 200}], "E": 2}]}}]
  connect(inductor.n, resistor.n, capacitor.n) [{
    "JuliaSim": {
      "edges": [
        {"S": 1, "E": -1},
        {"S": 2, "M": [{"x": 1200, "y": 200}], "E": -1},
        {"S": 3, "E": -1}
      ],
      "junctions": [{"x": 900, "y": 200}]
    }
  }]
  connect(resistor.p, ground.g, capacitor.p, source.p) [{
    "JuliaSim": {
      "edges": [
        {"S": 1, "M": [{"x": 1200, "y": 800}], "E": -1},
        {"S": 2, "E": -1},
        {"S": 3, "E": -1},
        {"S": -1, "M": [{"x": 500, "y": 800}], "E": 4}
      ],
      "junctions": [{"x": 900, "y": 800}]
    }
  }]
metadata {
  "JuliaSim": {
    "tests": {
      "case1": {
        "stop": 10,
        "expect": {"initial": {"capacitor.v": 10}, "final": {"capacitor.v": -0.067835084}}
      }
    }
  }
}
end
Flattened Source
# An RLC circuit with Sine voltage input
example component SinRLC
  resistor = Resistor(R=100) [{
    "JuliaSim": {
      "placement": {"icon": {"x1": 1100, "y1": 400, "x2": 1300, "y2": 600, "rot": -90}}
    }
  }]
  capacitor = Capacitor(C=1m) [{
    "JuliaSim": {
      "placement": {"icon": {"x1": 800, "y1": 400, "x2": 1000, "y2": 600, "rot": -90}}
    }
  }]
  inductor = Inductor(L=1) [{
    "JuliaSim": {"placement": {"icon": {"x1": 600, "y1": 100, "x2": 800, "y2": 300}}}
  }]
  source = VoltageSource() [{
    "JuliaSim": {
      "placement": {"icon": {"x1": 400, "y1": 400, "x2": 600, "y2": 600, "rot": -90}}
    }
  }]
  sine = BlockComponents.Sine(frequency=1, amplitude=1, phase=0) [{
    "JuliaSim": {"placement": {"icon": {"x1": 100, "y1": 400, "x2": 300, "y2": 600}}}
  }]
  ground = Ground() [{
    "JuliaSim": {"placement": {"icon": {"x1": 800, "y1": 900, "x2": 1000, "y2": 1100}}}
  }]
relations
  initial inductor.i = 0
  initial capacitor.v = 10
  connect(sine.y, source.V) [{"JuliaSim": {"edges": [{"S": 1, "E": 2}]}}]
  connect(source.n, inductor.p) [{"JuliaSim": {"edges": [{"S": 1, "M": [{"x": 500, "y": 200}], "E": 2}]}}]
  connect(inductor.n, resistor.n, capacitor.n) [{
    "JuliaSim": {
      "edges": [
        {"S": 1, "E": -1},
        {"S": 2, "M": [{"x": 1200, "y": 200}], "E": -1},
        {"S": 3, "E": -1}
      ],
      "junctions": [{"x": 900, "y": 200}]
    }
  }]
  connect(resistor.p, ground.g, capacitor.p, source.p) [{
    "JuliaSim": {
      "edges": [
        {"S": 1, "M": [{"x": 1200, "y": 800}], "E": -1},
        {"S": 2, "E": -1},
        {"S": 3, "E": -1},
        {"S": -1, "M": [{"x": 500, "y": 800}], "E": 4}
      ],
      "junctions": [{"x": 900, "y": 800}]
    }
  }]
metadata {
  "JuliaSim": {
    "tests": {
      "case1": {
        "stop": 10,
        "expect": {"initial": {"capacitor.v": 10}, "final": {"capacitor.v": -0.067835084}}
      }
    }
  }
}
end

Test Cases

Test Case case1

  • Examples
  • Experiments
  • Analyses