Skip to content

Commit

Permalink
v6.5.0-3 updated sundials to 6.5.0
Browse files Browse the repository at this point in the history
Signed-off-by: Serguei Sokol <[email protected]>
  • Loading branch information
sgsokol committed Mar 24, 2023
1 parent fc66cdd commit e7fe561
Show file tree
Hide file tree
Showing 203 changed files with 36,007 additions and 6,336 deletions.
10 changes: 9 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
todo.txt
gdb.txt
NAMESPACE.empty
NAMESPACE.save
^.*\.save$
^\.git.*$
^autom.*$
Readme.Rmd
Readme.md
gdb.txt
^rm$
^.*\.toremove$
lib-5.0.0
10 changes: 6 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: r2sundials
Type: Package
Title: Wrapper for 'SUNDIALS' Solving ODE and Sensitivity Problem
Version: 5.0.0-10
Date: 2021-05-17
Version: 6.5.0-3
Date: 2023-03-21
Authors@R: c(
person("Serguei", "Sokol", role=c("cre", "aut"), email="[email protected]"),
person("Carol S.", "Woodward", role="ctb"),
Expand Down Expand Up @@ -33,7 +33,9 @@ Authors@R: c(
person("Chris", "White", role="ctb"),
person("Lawrence Livermore National Security", role="cph"),
person("Southern Methodist University", role="cph"),
person("INRAE", role="cph")
person("INSA", role="cph"),
person("INRAE", role="cph"),
person("CNRS", role="cph")
)
Maintainer: Serguei Sokol <[email protected]>
Description: Wrapper for widely used 'SUNDIALS' software (SUite of Nonlinear and DIfferential/ALgebraic Equation Solvers) and more precisely to its 'CVODES' solver. It is aiming to solve ordinary differential equations (ODE) and optionally pending forward sensitivity problem. The wrapper is made 'R' friendly by allowing to pass custom parameters to user's callback functions. Such functions can be both written in 'R' and in 'C++' ('RcppArmadillo' flavor). In case of 'C++', performance is greatly improved so this option is highly advisable when performance matters. If provided, Jacobian matrix can be calculated either in dense or sparse format. In the latter case 'rmumps' package is used to solve corresponding linear systems. Root finding and pending event management are optional and can be specified as 'R' or 'C++' functions too. This makes them a very flexible tool for controlling the ODE system during the time course simulation. 'SUNDIALS' library was published in Hindmarsh et al. (2005) <doi:10.1145/1089014.1089020>.
Expand All @@ -43,7 +45,7 @@ License: GPL (>=2)
Imports: Rcpp (>= 1.0.0)
LinkingTo: Rcpp, RcppArmadillo, rmumps (>= 5.2.1-6)
Suggests: RcppXPtrUtils, slam, RUnit, deSolve, RcppArmadillo
RoxygenNote: 7.1.1
RoxygenNote: 7.2.2
Encoding: UTF-8
NeedsCompilation: yes
Biarch: FALSE
12 changes: 10 additions & 2 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
Version 5.0.0-10
Version 6.5.0-3
===============

* 2023-03-21
- passed to v6.5.0 of SUNDIALS library
- fixed warnings from "-Wstrict-prototypes" (reported by R-core)
- updated CIATION format

Version 5.0.0-10
================

* 2021-05-17
- fixed errors form "-fno-common" compile option relative to global variables
- fixed errors from "-fno-common" compile option relative to global variables (reported by R-core)

Version 5.0.0-9
===============
Expand Down
21 changes: 14 additions & 7 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@
#' return(CV_SUCCESS);
#' }
#' ', depends=c("RcppArmadillo","r2sundials","rmumps"),
#' includes="using namespace arma;\n#include <r2sundials.h>", cacheDir="lib", verbose=FALSE)
#' includes=c("// [[Rcpp::plugins(cpp14)]]", "using namespace arma;", "#include <r2sundials.h>"),
#' cacheDir="lib", verbose=FALSE)
#' # For ease of use in C++, we convert param to a numeric vector instead of a list.
#' pv=c(a=p$a)
#' # new call to r2cvodes() with XPtr pointer ptr_exp.
Expand Down Expand Up @@ -155,7 +156,8 @@
#' return(CV_SUCCESS);
#' }
#' ', depends=c("RcppArmadillo","r2sundials","rmumps"),
#' includes="using namespace arma;\n#include <r2sundials.h>", cacheDir="lib", verbose=FALSE)
#' includes=c("// [[Rcpp::plugins(cpp14)]]", "using namespace arma;", "#include <r2sundials.h>"),
#' cacheDir="lib", verbose=FALSE)
#'
#' # root function
#' ptr_ball_root=cppXPtr(code='
Expand All @@ -166,7 +168,8 @@
#' return(0);
#' }
#' ', depends=c("RcppArmadillo","r2sundials","rmumps"),
#' includes="using namespace arma;\n#include <r2sundials.h>", cacheDir="lib", verbose=FALSE)
#' includes=c("// [[Rcpp::plugins(cpp14)]]", "using namespace arma;", "#include <r2sundials.h>"),
#' cacheDir="lib", verbose=FALSE)
#'
#' # event handler function
#' ptr_ball_event=cppXPtr(code='
Expand All @@ -192,7 +195,8 @@
#' }
#' }
#' ', depends=c("RcppArmadillo","r2sundials","rmumps"),
#' includes="using namespace arma;\n#include <r2sundials.h>", cacheDir="lib", verbose=FALSE)
#' includes=c("// [[Rcpp::plugins(cpp14)]]", "using namespace arma;", "#include <r2sundials.h>"),
#' cacheDir="lib", verbose=FALSE)
#'
#' # ODE solving and plotting
#' res_ball <- r2sundials::r2cvodes(yv, ti, ptr_ball, param=pv, nroot=2L,
Expand Down Expand Up @@ -233,7 +237,8 @@
#' return(CV_SUCCESS);
#' }
#' ', depends=c("RcppArmadillo","r2sundials","rmumps"),
#' includes="using namespace arma;\n#include <r2sundials.h>", cacheDir="lib", verbose=FALSE)
#' includes=c("// [[Rcpp::plugins(cpp14)]]", "using namespace arma;", "#include <r2sundials.h>"),
#' cacheDir="lib", verbose=FALSE)
#' # pointer to sparse jacobian function
#' ptr_rob_jacsp=cppXPtr(code='
#' int spjac_rob(double t, const vec &y, const vec &ydot, uvec &ir, uvec &pj, vec &v, int n, int nz,
Expand Down Expand Up @@ -268,7 +273,8 @@
#' return(0);
#' }
#' ', depends=c("RcppArmadillo","r2sundials","rmumps"),
#' includes="using namespace arma;\n#include <r2sundials.h>", cacheDir="lib", verbose=FALSE)
#' includes=c("// [[Rcpp::plugins(cpp14)]]", "using namespace arma;", "#include <r2sundials.h>"),
#' cacheDir="lib", verbose=FALSE)
#' # pointer to sensitivity rhs function
#' ptr_rob_sens1=cppXPtr(code='
#' int sens_rob1(int Ns, double t, const vec &y, const vec &ydot, int iS, const vec &yS, vec &ySdot,
Expand Down Expand Up @@ -296,7 +302,8 @@
#' return(CV_SUCCESS);
#' }
#' ', depends=c("RcppArmadillo","r2sundials","rmumps"),
#' includes="using namespace arma;\n#include <r2sundials.h>", cacheDir="lib", verbose=FALSE)
#' includes=c("// [[Rcpp::plugins(cpp14)]]", "using namespace arma;", "#include <r2sundials.h>"),
#' cacheDir="lib", verbose=FALSE)
#' # Note that we don't use psens param for sensitivity calculations as we provide our own fsens1.
#' res_rob <- r2sundials::r2cvodes(yv, ti, ptr_rob, param=pv, nz=8, fjac=ptr_rob_jacsp, Ns=3,
#' fsens1=ptr_rob_sens1)
Expand Down
4 changes: 2 additions & 2 deletions inst/CITATION
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
citHeader("To cite SUNDIALS in publications use:")

c(
citEntry(entry = "Article",
bibentry(bibtype = "Article",
title = "SUNDIALS: Suite of nonlinear and differential/algebraic equation solvers",
author = personList(as.person("A. C. Hindmarsh"),
author = c(as.person("A. C. Hindmarsh"),
as.person("P. N. Brown"), as.person("K. E. Grant"), as.person("S. L. Lee"), as.person("R. Serban"), as.person("D. E. Shumaker"), as.person("C. S. Woodward")),
journal = "ACM Transactions on Mathematical Software (TOMS)",
year = "2005",
Expand Down
4 changes: 2 additions & 2 deletions inst/COPYRIGHTS
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
For SUNDIALS code:
Copyright (c) 2002-2019, Lawrence Livermore National Security and Southern Methodist University.
Copyright (c) 2002-2022, Lawrence Livermore National Security and Southern Methodist University.
All rights reserved.

For r2sundials wrapper:
Copyright (c) 2020, INRAE/INSA/CNRS
Copyright (c) 2023, INRAE/INSA/CNRS
All rights reserved.
122 changes: 99 additions & 23 deletions inst/include/cvodes/cvodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Programmer(s): Radu Serban @ LLNL
* -----------------------------------------------------------------
* SUNDIALS Copyright Start
* Copyright (c) 2002-2019, Lawrence Livermore National Security
* Copyright (c) 2002-2022, Lawrence Livermore National Security
* and Southern Methodist University.
* All rights reserved.
*
Expand All @@ -18,9 +18,11 @@
#define _CVODES_H

#include <stdio.h>
#include <sundials/sundials_context.h>
#include <sundials/sundials_nvector.h>
#include <sundials/sundials_nonlinearsolver.h>
#include <cvodes/cvodes_ls.h>
#include <cvodes/cvodes_proj.h>

#ifdef __cplusplus /* wrapper to enable C++ usage */
extern "C" {
Expand Down Expand Up @@ -107,6 +109,11 @@ extern "C" {
#define CV_REPTD_QSRHSFUNC_ERR -53
#define CV_UNREC_QSRHSFUNC_ERR -54

#define CV_CONTEXT_ERR -55

#define CV_PROJ_MEM_NULL -56
#define CV_PROJFUNC_FAIL -57
#define CV_REPTD_PROJFUNC_ERR -58

#define CV_UNRECOGNIZED_ERR -99

Expand Down Expand Up @@ -136,6 +143,8 @@ typedef void (*CVErrHandlerFn)(int error_code,
const char *module, const char *function,
char *msg, void *user_data);

typedef int (*CVMonitorFn)(void *cvode_mem, void *user_data);

typedef int (*CVQuadRhsFn)(realtype t, N_Vector y,
N_Vector yQdot, void *user_data);

Expand Down Expand Up @@ -176,7 +185,7 @@ typedef int (*CVQuadRhsFnBS)(realtype t, N_Vector y, N_Vector *yS,
* --------------------------------------- */

/* Initialization functions */
SUNDIALS_EXPORT void *CVodeCreate(int lmm);
SUNDIALS_EXPORT void *CVodeCreate(int lmm, SUNContext sunctx);

SUNDIALS_EXPORT int CVodeInit(void *cvode_mem, CVRhsFn f, realtype t0,
N_Vector y0);
Expand All @@ -190,26 +199,53 @@ SUNDIALS_EXPORT int CVodeSVtolerances(void *cvode_mem, realtype reltol,
SUNDIALS_EXPORT int CVodeWFtolerances(void *cvode_mem, CVEwtFn efun);

/* Optional input functions */
SUNDIALS_EXPORT int CVodeSetErrHandlerFn(void *cvode_mem, CVErrHandlerFn ehfun,
void *eh_data);

SUNDIALS_EXPORT int CVodeSetConstraints(void *cvode_mem, N_Vector constraints);
SUNDIALS_EXPORT int CVodeSetDeltaGammaMaxLSetup(void *cvode_mem,
realtype dgmax_lsetup);
SUNDIALS_EXPORT int CVodeSetErrFile(void *cvode_mem, FILE *errfp);
SUNDIALS_EXPORT int CVodeSetUserData(void *cvode_mem, void *user_data);
SUNDIALS_EXPORT int CVodeSetMaxOrd(void *cvode_mem, int maxord);
SUNDIALS_EXPORT int CVodeSetMaxNumSteps(void *cvode_mem, long int mxsteps);
SUNDIALS_EXPORT int CVodeSetMaxHnilWarns(void *cvode_mem, int mxhnil);
SUNDIALS_EXPORT int CVodeSetStabLimDet(void *cvode_mem, booleantype stldet);
SUNDIALS_EXPORT int CVodeSetErrHandlerFn(void *cvode_mem, CVErrHandlerFn ehfun, void *eh_data);
SUNDIALS_EXPORT int CVodeSetInitStep(void *cvode_mem, realtype hin);
SUNDIALS_EXPORT int CVodeSetMinStep(void *cvode_mem, realtype hmin);
SUNDIALS_EXPORT int CVodeSetMaxStep(void *cvode_mem, realtype hmax);
SUNDIALS_EXPORT int CVodeSetStopTime(void *cvode_mem, realtype tstop);
SUNDIALS_EXPORT int CVodeSetLSetupFrequency(void *cvode_mem, long int msbp);
SUNDIALS_EXPORT int CVodeSetMaxConvFails(void *cvode_mem, int maxncf);
SUNDIALS_EXPORT int CVodeSetMaxErrTestFails(void *cvode_mem, int maxnef);
SUNDIALS_EXPORT int CVodeSetMaxHnilWarns(void *cvode_mem, int mxhnil);
SUNDIALS_EXPORT int CVodeSetMaxNonlinIters(void *cvode_mem, int maxcor);
SUNDIALS_EXPORT int CVodeSetMaxConvFails(void *cvode_mem, int maxncf);
SUNDIALS_EXPORT int CVodeSetMaxNumSteps(void *cvode_mem, long int mxsteps);
SUNDIALS_EXPORT int CVodeSetMaxOrd(void *cvode_mem, int maxord);
SUNDIALS_EXPORT int CVodeSetMaxStep(void *cvode_mem, realtype hmax);
SUNDIALS_EXPORT int CVodeSetMinStep(void *cvode_mem, realtype hmin);
SUNDIALS_EXPORT int CVodeSetMonitorFn(void *cvode_mem, CVMonitorFn fn);
SUNDIALS_EXPORT int CVodeSetMonitorFrequency(void *cvode_mem, long int nst);
SUNDIALS_EXPORT int CVodeSetNlsRhsFn(void *cvode_mem, CVRhsFn f);
SUNDIALS_EXPORT int CVodeSetNonlinConvCoef(void *cvode_mem, realtype nlscoef);
SUNDIALS_EXPORT int CVodeSetConstraints(void *cvode_mem, N_Vector constraints);
SUNDIALS_EXPORT int CVodeSetNonlinearSolver(void *cvode_mem, SUNNonlinearSolver NLS);
SUNDIALS_EXPORT int CVodeSetStabLimDet(void *cvode_mem, booleantype stldet);
SUNDIALS_EXPORT int CVodeSetStopTime(void *cvode_mem, realtype tstop);
SUNDIALS_EXPORT int CVodeSetUserData(void *cvode_mem, void *user_data);

SUNDIALS_EXPORT int CVodeSetNonlinearSolver(void *cvode_mem,
SUNNonlinearSolver NLS);
/* Optional step adaptivity input functions */
SUNDIALS_EXPORT
int CVodeSetEtaFixedStepBounds(void* cvode_mem, realtype eta_min_fx,
realtype eta_max_fx);
SUNDIALS_EXPORT
int CVodeSetEtaMaxFirstStep(void* cvode_mem, realtype eta_max_fs);
SUNDIALS_EXPORT
int CVodeSetEtaMaxEarlyStep(void* cvode_mem, realtype eta_max_es);
SUNDIALS_EXPORT
int CVodeSetNumStepsEtaMaxEarlyStep(void* cvode_mem, long int small_nst);
SUNDIALS_EXPORT
int CVodeSetEtaMax(void* cvode_mem, realtype eta_max_gs);
SUNDIALS_EXPORT
int CVodeSetEtaMin(void* cvode_mem, realtype eta_min);
SUNDIALS_EXPORT
int CVodeSetEtaMinErrFail(void *cvode_mem, realtype eta_min_ef);
SUNDIALS_EXPORT
int CVodeSetEtaMaxErrFail(void* cvode_mem, realtype eta_max_ef);
SUNDIALS_EXPORT
int CVodeSetNumFailsEtaMaxErrFail(void *cvode_mem, int small_nef);
SUNDIALS_EXPORT
int CVodeSetEtaConvFail(void* cvode_mem, realtype eta_cf);

/* Rootfinding initialization function */
SUNDIALS_EXPORT int CVodeRootInit(void *cvode_mem, int nrtfn, CVRootFn g);
Expand All @@ -222,6 +258,14 @@ SUNDIALS_EXPORT int CVodeSetNoInactiveRootWarn(void *cvode_mem);
SUNDIALS_EXPORT int CVode(void *cvode_mem, realtype tout, N_Vector yout,
realtype *tret, int itask);

/* Utility functions to update/compute y based on ycor */
SUNDIALS_EXPORT int CVodeComputeState(void *cvode_mem, N_Vector ycor,
N_Vector y);
SUNDIALS_EXPORT int CVodeComputeStateSens(void *cvode_mem, N_Vector *yScor,
N_Vector *yS);
SUNDIALS_EXPORT int CVodeComputeStateSens1(void *cvode_mem, int idx,
N_Vector yScor1, N_Vector yS1);

/* Dense output function */
SUNDIALS_EXPORT int CVodeGetDky(void *cvode_mem, realtype t, int k,
N_Vector dky);
Expand Down Expand Up @@ -259,17 +303,39 @@ SUNDIALS_EXPORT int CVodeGetIntegratorStats(void *cvode_mem, long int *nsteps,
int *qlast, int *qcur,
realtype *hinused, realtype *hlast,
realtype *hcur, realtype *tcur);
SUNDIALS_EXPORT int CVodeGetNonlinearSystemData(void *cvode_mem, realtype *tcur,
N_Vector *ypred, N_Vector *yn,
N_Vector *fn, realtype *gamma,
realtype *rl1, N_Vector *zn1,
void **user_data);
SUNDIALS_EXPORT int CVodeGetNonlinearSystemDataSens(void *cvode_mem,
realtype *tcur,
N_Vector **ySpred,
N_Vector **ySn,
realtype *gamma,
realtype *rl1,
N_Vector **zn1,
void **user_data);
SUNDIALS_EXPORT int CVodeGetNumNonlinSolvIters(void *cvode_mem,
long int *nniters);
SUNDIALS_EXPORT int CVodeGetNumNonlinSolvConvFails(void *cvode_mem,
long int *nncfails);
long int *nnfails);
SUNDIALS_EXPORT int CVodeGetNonlinSolvStats(void *cvode_mem, long int *nniters,
long int *nncfails);
long int *nnfails);
SUNDIALS_EXPORT int CVodeGetNumStepSolveFails(void *cvode_mem,
long int *nncfails);
SUNDIALS_EXPORT int CVodeGetUserData(void *cvode_mem, void **user_data);
SUNDIALS_EXPORT int CVodePrintAllStats(void *cvode_mem, FILE *outfile,
SUNOutputFormat fmt);
SUNDIALS_EXPORT char *CVodeGetReturnFlagName(long int flag);

/* Free function */
SUNDIALS_EXPORT void CVodeFree(void **cvode_mem);

/* CVLS interface function that depends on CVRhsFn */
SUNDIALS_EXPORT int CVodeSetJacTimesRhsFn(void *cvode_mem,
CVRhsFn jtimesRhsFn);


/* ---------------------------------
* Exported Functions -- Quadrature
Expand Down Expand Up @@ -372,14 +438,21 @@ SUNDIALS_EXPORT int CVodeGetSensStats(void *cvode_mem, long int *nfSevals,
SUNDIALS_EXPORT int CVodeGetSensNumNonlinSolvIters(void *cvode_mem,
long int *nSniters);
SUNDIALS_EXPORT int CVodeGetSensNumNonlinSolvConvFails(void *cvode_mem,
long int *nSncfails);
long int *nSnfails);
SUNDIALS_EXPORT int CVodeGetSensNonlinSolvStats(void *cvode_mem,
long int *nSniters,
long int *nSnfails);
SUNDIALS_EXPORT int CVodeGetNumStepSensSolveFails(void *cvode_mem,
long int *nSncfails);
SUNDIALS_EXPORT int CVodeGetStgrSensNumNonlinSolvIters(void *cvode_mem,
long int *nSTGR1niters);
SUNDIALS_EXPORT int CVodeGetStgrSensNumNonlinSolvConvFails(void *cvode_mem,
long int *nSTGR1ncfails);
SUNDIALS_EXPORT int CVodeGetSensNonlinSolvStats(void *cvode_mem,
long int *nSniters,
long int *nSncfails);
long int *nSTGR1nfails);
SUNDIALS_EXPORT int CVodeGetStgrSensNonlinSolvStats(void *cvode_mem,
long int *nSTGR1niters,
long int *nSTGR1nfails);
SUNDIALS_EXPORT int CVodeGetNumStepStgrSensSolveFails(void *cvode_mem,
long int *nSTGR1ncfails);

/* Free function */
SUNDIALS_EXPORT void CVodeSensFree(void *cvode_mem);
Expand Down Expand Up @@ -537,6 +610,9 @@ typedef struct {
SUNDIALS_EXPORT int CVodeGetAdjCheckPointsInfo(void *cvode_mem,
CVadjCheckPointRec *ckpnt);

/* CVLS interface function that depends on CVRhsFn */
int CVodeSetJacTimesRhsFnB(void *cvode_mem, int which, CVRhsFn jtimesRhsFn);


/* Undocumented Optional Output Functions For Backward Problems */

Expand Down
2 changes: 1 addition & 1 deletion inst/include/cvodes/cvodes_bandpre.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Radu Serban @ LLNL
* -----------------------------------------------------------------
* SUNDIALS Copyright Start
* Copyright (c) 2002-2019, Lawrence Livermore National Security
* Copyright (c) 2002-2022, Lawrence Livermore National Security
* and Southern Methodist University.
* All rights reserved.
*
Expand Down
2 changes: 1 addition & 1 deletion inst/include/cvodes/cvodes_bbdpre.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Radu Serban @ LLNL
* -----------------------------------------------------------------
* SUNDIALS Copyright Start
* Copyright (c) 2002-2019, Lawrence Livermore National Security
* Copyright (c) 2002-2022, Lawrence Livermore National Security
* and Southern Methodist University.
* All rights reserved.
*
Expand Down
2 changes: 1 addition & 1 deletion inst/include/cvodes/cvodes_diag.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Programmer(s): Radu Serban @ LLNL
* ---------------------------------------------------------------------
* SUNDIALS Copyright Start
* Copyright (c) 2002-2019, Lawrence Livermore National Security
* Copyright (c) 2002-2022, Lawrence Livermore National Security
* and Southern Methodist University.
* All rights reserved.
*
Expand Down
Loading

0 comments on commit e7fe561

Please sign in to comment.