Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit a8cd990

Browse files
rfrankeOpenModelica-Hudson
authored andcommitted
Inline integration initializes clocked continuous states
Initialization during code generation does not work for states in algebraic loops. This initialization in the backend becomes possible with the introduction of $DER.x variables for derivatives.
1 parent d32ecbb commit a8cd990

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

Compiler/BackEnd/SynchronousFeatures.mo

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ algorithm
227227
// introduce states to delay derivatives; see MLS 3.3, section 16.8.2 Solver Methods
228228
exp2 := DAE.CALL(Absyn.IDENT(name = "previous"), {exp2}, DAE.callAttrBuiltinImpureReal);
229229
end if;
230+
exp2 := DAE.IFEXP(DAE.CALL(Absyn.IDENT(name = "firstTick"), {}, DAE.callAttrBuiltinImpureBool),
231+
DAE.RCONST(0), exp2);
230232
eq := BackendDAE.EQUATION(exp, exp2, var.source, BackendDAE.EQ_ATTR_DEFAULT_DYNAMIC);
231233
lstEqs := eq :: lstEqs;
232234
end for;

Compiler/Template/CodegenCppCommon.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1712,7 +1712,7 @@ template daeExpCall(Exp call, Context context, Text &preExp /*BUFP*/, Text &varD
17121712
'<%contextSystem(context)%><%cref(crefPrefixPrevious(arg.componentRef), useFlatArrayNotation)%>'
17131713

17141714
case CALL(path=IDENT(name="firstTick")) then
1715-
'<%contextSystem(context)%>_clockStart[clockIndex - 1]'
1715+
'(<%contextSystem(context)%>_clockStart[clockIndex - 1] || <%contextSystem(context)%>_clockSubactive[clockIndex - 1])'
17161716

17171717
case CALL(path=IDENT(name="interval")) then
17181718
'<%contextSystem(context)%>_clockInterval[clockIndex - 1]'

0 commit comments

Comments
 (0)