A Mechanical Example - SecondOrderSystem

Gallery
Tutorial
Click on the image to view it full size
The Modelica By Example target code including an 'initial equation' is:

model SecondOrderSystem "A second order rotational system"
  type Angle=Real(unit="rad");
  type AngularVelocity=Real(unit="rad/s");
  type Inertia=Real(unit="kg.m2");
  type Stiffness=Real(unit="N.m/rad");
  type Damping=Real(unit="N.m.s/rad");
  parameter Inertia J1=0.4 "Moment of inertia for inertia 1";
  parameter Inertia J2=1.0 "Moment of inertia for inertia 2";
  parameter Stiffness c1=11 "Spring constant for spring 1";
  parameter Stiffness c2=5 "Spring constant for spring 2";
  parameter Damping d1=0.2 "Damping for damper 1";
  parameter Damping d2=1.0 "Damping for damper 2";
  Angle phi1 "Angle for inertia 1";
  Angle phi2 "Angle for inertia 2";
  AngularVelocity omega1 "Velocity of inertia 1";
  AngularVelocity omega2 "Velocity of inertia 2";
initial equation
  phi1 = 0;
  phi2 = 1;
  omega1 = 0;
  omega2 = 0;
equation
  // Equations for inertia 1
  omega1 = der(phi1);
  J1*der(omega1) = c1*(phi2-phi1)+d1*der(phi2-phi1);
  // Equations for inertia 2
  omega2 = der(phi2);
  J2*der(omega2) = c1*(phi1-phi2)+d1*der(phi1-phi2)-c2*phi2-d2*der(phi2);
end SecondOrderSystem;

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


model SecondOrderSystem
  SecondOrderSystem _SecondOrderSystem;
  model SecondOrderSystem
    parameter Inertia j1(start=0.4,fixed=true);
    parameter Inertia j2(start=1.0,fixed=true);
    parameter Stiffness c1(start=11.0,fixed=true);
    parameter Stiffness c2(start=5.0,fixed=true);
    parameter Damping d1(start=0.2,fixed=true);
    parameter Damping d2(start=1.0,fixed=true);
    Angle phi1(start=0.0,fixed=true);
    Angle phi2(start=1.0,fixed=true);
    AngularVelocity omega1(start=0.0,fixed=true);
    AngularVelocity omega2(start=0.0,fixed=true);
  equation
    omega1=der(phi1);
    j1*der(omega1)=c1*(phi2-phi1)+d1*der(phi2-phi1);
    omega2=der(phi2);
    j2*der(omega2)=c1*(phi1-phi2)+d1*der(phi1-phi2)-c2*phi2-d2*der(phi2);
  end SecondOrderSystem;
  type Inertia=Real(unit="kg.m2");
  type Stiffness=Real(unit="N.m/rad");
  type Damping=Real(unit="N.m.s/rad");
  type Angle=Real(unit="rad");
  type AngularVelocity=Real(unit="rad/s");
end SecondOrderSystem;

Noting that SysPhS-1.1 does not support Modelica's 'initial equation', the variant SecondOrderSystemInitParams was not attempted here via SysPhS.
Up next
Notes
Snippets (quotes/extracts)
Visit also
Visit also (backlinks)
Related slides (includes other tutorials)
Related slides (backlinks, includes other tutorials)
External links