Skip to content

Commit

Permalink
[BE] update -d=dumpLoops and -d=dumpLoopsVerbose
Browse files Browse the repository at this point in the history
 - also dump initialization system
 - don't dump empty system headers
 - add size information
  • Loading branch information
kabdelhak authored and adrpo committed Jan 27, 2020
1 parent 6a5601b commit 1a699f7
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 17 deletions.
3 changes: 3 additions & 0 deletions OMCompiler/Compiler/BackEnd/BackendDAEUtil.mo
Expand Up @@ -7823,7 +7823,10 @@ algorithm
BackendDump.dumpEqnsSolved(outSimDAE, "indxdae: eqns in order");
end if;
if Flags.isSet(Flags.DUMP_LOOPS) or Flags.isSet(Flags.DUMP_LOOPS_VERBOSE) then
print("\n" + BackendDump.BORDER + "\n\n Algbraic Loops (Simulation): \n\n" + BackendDump.BORDER + "\n");
BackendDump.dumpLoops(outSimDAE);
print("\n" + BackendDump.BORDER + "\n\n Algbraic Loops (Initialization): \n\n" + BackendDump.BORDER + "\n");
BackendDump.dumpLoops(outInitDAE);
end if;
checkBackendDAEWithErrorMsg(outSimDAE);
return;
Expand Down
15 changes: 10 additions & 5 deletions OMCompiler/Compiler/BackEnd/BackendDump.mo
Expand Up @@ -1188,16 +1188,16 @@ algorithm
(elst1,vlst1Lst,_) = List.map_3(innerEquations, BackendDAEUtil.getEqnAndVarsFromInnerEquation);
vlst1 = List.flatten(vlst1Lst);
varlst = List.map1r(vlst1, BackendVariable.getVarAt, vars);
print("\ninternal vars\n");
print("\ninternal vars (" + intString(listLength(varlst)) + ")\n");
printVarList(varlst);
varlst = List.map1r(vlst, BackendVariable.getVarAt, vars);
print("\nresidual vars\n");
print("\nresidual vars (" + intString(listLength(varlst)) + ")\n");
printVarList(varlst);
print("\ninternal equation\n");
eqnlst = BackendEquation.getList(elst1,eqns);
print("\ninternal equations (" + intString(listLength(eqnlst)) + ")\n");
printEquationList(eqnlst);
print("\nresidual equations\n");
eqnlst = BackendEquation.getList(elst,eqns);
print("\nresidual equations (" + intString(listLength(eqnlst)) + ")\n");
printEquationList(eqnlst);
print("\n");
dumpEqnsSolved2(rest,eqns,vars);
Expand Down Expand Up @@ -1262,6 +1262,7 @@ protected
BackendDAE.EquationArray eqns;
BackendDAE.Variables vars;
Integer isyst = 1;
Boolean firstComp = true; // used to print header only if there is actually an algebraic loop
algorithm
_ := match outDAE.shared
case BackendDAE.SHARED(backendDAEType=BackendDAE.SIMULATION()) then print("SIMULATION\n");
Expand All @@ -1270,10 +1271,14 @@ algorithm
end match;

