Saarland University
Lehrstuhl für Automatisierungstechnik

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> [OpenModelica] Mismatch: Equations/Variables
daniel@ka
post Feb 23 2009, 07:47 PM
Post #1


Member
**

Group: Members
Posts: 23
Joined: 3-June 08
Member No.: 11,399



Thank you!
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
adrpo
post Feb 23 2009, 03:01 AM
Post #2


Member
**

Group: Members
Posts: 11
Joined: 17-December 07
From: Linköping, Sweden
Member No.: 4,942




Hi,

This was an error which is now fixed.

Please take the nightly build from here:
http://www.ida.liu.se/~pelab/modelica/Open...02_23-03_51.msi

This nightly-build fixes the errror.

Cheers,
Adrian Pop/
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
daniel@ka
post Feb 22 2009, 08:05 PM
Post #3


Member
**

Group: Members
Posts: 23
Joined: 3-June 08
Member No.: 11,399



Hello forum,

I wrote quite a big piece of modelica code, which should be fully determined as I think.
Since it's big, I don't expect you to check what may be wrong.
It consits of 44 variables (I counted them multiple times) and 44 equations.
When I do ..

checkModel(MassAttractionAndCollision)

I get ..

"Check of MassAttractionAndCollision successful. Model MassAttractionAndCollision
has 44 equation(s) and 46 variable(s)."

getErrorString() => ""

I don't understand where the additional 2 variables come from!
Eval version of Dymola says ...

Check of MassAttractionAndCollision:
DAE having 44 scalar unknowns and 44 scalar equations.
Check of MassAttractionAndCollision successful.

Here I have copy&pasted version of flattened modelica code to see what variables are inside:

