Opened 4 years ago

Last modified 3 years ago

#6285 reopened defect

Minimal tearing failing for example from MSL

Reported by: Andreas Heuermann Owned by: Andreas Heuermann
Priority: critical Milestone:
Component: Backend Version: v1.17.0-dev
Keywords: tearing, minimalTearing, linear system Cc: Karim Adbdelhak

Description

When disabling linear tearing for PR https://github.com/OpenModelica/OpenModelica/pull/6969 (related ticket #6196) we have some examples from the testsuite that are failing to simulate.

They are working with normal tearing and without tearing, but not with minimal tearing.

For example for Modelica.Electrical.Machines.Examples.AsynchronousInductionMachines.AIMC_Transformer we can run:

cd("temp");
loadModel(Modelica,{"3.2.3"}); getErrorString();
setCommandLineOptions("-d=newInst --tearingMethod=minimalTearing"); getErrorString();
simulate(Modelica.Electrical.Machines.Examples.AsynchronousInductionMachines.AIMC_Transformer); getErrorString();

and see that the linear solver will fail to solve linear system 536 in every time step:

LOG_LS            | info    | Start solving Linear System 536 (size 28) at time 0.002621 with Lapack Solver
LOG_LS            | warning | Failed to solve linear system of equations (no. 536) at time 0.002621. Residual norm is 104868561.449326.
LOG_LS            | warning | The default linear solver fails, the fallback solver with total pivoting is started at time 0.002621. That might raise performance issues, for more information use -lv LOG_LS.
LOG_LS            | info    | Start solving Linear System 536 (size 28) at time 0.002621 with Total Pivot Solver

The relevant loop should be

################################################################################
 dumpLoops: SORTED COMPONENT 
################################################################################

torn linear Equationsystem:

internal vars (0)

residual vars (28)
1: transformer.l2sigma.v[2]:VARIABLE(unit = "V" )  "Voltage drops of the two polyphase plugs" type: Real [3]
2: $DER.transformer.l2sigma.inductor[2].i:DUMMY_DER(fixed = false )  "Current flowing from pin p to pin n" type: Real [3]
3: transformer.l1sigma.inductor[2].i:STATE(1)(start = 0.0 unit = "A" )  "Current flowing from pin p to pin n" type: Real [3]
4: transformer.l1sigma.v[2]:VARIABLE(unit = "V" )  "Voltage drops of the two polyphase plugs" type: Real [3]
5: transformer.l1sigma.plug_n.pin[2].v:VARIABLE(flow=false unit = "V" )  "Potential at the pin" type: Real [3]
6: transformer.core.v1[2]:VARIABLE(unit = "V" )  type: Real [3]
7: transformer.core.v3[2]:VARIABLE(unit = "V" )  type: Real [3]
8: transformer.core.plug_p2.pin[2].v:VARIABLE(flow=false unit = "V" )  "Potential at the pin" type: Real [3]
9: transformer.core.v2[2]:VARIABLE(unit = "V" )  type: Real [3]
10: transformer.l1sigma.inductor[3].i:STATE(1)(start = 0.0 unit = "A" )  "Current flowing from pin p to pin n" type: Real [3]
11: $DER.transformer.l2sigma.inductor[3].i:DUMMY_DER(fixed = false )  "Current flowing from pin p to pin n" type: Real [3]
12: transformer.l2sigma.v[3]:VARIABLE(unit = "V" )  "Voltage drops of the two polyphase plugs" type: Real [3]
13: transformer.core.plug_p2.pin[3].v:VARIABLE(flow=false unit = "V" )  "Potential at the pin" type: Real [3]
14: transformer.core.v3[3]:VARIABLE(unit = "V" )  type: Real [3]
15: transformer.core.v1[3]:VARIABLE(unit = "V" )  type: Real [3]
16: transformer.core.v2[3]:VARIABLE(unit = "V" )  type: Real [3]
17: transformer.starpoint1.v:VARIABLE(flow=false unit = "V" )  "Potential at the pin" type: Real
18: transformer.l1sigma.plug_n.pin[1].v:VARIABLE(flow=false unit = "V" )  "Potential at the pin" type: Real [3]
19: transformer.l1sigma.v[1]:VARIABLE(unit = "V" )  "Voltage drops of the two polyphase plugs" type: Real [3]
20: $DER.transformer.l1sigma.inductor[1].i:DUMMY_DER(fixed = false )  "Current flowing from pin p to pin n" type: Real [3]
21: $DER.transformer.l2sigma.inductor[1].i:DUMMY_DER(fixed = false )  "Current flowing from pin p to pin n" type: Real [3]
22: transformer.l2sigma.v[1]:VARIABLE(unit = "V" )  "Voltage drops of the two polyphase plugs" type: Real [3]
23: transformer.core.plug_p2.pin[1].v:VARIABLE(flow=false unit = "V" )  "Potential at the pin" type: Real [3]
24: transformer.core.v3[1]:VARIABLE(unit = "V" )  type: Real [3]
25: transformer.core.v1[1]:VARIABLE(unit = "V" )  type: Real [3]
26: transformer.core.v2[1]:VARIABLE(unit = "V" )  type: Real [3]
27: transformer.l1sigma.v[3]:VARIABLE(unit = "V" )  "Voltage drops of the two polyphase plugs" type: Real [3]
28: transformer.l1sigma.plug_n.pin[3].v:VARIABLE(flow=false unit = "V" )  "Potential at the pin" type: Real [3]

internal equations (0)

