1 | // name: ModelicaTest
|
---|
2 | // keywords: simulation MSL Examples
|
---|
3 | // status: correct
|
---|
4 | //
|
---|
5 | // Simulation Results
|
---|
6 | // Modelica Standard Library
|
---|
7 | //
|
---|
8 |
|
---|
9 | loadModel(Modelica,{"3.2.1"});
|
---|
10 | getErrorString();
|
---|
11 |
|
---|
12 | loadString("
|
---|
13 | model RevolutePlanarLoopConstraintA
|
---|
14 | extends Modelica.Icons.Example;
|
---|
15 | parameter Real tor=1000;
|
---|
16 | Real k;
|
---|
17 |
|
---|
18 | inner Modelica.Mechanics.MultiBody.World world(animateWorld=false,
|
---|
19 | animateGravity=false) annotation (Placement(transformation(extent={{-160,
|
---|
20 | 40},{-140,60}}, rotation=0)));
|
---|
21 | Modelica.Mechanics.Rotational.Sources.Torque torque
|
---|
22 | annotation (Placement(transformation(extent={{-14,74},{6,94}})));
|
---|
23 | Modelica.Blocks.Sources.RealExpression realExpression(y=k)
|
---|
24 | annotation (Placement(transformation(extent={{-46,74},{-26,94}})));
|
---|
25 | Modelica.Mechanics.MultiBody.Parts.BodyCylinder bodyCylinder1(r={1,0,0},
|
---|
26 | diameter=0.2) annotation (Placement(transformation(
|
---|
27 | extent={{-10,-10},{10,10}},
|
---|
28 | rotation=270,
|
---|
29 | origin={106,20})));
|
---|
30 | Modelica.Mechanics.MultiBody.Parts.BodyCylinder bodyCylinder2(r={1,0,0},
|
---|
31 | diameter=0.2) annotation (Placement(transformation(
|
---|
32 | extent={{-10,-10},{10,10}},
|
---|
33 | rotation=180,
|
---|
34 | origin={42,-6})));
|
---|
35 | Modelica.Mechanics.MultiBody.Parts.BodyCylinder bodyCylinder3(r={1,0,0},
|
---|
36 | diameter=0.2) annotation (Placement(transformation(
|
---|
37 | extent={{-10,-10},{10,10}},
|
---|
38 | rotation=90,
|
---|
39 | origin={-20,22})));
|
---|
40 | Modelica.Mechanics.MultiBody.Joints.Revolute revolute2(
|
---|
41 | n={1,0,0},
|
---|
42 | phi(fixed=true, start=0),
|
---|
43 | w(fixed=true, start=2*Modelica.Constants.pi))
|
---|
44 | annotation (Placement(transformation(extent={{-122,40},{-102,60}})));
|
---|
45 | Modelica.Mechanics.MultiBody.Parts.FixedRotation fixedRotation(n={0,1,0},
|
---|
46 | angle=90)
|
---|
47 | annotation (Placement(transformation(extent={{-86,40},{-66,60}})));
|
---|
48 | Modelica.Mechanics.MultiBody.Parts.FixedRotation fixedRotation1(angle=45,
|
---|
49 | n={0,0,1})
|
---|
50 | annotation (Placement(transformation(extent={{-52,40},{-32,60}})));
|
---|
51 |
|
---|
52 | Modelica.Mechanics.MultiBody.Joints.RevolutePlanarLoopConstraint revolute(
|
---|
53 | n={0,1,0}) annotation (Placement(transformation(
|
---|
54 | extent={{-10,-10},{10,10}},
|
---|
55 | rotation=180,
|
---|
56 | origin={6,-6})));
|
---|
57 | Modelica.Mechanics.MultiBody.Joints.Revolute revolute1(n={0,1,0},
|
---|
58 | useAxisFlange=true) annotation (Placement(transformation(
|
---|
59 | extent={{-10,-10},{10,10}},
|
---|
60 | rotation=0,
|
---|
61 | origin={8,52})));
|
---|
62 | Modelica.Mechanics.MultiBody.Joints.Revolute revolute3(
|
---|
63 | n={0,1,0},
|
---|
64 | phi(fixed=true, start=1.5707963267949),
|
---|
65 | w(fixed=true)) annotation (Placement(transformation(
|
---|
66 | extent={{-10,-10},{10,10}},
|
---|
67 | rotation=0,
|
---|
68 | origin={82,52})));
|
---|
69 | Modelica.Mechanics.MultiBody.Joints.Revolute revolute4(n={0,1,0}, phi(
|
---|
70 | start=1.5707963267949)) annotation (Placement(transformation(
|
---|
71 | extent={{-10,-10},{10,10}},
|
---|
72 | rotation=180,
|
---|
73 | origin={76,-6})));
|
---|
74 | Modelica.Mechanics.MultiBody.Parts.BodyCylinder bodyCylinder(r={1,0,0},
|
---|
75 | diameter=0.2)
|
---|
76 | annotation (Placement(transformation(extent={{36,42},{56,62}})));
|
---|
77 | equation
|
---|
78 | if (time < 1) then
|
---|
79 | k = tor;
|
---|
80 | else
|
---|
81 | k = 0;
|
---|
82 | end if;
|
---|
83 | connect(revolute1.frame_b, bodyCylinder.frame_a) annotation (Line(
|
---|
84 | points={{18,52},{36,52}},
|
---|
85 | color={95,95,95},
|
---|
86 | thickness=0.5,
|
---|
87 | smooth=Smooth.None));
|
---|
88 | connect(bodyCylinder.frame_b, revolute3.frame_a) annotation (Line(
|
---|
89 | points={{56,52},{72,52}},
|
---|
90 | color={95,95,95},
|
---|
91 | thickness=0.5,
|
---|
92 | smooth=Smooth.None));
|
---|
93 | connect(torque.flange, revolute1.axis) annotation (Line(
|
---|
94 | points={{6,84},{6,62},{8,62}},
|
---|
95 | color={0,0,0},
|
---|
96 | smooth=Smooth.None));
|
---|
97 | connect(realExpression.y, torque.tau) annotation (Line(
|
---|
98 | points={{-25,84},{-16,84}},
|
---|
99 | color={0,0,127},
|
---|
100 | smooth=Smooth.None));
|
---|
101 | connect(revolute3.frame_b, bodyCylinder1.frame_a) annotation (Line(
|
---|
102 | points={{92,52},{102,52},{102,30},{106,30}},
|
---|
103 | color={95,95,95},
|
---|
104 | thickness=0.5,
|
---|
105 | smooth=Smooth.None));
|
---|
106 | connect(bodyCylinder1.frame_b, revolute4.frame_a) annotation (Line(
|
---|
107 | points={{106,10},{98,10},{98,-6},{86,-6}},
|
---|
108 | color={95,95,95},
|
---|
109 | thickness=0.5,
|
---|
110 | smooth=Smooth.None));
|
---|
111 | connect(revolute4.frame_b, bodyCylinder2.frame_a) annotation (Line(
|
---|
112 | points={{66,-6},{62.5,-6},{62.5,-6},{59,-6},{59,-6},{52,-6}},
|
---|
113 | color={95,95,95},
|
---|
114 | thickness=0.5,
|
---|
115 | smooth=Smooth.None));
|
---|
116 | connect(bodyCylinder2.frame_b, revolute.frame_a) annotation (Line(
|
---|
117 | points={{32,-6},{28,-6},{28,-6},{24,-6},{24,-6},{16,-6}},
|
---|
118 | color={95,95,95},
|
---|
119 | thickness=0.5,
|
---|
120 | smooth=Smooth.None));
|
---|
121 | connect(revolute.frame_b, bodyCylinder3.frame_a) annotation (Line(
|
---|
122 | points={{-4,-6},{-12,-6},{-12,12},{-20,12}},
|
---|
123 | color={95,95,95},
|
---|
124 | thickness=0.5,
|
---|
125 | smooth=Smooth.None));
|
---|
126 | connect(bodyCylinder3.frame_b, revolute1.frame_a) annotation (Line(
|
---|
127 | points={{-20,32},{-12,32},{-12,52},{-2,52}},
|
---|
128 | color={95,95,95},
|
---|
129 | thickness=0.5,
|
---|
130 | smooth=Smooth.None));
|
---|
131 | connect(world.frame_b, revolute2.frame_a) annotation (Line(
|
---|
132 | points={{-140,50},{-122,50}},
|
---|
133 | color={95,95,95},
|
---|
134 | thickness=0.5,
|
---|
135 | smooth=Smooth.None));
|
---|
136 | connect(fixedRotation.frame_b, fixedRotation1.frame_a) annotation (Line(
|
---|
137 | points={{-66,50},{-52,50}},
|
---|
138 | color={95,95,95},
|
---|
139 | thickness=0.5,
|
---|
140 | smooth=Smooth.None));
|
---|
141 | connect(revolute2.frame_b, fixedRotation.frame_a) annotation (Line(
|
---|
142 | points={{-102,50},{-86,50}},
|
---|
143 | color={95,95,95},
|
---|
144 | thickness=0.5,
|
---|
145 | smooth=Smooth.None));
|
---|
146 | connect(fixedRotation1.frame_b, revolute1.frame_a) annotation (Line(
|
---|
147 | points={{-32,50},{-18,50},{-18,52},{-2,52}},
|
---|
148 | color={95,95,95},
|
---|
149 | thickness=0.5,
|
---|
150 | smooth=Smooth.None));
|
---|
151 | annotation (experiment(StopTime=5), Diagram(coordinateSystem(extent={{-160,
|
---|
152 | -40},{120,100}}, preserveAspectRatio=true)));
|
---|
153 | end RevolutePlanarLoopConstraintA;
|
---|
154 |
|
---|
155 | model RevolutePlanarLoopConstraintB
|
---|
156 | extends Modelica.Icons.Example;
|
---|
157 | parameter Real tor=1000;
|
---|
158 | Real k;
|
---|
159 |
|
---|
160 | inner Modelica.Mechanics.MultiBody.World world(animateWorld=false,
|
---|
161 | animateGravity=false) annotation (Placement(transformation(extent={{-160,
|
---|
162 | 40},{-140,60}}, rotation=0)));
|
---|
163 |
|
---|
164 | Modelica.Mechanics.MultiBody.Joints.RevolutePlanarLoopConstraint revolute(
|
---|
165 | n={0,1,0}) annotation (Placement(transformation(
|
---|
166 | extent={{-10,-10},{10,10}},
|
---|
167 | rotation=180,
|
---|
168 | origin={6,-6})));
|
---|
169 | Modelica.Mechanics.MultiBody.Joints.Revolute revolute1(n={0,1,0},
|
---|
170 | useAxisFlange=true) annotation (Placement(transformation(
|
---|
171 | extent={{-10,-10},{10,10}},
|
---|
172 | rotation=0,
|
---|
173 | origin={8,52})));
|
---|
174 | Modelica.Mechanics.MultiBody.Joints.Revolute revolute3(
|
---|
175 | n={0,1,0},
|
---|
176 | phi(fixed=true, start=1.5707963267949),
|
---|
177 | w(fixed=true)) annotation (Placement(transformation(
|
---|
178 | extent={{-10,-10},{10,10}},
|
---|
179 | rotation=0,
|
---|
180 | origin={82,52})));
|
---|
181 | Modelica.Mechanics.MultiBody.Joints.Revolute revolute4(n={0,1,0}, phi(
|
---|
182 | start=1.5707963267949)) annotation (Placement(transformation(
|
---|
183 | extent={{-10,-10},{10,10}},
|
---|
184 | rotation=180,
|
---|
185 | origin={76,-6})));
|
---|
186 | Modelica.Mechanics.MultiBody.Parts.BodyCylinder bodyCylinder(r={1,0,0},
|
---|
187 | diameter=0.2)
|
---|
188 | annotation (Placement(transformation(extent={{36,42},{56,62}})));
|
---|
189 |
|
---|
190 | Modelica.Mechanics.Rotational.Sources.Torque torque
|
---|
191 | annotation (Placement(transformation(extent={{-14,74},{6,94}})));
|
---|
192 | Modelica.Blocks.Sources.RealExpression realExpression(y=k)
|
---|
193 | annotation (Placement(transformation(extent={{-46,74},{-26,94}})));
|
---|
194 | Modelica.Mechanics.MultiBody.Parts.BodyCylinder bodyCylinder1(r={1,0,0},
|
---|
195 | diameter=0.2) annotation (Placement(transformation(
|
---|
196 | extent={{-10,-10},{10,10}},
|
---|
197 | rotation=270,
|
---|
198 | origin={106,20})));
|
---|
199 | Modelica.Mechanics.MultiBody.Parts.BodyCylinder bodyCylinder2(r={1,0,0},
|
---|
200 | diameter=0.2) annotation (Placement(transformation(
|
---|
201 | extent={{-10,-10},{10,10}},
|
---|
202 | rotation=180,
|
---|
203 | origin={42,-6})));
|
---|
204 | Modelica.Mechanics.MultiBody.Parts.BodyCylinder bodyCylinder3(r={1,0,0},
|
---|
205 | diameter=0.2) annotation (Placement(transformation(
|
---|
206 | extent={{-10,-10},{10,10}},
|
---|
207 | rotation=90,
|
---|
208 | origin={-20,22})));
|
---|
209 | Modelica.Mechanics.MultiBody.Joints.Revolute revolute2(
|
---|
210 | n={1,0,0},
|
---|
211 | phi(fixed=true, start=0),
|
---|
212 | w(fixed=true, start=2*Modelica.Constants.pi))
|
---|
213 | annotation (Placement(transformation(extent={{-122,40},{-102,60}})));
|
---|
214 | Modelica.Mechanics.MultiBody.Parts.FixedRotation fixedRotation(n={0,1,0},
|
---|
215 | angle=90)
|
---|
216 | annotation (Placement(transformation(extent={{-86,40},{-66,60}})));
|
---|
217 | Modelica.Mechanics.MultiBody.Parts.FixedRotation fixedRotation1(angle=45,
|
---|
218 | n={0,0,1})
|
---|
219 | annotation (Placement(transformation(extent={{-52,40},{-32,60}})));
|
---|
220 |
|
---|
221 | equation
|
---|
222 | if (time < 1) then
|
---|
223 | k = tor;
|
---|
224 | else
|
---|
225 | k = 0;
|
---|
226 | end if;
|
---|
227 | connect(revolute1.frame_b, bodyCylinder.frame_a) annotation (Line(
|
---|
228 | points={{18,52},{36,52}},
|
---|
229 | color={95,95,95},
|
---|
230 | thickness=0.5,
|
---|
231 | smooth=Smooth.None));
|
---|
232 | connect(bodyCylinder.frame_b, revolute3.frame_a) annotation (Line(
|
---|
233 | points={{56,52},{72,52}},
|
---|
234 | color={95,95,95},
|
---|
235 | thickness=0.5,
|
---|
236 | smooth=Smooth.None));
|
---|
237 | connect(torque.flange, revolute1.axis) annotation (Line(
|
---|
238 | points={{6,84},{6,62},{8,62}},
|
---|
239 | color={0,0,0},
|
---|
240 | smooth=Smooth.None));
|
---|
241 | connect(realExpression.y, torque.tau) annotation (Line(
|
---|
242 | points={{-25,84},{-16,84}},
|
---|
243 | color={0,0,127},
|
---|
244 | smooth=Smooth.None));
|
---|
245 | connect(revolute3.frame_b, bodyCylinder1.frame_a) annotation (Line(
|
---|
246 | points={{92,52},{102,52},{102,30},{106,30}},
|
---|
247 | color={95,95,95},
|
---|
248 | thickness=0.5,
|
---|
249 | smooth=Smooth.None));
|
---|
250 | connect(bodyCylinder1.frame_b, revolute4.frame_a) annotation (Line(
|
---|
251 | points={{106,10},{98,10},{98,-6},{86,-6}},
|
---|
252 | color={95,95,95},
|
---|
253 | thickness=0.5,
|
---|
254 | smooth=Smooth.None));
|
---|
255 | connect(revolute4.frame_b, bodyCylinder2.frame_a) annotation (Line(
|
---|
256 | points={{66,-6},{62.5,-6},{62.5,-6},{59,-6},{59,-6},{52,-6}},
|
---|
257 | color={95,95,95},
|
---|
258 | thickness=0.5,
|
---|
259 | smooth=Smooth.None));
|
---|
260 | connect(bodyCylinder2.frame_b, revolute.frame_a) annotation (Line(
|
---|
261 | points={{32,-6},{28,-6},{28,-6},{24,-6},{24,-6},{16,-6}},
|
---|
262 | color={95,95,95},
|
---|
263 | thickness=0.5,
|
---|
264 | smooth=Smooth.None));
|
---|
265 | connect(revolute.frame_b, bodyCylinder3.frame_a) annotation (Line(
|
---|
266 | points={{-4,-6},{-12,-6},{-12,12},{-20,12}},
|
---|
267 | color={95,95,95},
|
---|
268 | thickness=0.5,
|
---|
269 | smooth=Smooth.None));
|
---|
270 | connect(bodyCylinder3.frame_b, revolute1.frame_a) annotation (Line(
|
---|
271 | points={{-20,32},{-12,32},{-12,52},{-2,52}},
|
---|
272 | color={95,95,95},
|
---|
273 | thickness=0.5,
|
---|
274 | smooth=Smooth.None));
|
---|
275 | connect(world.frame_b, revolute2.frame_a) annotation (Line(
|
---|
276 | points={{-140,50},{-122,50}},
|
---|
277 | color={95,95,95},
|
---|
278 | thickness=0.5,
|
---|
279 | smooth=Smooth.None));
|
---|
280 | connect(fixedRotation.frame_b, fixedRotation1.frame_a) annotation (Line(
|
---|
281 | points={{-66,50},{-52,50}},
|
---|
282 | color={95,95,95},
|
---|
283 | thickness=0.5,
|
---|
284 | smooth=Smooth.None));
|
---|
285 | connect(revolute2.frame_b, fixedRotation.frame_a) annotation (Line(
|
---|
286 | points={{-102,50},{-86,50}},
|
---|
287 | color={95,95,95},
|
---|
288 | thickness=0.5,
|
---|
289 | smooth=Smooth.None));
|
---|
290 | connect(fixedRotation1.frame_b, revolute1.frame_a) annotation (Line(
|
---|
291 | points={{-32,50},{-18,50},{-18,52},{-2,52}},
|
---|
292 | color={95,95,95},
|
---|
293 | thickness=0.5,
|
---|
294 | smooth=Smooth.None));
|
---|
295 | annotation (experiment(StopTime=5), Diagram(coordinateSystem(extent={{-160,
|
---|
296 | -40},{120,100}}, preserveAspectRatio=true)));
|
---|
297 | end RevolutePlanarLoopConstraintB;
|
---|
298 | ");
|
---|
299 |
|
---|
300 |
|
---|
301 | simulate(RevolutePlanarLoopConstraintA);
|
---|
302 | getErrorString();
|
---|
303 |
|
---|
304 | simulate(RevolutePlanarLoopConstraintB);
|
---|
305 | getErrorString();
|
---|
306 |
|
---|