Skip to content

Commit

Permalink
Updated sundials to ver 7.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sn248 committed Dec 14, 2024
1 parent a7c0a7e commit 606a761
Show file tree
Hide file tree
Showing 28 changed files with 741 additions and 89 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: sundialr
Type: Package
Title: An Interface to 'SUNDIALS' Ordinary Differential Equation (ODE) Solvers
Version: 0.1.5
Version: 0.1.6
Authors@R: c(
person("Satyaprakash", "Nayak", "", "[email protected]", c("aut", "cre","cph"), comment = c(ORCID = "0000-0001-7225-1317")),
person("Lawrence Livermore National Security", role = c("cph")),
Expand Down
3 changes: 1 addition & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
YEAR: 2020
YEAR: 2024
COPYRIGHT HOLDER: Satyaprakash Nayak
ORGANIZATION: Satyaprakash Nayak

13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,23 @@ information about `SUNDIALS` can be found [here](https://computing.llnl.gov/proj
Currently `sundialr` provides an interface to the `serial` versions of `cvode` (for solving ODES), `cvodes` (for solving ODE with sensitivity equations) and `ida` (for solving differential-algebraic equations) using the Linear Solver (dense version).

A convenience function `cvsolve` is provided which allows solving a system of equations with
multiple discontinutities in solution. An application of such a system of equations would be
multiple discontinuities in solution. An application of such a system of equations would be
to simulate the effect of multiple bolus doses of a drug in clinical pharmacokinetics. See the
vignette for more details.

## What's new?

### Release 0.1.5
## Comments for version 0.1.6
+ Updated the upstream `SUNDIALS` to version 7.2.0
+ Complete overall of the build system to use `cmake` based installation

### Comments for version 0.1.5
+ Updated the upstream `SUNDIALS` to version 7.1.1.
+ Fixed the `pkgdown` website
+ There was a bug is assigning absolute tolerance in equations. Fixed now.
+ There was a bug in assigning absolute tolerance in equations. Fixed now.

## Comments for version 0.1.4.1.2
* Fixed the issue with forwarded email address.

### Release 0.1.4.1
+ Fixed the linking bug due to multiple defined symbols. No other change.
Expand Down
16 changes: 9 additions & 7 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## Comments for version 0.1.6
+ Updated the upstream `SUNDIALS` to version 7.2.0
+ Complete overall of the build system to use `cmake` based installation

## Comments for 0.1.5
+ Updated the upstream `SUNDIALS` to version 7.1.1.
+ Fixed the `pkgdown` website
+ There was a bug in assigning absolute tolerance in equations. Fixed now.

## Comments for version 0.1.4.1.2
* Fixed the issue with forwarded email address.

Expand All @@ -19,10 +28,3 @@ There were no ERRORs or WARNINGs or NOTEs.
## Downstream dependencies
There are currently one downstream dependency for this package (CausalKinetiX)
which should be unaffected.







37 changes: 37 additions & 0 deletions inst/include/arkode/arkode.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <arkode/arkode_butcher.h>
#include <stdio.h>
#include <sundials/sundials_core.h>
#include <sundials/sundials_stepper.h>

#ifdef __cplusplus /* wrapper to enable C++ usage */
extern "C" {
Expand Down Expand Up @@ -140,6 +141,13 @@ extern "C" {

#define ARK_STEPPER_UNSUPPORTED -48

#define ARK_DOMEIG_FAIL -49
#define ARK_MAX_STAGE_LIMIT_FAIL -50

#define ARK_SUNSTEPPER_ERR -51

#define ARK_STEP_DIRECTION_ERR -52

#define ARK_UNRECOGNIZED_ERROR -99

/* ------------------------------
Expand Down Expand Up @@ -190,6 +198,18 @@ typedef enum
ARK_RELAX_NEWTON
} ARKRelaxSolver;

/* --------------------------
* Error Accumulation Options
* -------------------------- */

typedef enum
{
ARK_ACCUMERROR_NONE,
ARK_ACCUMERROR_MAX,
ARK_ACCUMERROR_SUM,
ARK_ACCUMERROR_AVG
} ARKAccumError;

/* --------------------------
* Shared API routines
* -------------------------- */
Expand All @@ -200,6 +220,10 @@ SUNDIALS_EXPORT int ARKodeResize(void* arkode_mem, N_Vector ynew,
ARKVecResizeFn resize, void* resize_data);
SUNDIALS_EXPORT int ARKodeReset(void* arkode_mem, sunrealtype tR, N_Vector yR);

/* Utility to wrap ARKODE as an MRIStepInnerStepper */
SUNDIALS_EXPORT int ARKodeCreateMRIStepInnerStepper(void* arkode_mem,
MRIStepInnerStepper* stepper);

/* Tolerance input functions */
SUNDIALS_EXPORT int ARKodeSStolerances(void* arkode_mem, sunrealtype reltol,
sunrealtype abstol);
Expand Down Expand Up @@ -228,6 +252,7 @@ SUNDIALS_EXPORT int ARKodeSetInterpolateStopTime(void* arkode_mem,
SUNDIALS_EXPORT int ARKodeSetStopTime(void* arkode_mem, sunrealtype tstop);
SUNDIALS_EXPORT int ARKodeClearStopTime(void* arkode_mem);
SUNDIALS_EXPORT int ARKodeSetFixedStep(void* arkode_mem, sunrealtype hfixed);
SUNDIALS_EXPORT int ARKodeSetStepDirection(void* arkode_mem, sunrealtype stepdir);
SUNDIALS_EXPORT int ARKodeSetUserData(void* arkode_mem, void* user_data);
SUNDIALS_EXPORT int ARKodeSetPostprocessStepFn(void* arkode_mem,
ARKPostProcessFn ProcessStep);
Expand Down Expand Up @@ -280,6 +305,9 @@ SUNDIALS_EXPORT int ARKodeSetInitStep(void* arkode_mem, sunrealtype hin);
SUNDIALS_EXPORT int ARKodeSetMinStep(void* arkode_mem, sunrealtype hmin);
SUNDIALS_EXPORT int ARKodeSetMaxStep(void* arkode_mem, sunrealtype hmax);
SUNDIALS_EXPORT int ARKodeSetMaxNumConstrFails(void* arkode_mem, int maxfails);
SUNDIALS_EXPORT int ARKodeSetAccumulatedErrorType(void* arkode_mem,
ARKAccumError accum_type);
SUNDIALS_EXPORT int ARKodeResetAccumulatedError(void* arkode_mem);

/* Integrate the ODE over an interval in t */
SUNDIALS_EXPORT int ARKodeEvolve(void* arkode_mem, sunrealtype tout,
Expand All @@ -294,13 +322,17 @@ SUNDIALS_EXPORT int ARKodeComputeState(void* arkode_mem, N_Vector zcor,
N_Vector z);

/* Optional output functions (general) */
SUNDIALS_EXPORT int ARKodeGetNumRhsEvals(void* arkode_mem, int partition_index,
long int* num_rhs_evals);
SUNDIALS_EXPORT int ARKodeGetNumStepAttempts(void* arkode_mem,
long int* step_attempts);
SUNDIALS_EXPORT int ARKodeGetWorkSpace(void* arkode_mem, long int* lenrw,
long int* leniw);
SUNDIALS_EXPORT int ARKodeGetNumSteps(void* arkode_mem, long int* nsteps);
SUNDIALS_EXPORT int ARKodeGetLastStep(void* arkode_mem, sunrealtype* hlast);
SUNDIALS_EXPORT int ARKodeGetCurrentStep(void* arkode_mem, sunrealtype* hcur);
SUNDIALS_EXPORT int ARKodeGetStepDirection(void* arkode_mem,
sunrealtype* stepdir);
SUNDIALS_EXPORT int ARKodeGetErrWeights(void* arkode_mem, N_Vector eweight);
SUNDIALS_EXPORT int ARKodeGetNumGEvals(void* arkode_mem, long int* ngevals);
SUNDIALS_EXPORT int ARKodeGetRootInfo(void* arkode_mem, int* rootsfound);
Expand All @@ -325,6 +357,8 @@ SUNDIALS_EXPORT int ARKodeGetNumConstrFails(void* arkode_mem,
SUNDIALS_EXPORT int ARKodeGetStepStats(void* arkode_mem, long int* nsteps,
sunrealtype* hinused, sunrealtype* hlast,
sunrealtype* hcur, sunrealtype* tcur);
SUNDIALS_EXPORT int ARKodeGetAccumulatedError(void* arkode_mem,
sunrealtype* accum_error);

/* Optional output functions (implicit solver) */
SUNDIALS_EXPORT int ARKodeGetNumLinSolvSetups(void* arkode_mem,
Expand Down Expand Up @@ -412,6 +446,9 @@ SUNDIALS_EXPORT int ARKodeGetNumRelaxSolveFails(void* arkode_mem,
SUNDIALS_EXPORT int ARKodeGetNumRelaxSolveIters(void* arkode_mem,
long int* iters);

/* SUNStepper functions */
SUNDIALS_EXPORT int ARKodeCreateSUNStepper(void* arkode_mem, SUNStepper* stepper);

#ifdef __cplusplus
}
#endif
Expand Down
13 changes: 6 additions & 7 deletions inst/include/arkode/arkode_arkstep.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ SUNDIALS_EXPORT int ARKStepSetTableName(void* arkode_mem, const char* itable,
const char* etable);

/* Optional output functions */
SUNDIALS_EXPORT int ARKStepGetNumRhsEvals(void* arkode_mem, long int* nfe_evals,
long int* nfi_evals);
SUNDIALS_EXPORT int ARKStepGetCurrentButcherTables(void* arkode_mem,
ARKodeButcherTable* Bi,
ARKodeButcherTable* Be);
Expand All @@ -96,14 +94,13 @@ SUNDIALS_EXPORT int ARKStepGetTimestepperStats(
long int* step_attempts, long int* nfe_evals, long int* nfi_evals,
long int* nlinsetups, long int* netfails);

/* MRIStep interface functions */
SUNDIALS_EXPORT int ARKStepCreateMRIStepInnerStepper(void* arkode_mem,
MRIStepInnerStepper* stepper);

/* --------------------------------------------------------------------------
* Deprecated Functions -- all are superseded by shared ARKODE-level routines
* -------------------------------------------------------------------------- */

SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeCreateMRIStepInnerStepper instead")
int ARKStepCreateMRIStepInnerStepper(void* arkode_mem,
MRIStepInnerStepper* stepper);
SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeResize instead")
int ARKStepResize(void* arkode_mem, N_Vector ynew, sunrealtype hscale,
sunrealtype t0, ARKVecResizeFn resize, void* resize_data);
Expand Down Expand Up @@ -430,7 +427,9 @@ SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumRelaxSolveFails instead")
int ARKStepGetNumRelaxSolveFails(void* arkode_mem, long int* fails);
SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumRelaxSolveIters instead")
int ARKStepGetNumRelaxSolveIters(void* arkode_mem, long int* iters);

SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumRhsEvals instead")
int ARKStepGetNumRhsEvals(void* arkode_mem, long int* nfe_evals,
long int* nfi_evals);
#ifdef __cplusplus
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion inst/include/arkode/arkode_bandpre.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
extern "C" {
#endif

/* BandPrec inititialization function */
/* BandPrec initialization function */

SUNDIALS_EXPORT int ARKBandPrecInit(void* arkode_mem, sunindextype N,
sunindextype mu, sunindextype ml);
Expand Down
33 changes: 17 additions & 16 deletions inst/include/arkode/arkode_erkstep.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ SUNDIALS_EXPORT int ERKStepSetTableNum(void* arkode_mem,
SUNDIALS_EXPORT int ERKStepSetTableName(void* arkode_mem, const char* etable);

/* Optional output functions */
SUNDIALS_EXPORT int ERKStepGetNumRhsEvals(void* arkode_mem, long int* nfevals);
SUNDIALS_EXPORT int ERKStepGetCurrentButcherTable(void* arkode_mem,
ARKodeButcherTable* B);

Expand Down Expand Up @@ -109,7 +108,7 @@ SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMaxGrowth instead")
int ERKStepSetMaxGrowth(void* arkode_mem, sunrealtype mx_growth);
SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMinReduction instead")
int ERKStepSetMinReduction(void* arkode_mem, sunrealtype eta_min);
SUNDIALS_DEPRECATED_EXPORT_MSG("use ERKStepSetFiARKodeBounds instead")
SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetFixedStepBounds instead")
int ERKStepSetFixedStepBounds(void* arkode_mem, sunrealtype lb, sunrealtype ub);
SUNDIALS_DEPRECATED_EXPORT_MSG("use SUNAdaptController instead")
int ERKStepSetAdaptivityMethod(void* arkode_mem, int imethod, int idefault,
Expand All @@ -128,23 +127,23 @@ SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMaxErrTestFails instead")
int ERKStepSetMaxErrTestFails(void* arkode_mem, int maxnef);
SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetConstraints instead")
int ERKStepSetConstraints(void* arkode_mem, N_Vector constraints);
SUNDIALS_DEPRECATED_EXPORT_MSG("use ERKStepSetMaxARKodes instead")
SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMaxNumSteps instead")
int ERKStepSetMaxNumSteps(void* arkode_mem, long int mxsteps);
SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMaxHnilWarns instead")
int ERKStepSetMaxHnilWarns(void* arkode_mem, int mxhnil);
SUNDIALS_DEPRECATED_EXPORT_MSG("use ERKStepSetIARKode instead")
SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetInitStep instead")
int ERKStepSetInitStep(void* arkode_mem, sunrealtype hin);
SUNDIALS_DEPRECATED_EXPORT_MSG("use ERKStepSetARKode instead")
SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMinStep instead")
int ERKStepSetMinStep(void* arkode_mem, sunrealtype hmin);
SUNDIALS_DEPRECATED_EXPORT_MSG("use ERKStepSetARKode instead")
SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMaxStep instead")
int ERKStepSetMaxStep(void* arkode_mem, sunrealtype hmax);
SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetInterpolateStopTime instead")
int ERKStepSetInterpolateStopTime(void* arkode_mem, sunbooleantype interp);
SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetStopTime instead")
int ERKStepSetStopTime(void* arkode_mem, sunrealtype tstop);
SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeClearStopTime instead")
int ERKStepClearStopTime(void* arkode_mem);
SUNDIALS_DEPRECATED_EXPORT_MSG("use ERKStepSetFiARKode instead")
SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetFixedStep instead")
int ERKStepSetFixedStep(void* arkode_mem, sunrealtype hfixed);
SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetMaxNumConstrFails instead")
int ERKStepSetMaxNumConstrFails(void* arkode_mem, int maxfails);
Expand All @@ -154,7 +153,7 @@ SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetNoInactiveRootWarn instead")
int ERKStepSetNoInactiveRootWarn(void* arkode_mem);
SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetUserData instead")
int ERKStepSetUserData(void* arkode_mem, void* user_data);
SUNDIALS_DEPRECATED_EXPORT_MSG("use ERKStepSetPostprocARKodeFn instead")
SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetPostprocessStepFn instead")
int ERKStepSetPostprocessStepFn(void* arkode_mem, ARKPostProcessFn ProcessStep);
SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeSetPostprocessStageFn instead")
int ERKStepSetPostprocessStageFn(void* arkode_mem, ARKPostProcessFn ProcessStage);
Expand All @@ -163,25 +162,25 @@ int ERKStepEvolve(void* arkode_mem, sunrealtype tout, N_Vector yout,
sunrealtype* tret, int itask);
SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetDky instead")
int ERKStepGetDky(void* arkode_mem, sunrealtype t, int k, N_Vector dky);
SUNDIALS_DEPRECATED_EXPORT_MSG("use ERKStepGetNumARKodes instead")
SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumExpSteps instead")
int ERKStepGetNumExpSteps(void* arkode_mem, long int* expsteps);
SUNDIALS_DEPRECATED_EXPORT_MSG("use ERKStepGetNumARKodes instead")
SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumAccSteps instead")
int ERKStepGetNumAccSteps(void* arkode_mem, long int* accsteps);
SUNDIALS_DEPRECATED_EXPORT_MSG("use ERKStepGetARKodeAttempts instead")
SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumStepAttempts instead")
int ERKStepGetNumStepAttempts(void* arkode_mem, long int* step_attempts);
SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumErrTestFails instead")
int ERKStepGetNumErrTestFails(void* arkode_mem, long int* netfails);
SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetEstLocalErrors instead")
int ERKStepGetEstLocalErrors(void* arkode_mem, N_Vector ele);
SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetWorkSpace instead")
int ERKStepGetWorkSpace(void* arkode_mem, long int* lenrw, long int* leniw);
SUNDIALS_DEPRECATED_EXPORT_MSG("use ERKStepGetARKodes instead")
SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumSteps instead")
int ERKStepGetNumSteps(void* arkode_mem, long int* nsteps);
SUNDIALS_DEPRECATED_EXPORT_MSG("use ERKStepGetActualIARKode instead")
SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetActualInitStep instead")
int ERKStepGetActualInitStep(void* arkode_mem, sunrealtype* hinused);
SUNDIALS_DEPRECATED_EXPORT_MSG("use ERKStepGetLARKode instead")
SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetLastStep instead")
int ERKStepGetLastStep(void* arkode_mem, sunrealtype* hlast);
SUNDIALS_DEPRECATED_EXPORT_MSG("use ERKStepGetCurrARKode instead")
SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetCurrentStep instead")
int ERKStepGetCurrentStep(void* arkode_mem, sunrealtype* hcur);
SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetCurrentTime instead")
int ERKStepGetCurrentTime(void* arkode_mem, sunrealtype* tcur);
Expand All @@ -206,7 +205,7 @@ int ERKStepWriteParameters(void* arkode_mem, FILE* fp);
SUNDIALS_DEPRECATED_EXPORT_MSG(
"use ERKStepGetCurrentButcherTable and ARKodeButcherTable_Write instead")
int ERKStepWriteButcher(void* arkode_mem, FILE* fp);
SUNDIALS_DEPRECATED_EXPORT_MSG("use ERKStepARKodeStats instead")
SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetStepStats instead")
int ERKStepGetStepStats(void* arkode_mem, long int* nsteps, sunrealtype* hinused,
sunrealtype* hlast, sunrealtype* hcur, sunrealtype* tcur);
SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeFree instead")
Expand Down Expand Up @@ -244,6 +243,8 @@ SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumRelaxSolveFails instead")
int ERKStepGetNumRelaxSolveFails(void* arkode_mem, long int* fails);
SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumRelaxSolveIters instead")
int ERKStepGetNumRelaxSolveIters(void* arkode_mem, long int* iters);
SUNDIALS_DEPRECATED_EXPORT_MSG("use ARKodeGetNumRhsEvals instead")
int ERKStepGetNumRhsEvals(void* arkode_mem, long int* nfevals);

#ifdef __cplusplus
}
Expand Down
43 changes: 43 additions & 0 deletions inst/include/arkode/arkode_forcingstep.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*---------------------------------------------------------------
* Programmer(s): Steven B. Roberts @ LLNL
*---------------------------------------------------------------
* SUNDIALS Copyright Start
* Copyright (c) 2002-2024, Lawrence Livermore National Security
* and Southern Methodist University.
* All rights reserved.
*
* See the top-level LICENSE and NOTICE files for details.
*
* SPDX-License-Identifier: BSD-3-Clause
* SUNDIALS Copyright End
*---------------------------------------------------------------
* This is the header file for the ARKODE ForcingStep module.
*--------------------------------------------------------------*/

#ifndef ARKODE_FORCINGINGSTEP_H_
#define ARKODE_FORCINGINGSTEP_H_

#include <sundials/sundials_nvector.h>
#include <sundials/sundials_stepper.h>
#include <sundials/sundials_types.h>

#ifdef __cplusplus /* wrapper to enable C++ usage */
extern "C" {
#endif

SUNDIALS_EXPORT void* ForcingStepCreate(SUNStepper stepper1,
SUNStepper stepper2, sunrealtype t0,
N_Vector y0, SUNContext sunctx);

SUNDIALS_EXPORT int ForcingStepReInit(void* arkode_mem, SUNStepper stepper1,
SUNStepper stepper2, sunrealtype t0,
N_Vector y0);

SUNDIALS_EXPORT int ForcingStepGetNumEvolves(void* arkode_mem, int partition,
long int* evolves);

#ifdef __cplusplus
}
#endif

#endif
Loading

0 comments on commit 606a761

Please sign in to comment.