Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BE] set --generateSymbolicJacobian by default #9221

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion OMCompiler/Compiler/BackEnd/BackendDump.mo
Original file line number Diff line number Diff line change
Expand Up @@ -1486,7 +1486,7 @@ algorithm
(innerEqLst,innerVarLst,_) = BackendDAEUtil.getEqnAndVarsFromInnerEquationLst(innerEquations);
tmpStr = tmpStr
+ "\nTearing Variables:\n-------------------------------------\n" + dumpMarkedVars(eSys,vlst) + "\n"
+ "Residual Equations:\n-------------------------------------\n" + dumpMarkedEqns(eSys,ilst)
+ "Residual Equations:\n-------------------------------------\n" + dumpMarkedEqns(eSys,ilst) + "\n"
+ "Inner Variables:\n-------------------------------------\n" + dumpMarkedVarsLsts(eSys,innerVarLst) + "\n"
+ "InnerEquations:\n-------------------------------------\n" + dumpMarkedEqns(eSys,innerEqLst);
else
Expand Down
39 changes: 25 additions & 14 deletions OMCompiler/Compiler/BackEnd/SymbolicJacobian.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2186,13 +2186,12 @@ algorithm
// no jacobian -> no nonlinear pattern
nonlinearPattern := BackendDAE.emptyNonlinearPattern;
end if;
// generate sparse pattern
if (not stringEq(inName, "FMIDERINIT")) then
(outSparsePattern,outSparseColoring) := generateSparsePattern(inBackendDAE, inDiffVars, BackendVariable.varList(inDifferentiatedVars));
end if;
else
fail();
outJacobian := NONE();
end try;
if (not stringEq(inName, "FMIDERINIT")) then
(outSparsePattern,outSparseColoring) := generateSparsePattern(inBackendDAE, inDiffVars, BackendVariable.varList(inDifferentiatedVars));
end if;
end generateGenericJacobian;

protected function createJacobian "author: wbraun"
Expand Down Expand Up @@ -4264,15 +4263,27 @@ algorithm
() := match (comp)
local
BackendDAE.JacobianType jacTp;
case BackendDAE.EQUATIONSYSTEM(jacType=BackendDAE.JAC_NONLINEAR())
then fail();
case BackendDAE.EQUATIONSYSTEM(jacType=BackendDAE.JAC_NO_ANALYTIC())
then fail();
case BackendDAE.EQUATIONSYSTEM(jacType=BackendDAE.JAC_GENERIC())
then fail();
case BackendDAE.TORNSYSTEM(linear=false)
then fail();
else ();
case BackendDAE.EQUATIONSYSTEM(jacType=BackendDAE.JAC_NONLINEAR()) algorithm
if Flags.isSet(Flags.JAC_DUMP) then
print("[symjacdump] Following strong component represents a nonlinear symbolic jacobian:\n" + BackendDump.printComponent(comp, SOME(syst)) + "\n");
end if;
then fail();
case BackendDAE.EQUATIONSYSTEM(jacType=BackendDAE.JAC_NO_ANALYTIC())algorithm
if Flags.isSet(Flags.JAC_DUMP) then
print("[symjacdump] Following strong component represents a no symbolic jacobian:\n" + BackendDump.printComponent(comp, SOME(syst)) + "\n");
end if;
then fail();
case BackendDAE.EQUATIONSYSTEM(jacType=BackendDAE.JAC_GENERIC())algorithm
if Flags.isSet(Flags.JAC_DUMP) then
print("[symjacdump] Following strong component represents a generic jacobian:\n" + BackendDump.printComponent(comp, SOME(syst)) + "\n");
end if;
then fail();
case BackendDAE.TORNSYSTEM(linear=false)algorithm
if Flags.isSet(Flags.JAC_DUMP) then
print("[symjacdump] Following (torn) strong component represents a nonlinear symbolic jacobian:\n" + BackendDump.printComponent(comp, SOME(syst)) + "\n");
end if;
then fail();
else ();
end match;
end for;
else
Expand Down
2 changes: 1 addition & 1 deletion OMCompiler/Compiler/Util/Flags.mo
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ constant ConfigFlag REPLACE_HOMOTOPY = CONFIG_FLAG(53, "replaceHomotopy",
Gettext.gettext("Replaces homotopy(actual, simplified) with the actual expression or the simplified expression. Good for debugging models which use homotopy. The default is to not replace homotopy."));

constant ConfigFlag GENERATE_SYMBOLIC_JACOBIAN = CONFIG_FLAG(54, "generateSymbolicJacobian",
NONE(), EXTERNAL(), BOOL_FLAG(false), NONE(),
NONE(), EXTERNAL(), BOOL_FLAG(true), NONE(),
Gettext.gettext("Generates symbolic Jacobian matrix, where der(x) is differentiated w.r.t. x. This matrix can be used by dassl or ida solver with simulation flag '-jacobian'."));

constant ConfigFlag GENERATE_SYMBOLIC_LINEARIZATION = CONFIG_FLAG(55, "generateSymbolicLinearization",
Expand Down