GroundedGear - comparison

Gallery
Tutorial
Click on the image to view it full size

The Modelica By Example target code is:


within ModelicaByExample.Components.Rotational.Components;
model GroundedGear "An ideal non-reversing gear with grounded housing"
  parameter Real ratio "Ratio of phi_a/phi_b";
  extends Interfaces.TwoFlange;
equation
  ratio*flange_a.tau + flange_b.tau = 0 "No storage";
  flange_a.phi = ratio*flange_b.phi "Kinematic constraint";
  annotation ...
end GroundedGear;

The Modelica By Example page does not show the code for the usage comparison, but it does give this patch diagram:

This page contains content quoted, copied, or adapted for educational purposes from the Modelica By Example tutorials for educational purposes. The original © copyright is retained by Dr. Michael M. Tiller.

With a little detective work (including viewing the simulation plot) the initial values can be gleaned. The Dependencies from the parts to the instances that defined the 'start' values are just for illustration.

The complete exported Modelica code for block GroundedGearComparison is:


model GroundedGearComparison
  GroundedGearComparison _GroundedGearComparison;
  model GroundedGearComparison
    GroundedGear gg(ratio.start=2.0,ratio.fixed=true);
    Damper d2(d.start=1.0,d.fixed=true);
    Damper d3(d.start=1.0,d.fixed=true);
    Spring s2(c.start=5.0,c.fixed=true);
    Spring s3(c.start=5.0,c.fixed=true);
    RotationalInertia i1(j.start=0.4,j.fixed=true,phi.start=2.0,phi.fixed=true,w.start=0.0,w.fixed=true);
    RotationalInertia i2(j.start=1.0,j.fixed=true,phi.start=1.0,phi.fixed=true,w.start=0.0,w.fixed=true);
    RotationalInertia i3(j.start=2.6,j.fixed=true,phi.start=1.0,phi.fixed=true,w.start=0.0,w.fixed=true);
    Ground g2;
    Ground g3;
  equation
    connect(g2.f,d2.fb);
    connect(g2.f,s2.fb);
    connect(d2.fa,i2.fb);
    connect(s2.fa,i2.fb);
    connect(gg.fb,i2.fa);
    connect(gg.fa,i1.fb);
    connect(d3.fa,i3.fb);
    connect(g3.f,d3.fb);
    connect(g3.f,s3.fb);
    connect(s3.fa,i3.fb);
  end GroundedGearComparison;
  model GroundedGear
    extends TwoFlange;
    parameter Real ratio;
  equation
    ratio*fa.tau+fb.tau=0;
    fa.phi=ratio*fb.phi;
  end GroundedGear;
  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 TwoFlange
    Flange_a fa;
    Flange_b fb;
  protected
    Angle phi_rel;
  equation
    phi_rel=fa.phi-fb.phi;
  end TwoFlange;
  model Compliant
    extends TwoFlange;
    Torque tau;
  equation
    tau=fa.tau;
    fa.tau+fb.tau=0;
  end Compliant;
  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");
end GroundedGearComparison;
Up next
Notes
Snippets (quotes/extracts)
Visit also
Visit also (backlinks)
Related slides (includes other tutorials)
Related slides (backlinks, includes other tutorials)
External links