Compliant - RotationalInertia - Spring - Damper - Ground

Gallery
Tutorial
Click on the image to view it full size

The Modelica By Example target code is:


within ModelicaByExample.Components.Rotational.Interfaces;
partial model Compliant "A compliant rotational component"
  extends ModelicaByExample.Components.Rotational.Interfaces.TwoFlange;
protected
  Modelica.SIunits.Torque tau;
equation
  tau = flange_a.tau;
  flange_a.tau + flange_b.tau = 0
    "Conservation of angular momentum (no storage)";
end Compliant;

within ModelicaByExample.Components.Rotational.Components;
model Inertia "A rotational inertia model"
  parameter Modelica.SIunits.Inertia J;
  extends ModelicaByExample.Components.Rotational.Interfaces.TwoFlange;
  Modelica.SIunits.AngularVelocity w "Angular Velocity"
    annotation ...
  Modelica.SIunits.Angle phi "Angle"
    annotation ...
equation
  phi = flange_a.phi;
  w = der(flange_a.phi) "velocity of inertia";
  phi_rel = 0 "inertia is rigid";
  J*der(w) = flange_a.tau + flange_b.tau
    "Conservation of angular momentum with storage";
end Inertia;

within ModelicaByExample.Components.Rotational.Components;
model Spring "A rotational spring component"
  parameter Modelica.SIunits.RotationalSpringConstant c;
  extends ModelicaByExample.Components.Rotational.Interfaces.Compliant;
equation
  tau = c*phi_rel "Hooke's Law";
end Spring;

within ModelicaByExample.Components.Rotational.Components;
model Damper "A rotational damper"
  parameter Modelica.SIunits.RotationalDampingConstant d;
  extends ModelicaByExample.Components.Rotational.Interfaces.Compliant;
equation
  tau = d*der(phi_rel) "Damping relationship";
end Damper;

within ModelicaByExample.Components.Rotational.Components;
model Ground "Mechanical ground"
  Modelica.Mechanics.Rotational.Interfaces.Flange_a flange_a
    annotation ...
equation
  flange_a.phi = 0;
end Ground;

Note we're targeting the DRY versions.

Except for Ground they all reuse TwoFlange from the previous diagram.

This SysML/SysPhS trail version uses slightly different and more concise naming.

The exported Modelica code (exported as usages to be shown in the next slide) is:


  model Damper
    extends Compliant;
    parameter RotationalDampingConstant d;
  equation
    tau=d*der(phi_rel);
  end Damper;

  model Spring
    extends Compliant;
    parameter RotationalSpringConstant c;
  equation
    tau=c*phi_rel;
  end Spring;

  model RotationalInertia
    extends TwoFlange;
    AngularVelocity w;
    Angle phi;
    parameter Inertia j;
  equation
    phi=fa.phi;
    w=der(fa.phi);
    phi_rel=0;
    j*der(w)=fa.tau+fb.tau;
  end RotationalInertia;

  model Ground
    Flange_a f;
  equation
    f.phi=0;
  end Ground;

  connector Flange_a
    extends Flange;
  end Flange_a;

  connector Flange_b
    extends Flange;
  end Flange_b;

  model Compliant
    extends TwoFlange;
    Torque tau;
  equation
    tau=fa.tau;
    fa.tau+fb.tau=0;
  end Compliant;

  model TwoFlange
    Flange_a fa;
    Flange_b fb;
  protected
    Angle phi_rel;
  equation
    phi_rel=fa.phi-fb.phi;
  end TwoFlange;

  connector Flange
    flow Torque tau;
    Angle phi;
  end Flange;

  type RotationalDampingConstant=Real(unit="N.m.s/rad");
  type RotationalSpringConstant=Real(unit="N.m/rad");
  type AngularVelocity=Real(unit="rad/s");
  type Angle=Real(unit="rad");
  type Inertia=Real(unit="kg.m2");
  type Torque=Real(unit="N·m");
Up next
Notes
Snippets (quotes/extracts)
Visit also
Visit also (backlinks)
Related slides (includes other tutorials)
Related slides (backlinks, includes other tutorials)
External links