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

Commit

Permalink
Use start values as initial guess for nonlinear systems
Browse files Browse the repository at this point in the history
  • Loading branch information
lochel authored and OpenModelica-Hudson committed Mar 31, 2017
1 parent 4548444 commit 280c5ba
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Compiler/Template/CodegenC.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5146,10 +5146,16 @@ case SES_SIMPLE_ASSIGN(__)
case SES_SIMPLE_ASSIGN_CONSTRAINTS(__) then
let &preExp = buffer ""
let expPart = daeExp(exp, context, &preExp, &varDecls, &auxFunction)
let postExp = if isStartCref(cref) then
<<
<%cref(popCref(cref))%> = <%cref(cref)%>;
infoStreamPrint(LOG_INIT, 0, "updated start value: %s(start=<%crefToPrintfArg(popCref(cref))%>)", <%crefVarInfo(popCref(cref))%>.name, (<%crefType(popCref(cref))%>) <%cref(popCref(cref))%>);
>>
<<
<%modelicaLine(eqInfo(eq))%>
<%preExp%>
<%cref(cref)%> = <%expPart%>;
<%postExp%>
<%endModelicaLine()%>
>>
end equationSimpleAssign;
Expand Down
15 changes: 15 additions & 0 deletions Compiler/Template/SimCodeTV.mo
Original file line number Diff line number Diff line change
Expand Up @@ -3147,6 +3147,21 @@ package ComponentReference
output Absyn.Path outPath;
end crefToPathIgnoreSubs;

function crefPrefixStart
input DAE.ComponentRef inCref;
output DAE.ComponentRef outCref;
end crefPrefixStart;

function isStartCref
input DAE.ComponentRef cr;
output Boolean b;
end isStartCref;

function popCref
input DAE.ComponentRef inCR;
output DAE.ComponentRef outCR;
end popCref;

end ComponentReference;

package Expression
Expand Down

0 comments on commit 280c5ba

Please sign in to comment.