Skip to content

Commit

Permalink
Evaluate DAE as part of All in Cpp
Browse files Browse the repository at this point in the history
This unifies the use and prepares support for clocked subsystems.
  • Loading branch information
rfranke committed Apr 21, 2023
1 parent 5d8d697 commit bffb081
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
2 changes: 2 additions & 0 deletions OMCompiler/Compiler/Template/CodegenCppOld.tpl
Expand Up @@ -12424,6 +12424,8 @@ case SIMCODE(modelInfo = MODELINFO(__)) then
<%createTimeConditionTreatments(timeEventLength(simCode), clockedPartitions)%>

// Evaluate Equations
if (_dimAE > 0)
evaluateDAE(command);
<%equation_all_func_calls%>

<%if createMeasureTime then generateMeasureTimeEndCode("measuredFunctionStartValues", "measuredFunctionEndValues", "(*measureTimeFunctionsArray)[1]", "evaluateAll", "MEASURETIME_MODELFUNCTIONS") else ""%>
Expand Down
16 changes: 4 additions & 12 deletions OMCompiler/SimulationRuntime/cpp/Solver/DASSL/DASSL.cpp
Expand Up @@ -446,13 +446,11 @@ void DASSL::DASSLCore()
if (_idid == 3)
_time_system->setTime(_tEnd); // interpolated time point
_continuous_system->setContinuousStates(_y);
if (_dimAE == 0)
_continuous_system->evaluateAll(IContinuous::CONTINUOUS);
else {
if (_dimAE > 0) {
_mixed_system->setAlgebraicDAEVars(_y + _dimStates);
_continuous_system->setStateDerivatives(_yPrime);
_continuous_system->evaluateDAE(IContinuous::CONTINUOUS);
}
_continuous_system->evaluateAll(IContinuous::CONTINUOUS);
writeToFile(_accStps, _tCurrent, _h);
}

Expand Down Expand Up @@ -519,10 +517,7 @@ void DASSL::DASSLCore()
{
try
{
if (_dimAE == 0)
_continuous_system->evaluateAll(IContinuous::CONTINUOUS);
else
_continuous_system->evaluateDAE(IContinuous::CONTINUOUS);
_continuous_system->evaluateAll(IContinuous::CONTINUOUS);
}
catch (std::exception& ex)
{
Expand All @@ -549,10 +544,7 @@ void DASSL::DASSLCore()
if (writeEventOutput)
{
// If we want to write the event-results, we should evaluate the whole system again
if (_dimAE == 0)
_continuous_system->evaluateAll(IContinuous::CONTINUOUS);
else
_continuous_system->evaluateDAE(IContinuous::CONTINUOUS);
_continuous_system->evaluateAll(IContinuous::CONTINUOUS);
writeToFile(_accStps, _tCurrent, _h);
}

Expand Down

0 comments on commit bffb081

Please sign in to comment.