Skip to content

Commit 8808322

Browse files
committed
Inherit from PartialConstraint
1 parent 92cc95b commit 8808322

4 files changed

Lines changed: 21 additions & 198 deletions

File tree

Modelica/Mechanics/MultiBody/Joints/Constraints/Prismatic.mo

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
11
within Modelica.Mechanics.MultiBody.Joints.Constraints;
22
model Prismatic
33
"Prismatic cut-joint and translational directions may be constrained or released"
4-
extends Modelica.Mechanics.MultiBody.Interfaces.PartialTwoFrames;
5-
6-
parameter Boolean x_locked=true
7-
"= true: constraint force in x-direction, resolved in frame_a"
8-
annotation (Dialog(group="Constraints"),choices(checkBox=true));
9-
parameter Boolean y_locked=true
10-
"= true: constraint force in y-direction, resolved in frame_a"
11-
annotation (Dialog(group="Constraints"),choices(checkBox=true));
12-
parameter Boolean z_locked=true
13-
"= true: constraint force in z-direction, resolved in frame_a"
14-
annotation (Dialog(group="Constraints"),choices(checkBox=true));
4+
extends Modelica.Mechanics.MultiBody.Interfaces.PartialConstraint;
155

166
parameter Boolean animation=true
177
"= true, if animation shall be enabled (show sphere)";
@@ -25,13 +15,6 @@ model Prismatic
2515
"Reflection of ambient light (= 0: light is completely absorbed)"
2616
annotation (Dialog(group="if animation = true", enable=animation));
2717

28-
protected
29-
Frames.Orientation R_rel
30-
"Dummy or relative orientation object from frame_a to frame_b";
31-
SI.Position r_rel_a[3]
32-
"Position vector from origin of frame_a to origin of frame_b, resolved in frame_a";
33-
SI.InstantaneousPower P;
34-
3518
public
3619
Visualizers.Advanced.Shape sphere(
3720
shapeType="sphere",
@@ -46,40 +29,10 @@ public
4629
r=frame_a.r_0,
4730
R=frame_a.R) if world.enableAnimation and animation;
4831
equation
49-
// Determine relative position vector resolved in frame_a
50-
R_rel = Frames.relativeRotation(frame_a.R, frame_b.R);
51-
r_rel_a = Frames.resolve2(frame_a.R, frame_b.r_0 - frame_a.r_0);
52-
5332
// Constraint equations concerning rotations
5433
// Same logic as for overdetermined connection graph loops to get good residuals.
5534
zeros(3)=Modelica.Mechanics.MultiBody.Frames.Orientation.equalityConstraint(frame_a.R, frame_b.R);
5635

