Skip to content

Commit

Permalink
[C-runtime] Adding CVODE
Browse files Browse the repository at this point in the history
For trac ticket 5830.
  - Adding Sundials CVODE v2.8.2 as integration method for C runtime.
    Use `method="cvode"` in OMEdit or `-s=cvode` when running the executable.
  - Possible to choose integrator method:
    - For stiff problems [default]: `-cvodeLinearMultistepMethod=CV_BDF -cvodeNonlinearSolverIteration=CV_NEWTON`.
    - For non-stiff problems: `-cvodeLinearMultistepMethod=CV_ADAMS -cvodeNonlinearSolverIteration=CV_FUNCTIONAL`.
  - Added tests for CVODE to testsuite.
    - problem2 still failing

Additional changes to existing files:
  - Added check in printSparseStructure to check for NULL.
  - Fixed warnings during compilation of some infoStreamPrint calls.
  - Added new flags to choose CVODE solver and set some settings.
  - Changed debug print in ida_solver.c to use `LOG_SOLVER_V` instead of `LOG_DASSL_STATES`.
  - Added CVODE to solver_main.c.
  - Addapted build system to add libsundials_cvodes.* to runtime.

Still WIP:
  - Use colored dense numberic Jacobian instead of internal dense Jacobian from CVODE
  • Loading branch information
AnHeuermann authored and lochel committed May 29, 2020
1 parent e293f5a commit 419f112
Show file tree
Hide file tree
Showing 15 changed files with 1,325 additions and 14 deletions.
2 changes: 1 addition & 1 deletion OMCompiler/Compiler/Util/Autoconf.mo.omdev.mingw
Expand Up @@ -9,7 +9,7 @@ encapsulated package Autoconf
constant String make = "make";
constant String exeExt = ".exe";
constant String dllExt = ".dll";
constant String ldflags_basic = " -Wl,-Bstatic -lomcgc -lregex -ltre -lintl -liconv -lexpat -static-libgcc -luuid -loleaut32 -lole32 -limagehlp -lws2_32 -llis -lumfpack -lklu -lcolamd -lbtf -lamd -lsundials_idas -lsundials_kinsol -lsundials_nvecserial -lipopt -lcoinmumps -lpthread -lm -lgfortranbegin -lgfortran -lquadmath -lmingw32 -lgcc_eh -lmoldname -lmingwex -lmsvcrt -luser32 -lkernel32 -ladvapi32 -lshell32 -lopenblas -lcminpack -Wl,-Bdynamic";
constant String ldflags_basic = " -Wl,-Bstatic -lomcgc -lregex -ltre -lintl -liconv -lexpat -static-libgcc -luuid -loleaut32 -lole32 -limagehlp -lws2_32 -llis -lumfpack -lklu -lcolamd -lbtf -lamd -lsundials_idas -lsundials_cvodes -lsundials_kinsol -lsundials_nvecserial -lipopt -lcoinmumps -lpthread -lm -lgfortranbegin -lgfortran -lquadmath -lmingw32 -lgcc_eh -lmoldname -lmingwex -lmsvcrt -luser32 -lkernel32 -ladvapi32 -lshell32 -lopenblas -lcminpack -Wl,-Bdynamic";

