Tags and keywords
The Modelica By Example target code is:
within ModelicaByExample.Components.Rotational.Examples;
model SMD
Components.Ground ground annotation ...
Components.Damper damper2(d=1)
annotation ...
Components.Spring spring2(c=5)
annotation ...
Components.Inertia inertia2(
J=1,
phi(fixed=true, start=1),
w(fixed=true, start=0))
annotation ...
Components.Damper damper1(d=0.2)
annotation ...
Components.Spring spring1(c=11)
annotation ...
Components.Inertia inertia1(
J=0.4,
phi(fixed=true, start=0),
w(fixed=true, start=0))
annotation ...
equation
connect(ground.flange_a, damper2.flange_b) annotation ...
connect(ground.flange_a, spring2.flange_b) annotation ...
connect(damper2.flange_a, inertia2.flange_b) annotation ...
connect(spring2.flange_a, inertia2.flange_b) annotation ...
connect(inertia2.flange_a, damper1.flange_b) annotation ...
connect(inertia2.flange_a, spring1.flange_b) annotation ...
connect(damper1.flange_a, inertia1.flange_b) annotation ...
connect(spring1.flange_a, inertia1.flange_b) annotation ...
end SMD;
This reuses one of each of the components from the previous diagram to build the following system:
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.
This SysML/SysPhS trail version uses slightly different and more concise naming. The Dependencies from the parts to the instances that defined the 'start' values are only just for illustration.
The complete exported Modelica code for block SMD
is:
model SMD
SMD _SMD;
model SMD
Damper d1(d.start=0.2,d.fixed=true);
Damper d2(d.start=1.0,d.fixed=true);
Spring s1(c.start=11.0,c.fixed=true);
Spring s2(c.start=5.0,c.fixed=true);
RotationalInertia i1(j.start=0.4,j.fixed=true,phi.start=0.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);
Ground g;
equation
connect(g.f,d2.fb);
connect(g.f,s2.fb);
connect(i2.fb,d2.fa);
connect(i2.fb,s2.fa);
connect(d1.fb,i2.fa);
connect(s1.fb,i2.fa);
connect(d1.fa,i1.fb);
connect(s1.fa,i1.fb);
end SMD;
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");
end SMD;