>> instantiateModel(MassAttractionAndCollision)
"fclass MassAttractionAndCollision
parameter Real gamma(unit = "N*m^2/kg^2") = 100;
parameter Real p.m(unit = "kg") = 1;
parameter Real p.r(unit = "m") = 1;
Real p.x[1](start = 0.0) "position";
Real p.x[2](start = 0.0) "position";
Real p.x[3](start = 0.0) "position";
Real p.v[1](start = 0.0) "velocity";
Real p.v[2](start = 0.0) "velocity";
Real p.v[3](start = 0.0) "velocity";
parameter Real q.m(unit = "kg") = 1;
parameter Real q.r(unit = "m") = 1;
Real q.x[1](start = 1.0) "position";
Real q.x[2](start = 1.0) "position";
Real q.x[3](start = 1.0) "position";
Real q.v[1](start = 0.0) "velocity";
Real q.v[2](start = 0.0) "velocity";
Real q.v[3](start = 0.0) "velocity";
Real dx;
Real dy;
Real dz;
Real dxy;
Real d "distance(p,q)";
Real force;
Real phi;
Real theta;
Real p2q[1] "unity vector pointing from p to q";
Real p2q[2] "unity vector pointing from p to q";
Real p2q[3] "unity vector pointing from p to q";
Real q2p[1] "unity vector pointing from q to p";
Real q2p[2] "unity vector pointing from q to p";
Real q2p[3] "unity vector pointing from q to p";
Real vp_c[1] "collision component of p.v into direction of p2q";
Real vp_c[2] "collision component of p.v into direction of p2q";
Real vp_c[3] "collision component of p.v into direction of p2q";
Real vp_t[1] "normal component of p.v related to direction of p2q";
Real vp_t[2] "normal component of p.v related to direction of p2q";
Real vp_t[3] "normal component of p.v related to direction of p2q";
Real vq_t[1] "collision component of q.v into direction of q2p";
Real vq_t[2] "collision component of q.v into direction of q2p";
Real vq_t[3] "collision component of q.v into direction of q2p";
Real vq_c[1] "normal component of q.v related to direction of q2p";
Real vq_c[2] "normal component of q.v related to direction of q2p";
Real vq_c[3] "normal component of q.v related to direction of q2p";
Real vp_cc[1] "after collision component";
Real vp_cc[2] "after collision component";
Real vp_cc[3] "after collision component";
Real vq_cc[1] "after collision component";
Real vq_cc[2] "after collision component";
Real vq_cc[3] "after collision component";
equation
der(p.x[1]) = p.v[1];
der(p.x[2]) = p.v[2];
der(p.x[3]) = p.v[3];
der(q.x[1]) = q.v[1];
der(q.x[2]) = q.v[2];
der(q.x[3]) = q.v[3];
dx = p.x[1] - q.x[1];
dy = p.x[2] - q.x[2];
dz = p.x[3] - q.x[3];
dxy = sqrt(dx ^ 2.0 + dy ^ 2.0);
d = sqrt(dx ^ 2.0 + dy ^ 2.0 + dz ^ 2.0);
force = (gamma * p.m * q.m) / d ^ 2.0;
theta = Modelica.Math.atan2(dz,dxy);
phi = Modelica.Math.atan2(dy,dx);
(-p.m) * der(p.v[1]) + Modelica.Math.cos(theta) * Modelica.Math.cos(phi) * force = 0.0;
(-p.m) * der(p.v[2]) + Modelica.Math.cos(theta) * Modelica.Math.sin(phi) * force = 0.0;
(-p.m) * der(p.v[3]) + Modelica.Math.sin(theta) * force = 0.0;
(-q.m) * der(q.v[1]) - Modelica.Math.cos(theta) * Modelica.Math.cos(phi) * force = 0.0;
(-q.m) * der(q.v[2]) - Modelica.Math.cos(theta) * Modelica.Math.sin(phi) * force = 0.0;
(-q.m) * der(q.v[3]) - Modelica.Math.sin(theta) * force = 0.0;
p2q[1] = (q.x[1] - p.x[1]) / d;
p2q[2] = (q.x[2] - p.x[2]) / d;
p2q[3] = (q.x[3] - p.x[3]) / d;
q2p[1] = (p.x[1] - q.x[1]) / d;
q2p[2] = (p.x[2] - q.x[2]) / d;
q2p[3] = (p.x[3] - q.x[3]) / d;
vp_c[1] = (p2q[1] * p.v[1] + p2q[2] * p.v[2] + p2q[3] * p.v[3]) * p2q[1];
vp_c[2] = (p2q[1] * p.v[1] + p2q[2] * p.v[2] + p2q[3] * p.v[3]) * p2q[2];
vp_c[3] = (p2q[1] * p.v[1] + p2q[2] * p.v[2] + p2q[3] * p.v[3]) * p2q[3];
vp_t[1] = p.v[1] - vp_c[1];
vp_t[2] = p.v[2] - vp_c[2];
vp_t[3] = p.v[3] - vp_c[3];
vq_c[1] = (q2p[1] * q.v[1] + q2p[2] * q.v[2] + q2p[3] * q.v[3]) * q2p[1];
vq_c[2] = (q2p[1] * q.v[1] + q2p[2] * q.v[2] + q2p[3] * q.v[3]) * q2p[2];
vq_c[3] = (q2p[1] * q.v[1] + q2p[2] * q.v[2] + q2p[3] * q.v[3]) * q2p[3];
vq_t[1] = q.v[1] - vq_c[1];
vq_t[2] = q.v[2] - vq_c[2];
vq_t[3] = q.v[3] - vq_c[3];
p.m * vp_c[1] + q.m * vq_c[1] = p.m * vp_cc[1] + q.m * vq_cc[1];
p.m * vp_c[2] + q.m * vq_c[2] = p.m * vp_cc[2] + q.m * vq_cc[2];
p.m * vp_c[3] + q.m * vq_c[3] = p.m * vp_cc[3] + q.m * vq_cc[3];
p.m * vp_c[1] ^ 2.0 + q.m * vq_c[1] ^ 2.0 = p.m * vp_cc[1] ^ 2.0 + q.m * vq_cc[1] ^ 2.0;
p.m * vp_c[2] ^ 2.0 + q.m * vq_c[2] ^ 2.0 = p.m * vp_cc[2] ^ 2.0 + q.m * vq_cc[2] ^ 2.0;
p.m * vp_c[3] ^ 2.0 + q.m * vq_c[3] ^ 2.0 = p.m * vp_cc[3] ^ 2.0 + q.m * vq_cc[3] ^ 2.0;
when d < p.r + q.r then
reinit(p.v,{vp_t[1] + vp_cc[1],vp_t[2] + vp_cc[2],vp_t[3] + vp_cc[3]});
reinit(q.v,{vq_t[1] + vq_cc[1],vq_t[2] + vq_cc[2],vq_t[3] + vq_cc[3]});
end when;
end MassAttractionAndCollision;


I would be happy if somebody could point me to the source of the 2 additional variables
or would just try to simulate the model. Can the flattened version be simulated with Dymola?
Anyway I attached the code.

Regards, Daniel


Attached File(s)
Attached File  MassAttractionAndCollision.mo ( 2.82k ) Number of downloads: 574
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



Lo-Fi Version Time is now: 22nd May 2019 - 09:05 AM