constant String ldflags_runtime = " -lOpenModelicaRuntimeC" + ldflags_basic;
constant String ldflags_runtime_sim = " -Wl,-Bstatic -lSimulationRuntimeC -Wl,-Bdynamic" + ldflags_basic + " -lwsock32 -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic";
Expand Down
5 changes: 5 additions & 0 deletions OMCompiler/SimulationRuntime/c/Makefile.common
Expand Up @@ -79,6 +79,7 @@ RUNTIMESIMSOLVER_HEADERS = ./simulation/solver/delay.h \
./simulation/solver/dassl.h \
./simulation/solver/embedded_server.h \
./simulation/solver/ida_solver.h \
./simulation/solver/cvode_solver.h \
./simulation/solver/omc_math.h \
./simulation/solver/events.h \
./simulation/solver/synchronous.h \
Expand Down Expand Up @@ -282,13 +283,17 @@ libSimulationRuntimeFMI.a: $(FMI_ME_OBJS_BUILDPATH)
install: bootstrap-dependencies $(LIBSIMULATION) $(LIBFMIRUNTIME) $(ALL_OBJS) fmi-runtime RuntimeSources.mo
# copy libraries
cp -p $(LIBSIMULATION) $(LIBFMIRUNTIME) $(LIBSIMULATIONFMI) $(builddir_lib)
# FMI runtime libs
test ! -f libSimulationRuntimeC.bc || cp libSimulationRuntimeC.bc $(builddir_lib)/emcc/libSimulationRuntimeC.so
test ! `uname` = Darwin || install_name_tool -change libsundials_idas.0.dylib @rpath/libsundials_idas.0.dylib $(builddir_lib)/$(LIBFMIRUNTIME)
test ! `uname` = Darwin || install_name_tool -change libsundials_ida.2.dylib @rpath/libsundials_ida.2.dylib $(builddir_lib)/$(LIBFMIRUNTIME)
test ! `uname` = Darwin || install_name_tool -change libsundials_nvecserial.0.dylib @rpath/libsundials_nvecserial.0.dylib $(builddir_lib)/$(LIBFMIRUNTIME)
test ! `uname` = Darwin || install_name_tool -change libsundials_kinsol.1.dylib @rpath/libsundials_kinsol.1.dylib $(builddir_lib)/$(LIBFMIRUNTIME)
# C runtime libs
test ! `uname` = Darwin || install_name_tool -change libsundials_idas.0.dylib @rpath/libsundials_idas.0.dylib $(builddir_lib)/$(LIBSIMULATION)
test ! `uname` = Darwin || install_name_tool -change libsundials_ida.2.dylib @rpath/libsundials_ida.2.dylib $(builddir_lib)/$(LIBSIMULATION)
test ! `uname` = Darwin || install_name_tool -change libsundials_cvodes.2.dylib @rpath/libsundials_cvodes.2.dylib $(builddir_lib)/$(LIBSIMULATION)
test ! `uname` = Darwin || install_name_tool -change libsundials_cvode.1.dylib @rpath/libsundials_cvode.1.dylib $(builddir_lib)/$(LIBSIMULATION)
test ! `uname` = Darwin || install_name_tool -change libsundials_nvecserial.0.dylib @rpath/libsundials_nvecserial.0.dylib $(builddir_lib)/$(LIBSIMULATION)
test ! `uname` = Darwin || install_name_tool -change libsundials_kinsol.1.dylib @rpath/libsundials_kinsol.1.dylib $(builddir_lib)/$(LIBSIMULATION)
test ! `uname` = Darwin || install_name_tool -change liblis.dylib @rpath/liblis.dylib $(builddir_lib)/$(LIBSIMULATION)
Expand Down
4 changes: 2 additions & 2 deletions OMCompiler/SimulationRuntime/c/Makefile.objs
Expand Up @@ -69,11 +69,11 @@ else
SOLVER_OBJS_MINIMAL=$(SOLVER_OBJS_FMU)
endif
ifeq ($(OMC_MINIMAL_RUNTIME),)
SOLVER_OBJS=$(SOLVER_OBJS_MINIMAL) kinsolSolver$(OBJ_EXT) linearSolverKlu$(OBJ_EXT) linearSolverLis$(OBJ_EXT) linearSolverUmfpack$(OBJ_EXT) dassl$(OBJ_EXT) radau$(OBJ_EXT) sym_solver_ssc$(OBJ_EXT) nonlinearSolverNewton$(OBJ_EXT) newtonIteration$(OBJ_EXT) ida_solver$(OBJ_EXT) irksco$(OBJ_EXT) dae_mode$(OBJ_EXT) jacobianSymbolical$(OBJ_EXT)
SOLVER_OBJS=$(SOLVER_OBJS_MINIMAL) kinsolSolver$(OBJ_EXT) linearSolverKlu$(OBJ_EXT) linearSolverLis$(OBJ_EXT) linearSolverUmfpack$(OBJ_EXT) dassl$(OBJ_EXT) radau$(OBJ_EXT) sym_solver_ssc$(OBJ_EXT) nonlinearSolverNewton$(OBJ_EXT) newtonIteration$(OBJ_EXT) ida_solver$(OBJ_EXT) cvode_solver$(OBJ_EXT) irksco$(OBJ_EXT) dae_mode$(OBJ_EXT) jacobianSymbolical$(OBJ_EXT)
else
SOLVER_OBJS=$(SOLVER_OBJS_MINIMAL)
endif
SOLVER_HFILES = dassl.h dae_mode.h delay.h epsilon.h events.h external_input.h fmi_events.h ida_solver.h linearSystem.h mixedSystem.h model_help.h nonlinearSystem.h nonlinearValuesList.h radau.h sym_solver_ssc.h solver_main.h stateset.h jacobianSymbolical.h
SOLVER_HFILES = dassl.h dae_mode.h delay.h epsilon.h events.h external_input.h fmi_events.h ida_solver.h cvode_solver.h linearSystem.h mixedSystem.h model_help.h nonlinearSystem.h nonlinearValuesList.h radau.h sym_solver_ssc.h solver_main.h stateset.h jacobianSymbolical.h

INITIALIZATION_OBJS = initialization$(OBJ_EXT)
INITIALIZATION_HFILES = initialization.h
Expand Down

0 comments on commit 419f112

Please sign in to comment.