residual equations (28)
1/1 (1): transformer.l1sigma.v[3] = transformer.r1.plug_n.pin[3].v - transformer.l1sigma.plug_n.pin[3].v   [dynamic |0|0|0|0|]
2/2 (1): transformer.l1sigma.inductor[3].L * der(transformer.l1sigma.inductor[3].i) = transformer.l1sigma.v[3]   [dynamic |0|0|0|0|]
3/3 (1): transformer.core.v1[1] = transformer.core.n12 * transformer.core.v2[1]   [dynamic |0|0|0|0|]
4/4 (1): transformer.core.v1[1] = transformer.core.n13 * transformer.core.v3[1]   [dynamic |0|0|0|0|]
5/5 (1): transformer.core.v2[1] = transformer.core.plug_p2.pin[1].v - transformer.core.v3[1]   [dynamic |0|0|0|0|]
6/6 (1): transformer.l2sigma.v[1] = transformer.l2sigma.plug_p.pin[1].v - transformer.core.plug_p2.pin[1].v   [dynamic |0|0|0|0|]
7/7 (1): transformer.l2sigma.inductor[1].L * $DER.transformer.l2sigma.inductor[1].i = transformer.l2sigma.v[1]   [dynamic |0|0|0|0|]
8/8 (1): 0.0 = $DER.transformer.l1sigma.inductor[1].i + $DER.transformer.l2sigma.inductor[1].i / transformer.core.n12 + $DER.transformer.l2sigma.inductor[1].i / transformer.core.n13   [dynamic |0|0|0|0|]
9/9 (1): transformer.l1sigma.inductor[1].L * $DER.transformer.l1sigma.inductor[1].i = transformer.l1sigma.v[1]   [dynamic |0|0|0|0|]
10/10 (1): transformer.l1sigma.v[1] = transformer.r1.plug_n.pin[1].v - transformer.l1sigma.plug_n.pin[1].v   [dynamic |0|0|0|0|]
11/11 (1): transformer.core.v1[1] = transformer.l1sigma.plug_n.pin[1].v - transformer.starpoint1.v   [dynamic |0|0|0|0|]
12/12 (1): transformer.core.v1[3] = transformer.l1sigma.plug_n.pin[3].v - transformer.starpoint1.v   [dynamic |0|0|0|0|]
13/13 (1): transformer.core.v1[3] = transformer.core.n12 * transformer.core.v2[3]   [dynamic |0|0|0|0|]
14/14 (1): transformer.core.v1[3] = transformer.core.n13 * transformer.core.v3[3]   [dynamic |0|0|0|0|]
15/15 (1): transformer.core.v2[3] = transformer.core.plug_p2.pin[3].v - transformer.core.v3[3]   [dynamic |0|0|0|0|]
16/16 (1): transformer.l2sigma.v[3] = transformer.l2sigma.plug_p.pin[3].v - transformer.core.plug_p2.pin[3].v   [dynamic |0|0|0|0|]
17/17 (1): transformer.l2sigma.inductor[3].L * $DER.transformer.l2sigma.inductor[3].i = transformer.l2sigma.v[3]   [dynamic |0|0|0|0|]
18/18 (1): 0.0 = der(transformer.l1sigma.inductor[3].i) + $DER.transformer.l2sigma.inductor[3].i / transformer.core.n12 + $DER.transformer.l2sigma.inductor[3].i / transformer.core.n13   [dynamic |0|0|0|0|]
19/19 (1): $DER.transformer.l1sigma.inductor[1].i + der(transformer.l1sigma.inductor[2].i) + der(transformer.l1sigma.inductor[3].i) = 0.0   [dynamic |0|0|0|0|]
20/20 (1): transformer.core.v1[2] = transformer.core.n12 * transformer.core.v2[2]   [dynamic |0|0|0|0|]
21/21 (1): transformer.core.v2[2] = transformer.core.plug_p2.pin[2].v - transformer.core.v3[2]   [dynamic |0|0|0|0|]
22/22 (1): transformer.core.v1[2] = transformer.core.n13 * transformer.core.v3[2]   [dynamic |0|0|0|0|]
23/23 (1): transformer.core.v1[2] = transformer.l1sigma.plug_n.pin[2].v - transformer.starpoint1.v   [dynamic |0|0|0|0|]
24/24 (1): transformer.l1sigma.v[2] = transformer.r1.plug_n.pin[2].v - transformer.l1sigma.plug_n.pin[2].v   [dynamic |0|0|0|0|]
25/25 (1): transformer.l1sigma.inductor[2].L * der(transformer.l1sigma.inductor[2].i) = transformer.l1sigma.v[2]   [dynamic |0|0|0|0|]
26/26 (1): 0.0 = der(transformer.l1sigma.inductor[2].i) + $DER.transformer.l2sigma.inductor[2].i / transformer.core.n12 + $DER.transformer.l2sigma.inductor[2].i / transformer.core.n13   [dynamic |0|0|0|0|]
27/27 (1): transformer.l2sigma.inductor[2].L * $DER.transformer.l2sigma.inductor[2].i = transformer.l2sigma.v[2]   [dynamic |0|0|0|0|]
28/28 (1): transformer.l2sigma.v[2] = transformer.l2sigma.plug_p.pin[2].v - transformer.core.plug_p2.pin[2].v   [dynamic |0|0|0|0|]

With tearing enabled this loop will look like

################################################################################
 dumpLoops: SORTED COMPONENT 
################################################################################

torn linear Equationsystem:

