Opened 6 years ago
Closed 6 years ago
#5056 closed defect (fixed)
Issue with MultiBody models in the NF due to missing evaluation during flattening
Reported by: | Francesco Casella | Owned by: | Per Östlund |
---|---|---|---|
Priority: | high | Milestone: | 2.0.0 |
Component: | New Instantiation | Version: | |
Keywords: | Cc: |
Description (last modified by )
After @adrpo's commits for overconstrained connectors, the MultiBody examples all flatten and produce a balanced system of equations. Howevver, there are still problems that prevents them to run.
Please check Modelica.Mechanics.MultiBody.Examples.Constraints.UniversalConstraint. The following error is reported:
[/var/lib/hudson/slave/workspace/OpenModelica_TEST_LIBS/OpenModelica/OMCompiler/Compiler/BackEnd/Differentiate.mo:402:3-402:155:writable] Error: Derivative of expression "joint.revolute_b.R_rel.T[1,2] = (matrix({1.0, 0.0, 0.0}) * transpose(matrix({1.0, 0.0, 0.0})))[1, 2] - (matrix({1.0, 0.0, 0.0}) * transpose(matrix({1.0, 0.0, 0.0})))[1, 2] * cos(joint.phi_b)" w.r.t. "time" is non-existent. [/var/lib/hudson/slave/workspace/OpenModelica_TEST_LIBS/OpenModelica/OMCompiler/build/lib/omlibrary/Modelica trunk/Mechanics/MultiBody/Joints.mo:306:7-306:60:writable] Error: Internal error Differentiate.differentiateEquationTime failed for joint.revolute_b.R_rel.T[1,2] = (matrix({1.0, 0.0, 0.0}) * transpose(matrix({1.0, 0.0, 0.0})))[1, 2] - (matrix({1.0, 0.0, 0.0}) * transpose(matrix({1.0, 0.0, 0.0})))[1, 2] * cos(joint.phi_b) Error: Internal error - IndexReduction.pantelidesIndexReduction1 failed! Use -d=bltdump to get more information.
For some reason, the expression
(matrix({1.0, 0.0, 0.0}) * transpose(matrix({1.0, 0.0, 0.0})))[1, 2] - (matrix({1.0, 0.0, 0.0}) * transpose(matrix({1.0, 0.0, 0.0})))[1, 2] * cos(joint.phi_b)
is not evaluated appropriately during flattening, causing a failure of Pantelides's algoritm later on.
Change History (5)
comment:1 by , 6 years ago
Component: | *unknown* → New Instantiation |
---|---|
Description: | modified (diff) |
Owner: | changed from | to
Status: | new → assigned |
Summary: | Issue with MultiBody models in the NF → Issue with MultiBody models in the NF due to missing evaluation during flattening |
comment:2 by , 6 years ago
follow-up: 4 comment:3 by , 6 years ago
I think the Backend don't know e.g. skew
, because the OF evaluate skew
.
model test function foo input Real[3] e; output Real[:, :] y = skew(e); end foo; Real [:,:] y = foo({1,1,1}); equation end test;
where Instantiation return
function test.foo input Real[3] e; output Real[3, 3] y = {{0.0, -e[3], e[2]}, {e[3], 0.0, -e[1]}, {-e[2], e[1], 0.0}}; end test.foo; class test Real y[1,1]; Real y[1,2]; Real y[1,3]; Real y[2,1]; Real y[2,2]; Real y[2,3]; Real y[3,1]; Real y[3,2]; Real y[3,3]; equation y = {{0.0, -1.0, 1.0}, {1.0, 0.0, -1.0}, {-1.0, 1.0, 0.0}}; end test;
So, I would rule out the error in inline module.
In case e[:]
I get a crash in the runtime for OF.
comment:4 by , 6 years ago
Replying to vitalij:
So, I would rule out the error in inline module.
The inline module does what it's supposed to do in this case, but the inlined expression can't be handled by e.g. the differentiation even though it's a perfectly valid expression. So maybe some simplification needs to be applied after the inlining.
However, I now realised that skew
does in fact always take a vector of three elements and returns a 3x3 matrix, so that's something the NF could handle by just adding the appropriate definition of skew
to ModelicaBuiltin.
comment:5 by , 6 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
I'm not sure why a different error is reported in the error log compared to the one in this ticket, but the actual error is currently:
The issue seems to be in the
Modelica.Mechanics.MultiBody.Frames.TransformationMatrices.planarRotation
function, which is defined as:The NF doesn't mess around much with algorithms, and flattens it as:
The OF on the other hand produces:
The issue occurs when the function is inlined by the backend, which produces expressions that it can't handle for some reason. "Simplifying" algorithms like the OF does is a slippery slope, and not always possible anyway (what if
e[3]
instead wase[:]
for example?). So this seems like something that would be best handled by the backend, either by simplifying the inlined expressions or fixing the Differentiate module so it can handle this.