57-
// Constraint equations concerning translations
58-
if x_locked then
59-
r_rel_a[1]=0;
60-
else
61-
frame_a.f[1]=0;
62-
end if;
63-
64-
if y_locked then
65-
r_rel_a[2]=0;
66-
else
67-
frame_a.f[2]=0;
68-
end if;
69-
70-
if z_locked then
71-
r_rel_a[3]=0;
72-
else
73-
frame_a.f[3]=0;
74-
end if;
75-
76-
zeros(3) = frame_a.t + Frames.resolve1(R_rel, frame_b.t) + cross(r_rel_a,
77-
Frames.resolve1(R_rel, frame_b.f));
78-
zeros(3) = Frames.resolve1(R_rel, frame_b.f) + frame_a.f;
79-
P = frame_a.t*Frames.angularVelocity2(frame_a.R) + frame_b.t*
80-
Frames.angularVelocity2(frame_b.R) + frame_b.f*Frames.resolve2(frame_b.R,
81-
der(frame_b.r_0)) + frame_a.f*Frames.resolve2(frame_a.R, der(frame_a.r_0));
82-
8336
annotation (
8437
defaultComponentName="constraint",
8538
Icon(coordinateSystem(

Modelica/Mechanics/MultiBody/Joints/Constraints/Revolute.mo

Lines changed: 9 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
11
within Modelica.Mechanics.MultiBody.Joints.Constraints;
22
model Revolute
33
"Revolute cut-joint and translational directions may be constrained or released"
4-
extends Modelica.Mechanics.MultiBody.Interfaces.PartialTwoFrames;
5-
6-
parameter Boolean x_locked=true
7-
"= true: constraint force in x-direction, resolved in frame_a"
8-
annotation (Dialog(group="Constraints in translational motion"),choices(checkBox=true));
9-
parameter Boolean y_locked=true
10-
"= true: constraint force in y-direction, resolved in frame_a"
11-
annotation (Dialog(group="Constraints in translational motion"),choices(checkBox=true));
12-
parameter Boolean z_locked=true
13-
"= true: constraint force in z-direction, resolved in frame_a"
14-
annotation (Dialog(group="Constraints in translational motion"),choices(checkBox=true));
4+
extends Modelica.Mechanics.MultiBody.Interfaces.PartialConstraint;
155

166
parameter Boolean animation=true
177
"= true, if animation shall be enabled (show sphere)";
@@ -30,21 +20,15 @@ model Revolute
3020
annotation (Dialog(group="if animation = true", enable=animation));
3121

3222
protected
33-
Frames.Orientation R_rel
34-
"Dummy or relative orientation object from frame_a to frame_b";
35-
SI.Position r_rel_a[3]
36-
"Position vector from origin of frame_a to origin of frame_b, resolved in frame_a";
37-
SI.InstantaneousPower P;
38-
parameter Real e[3](each final unit="1")=Modelica.Math.Vectors.normalizeWithAssert(
39-
n)
23+
parameter Real e[3](each final unit="1")=Modelica.Math.Vectors.normalizeWithAssert(n)
4024
"Unit vector in direction of rotation axis, resolved in frame_a (= same as in frame_b)";
4125

42-
parameter Real nnx_a[3](each final unit="1")=if abs(e[1]) > 0.1 then {0,1,0} else (if abs(e[2])
43-
> 0.1 then {0,0,1} else {1,0,0})
26+
parameter Real nnx_a[3](each final unit="1")=
27+
if abs(e[1]) > 0.1 then {0,1,0} else (if abs(e[2]) > 0.1 then {0,0,1} else {1,0,0})
4428
"Arbitrary vector that is not aligned with rotation axis n"
4529
annotation (Evaluate=true);
46-
parameter Real ey_a[3](each final unit="1")=Modelica.Math.Vectors.normalizeWithAssert(
47-
cross(e, nnx_a))
30+
parameter Real ey_a[3](each final unit="1")=
31+
Modelica.Math.Vectors.normalizeWithAssert(cross(e, nnx_a))
4832
"Unit vector orthogonal to axis n of revolute joint, resolved in frame_a"
4933
annotation (Evaluate=true);
5034
parameter Real ex_a[3](each final unit="1")=cross(ey_a, e)
@@ -65,43 +49,13 @@ public
6549
R=frame_a.R) if world.enableAnimation and animation;
6650

6751
equation
68-
// Determine relative position vector resolved in frame_a
69-
R_rel = Frames.relativeRotation(frame_a.R, frame_b.R);
70-
r_rel_a = Frames.resolve2(frame_a.R, frame_b.r_0 - frame_a.r_0);
71-
72-
// Constraint equations concerning translations
73-
if x_locked then
74-
r_rel_a[1]=0;
75-
else
76-
frame_a.f[1]=0;
77-
end if;
78-
79-
if y_locked then
80-
r_rel_a[2]=0;
81-
else
82-
frame_a.f[2]=0;
83-
end if;
84-
85-
if z_locked then
86-
r_rel_a[3]=0;
87-
else
88-
frame_a.f[3]=0;
89-
end if;
90-
9152
// Constraint equations concerning rotations
9253
0 = ex_a*R_rel.T*e;
9354
0 = ey_a*R_rel.T*e;
9455
frame_a.t*n=0;
9556

96-
zeros(3) = frame_a.f + Frames.resolve1(R_rel, frame_b.f);
97-
zeros(3) = frame_a.t + Frames.resolve1(R_rel, frame_b.t) - cross(r_rel_a,
98-
frame_a.f);
99-
P = frame_a.t*Frames.angularVelocity2(frame_a.R) + frame_b.t*
100-
Frames.angularVelocity2(frame_b.R) + Frames.resolve1(frame_b.R, frame_b.f)
101-
*der(frame_b.r_0) + Frames.resolve1(frame_a.R, frame_a.f)*der(frame_a.r_0);
102-
103-
annotation ( defaultComponentName="constraint",
104-
Icon(coordinateSystem(
57+
annotation ( defaultComponentName="constraint",
58+
Icon(coordinateSystem(
10559
preserveAspectRatio=true,
10660
extent={{-100,-100},{100,100}}), graphics={
10761
Text(
@@ -137,7 +91,7 @@ equation
13791
extent={{-150,110},{150,70}},
13892
textColor={0,0,255},
13993
textString="%name")}),
140-
Documentation(info="<html>
94+
Documentation(info="<html>
14195
<p>This model does not use explicit variables e.g. state variables in order to describe the relative motion of frame_b with respect to frame_a, but defines kinematic constraints between the frame_a and frame_b. The forces and torques at both frames are then evaluated in such a way that the constraints are satisfied. Sometimes this type of formulation is also called an implicit joint in literature.</p>
14296
<p>As a consequence of the formulation the relative kinematics between frame_a and frame_b cannot be initialized.</p>
14397
<p>In particular in complex multibody systems with closed loops this may help to simplify the system of non-linear equations. Please compare the translation log using the classical joint formulation and the alternative formulation used here in order to check whether this fact applies to the particular system under consideration.</p>

Modelica/Mechanics/MultiBody/Joints/Constraints/Spherical.mo

Lines changed: 5 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,18 @@
11
within Modelica.Mechanics.MultiBody.Joints.Constraints;
22
model Spherical
33
"Spherical cut joint and translational directions may be constrained or released"
4-
extends Modelica.Mechanics.MultiBody.Interfaces.PartialTwoFrames;
5-
import MBS = Modelica.Mechanics.MultiBody;
6-
7-
parameter Boolean x_locked=true
8-
"= true: constraint force in x-direction, resolved in frame_a"
9-
annotation (Dialog(group="Constraints"), choices(checkBox=true));
10-
parameter Boolean y_locked=true
11-
"= true: constraint force in y-direction, resolved in frame_a"
12-
annotation (Dialog(group="Constraints"), choices(checkBox=true));
13-
parameter Boolean z_locked=true
14-
"= true: constraint force in z-direction, resolved in frame_a"
15-
annotation (Dialog(group="Constraints"), choices(checkBox=true));
4+
extends Modelica.Mechanics.MultiBody.Interfaces.PartialConstraint;
165

176
parameter Boolean animation=true
187
"= true, if animation shall be enabled (show sphere)"
198
annotation (Dialog(group="Animation"));
209
parameter SI.Distance sphereDiameter=world.defaultJointLength /3
2110
"Diameter of sphere representing the spherical joint"
2211
annotation (Dialog(group="Animation", enable=animation));
23-
input MBS.Types.Color sphereColor=MBS.Types.Defaults.JointColor
12+
input Types.Color sphereColor=Types.Defaults.JointColor
2413
"Color of sphere representing the spherical joint"
2514
annotation (Dialog(colorSelector=true, group="Animation", enable=animation));
26-
input MBS.Types.SpecularCoefficient specularCoefficient = world.defaultSpecularCoefficient
15+
input Types.SpecularCoefficient specularCoefficient = world.defaultSpecularCoefficient
2716
"Reflection of ambient light (= 0: light is completely absorbed)"
2817
annotation (Dialog(group="Animation", enable=animation));
2918

@@ -39,42 +28,11 @@ model Spherical
3928
r_shape={-0.5,0,0}*sphereDiameter,
4029
r=frame_a.r_0,
4130
R=frame_a.R) if world.enableAnimation and animation;
42-
protected
43-
MBS.Frames.Orientation R_rel
44-
"Dummy or relative orientation object from frame_a to frame_b";
45-
SI.Position r_rel_a[3]
46-
"Position vector from origin of frame_a to origin of frame_b, resolved in frame_a";
47-
SI.InstantaneousPower P;
4831

4932
equation
50-
// Determine relative position vector resolved in frame_a
51-
R_rel = MBS.Frames.relativeRotation(frame_a.R, frame_b.R);
52-
r_rel_a = MBS.Frames.resolve2(frame_a.R, frame_b.r_0 - frame_a.r_0);
53-
54-
// Constraint equations concerning translation
55-
if x_locked then
56-
r_rel_a[1]=0;
57-
else
58-
frame_a.f[1]=0;
59-
end if;
60-
61-
if y_locked then
62-
r_rel_a[2]=0;
63-
else
64-
frame_a.f[2]=0;
65-
end if;
66-
67-
if z_locked then
68-
r_rel_a[3]=0;
69-
else
70-
frame_a.f[3]=0;
71-
end if;
72-
7333
//frame_a.t = zeros(3);
7434
frame_b.t = zeros(3);
75-
frame_b.f = -MBS.Frames.resolve2(R_rel, frame_a.f);
76-
zeros(3) = frame_a.t + MBS.Frames.resolve1(R_rel, frame_b.t) - cross(r_rel_a, frame_a.f);
77-
P= frame_a.t*MBS.Frames.angularVelocity2(frame_a.R)+frame_b.t*MBS.Frames.angularVelocity2(frame_b.R) + MBS.Frames.resolve1(frame_b.R,frame_b.f)*der(frame_b.r_0)+MBS.Frames.resolve1(frame_a.R,frame_a.f)*der(frame_a.r_0);
35+
7836
annotation (
7937
defaultComponentName="constraint",
8038
Icon(coordinateSystem(
@@ -155,7 +113,7 @@ equation
155113
textColor={0,0,255},
156114
textString="%name")}),
157115
Documentation(info="<html>
158-
<p>This model does not use explicit variables e.g. state variables in order to describe the relative motion of frame_b with to respect to frame_a, but defines kinematic constraints between the frame_a and frame_b. The forces and torques at both frames are then evaluated in such a way that the constraints are satisfied. Sometimes this type of formulation is also called an implicit joint in literature.</p>
116+
<p>This model does not use explicit variables e.g. state variables in order to describe the relative motion of frame_b with respect to frame_a, but defines kinematic constraints between the frame_a and frame_b. The forces and torques at both frames are then evaluated in such a way that the constraints are satisfied. Sometimes this type of formulation is also called an implicit joint in literature.</p>
159117
<p>As a consequence of the formulation the relative kinematics between frame_a and frame_b cannot be initialized.</p>
160118
<p>In particular in complex multibody systems with closed loops this may help to simplify the system of non-linear equations. Please compare the translation log using the classical joint formulation and the alternative formulation used here in order to check whether this fact applies to the particular system under consideration.</p>
161119
<p>In systems without closed loops the use of this implicit joint does not make sense or may even be disadvantageous.</p>

Modelica/Mechanics/MultiBody/Joints/Constraints/Universal.mo

Lines changed: 6 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,37 @@
11
within Modelica.Mechanics.MultiBody.Joints.Constraints;
22
model Universal
33
"Universal cut-joint and translational directions may be constrained or released"
4-
extends Modelica.Mechanics.MultiBody.Interfaces.PartialTwoFrames;
5-
import MBS = Modelica.Mechanics.MultiBody;
4+
extends Modelica.Mechanics.MultiBody.Interfaces.PartialConstraint;
65

7-
parameter MBS.Types.Axis n_a={1,0,0}
6+
parameter Types.Axis n_a={1,0,0}
87
"Axis of revolute joint 1 resolved in frame_a" annotation (Evaluate=true);
9-
parameter MBS.Types.Axis n_b={0,1,0}
8+
parameter Types.Axis n_b={0,1,0}
109
"Axis of revolute joint 2 resolved in frame_b" annotation (Evaluate=true);
1110

12-
parameter Boolean x_locked=true
13-
"= true: constraint force in x-direction, resolved in frame_a"
14-
annotation (Dialog(group="Constraints in translational motion"), choices(checkBox=true));
15-
parameter Boolean y_locked=true
16-
"= true: constraint force in y-direction, resolved in frame_a"
17-
annotation (Dialog(group="Constraints in translational motion"), choices(checkBox=true));
18-
parameter Boolean z_locked=true
19-
"= true: constraint force in z-direction, resolved in frame_a"
20-
annotation (Dialog(group="Constraints in translational motion"), choices(checkBox=true));
21-
2211
parameter Boolean animation=true
2312
"= true, if animation shall be enabled (show sphere)"
2413
annotation (Dialog(group="Animation"));
2514
parameter SI.Distance sphereDiameter=world.defaultJointLength /3
2615
"Diameter of sphere representing the spherical joint"
2716
annotation (Dialog(group="Animation", enable=animation));
28-
input MBS.Types.Color sphereColor=MBS.Types.Defaults.JointColor
17+
input Types.Color sphereColor=Types.Defaults.JointColor
2918
"Color of sphere representing the spherical joint"
3019
annotation (Dialog(colorSelector=true, group="Animation", enable=animation));
31-
input MBS.Types.SpecularCoefficient specularCoefficient = world.defaultSpecularCoefficient
20+
input Types.SpecularCoefficient specularCoefficient = world.defaultSpecularCoefficient
3221
"Reflection of ambient light (= 0: light is completely absorbed)"
3322
annotation (Dialog(group="Animation", enable=animation));
3423
protected
35-
MBS.Frames.Orientation R_rel
36-
"Dummy or relative orientation object from frame_a to frame_b";
3724
Real w_rel[3];
38-
SI.Position r_rel_a[3]
39-
"Position vector from origin of frame_a to origin of frame_b, resolved in frame_a";
4025

41-
SI.InstantaneousPower P;
4226
equation
43-
// Determine relative position vector resolved in frame_a
44-
R_rel = MBS.Frames.relativeRotation(frame_a.R, frame_b.R);
45-
w_rel = MBS.Frames.angularVelocity1(R_rel);
46-
r_rel_a = MBS.Frames.resolve2(frame_a.R, frame_b.r_0 - frame_a.r_0);
47-
48-
// Constraint equations concerning translations
49-
if x_locked then
50-
r_rel_a[1]=0;
51-
else
52-
frame_a.f[1]=0;
53-
end if;
54-
55-
if y_locked then
56-
r_rel_a[2]=0;
57-
else
58-
frame_a.f[2]=0;
59-
end if;
60-
61-
if z_locked then
62-
r_rel_a[3]=0;
63-
else
64-
frame_a.f[3]=0;
65-
end if;
27+
w_rel = Frames.angularVelocity1(R_rel);
6628

6729
// Constraint equations concerning rotations
6830
frame_a.t*n_a=0;
6931
frame_b.t*n_b=0;
7032
n_b*R_rel.T*n_a=0;
7133
assert(abs(n_a*n_b) < Modelica.Constants.eps, "The two axes that constitute the Constraints.Universal joint must be different");
7234

73-
zeros(3)=frame_a.f + MBS.Frames.resolve1(R_rel, frame_b.f);
74-
zeros(3) = frame_a.t+MBS.Frames.resolve1(R_rel, frame_b.t)- cross(r_rel_a, frame_a.f);
75-
P = frame_a.t*MBS.Frames.angularVelocity2(frame_a.R)+frame_b.t*MBS.Frames.angularVelocity2(frame_b.R) + MBS.Frames.resolve1(frame_b.R,frame_b.f)*der(frame_b.r_0)+MBS.Frames.resolve1(frame_a.R,frame_a.f)*der(frame_a.r_0);
76-
7735
annotation (
7836
defaultComponentName="constraint",
7937
Icon(coordinateSystem(

0 commit comments

Comments
 (0)