for syst in inDAE.eqs loop
print("\nsystem " + intString(isyst) + "\n" + UNDERLINE + "\n");
firstComp := true;
BackendDAE.EQSYSTEM(orderedVars=vars,orderedEqs=eqns, matching=BackendDAE.MATCHING(comps=comps)) := syst;
for comp in comps loop
if BackendEquation.isEquationsSystem(comp) or BackendEquation.isTornSystem(comp) then
if firstComp then
firstComp := false;
print("\nsystem " + intString(isyst) + "\n" + UNDERLINE + "\n");
end if;
print("\n" + BORDER + BORDER + "\n dumpLoops: SORTED COMPONENT \n" + BORDER + BORDER + "\n\n");
dumpEqnsSolved2({comp}, eqns, vars);
if Flags.isSet(Flags.DUMP_LOOPS_VERBOSE) then
Expand Down
46 changes: 42 additions & 4 deletions testsuite/simulation/modelica/inlineFunction/forceComplexEq2.mos
Expand Up @@ -33,6 +33,12 @@ val(x3,{0,1});
// true
// ""
//
// ########################################
//
// Algbraic Loops (Simulation):
//
// ########################################
//
// system 1
// ========================================
//
Expand All @@ -42,22 +48,54 @@ val(x3,{0,1});
//
// torn nonlinear Equationsystem:
//
// internal vars
// internal vars (2)
// 1: x4:VARIABLE() type: Real
// 2: x1:VARIABLE() type: Real
//
// residual vars
// residual vars (2)
// 1: x2:VARIABLE() type: Real
// 2: x3:VARIABLE() type: Real
//
// internal equation
// internal equations (2)
// 1/1 (1): x2 = 3.0 * (1.0 + 3.0 * x2 + x3 + (-5.0) * x4) [unknown |0|0|0|0|]
// 2/2 (1): x3 = 3.0 * (x1 + x3 - x2) [unknown |0|0|0|0|]
//
// residual equations
// residual equations (2)
// 1/1 (1): x1 = (3.0 * x1 + $cse3) * (1.0 + 3.0 * x2 + x3 + (-5.0) * x4) [unknown |0|0|0|0|]
// 2/2 (1): x4 = $cse4 * (x1 + x3 - x2) [unknown |0|0|0|0|]
//
//
// ########################################
//
// Algbraic Loops (Initialization):
//
// ########################################
//
// system 1
// ========================================
//
// ################################################################################
// dumpLoops: SORTED COMPONENT
// ################################################################################
//
// torn nonlinear Equationsystem:
//
// internal vars (2)
// 1: x4:VARIABLE() type: Real
// 2: x1:VARIABLE() type: Real
//
// residual vars (2)
// 1: x3:VARIABLE() type: Real
// 2: x2:VARIABLE() type: Real
//
// internal equations (2)
// 1/1 (1): x2 = 3.0 * (1.0 + 3.0 * x2 + x3 + (-5.0) * x4) [dynamic |0|0|0|0|]
// 2/2 (1): x3 = 3.0 * (x1 + x3 - x2) [dynamic |0|0|0|0|]
//
// residual equations (2)
// 1/1 (1): x1 = (3.0 * x1 + cos(time)) * (1.0 + 3.0 * x2 + x3 + (-5.0) * x4) [dynamic |0|0|0|0|]
// 2/2 (1): x4 = sin(time) * (x1 + x3 - x2) [dynamic |0|0|0|0|]
//
// record SimulationResult
// resultFile = "foo_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'foo', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
Expand Down
62 changes: 58 additions & 4 deletions testsuite/simulation/modelica/inlineFunction/forceComplexEq3.mos
Expand Up @@ -36,6 +36,12 @@ val(x3,{0,1});
// true
// ""
//
// ########################################
//
// Algbraic Loops (Simulation):
//
// ########################################
//
// system 1
// ========================================
//
Expand All @@ -45,7 +51,7 @@ val(x3,{0,1});
//
// torn nonlinear Equationsystem:
//
// internal vars
// internal vars (10)
// 1: y2$$Pfoo$Pf9:VARIABLE() type: Real
// 2: x4:VARIABLE() type: Real
// 3: y1$$Pfoo$Pf12:VARIABLE() type: Real
Expand All @@ -57,11 +63,11 @@ val(x3,{0,1});
// 9: b$$Pfoo$Pf11:VARIABLE() type: Real
// 10: y1$$Pfoo$Pf8:VARIABLE() type: Real
//
// residual vars
// residual vars (2)
// 1: x3:VARIABLE() type: Real
// 2: x2:VARIABLE() type: Real
//
// internal equation
// internal equations (10)
// 1/1 (1): x2 = y2$$Pfoo$Pf9 [unknown |0|0|0|0|]
// 2/2 (1): y2$$Pfoo$Pf9 = -5.0 + 3.0 * (1.0 + 3.0 * x2 + x3 + (-5.0) * x4) [unknown |0|0|0|0|]
// 3/3 (1): x4 = y1$$Pfoo$Pf12 [unknown |0|0|0|0|]
Expand All @@ -73,10 +79,58 @@ val(x3,{0,1});
// 9/9 (1): b$$Pfoo$Pf11 = 23.0 * a$$Pfoo$Pf10 [unknown |0|0|0|0|]
// 10/10 (1): y1$$Pfoo$Pf8 = b$$Pfoo$Pf11 * (1.0 + 3.0 * x2 + x3 + (-5.0) * x4) - a$$Pfoo$Pf10 [unknown |0|0|0|0|]
//
// residual equations
// residual equations (2)
// 1/1 (1): y1$$Pfoo$Pf12 = b$$Pfoo$Pf15 * (x1 + x3 - x2) - a$$Pfoo$Pf14 [unknown |0|0|0|0|]
// 2/2 (1): x1 = y1$$Pfoo$Pf8 [unknown |0|0|0|0|]
//
//
// ########################################
//
// Algbraic Loops (Initialization):
//
// ########################################
//
// system 1
// ========================================
//
// ################################################################################
// dumpLoops: SORTED COMPONENT
// ################################################################################
//
// torn nonlinear Equationsystem:
//
// internal vars (10)
// 1: y2$$Pfoo$Pf5:VARIABLE() type: Real
// 2: x1:VARIABLE() type: Real
// 3: a$$Pfoo$Pf6:VARIABLE() type: Real
// 4: b$$Pfoo$Pf7:VARIABLE() type: Real
// 5: y1$$Pfoo$Pf4:VARIABLE() type: Real
// 6: x4:VARIABLE() type: Real
// 7: a$$Pfoo$Pf2:VARIABLE() type: Real
// 8: y2$$Pfoo$Pf1:VARIABLE() type: Real
// 9: b$$Pfoo$Pf3:VARIABLE() type: Real
// 10: y1$$Pfoo$Pf0:VARIABLE() type: Real
//
// residual vars (2)
// 1: x2:VARIABLE() type: Real
// 2: x3:VARIABLE() type: Real
//
// internal equations (10)
// 1/1 (1): x3 = y2$$Pfoo$Pf5 [dynamic |0|0|0|0|]
// 2/2 (1): y2$$Pfoo$Pf5 = -5.0 + 3.0 * (x1 + x3 - x2) [unknown |0|0|0|0|]
// 3/3 (1): a$$Pfoo$Pf6 = 10.0 + sin(time) - (x1 + x3 - x2) [unknown |0|0|0|0|]
// 4/4 (1): b$$Pfoo$Pf7 = 23.0 * a$$Pfoo$Pf6 [unknown |0|0|0|0|]
// 5/5 (1): y1$$Pfoo$Pf4 = b$$Pfoo$Pf7 * (x1 + x3 - x2) - a$$Pfoo$Pf6 [unknown |0|0|0|0|]
// 6/6 (1): x4 = y1$$Pfoo$Pf4 [dynamic |0|0|0|0|]
// 7/7 (1): a$$Pfoo$Pf2 = 10.0 + 3.0 * x1 + cos(time) - (1.0 + 3.0 * x2 + x3 + (-5.0) * x4) [unknown |0|0|0|0|]
// 8/8 (1): y2$$Pfoo$Pf1 = -5.0 + 3.0 * (1.0 + 3.0 * x2 + x3 + (-5.0) * x4) [unknown |0|0|0|0|]
// 9/9 (1): b$$Pfoo$Pf3 = 23.0 * a$$Pfoo$Pf2 [unknown |0|0|0|0|]
// 10/10 (1): y1$$Pfoo$Pf0 = b$$Pfoo$Pf3 * (1.0 + 3.0 * x2 + x3 + (-5.0) * x4) - a$$Pfoo$Pf2 [unknown |0|0|0|0|]
//
// residual equations (2)
// 1/1 (1): x2 = y2$$Pfoo$Pf1 [dynamic |0|0|0|0|]
// 2/2 (1): x1 = y1$$Pfoo$Pf0 [dynamic |0|0|0|0|]
//
// record SimulationResult
// resultFile = "foo_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'foo', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
Expand Down
46 changes: 42 additions & 4 deletions testsuite/simulation/modelica/inlineFunction/forceComplexEq4.mos
Expand Up @@ -36,6 +36,12 @@ val(x3,{0,1});
// true
// ""
//
// ########################################
//
// Algbraic Loops (Simulation):
//
// ########################################
//
// system 1
// ========================================
//
Expand All @@ -45,22 +51,54 @@ val(x3,{0,1});
//
// torn nonlinear Equationsystem:
//
// internal vars
// internal vars (2)
// 1: x4:VARIABLE() type: Real
// 2: x1:VARIABLE() type: Real
//
// residual vars
// residual vars (2)
// 1: x2:VARIABLE() type: Real
// 2: x3:VARIABLE() type: Real
//
// internal equation
// internal equations (2)
// 1/1 (1): x2 = -5.0 + 3.0 * (1.0 + 3.0 * x2 + x3 + (-5.0) * x4) [unknown |0|0|0|0|]
// 2/2 (1): x3 = -5.0 + 3.0 * (x1 + x3 - x2) [unknown |0|0|0|0|]
//
// residual equations
// residual equations (2)
// 1/1 (1): x1 = 23.0 * (10.0 + 3.0 * x1 + $cse3 - (1.0 + 3.0 * x2 + x3 + (-5.0) * x4)) * (1.0 + 3.0 * x2 + x3 + (-5.0) * x4) - (10.0 + 3.0 * x1 + $cse3 - (1.0 + 3.0 * x2 + x3 + (-5.0) * x4)) [unknown |0|0|0|0|]
// 2/2 (1): x4 = 23.0 * (10.0 + $cse4 - (x1 + x3 - x2)) * (x1 + x3 - x2) - (10.0 + $cse4 - (x1 + x3 - x2)) [unknown |0|0|0|0|]
//
//
// ########################################
//
// Algbraic Loops (Initialization):
//
// ########################################
//
// system 1
// ========================================
//
// ################################################################################
// dumpLoops: SORTED COMPONENT
// ################################################################################
//
// torn nonlinear Equationsystem:
//
// internal vars (2)
// 1: x4:VARIABLE() type: Real
// 2: x1:VARIABLE() type: Real
//
// residual vars (2)
// 1: x3:VARIABLE() type: Real
// 2: x2:VARIABLE() type: Real
//
// internal equations (2)
// 1/1 (1): x2 = -5.0 + 3.0 * (1.0 + 3.0 * x2 + x3 + (-5.0) * x4) [dynamic |0|0|0|0|]
// 2/2 (1): x3 = -5.0 + 3.0 * (x1 + x3 - x2) [dynamic |0|0|0|0|]
//
// residual equations (2)
// 1/1 (1): x1 = 23.0 * (10.0 + 3.0 * x1 + cos(time) - (1.0 + 3.0 * x2 + x3 + (-5.0) * x4)) * (1.0 + 3.0 * x2 + x3 + (-5.0) * x4) - (10.0 + 3.0 * x1 + cos(time) - (1.0 + 3.0 * x2 + x3 + (-5.0) * x4)) [dynamic |0|0|0|0|]
// 2/2 (1): x4 = 23.0 * (10.0 + sin(time) - (x1 + x3 - x2)) * (x1 + x3 - x2) - (10.0 + sin(time) - (x1 + x3 - x2)) [dynamic |0|0|0|0|]
//
// record SimulationResult
// resultFile = "foo_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'foo', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
Expand Down

0 comments on commit 1a699f7

Please sign in to comment.