Skip to content

Commit

Permalink
- call other equations in residual functions via equation_indx and ca…
Browse files Browse the repository at this point in the history
…ll them again after solution was found to set value of other equations to valid

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@13462 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Jens Frenkel committed Oct 18, 2012
1 parent 5bd3246 commit 2e61c96
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions Compiler/Template/CodegenC.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -849,13 +849,22 @@ template functionExtraResidualsPreBody(SimEqSystem eq, Text &varDecls /*BUFP*/,
match eq
case e as SES_RESIDUAL(__)
then ""
case e as SES_SIMPLE_ASSIGN(__)
then old_equation_(e, contextSimulationDiscrete, &varDecls /*BUFD*/)
else
equation_(eq, contextSimulationDiscrete, &varDecls /*BUFD*/, &eqs)
end match
end functionExtraResidualsPreBody;

template equationNamesExtraResidualsPreBody(SimEqSystem eq)
"Generates an equation."
::=
match eq
case e as SES_RESIDUAL(__)
then ""
else
equationNames_(eq, contextSimulationDiscrete)
end match
end equationNamesExtraResidualsPreBody;

template functionExtraResiduals(list<SimEqSystem> allEquations)
"Generates functions in simulation file."
::=
Expand Down Expand Up @@ -2097,6 +2106,7 @@ template equationNonlinear(SimEqSystem eq, Context context, Text &varDecls /*BUF
match eq
case SES_NONLINEAR(__) then
let size = listLength(crefs)
let eqncalls = (eqs |> eq2 => equationNamesExtraResidualsPreBody(eq2) ;separator="\n")
let nonlinindx = indexNonLinear
<<
#ifdef _OMC_MEASURE_TIME
Expand All @@ -2116,6 +2126,7 @@ case SES_NONLINEAR(__) then
/* write solution */
<%crefs |> name hasindex i0 => '<%cref(name)%> = data->simulationInfo.nonlinearSystemData[<%nonlinindx%>].nlsx[<%i0%>];' ;separator="\n"%>
<%inlineCrefs(context,crefs)%>
<%eqncalls%>
#ifdef _OMC_MEASURE_TIME
SIM_PROF_ACC_EQ(SIM_PROF_EQ_<%index%>);
#endif<%\n%>
Expand Down

0 comments on commit 2e61c96

Please sign in to comment.