From 69d91517a6653ef97cd46677c28c9b4294c2c272 Mon Sep 17 00:00:00 2001 From: kabdelhak <38032125+kabdelhak@users.noreply.github.com> Date: Tue, 24 Oct 2023 17:16:51 +0200 Subject: [PATCH] [NB] udapte discrete state handling (#11405) * [NB] udapte discrete state handling - only collect discrete states from LHS of when equations - collect pre variables for all variables and dont assume they are discrete states - update start/pre initial equations - update variable structure - update -d=backenddaeinfo --- .../NBackEnd/Classes/NBStrongComponent.mo | 9 ++ .../Compiler/NBackEnd/Classes/NBSystem.mo | 16 ++ .../Compiler/NBackEnd/Classes/NBVariable.mo | 152 ++++++++---------- .../Compiler/NBackEnd/Classes/NBackendDAE.mo | 43 ++--- .../NBackEnd/Modules/1_Main/NBAdjacency.mo | 4 +- .../Modules/1_Main/NBInitialization.mo | 90 ++++++----- .../NBackEnd/Modules/1_Main/NBPartitioning.mo | 2 +- .../Modules/1_Main/NBResolveSingularities.mo | 4 +- .../NBackEnd/Modules/2_Pre/NBDetectStates.mo | 100 ++++++------ .../NBackEnd/Modules/3_Post/NBJacobian.mo | 1 + .../Compiler/NBackEnd/Modules/NBModule.mo | 15 +- .../Compiler/NFFrontEnd/NFBackendExtension.mo | 25 +-- OMCompiler/Compiler/NFFrontEnd/NFVariable.mo | 5 +- OMCompiler/Compiler/NSimCode/NSimVar.mo | 35 ++-- .../modelica/NBackend/basics/partitioning.mos | 60 +++---- .../NBackend/event_handling/hybridSys.mos | 6 +- .../NBackend/functions/builtin_functions.mos | 54 +++---- 17 files changed, 321 insertions(+), 300 deletions(-) diff --git a/OMCompiler/Compiler/NBackEnd/Classes/NBStrongComponent.mo b/OMCompiler/Compiler/NBackEnd/Classes/NBStrongComponent.mo index 9f3660ac50a..84b82683ed4 100644 --- a/OMCompiler/Compiler/NBackEnd/Classes/NBStrongComponent.mo +++ b/OMCompiler/Compiler/NBackEnd/Classes/NBStrongComponent.mo @@ -306,6 +306,15 @@ public end match; end isEqual; + function removeAlias + input output StrongComponent comp; + algorithm + comp := match comp + case ALIAS() then comp.original; + else comp; + end match; + end removeAlias; + function createPseudoSlice input Integer eqn_arr_idx; input ComponentRef cref_to_solve; diff --git a/OMCompiler/Compiler/NBackEnd/Classes/NBSystem.mo b/OMCompiler/Compiler/NBackEnd/Classes/NBSystem.mo index e95eab1e9ba..5f6cdc10f06 100644 --- a/OMCompiler/Compiler/NBackEnd/Classes/NBSystem.mo +++ b/OMCompiler/Compiler/NBackEnd/Classes/NBSystem.mo @@ -304,6 +304,22 @@ public end if; end clone; + function removeAlias + "removes alias strong components and replaces it with their original strong components. + used before differentiating for jacobians." + input output System sys; + protected + array comps; + algorithm + if Util.isSome(sys.strongComponents) then + // no need to override comps afterwards since arrays are mutable + comps := Util.getOption(sys.strongComponents); + for i in 1:arrayLength(comps) loop + comps[i] := StrongComponent.removeAlias(comps[i]); + end for; + end if; + end removeAlias; + protected function partitionKindString input PartitionKind partitionKind; diff --git a/OMCompiler/Compiler/NBackEnd/Classes/NBVariable.mo b/OMCompiler/Compiler/NBackEnd/Classes/NBVariable.mo index 4aed5cb3190..4f79e088297 100644 --- a/OMCompiler/Compiler/NBackEnd/Classes/NBVariable.mo +++ b/OMCompiler/Compiler/NBackEnd/Classes/NBVariable.mo @@ -87,7 +87,7 @@ public constant Variable TIME_VARIABLE = Variable.VARIABLE(NFBuiltin.TIME_CREF, Type.REAL(), NFBinding.EMPTY_BINDING, NFPrefixes.Visibility.PUBLIC, NFAttributes.DEFAULT_ATTR, {}, {}, NONE(), SCodeUtil.dummyInfo, BackendExtension.BACKEND_INFO( - VariableKind.TIME(), NFBackendExtension.EMPTY_VAR_ATTR_REAL, NFBackendExtension.EMPTY_ANNOTATIONS)); + VariableKind.TIME(), NFBackendExtension.EMPTY_VAR_ATTR_REAL, NFBackendExtension.EMPTY_ANNOTATIONS, NONE())); constant String DERIVATIVE_STR = "$DER"; constant String DUMMY_DERIVATIVE_STR = "$dDER"; @@ -170,6 +170,20 @@ public Pointer.update(var_ptr, var); end makeVarPtrCyclic; + function connectPrePostVar + "sets the pre() var for the variable and also sets the variable pointer at the pre() variable" + input Pointer var_ptr; + input Pointer pre_ptr; + protected + Variable var = Pointer.access(var_ptr); + Variable pre = Pointer.access(pre_ptr); + algorithm + var.backendinfo := BackendInfo.setPrePost(var.backendinfo, SOME(pre_ptr)); + pre.backendinfo := BackendInfo.setPrePost(pre.backendinfo, SOME(var_ptr)); + Pointer.update(var_ptr, var); + Pointer.update(pre_ptr, pre); + end connectPrePostVar; + function getVar input ComponentRef cref; output Variable var; @@ -331,6 +345,39 @@ public end match; end isPrevious; + function getPrePost + "gets the pre() / previous() var if its a variable / clocked variable or the other way around" + input Pointer var_ptr; + output Option> pre_post; + protected + Variable var = Pointer.access(var_ptr); + algorithm + pre_post := var.backendinfo.pre_post; + end getPrePost; + + function getPrePostCref + "only use if you are sure there is a pre-post variable" + input ComponentRef cref; + output ComponentRef pre_post; + protected + Option> pre_post_opt; + algorithm + pre_post_opt := getPrePost(getVarPointer(cref)); + if Util.isSome(pre_post_opt) then + pre_post := getVarName(Util.getOption(pre_post_opt)); + else + Error.addMessage(Error.INTERNAL_ERROR,{getInstanceName() + " failed for " + ComponentRef.toString(cref) + " because it had no pre or post variable."}); + fail(); + end if; + end getPrePostCref; + + function hasPre + "only returns true if the variable itself is not a pre() or previous() and has a pre() pointer set" + extends checkVar; + algorithm + b := not isPrevious(var_ptr) and Util.isSome(getPrePost(var_ptr)); + end hasPre; + function isDummyState extends checkVar; algorithm b := match Pointer.access(var_ptr) @@ -427,10 +474,11 @@ public algorithm b := match Pointer.access(var_ptr) case Variable.VARIABLE(backendinfo = BackendExtension.BACKEND_INFO(varKind = BackendExtension.STATE())) then not isFixed(var_ptr); - case Variable.VARIABLE(backendinfo = BackendExtension.BACKEND_INFO(varKind = BackendExtension.DISCRETE())) then not isFixed(var_ptr); - case Variable.VARIABLE(backendinfo = BackendExtension.BACKEND_INFO(varKind = BackendExtension.DISCRETE_STATE())) then true; - case Variable.VARIABLE(backendinfo = BackendExtension.BACKEND_INFO(varKind = BackendExtension.PREVIOUS())) then not isFixed(getDiscreteStateVar(var_ptr)); + case Variable.VARIABLE(backendinfo = BackendExtension.BACKEND_INFO(varKind = BackendExtension.ALGEBRAIC())) then not isFixed(var_ptr) or hasPre(var_ptr); + case Variable.VARIABLE(backendinfo = BackendExtension.BACKEND_INFO(varKind = BackendExtension.DISCRETE())) then not isFixed(var_ptr) or hasPre(var_ptr); + case Variable.VARIABLE(backendinfo = BackendExtension.BACKEND_INFO(varKind = BackendExtension.DISCRETE_STATE())) then not isFixed(var_ptr) or hasPre(var_ptr); case Variable.VARIABLE(backendinfo = BackendExtension.BACKEND_INFO(varKind = BackendExtension.PARAMETER())) then not isFixed(var_ptr); + case Variable.VARIABLE(backendinfo = BackendExtension.BACKEND_INFO(varKind = BackendExtension.PREVIOUS())) then true; else false; end match; end isFixable; @@ -574,8 +622,6 @@ public state_var := match Pointer.access(der_var) case Variable.VARIABLE(backendinfo = BackendExtension.BACKEND_INFO(varKind = BackendExtension.STATE_DER(state = state_var))) then state_var; - case Variable.VARIABLE(backendinfo = BackendExtension.BACKEND_INFO(varKind = BackendExtension.PREVIOUS(state = state_var))) - then state_var; else algorithm Error.addMessage(Error.INTERNAL_ERROR,{getInstanceName() + " failed for " + pointerToString(der_var) + " because of wrong variable kind."}); then fail(); @@ -596,10 +642,6 @@ public algorithm stateVar := Pointer.access(state); then stateVar.name; - case Variable.VARIABLE(backendinfo = BackendExtension.BACKEND_INFO(varKind = BackendExtension.PREVIOUS(state = state))) - algorithm - stateVar := Pointer.access(state); - then stateVar.name; else algorithm Error.addMessage(Error.INTERNAL_ERROR,{getInstanceName() + " failed for " + ComponentRef.toString(cref) + " because of wrong variable kind."}); then fail(); @@ -647,43 +689,6 @@ public end match; end getDerCref; - function getDiscreteStateVar - input Pointer pre_var; - output Pointer state_var; - algorithm - state_var := match Pointer.access(pre_var) - case Variable.VARIABLE(backendinfo = BackendExtension.BACKEND_INFO(varKind = BackendExtension.PREVIOUS(state = state_var))) - then state_var; - else algorithm - Error.addMessage(Error.INTERNAL_ERROR,{getInstanceName() + " failed for " + pointerToString(pre_var) + " because of wrong variable kind."}); - then fail(); - end match; - end getDiscreteStateVar; - - function getDiscreteStateCref - "Returns the discrete state variable component reference from a previous reference. - Only works after the discrete state has been detected by the DetectStates module and fails for non-previous crefs!" - input output ComponentRef cref; - algorithm - cref := match cref - local - Pointer previous, state; - Variable stateVar; - case ComponentRef.CREF(node = InstNode.VAR_NODE(varPointer = previous)) then match Pointer.access(previous) - case Variable.VARIABLE(backendinfo = BackendExtension.BACKEND_INFO(varKind = BackendExtension.PREVIOUS(state = state))) - algorithm - stateVar := Pointer.access(state); - then stateVar.name; - else algorithm - Error.addMessage(Error.INTERNAL_ERROR,{getInstanceName() + " failed for " + ComponentRef.toString(cref) + " because of wrong variable kind."}); - then fail(); - end match; - else algorithm - Error.addMessage(Error.INTERNAL_ERROR,{getInstanceName() + " failed for " + ComponentRef.toString(cref) + " because of wrong InstNode type."}); - then fail(); - end match; - end getDiscreteStateCref; - function getRecordChildren "returns all children of the variable if its a record, otherwise returns empty list" input Pointer var; @@ -751,35 +756,34 @@ public function makeDiscreteStateVar "Updates a discrete variable pointer to be a discrete state, requires the pointer to its left limit (pre) variable." input Pointer varPointer; - input Pointer previous; protected - Variable var; + Variable var = Pointer.access(varPointer); algorithm - var := Pointer.access(varPointer); - var.backendinfo := BackendExtension.BackendInfo.setVarKind(var.backendinfo, BackendExtension.DISCRETE_STATE(previous, false)); + var.backendinfo := BackendExtension.BackendInfo.setVarKind(var.backendinfo, BackendExtension.DISCRETE_STATE(false)); Pointer.update(varPointer, var); end makeDiscreteStateVar; function makePreVar - "Creates a previous variable pointer from the discrete variable cref. + "Creates a previous variable pointer from the variable cref. e.g. isOpen -> $PRE.isOpen" input ComponentRef cref "old component reference"; output ComponentRef pre_cref "new component reference"; - output Pointer var_ptr "pointer to new variable"; + output Pointer pre_ptr "pointer to new variable"; algorithm () := match ComponentRef.node(cref) local InstNode qual; - Pointer disc; - Variable var; + Pointer var_ptr; + Variable pre; case qual as InstNode.VAR_NODE() algorithm - disc := BVariable.getVarPointer(cref); + var_ptr := BVariable.getVarPointer(cref); qual.name := PREVIOUS_STR; pre_cref := ComponentRef.append(cref, ComponentRef.fromNode(qual, ComponentRef.scalarType(cref))); - var := fromCref(pre_cref, Variable.attributes(Pointer.access(disc))); - var.backendinfo := BackendExtension.BackendInfo.setVarKind(var.backendinfo, BackendExtension.PREVIOUS(disc)); - (var_ptr, pre_cref) := makeVarPtrCyclic(var, pre_cref); + pre := fromCref(pre_cref, Variable.attributes(Pointer.access(var_ptr))); + pre.backendinfo := BackendExtension.BackendInfo.setVarKind(pre.backendinfo, BackendExtension.PREVIOUS()); + (pre_ptr, pre_cref) := makeVarPtrCyclic(pre, pre_cref); + connectPrePostVar(var_ptr, pre_ptr); then (); else algorithm @@ -788,30 +792,6 @@ public end match; end makePreVar; - function getPreCref - "Returns the previous variable component reference from a discrete componet reference. - Only works after the discrete state has been detected by the DetectStates module and fails for non-discrete-state crefs!" - input output ComponentRef cref; - algorithm - cref := match cref - local - Pointer disc, previous; - Variable preVar; - case ComponentRef.CREF(node = InstNode.VAR_NODE(varPointer = disc)) then match Pointer.access(disc) - case Variable.VARIABLE(backendinfo = BackendExtension.BACKEND_INFO(varKind = BackendExtension.DISCRETE_STATE(previous = previous))) - algorithm - preVar := Pointer.access(previous); - then preVar.name; - else algorithm - Error.addMessage(Error.INTERNAL_ERROR,{getInstanceName() + " failed for " + ComponentRef.toString(cref) + " because of wrong variable kind."}); - then fail(); - end match; - else algorithm - Error.addMessage(Error.INTERNAL_ERROR,{getInstanceName() + " failed for " + ComponentRef.toString(cref) + " because of wrong InstNode type."}); - then fail(); - end match; - end getPreCref; - function makeSeedVar "Creates a seed variable pointer from a cref. Used in NBJacobian and NBHessian to represent generic gradient equations. @@ -1696,11 +1676,13 @@ public VariablePointers derivatives "State derivatives (der(x) -> $DER.x)"; VariablePointers algebraics "Algebraic variables"; VariablePointers discretes "Discrete variables"; - VariablePointers previous "Previous discrete variables (pre(d) -> $PRE.d)"; + VariablePointers discrete_states "Discrete state variables"; + VariablePointers previous "Previous variables (pre(d) -> $PRE.d)"; // clocked /* subset of knowns */ VariablePointers states "States"; + VariablePointers top_level_inputs "Top level inputs"; VariablePointers parameters "Parameters"; VariablePointers constants "Constants"; VariablePointers records "Records"; @@ -1828,7 +1810,9 @@ public VariablePointers.toString(varData.derivatives, "Derivative", false) + VariablePointers.toString(varData.algebraics, "Algebraic", false) + VariablePointers.toString(varData.discretes, "Discrete", false) + + VariablePointers.toString(varData.discrete_states, "Discrete States", false) + VariablePointers.toString(varData.previous, "Previous", false) + + VariablePointers.toString(varData.top_level_inputs, "Top Level Inputs", false) + VariablePointers.toString(varData.parameters, "Parameter", false) + VariablePointers.toString(varData.constants, "Constant", false) + VariablePointers.toString(varData.records, "Record", false) + diff --git a/OMCompiler/Compiler/NBackEnd/Classes/NBackendDAE.mo b/OMCompiler/Compiler/NBackEnd/Classes/NBackendDAE.mo index 914598f755b..bdcf1fda373 100644 --- a/OMCompiler/Compiler/NBackEnd/Classes/NBackendDAE.mo +++ b/OMCompiler/Compiler/NBackEnd/Classes/NBackendDAE.mo @@ -389,11 +389,11 @@ protected list vars; Pointer lowVar_ptr, time_ptr, dummy_ptr; list> unknowns_lst = {}, knowns_lst = {}, initials_lst = {}, auxiliaries_lst = {}, aliasVars_lst = {}, nonTrivialAlias_lst = {}; - list> states_lst = {}, derivatives_lst = {}, algebraics_lst = {}, discretes_lst = {}, previous_lst = {}; - list> parameters_lst = {}, constants_lst = {}, records_lst = {}, artificials_lst = {}; + list> states_lst = {}, derivatives_lst = {}, algebraics_lst = {}, discretes_lst = {}, discrete_states_lst = {}, previous_lst = {}; + list> inputs_lst = {}, parameters_lst = {}, constants_lst = {}, records_lst = {}, artificials_lst = {}; VariablePointers variables, unknowns, knowns, initials, auxiliaries, aliasVars, nonTrivialAlias; - VariablePointers states, derivatives, algebraics, discretes, previous; - VariablePointers parameters, constants, records, artificials; + VariablePointers states, derivatives, algebraics, discretes, discrete_states, previous; + VariablePointers inputs, parameters, constants, records, artificials; Pointer>> binding_iter_lst = Pointer.create({}); Boolean scalarized = Flags.isSet(Flags.NF_SCALARIZE); algorithm @@ -417,13 +417,8 @@ protected variables := VariablePointers.add(lowVar_ptr, variables); () := match lowVar.backendinfo.varKind - case BackendExtension.ALGEBRAIC() guard(Variable.isTopLevelInput(var)) algorithm - algebraics_lst := lowVar_ptr :: algebraics_lst; - knowns_lst := lowVar_ptr :: knowns_lst; - then (); - - case BackendExtension.DISCRETE() guard(Variable.isTopLevelInput(var)) algorithm - discretes_lst := lowVar_ptr :: discretes_lst; + case _ guard(Variable.isTopLevelInput(var)) algorithm + inputs_lst := lowVar_ptr :: inputs_lst; knowns_lst := lowVar_ptr :: knowns_lst; then (); @@ -492,8 +487,10 @@ protected derivatives := VariablePointers.fromList(derivatives_lst, scalarized); algebraics := VariablePointers.fromList(algebraics_lst, scalarized); discretes := VariablePointers.fromList(discretes_lst, scalarized); + discrete_states := VariablePointers.fromList(discrete_states_lst, scalarized); previous := VariablePointers.fromList(previous_lst, scalarized); + inputs := VariablePointers.fromList(inputs_lst, scalarized); parameters := VariablePointers.fromList(parameters_lst, scalarized); constants := VariablePointers.fromList(constants_lst, scalarized); records := VariablePointers.fromList(records_lst, scalarized); @@ -511,7 +508,7 @@ protected /* create variable data */ variableData := BVariable.VAR_DATA_SIM(variables, unknowns, knowns, initials, auxiliaries, aliasVars, nonTrivialAlias, - derivatives, algebraics, discretes, previous, states, parameters, constants, records, artificials); + derivatives, algebraics, discretes, discrete_states, previous, states, inputs, parameters, constants, records, artificials); end lowerVariableData; function lowerVariable @@ -531,7 +528,7 @@ protected var.backendinfo := match var.backendinfo case BackendExtension.BACKEND_INFO(varKind = BackendExtension.FRONTEND_DUMMY()) algorithm (varKind, attributes) := lowerVariableKind(Variable.variability(var), attributes, var.ty); - then BackendExtension.BACKEND_INFO(varKind, attributes, annotations); + then BackendExtension.BACKEND_INFO(varKind, attributes, annotations, NONE()); else BackendExtension.BackendInfo.setAttributes(var.backendinfo, attributes, annotations); end match; @@ -1294,9 +1291,9 @@ public // collect variable info states := intString(VariablePointers.scalarSize(varData.states)) + " (" + intString(VariablePointers.size(varData.states)) + ")"; discretes := intString(VariablePointers.scalarSize(varData.discretes)) + " (" + intString(VariablePointers.size(varData.discretes)) + ")"; - discrete_states := intString(VariablePointers.scalarSize(varData.previous)) + " (" + intString(VariablePointers.size(varData.previous)) + ")"; + discrete_states := intString(VariablePointers.scalarSize(varData.discrete_states)) + " (" + intString(VariablePointers.size(varData.discrete_states)) + ")"; clocked_states := "0 (0)"; - inputs := "0 (0)"; + inputs := intString(VariablePointers.scalarSize(varData.top_level_inputs)) + " (" + intString(VariablePointers.size(varData.top_level_inputs)) + ")"; if Flags.isSet(Flags.DUMP_STATESELECTION_INFO) then states := states + " " + List.toString(VariablePointers.toList(varData.states), BVariable.nameString); @@ -1306,12 +1303,18 @@ public if Flags.isSet(Flags.DUMP_DISCRETEVARS_INFO) then discretes := discretes + " " + List.toString(VariablePointers.toList(varData.discretes), BVariable.nameString); - discrete_states := discrete_states + " {NOT YET AVAILABLE}"; - clocked_states := clocked_states + " {NOT YET AVAILABLE}"; + inputs := inputs + " " + List.toString(VariablePointers.toList(varData.top_level_inputs), BVariable.nameString); else discretes := discretes + " ('-d=discreteinfo' for list of discrete variables)"; - discrete_states := discrete_states + " ('-d=discreteinfo' for list of discrete states)"; - clocked_states := clocked_states + " ('-d=discreteinfo' for list of clocked states)"; + inputs := inputs + " ('-d=discreteinfo' for list of top level inputs)"; + end if; + + if Flags.isSet(Flags.DUMP_STATESELECTION_INFO) or Flags.isSet(Flags.DUMP_DISCRETEVARS_INFO) then + discrete_states := discrete_states + " " + List.toString(VariablePointers.toList(varData.discrete_states), BVariable.nameString); + clocked_states := clocked_states + " {NOT YET AVAILABLE}"; + else + discrete_states := discrete_states + " ('-d=discreteinfo' or '-d=stateselection' for list of discrete states)"; + clocked_states := clocked_states + " ('-d=discreteinfo' or '-d=stateselection' for list of clocked states)"; end if; Error.addCompilerNotification( @@ -1327,9 +1330,9 @@ public Error.addCompilerNotification( "Variable statistics after passing the back-end:\n" + "* Number of states: ............................. " + states + "\n" - + "* Number of discrete variables: ................. " + discretes + "\n" + "* Number of discrete states: .................... " + discrete_states + "\n" + "* Number of clocked states: ..................... " + clocked_states + "\n" + + "* Number of discrete variables: ................. " + discretes + "\n" + "* Number of top-level inputs: ................... " + inputs); // collect strong component info simulation diff --git a/OMCompiler/Compiler/NBackEnd/Modules/1_Main/NBAdjacency.mo b/OMCompiler/Compiler/NBackEnd/Modules/1_Main/NBAdjacency.mo index fed92471386..108bfc5e736 100644 --- a/OMCompiler/Compiler/NBackEnd/Modules/1_Main/NBAdjacency.mo +++ b/OMCompiler/Compiler/NBackEnd/Modules/1_Main/NBAdjacency.mo @@ -415,8 +415,8 @@ public end match; else Error.addMessage(Error.INTERNAL_ERROR,{getInstanceName() + " failed to create adjacency matrix for system:\n" - + VariablePointers.toString(vars, "system vars") + "\n" - + EquationPointers.toString(eqns, "system eqns")}); + + VariablePointers.toString(vars, "System") + "\n" + + EquationPointers.toString(eqns, "System")}); fail(); end try; end create; diff --git a/OMCompiler/Compiler/NBackEnd/Modules/1_Main/NBInitialization.mo b/OMCompiler/Compiler/NBackEnd/Modules/1_Main/NBInitialization.mo index cf3cf9f054d..cfa9c5e6c88 100644 --- a/OMCompiler/Compiler/NBackEnd/Modules/1_Main/NBInitialization.mo +++ b/OMCompiler/Compiler/NBackEnd/Modules/1_Main/NBInitialization.mo @@ -88,7 +88,8 @@ public algorithm // create the equations from fixed variables. (variables, equations, initialEqs) := createStartEquations(varData.states, variables, equations, initialEqs, eqData.uniqueIndex, "State"); - (variables, equations, initialEqs) := createStartEquations(varData.discretes, variables, equations, initialEqs, eqData.uniqueIndex, "Discrete State"); + (variables, equations, initialEqs) := createStartEquations(varData.discretes, variables, equations, initialEqs, eqData.uniqueIndex, "Discretes"); + (variables, equations, initialEqs) := createStartEquations(varData.discrete_states, variables, equations, initialEqs, eqData.uniqueIndex, "Discrete States"); (equations, initialEqs, initialVars) := createParameterEquations(varData.parameters, equations, initialEqs, initialVars, eqData.uniqueIndex); varData.variables := variables; @@ -211,19 +212,20 @@ public output Pointer start_var; output ComponentRef start_name; protected + Option> pre_post = BVariable.getPrePost(var_ptr); Pointer disc_state_var; ComponentRef merged_name; algorithm - if BVariable.isDiscreteState(var_ptr) then - // for discrete states change the lhs cref to the $PRE cref - merged_name := ComponentRef.mergeSubscripts(subscripts, name, true, true); - name := BVariable.getPreCref(name); - name := ComponentRef.mergeSubscripts(subscripts, name, true, true); - var_ptr := BVariable.getVarPointer(name); - elseif BVariable.isPrevious(var_ptr) then + if BVariable.isPrevious(var_ptr) and Util.isSome(pre_post) then // for previous change the rhs to the start value of the discrete state - merged_name := BVariable.getDiscreteStateCref(name); + merged_name := BVariable.getVarName(Util.getOption(pre_post)); merged_name := ComponentRef.mergeSubscripts(subscripts, merged_name, true, true); + elseif Util.isSome(pre_post) then + // for vars with previous change the lhs cref to the $PRE cref + merged_name := ComponentRef.mergeSubscripts(subscripts, name, true, true); + var_ptr := Util.getOption(pre_post); + name := BVariable.getVarName(var_ptr); + name := ComponentRef.mergeSubscripts(subscripts, name, true, true); else // just apply subscripts and make start var name := ComponentRef.mergeSubscripts(subscripts, name, true, true); @@ -334,34 +336,33 @@ public function createPreEquation "creates d = $PRE.d equations" - input Pointer disc_state; + input Pointer var_ptr; input Pointer>> ptr_pre_eqs; input Pointer idx; + protected + Option> pre; + Pointer pre_eq; + EquationKind kind; algorithm - () := match Pointer.access(disc_state) - local - Pointer previous; - Pointer pre_eq; - EquationKind kind; - - case Variable.VARIABLE(backendinfo = BackendExtension.BACKEND_INFO(varKind = BackendExtension.VariableKind.DISCRETE_STATE(previous = previous))) - algorithm - kind := if BVariable.isContinuous(disc_state) then EquationKind.CONTINUOUS else EquationKind.DISCRETE; - pre_eq := Equation.makeAssignment(BVariable.getVarName(disc_state), Expression.fromCref(BVariable.getVarName(previous)), idx, NBEquation.PRE_STR, Iterator.EMPTY(), EquationAttributes.default(kind, true)); - Pointer.update(ptr_pre_eqs, pre_eq :: Pointer.access(ptr_pre_eqs)); - then (); - else (); - end match; + if not BVariable.isPrevious(var_ptr) then + pre := BVariable.getPrePost(var_ptr); + if Util.isSome(pre) then + kind := if BVariable.isContinuous(var_ptr) then EquationKind.CONTINUOUS else EquationKind.DISCRETE; + pre_eq := Equation.makeAssignment(BVariable.getVarName(var_ptr), Expression.fromCref(BVariable.getVarName(Util.getOption(pre))), idx, NBEquation.PRE_STR, Iterator.EMPTY(), EquationAttributes.default(kind, true)); + Pointer.update(ptr_pre_eqs, pre_eq :: Pointer.access(ptr_pre_eqs)); + end if; + end if; end createPreEquation; function createPreEquationSlice "creates a pre equation for a sliced variable. usually results in a for equation, but might be scalarized if that is not possible." - input Slice disc_state; + input Slice var_slice; input Pointer>> ptr_pre_eqs; input Pointer idx; protected Pointer var_ptr; + Option> pre; ComponentRef name, pre_name; list dims; list iterators; @@ -371,24 +372,29 @@ public Pointer pre_eq; EquationKind kind; algorithm - var_ptr := Slice.getT(disc_state); - name := BVariable.getVarName(var_ptr); - dims := Type.arrayDims(ComponentRef.nodeType(name)); - (iterators, ranges, subscripts) := Flatten.makeIterators(name, dims); - frames := List.zip(list(ComponentRef.makeIterator(iter, Type.INTEGER()) for iter in iterators), ranges); - - pre_name := BVariable.getPreCref(name); - pre_name := ComponentRef.mergeSubscripts(subscripts, pre_name, true, true); - name := ComponentRef.mergeSubscripts(subscripts, name, true, true); - - kind := if BVariable.isContinuous(var_ptr) then EquationKind.CONTINUOUS else EquationKind.DISCRETE; - pre_eq := Equation.makeAssignment(name, Expression.fromCref(pre_name), idx, NBEquation.PRE_STR, Iterator.fromFrames(frames), EquationAttributes.default(kind, true)); - - if not listEmpty(disc_state.indices) then - // empty list indicates full array, slice otherwise - (pre_eq, _, _) := Equation.slice(pre_eq, disc_state.indices, NONE(), FunctionTreeImpl.EMPTY()); + var_ptr := Slice.getT(var_slice); + if not BVariable.isPrevious(var_ptr) then + pre := BVariable.getPrePost(var_ptr); + if Util.isSome(pre) then + name := BVariable.getVarName(var_ptr); + dims := Type.arrayDims(ComponentRef.nodeType(name)); + (iterators, ranges, subscripts) := Flatten.makeIterators(name, dims); + frames := List.zip(list(ComponentRef.makeIterator(iter, Type.INTEGER()) for iter in iterators), ranges); + + pre_name := BVariable.getVarName(Util.getOption(pre)); + pre_name := ComponentRef.mergeSubscripts(subscripts, pre_name, true, true); + name := ComponentRef.mergeSubscripts(subscripts, name, true, true); + + kind := if BVariable.isContinuous(var_ptr) then EquationKind.CONTINUOUS else EquationKind.DISCRETE; + pre_eq := Equation.makeAssignment(name, Expression.fromCref(pre_name), idx, NBEquation.PRE_STR, Iterator.fromFrames(frames), EquationAttributes.default(kind, true)); + + if not listEmpty(var_slice.indices) then + // empty list indicates full array, slice otherwise + (pre_eq, _, _) := Equation.slice(pre_eq, var_slice.indices, NONE(), FunctionTreeImpl.EMPTY()); + end if; + Pointer.update(ptr_pre_eqs, pre_eq :: Pointer.access(ptr_pre_eqs)); + end if; end if; - Pointer.update(ptr_pre_eqs, pre_eq :: Pointer.access(ptr_pre_eqs)); end createPreEquationSlice; function cleanup diff --git a/OMCompiler/Compiler/NBackEnd/Modules/1_Main/NBPartitioning.mo b/OMCompiler/Compiler/NBackEnd/Modules/1_Main/NBPartitioning.mo index f8079192187..b2ec6c70854 100644 --- a/OMCompiler/Compiler/NBackEnd/Modules/1_Main/NBPartitioning.mo +++ b/OMCompiler/Compiler/NBackEnd/Modules/1_Main/NBPartitioning.mo @@ -447,7 +447,7 @@ protected if BVariable.isState(var_ptr) then UnorderedSet.add(BVariable.getDerCref(cref), set); elseif BVariable.isPrevious(var_ptr) then - UnorderedSet.add(BVariable.getStateCref(cref), set); + UnorderedSet.add(BVariable.getPrePostCref(cref), set); else UnorderedSet.add(cref, set); end if; diff --git a/OMCompiler/Compiler/NBackEnd/Modules/1_Main/NBResolveSingularities.mo b/OMCompiler/Compiler/NBackEnd/Modules/1_Main/NBResolveSingularities.mo index 2f04928cfd5..5d97a6a2ca7 100644 --- a/OMCompiler/Compiler/NBackEnd/Modules/1_Main/NBResolveSingularities.mo +++ b/OMCompiler/Compiler/NBackEnd/Modules/1_Main/NBResolveSingularities.mo @@ -327,8 +327,8 @@ public for var in unmatched_vars loop var_ptr := Slice.getT(var); if BVariable.isFixable(var_ptr) then - if BVariable.isDiscreteState(var_ptr) then - // create previous equations for discrete states + if BVariable.hasPre(var_ptr) then + // create previous equations // d = $PRE.d Initialization.createPreEquationSlice(var, ptr_start_eqns, idx); else diff --git a/OMCompiler/Compiler/NBackEnd/Modules/2_Pre/NBDetectStates.mo b/OMCompiler/Compiler/NBackEnd/Modules/2_Pre/NBDetectStates.mo index eeb8c6548e7..462c78c5c6e 100644 --- a/OMCompiler/Compiler/NBackEnd/Modules/2_Pre/NBDetectStates.mo +++ b/OMCompiler/Compiler/NBackEnd/Modules/2_Pre/NBDetectStates.mo @@ -125,32 +125,35 @@ protected VariablePointers derivatives "State derivatives (der(x) -> $DER.x)"; VariablePointers algebraics "Algebraic variables"; VariablePointers discretes "Discrete variables"; + VariablePointers discrete_states"Discrete state variables"; VariablePointers previous "Previous discrete variables (pre(d) -> $PRE.d)"; - VariablePointers auxiliaries, aliasVars, nonTrivialAlias, parameters, constants, records, artificials "(only to reconstruct VAR_DATA_SIM)"; + VariablePointers auxiliaries, aliasVars, nonTrivialAlias, top_level_inputs, parameters, constants, records, artificials "(only to reconstruct VAR_DATA_SIM)"; list> aux_eqns; algorithm - BVariable.VAR_DATA_SIM(variables = variables, unknowns = unknowns, knowns = knowns, initials = initials, auxiliaries = auxiliaries, aliasVars = aliasVars, nonTrivialAlias = nonTrivialAlias, states = states, derivatives = derivatives, algebraics = algebraics, discretes = discretes, previous = previous, parameters = parameters, constants = constants, records = records, artificials = artificials) := varData; + BVariable.VAR_DATA_SIM(variables = variables, unknowns = unknowns, knowns = knowns, initials = initials, auxiliaries = auxiliaries, aliasVars = aliasVars, nonTrivialAlias = nonTrivialAlias, states = states, derivatives = derivatives, algebraics = algebraics, discretes = discretes, discrete_states = discrete_states, previous = previous, top_level_inputs = top_level_inputs, parameters = parameters, constants = constants, records = records, artificials = artificials) := varData; BEquation.EQ_DATA_SIM(equations = equations, discretes = disc_eqns, initials = init_eqns) := eqData; (variables, unknowns, knowns, initials, states, derivatives, algebraics, aux_eqns) := continuousFunc(variables, unknowns, knowns, initials, states, derivatives, algebraics, equations); - (variables, disc_eqns, knowns, initials, discretes, previous) := discreteFunc(variables, disc_eqns, knowns, initials, discretes, previous, "discrete equations"); - (variables, init_eqns, knowns, initials, discretes, previous) := discreteFunc(variables, init_eqns, knowns, initials, discretes, previous, "initial equations"); + (variables, disc_eqns, knowns, initials, discretes, discrete_states, previous) := discreteFunc(variables, disc_eqns, knowns, initials, discretes, discrete_states, previous, "discrete equations"); + (variables, init_eqns, knowns, initials, discretes, discrete_states, previous) := discreteFunc(variables, init_eqns, knowns, initials, discretes, discrete_states, previous, "initial equations"); varData := BVariable.VAR_DATA_SIM( - variables = variables, - unknowns = unknowns, - knowns = knowns, - initials = initials, - auxiliaries = auxiliaries, - aliasVars = aliasVars, - nonTrivialAlias = nonTrivialAlias, - derivatives = derivatives, - algebraics = algebraics, - discretes = discretes, - previous = previous, - states = states, - parameters = parameters, - constants = constants, - records = records, - artificials = artificials + variables = variables, + unknowns = unknowns, + knowns = knowns, + initials = initials, + auxiliaries = auxiliaries, + aliasVars = aliasVars, + nonTrivialAlias = nonTrivialAlias, + derivatives = derivatives, + algebraics = algebraics, + discretes = discretes, + discrete_states = discrete_states, + previous = previous, + states = states, + top_level_inputs = top_level_inputs, + parameters = parameters, + constants = constants, + records = records, + artificials = artificials ); eqData := EqData.addTypedList(eqData, aux_eqns, EqData.EqType.CONTINUOUS, false); end detectStatesDefault; @@ -182,12 +185,12 @@ protected Pointer>> acc_discrete_states = Pointer.create({}); Pointer>> acc_previous = Pointer.create({}); algorithm - // collect all 'natural' states on the lhs of a when - EquationPointers.map(equations, function collectDiscreteStatesFromWhen(acc_discrete_states = acc_discrete_states, acc_previous = acc_previous, scalarized = variables.scalarized)); - // collect all 'natural' states from pre(d) - EquationPointers.mapExp(equations, function collectDiscreteStatesAndPrevious(acc_discrete_states = acc_discrete_states, acc_previous = acc_previous, scalarized = variables.scalarized)); + // collect all states on the lhs of a when + EquationPointers.map(equations, function collectDiscreteStatesFromWhen(acc_discrete_states = acc_discrete_states, scalarized = variables.scalarized)); + // collect all pre(d) + EquationPointers.mapExp(equations, function collectPreAndPrevious(acc_previous = acc_previous, scalarized = variables.scalarized)); // move stuff to their correct arrays - (variables, knowns, initials, discretes, previous) := updateDiscreteStatesAndPrevious(variables, knowns, initials, discretes, previous, Pointer.access(acc_discrete_states), Pointer.access(acc_previous), context); + (variables, knowns, initials, discretes, discrete_states, previous) := updateDiscreteStatesAndPrevious(variables, knowns, initials, discretes, discrete_states, previous, Pointer.access(acc_discrete_states), Pointer.access(acc_previous), context); end detectDiscreteStatesDefault; function collectStatesAndDerivatives @@ -328,10 +331,9 @@ protected end if; end updateStatesAndDerivatives; - function collectDiscreteStatesAndPrevious - "Collects all discrete states and creates a previous variable for each. Only to be used on discrete equations!" + function collectPreAndPrevious + "Collects all pre and previous variables. Only to be used on discrete equations!" input output Expression exp; - input Pointer>> acc_discrete_states; input Pointer>> acc_previous; input Boolean scalarized; algorithm @@ -344,13 +346,13 @@ protected arguments = {Expression.CREF(cref = state_cref)})) algorithm state_var := BVariable.getVarPointer(state_cref); - pre_cref := getPreVar(state_cref, state_var, acc_discrete_states, acc_previous, scalarized); + pre_cref := getPreVar(state_cref, state_var, acc_previous, scalarized); then Expression.fromCref(pre_cref); // ToDo! General expressions inside pre call! // ToDo! edge and change replacement! else exp; end match; - end collectDiscreteStatesAndPrevious; + end collectPreAndPrevious; function updateDiscreteStatesAndPrevious "Updates the variable pointer arrays with the new information about states and derivatives." @@ -358,6 +360,7 @@ protected input output VariablePointers knowns "Knowns"; input output VariablePointers initials "initial unknowns"; input output VariablePointers discretes "Discrete variables"; + input output VariablePointers discrete_states "Discrete state variables"; input output VariablePointers previous "Previous (left limit) variables"; input list> acc_discrete_states; input list> acc_previous; @@ -368,6 +371,9 @@ protected knowns := VariablePointers.addList(acc_previous, knowns); initials := VariablePointers.addList(acc_previous, initials); previous := VariablePointers.addList(acc_previous, previous); + discrete_states := VariablePointers.addList(acc_discrete_states, discrete_states); + // also remove discrete states from discretes + discretes := VariablePointers.removeList(acc_discrete_states, discretes); if Flags.isSet(Flags.DUMP_STATESELECTION_INFO) then print(StringUtil.headline_4("[stateselection] Natural discrete states from " + context + ":")); @@ -383,12 +389,11 @@ protected "All variables on the LHS in a when equation are considered discrete." input output Equation eqn "outputs equation just to fit the map() interface. does not change."; input Pointer>> acc_discrete_states; - input Pointer>> acc_previous; input Boolean scalarized; algorithm () := match eqn case Equation.WHEN_EQUATION() algorithm - collectDiscreteStatesFromWhenBody(eqn.body, acc_discrete_states, acc_previous, scalarized); + collectDiscreteStatesFromWhenBody(eqn.body, acc_discrete_states, scalarized); then (); else (); end match; @@ -398,7 +403,6 @@ protected "All variables on the LHS in a when equation are considered discrete." input WhenEquationBody body; input Pointer>> acc_discrete_states; - input Pointer>> acc_previous; input Boolean scalarized; algorithm for body_stmt in body.when_stmts loop @@ -411,7 +415,8 @@ protected // the function getPreVar() does all necessary collecting of information // but we don't need the actual pre cref it returns state_var := BVariable.getVarPointer(state_cref); - pre_cref := getPreVar(state_cref, state_var, acc_discrete_states, acc_previous, scalarized); + BVariable.makeDiscreteStateVar(state_var); + Pointer.update(acc_discrete_states, state_var :: Pointer.access(acc_discrete_states)); then (); else (); @@ -419,36 +424,31 @@ protected end for; if Util.isSome(body.else_when) then - collectDiscreteStatesFromWhenBody(Util.getOption(body.else_when), acc_discrete_states, acc_previous, scalarized); + collectDiscreteStatesFromWhenBody(Util.getOption(body.else_when), acc_discrete_states, scalarized); end if; end collectDiscreteStatesFromWhenBody; function getPreVar - input ComponentRef state_cref; - input Pointer state_var; - input Pointer>> acc_discrete_states; + input ComponentRef var_cref; + input Pointer var_ptr; input Pointer>> acc_previous; input Boolean scalarized; output ComponentRef pre_cref; protected + Option> pre = BVariable.getPrePost(var_ptr); Pointer pre_var; algorithm - if BVariable.isDiscreteState(state_var) then - // this previous was already created -> the variable should already have a pointer to its previous variable - pre_cref := BVariable.getPreCref(state_cref); - if not scalarized then - pre_cref := ComponentRef.setSubscriptsList(listReverse(ComponentRef.subscriptsAll(state_cref)), pre_cref); - end if; + if Util.isSome(pre) then + SOME(pre_var) := pre; + pre_cref := BVariable.getVarName(pre_var); else if not scalarized then - // prevent the variable from having the subscripts, but add it to the pre_cref - (pre_cref, pre_var) := BVariable.makePreVar(ComponentRef.stripSubscriptsAll(state_cref)); - pre_cref := ComponentRef.setSubscriptsList(listReverse(ComponentRef.subscriptsAll(state_cref)), pre_cref); + // prevent the created pre variable from having the subscripts, but add it to the pre_cref + (pre_cref, pre_var) := BVariable.makePreVar(ComponentRef.stripSubscriptsAll(var_cref)); + pre_cref := ComponentRef.setSubscriptsList(listReverse(ComponentRef.subscriptsAll(var_cref)), pre_cref); else - (pre_cref, pre_var) := BVariable.makePreVar(state_cref); + (pre_cref, pre_var) := BVariable.makePreVar(var_cref); end if; - BVariable.makeDiscreteStateVar(state_var, pre_var); - Pointer.update(acc_discrete_states, state_var :: Pointer.access(acc_discrete_states)); Pointer.update(acc_previous, pre_var :: Pointer.access(acc_previous)); end if; end getPreVar; diff --git a/OMCompiler/Compiler/NBackEnd/Modules/3_Post/NBJacobian.mo b/OMCompiler/Compiler/NBackEnd/Modules/3_Post/NBJacobian.mo index daa19598959..6fe92b94acc 100644 --- a/OMCompiler/Compiler/NBackEnd/Modules/3_Post/NBJacobian.mo +++ b/OMCompiler/Compiler/NBackEnd/Modules/3_Post/NBJacobian.mo @@ -676,6 +676,7 @@ protected derivative_vars := list(var for var guard(BVariable.isStateDerivative(var)) in VariablePointers.toList(syst.unknowns)); state_vars := list(BVariable.getStateVar(var) for var in derivative_vars); seedCandidates := VariablePointers.fromList(state_vars, partialCandidates.scalarized); + (jacobian, funcTree) := func(name, JacobianType.ODE, seedCandidates, partialCandidates, syst.equations, knowns, syst.strongComponents, funcTree); syst.jacobian := jacobian; if Flags.isSet(Flags.JAC_DUMP) then diff --git a/OMCompiler/Compiler/NBackEnd/Modules/NBModule.mo b/OMCompiler/Compiler/NBackEnd/Modules/NBModule.mo index 65f99227154..9297518db15 100644 --- a/OMCompiler/Compiler/NBackEnd/Modules/NBModule.mo +++ b/OMCompiler/Compiler/NBackEnd/Modules/NBModule.mo @@ -200,13 +200,14 @@ public "DetectDiscreteStates This function is only allowed to read and change equations, change algebraic variables to discrete and create previous discrete variables." - input output VariablePointers variables "All variables"; - input output EquationPointers equations "ONLY discrete or initial equations!"; - input output VariablePointers knowns "Knowns"; - input output VariablePointers initials "Initial unknowns"; - input output VariablePointers discretes "Discrete variables"; - input output VariablePointers previous "Previous discrete variables (pre(d) -> $PRE.d)"; - input String context "only for debugging"; + input output VariablePointers variables "All variables"; + input output EquationPointers equations "ONLY discrete or initial equations!"; + input output VariablePointers knowns "Knowns"; + input output VariablePointers initials "Initial unknowns"; + input output VariablePointers discretes "Discrete variables"; + input output VariablePointers discrete_states "Discrete variables"; + input output VariablePointers previous "Previous discrete variables (pre(d) -> $PRE.d)"; + input String context "only for debugging"; end detectDiscreteStatesInterface; // ========================================================================= diff --git a/OMCompiler/Compiler/NFFrontEnd/NFBackendExtension.mo b/OMCompiler/Compiler/NFFrontEnd/NFBackendExtension.mo index 068435d8bc9..1be6aed22a1 100644 --- a/OMCompiler/Compiler/NFFrontEnd/NFBackendExtension.mo +++ b/OMCompiler/Compiler/NFFrontEnd/NFBackendExtension.mo @@ -66,9 +66,10 @@ protected public uniontype BackendInfo record BACKEND_INFO - VariableKind varKind "Structural kind: state, algebraic..."; - VariableAttributes attributes "values on built-in attributes"; - Annotations annotations "values on annotations (vendor specific)"; + VariableKind varKind "Structural kind: state, algebraic..."; + VariableAttributes attributes "values on built-in attributes"; + Annotations annotations "values on annotations (vendor specific)"; + Option> pre_post "Pointer (var->pre) or (pre-> var) if existent."; end BACKEND_INFO; function toString @@ -101,6 +102,13 @@ public binfo.varKind := varKind; end setVarKind; + function setPrePost + input output BackendInfo binfo; + input Option> pre_post; + algorithm + binfo.pre_post := pre_post; + end setPrePost; + function setAttributes input output BackendInfo binfo; input VariableAttributes attributes; @@ -136,12 +144,12 @@ public case VariableKind.FRONTEND_DUMMY() then List.fill(binfo, length); else algorithm scalar_attributes := VariableAttributes.scalarize(binfo.attributes, length); - then list(BACKEND_INFO(binfo.varKind, attr, binfo.annotations) for attr in scalar_attributes); + then list(BACKEND_INFO(binfo.varKind, attr, binfo.annotations, binfo.pre_post) for attr in scalar_attributes); end match; end scalarize; end BackendInfo; - constant BackendInfo DUMMY_BACKEND_INFO = BACKEND_INFO(FRONTEND_DUMMY(), EMPTY_VAR_ATTR_REAL, EMPTY_ANNOTATIONS); + constant BackendInfo DUMMY_BACKEND_INFO = BACKEND_INFO(FRONTEND_DUMMY(), EMPTY_VAR_ATTR_REAL, EMPTY_ANNOTATIONS, NONE()); uniontype VariableKind record TIME end TIME; @@ -160,15 +168,12 @@ public end DUMMY_DER; record DUMMY_STATE Pointer dummy_der "corresponding dummy derivative"; - end DUMMY_STATE; // ToDo: maybe dynamic state for dynamic state seleciton in index reduction + end DUMMY_STATE; // ToDo: maybe dynamic state for dynamic state selection in index reduction record DISCRETE end DISCRETE; record DISCRETE_STATE - Pointer previous "Pointer to the left limit if existant."; Boolean fixed "is fixed at first clock tick"; end DISCRETE_STATE; - record PREVIOUS - Pointer state "Pointer to the corresponding discrete state."; - end PREVIOUS; + record PREVIOUS end PREVIOUS; record PARAMETER end PARAMETER; record CONSTANT end CONSTANT; record ITERATOR end ITERATOR; diff --git a/OMCompiler/Compiler/NFFrontEnd/NFVariable.mo b/OMCompiler/Compiler/NFFrontEnd/NFVariable.mo index 94bc46f0d56..4e543c2c334 100644 --- a/OMCompiler/Compiler/NFFrontEnd/NFVariable.mo +++ b/OMCompiler/Compiler/NFFrontEnd/NFVariable.mo @@ -79,6 +79,7 @@ public Attributes attr; Option cmt; SourceInfo info; + BackendExtension.BackendInfo binfo = NFBackendExtension.DUMMY_BACKEND_INFO; algorithm node := ComponentRef.node(cref); comp := InstNode.component(node); @@ -91,11 +92,11 @@ public // conversion to backend process (except for iterators). NBackendDAE.lower if ComponentRef.isIterator(cref) then binding := NFBinding.EMPTY_BINDING; - variable := VARIABLE(cref, ty, binding, vis, attr, {}, {}, cmt, info, BackendExtension.BACKEND_INFO(BackendExtension.ITERATOR(), NFBackendExtension.EMPTY_VAR_ATTR_REAL, NFBackendExtension.EMPTY_ANNOTATIONS)); + binfo.varKind := BackendExtension.ITERATOR(); else binding := Component.getImplicitBinding(comp); - variable := VARIABLE(cref, ty, binding, vis, attr, {}, {}, cmt, info, NFBackendExtension.DUMMY_BACKEND_INFO); end if; + variable := VARIABLE(cref, ty, binding, vis, attr, {}, {}, cmt, info, binfo); end fromCref; function size diff --git a/OMCompiler/Compiler/NSimCode/NSimVar.mo b/OMCompiler/Compiler/NSimCode/NSimVar.mo index 419615a69cd..af6546d9d36 100644 --- a/OMCompiler/Compiler/NSimCode/NSimVar.mo +++ b/OMCompiler/Compiler/NSimCode/NSimVar.mo @@ -469,11 +469,7 @@ public case BackendExtension.DUMMY_DER() then OldBackendDAE.DUMMY_DER(); case BackendExtension.DUMMY_STATE() then OldBackendDAE.DUMMY_STATE(); case BackendExtension.DISCRETE() then OldBackendDAE.DISCRETE(); - case qual as BackendExtension.DISCRETE_STATE() - algorithm - var := Pointer.access(qual.previous); - oldCref := ComponentRef.toDAE(var.name); - then OldBackendDAE.CLOCKED_STATE(oldCref, qual.fixed); + case BackendExtension.DISCRETE_STATE() then OldBackendDAE.DISCRETE(); // we dont differ between discrete states and discretes in the old backend. is this correct? case BackendExtension.PREVIOUS() then OldBackendDAE.DISCRETE(); case BackendExtension.PARAMETER() then OldBackendDAE.PARAM(); case BackendExtension.CONSTANT() then OldBackendDAE.CONST(); @@ -739,6 +735,7 @@ public protected list stateVars = {}, derivativeVars = {}, algVars = {}, nonTrivialAlias = {}; list discreteAlgVars = {}, intAlgVars = {}, boolAlgVars = {}, stringAlgVars = {}; + list discreteAlgVars2 = {}, intAlgVars2 = {}, boolAlgVars2 = {}, stringAlgVars2 = {}; list inputVars = {}; list outputVars = {}; list aliasVars = {}, intAliasVars = {}, boolAliasVars = {}, stringAliasVars = {}; @@ -761,15 +758,17 @@ public case qual as BVariable.VAR_DATA_SIM() algorithm - ({stateVars}, simCodeIndices) := createSimVarLists(qual.states, simCodeIndices, SplitType.NONE, VarType.SIMULATION); - ({derivativeVars}, simCodeIndices) := createSimVarLists(qual.derivatives, simCodeIndices, SplitType.NONE, VarType.SIMULATION); - ({algVars}, simCodeIndices) := createSimVarLists(qual.algebraics, simCodeIndices, SplitType.NONE, VarType.SIMULATION); - ({nonTrivialAlias}, simCodeIndices) := createSimVarLists(qual.nonTrivialAlias, simCodeIndices, SplitType.NONE, VarType.SIMULATION); - ({discreteAlgVars, intAlgVars, boolAlgVars, stringAlgVars}, simCodeIndices) := createSimVarLists(qual.discretes, simCodeIndices, SplitType.TYPE, VarType.SIMULATION); - ({aliasVars, intAliasVars, boolAliasVars, stringAliasVars}, simCodeIndices) := createSimVarLists(qual.aliasVars, simCodeIndices, SplitType.TYPE, VarType.ALIAS); - ({paramVars, intParamVars, boolParamVars, stringParamVars}, simCodeIndices) := createSimVarLists(qual.parameters, simCodeIndices, SplitType.TYPE, VarType.PARAMETER); - ({constVars, intConstVars, boolConstVars, stringConstVars}, simCodeIndices) := createSimVarLists(qual.constants, simCodeIndices, SplitType.TYPE, VarType.SIMULATION); - ({residualVars}, simCodeIndices) := createSimVarLists(residual_vars, simCodeIndices, SplitType.NONE, VarType.RESIDUAL); + ({stateVars}, simCodeIndices) := createSimVarLists(qual.states, simCodeIndices, SplitType.NONE, VarType.SIMULATION); + ({derivativeVars}, simCodeIndices) := createSimVarLists(qual.derivatives, simCodeIndices, SplitType.NONE, VarType.SIMULATION); + ({algVars}, simCodeIndices) := createSimVarLists(qual.algebraics, simCodeIndices, SplitType.NONE, VarType.SIMULATION); + ({nonTrivialAlias}, simCodeIndices) := createSimVarLists(qual.nonTrivialAlias, simCodeIndices, SplitType.NONE, VarType.SIMULATION); + ({discreteAlgVars, intAlgVars, boolAlgVars, stringAlgVars}, simCodeIndices) := createSimVarLists(qual.discretes, simCodeIndices, SplitType.TYPE, VarType.SIMULATION); + ({discreteAlgVars2, intAlgVars2, boolAlgVars2, stringAlgVars2}, simCodeIndices) := createSimVarLists(qual.discrete_states, simCodeIndices, SplitType.TYPE, VarType.SIMULATION); + ({aliasVars, intAliasVars, boolAliasVars, stringAliasVars}, simCodeIndices) := createSimVarLists(qual.aliasVars, simCodeIndices, SplitType.TYPE, VarType.ALIAS); + ({paramVars, intParamVars, boolParamVars, stringParamVars}, simCodeIndices) := createSimVarLists(qual.parameters, simCodeIndices, SplitType.TYPE, VarType.PARAMETER); + ({constVars, intConstVars, boolConstVars, stringConstVars}, simCodeIndices) := createSimVarLists(qual.constants, simCodeIndices, SplitType.TYPE, VarType.SIMULATION); + ({inputVars}, simCodeIndices) := createSimVarLists(qual.top_level_inputs, simCodeIndices, SplitType.NONE, VarType.SIMULATION); + ({residualVars}, simCodeIndices) := createSimVarLists(residual_vars, simCodeIndices, SplitType.NONE, VarType.RESIDUAL); then (); case qual as BVariable.VAR_DATA_JAC() then (); @@ -784,9 +783,9 @@ public stateVars = stateVars, derivativeVars = derivativeVars, algVars = listAppend(algVars, nonTrivialAlias), - discreteAlgVars = discreteAlgVars, - intAlgVars = intAlgVars, - boolAlgVars = boolAlgVars, + discreteAlgVars = listAppend(discreteAlgVars, discreteAlgVars2), + intAlgVars = listAppend(intAlgVars, intAlgVars2), + boolAlgVars = listAppend(boolAlgVars, boolAlgVars2), inputVars = inputVars, outputVars = outputVars, aliasVars = aliasVars, @@ -795,7 +794,7 @@ public paramVars = paramVars, intParamVars = intParamVars, boolParamVars = boolParamVars, - stringAlgVars = stringAlgVars, + stringAlgVars = listAppend(stringAlgVars, stringAlgVars2), stringParamVars = stringParamVars, stringAliasVars = stringAliasVars, extObjVars = extObjVars, diff --git a/testsuite/simulation/modelica/NBackend/basics/partitioning.mos b/testsuite/simulation/modelica/NBackend/basics/partitioning.mos index 6cda8a2c6c2..9f9c20faa6e 100644 --- a/testsuite/simulation/modelica/NBackend/basics/partitioning.mos +++ b/testsuite/simulation/modelica/NBackend/basics/partitioning.mos @@ -136,44 +136,44 @@ simulate(partitioning); getErrorString(); // BLOCK 1: Single Strong Component (status = Solve.UNPROCESSED) // --------------------------------------------------------------- // ### Variable: -// Real x +// Real $FUN_2 // ### Equation: -// [SCAL] (1) x = $START.x ($RES_SIM_7) +// [SCAL] (1) $FUN_2 = sin(time) ($RES_$AUX_4) // // BLOCK 2: Single Strong Component (status = Solve.UNPROCESSED) // --------------------------------------------------------------- // ### Variable: -// Real y +// Real $DER.x // ### Equation: -// [SCAL] (1) y = x ^ 2.0 + a ($RES_SIM_1) +// [SCAL] (1) $DER.x = $FUN_2 ($RES_SIM_0) // // BLOCK 3: Single Strong Component (status = Solve.UNPROCESSED) // --------------------------------------------------------------- // ### Variable: -// Real k +// Real x // ### Equation: -// [SCAL] (1) k = cos(time) ($RES_$AUX_5) +// [SCAL] (1) x = $START.x ($RES_SIM_7) // // BLOCK 4: Single Strong Component (status = Solve.UNPROCESSED) // --------------------------------------------------------------- // ### Variable: -// Real z +// Real y // ### Equation: -// [SCAL] (1) z = a ^ 2.0 * k ($RES_SIM_2) +// [SCAL] (1) y = x ^ 2.0 + a ($RES_SIM_1) // // BLOCK 5: Single Strong Component (status = Solve.UNPROCESSED) // --------------------------------------------------------------- // ### Variable: -// Real $FUN_2 +// Real k // ### Equation: -// [SCAL] (1) $FUN_2 = sin(time) ($RES_$AUX_4) +// [SCAL] (1) k = cos(time) ($RES_$AUX_5) // // BLOCK 6: Single Strong Component (status = Solve.UNPROCESSED) // --------------------------------------------------------------- // ### Variable: -// Real $DER.x +// Real z // ### Equation: -// [SCAL] (1) $DER.x = $FUN_2 ($RES_SIM_0) +// [SCAL] (1) z = a ^ 2.0 * k ($RES_SIM_2) // // ############################################# // @@ -185,7 +185,7 @@ simulate(partitioning); getErrorString(); // CONTINUOUS 2 ODE System // =========================== // -// --- Alias of INI[1 | 2] --- +// --- Alias of INI[1 | 4] --- // BLOCK 1: Single Strong Component (status = Solve.EXPLICIT) // ------------------------------------------------------------ // ### Variable: @@ -193,7 +193,7 @@ simulate(partitioning); getErrorString(); // ### Equation: // [SCAL] (1) y = x ^ 2.0 + a ($RES_SIM_1) // -// --- Alias of INI[1 | 5] --- +// --- Alias of INI[1 | 1] --- // BLOCK 2: Single Strong Component (status = Solve.EXPLICIT) // ------------------------------------------------------------ // ### Variable: @@ -201,7 +201,7 @@ simulate(partitioning); getErrorString(); // ### Equation: // [SCAL] (1) $FUN_2 = sin(time) ($RES_$AUX_4) // -// --- Alias of INI[1 | 6] --- +// --- Alias of INI[1 | 2] --- // BLOCK 3: Single Strong Component (status = Solve.EXPLICIT) // ------------------------------------------------------------ // ### Variable: @@ -219,7 +219,7 @@ simulate(partitioning); getErrorString(); // CONTINUOUS 1 ALG System // =========================== // -// --- Alias of INI[1 | 3] --- +// --- Alias of INI[1 | 5] --- // BLOCK 1: Single Strong Component (status = Solve.EXPLICIT) // ------------------------------------------------------------ // ### Variable: @@ -227,7 +227,7 @@ simulate(partitioning); getErrorString(); // ### Equation: // [SCAL] (1) k = cos(time) ($RES_$AUX_5) // -// --- Alias of INI[1 | 4] --- +// --- Alias of INI[1 | 6] --- // BLOCK 2: Single Strong Component (status = Solve.EXPLICIT) // ------------------------------------------------------------ // ### Variable: @@ -248,48 +248,48 @@ simulate(partitioning); getErrorString(); // BLOCK 1: Single Strong Component (status = Solve.EXPLICIT) // ------------------------------------------------------------ // ### Variable: -// Real x +// Real $FUN_2 // ### Equation: -// [SCAL] (1) x = $START.x ($RES_SIM_7) +// [SCAL] (1) $FUN_2 = sin(time) ($RES_$AUX_4) // // BLOCK 2: Single Strong Component (status = Solve.EXPLICIT) // ------------------------------------------------------------ // ### Variable: -// Real y +// Real $DER.x // ### Equation: -// [SCAL] (1) y = x ^ 2.0 + a ($RES_SIM_1) +// [SCAL] (1) $DER.x = $FUN_2 ($RES_SIM_0) // // BLOCK 3: Single Strong Component (status = Solve.EXPLICIT) // ------------------------------------------------------------ // ### Variable: -// Real k +// Real x // ### Equation: -// [SCAL] (1) k = cos(time) ($RES_$AUX_5) +// [SCAL] (1) x = $START.x ($RES_SIM_7) // // BLOCK 4: Single Strong Component (status = Solve.EXPLICIT) // ------------------------------------------------------------ // ### Variable: -// Real z +// Real y // ### Equation: -// [SCAL] (1) z = a ^ 2.0 * k ($RES_SIM_2) +// [SCAL] (1) y = x ^ 2.0 + a ($RES_SIM_1) // // BLOCK 5: Single Strong Component (status = Solve.EXPLICIT) // ------------------------------------------------------------ // ### Variable: -// Real $FUN_2 +// Real k // ### Equation: -// [SCAL] (1) $FUN_2 = sin(time) ($RES_$AUX_4) +// [SCAL] (1) k = cos(time) ($RES_$AUX_5) // // BLOCK 6: Single Strong Component (status = Solve.EXPLICIT) // ------------------------------------------------------------ // ### Variable: -// Real $DER.x +// Real z // ### Equation: -// [SCAL] (1) $DER.x = $FUN_2 ($RES_SIM_0) +// [SCAL] (1) z = a ^ 2.0 * k ($RES_SIM_2) // // record SimulationResult // resultFile = "partitioning_res.mat", -// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'partitioning', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''", +// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-6, method = 'dassl', fileNamePrefix = 'partitioning', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''", // messages = "LOG_SUCCESS | info | The initialization finished successfully without homotopy method. // LOG_SUCCESS | info | The simulation finished successfully. // " diff --git a/testsuite/simulation/modelica/NBackend/event_handling/hybridSys.mos b/testsuite/simulation/modelica/NBackend/event_handling/hybridSys.mos index b4caf7a725d..191e0d3bf9f 100644 --- a/testsuite/simulation/modelica/NBackend/event_handling/hybridSys.mos +++ b/testsuite/simulation/modelica/NBackend/event_handling/hybridSys.mos @@ -20,10 +20,6 @@ simulate(hybridSys); getErrorString(); // // [stateselection] Natural discrete states from discrete equations: // ******************************************************************* -// [DISS] (1) Boolean phase_Loop2 (start = false) -// [DISS] (1) Boolean phase_Loop1 (start = false) -// [DISS] (1) Boolean phase_Loop3 (start = false) -// [DISS] (1) Boolean phase_Start (start = true) // [DISS] (1) Real x_End (start = 0.0) // [DISS] (1) Real x_Loop3 (start = 0.0) // [DISS] (1) Real x_Loop2 (start = 0.0) @@ -89,7 +85,7 @@ simulate(hybridSys); getErrorString(); // // record SimulationResult // resultFile = "hybridSys_res.mat", -// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'hybridSys', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''", +// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-6, method = 'dassl', fileNamePrefix = 'hybridSys', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''", // messages = "LOG_SUCCESS | info | The initialization finished successfully without homotopy method. // LOG_SUCCESS | info | The simulation finished successfully. // " diff --git a/testsuite/simulation/modelica/NBackend/functions/builtin_functions.mos b/testsuite/simulation/modelica/NBackend/functions/builtin_functions.mos index f17a9baa3a9..4355aff61f7 100644 --- a/testsuite/simulation/modelica/NBackend/functions/builtin_functions.mos +++ b/testsuite/simulation/modelica/NBackend/functions/builtin_functions.mos @@ -51,7 +51,7 @@ simulate(builtin_functions); getErrorString(); // ### Equation: // [SCAL] (1) y = abs(x[2]) ($RES_$AUX_29) // -// --- Alias of INI[1 | 10] --- +// --- Alias of INI[1 | 17] --- // BLOCK 2: Single Strong Component (status = Solve.EXPLICIT) // ------------------------------------------------------------ // ### Variable: @@ -59,7 +59,7 @@ simulate(builtin_functions); getErrorString(); // ### Equation: // [SCAL] (1) $FUN_9 = sinh(y) ($RES_$AUX_21) // -// --- Alias of INI[1 | 9] --- +// --- Alias of INI[1 | 15] --- // BLOCK 3: Single Strong Component (status = Solve.EXPLICIT) // ------------------------------------------------------------ // ### Variable: @@ -67,7 +67,7 @@ simulate(builtin_functions); getErrorString(); // ### Equation: // [SCAL] (1) $FUN_8 = atan(y) ($RES_$AUX_22) // -// --- Alias of INI[1 | 8] --- +// --- Alias of INI[1 | 13] --- // BLOCK 4: Single Strong Component (status = Solve.EXPLICIT) // ------------------------------------------------------------ // ### Variable: @@ -75,7 +75,7 @@ simulate(builtin_functions); getErrorString(); // ### Equation: // [SCAL] (1) $FUN_7 = acos(y) ($RES_$AUX_23) // -// --- Alias of INI[1 | 7] --- +// --- Alias of INI[1 | 11] --- // BLOCK 5: Single Strong Component (status = Solve.EXPLICIT) // ------------------------------------------------------------ // ### Variable: @@ -83,7 +83,7 @@ simulate(builtin_functions); getErrorString(); // ### Equation: // [SCAL] (1) $FUN_6 = asin(y) ($RES_$AUX_24) // -// --- Alias of INI[1 | 6] --- +// --- Alias of INI[1 | 9] --- // BLOCK 6: Single Strong Component (status = Solve.EXPLICIT) // ------------------------------------------------------------ // ### Variable: @@ -91,7 +91,7 @@ simulate(builtin_functions); getErrorString(); // ### Equation: // [SCAL] (1) $FUN_5 = tan(y) ($RES_$AUX_25) // -// --- Alias of INI[1 | 5] --- +// --- Alias of INI[1 | 7] --- // BLOCK 7: Single Strong Component (status = Solve.EXPLICIT) // ------------------------------------------------------------ // ### Variable: @@ -99,7 +99,7 @@ simulate(builtin_functions); getErrorString(); // ### Equation: // [SCAL] (1) $FUN_4 = cos(y) ($RES_$AUX_26) // -// --- Alias of INI[1 | 4] --- +// --- Alias of INI[1 | 5] --- // BLOCK 8: Single Strong Component (status = Solve.EXPLICIT) // ------------------------------------------------------------ // ### Variable: @@ -115,7 +115,7 @@ simulate(builtin_functions); getErrorString(); // ### Equation: // [SCAL] (1) $FUN_2 = sqrt(y) ($RES_$AUX_28) // -// --- Alias of INI[1 | 16] --- +// --- Alias of INI[1 | 29] --- // BLOCK 10: Single Strong Component (status = Solve.EXPLICIT) // ------------------------------------------------------------- // ### Variable: @@ -123,7 +123,7 @@ simulate(builtin_functions); getErrorString(); // ### Equation: // [SCAL] (1) $FUN_15 = atan2(y, x[1]) ($RES_$AUX_15) // -// --- Alias of INI[1 | 15] --- +// --- Alias of INI[1 | 27] --- // BLOCK 11: Single Strong Component (status = Solve.EXPLICIT) // ------------------------------------------------------------- // ### Variable: @@ -131,7 +131,7 @@ simulate(builtin_functions); getErrorString(); // ### Equation: // [SCAL] (1) $FUN_14 = log10(1.0 + y) ($RES_$AUX_16) // -// --- Alias of INI[1 | 17] --- +// --- Alias of INI[1 | 4] --- // BLOCK 12: Sliced Component (status = Solve.EXPLICIT) // ------------------------------------------------------ // ### Variable: @@ -140,7 +140,7 @@ simulate(builtin_functions); getErrorString(); // [SCAL] (1) $DER.x[1] = $FUN_2 ($RES_SIM_13) // slice: {} // -// --- Alias of INI[1 | 18] --- +// --- Alias of INI[1 | 6] --- // BLOCK 13: Sliced Component (status = Solve.EXPLICIT) // ------------------------------------------------------ // ### Variable: @@ -149,7 +149,7 @@ simulate(builtin_functions); getErrorString(); // [SCAL] (1) $DER.x[2] = $FUN_3 ($RES_SIM_12) // slice: {} // -// --- Alias of INI[1 | 19] --- +// --- Alias of INI[1 | 8] --- // BLOCK 14: Sliced Component (status = Solve.EXPLICIT) // ------------------------------------------------------ // ### Variable: @@ -158,7 +158,7 @@ simulate(builtin_functions); getErrorString(); // [SCAL] (1) $DER.x[3] = $FUN_4 ($RES_SIM_11) // slice: {} // -// --- Alias of INI[1 | 20] --- +// --- Alias of INI[1 | 10] --- // BLOCK 15: Sliced Component (status = Solve.EXPLICIT) // ------------------------------------------------------ // ### Variable: @@ -167,7 +167,7 @@ simulate(builtin_functions); getErrorString(); // [SCAL] (1) $DER.x[4] = $FUN_5 ($RES_SIM_10) // slice: {} // -// --- Alias of INI[1 | 21] --- +// --- Alias of INI[1 | 12] --- // BLOCK 16: Sliced Component (status = Solve.EXPLICIT) // ------------------------------------------------------ // ### Variable: @@ -176,7 +176,7 @@ simulate(builtin_functions); getErrorString(); // [SCAL] (1) $DER.x[5] = $FUN_6 ($RES_SIM_9) // slice: {} // -// --- Alias of INI[1 | 22] --- +// --- Alias of INI[1 | 14] --- // BLOCK 17: Sliced Component (status = Solve.EXPLICIT) // ------------------------------------------------------ // ### Variable: @@ -185,7 +185,7 @@ simulate(builtin_functions); getErrorString(); // [SCAL] (1) $DER.x[6] = $FUN_7 ($RES_SIM_8) // slice: {} // -// --- Alias of INI[1 | 23] --- +// --- Alias of INI[1 | 16] --- // BLOCK 18: Sliced Component (status = Solve.EXPLICIT) // ------------------------------------------------------ // ### Variable: @@ -194,7 +194,7 @@ simulate(builtin_functions); getErrorString(); // [SCAL] (1) $DER.x[7] = $FUN_8 ($RES_SIM_7) // slice: {} // -// --- Alias of INI[1 | 24] --- +// --- Alias of INI[1 | 18] --- // BLOCK 19: Sliced Component (status = Solve.EXPLICIT) // ------------------------------------------------------ // ### Variable: @@ -203,7 +203,7 @@ simulate(builtin_functions); getErrorString(); // [SCAL] (1) $DER.x[8] = $FUN_9 ($RES_SIM_6) // slice: {} // -// --- Alias of INI[1 | 11] --- +// --- Alias of INI[1 | 19] --- // BLOCK 20: Single Strong Component (status = Solve.EXPLICIT) // ------------------------------------------------------------- // ### Variable: @@ -211,7 +211,7 @@ simulate(builtin_functions); getErrorString(); // ### Equation: // [SCAL] (1) $FUN_10 = cosh(y) ($RES_$AUX_20) // -// --- Alias of INI[1 | 25] --- +// --- Alias of INI[1 | 20] --- // BLOCK 21: Sliced Component (status = Solve.EXPLICIT) // ------------------------------------------------------ // ### Variable: @@ -220,7 +220,7 @@ simulate(builtin_functions); getErrorString(); // [SCAL] (1) $DER.x[9] = $FUN_10 ($RES_SIM_5) // slice: {} // -// --- Alias of INI[1 | 12] --- +// --- Alias of INI[1 | 21] --- // BLOCK 22: Single Strong Component (status = Solve.EXPLICIT) // ------------------------------------------------------------- // ### Variable: @@ -228,7 +228,7 @@ simulate(builtin_functions); getErrorString(); // ### Equation: // [SCAL] (1) $FUN_11 = tanh(y) ($RES_$AUX_19) // -// --- Alias of INI[1 | 26] --- +// --- Alias of INI[1 | 22] --- // BLOCK 23: Sliced Component (status = Solve.EXPLICIT) // ------------------------------------------------------ // ### Variable: @@ -237,7 +237,7 @@ simulate(builtin_functions); getErrorString(); // [SCAL] (1) $DER.x[10] = $FUN_11 ($RES_SIM_4) // slice: {} // -// --- Alias of INI[1 | 13] --- +// --- Alias of INI[1 | 23] --- // BLOCK 24: Single Strong Component (status = Solve.EXPLICIT) // ------------------------------------------------------------- // ### Variable: @@ -245,7 +245,7 @@ simulate(builtin_functions); getErrorString(); // ### Equation: // [SCAL] (1) $FUN_12 = exp(y) ($RES_$AUX_18) // -// --- Alias of INI[1 | 27] --- +// --- Alias of INI[1 | 24] --- // BLOCK 25: Sliced Component (status = Solve.EXPLICIT) // ------------------------------------------------------ // ### Variable: @@ -254,7 +254,7 @@ simulate(builtin_functions); getErrorString(); // [SCAL] (1) $DER.x[11] = $FUN_12 ($RES_SIM_3) // slice: {} // -// --- Alias of INI[1 | 14] --- +// --- Alias of INI[1 | 25] --- // BLOCK 26: Single Strong Component (status = Solve.EXPLICIT) // ------------------------------------------------------------- // ### Variable: @@ -262,7 +262,7 @@ simulate(builtin_functions); getErrorString(); // ### Equation: // [SCAL] (1) $FUN_13 = log(1.0 + y) ($RES_$AUX_17) // -// --- Alias of INI[1 | 28] --- +// --- Alias of INI[1 | 26] --- // BLOCK 27: Sliced Component (status = Solve.EXPLICIT) // ------------------------------------------------------ // ### Variable: @@ -271,7 +271,7 @@ simulate(builtin_functions); getErrorString(); // [SCAL] (1) $DER.x[12] = $FUN_13 ($RES_SIM_2) // slice: {} // -// --- Alias of INI[1 | 29] --- +// --- Alias of INI[1 | 28] --- // BLOCK 28: Sliced Component (status = Solve.EXPLICIT) // ------------------------------------------------------ // ### Variable: @@ -378,7 +378,7 @@ simulate(builtin_functions); getErrorString(); // // record SimulationResult // resultFile = "builtin_functions_res.mat", -// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'builtin_functions', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''", +// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-6, method = 'dassl', fileNamePrefix = 'builtin_functions', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''", // messages = "LOG_SUCCESS | info | The initialization finished successfully without homotopy method. // LOG_SUCCESS | info | The simulation finished successfully. // "