internal vars (25)
1: $DER.transformer.l2sigma.inductor[2].i:DUMMY_DER(fixed = false )  "Current flowing from pin p to pin n" type: Real [3]
2: transformer.l2sigma.v[2]:VARIABLE(unit = "V" )  "Voltage drops of the two polyphase plugs" type: Real [3]
3: transformer.l1sigma.v[2]:VARIABLE(unit = "V" )  "Voltage drops of the two polyphase plugs" type: Real [3]
4: transformer.core.plug_p2.pin[2].v:VARIABLE(flow=false unit = "V" )  "Potential at the pin" type: Real [3]
5: transformer.l1sigma.plug_n.pin[2].v:VARIABLE(flow=false unit = "V" )  "Potential at the pin" type: Real [3]
6: transformer.core.v3[2]:VARIABLE(unit = "V" )  type: Real [3]
7: transformer.core.v2[2]:VARIABLE(unit = "V" )  type: Real [3]
8: transformer.starpoint1.v:VARIABLE(flow=false unit = "V" )  "Potential at the pin" type: Real
9: $DER.transformer.l2sigma.inductor[3].i:DUMMY_DER(fixed = false )  "Current flowing from pin p to pin n" type: Real [3]
10: transformer.l2sigma.v[3]:VARIABLE(unit = "V" )  "Voltage drops of the two polyphase plugs" type: Real [3]
11: transformer.l1sigma.v[3]:VARIABLE(unit = "V" )  "Voltage drops of the two polyphase plugs" type: Real [3]
12: $DER.transformer.l1sigma.inductor[1].i:DUMMY_DER(fixed = false )  "Current flowing from pin p to pin n" type: Real [3]
13: $DER.transformer.l2sigma.inductor[1].i:DUMMY_DER(fixed = false )  "Current flowing from pin p to pin n" type: Real [3]
14: transformer.l1sigma.v[1]:VARIABLE(unit = "V" )  "Voltage drops of the two polyphase plugs" type: Real [3]
15: transformer.l2sigma.v[1]:VARIABLE(unit = "V" )  "Voltage drops of the two polyphase plugs" type: Real [3]
16: transformer.core.plug_p2.pin[3].v:VARIABLE(flow=false unit = "V" )  "Potential at the pin" type: Real [3]
17: transformer.l1sigma.plug_n.pin[1].v:VARIABLE(flow=false unit = "V" )  "Potential at the pin" type: Real [3]
18: transformer.core.v1[1]:VARIABLE(unit = "V" )  type: Real [3]
19: transformer.core.v3[1]:VARIABLE(unit = "V" )  type: Real [3]
20: transformer.core.v2[1]:VARIABLE(unit = "V" )  type: Real [3]
21: transformer.core.plug_p2.pin[1].v:VARIABLE(flow=false unit = "V" )  "Potential at the pin" type: Real [3]
22: transformer.l1sigma.plug_n.pin[3].v:VARIABLE(flow=false unit = "V" )  "Potential at the pin" type: Real [3]
23: transformer.core.v1[3]:VARIABLE(unit = "V" )  type: Real [3]
24: transformer.core.v3[3]:VARIABLE(unit = "V" )  type: Real [3]
25: transformer.core.v2[3]:VARIABLE(unit = "V" )  type: Real [3]

residual vars (3)
1: transformer.l1sigma.inductor[3].i:STATE(1)(start = 0.0 unit = "A" )  "Current flowing from pin p to pin n" type: Real [3]
2: transformer.core.v1[2]:VARIABLE(unit = "V" )  type: Real [3]
3: transformer.l1sigma.inductor[2].i:STATE(1)(start = 0.0 unit = "A" )  "Current flowing from pin p to pin n" type: Real [3]

internal equations (25)
1/1 (1): 0.0 = der(transformer.l1sigma.inductor[2].i) + $DER.transformer.l2sigma.inductor[2].i / transformer.core.n12 + $DER.transformer.l2sigma.inductor[2].i / transformer.core.n13   [dynamic |0|0|0|0|]
2/2 (1): transformer.l2sigma.inductor[2].L * $DER.transformer.l2sigma.inductor[2].i = transformer.l2sigma.v[2]   [dynamic |0|0|0|0|]
3/3 (1): transformer.l1sigma.inductor[2].L * der(transformer.l1sigma.inductor[2].i) = transformer.l1sigma.v[2]   [dynamic |0|0|0|0|]
4/4 (1): transformer.l2sigma.v[2] = transformer.l2sigma.plug_p.pin[2].v - transformer.core.plug_p2.pin[2].v   [dynamic |0|0|0|0|]
5/5 (1): transformer.l1sigma.v[2] = transformer.r1.plug_n.pin[2].v - transformer.l1sigma.plug_n.pin[2].v   [dynamic |0|0|0|0|]
6/6 (1): transformer.core.v1[2] = transformer.core.n13 * transformer.core.v3[2]   [dynamic |0|0|0|0|]
7/7 (1): transformer.core.v1[2] = transformer.core.n12 * transformer.core.v2[2]   [dynamic |0|0|0|0|]
8/8 (1): transformer.core.v1[2] = transformer.l1sigma.plug_n.pin[2].v - transformer.starpoint1.v   [dynamic |0|0|0|0|]
9/9 (1): 0.0 = der(transformer.l1sigma.inductor[3].i) + $DER.transformer.l2sigma.inductor[3].i / transformer.core.n12 + $DER.transformer.l2sigma.inductor[3].i / transformer.core.n13   [dynamic |0|0|0|0|]
10/10 (1): transformer.l2sigma.inductor[3].L * $DER.transformer.l2sigma.inductor[3].i = transformer.l2sigma.v[3]   [dynamic |0|0|0|0|]
11/11 (1): transformer.l1sigma.inductor[3].L * der(transformer.l1sigma.inductor[3].i) = transformer.l1sigma.v[3]   [dynamic |0|0|0|0|]
12/12 (1): $DER.transformer.l1sigma.inductor[1].i + der(transformer.l1sigma.inductor[2].i) + der(transformer.l1sigma.inductor[3].i) = 0.0   [dynamic |0|0|0|0|]
13/13 (1): 0.0 = $DER.transformer.l1sigma.inductor[1].i + $DER.transformer.l2sigma.inductor[1].i / transformer.core.n12 + $DER.transformer.l2sigma.inductor[1].i / transformer.core.n13   [dynamic |0|0|0|0|]
14/14 (1): transformer.l1sigma.inductor[1].L * $DER.transformer.l1sigma.inductor[1].i = transformer.l1sigma.v[1]   [dynamic |0|0|0|0|]
15/15 (1): transformer.l2sigma.inductor[1].L * $DER.transformer.l2sigma.inductor[1].i = transformer.l2sigma.v[1]   [dynamic |0|0|0|0|]
16/16 (1): transformer.l2sigma.v[3] = transformer.l2sigma.plug_p.pin[3].v - transformer.core.plug_p2.pin[3].v   [dynamic |0|0|0|0|]
17/17 (1): transformer.l1sigma.v[1] = transformer.r1.plug_n.pin[1].v - transformer.l1sigma.plug_n.pin[1].v   [dynamic |0|0|0|0|]
18/18 (1): transformer.core.v1[1] = transformer.l1sigma.plug_n.pin[1].v - transformer.starpoint1.v   [dynamic |0|0|0|0|]
19/19 (1): transformer.core.v1[1] = transformer.core.n13 * transformer.core.v3[1]   [dynamic |0|0|0|0|]
20/20 (1): transformer.core.v1[1] = transformer.core.n12 * transformer.core.v2[1]   [dynamic |0|0|0|0|]
21/21 (1): transformer.core.v2[1] = transformer.core.plug_p2.pin[1].v - transformer.core.v3[1]   [dynamic |0|0|0|0|]
22/22 (1): transformer.l1sigma.v[3] = transformer.r1.plug_n.pin[3].v - transformer.l1sigma.plug_n.pin[3].v   [dynamic |0|0|0|0|]
23/23 (1): transformer.core.v1[3] = transformer.l1sigma.plug_n.pin[3].v - transformer.starpoint1.v   [dynamic |0|0|0|0|]
24/24 (1): transformer.core.v1[3] = transformer.core.n13 * transformer.core.v3[3]   [dynamic |0|0|0|0|]
25/25 (1): transformer.core.v1[3] = transformer.core.n12 * transformer.core.v2[3]   [dynamic |0|0|0|0|]

