| 1 | model DoubleMassVecLen
|
|---|
| 2 | import Modelica.Math.Vectors;
|
|---|
| 3 |
|
|---|
| 4 | Real[3] x1(start = {0, 0, 0}, each fixed = true);
|
|---|
| 5 | Real[3] x2(start = {len, 0, 0}, fixed = {true, true, false});
|
|---|
| 6 | Real[3] v1(each start = 0, fixed = {true, true, true});
|
|---|
| 7 | Real[3] v2(each start = 0, fixed = {true, true, false});
|
|---|
| 8 | Real[3] fApplied1 = {0.0, 2.0, 0.0}, fApplied2 = {0.0, -2.0, 0.0};
|
|---|
| 9 | Real fInternal (start = 0, fixed = false);
|
|---|
| 10 | Real[3] fInternalVec;
|
|---|
| 11 | Real[3] x1x2Unit; // Unit vector from x1 to x2
|
|---|
| 12 | parameter Real m1 = 0.8, m2 = 1.2, len =2.5;
|
|---|
| 13 | Real lengthCheck;
|
|---|
| 14 | equation
|
|---|
| 15 | // Basic ODE
|
|---|
| 16 | der(x1) = v1;
|
|---|
| 17 | der(x2) = v2;
|
|---|
| 18 | der(v1) = (fApplied1 - fInternalVec) / m1;
|
|---|
| 19 | der(v2) = (fApplied2 + fInternalVec) / m2;
|
|---|
| 20 | fInternalVec = x1x2Unit * fInternal;
|
|---|
| 21 |
|
|---|
| 22 | // Computation of constraint information
|
|---|
| 23 | x1x2Unit = Vectors.normalize(x2 - x1); // Unit vector from x1 to x2
|
|---|
| 24 | Vectors.length(x1 - x2) = len;
|
|---|
| 25 | lengthCheck = Vectors.length(x1 - x2);
|
|---|
| 26 | annotation(experiment(StartTime = 0, StopTime = 5, Tolerance = 1e-06, Interval = 0.006));
|
|---|
| 27 | end DoubleMassVecLen;
|
|---|