Skip to content

Commit

Permalink
refs modelica#2468: Remove superfluous constants
Browse files Browse the repository at this point in the history
  • Loading branch information
beutlich committed Jul 15, 2019
1 parent 7a6a457 commit cb18955
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 32 deletions.
20 changes: 8 additions & 12 deletions Modelica/Mechanics/MultiBody/Joints.mo
Expand Up @@ -19,8 +19,6 @@ package Joints "Components that constrain the motion between two frames"
parameter Modelica.Mechanics.MultiBody.Types.Axis n={1,0,0}
"Axis of translation resolved in frame_a (= same as in frame_b)"
annotation (Evaluate=true);
constant SI.Position s_offset=0
"Relative distance offset (distance between frame_a and frame_b = s_offset + s)";
parameter Types.Axis boxWidthDirection={0,1,0}
"Vector in width direction of box, resolved in frame_a"
annotation (Evaluate=true, Dialog(tab="Animation", group=
Expand Down Expand Up @@ -64,7 +62,7 @@ Possible reasons:
shapeType="box",
color=boxColor,
specularCoefficient=specularCoefficient,
length=if noEvent(abs(s + s_offset) > 1.e-6) then s + s_offset else 1.e-6,
length=if noEvent(abs(s) > 1.e-6) then s else 1.e-6,
width=boxWidth,
height=boxHeight,
lengthDirection=e,
Expand All @@ -82,12 +80,12 @@ Possible reasons:
a = der(v);

// relationships between kinematic quantities of frame_a and of frame_b
frame_b.r_0 = frame_a.r_0 + Frames.resolve1(frame_a.R, e*(s_offset + s));
frame_b.r_0 = frame_a.r_0 + Frames.resolve1(frame_a.R, e*s);
frame_b.R = frame_a.R;

// Force and torque balance
zeros(3) = frame_a.f + frame_b.f;
zeros(3) = frame_a.t + frame_b.t + cross(e*(s_offset + s), frame_b.f);
zeros(3) = frame_a.t + frame_b.t + cross(e*s, frame_b.f);

// d'Alemberts principle
f = -e*frame_b.f;
Expand Down Expand Up @@ -224,8 +222,6 @@ vector \"n\" defining the translation axis
parameter Modelica.Mechanics.MultiBody.Types.Axis n={0,0,1}
"Axis of rotation resolved in frame_a (= same as in frame_b)"
annotation (Evaluate=true);
constant SI.Angle phi_offset=0
"Relative angle offset (angle = phi_offset + phi)";
parameter SI.Distance cylinderLength=world.defaultJointLength
"Length of cylinder representing the joint axis"
annotation (Dialog(tab="Animation", group="if animation = true", enable=animation));
Expand All @@ -236,7 +232,7 @@ vector \"n\" defining the translation axis
"Color of cylinder representing the joint axis"
annotation (Dialog(colorSelector=true, tab="Animation", group="if animation = true", enable=animation));
input Modelica.Mechanics.MultiBody.Types.SpecularCoefficient
specularCoefficient = world.defaultSpecularCoefficient
specularCoefficient = world.defaultSpecularCoefficient
"Reflection of ambient light (= 0: light is completely absorbed)"
annotation (Dialog(tab="Animation", group="if animation = true", enable=animation));
parameter StateSelect stateSelect=StateSelect.prefer
Expand All @@ -258,7 +254,7 @@ Possible reasons:
SI.AngularAcceleration a(start=0)
"Second derivative of angle phi (relative angular acceleration)";
SI.Torque tau "Driving torque in direction of axis of rotation";
SI.Angle angle "= phi_offset + phi";
SI.Angle angle "= phi";

protected
outer Modelica.Mechanics.MultiBody.World world;
Expand Down Expand Up @@ -295,20 +291,20 @@ Possible reasons:
assert(cardinality(frame_b) > 0,
"Connector frame_b of revolute joint is not connected");

angle = phi_offset + phi;
angle = phi;
w = der(phi);
a = der(w);

// relationships between quantities of frame_a and of frame_b
frame_b.r_0 = frame_a.r_0;

if Connections.rooted(frame_a.R) then
R_rel = Frames.planarRotation(e, phi_offset + phi, w);
R_rel = Frames.planarRotation(e, phi, w);
frame_b.R = Frames.absoluteRotation(frame_a.R, R_rel);
frame_a.f = -Frames.resolve1(R_rel, frame_b.f);
frame_a.t = -Frames.resolve1(R_rel, frame_b.t);
else
R_rel = Frames.planarRotation(-e, phi_offset + phi, w);
R_rel = Frames.planarRotation(-e, phi, w);
frame_a.R = Frames.absoluteRotation(frame_b.R, R_rel);
frame_b.f = -Frames.resolve1(R_rel, frame_a.f);
frame_b.t = -Frames.resolve1(R_rel, frame_a.t);
Expand Down
27 changes: 7 additions & 20 deletions ModelicaTest/MultiBody.mo
Expand Up @@ -319,9 +319,7 @@ alt=\"model Examples.Elementary.DoublePendulum\">
transformation(extent={{-54,-40},{-34,-20}})));
Modelica.Mechanics.MultiBody.Joints.Prismatic j2(
n={1,0,0},
boxWidth=0.05,
s_offset=-0.2) annotation (Placement(transformation(extent={{12,-80},{
32,-60}})));
boxWidth=0.05) annotation (Placement(transformation(extent={{12,-80},{32,-60}})));
Modelica.Mechanics.MultiBody.Parts.BodyCylinder b1(r={0,0.5,0.1},
diameter=0.05) annotation (Placement(transformation(
origin={-30,0},
Expand Down Expand Up @@ -441,9 +439,7 @@ for rodLength:
n={1,0,0},
a(fixed=false),
s(fixed=true),
v(fixed=false),
s_offset=-0.2) annotation (Placement(transformation(extent={{12,-80},{
32,-60}})));
v(fixed=false)) annotation (Placement(transformation(extent={{12,-80},{32,-60}})));
Modelica.Mechanics.MultiBody.Parts.BodyCylinder b1(r={0,0.5,0.1},
diameter=0.05) annotation (Placement(transformation(
origin={-30,0},
Expand Down Expand Up @@ -539,9 +535,7 @@ menu (this sets \"fixed=false\" on parameter \"length\").
boxWidth=0.01,
a(fixed=false),
s(fixed=false),
v(fixed=false),
s_offset=-0.2) annotation (Placement(transformation(extent={{12,-80},{
32,-60}})));
v(fixed=false)) annotation (Placement(transformation(extent={{12,-80},{32,-60}})));
Modelica.Mechanics.MultiBody.Parts.BodyCylinder b1(r={0,0.5,0.1},
diameter=0.05) annotation (Placement(transformation(
origin={-30,0},
Expand Down Expand Up @@ -643,17 +637,14 @@ menu (this sets \"fixed=false\" on parameter \"length\").
stateSelect=StateSelect.always,
a(fixed=false),
s(fixed=true),
v(fixed=true, start=-0.4),
s_offset=-0.2) annotation (Placement(transformation(extent={{10,-80},{
30,-60}})));
v(fixed=true, start=-0.4)) annotation (Placement(transformation(extent={{10,-80},{30,-60}})));
Modelica.Mechanics.MultiBody.Parts.BodyCylinder b2(r={0,0.2,0}, diameter=
0.05) annotation (Placement(transformation(
origin={40,-30},
extent={{-10,-10},{10,10}},
rotation=90)));
Modelica.Mechanics.MultiBody.Parts.FixedTranslation b3(animation=false, r=
{1.2,0,0}) annotation (Placement(transformation(extent={{-30,-80},{-10,
-60}})));
{1.2,0,0}) annotation (Placement(transformation(extent={{-30,-80},{-10,-60}})));
Modelica.Mechanics.MultiBody.Visualizers.FixedFrame fixedFrame
annotation (Placement(transformation(
origin={30,30},
Expand Down Expand Up @@ -784,9 +775,7 @@ menu (this sets \"fixed=false\" on parameter \"length\").
stateSelect=StateSelect.always,
a(fixed=false),
s(fixed=true),
v(fixed=true, start=-0.2),
s_offset=-0.2) annotation (Placement(transformation(extent={{10,-80},{
30,-60}})));
v(fixed=true, start=-0.2)) annotation (Placement(transformation(extent={{10,-80},{30,-60}})));
Modelica.Mechanics.MultiBody.Parts.BodyCylinder b2(r={0,0.2,0}, diameter=
0.05) annotation (Placement(transformation(
origin={40,-30},
Expand Down Expand Up @@ -10706,9 +10695,7 @@ they were not deleted yet.")}));
stateSelect=StateSelect.always,
a(fixed=false, start=1),
s(fixed=true, start=1),
v(fixed=true, start=1),
s_offset=0.1) annotation (Placement(transformation(extent={{-50,20},{-30,
40}})));
v(fixed=true, start=1)) annotation (Placement(transformation(extent={{-50,20},{-30,40}})));
Modelica.Mechanics.MultiBody.Parts.BodyBox bodyBox2(r={1,0,0})
annotation (Placement(transformation(extent={{-20,20},{0,40}})));
Modelica.Mechanics.MultiBody.Joints.Prismatic actuatedPrismatic(
Expand Down

0 comments on commit cb18955

Please sign in to comment.