residual equations (3)
1/1 (1): transformer.l2sigma.v[1] = transformer.l2sigma.plug_p.pin[1].v - transformer.core.plug_p2.pin[1].v   [dynamic |0|0|0|0|]
2/2 (1): transformer.core.v2[3] = transformer.core.plug_p2.pin[3].v - transformer.core.v3[3]   [dynamic |0|0|0|0|]
3/3 (1): transformer.core.v2[2] = transformer.core.plug_p2.pin[2].v - transformer.core.v3[2]   [dynamic |0|0|0|0|]

Change History (12)

comment:1 by Andreas Heuermann, 4 years ago

Other examples that failing in the same way:

  • Modelica.Electrical.Machines.Examples.Transformers.AIMC_Transformer
  • Modelica.Mechanics.MultiBody.Examples.Constraints.RevoluteConstraint
  • Modelica.Mechanics.MultiBody.Examples.Constraints.UniversalConstraint

While looking at these examples I noticed that for Modelica.Mechanics.MultiBody.Examples.Constraints.UniversalConstraint
we have a loop with size 4 but dumLoops doesn't report a loop with that size.

void residualFunc3507(void** dataIn, const double* xloc, double* res, const int* iflag)
{
  TRACE_PUSH
  DATA *data = (DATA*) ((void**)dataIn[0]);
  threadData_t *threadData = (threadData_t*) ((void**)dataIn[1]);
  const int equationIndexes[2] = {1,3507};
  ANALYTIC_JACOBIAN* parentJacobian = data->simulationInfo->linearSystemData[9].parDynamicData[omc_get_thread_num()].parentJacobian;
  ANALYTIC_JACOBIAN* jacobian = NULL;
  parentJacobian->tmpVars[7] /* der(fixedTranslationOfConstraint.frame_b.R.T.$pDERStateSetJac16.dummyVarStateSetJac16[1,1]) JACOBIAN_DIFF_VAR */ = xloc[0];
  parentJacobian->tmpVars[2] /* der(fixedTranslationOfConstraint.frame_b.R.T.$pDERStateSetJac16.dummyVarStateSetJac16[1,2]) JACOBIAN_DIFF_VAR */ = xloc[1];
  parentJacobian->tmpVars[0] /* der(freeMotionScalarInit.initAngle.R_rel.T.$pDERStateSetJac16.dummyVarStateSetJac16[1,1]) JACOBIAN_DIFF_VAR */ = xloc[2];
  parentJacobian->tmpVars[1] /* der(fixedTranslationOfConstraint.frame_b.R.T.$pDERStateSetJac16.dummyVarStateSetJac16[1,3]) JACOBIAN_DIFF_VAR */ = xloc[3];
  res[0] = (0.5648625214636235) * (parentJacobian->tmpVars[6] /* der(freeMotionScalarInit.initAngle.R_rel.T.$pDERStateSetJac16.dummyVarStateSetJac16[1,3]) JACOBIAN_DIFF_VAR */) + (0.8130157214783864) * (parentJacobian->tmpVars[3] /* der(freeMotionScalarInit.initAngle.R_rel.T.$pDERStateSetJac16.dummyVarStateSetJac16[1,2]) JACOBIAN_DIFF_VAR */) + (-0.1411940808771254) * (parentJacobian->tmpVars[0] /* der(freeMotionScalarInit.initAngle.R_rel.T.$pDERStateSetJac16.dummyVarStateSetJac16[1,1]) JACOBIAN_DIFF_VAR */) - parentJacobian->tmpVars[1] /* der(fixedTranslationOfConstraint.frame_b.R.T.$pDERStateSetJac16.dummyVarStateSetJac16[1,3]) JACOBIAN_DIFF_VAR */;

  res[1] = (-0.09960050292505122) * (parentJacobian->tmpVars[6] /* der(freeMotionScalarInit.initAngle.R_rel.T.$pDERStateSetJac16.dummyVarStateSetJac16[1,3]) JACOBIAN_DIFF_VAR */) + (0.2370288965055821) * (parentJacobian->tmpVars[3] /* der(freeMotionScalarInit.initAngle.R_rel.T.$pDERStateSetJac16.dummyVarStateSetJac16[1,2]) JACOBIAN_DIFF_VAR */) + (0.9663834860128886) * (parentJacobian->tmpVars[0] /* der(freeMotionScalarInit.initAngle.R_rel.T.$pDERStateSetJac16.dummyVarStateSetJac16[1,1]) JACOBIAN_DIFF_VAR */) - parentJacobian->tmpVars[2] /* der(fixedTranslationOfConstraint.frame_b.R.T.$pDERStateSetJac16.dummyVarStateSetJac16[1,2]) JACOBIAN_DIFF_VAR */;

  res[2] = (0.5648625214636235) * (parentJacobian->tmpVars[1] /* der(fixedTranslationOfConstraint.frame_b.R.T.$pDERStateSetJac16.dummyVarStateSetJac16[1,3]) JACOBIAN_DIFF_VAR */) + (-0.09960050292505122) * (parentJacobian->tmpVars[2] /* der(fixedTranslationOfConstraint.frame_b.R.T.$pDERStateSetJac16.dummyVarStateSetJac16[1,2]) JACOBIAN_DIFF_VAR */) + (0.8191520442889918) * (parentJacobian->tmpVars[7] /* der(fixedTranslationOfConstraint.frame_b.R.T.$pDERStateSetJac16.dummyVarStateSetJac16[1,1]) JACOBIAN_DIFF_VAR */);

  res[3] = (0.8191520442889918) * (parentJacobian->tmpVars[6] /* der(freeMotionScalarInit.initAngle.R_rel.T.$pDERStateSetJac16.dummyVarStateSetJac16[1,3]) JACOBIAN_DIFF_VAR */) + (-0.5318108111446446) * (parentJacobian->tmpVars[3] /* der(freeMotionScalarInit.initAngle.R_rel.T.$pDERStateSetJac16.dummyVarStateSetJac16[1,2]) JACOBIAN_DIFF_VAR */) + (0.2148655148851041) * (parentJacobian->tmpVars[0] /* der(freeMotionScalarInit.initAngle.R_rel.T.$pDERStateSetJac16.dummyVarStateSetJac16[1,1]) JACOBIAN_DIFF_VAR */) - parentJacobian->tmpVars[7] /* der(fixedTranslationOfConstraint.frame_b.R.T.$pDERStateSetJac16.dummyVarStateSetJac16[1,1]) JACOBIAN_DIFF_VAR */;
  TRACE_POP
}

