Skip to content

Commit

Permalink
fix IDAGetDky issue
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@24393 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Michael Kloeppel committed Feb 4, 2015
1 parent 990e467 commit 7cd499e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion SimulationRuntime/cpp/CMakeLists.txt
Expand Up @@ -283,7 +283,7 @@ IF(USE_SUNDIALS)
IF(NOT SUNDIALS_CVODES_LIB)
MESSAGE(FATAL_ERROR "Could not find libsundials_cvodes!")
ENDIF()
FIND_LIBRARY(SUNDIALS_IDA_LIB "sundials_ida" PATHS ${SUNDIALS_LIBRARY_RELEASE_HOME} $ENV{SUNDIALS_ROOT}/lib)
FIND_LIBRARY(SUNDIALS_IDA_LIB "sundials_idas" PATHS ${SUNDIALS_LIBRARY_RELEASE_HOME} $ENV{SUNDIALS_ROOT}/lib)
IF(NOT SUNDIALS_IDA_LIB)
MESSAGE(FATAL_ERROR "Could not find libsundials_ida!")
ENDIF()
Expand Down
7 changes: 4 additions & 3 deletions SimulationRuntime/cpp/Include/Solver/IDA/IDA.h
Expand Up @@ -4,10 +4,10 @@
#include "FactoryExport.h"

#include <Core/Solver/SolverDefaultImplementation.h>
#include <ida/ida.h>
#include <idas/idas.h>
#include <nvector/nvector_serial.h>
#include <sundials/sundials_direct.h>
#include <ida/ida_dense.h>
#include <idas/idas_dense.h>


#ifdef RUNTIME_PROFILING
Expand Down Expand Up @@ -207,8 +207,9 @@ double
N_Vector
_CV_y0, ///< Temp - Initial values in the ida Format
_CV_y, ///< Temp - State in ida Format
_CV_yp, ///<Temp - Stateders in ida Format
_CV_yp, ///<Temp - Stateders in ida Format
_CV_yWrite, ///< Temp - Vector for dense out
_CV_ypWrite,
_CV_absTol;

// Variables for Coloured Jacobians
Expand Down
17 changes: 9 additions & 8 deletions SimulationRuntime/cpp/Solver/IDA/IDA.cpp
Expand Up @@ -77,6 +77,7 @@ Ida::~Ida()
{
N_VDestroy_Serial(_CV_y0);
N_VDestroy_Serial(_CV_y);
N_VDestroy_Serial(_CV_yp);
N_VDestroy_Serial(_CV_yWrite);
N_VDestroy_Serial(_CV_absTol);
IDAFree(&_idaMem);
Expand Down Expand Up @@ -524,8 +525,8 @@ void Ida::IDACore()
// State variables were reinitialized, thus we have to give these values to the ida-solver
// Take care about the memory regions, _z is the same like _CV_y
_continuous_system->getContinuousStates(_z);
calcFunction(_tCurrent, NV_DATA_S(_CV_y), NV_DATA_S(_CV_yp));

calcFunction(_tCurrent, NV_DATA_S(_CV_y), NV_DATA_S(_CV_yp));
}
}

Expand Down Expand Up @@ -698,12 +699,12 @@ int Ida::calcFunction(const double& time, const double* y, double* f)
}

int Ida::CV_fCallback(double t, N_Vector y, N_Vector ydot, N_Vector resval, void *user_data)
{
double* ypval=NV_DATA_S(ydot);
double* rval=NV_DATA_S(resval);
((Ida*) user_data)->calcFunction(t, NV_DATA_S(y), NV_DATA_S(resval));
for(size_t i(0); i<((Ida*) user_data)->_dimSys; ++i) rval[i]-=ypval[i];
return 0;
{
double* ypval=NV_DATA_S(ydot);
double* rval=NV_DATA_S(resval);
((Ida*) user_data)->calcFunction(t, NV_DATA_S(y), NV_DATA_S(resval));
for(size_t i(0); i<((Ida*) user_data)->_dimSys; ++i) rval[i]-=ypval[i];
return 0;
}

void Ida::giveZeroVal(const double &t, const double *y, double *zeroValue)
Expand Down

0 comments on commit 7cd499e

Please sign in to comment.