Skip to content

Commit

Permalink
fix in covde for event output
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@17395 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
niklwors committed Sep 26, 2013
1 parent e4edf21 commit 328dd62
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Compiler/Template/CodegenCpp.tpl
Expand Up @@ -5455,7 +5455,7 @@ template daeExpCall(Exp call, Context context, Text &preExp /*BUFP*/,
case CALL(path=IDENT(name="div"), expLst={e1,e2}) then
let var1 = daeExp(e1, context, &preExp, &varDecls,simCode)
let var2 = daeExp(e2, context, &preExp, &varDecls,simCode)
'trunc(<%var1%>/<%var2%>)'
'boost::math::trunc(<%var1%>/<%var2%>)'

case CALL(path=IDENT(name="mod"), expLst={e1,e2}, attr=attr as CALL_ATTR(__)) then
let var1 = daeExp(e1, context, &preExp, &varDecls,simCode)
Expand Down
1 change: 1 addition & 0 deletions SimulationRuntime/cpp/Include/Core/Modelica.h
Expand Up @@ -54,6 +54,7 @@ using namespace std;
#include <boost/numeric/ublas/matrix_sparse.hpp>
#include <boost/range/adaptor/map.hpp>
#include <boost/range/algorithm/copy.hpp>
#include <boost/math/special_functions/trunc.hpp>
namespace uBlas = boost::numeric::ublas;
using namespace boost::extensions;
using namespace boost::assign;
Expand Down
13 changes: 8 additions & 5 deletions SimulationRuntime/cpp/Solver/CVode/CVode.cpp
Expand Up @@ -282,7 +282,8 @@ void Cvode::CVodeCore()
_accStps +=_locStps;
_idid = CVodeGetLastStep(_cvodeMem,&_h);
//Ausgabe
writeCVodeOutput(_tCurrent,_h,_locStps);
if(_cv_rt == CV_SUCCESS)
writeCVodeOutput(_tCurrent,_h,_locStps);

/*ToDo
if(dynamic_cast<IStepEvent*>(_system)->isStepEvent())
Expand All @@ -300,14 +301,14 @@ void Cvode::CVodeCore()
}

// A root is found
if(_cv_rt == 2)
if(_cv_rt == CV_ROOT_RETURN)
{
_zeroFound = true;
_time_system->setTime(_tCurrent);
_continuous_system->setContinuousStates(NV_DATA_S(_CV_y));
_continuous_system->evaluate(IContinuous::ALL );
// Zustände recorden bis hierher
SolverDefaultImplementation::writeToFile(-99, _tCurrent, _h);
//SolverDefaultImplementation::writeToFile(-99, _tCurrent, _h);
}

// Eventiteration starten
Expand All @@ -332,6 +333,9 @@ void Cvode::CVodeCore()
_idid = CVodeReInit(_cvodeMem, _tCurrent, _CV_y);
if(_idid < 0)
throw std::runtime_error("CVode::ReInit()");
//Zustände nach der Ereignisbehandlung aufnehmen
if (_cvodesettings->getEventOutput())
writeToFile(0, _tCurrent, _h);

// Der Eventzeitpunkt kann auf der Endzeit liegen (Time-Events). In diesem Fall wird der Solver beendet, da CVode sonst eine interne Warnung schmeißt
if(_tCurrent == _tEnd)
Expand All @@ -348,7 +352,7 @@ void Cvode::CVodeCore()
_continuous_system->setContinuousStates(NV_DATA_S(_CV_y));
_continuous_system->evaluate(IContinuous::ALL);
_solverStatus = DONE;
writeCVodeOutput(_tEnd,_h,_locStps);
//writeCVodeOutput(_tEnd,_h,_locStps);
}
}
}
Expand Down Expand Up @@ -404,7 +408,6 @@ int Cvode::calcFunction(const double& time, const double* y, double* f)
catch(std::exception& ex)
{
std::string error = ex.what();
ISolver::SOLVERERROR;
cerr << "CVode integration error: "<< error ;
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion SimulationRuntime/cpp/Solver/CVode/CVodeSettings.cpp
Expand Up @@ -5,7 +5,7 @@
CVodeSettings::CVodeSettings(IGlobalSettings* globalSettings)
: SolverSettings (globalSettings)
,_denseOutput(true)

,_eventOutput(true)
{
};

Expand Down

0 comments on commit 328dd62

Please sign in to comment.