Also the C code itself looks wrong. We have parentJacobian->tmpVars[7], parentJacobian->tmpVars[2], parentJacobian->tmpVars[0] and parentJacobian->tmpVars[1]. But we using all tempVars from 0 to 7. So I guess the loop should have size 8.

This loop involves arrays, so my highly professional guess is that we suck at counting array variables.

I'll try to come up with a minimal working example, since this example is still to big to debug and I'm not 100% sure what the solution should look like.

comment:2 by Andreas Heuermann, 4 years ago

Minimal examples are hard...

But for now I'm working with

loadModel(Modelica,{"3.2.3"}); getErrorString();
setCommandLineOptions("-d=newInst,dumpLoops --tearingMethod=minimalTearing --maxSizeLinearTearing=200"); getErrorString();
setCommandLineOptions("-d=tearingdump,tearingdumpV --noTearingForComponent=1,2,3,4,5,6,7,8,9,10,12,13,14,15"); getErrorString();

cd("temp-UniversalConstraint");
buildModel(Modelica.Mechanics.MultiBody.Examples.Constraints.UniversalConstraint); getErrorString();
system("./Modelica.Mechanics.MultiBody.Examples.Constraints.UniversalConstraint -lv=LOG_STATS");

I disabled tearing for all but component 11.

So the only torn system remaining must be the culprit:

################################################################################
 dumpLoops: SORTED COMPONENT 
################################################################################

torn linear Equationsystem:

internal vars (0)

residual vars (11)
1: $DER.freeMotionScalarInit.initAngle.R_rel.T[1,1]:DUMMY_DER(fixed = false )  "Transformation matrix from world frame to local frame" type: Real [3,3]
2: $DER.fixedTranslationOfConstraint.frame_b.R.T[1,3]:DUMMY_DER(flow=false fixed = false )  "Transformation matrix from world frame to local frame" type: Real [3,3]
3: $DER.fixedTranslationOfConstraint.frame_b.R.T[1,2]:DUMMY_DER(flow=false fixed = false )  "Transformation matrix from world frame to local frame" type: Real [3,3]
4: $DER.freeMotionScalarInit.initAngle.R_rel.T[1,2]:DUMMY_DER(fixed = false )  "Transformation matrix from world frame to local frame" type: Real [3,3]
5: freeMotionScalarInit.angle_d_3:DUMMY_STATE(flow=false start = 0.0 unit = "rad/s" fixed = true stateSelect=StateSelect.never )  "= der(angle_3)" type: Real
6: freeMotionScalarInit.angle_d_1:DUMMY_STATE(flow=false start = 0.0 unit = "rad/s" fixed = true stateSelect=StateSelect.never )  "= der(angle_1)" type: Real
7: bodyOfConstraint.body.w_a[3]:DUMMY_STATE(start = 0.8191520442889911 * bodyOfConstraint.body.w_0_start[1] + (-0.09960050292504974) * bodyOfConstraint.body.w_0_start[2] + 0.5648625214636248 * bodyOfConstraint.body.w_0_start[3] unit = "rad/s" fixed = false stateSelect=StateSelect.avoid )  "Absolute angular velocity of frame_a resolved in frame_a" type: Real [3]
8: freeMotionScalarInit.angle_d_2:DUMMY_STATE(flow=false start = 0.0 unit = "rad/s" stateSelect=StateSelect.never )  "= der(angle_2)" type: Real
9: $DER.freeMotionScalarInit.initAngle.R_rel.T[3,1]:DUMMY_DER(fixed = false )  "Transformation matrix from world frame to local frame" type: Real [3,3]
10: $DER.freeMotionScalarInit.initAngle.R_rel.T[1,3]:DUMMY_DER(fixed = false )  "Transformation matrix from world frame to local frame" type: Real [3,3]
11: $DER.fixedTranslationOfConstraint.frame_b.R.T[1,1]:DUMMY_DER(flow=false fixed = false )  "Transformation matrix from world frame to local frame" type: Real [3,3]

