UngroundedGearComparison - 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 UngroundedGear "An ideal non-reversing gear with a free housing"
  parameter Real ratio "Ratio of phi_a/phi_b";
  extends Interfaces.TwoFlange;
  Modelica.Mechanics.Rotational.Interfaces.Flange_b housing
    "Connection for housing"
    annotation ...
equation
  (1-ratio)*housing.phi = flange_a.phi - ratio*flange_b.phi;
  flange_b.tau = -ratio*flange_a.tau;
  housing.tau = -(1-ratio)*flange_a.tau;
end UngroundedGear;

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.
Modelica By Example has an error in the value of 'J' shared by inertia1, inertia3, inertia5. In the patch diagram it has 0.4, in the inline simulation panel it has 1.4; execution and plotting confirms it is 1.4

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. Note how the shared values are DRY.

The complete exported Modelica code for block GroundedGearComparison is:


model UngroundedGearComparison
  UngroundedGearComparison _UngroundedGearComparison;
  model UngroundedGearComparison
    GroundedGear gg(ratio.start=2.0,ratio.fixed=true);
    UngroundedGear ug1(ratio.start=2.0,ratio.fixed=true);
    UngroundedGear ug2(ratio.start=2.0,ratio.fixed=true);
    Damper d2(d.start=1.0,d.fixed=true);
    Damper d6(d.start=1.0,d.fixed=true);
    Damper d4(d.start=1.0,d.fixed=true);
    Damper dh(d.start=0.2,d.fixed=true);
    Spring s2(c.start=5.0,c.fixed=true);
    Spring s4(c.start=5.0,c.fixed=true);
    Spring s6(c.start=5.0,c.fixed=true);
    Spring sh(c.start=80.0,c.fixed=true);
    RotationalInertia i1(j.start=1.4,j.fixed=true,phi.start=4.0,phi.fixed=true,w.start=0.0,w.fixed=true);
    RotationalInertia i2(j.start=1.0,j.fixed=true,phi.start=2.0,phi.fixed=true,w.start=0.0,w.fixed=true);
    RotationalInertia i3(j.start=1.4,j.fixed=true,phi.start=4.0,phi.fixed=true,w.start=0.0,w.fixed=true);
    RotationalInertia i4(j.start=1.0,j.fixed=true,phi.start=2.0,phi.fixed=true,w.start=0.0,w.fixed=true);
    RotationalInertia i5(j.start=1.4,j.fixed=true,phi.start=4.0,phi.fixed=true,w.start=0.0,w.fixed=true);
    RotationalInertia i6(j.start=1.0,j.fixed=true,phi.start=2.0,phi.fixed=true,w.start=0.0,w.fixed=true);
    Ground g2;
    Ground g4;
    Ground g5;
    Ground g6;
    Ground gh;
  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(d4.fa,i4.fb);
    connect(g4.f,d4.fb);
    connect(g4.f,s4.fb);
    connect(s4.fa,i4.fb);
    connect(ug2.housing,g5.f);
    connect(ug2.fa,i3.fb);
    connect(i4.fa,ug2.fb);
    connect(dh.fa,gh.f);
    connect(ug1.housing,dh.fb);
    connect(ug1.housing,sh.fb);
    connect(sh.fa,gh.f);
    connect(ug1.fa,i5.fb);
    connect(g6.f,s6.fb);
    connect(s6.fa,i6.fb);
    connect(i6.fa,ug1.fb);
    connect(g6.f,d6.fb);
    connect(d6.fa,i6.fb);
  end UngroundedGearComparison;
  model GroundedGear
    extends TwoFlange;
    parameter Real ratio;
  equation
    ratio*fa.tau+fb.tau=0;
    fa.phi=ratio*fb.phi;
  end GroundedGear;
  model UngroundedGear
    extends TwoFlange;
    parameter Real ratio;
    Flange_b housing;
  equation
    fb.tau=-ratio*fa.tau;
    (1-ratio)*housing.phi=fa.phi-ratio*fb.phi;
    housing.tau=-(1-ratio)*fa.tau;
  end UngroundedGear;
  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 UngroundedGearComparison;

The Modelica By Example case ConfigurableGear is not attempted yet because:
Up next
Notes
Snippets (quotes/extracts)
Visit also
Visit also (backlinks)
Related slides (includes other tutorials)
Related slides (backlinks, includes other tutorials)
External links