@@ -1654,6 +1654,7 @@ continuous states: der(x) > dependent and x > independent
16541654clocked states: previous(x) > independent and x > dependent
16551655"
16561656 input list< BackendDAE . Var > independentVars;
1657+ input Boolean createpDerStates = true ;
16571658 output list< BackendDAE . Var > outVars = {};
16581659 output list< DAE . ComponentRef > outCrefs = {};
16591660protected
@@ -1664,9 +1665,12 @@ algorithm
16641665 var := BackendVariable . createClockedState(v);
16651666 outVars := var ::outVars;
16661667 outCrefs := var . varName::outCrefs;
1667- else
1668+ elseif createpDerStates then
16681669 outVars := BackendVariable . createpDerVar(v)::outVars;
16691670 outCrefs := v. varName::outCrefs;
1671+ else
1672+ outVars := v::outVars;
1673+ outCrefs := v. varName::outCrefs;
16701674 end if ;
16711675 end for ;
16721676 outVars := listReverse(outVars);
@@ -2000,7 +2004,7 @@ algorithm
20002004
20012005 BackendDAE . Shared shared ;
20022006 BackendDAE . Variables globalKnownVars, globalKnownVars1;
2003- list< BackendDAE . Var > diffedVars "resVars" , seedlst;
2007+ list< BackendDAE . Var > diffedVars "resVars" , seedlst, indepVars ;
20042008
20052009 DAE . FunctionTree funcs;
20062010
@@ -2013,9 +2017,20 @@ algorithm
20132017
20142018 comref_vars = List . map(inDiffVars, BackendVariable . varCref);
20152019 seedlst = List . map1(comref_vars, createSeedVars, inName);
2020+ indepVars = createInDepVars(inDiffVars, false );
2021+
2022+ if Flags . isSet(Flags . JAC_DUMP ) then
2023+ print("Crete symbolic Jacobianis from: \n " );
2024+ print(BackendDump . varListString(indepVars, "Independent Variables" ));
2025+ print(BackendDump . varListString(diffedVars, "Dependent Variables" ));
2026+ print("Basic equation system: \n " );
2027+ print(BackendDump . equationListString(BackendEquation . equationSystemsEqnsLst(reducedDAE. eqs), "differentiated equations" ));
2028+ print(BackendDump . varListString(BackendVariable . equationSystemsVarsLst(reducedDAE. eqs), "related variables" ));
2029+ print(BackendDump . varListString(BackendVariable . varList(reducedDAE. shared . globalKnownVars), "known variables" ));
2030+ end if ;
20162031
2017- // Differentiate the ODE system w.r.t states for jacobian
2018- (backendDAE as BackendDAE . DAE (shared = _), funcs) = generateSymbolicJacobian(reducedDAE, inDiffVars , inDifferentiatedVars, BackendVariable . listVar1(seedlst), inStateVars, inInputVars, inParameterVars, inName);
2032+ // Differentiate the eqns system in reducedDAE w.r.t. independents
2033+ (backendDAE as BackendDAE . DAE (shared = _), funcs) = generateSymbolicJacobian(reducedDAE, indepVars , inDifferentiatedVars, BackendVariable . listVar1(seedlst), inStateVars, inInputVars, inParameterVars, inName);
20192034 if Flags . isSet(Flags . JAC_DUMP2 ) then
20202035 print("analytical Jacobians -> generated equations for Jacobian " + inName + " time: " + realString(clock()) + " \n " );
20212036 end if ;
0 commit comments