internal equations (0)

residual equations (11)
1/1 (1): $DER.fixedTranslationOfConstraint.frame_b.R.T[1,1] = 0.2148655148851041 * $DER.freeMotionScalarInit.initAngle.R_rel.T[1,1] + (-0.5318108111446446) * $DER.freeMotionScalarInit.initAngle.R_rel.T[1,2] + 0.8191520442889918 * $DER.freeMotionScalarInit.initAngle.R_rel.T[1,3]   [dynamic |0|0|0|0|]
2/2 (1): $DER.freeMotionScalarInit.initAngle.R_rel.T[1,3] = $cse22 * $cse26 * freeMotionScalarInit.angle_d_1 + $cse23 * freeMotionScalarInit.angle_d_3 * $cse27 + $cse22 * freeMotionScalarInit.angle_d_3 * freeMotionScalarInit.initAngle.R_rel.T[3,1] * $cse26 - $cse23 * (freeMotionScalarInit.initAngle.R_rel.T[3,1] * (-$cse27) * freeMotionScalarInit.angle_d_1 + $DER.freeMotionScalarInit.initAngle.R_rel.T[3,1] * $cse26)   [dynamic |0|0|0|0|]
3/3 (1): $DER.freeMotionScalarInit.initAngle.R_rel.T[3,1] = $cse24 * freeMotionScalarInit.angle_d_2   [dynamic |0|0|0|0|]
4/4 (1): $STATESET1.x[1] = /*Real*/($STATESET1.A[1,1]) * freeMotionScalarInit.angle_d_2 + /*Real*/($STATESET1.A[1,2]) * freeMotionScalarInit.angle_d_1 + /*Real*/($STATESET1.A[1,3]) * bodyOfConstraint.body.w_a[3]   [dynamic |0|0|0|0|]
5/5 (1): $STATESET1.x[2] = /*Real*/($STATESET1.A[2,1]) * freeMotionScalarInit.angle_d_2 + /*Real*/($STATESET1.A[2,2]) * freeMotionScalarInit.angle_d_1 + /*Real*/($STATESET1.A[2,3]) * bodyOfConstraint.body.w_a[3]   [dynamic |0|0|0|0|]
6/6 (1): bodyOfConstraint.body.w_a[3] = freeMotionScalarInit.angle_d_3 + freeMotionScalarInit.initAngle.R_rel.T[3,1] * freeMotionScalarInit.angle_d_1   [dynamic |0|0|0|0|]
7/7 (1): $DER.freeMotionScalarInit.initAngle.R_rel.T[1,2] = $cse22 * (-$cse27) * freeMotionScalarInit.angle_d_1 + $cse23 * freeMotionScalarInit.angle_d_3 * $cse26 + $cse23 * (freeMotionScalarInit.initAngle.R_rel.T[3,1] * $cse26 * freeMotionScalarInit.angle_d_1 + $DER.freeMotionScalarInit.initAngle.R_rel.T[3,1] * $cse27) - $cse22 * freeMotionScalarInit.angle_d_3 * freeMotionScalarInit.initAngle.R_rel.T[3,1] * $cse27   [dynamic |0|0|0|0|]
8/8 (1): $DER.fixedTranslationOfConstraint.frame_b.R.T[1,2] = 0.9663834860128886 * $DER.freeMotionScalarInit.initAngle.R_rel.T[1,1] + 0.2370288965055821 * $DER.freeMotionScalarInit.initAngle.R_rel.T[1,2] + (-0.09960050292505122) * $DER.freeMotionScalarInit.initAngle.R_rel.T[1,3]   [dynamic |0|0|0|0|]
9/9 (1): 0.0 = 0.8191520442889918 * $DER.fixedTranslationOfConstraint.frame_b.R.T[1,1] + (-0.09960050292505122) * $DER.fixedTranslationOfConstraint.frame_b.R.T[1,2] + 0.5648625214636235 * $DER.fixedTranslationOfConstraint.frame_b.R.T[1,3]   [dynamic |0|0|0|0|]
10/10 (1): $DER.fixedTranslationOfConstraint.frame_b.R.T[1,3] = (-0.1411940808771254) * $DER.freeMotionScalarInit.initAngle.R_rel.T[1,1] + 0.8130157214783864 * $DER.freeMotionScalarInit.initAngle.R_rel.T[1,2] + 0.5648625214636235 * $DER.freeMotionScalarInit.initAngle.R_rel.T[1,3]   [dynamic |0|0|0|0|]
11/11 (1): $DER.freeMotionScalarInit.initAngle.R_rel.T[1,1] = $cse23 * (-freeMotionScalarInit.initAngle.R_rel.T[3,1]) * freeMotionScalarInit.angle_d_2 - $cse22 * freeMotionScalarInit.angle_d_3 * $cse24   [dynamic |0|0|0|0|]

with the corresponding C code:

