An Electrical Example - RLC1

Gallery
Tutorial
The Modelica By Example target code is:

model RLC1 "A resistor-inductor-capacitor circuit model"
  type Voltage=Real(unit="V");
  type Current=Real(unit="A");
  type Resistance=Real(unit="Ohm");
  type Capacitance=Real(unit="F");
  type Inductance=Real(unit="H");
  parameter Voltage Vb=24 "Battery voltage";
  parameter Inductance L = 1;
  parameter Resistance R = 100;
  parameter Capacitance C = 1e-3;
  Voltage V;
  Current i_L;
  Current i_R;
  Current i_C;
equation
  V = i_R*R;
  C*der(V) = i_C;
  L*der(i_L) = (Vb-V);
  i_L=i_R+i_C;
end RLC1;

The exported Modelica code is (using lower case value property names):


model RLC1
  RLC1 _RLC1;
  model RLC1
    parameter Voltage vb(start=24.0,fixed=true);
    parameter Inductance l(start=1.0,fixed=true);
    parameter Resistance r(start=100.0,fixed=true);
    parameter Capacitance c(start=0.001,fixed=true);
    Voltage v;
    Current i_l;
    Current i_r;
    Current i_c;
  equation
    v=i_r*r;
    c*der(v)=i_c;
    l*der(i_l)=(vb-v);
    i_l=i_r+i_c;
  end RLC1;
  type Voltage=Real(unit="V");
  type Inductance=Real(unit="H");
  type Resistance=Real(unit="Ohm");
  type Capacitance=Real(unit="F");
  type Current=Real(unit="A");
end RLC1;

A custom version of the ValueType Resistance was used to get a Modelica-friendly units symbols 'Ohm'.

Up next
Notes
Snippets (quotes/extracts)
Visit also
Visit also (backlinks)
Related slides (includes other tutorials)
Related slides (backlinks, includes other tutorials)
External links