Skip to content

Commit

Permalink
Added analytical jacobian for linear strong components
Browse files Browse the repository at this point in the history
  - Added new flag LSanalyticJacobian to enable analytical jacobian for linear loops
    Defaults to false
  - Generate symbolic jacobian for linear systems when flag is enabled
  - Added testcase for linear solvers with analytical jacobian
  - Added testcase to dump sparsity pattern for linear problem
  • Loading branch information
AnHeuermann authored and lochel committed Jul 1, 2019
1 parent ea1e2c1 commit 6604e0d
Show file tree
Hide file tree
Showing 6 changed files with 359 additions and 106 deletions.
14 changes: 12 additions & 2 deletions OMCompiler/Compiler/BackEnd/SymbolicJacobian.mo
Expand Up @@ -2668,11 +2668,21 @@ algorithm
casualTearingSet.jac = jacobianCausal;
optCasualTearingSet = SOME(casualTearingSet);
end if;

then (BackendDAE.TORNSYSTEM(strictTearingset, optCasualTearingSet, linear, mixedSystem), shared);

// do not touch linear and constant systems for now
// do not touch constant systems for now
case (comp as BackendDAE.EQUATIONSYSTEM(jacType=BackendDAE.JAC_CONSTANT()), _, _, _) then (comp, inShared);

// Convert linear system to a torn system with symbolica jacobian, when flag is enabled
case (comp as BackendDAE.EQUATIONSYSTEM(jacType=BackendDAE.JAC_LINEAR(), eqns=residualequations, vars=iterationvarsInts, mixedSystem=mixedSystem), _, _, _)
guard(Flags.isSet(Flags.LS_ANALYTIC_JACOBIAN))
equation
strictTearingset = BackendDAE.TEARINGSET(iterationvarsInts, residualequations, {}, BackendDAE.EMPTY_JACOBIAN());
(jacobian, shared) = calculateTearingSetJacobian(inVars, inEqns, strictTearingset, inShared, true);
strictTearingset.jac = jacobian;
then (BackendDAE.TORNSYSTEM(strictTearingset, NONE(), true, mixedSystem), shared);

// Do not touch linear system
case (comp as BackendDAE.EQUATIONSYSTEM(jacType=BackendDAE.JAC_LINEAR()), _, _, _) then (comp, inShared);

case (BackendDAE.EQUATIONSYSTEM(eqns=residualequations, vars=iterationvarsInts, mixedSystem=mixedSystem), _, _, _)
Expand Down

0 comments on commit 6604e0d

Please sign in to comment.