void residualFunc1324(void** dataIn, const double* xloc, double* res, const int* iflag)
{
  TRACE_PUSH
  DATA *data = (DATA*) ((void**)dataIn[0]);
  threadData_t *threadData = (threadData_t*) ((void**)dataIn[1]);
  const int equationIndexes[2] = {1,1324};
  ANALYTIC_JACOBIAN* jacobian = NULL;
  data->localData[0]->realVars[44] /* der(freeMotionScalarInit.initAngle.R_rel.T[1,1]) DUMMY_DER */ = xloc[0];
  data->localData[0]->realVars[37] /* der(fixedTranslationOfConstraint.frame_b.R.T[1,3]) DUMMY_DER */ = xloc[1];
  data->localData[0]->realVars[36] /* der(fixedTranslationOfConstraint.frame_b.R.T[1,2]) DUMMY_DER */ = xloc[2];
  data->localData[0]->realVars[45] /* der(freeMotionScalarInit.initAngle.R_rel.T[1,2]) DUMMY_DER */ = xloc[3];
  data->localData[0]->realVars[334] /* freeMotionScalarInit.angle_d_3 DUMMY_STATE */ = xloc[4];
  data->localData[0]->realVars[332] /* freeMotionScalarInit.angle_d_1 DUMMY_STATE */ = xloc[5];
  data->localData[0]->realVars[108] /* bodyOfConstraint.body.w_a[3] DUMMY_STATE */ = xloc[6];
  data->localData[0]->realVars[333] /* freeMotionScalarInit.angle_d_2 DUMMY_STATE */ = xloc[7];
  data->localData[0]->realVars[48] /* der(freeMotionScalarInit.initAngle.R_rel.T[3,1]) DUMMY_DER */ = xloc[8];
  data->localData[0]->realVars[46] /* der(freeMotionScalarInit.initAngle.R_rel.T[1,3]) DUMMY_DER */ = xloc[9];
  data->localData[0]->realVars[35] /* der(fixedTranslationOfConstraint.frame_b.R.T[1,1]) DUMMY_DER */ = xloc[10];
  res[0] = (0.8191520442889918) * (data->localData[0]->realVars[46] /* der(freeMotionScalarInit.initAngle.R_rel.T[1,3]) DUMMY_DER */) + (-0.5318108111446446) * (data->localData[0]->realVars[45] /* der(freeMotionScalarInit.initAngle.R_rel.T[1,2]) DUMMY_DER */) + (0.2148655148851041) * (data->localData[0]->realVars[44] /* der(freeMotionScalarInit.initAngle.R_rel.T[1,1]) DUMMY_DER */) - data->localData[0]->realVars[35] /* der(fixedTranslationOfConstraint.frame_b.R.T[1,1]) DUMMY_DER */;

  res[1] = (data->localData[0]->realVars[74] /* $cse22 variable */) * ((data->localData[0]->realVars[334] /* freeMotionScalarInit.angle_d_3 DUMMY_STATE */) * ((data->localData[0]->realVars[356] /* freeMotionScalarInit.initAngle.R_rel.T[3,1] DUMMY_STATE */) * (data->localData[0]->realVars[77] /* $cse26 variable */))) + (data->localData[0]->realVars[75] /* $cse23 variable */) * ((data->localData[0]->realVars[334] /* freeMotionScalarInit.angle_d_3 DUMMY_STATE */) * (data->localData[0]->realVars[78] /* $cse27 variable */)) + (data->localData[0]->realVars[74] /* $cse22 variable */) * ((data->localData[0]->realVars[77] /* $cse26 variable */) * (data->localData[0]->realVars[332] /* freeMotionScalarInit.angle_d_1 DUMMY_STATE */)) - data->localData[0]->realVars[46] /* der(freeMotionScalarInit.initAngle.R_rel.T[1,3]) DUMMY_DER */ - ((data->localData[0]->realVars[75] /* $cse23 variable */) * ((data->localData[0]->realVars[356] /* freeMotionScalarInit.initAngle.R_rel.T[3,1] DUMMY_STATE */) * (((-data->localData[0]->realVars[78] /* $cse27 variable */)) * (data->localData[0]->realVars[332] /* freeMotionScalarInit.angle_d_1 DUMMY_STATE */)) + (data->localData[0]->realVars[48] /* der(freeMotionScalarInit.initAngle.R_rel.T[3,1]) DUMMY_DER */) * (data->localData[0]->realVars[77] /* $cse26 variable */)));

  res[2] = (data->localData[0]->realVars[76] /* $cse24 variable */) * (data->localData[0]->realVars[333] /* freeMotionScalarInit.angle_d_2 DUMMY_STATE */) - data->localData[0]->realVars[48] /* der(freeMotionScalarInit.initAngle.R_rel.T[3,1]) DUMMY_DER */;

  res[3] = (((modelica_real)data->localData[0]->integerVars[2] /* $STATESET1.A[1,3] variable */)) * (data->localData[0]->realVars[108] /* bodyOfConstraint.body.w_a[3] DUMMY_STATE */) + (((modelica_real)data->localData[0]->integerVars[1] /* $STATESET1.A[1,2] variable */)) * (data->localData[0]->realVars[332] /* freeMotionScalarInit.angle_d_1 DUMMY_STATE */) + (((modelica_real)data->localData[0]->integerVars[0] /* $STATESET1.A[1,1] variable */)) * (data->localData[0]->realVars[333] /* freeMotionScalarInit.angle_d_2 DUMMY_STATE */) - data->localData[0]->realVars[0] /* $STATESET1.x[1] STATE(1) */;

  res[4] = (((modelica_real)data->localData[0]->integerVars[5] /* $STATESET1.A[2,3] variable */)) * (data->localData[0]->realVars[108] /* bodyOfConstraint.body.w_a[3] DUMMY_STATE */) + (((modelica_real)data->localData[0]->integerVars[4] /* $STATESET1.A[2,2] variable */)) * (data->localData[0]->realVars[332] /* freeMotionScalarInit.angle_d_1 DUMMY_STATE */) + (((modelica_real)data->localData[0]->integerVars[3] /* $STATESET1.A[2,1] variable */)) * (data->localData[0]->realVars[333] /* freeMotionScalarInit.angle_d_2 DUMMY_STATE */) - data->localData[0]->realVars[1] /* $STATESET1.x[2] STATE(1) */;

  res[5] = (data->localData[0]->realVars[356] /* freeMotionScalarInit.initAngle.R_rel.T[3,1] DUMMY_STATE */) * (data->localData[0]->realVars[332] /* freeMotionScalarInit.angle_d_1 DUMMY_STATE */) + data->localData[0]->realVars[334] /* freeMotionScalarInit.angle_d_3 DUMMY_STATE */ - data->localData[0]->realVars[108] /* bodyOfConstraint.body.w_a[3] DUMMY_STATE */;

  res[6] = (data->localData[0]->realVars[75] /* $cse23 variable */) * ((data->localData[0]->realVars[356] /* freeMotionScalarInit.initAngle.R_rel.T[3,1] DUMMY_STATE */) * ((data->localData[0]->realVars[77] /* $cse26 variable */) * (data->localData[0]->realVars[332] /* freeMotionScalarInit.angle_d_1 DUMMY_STATE */)) + (data->localData[0]->realVars[48] /* der(freeMotionScalarInit.initAngle.R_rel.T[3,1]) DUMMY_DER */) * (data->localData[0]->realVars[78] /* $cse27 variable */)) + (data->localData[0]->realVars[75] /* $cse23 variable */) * ((data->localData[0]->realVars[334] /* freeMotionScalarInit.angle_d_3 DUMMY_STATE */) * (data->localData[0]->realVars[77] /* $cse26 variable */)) + (data->localData[0]->realVars[74] /* $cse22 variable */) * (((-data->localData[0]->realVars[78] /* $cse27 variable */)) * (data->localData[0]->realVars[332] /* freeMotionScalarInit.angle_d_1 DUMMY_STATE */)) - data->localData[0]->realVars[45] /* der(freeMotionScalarInit.initAngle.R_rel.T[1,2]) DUMMY_DER */ - ((data->localData[0]->realVars[74] /* $cse22 variable */) * ((data->localData[0]->realVars[334] /* freeMotionScalarInit.angle_d_3 DUMMY_STATE */) * ((data->localData[0]->realVars[356] /* freeMotionScalarInit.initAngle.R_rel.T[3,1] DUMMY_STATE */) * (data->localData[0]->realVars[78] /* $cse27 variable */))));

  res[7] = (-0.09960050292505122) * (data->localData[0]->realVars[46] /* der(freeMotionScalarInit.initAngle.R_rel.T[1,3]) DUMMY_DER */) + (0.2370288965055821) * (data->localData[0]->realVars[45] /* der(freeMotionScalarInit.initAngle.R_rel.T[1,2]) DUMMY_DER */) + (0.9663834860128886) * (data->localData[0]->realVars[44] /* der(freeMotionScalarInit.initAngle.R_rel.T[1,1]) DUMMY_DER */) - data->localData[0]->realVars[36] /* der(fixedTranslationOfConstraint.frame_b.R.T[1,2]) DUMMY_DER */;

  res[8] = (0.5648625214636235) * (data->localData[0]->realVars[37] /* der(fixedTranslationOfConstraint.frame_b.R.T[1,3]) DUMMY_DER */) + (-0.09960050292505122) * (data->localData[0]->realVars[36] /* der(fixedTranslationOfConstraint.frame_b.R.T[1,2]) DUMMY_DER */) + (0.8191520442889918) * (data->localData[0]->realVars[35] /* der(fixedTranslationOfConstraint.frame_b.R.T[1,1]) DUMMY_DER */);

  res[9] = (0.5648625214636235) * (data->localData[0]->realVars[46] /* der(freeMotionScalarInit.initAngle.R_rel.T[1,3]) DUMMY_DER */) + (0.8130157214783864) * (data->localData[0]->realVars[45] /* der(freeMotionScalarInit.initAngle.R_rel.T[1,2]) DUMMY_DER */) + (-0.1411940808771254) * (data->localData[0]->realVars[44] /* der(freeMotionScalarInit.initAngle.R_rel.T[1,1]) DUMMY_DER */) - data->localData[0]->realVars[37] /* der(fixedTranslationOfConstraint.frame_b.R.T[1,3]) DUMMY_DER */;

  res[10] = (data->localData[0]->realVars[75] /* $cse23 variable */) * (((-data->localData[0]->realVars[356] /* freeMotionScalarInit.initAngle.R_rel.T[3,1] DUMMY_STATE */)) * (data->localData[0]->realVars[333] /* freeMotionScalarInit.angle_d_2 DUMMY_STATE */)) + ((-data->localData[0]->realVars[74] /* $cse22 variable */)) * ((data->localData[0]->realVars[334] /* freeMotionScalarInit.angle_d_3 DUMMY_STATE */) * (data->localData[0]->realVars[76] /* $cse24 variable */)) - data->localData[0]->realVars[44] /* der(freeMotionScalarInit.initAngle.R_rel.T[1,1]) DUMMY_DER */;
  TRACE_POP
}

It's suspicious that all variables are dummy derivative variables.
And now we need to check all equations one by one. Maybe we get a clue where to continue with the search.

comment:4 by Andreas Heuermann, 4 years ago

Resolution: fixed
Status: newclosed

comment:5 by Francesco Casella, 4 years ago

Resolution: fixed
Status: closedreopened

@AnHeuermann, would you mind pushing this PR also to 1.17 maintenance, so we get this in 1.17.0 as well?

If you do that, pls. change the milestone to 1.17.0

Thanks!

comment:6 by Andreas Heuermann, 4 years ago

Milestone: 1.18.01.17.0

comment:8 by Andreas Heuermann, 4 years ago

Resolution: fixed
Status: reopenedclosed

The PR is now backported to the 1.17 maintenance branch.

comment:9 by Francesco Casella, 4 years ago

Thank you Andreas!

comment:10 by Andreas Heuermann, 4 years ago

Resolution: fixed
Status: closedreopened

Turns out that we didn't fix all problems, see the failing tests for

  • Modelica.Electrical.Machines.Examples.AsynchronousInductionMachines.AIMC_Transformer
  • Modelica.Mechanics.MultiBody.Examples.Constraints.RevoluteConstraint
  • Modelica.Mechanics.MultiBody.Examples.Constraints.PrismaticConstraint

from Jenkins PR-6969 run 24.

@kabdelhak Any lucky guesses?

comment:11 by Francesco Casella, 4 years ago

Milestone: 1.17.01.18.0

Retargeted to 1.18.0 because of 1.17.0 timed release.

comment:12 by Francesco Casella, 3 years ago

Milestone: 1.18.0

Ticket retargeted after milestone closed

Note: See TracTickets for help on using tickets.