From 60e8619087527c56d2cc3e3512d8904be53adb49 Mon Sep 17 00:00:00 2001 From: sn248 Date: Sun, 16 May 2021 19:59:22 -0400 Subject: [PATCH] Version 0.4.1 Fixed the bug in linking related to multiple definitions. Removed Makevars.win as it is identical to Makevars. Removed files related to fortran and non-essential text files in Sundials source code. --- DESCRIPTION | 7 +- NEWS | 5 + R/zzz.R | 2 +- README.md | 2 + cran-comments.md | 4 + docs/articles/my-vignette.html | 459 ------------- docs/index.html | 177 ----- src/Makevars | 27 +- src/Makevars.win | 97 --- src/sundials/cvode/CMakeLists.txt | 149 ----- src/sundials/cvode/LICENSE | 29 - src/sundials/cvode/NOTICE | 21 - src/sundials/cvode/README.md | 60 -- src/sundials/cvodes/CMakeLists.txt | 156 ----- src/sundials/ida/CMakeLists.txt | 147 ----- src/sundials/ida/LICENSE | 29 - src/sundials/ida/NOTICE | 21 - src/sundials/ida/README.md | 64 -- src/sundials/nvector/serial/CMakeLists.txt | 105 --- src/sundials/nvector/serial/fnvector_serial.c | 154 ----- src/sundials/nvector/serial/fnvector_serial.h | 92 --- src/sundials/sundials/CMakeLists.txt | 94 --- src/sundials/sundials/sundials_futils.c | 29 - src/sundials/sunlinsol/band/CMakeLists.txt | 141 ---- src/sundials/sunlinsol/band/fsunlinsol_band.c | 96 --- src/sundials/sunlinsol/band/fsunlinsol_band.h | 62 -- src/sundials/sunlinsol/dense/CMakeLists.txt | 141 ---- .../sunlinsol/dense/fsunlinsol_dense.c | 96 --- .../sunlinsol/dense/fsunlinsol_dense.h | 62 -- src/sundials/sunmatrix/band/CMakeLists.txt | 106 --- src/sundials/sunmatrix/band/fsunmatrix_band.c | 90 --- src/sundials/sunmatrix/band/fsunmatrix_band.h | 62 -- src/sundials/sunmatrix/dense/CMakeLists.txt | 107 --- .../sunmatrix/dense/fsunmatrix_dense.c | 83 --- .../sunmatrix/dense/fsunmatrix_dense.h | 62 -- src/sundials/sunnonlinsol/CMakeLists.txt | 23 - .../sunnonlinsol/fixedpoint/CMakeLists.txt | 108 --- .../fixedpoint/fsunnonlinsol_fixedpoint.c | 95 --- .../fixedpoint/fsunnonlinsol_fixedpoint.h | 56 -- .../sunnonlinsol/newton/CMakeLists.txt | 109 ---- .../newton/fsunnonlinsol_newton.c | 95 --- .../newton/fsunnonlinsol_newton.h | 56 -- vignettes/my-vignette.Rmd | 6 +- vignettes/my-vignette.html | 614 +++++++----------- 44 files changed, 248 insertions(+), 3952 deletions(-) delete mode 100644 docs/articles/my-vignette.html delete mode 100644 docs/index.html delete mode 100644 src/Makevars.win delete mode 100644 src/sundials/cvode/CMakeLists.txt delete mode 100644 src/sundials/cvode/LICENSE delete mode 100644 src/sundials/cvode/NOTICE delete mode 100644 src/sundials/cvode/README.md delete mode 100644 src/sundials/cvodes/CMakeLists.txt delete mode 100644 src/sundials/ida/CMakeLists.txt delete mode 100644 src/sundials/ida/LICENSE delete mode 100644 src/sundials/ida/NOTICE delete mode 100644 src/sundials/ida/README.md delete mode 100644 src/sundials/nvector/serial/CMakeLists.txt delete mode 100644 src/sundials/nvector/serial/fnvector_serial.c delete mode 100644 src/sundials/nvector/serial/fnvector_serial.h delete mode 100644 src/sundials/sundials/CMakeLists.txt delete mode 100644 src/sundials/sundials/sundials_futils.c delete mode 100644 src/sundials/sunlinsol/band/CMakeLists.txt delete mode 100644 src/sundials/sunlinsol/band/fsunlinsol_band.c delete mode 100644 src/sundials/sunlinsol/band/fsunlinsol_band.h delete mode 100644 src/sundials/sunlinsol/dense/CMakeLists.txt delete mode 100644 src/sundials/sunlinsol/dense/fsunlinsol_dense.c delete mode 100644 src/sundials/sunlinsol/dense/fsunlinsol_dense.h delete mode 100644 src/sundials/sunmatrix/band/CMakeLists.txt delete mode 100644 src/sundials/sunmatrix/band/fsunmatrix_band.c delete mode 100644 src/sundials/sunmatrix/band/fsunmatrix_band.h delete mode 100644 src/sundials/sunmatrix/dense/CMakeLists.txt delete mode 100644 src/sundials/sunmatrix/dense/fsunmatrix_dense.c delete mode 100644 src/sundials/sunmatrix/dense/fsunmatrix_dense.h delete mode 100644 src/sundials/sunnonlinsol/CMakeLists.txt delete mode 100644 src/sundials/sunnonlinsol/fixedpoint/CMakeLists.txt delete mode 100644 src/sundials/sunnonlinsol/fixedpoint/fsunnonlinsol_fixedpoint.c delete mode 100644 src/sundials/sunnonlinsol/fixedpoint/fsunnonlinsol_fixedpoint.h delete mode 100644 src/sundials/sunnonlinsol/newton/CMakeLists.txt delete mode 100644 src/sundials/sunnonlinsol/newton/fsunnonlinsol_newton.c delete mode 100644 src/sundials/sunnonlinsol/newton/fsunnonlinsol_newton.h diff --git a/DESCRIPTION b/DESCRIPTION index bf2c7ab..628d3dc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: sundialr Type: Package Title: An Interface to 'SUNDIALS' Ordinary Differential Equation (ODE) Solvers -Version: 0.1.4 +Version: 0.1.4.1 Authors@R: c( person("Satyaprakash", "Nayak", "", "sn248@cornell.edu", c("aut", "cre","cph"), comment = c(ORCID = "0000-0001-7225-1317")), person("Lawrence Livermore National Security", role = c("cph")), @@ -10,15 +10,14 @@ Authors@R: c( Maintainer: Satyaprakash Nayak URL: https://github.com/sn248/sundialr BugReports: https://github.com/sn248/sundialr/issues -Description: Provides a way to call the functions in 'SUNDIALS' C ODE solving library (). Currently the serial version of ODE solver, 'CVODE', sensitivity calculator 'CVODES' and differential algebraic solver 'IDA' from the 'SUNDIALS' library are implemented. The package requires ODE to be written as an 'R' or 'Rcpp' function and does not require the 'SUNDIALS' library to be installed on the local machine. +Description: Provides a way to call the functions in 'SUNDIALS' C ODE solving library (). Currently the serial version of ODE solver, 'CVODE', sensitivity calculator 'CVODES' and differential algebraic solver 'IDA' from the 'SUNDIALS' library are implemented. The package requires ODE to be written as an 'R' or 'Rcpp' function and does not require the 'SUNDIALS' library to be installed on the local machine. License: BSD_3_clause + file LICENSE Copyright: file COPYRIGHTS -LazyData: TRUE Imports: Rcpp (>= 0.12.5) LinkingTo: Rcpp, RcppArmadillo -RoxygenNote: 7.1.0 +RoxygenNote: 7.1.1 Suggests: knitr, rmarkdown, diff --git a/NEWS b/NEWS index 612395e..0a1fff3 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,8 @@ +sundialr v0.1.4.1 +================ +Bug fixex: +* Fixed the linking problem due to multiple defined sybmols + sundialr v0.1.4 ================ diff --git a/R/zzz.R b/R/zzz.R index 2bb1182..1e01369 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -1,4 +1,4 @@ .onAttach <- function(...){ packageStartupMessage( - "SUNDIALS - Copyright (c) 2002-2020, Lawrence Livermore National Security and Southern Methodist University.\nAll rights reserved.\nSee - https://computation.llnl.gov/projects/sundials\nsundialr - https://github.com/sn248/sundialr") + "SUNDIALS - Copyright (c) 2002-2020, Lawrence Livermore National Security and Southern Methodist University.\nAll rights reserved.") } diff --git a/README.md b/README.md index 68df758..416afbb 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,8 @@ to simulate the effect of multiple bolus doses of a drug in clinical pharmacokin vignette for more details. ## What's new? +### Release 0.1.4.1 ++ Fixed the linking bug due to multiple defined symbols. No other change. ### Release 0.1.4 + This version has version 5.2.0 of `SUNDIALS` (released in March 2020) at the back end. diff --git a/cran-comments.md b/cran-comments.md index 6963fa9..a787232 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,3 +1,7 @@ +## Comments for version 0.1.4.1 +* Fixed the problem with linking due to multiple definitions. The downstream +dependency should be unaffected by this change. + ## Comments for version 0.1.4 ## Test environments diff --git a/docs/articles/my-vignette.html b/docs/articles/my-vignette.html deleted file mode 100644 index b535152..0000000 --- a/docs/articles/my-vignette.html +++ /dev/null @@ -1,459 +0,0 @@ - - - - - - - -sundialr - An Interface to 'SUNDIALS' Ordinary Differential Equation (ODE) Solvers • sundialr - - - - - - - - - - -
-
- - - - -
-
- - - - -
-

-Introduction

-

Ordinary Differential Equations (ODEs) describe the rate of change of dependent variables with respect to a single independent variable and are used in many fields to model behavior of the system. There are many good C libraries available to solve (i.e., integrate systems of ODEs) and SUNDIALS available from the Lawrence Livermore National Laboratory is a one of the most popular and well-respected C library for solving non-stiff and stiff systems of ODEs.

-

Currently, this package provides an interface to the CVODE and CVODES function (serial version) in the library which is used to solve ODEs (or Initial Value Problems) and calculate sensitivities.

-

The four exported functions from the package are:

-
    -
  • cvode - An interface to the CVODE function in SUNDIALS to solve a system of ODEs.

  • -
  • cvodes - An interface to the CVODES function in SUNDIALS to calculate forward sensitivites with respect to parameters of the ODE system.

  • -
  • ida - An interface to the IDA function in SUNDIALS to solve a system of Differential-Algebraic Equations (DAEs).

  • -
  • cvsolve - A convenient interface to solve a system of ODEs with discontinuities in solution.

  • -
-

In future, we plan to provide interface for the other solvers (i.e., IDA/IDAS and ARCODE in the library also. Right now, this package serves as a test case for providing an interface to the SUNDIALS library for R users.

-

One of the advantage of using this package is that all the source code of the SUNDIALS library is bundled with the package itself, so it does not require the SUNDIALS library to be installed on the machine separately (which is sometimes non trivial on a Windows machine).

-
-
-

-System of ODEs

-

As described in the link above, the problem is from chemical kinetics, and consists of the following three rate equations:

-

\[ -\begin{aligned} -\frac{dy_1}{dt} &= -.04 \times y_1 + 10^4 \times y_2 \times y_3 \\ -\frac{dy_2}{dt} &= .04 \times y_1 - 10^4 \times y_2 \times y_3 - 3 \times 10^7 \times y_2^2 \\ -\frac{dy_3}{dt} &= 3 \times 10^7 \times y_2^2 -\end{aligned} -\]

-

with time interval from \(t = 0.0\) to \(t = 4 \times 10^{10}\) and initial conditions: \[ y_1 = 1.0 , ~y_2 = y_3 = 0 \]

-

The problem is stiff.

-

The original example , While integrating the system, also uses the rootfinding feature to find the points at which

-

\[ y_1 = 1 \times 10^{-4} \] or at which \[ y_3 = 0.01 \] but currently root-finding is not supported in this version. As in the original example, this package also solves the problem with the BDF method, Newton iteration with the SUNDENSE dense linear solver, however, without a user-supplied Jacobian routine (unlike the original example). The future versions may include an ability to provide Jacobian calculated analytically or via automatic differentiation. CVODE uses a scalar relative tolerance and a vector absolute tolerance (which can be provided as an input). Output is printed in decades from \(t = 0.4\) to \(t = 4 \times 10^{10}\) in this example.

-
-
-

-Writing the Differential Equations

-
-

-Using R

-

Differential equations can be written as an R function or as an Rcpp function. Differential equations function must be written as

-
function(t, y, p){
-  # code to write differential equations
-  # using parameter vector (p) and state/entity vector (y)
-  # should return `ydot`, the vector representing
-  # rate of change of entities in `y`
-  # length of `ydot` must be equal to `y1
-}
-

where t represents time, y is the vector describing the values of states/entities of the ODE system at time t and p is the vector of parameters used to define the ODEs. The output of this function is a vector of rate of change of entities of y.

-

The key aspect to keep in mind is that the signature of the function must be function(t,y,p). As an example, we try to solve the cv_Roberts_dns.c problem described above, the original code can be found here. An example of an R function is as follows:

-
ODE_R <- function(t, y, p){
-
-   ## initialize the derivative vector
-   ydot <- vector(mode = "numeric", length = length(y))
-
-   ## p (parameter vector input) is  [-0.04 1e04 3e07]
-
-   ydot[1] = p[1]*y[1] + p[2]*y[2]*y[3]
-   ydot[2] = -p[1]*y[1] - p[2]*y[2]*y[3] - p[3]*y[2]*y[2]
-   ydot[3] = p[3]*y[2]*y[2]
-
-   ydot      ## return ydot
-}
-

where p is a parameter vector with the values [-0.04 1e04 3e07].

-
-
-

-Using Rcpp

-

Also, since this package using Rcpp to bundle the C code, we can use the notation used in Rcpp to describe the system of ODEs. The cv_Roberts_dns problem describe above can be described in an Rcpp function as follows (indices in C++ start from 0, functions need to declare their return type, here NumericVector and every expression ends in a semicolon, ;) :

-
#include <Rcpp.h>
-using namespace Rcpp;
-
-// [[Rcpp::export]]
-NumericVector ODE_Rcpp (double t, NumericVector y){
-
-  // Initialize ydot filled with zeros
-  NumericVector ydot(y.length());
-
-  // p (parameter vector) is [-0.04 1e04 3e07]
-  ydot[0] = p[0] * y[0] + p[1] * y[1] * y[2];
-  ydot[1] = -p[0]*y[0] - p[1]*y[1]*y[2] - p[2]*y[1]*y[1]
-  ydot[2] = p[2] * y[1] * y[1];
-
-  return ydot;
-
-}
-

The above is a re-write of the cvRoberts_dns.c example in the documentation of CVODE. The original example can be found the document here.

-
-
-

-Putting everything together

-

The entire R file to create right hand side of ODE function (which calculates rates of change) is as follows (also found here):

-
# ODEs described by an R function
-ODE_R <- function(t, y, p){
-
-   ## initialize the derivative vector
-   ydot <- vector(mode = "numeric", length = length(y))
-
-   ## p (parameter vector) is  [-0.04 1e04 3e07]
-
-   ydot[1] = p[1]*y[1] + p[2]*y[2]*y[3]
-   ydot[2] = -p[1]*y[1] - p[2]*y[2]*y[3] - p[3]*y[2]*y[2]
-   ydot[3] = p[3]*y[2]*y[2]
-
-   ydot      ## return ydot
-}
-
-# ODEs can also be described using Rcpp
-Rcpp::sourceCpp(code = '
-
-#include <Rcpp.h>
-using namespace Rcpp;
-
-// [[Rcpp::export]]
-NumericVector ODE_Rcpp (double t, NumericVector y){
-
-  // Initialize ydot filled with zeros
-  NumericVector ydot(y.length());
-
-  // p (parameter vector) is [-0.04 1e04 3e07]
-  ydot[0] = p[0] * y[0] + p[1] * y[1] * y[2];
-  ydot[1] = -p[0]*y[0] - p[1]*y[1]*y[2] - p[2]*y[1]*y[1]
-  ydot[2] = p[2] * y[1] * y[1];
-
-  return ydot;
-
-}')
-
-# Generate time vector, IC and call cvode to solve the equations
-# R code to genrate time vector, IC and solve the equations
-time_vec <- c(0.0, 0.4, 4.0, 40.0, 4E2, 4E3, 4E4, 4E5, 4E6, 4E7, 4E8, 4E9, 4E10)
-IC <- c(1,0,0)
-params <- c(0.04, 10000, 30000000)
-reltol <- 1e-04
-abstol <- c(1e-8,1e-14,1e-6)
-
-## Solving the ODEs using cvode function
-df1 <- cvode(time_vec, IC, ODE_R , params, reltol, abstol)           ## using R
-df2 <- cvode(time_vec, IC, ODE_Rcpp , params, reltol, abstol)        ## using Rcpp
-
-## Check that both solutions are identical
-# identical(df1, df2)
-

The final output is the df1 matrix in which first column is time, second, third and fourth column are the values of y1, y2 and y3 respectively.

-
> df1
-       [,1]         [,2]         [,3]       [,4]
- [1,] 0e+00 1.000000e+00 0.000000e+00 0.00000000
- [2,] 4e-01 9.851641e-01 3.386242e-05 0.01480205
- [3,] 4e+00 9.055097e-01 2.240338e-05 0.09446793
- [4,] 4e+01 7.158016e-01 9.185043e-06 0.28418924
- [5,] 4e+02 4.505209e-01 3.222826e-06 0.54947590
- [6,] 4e+03 1.832217e-01 8.943516e-07 0.81677741
- [7,] 4e+04 3.898091e-02 1.621669e-07 0.96101893
- [8,] 4e+05 4.936971e-03 1.984450e-08 0.99506301
- [9,] 4e+06 5.170103e-04 2.069098e-09 0.99948299
-[10,] 4e+07 5.204927e-05 2.082078e-10 0.99994795
-[11,] 4e+08 5.184946e-06 2.073989e-11 0.99999482
-[12,] 4e+09 5.246212e-07 2.098486e-12 0.99999948
-[13,] 4e+10 6.043000e-08 2.417200e-13 0.99999994
-
-
-
-

-Solving a system of Differential-Algebraic Equations

-

An interface to the IDA solver is also provided to solve a system of Differential-Algebraic equations. A system of differential-algebraic equations is a system of equations containing both differential and algebraic equations and can be written as \[ -F(\dot{x}(t), x(t), t) = 0 -\] The equations for such a system are written in terms of residuals and require both the value of \(x_0\) and \(\dot{x}_0\) as the initial conditions. Writing the previously solved equations as a system of DAEs, we have, \[ -\begin{aligned} -\dot{y}_1 &= -p_1y_1 + p_2y_2y_3 \\ -\dot{y}_2 &= p_1y_1 - p_2y_2y_3 - p_3y_2^2 \\ -1 &= y_1 + y_2 + y_3 -\end{aligned} -\] The above system of DAEs can be written in terms of residuals as

-

\[ -\begin{aligned} -res_1 &= -p_1y_1 + p_2y_2y_3 - \dot{y}_1 \\ -res_2 &= p_1y_1 - p_2y_2y_3 - p_3y_2^2 - \dot{y}_2\\ -res_3 &= y_1 + y_2 + y_3 - 1 -\end{aligned} -\] Here is the complete code for solving this system of DAEs,

-
DAE_R <- function(t, y, ydot, p){
-
-  # vector containing the residuals
-  res = vector(mode = "numeric", length = length(y))
-
-  # R indices start from 1
-  res[1] <- -0.04 * y[1] + 10000 * y[2] * y[3] - ydot[1]
-  res[2] <- -res[1] - 30000000 * y[2] * y[2] - ydot[2]
-  res[3] <- y[1] + y[2] + y[3] - 1.0
-
-  res
-}
-
-# R code to genrate time vector, IC and solve the equations
-time_vec <- c(0.0, 0.4, 4.0, 40.0, 4E2, 4E3, 4E4, 4E5, 4E6, 4E7, 4E8, 4E9, 4E10)
-IC <- c(1,0,0)                  # Initial value of y
-IRes <- c(-0.4, 0.4, 0)         # Initial value of ydot
-params <- c(0.04, 10000, 30000000)
-reltol <- 1e-04
-abstol <- c(1e-8,1e-14,1e-6)
-
-## Solving the DAEs using the ida function
-df1 <- sundialr::ida(time_vec, IC, IRes, DAE_R , params, reltol, abstol)
-
-
-

-Solving an ODE system with discontinuties in solution

-

The cvsolve function defined in sundialr package provides a convenience interface to solve ODEs with one or more discontinuities in solution. An example of such a system of ODEs would be pharmacokinetics of a drug with repeated bolus administration. Let’s look at a simple example of multiple doses of a drug with a first-order degradation administered intravenously. The ODE system for the drug is \[ -\frac{dC}{dt} = -k_{el} * C -\] where \(C\) is the concentration of the drug and \(k_{el}\) is the elimination rate of the drug. The \(R\) code for such a system is

-
ODErepeated_R <- function(t, y, p){
-
-  # vector containing the right hand side gradients
-  ydot = vector(mode = "numeric", length = length(y))
-
-  # R indices start from 1
-  ydot[1] = -p[1]*y[1]
-
-  ydot
-
-}
-

We also need to define when the multiple doses are given and the state to which they are to be applied (here to be applied to the only state in the model, \(C\)). This is provided via the \(Events\) dataframe (here, \(TDOSE\) or the dosing dataframe).

-
TDOSE <- data.frame(ID = 1, TIMES = c(0, 10, 20, 30, 40, 50), VAL = 100)
-TDOSE
-#>   ID TIMES VAL
-#> 1  1     0 100
-#> 2  1    10 100
-#> 3  1    20 100
-#> 4  1    30 100
-#> 5  1    40 100
-#> 6  1    50 100
-

TDOSE is a data frame with the index of the state to which discontinuity is to be applied (represented by ID), the times at which the discontinuity is to be applied (represented by TIMES) at the value to be added to the value of the state at that time-point. A typical example would be addition of the dose amount to the value of the concentration at the specified times, e.g., the TDOSE data frame says that a value of 100 is to be added to the concentration of the 1st state (the only state in this system) at the times specified by the TIMES column. In summary,

-
    -
  • ID represents the index of the state with discontinuity

  • -
  • TIMES represents the times at which discontinutiy is applied

  • -
  • VAL represents the value added to the value of the state at specified times.

  • -
-

The complete code for simulating such a system is

-
# Example of solving a set of ODEs with multiple discontinuities using cvsolve
-# A simple One dimensional equation, y = -0.1 * y
-# ODEs described by an R function
-ODE_R <- function(t, y, p){
-
-  # vector containing the right hand side gradients
-  ydot = vector(mode = "numeric", length = length(y))
-
-  # R indices start from 1
-  ydot[1] = -p[1]*y[1]
-
-  ydot
-
-}
-
-# R code to generate time vector, IC and solve the equations
-TSAMP <- seq(from = 0, to = 100, by = 0.1)      # sampling time points
-IC <- c(1)
-params <- c(0.1)
-
-# A dataset describing the dosing at times at which additions to y[1] are to be done
-# Names of the columns don't matter, but they MUST be in the order of state index,
-# times and Values at discontinuity.
-TDOSE <- data.frame(ID = 1, TIMES = c(0, 10, 20, 30, 40, 50), VAL = 100)
-
-df1 <- sundialr::cvsolve(TSAMP, c(1), ODE_R, params)         # solving without any discontinuity
-df2 <- sundialr::cvsolve(TSAMP, c(1), ODE_R, params, TDOSE)  # solving with discontinuity
-
-## Plot the solution with discontinuities
-## first column is time, second column is the state
-time <- df2[,1]
-y1 <- df2[,2]
-plot(time, y1, type = "l", lty = 1, main = "An ODE system with discontinuties", frame.plot = F)
-

-

Note that in the example above, TSAMP is the sampling time at which the solution is desired. Also, even though an Initial Value of \(y_1\) of 1 is provided by the IC parameter, it is overwritten by the value of 100 provided in the TDOSE data frame. In general, the values in the initial conditions are overwritten by values in the Events input.

-
-
-

-System of ODEs for Parameter Sensitivities

-

Sensitivity with respect to the parameters of the ODE system can be calculated using CVODES function. This package implements Forward Sensitivity Analysis from CVODES function (see the example cvRoberts_FSA_dns.c from the link here). Briefly, given the ODE system as described below

-

\[ -\begin{aligned} -\frac{dy_1}{dt} &= -p_1y_1 + p_2y_2y_3 \\ -\frac{dy_2}{dt} &= p_1y_1 - p_2y_2y_3 - p_3y_2^2 \\ -\frac{dy_3}{dt} &= p_3y_2^2 -\end{aligned} -\] with the same initial conditions as above (i.e., \(y_1 = 0, y_2 = y_3 = 0\)) and \(p_1 = 0.04, \quad p_2 = 10^4, \quad p_3 = 3\times10^7\). The system of Sensitivity equations (taken from cvs_guide.pdf) that is solved can be given by \[ -\begin{aligned} -\frac{ds}{dt} = -\left[\begin{array} -{ccc} --p_1 & p_2y_3 & p_2y_2 \\ -p_1 & -p_2y_3-2p_3y_2 & -p_2y_2 \\ -0 & 2p_3y_2 & 0 -\end{array}\right]s_i + \frac{\partial f}{\partial p_i}, -\quad s_i(t_0) = -\left[\begin{array} {c} 0 \\ 0 \\ 0 \end{array}\right], \quad i = 1, 2, 3 -\end{aligned} -\] where \[ -\frac{\partial f}{\partial p_1} = \left[\begin{array} {c} -y_1 \\ y_1 \\ 0 \end{array}\right], -\quad \frac{\partial f}{\partial p_2} = \left[\begin{array} {c} y_2y_3 \\ -y_2y_3 \\ 0 \end{array}\right], -\quad -\frac{\partial f}{\partial p_3} = \left[\begin{array} {c} 0 \\ -y_2^2 \\ y_2^2 \end{array}\right] -\] In the original CVODES interface from SUNDIALS, the sensitivity equations can either be provided by the user or can be calculated using numerical interpolation by the solver. Here, I have only included the numerical interpolation version and currently the user cannot specify the sensitivity equations. However, in the future versions I will provide an ability to specify user-defined Jacobian as well as user-defined sensitivity equations.

-

Also, currently, forward sensitivities are calculated with respect to all parameters of the system. I plan to provide in future, an ability to specify specific particular parameters for which sensitivity is desired. Currently, SIMULATENOUS and STAGGERED methods of sensitivity calculations from the SUNDIALS library are supported in this package.

-
-
-

-Calculation of Sensitivities using CVODES -

-

Once, the system of ODEs has been defined using the instructions provided above, sensitivities can be easily calculated using the cvodes function using the function call below (the entire code can be found at this link)

-
df1 <- cvodes(time_vec, IC, ODE_R , params, reltol, abstol,"STG",F)  ## using R
-df2 <- cvodes(time_vec, IC, ODE_Rcpp , params, reltol, abstol,"STG",F)  ## using Rcpp
-

The additional arguments in cvodes specify the senstivity calculation method to be used (STG for STAGGERED or SIM for SIMULATENOUS) and flag for error control (either T or F).

-

The output of cvodes is a matrix with number of rows equal to the length of the time vector (time_vec) and the number of columns being equal to length of (y \(\times\) p + 1). The first columns is for time. Currently, the sensitivity of every enitity is calculated with respect to every parameter in model. For example, for the current model with 3 entities (ODEs) and 3 parameters, a total of 9 sensitivities are calculated at each output time, i.e. y1 w.r.t p1, p2, p3, y2 w.r.t. p1, p2, p3 and so on. The first 3 (length(y)) columns give sensitivity w.r.t the first parameter, the next 3 (length(y)) columns give sensitivity w.r.t the second parameter and so on.

-

In the Sensitivity Matrix output for the systems of equations described above, the first column gives output time, the next 3 columns provide sensitivity of y1, y2 and y3 w.r.t first parameter (say p1), the next three columns provide sensitivity of y1, y2 and y3 w.r.t. the second parameter (p2) and so on. The output Sensitivity Matrix is given below. The sensitivity values match with the values provided in the CVODES documentation.

-
> df1
-       [,1]          [,2]          [,3]         [,4]         [,5]          [,6]          [,7]          [,8]          [,9]        [,10]
- [1,] 0e+00  0.000000e+00  0.000000e+00 0.000000e+00 0.000000e+00  0.000000e+00  0.000000e+00  0.000000e+00  0.000000e+00 0.000000e+00
- [2,] 4e-01 -3.561085e-01  3.902252e-04 3.557183e-01 9.483149e-08 -2.132509e-10 -9.461823e-08 -1.573297e-11 -5.289692e-13 1.626194e-11
- [3,] 4e+00 -1.876130e+00  1.792229e-04 1.875951e+00 2.961233e-06 -5.830758e-10 -2.960650e-06 -4.932970e-10 -2.762408e-13 4.935732e-10
- [4,] 4e+01 -4.247395e+00  4.592812e-05 4.247349e+00 1.372964e-05 -2.357270e-10 -1.372941e-05 -2.288274e-09 -1.138015e-13 2.288387e-09
- [5,] 4e+02 -5.958192e+00  3.545986e-06 5.958189e+00 2.273754e-05 -2.260807e-11 -2.273752e-05 -3.789554e-09 -4.994795e-14 3.789604e-09
- [6,] 4e+03 -4.750132e+00 -5.991971e-06 4.750138e+00 1.880937e-05  2.312156e-11 -1.880939e-05 -3.134824e-09 -1.875976e-14 3.134843e-09
- [7,] 4e+04 -1.574902e+00 -2.761679e-06 1.574905e+00 6.288404e-06  1.100645e-11 -6.288415e-06 -1.047876e-09 -4.536508e-15 1.047881e-09
- [8,] 4e+05 -2.363168e-01 -4.584043e-07 2.363173e-01 9.450741e-07  1.832930e-12 -9.450760e-07 -1.574929e-10 -6.362045e-16 1.574935e-10
- [9,] 4e+06 -2.566355e-02 -5.105587e-08 2.566361e-02 1.026491e-07  2.042044e-13 -1.026493e-07 -1.711080e-11 -6.851356e-17 1.711087e-11
-[10,] 4e+07 -2.597859e-03 -5.190342e-09 2.597864e-03 1.039134e-08  2.076100e-14 -1.039136e-08 -1.732552e-12 -6.930923e-18 1.732559e-12
-[11,] 4e+08 -2.601996e-04 -5.199259e-10 2.602002e-04 1.040802e-09  2.079717e-15 -1.040804e-09 -1.737821e-13 -6.951356e-19 1.737828e-13
-[12,] 4e+09 -2.648142e-05 -5.616896e-11 2.648147e-05 1.059193e-10  2.246502e-16 -1.059195e-10 -1.804535e-14 -7.218146e-20 1.804542e-14
-[13,] 4e+10 -2.899376e-06 -7.759920e-12 2.899383e-06 1.159764e-11  3.104024e-17 -1.159768e-11 -1.727574e-15 -6.910296e-21 1.727581e-15
-

In future, I intend to provide options to select specific entities and parameters with respect to which sensitivities are to be computed as the sensitivity matrix can get very large for medium to large models.

-
-
-

-Summary

-
    -
  • The package sundialr provides a way to interface with the famous SUNDIALS C library (provided by Lawerence Livermore National Security) to solver initial value problems.

  • -
  • The package allows the system of differential equations to be written in R or using Rcpp. Function cvode is used to solve initial value problems with a single initialization, but problems with multiple discontinuities in the solution can be solved using the cvsolve interface.

  • -
  • For sensitivities, currently, calculation of forward sensitivities for all entities with respect to all the parameters in the model is implemented in the cvodes function. An ability to select specific entities and parameters for which sensitivities is to be calculated will be added soon.

  • -
  • To solve a system of differential algebraic systems, the ida function is provided which is an interface to the IDA function in SUNDIALS.

  • -
-

As a note, since this package is under active development, the interfaces of both CVODE and CVODES (i.e., the function signatures) may change in the future versions. Please keep this mind if you intend to use sundialr in your applications. In near future, interface for other solvers from the C library such asIDAS and ARKODE may also be added.

-
-
- - - -
- - - -
- -
-

Site built with pkgdown 1.5.1.

-
- -
-
- - - - - - diff --git a/docs/index.html b/docs/index.html deleted file mode 100644 index d2ff793..0000000 --- a/docs/index.html +++ /dev/null @@ -1,177 +0,0 @@ - - - - - - - -An Interface to SUNDIALS Ordinary Differential Equation (ODE) Solvers • sundialr - - - - - - - - - - -
-
- - - - -
-
-
- - - - -
-

-sundialr

-

sundialr is a wrapper around a few of the solvers in the SUNDIALS ODE solving C library produced by the Lawrence Livermore National Laboratory and Southern Methodist University. More information about SUNDIALS can be found here. SUNDIALS is one of the most popular and well-respected ODE solving libraries available and sundialr provides a way to interface some of the SUNDIALS solvers in R.

-

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 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.4

-
    -
  • This version has version 5.2.0 of SUNDIALS (released in March 2020) at the back end.
  • -
  • A new function cvsolve is added. It allows solving ODEs with multiple discontinuities in the solution. See a complete use case in the vignette.
  • -
  • A pkgdown create site of the package is added.
  • -
  • A hex sticker for the package is released!
  • -
-
-
-

-Release 0.1.3

-
    -
  • This version has version 4.0.1 of SUNDIALS (released in Dec 2018) at the back end.
  • -
  • An interface to CVODES is added. It calculates forward sensitivities w.r.t all parameters of the ODE system.
  • -
  • Parameters can now be defined as an input parameter to the ODE function. This will allow performing parameter optimization via numerical optimizers.
  • -
-
-
-
-
- - -
- - -
- -
-

Site built with pkgdown 1.5.1.

-
- -
-
- - - - - - diff --git a/src/Makevars b/src/Makevars index 4ff0b75..6cdd4c3 100644 --- a/src/Makevars +++ b/src/Makevars @@ -1,5 +1,6 @@ CXX=clang++ -PKG_CPPFLAGS= -I../inst/include/ -I./inst/ -DHAVE_CONFIG_H +PKG_CPPFLAGS= -I../inst/include/ -I./inst/ -DHAVE_CONFIG_H -DARMA_USE_CXX11 +CXX_STD = CXX11 PKG_LIBS= $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) -L../inst/ -lsundials_all LIBS=-L./ -L../inst/ @@ -30,12 +31,10 @@ SOURCES_IDA = ./sundials/ida/ida.c \ ./sundials/ida/ida_io.c ./sundials/ida/ida_ls.c \ ./sundials/ida/ida_nls.c ./sundials/ida/ida_spils.c -SOURCES_NVECSERIAL= ./sundials/nvector/serial/fnvector_serial.c \ -./sundials/nvector/serial/nvector_serial.c +SOURCES_NVECSERIAL= ./sundials/nvector/serial/nvector_serial.c SOURCES_SUNDIALS= ./sundials/sundials/sundials_band.c ./sundials/sundials/sundials_dense.c \ -./sundials/sundials/sundials_direct.c ./sundials/sundials/sundials_futils.c \ -./sundials/sundials/sundials_iterative.c \ +./sundials/sundials/sundials_direct.c ./sundials/sundials/sundials_iterative.c \ ./sundials/sundials/sundials_linearsolver.c \ ./sundials/sundials/sundials_math.c ./sundials/sundials/sundials_matrix.c \ ./sundials/sundials/sundials_nonlinearsolver.c \ @@ -47,23 +46,17 @@ SOURCES_SUNDIALS= ./sundials/sundials/sundials_band.c ./sundials/sundials/sundia ./sundials/sundials/sundials_sparse.c ./sundials/sundials/sundials_spbcgs.c \ ./sundials/sundials/sundials_sptfqmr.c -SOURCES_SUNLINSOL_BAND = ./sundials/sunlinsol/band/fsunlinsol_band.c \ -./sundials/sunlinsol/band/sunlinsol_band.c +SOURCES_SUNLINSOL_BAND = ./sundials/sunlinsol/band/sunlinsol_band.c -SOURCES_SUNLINSOL_DENSE = ./sundials/sunlinsol/dense/fsunlinsol_dense.c \ -./sundials/sunlinsol/dense/sunlinsol_dense.c +SOURCES_SUNLINSOL_DENSE = ./sundials/sunlinsol/dense/sunlinsol_dense.c -SOURCES_SUNMAT_BAND = ./sundials/sunmatrix/band/fsunmatrix_band.c \ -./sundials/sunmatrix/band/sunmatrix_band.c +SOURCES_SUNMAT_BAND = ./sundials/sunmatrix/band/sunmatrix_band.c -SOURCES_SUNMAT_DENSE = ./sundials/sunmatrix/dense/fsunmatrix_dense.c \ -./sundials/sunmatrix/dense/sunmatrix_dense.c +SOURCES_SUNMAT_DENSE = ./sundials/sunmatrix/dense/sunmatrix_dense.c -SOURCES_SUNNONLINSOL_FIXEDPOINT = ./sundials/sunnonlinsol/fixedpoint/fsunnonlinsol_fixedpoint.c \ -./sundials/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c +SOURCES_SUNNONLINSOL_FIXEDPOINT = ./sundials/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c -SOURCES_SUNNONLINSOL_NEWTON = ./sundials/sunnonlinsol/newton/fsunnonlinsol_newton.c \ -./sundials/sunnonlinsol/newton/sunnonlinsol_newton.c +SOURCES_SUNNONLINSOL_NEWTON = ./sundials/sunnonlinsol/newton/sunnonlinsol_newton.c SOURCES_SUNDIALS_ALL= $(SOURCES_CVODES) $(SOURCES_IDA) $(SOURCES_NVECSERIAL) $(SOURCES_SUNDIALS) \ $(SOURCES_SUNLINSOL_DENSE) $(SOURCES_SUNLINSOL_BAND) \ diff --git a/src/Makevars.win b/src/Makevars.win deleted file mode 100644 index 4ff0b75..0000000 --- a/src/Makevars.win +++ /dev/null @@ -1,97 +0,0 @@ -CXX=clang++ -PKG_CPPFLAGS= -I../inst/include/ -I./inst/ -DHAVE_CONFIG_H -PKG_LIBS= $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) -L../inst/ -lsundials_all -LIBS=-L./ -L../inst/ - -.PHONY: all ../inst/libsundials_all.a - -SOURCES= check_retval.cpp cvode.cpp cvodes.cpp \ -ida.cpp cvsolve.cpp rhs_func.cpp RcppExports.cpp - -OBJECTS= $(SOURCES:.cpp=.o) - -#SOURCES_CVODE= ./sundials/cvode/cvode.c ./sundials/cvode/cvode_bandpre.c \ -#./sundials/cvode/cvode_bbdpre.c \ -#./sundials/cvode/cvode_diag.c \ -#./sundials/cvode/cvode_io.c \ -#./sundials/cvode/cvode_ls.c \ -#./sundials/cvode/cvode_nls.c - -SOURCES_CVODES = ./sundials/cvodes/cvodea.c ./sundials/cvodes/cvodea_io.c \ -./sundials/cvodes/cvodes.c \ -./sundials/cvodes/cvodes_bandpre.c ./sundials/cvodes/cvodes_bbdpre.c \ -./sundials/cvodes/cvodes_diag.c ./sundials/cvodes/cvodes_io.c \ -./sundials/cvodes/cvodes_ls.c ./sundials/cvodes/cvodes_nls.c \ -./sundials/cvodes/cvodes_nls_sim.c ./sundials/cvodes/cvodes_nls_stg.c \ -./sundials/cvodes/cvodes_nls_stg1.c ./sundials/cvodes/cvodes_spils.c - -SOURCES_IDA = ./sundials/ida/ida.c \ -./sundials/ida/ida_bbdpre.c ./sundials/ida/ida_ic.c \ -./sundials/ida/ida_io.c ./sundials/ida/ida_ls.c \ -./sundials/ida/ida_nls.c ./sundials/ida/ida_spils.c - -SOURCES_NVECSERIAL= ./sundials/nvector/serial/fnvector_serial.c \ -./sundials/nvector/serial/nvector_serial.c - -SOURCES_SUNDIALS= ./sundials/sundials/sundials_band.c ./sundials/sundials/sundials_dense.c \ -./sundials/sundials/sundials_direct.c ./sundials/sundials/sundials_futils.c \ -./sundials/sundials/sundials_iterative.c \ -./sundials/sundials/sundials_linearsolver.c \ -./sundials/sundials/sundials_math.c ./sundials/sundials/sundials_matrix.c \ -./sundials/sundials/sundials_nonlinearsolver.c \ -./sundials/sundials/sundials_nvector.c ./sundials/sundials/sundials_nvector_senswrapper.c \ -./sundials/sundials/sundials_version.c - -#./sundials/sundials/sundials_mpi.c \ -#./sundials/sundials/sundials_pcg.c \ -./sundials/sundials/sundials_sparse.c ./sundials/sundials/sundials_spbcgs.c \ -./sundials/sundials/sundials_sptfqmr.c - -SOURCES_SUNLINSOL_BAND = ./sundials/sunlinsol/band/fsunlinsol_band.c \ -./sundials/sunlinsol/band/sunlinsol_band.c - -SOURCES_SUNLINSOL_DENSE = ./sundials/sunlinsol/dense/fsunlinsol_dense.c \ -./sundials/sunlinsol/dense/sunlinsol_dense.c - -SOURCES_SUNMAT_BAND = ./sundials/sunmatrix/band/fsunmatrix_band.c \ -./sundials/sunmatrix/band/sunmatrix_band.c - -SOURCES_SUNMAT_DENSE = ./sundials/sunmatrix/dense/fsunmatrix_dense.c \ -./sundials/sunmatrix/dense/sunmatrix_dense.c - -SOURCES_SUNNONLINSOL_FIXEDPOINT = ./sundials/sunnonlinsol/fixedpoint/fsunnonlinsol_fixedpoint.c \ -./sundials/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c - -SOURCES_SUNNONLINSOL_NEWTON = ./sundials/sunnonlinsol/newton/fsunnonlinsol_newton.c \ -./sundials/sunnonlinsol/newton/sunnonlinsol_newton.c - -SOURCES_SUNDIALS_ALL= $(SOURCES_CVODES) $(SOURCES_IDA) $(SOURCES_NVECSERIAL) $(SOURCES_SUNDIALS) \ -$(SOURCES_SUNLINSOL_DENSE) $(SOURCES_SUNLINSOL_BAND) \ -$(SOURCES_SUNMAT_BAND) $(SOURCES_SUNMAT_DENSE) \ -$(SOURCES_SUNNONLINSOL_FIXEDPOINT) $(SOURCES_SUNNONLINSOL_NEWTON) - -OBJECTS_SUNDIALS_ALL = $(SOURCES_SUNDIALS_ALL:.c=.o) - -all: $(SHLIB) - -$(SHLIB): ../inst/libsundials_all.a - -../inst/libsundials_all.a: $(OBJECTS_SUNDIALS_ALL) - $(AR) -crvs ../inst/libsundials_all.a $(OBJECTS_SUNDIALS_ALL) - $(RANLIB) $@ - -clean: - (cd ./sundials/cvode;rm -f *.o) - (cd ./sundials/cvodes;rm -f *.o) - (cd ./sundials/ida;rm -f *.o) - (cd ./sundials/nvector/serial;rm -f *.o) - (cd ./sundials/sundials;rm -f *.o) - (cd ./sundials/sunlinsol/band;rm -f *.o) - (cd ./sundials/sunlinsol/dense;rm -f *.o) - (cd ./sundials/sunmatrix/band;rm -f *.o) - (cd ./sundials/sunmatrix/dense;rm -f *.o) - (cd ./sundials/sunnonlinsol/fixedpoint;rm -f *.o) - (cd ./sundials/sunnonlinsol/newton;rm -f *.o) - rm -f *.dll - rm -f *.exe - (cd ../inst;rm -f *.a) diff --git a/src/sundials/cvode/CMakeLists.txt b/src/sundials/cvode/CMakeLists.txt deleted file mode 100644 index a591122..0000000 --- a/src/sundials/cvode/CMakeLists.txt +++ /dev/null @@ -1,149 +0,0 @@ -# --------------------------------------------------------------- -# Programmer(s): Daniel R. Reynolds @ SMU -# Radu Serban @ LLNL -# --------------------------------------------------------------- -# SUNDIALS Copyright Start -# Copyright (c) 2002-2020, 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 -# --------------------------------------------------------------- -# CMakeLists.txt file for the CVODE library -# --------------------------------------------------------------- - -install(CODE "MESSAGE(\"\nInstall CVODE\n\")") - -# Add F90 module if F2003 interface is enabled -if(F2003_FOUND AND F2003_INTERFACE_ENABLE) - add_subdirectory(fmod) -endif(F2003_FOUND AND F2003_INTERFACE_ENABLE) - -# Add variable cvode_SOURCES with the sources for the CVODE library -set(cvode_SOURCES - cvode.c - cvode_bandpre.c - cvode_bbdpre.c - cvode_diag.c - cvode_direct.c - cvode_io.c - cvode_ls.c - cvode_nls.c - cvode_spils.c - ) - -# Add variable shared_SOURCES with the common SUNDIALS sources which will -# also be included in the CVODE library -set(shared_SOURCES - ${sundials_SOURCE_DIR}/src/sundials/sundials_nvector.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_matrix.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_linearsolver.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_nonlinearsolver.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_math.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_band.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_dense.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_direct.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_iterative.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_version.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_nvector_senswrapper.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_futils.c - ${sundials_SOURCE_DIR}/src/nvector/serial/nvector_serial.c - ) - -# Add variable sunmatrix_SOURCES with the common SUNMatrix sources which will -# also be included in the CVODE library -set(sunmatrix_SOURCES - ${sundials_SOURCE_DIR}/src/sunmatrix/band/sunmatrix_band.c - ${sundials_SOURCE_DIR}/src/sunmatrix/dense/sunmatrix_dense.c - ${sundials_SOURCE_DIR}/src/sunmatrix/sparse/sunmatrix_sparse.c - ) - -# Add variable sunlinsol_SOURCES with the common SUNLinearSolver sources which will -# also be included in the CVODE library -set(sunlinsol_SOURCES - ${sundials_SOURCE_DIR}/src/sunlinsol/band/sunlinsol_band.c - ${sundials_SOURCE_DIR}/src/sunlinsol/dense/sunlinsol_dense.c - ${sundials_SOURCE_DIR}/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c - ${sundials_SOURCE_DIR}/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c - ${sundials_SOURCE_DIR}/src/sunlinsol/spgmr/sunlinsol_spgmr.c - ${sundials_SOURCE_DIR}/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c - ${sundials_SOURCE_DIR}/src/sunlinsol/pcg/sunlinsol_pcg.c - ) - -# Add variable sunnonlinsol_SOURCES with the common SUNNonlinearSolver sources -# which will also be included in the CVODE library -set(sunnonlinsol_SOURCES - ${sundials_SOURCE_DIR}/src/sunnonlinsol/newton/sunnonlinsol_newton.c - ${sundials_SOURCE_DIR}/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c - ) - -# Add variable cvode_HEADERS with the exported CVODE header files -set(cvode_HEADERS - cvode.h - cvode_bandpre.h - cvode_bbdpre.h - cvode_diag.h - cvode_direct.h - cvode_ls.h - cvode_spils.h - ) - -# Add prefix with complete path to the CVODE header files -add_prefix(${sundials_SOURCE_DIR}/include/cvode/ cvode_HEADERS) - -# Add source directories to include directories for access to -# implementation only header files. -include_directories(.) -include_directories(../sundials) - -# Define C preprocessor flag -DBUILD_SUNDIALS_LIBRARY -add_definitions(-DBUILD_SUNDIALS_LIBRARY) - -# Build the static library -if(BUILD_STATIC_LIBS) - # Add the build target for the static CVODE library - add_library(sundials_cvode_static STATIC - ${cvode_SOURCES} ${shared_SOURCES} ${sunmatrix_SOURCES} ${sunlinsol_SOURCES} ${sunnonlinsol_SOURCES} - ) - - # Set the library name and make sure it is not deleted - set_target_properties(sundials_cvode_static - PROPERTIES OUTPUT_NAME sundials_cvode CLEAN_DIRECT_OUTPUT 1) - - # Install the CVODE library - install(TARGETS sundials_cvode_static DESTINATION ${CMAKE_INSTALL_LIBDIR}) - -endif(BUILD_STATIC_LIBS) - -# Build the shared library -if(BUILD_SHARED_LIBS) - # Add the build target for the shared CVODE library - add_library(sundials_cvode_shared SHARED - ${cvode_SOURCES} ${shared_SOURCES} ${sunmatrix_SOURCES} ${sunlinsol_SOURCES} ${sunnonlinsol_SOURCES} - ) - - if(UNIX) - target_link_libraries(sundials_cvode_shared m) - endif() - - # Set the library name and make sure it is not deleted - set_target_properties(sundials_cvode_shared - PROPERTIES OUTPUT_NAME sundials_cvode CLEAN_DIRECT_OUTPUT 1) - - # Set VERSION and SOVERSION for shared libraries - set_target_properties(sundials_cvode_shared - PROPERTIES VERSION ${cvodelib_VERSION} SOVERSION ${cvodelib_SOVERSION}) - - # Install the CVODE library - install(TARGETS sundials_cvode_shared DESTINATION ${CMAKE_INSTALL_LIBDIR}) - -endif(BUILD_SHARED_LIBS) - -# Install the CVODE header files -install(FILES ${cvode_HEADERS} DESTINATION include/cvode) - -# -message(STATUS "Added CVODE module") diff --git a/src/sundials/cvode/LICENSE b/src/sundials/cvode/LICENSE deleted file mode 100644 index 2966cbb..0000000 --- a/src/sundials/cvode/LICENSE +++ /dev/null @@ -1,29 +0,0 @@ -BSD 3-Clause License - -Copyright (c) 2002-2019, Lawrence Livermore National Security and Southern Methodist University. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -* Neither the name of the copyright holder nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/src/sundials/cvode/NOTICE b/src/sundials/cvode/NOTICE deleted file mode 100644 index 329b142..0000000 --- a/src/sundials/cvode/NOTICE +++ /dev/null @@ -1,21 +0,0 @@ -This work was produced under the auspices of the U.S. Department of -Energy by Lawrence Livermore National Laboratory under Contract -DE-AC52-07NA27344. - -This work was prepared as an account of work sponsored by an agency of -the United States Government. Neither the United States Government nor -Lawrence Livermore National Security, LLC, nor any of their employees -makes any warranty, expressed or implied, or assumes any legal liability -or responsibility for the accuracy, completeness, or usefulness of any -information, apparatus, product, or process disclosed, or represents that -its use would not infringe privately owned rights. - -Reference herein to any specific commercial product, process, or service -by trade name, trademark, manufacturer, or otherwise does not necessarily -constitute or imply its endorsement, recommendation, or favoring by the -United States Government or Lawrence Livermore National Security, LLC. - -The views and opinions of authors expressed herein do not necessarily -state or reflect those of the United States Government or Lawrence -Livermore National Security, LLC, and shall not be used for advertising -or product endorsement purposes. \ No newline at end of file diff --git a/src/sundials/cvode/README.md b/src/sundials/cvode/README.md deleted file mode 100644 index f6806bb..0000000 --- a/src/sundials/cvode/README.md +++ /dev/null @@ -1,60 +0,0 @@ -# CVODE -### Version 5.2.0 (Mar 2020) - -**Alan C. Hindmarsh and Radu Serban - Center for Applied Scientific Computing, LLNL** - -CVODE is a package for the solution of stiff and nonstiff ordinary differential -equation (ODE) systems (initial value problems) given in explicit form -``` -dy/dt = f(t,y), y(t0) = y0. -``` -CVODE provides a choice of two variable-order, variable-coefficient multistep -methods, Adams-Moulton methods for non-stiff problems or BDF (Backward -Differentiation Formula) methods in fixed-leading-coefficient form for stiff -problems. - -CVODE is part of the SUNDIALS Suite of Nonlinear and Differential/Algebraic -equation Solvers which consists of ARKode, CVODE, CVODES, IDA, IDAS and KINSOL. -It is written in ANSI standard C and can be used in a variety of computing -environments including serial, shared memory, distributed memory, and -accelerator-based (e.g., GPU) systems. This flexibility is obtained from a -modular design that leverages the shared vector, matrix, linear solver, and -nonlinear solver APIs used across SUNDIALS packages. - -For use with Fortran applications, a set of Fortran/C interface routines, called -FCVODE, is also supplied. These are written in C, but assume that the user -calling program and all user-supplied routines are in Fortran. - -## Documentation - -See the [CVODE User Guide](/doc/cvode/cv_guide.pdf) and -[CVODE Examples](/doc/cvode/cv_examples.pdf) document for more information -about CVODE usage and the provided example programs respectively. - -## Installation - -For installation instructions see the [INSTALL_GUIDE](/INSTALL_GUIDE.pdf) -or the "Installation Procedure" chapter in the CVODE User Guide. - -## Release History - -Information on recent changes to CVODE can be found in the "Introduction" -chapter of the CVODE User Guide and a complete release history is available in -the "SUNDIALS Release History" appendix of the CVODE User Guide. - -## References - -* A. C. Hindmarsh and R. Serban, "User Documentation for CVODE v5.2.0," - LLNL technical report UCRL-SM-208108, Mar 2020. - -* A. C. Hindmarsh and R. Serban, "Example Programs for CVODE v5.2.0," - LLNL technical report UCRL-SM-208110, Mar 2020. - -* S.D. Cohen and A.C. Hindmarsh, "CVODE, a Stiff/nonstiff ODE Solver in C," - Computers in Physics, 10(2), pp. 138-143, 1996. - -* A. C. Hindmarsh, P. N. Brown, K. E. Grant, S. L. Lee, R. Serban, - D. E. Shumaker, and C. S. Woodward, "SUNDIALS, Suite of Nonlinear and - Differential/Algebraic Equation Solvers," ACM Trans. Math. Softw., - 31(3), pp. 363-396, 2005. diff --git a/src/sundials/cvodes/CMakeLists.txt b/src/sundials/cvodes/CMakeLists.txt deleted file mode 100644 index 15db6e3..0000000 --- a/src/sundials/cvodes/CMakeLists.txt +++ /dev/null @@ -1,156 +0,0 @@ -# --------------------------------------------------------------- -# Programmer(s): Daniel R. Reynolds @ SMU -# Radu Serban @ LLNL -# --------------------------------------------------------------- -# SUNDIALS Copyright Start -# Copyright (c) 2002-2020, 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 -# --------------------------------------------------------------- -# CMakeLists.txt file for the CVODES library -# --------------------------------------------------------------- - -install(CODE "MESSAGE(\"\nInstall CVODES\n\")") - -# Add F90 module if F2003 interface is enabled -if(F2003_FOUND AND F2003_INTERFACE_ENABLE) - add_subdirectory(fmod) -endif(F2003_FOUND AND F2003_INTERFACE_ENABLE) - -# Add variable cvodes_SOURCES with the sources for the CVODES library -set(cvodes_SOURCES - cvodea.c - cvodea_io.c - cvodes.c - cvodes_bandpre.c - cvodes_bbdpre.c - cvodes_diag.c - cvodes_direct.c - cvodes_io.c - cvodes_ls.c - cvodes_nls.c - cvodes_nls_sim.c - cvodes_nls_stg.c - cvodes_nls_stg1.c - cvodes_spils.c - ) - -# Add variable shared_SOURCES with the common SUNDIALS sources which will -# also be included in the CVODES library -set(shared_SOURCES - ${sundials_SOURCE_DIR}/src/sundials/sundials_nvector.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_matrix.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_linearsolver.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_nonlinearsolver.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_math.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_band.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_dense.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_direct.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_iterative.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_version.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_nvector_senswrapper.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_futils.c - ${sundials_SOURCE_DIR}/src/nvector/serial/nvector_serial.c - ) - -# Add variable sunmatrix_SOURCES with the common SUNMatrix sources which will -# also be included in the CVODES library -set(sunmatrix_SOURCES - ${sundials_SOURCE_DIR}/src/sunmatrix/band/sunmatrix_band.c - ${sundials_SOURCE_DIR}/src/sunmatrix/dense/sunmatrix_dense.c - ${sundials_SOURCE_DIR}/src/sunmatrix/sparse/sunmatrix_sparse.c - ) - -# Add variable sunlinsol_SOURCES with the common SUNLinearSolver sources which will -# also be included in the CVODES library -set(sunlinsol_SOURCES - ${sundials_SOURCE_DIR}/src/sunlinsol/band/sunlinsol_band.c - ${sundials_SOURCE_DIR}/src/sunlinsol/dense/sunlinsol_dense.c - ${sundials_SOURCE_DIR}/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c - ${sundials_SOURCE_DIR}/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c - ${sundials_SOURCE_DIR}/src/sunlinsol/spgmr/sunlinsol_spgmr.c - ${sundials_SOURCE_DIR}/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c - ${sundials_SOURCE_DIR}/src/sunlinsol/pcg/sunlinsol_pcg.c - ) - -# Add variable sunnonlinsol_SOURCES with the common SUNNonlinearSolver sources -# which will also be included in the CVODES library -set(sunnonlinsol_SOURCES - ${sundials_SOURCE_DIR}/src/sunnonlinsol/newton/sunnonlinsol_newton.c - ${sundials_SOURCE_DIR}/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c - ) - -# Add variable cvodes_HEADERS with the exported CVODES header files -set(cvodes_HEADERS - cvodes.h - cvodes_bandpre.h - cvodes_bbdpre.h - cvodes_diag.h - cvodes_direct.h - cvodes_ls.h - cvodes_spils.h - ) - -# Add prefix with complete path to the CVODES header files -add_prefix(${sundials_SOURCE_DIR}/include/cvodes/ cvodes_HEADERS) - -# Add source directories to include directories for access to -# implementation only header files. -include_directories(.) -include_directories(../sundials) - -# Define C preprocessor flag -DBUILD_SUNDIALS_LIBRARY -add_definitions(-DBUILD_SUNDIALS_LIBRARY) - -# Build the static library -if(BUILD_STATIC_LIBS) - - # Add the build target for the static CVODES library - add_library(sundials_cvodes_static STATIC - ${cvodes_SOURCES} ${shared_SOURCES} ${sunmatrix_SOURCES} ${sunlinsol_SOURCES} - ${sunnonlinsol_SOURCES}) - - # Set the library name and make sure it is not deleted - set_target_properties(sundials_cvodes_static - PROPERTIES OUTPUT_NAME sundials_cvodes CLEAN_DIRECT_OUTPUT 1) - - # Install the CVODES library - install(TARGETS sundials_cvodes_static DESTINATION ${CMAKE_INSTALL_LIBDIR}) - -endif(BUILD_STATIC_LIBS) - -# Build the shared library -if(BUILD_SHARED_LIBS) - - # Add the build target for the CVODES library - add_library(sundials_cvodes_shared SHARED - ${cvodes_SOURCES} ${shared_SOURCES} ${sunmatrix_SOURCES} ${sunlinsol_SOURCES} - ${sunnonlinsol_SOURCES}) - - if(UNIX) - target_link_libraries(sundials_cvodes_shared m) - endif() - - # Set the library name and make sure it is not deleted - set_target_properties(sundials_cvodes_shared - PROPERTIES OUTPUT_NAME sundials_cvodes CLEAN_DIRECT_OUTPUT 1) - - # Set VERSION and SOVERSION for shared libraries - set_target_properties(sundials_cvodes_shared - PROPERTIES VERSION ${cvodeslib_VERSION} SOVERSION ${cvodeslib_SOVERSION}) - - # Install the CVODES library - install(TARGETS sundials_cvodes_shared DESTINATION ${CMAKE_INSTALL_LIBDIR}) - -endif(BUILD_SHARED_LIBS) - -# Install the CVODES header files -install(FILES ${cvodes_HEADERS} DESTINATION include/cvodes) - -# -message(STATUS "Added CVODES module") diff --git a/src/sundials/ida/CMakeLists.txt b/src/sundials/ida/CMakeLists.txt deleted file mode 100644 index 329d4de..0000000 --- a/src/sundials/ida/CMakeLists.txt +++ /dev/null @@ -1,147 +0,0 @@ -# --------------------------------------------------------------- -# Programmer(s): Daniel R. Reynolds @ SMU -# Radu Serban @ LLNL -# --------------------------------------------------------------- -# SUNDIALS Copyright Start -# Copyright (c) 2002-2020, 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 -# --------------------------------------------------------------- -# CMakeLists.txt file for the IDA library -# --------------------------------------------------------------- - -install(CODE "MESSAGE(\"\nInstall IDA\n\")") - -# Add F90 module if F2003 interface is enabled -if(F2003_FOUND AND F2003_INTERFACE_ENABLE) - add_subdirectory(fmod) -endif(F2003_FOUND AND F2003_INTERFACE_ENABLE) - -# Add variable ida_SOURCES with the sources for the IDA library -set(ida_SOURCES - ida.c - ida_bbdpre.c - ida_direct.c - ida_ic.c - ida_io.c - ida_ls.c - ida_nls.c - ida_spils.c - ) - -# Add variable shared_SOURCES with the common SUNDIALS sources which will -# also be included in the IDA library -set(shared_SOURCES - ${sundials_SOURCE_DIR}/src/sundials/sundials_nvector.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_matrix.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_linearsolver.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_nonlinearsolver.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_math.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_band.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_dense.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_direct.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_iterative.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_version.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_nvector_senswrapper.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_futils.c - ${sundials_SOURCE_DIR}/src/nvector/serial/nvector_serial.c - ) - -# Add variable sunmatrix_SOURCES with the common SUNMatrix sources which will -# also be included in the IDA library -set(sunmatrix_SOURCES - ${sundials_SOURCE_DIR}/src/sunmatrix/band/sunmatrix_band.c - ${sundials_SOURCE_DIR}/src/sunmatrix/dense/sunmatrix_dense.c - ${sundials_SOURCE_DIR}/src/sunmatrix/sparse/sunmatrix_sparse.c - ) - -# Add variable sunlinsol_SOURCES with the common SUNLinearSolver sources which will -# also be included in the IDA library -set(sunlinsol_SOURCES - ${sundials_SOURCE_DIR}/src/sunlinsol/band/sunlinsol_band.c - ${sundials_SOURCE_DIR}/src/sunlinsol/dense/sunlinsol_dense.c - ${sundials_SOURCE_DIR}/src/sunlinsol/spbcgs/sunlinsol_spbcgs.c - ${sundials_SOURCE_DIR}/src/sunlinsol/spfgmr/sunlinsol_spfgmr.c - ${sundials_SOURCE_DIR}/src/sunlinsol/spgmr/sunlinsol_spgmr.c - ${sundials_SOURCE_DIR}/src/sunlinsol/sptfqmr/sunlinsol_sptfqmr.c - ${sundials_SOURCE_DIR}/src/sunlinsol/pcg/sunlinsol_pcg.c - ) - -# Add variable sunnonlinsol_SOURCES with the common SUNNonlinearSolver sources -# which will also be included in the IDA library -set(sunnonlinsol_SOURCES - ${sundials_SOURCE_DIR}/src/sunnonlinsol/newton/sunnonlinsol_newton.c - ${sundials_SOURCE_DIR}/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.c - ) - -# Add variable ida_HEADERS with the exported IDA header files -set(ida_HEADERS - ida.h - ida_bbdpre.h - ida_direct.h - ida_ls.h - ida_spils.h - ) - -# Add prefix with complete path to the IDA header files -add_prefix(${sundials_SOURCE_DIR}/include/ida/ ida_HEADERS) - -# Add source directories to include directories for access to -# implementation only header files. -include_directories(.) - -# Define C preprocessor flag -DBUILD_SUNDIALS_LIBRARY -add_definitions(-DBUILD_SUNDIALS_LIBRARY) - -# Build the static library -if(BUILD_STATIC_LIBS) - - # Add the build target for the static IDA library - add_library(sundials_ida_static STATIC - ${ida_SOURCES} ${shared_SOURCES} ${sunmatrix_SOURCES} ${sunlinsol_SOURCES} - ${sunnonlinsol_SOURCES}) - - # Set the library name and make sure it is not deleted - set_target_properties(sundials_ida_static - PROPERTIES OUTPUT_NAME sundials_ida CLEAN_DIRECT_OUTPUT 1) - - # Install the IDA library - install(TARGETS sundials_ida_static DESTINATION ${CMAKE_INSTALL_LIBDIR}) - -endif(BUILD_STATIC_LIBS) - -# Build the shared library -if(BUILD_SHARED_LIBS) - - # Add the build target for the IDA library - add_library(sundials_ida_shared SHARED - ${ida_SOURCES} ${shared_SOURCES} ${sunmatrix_SOURCES} ${sunlinsol_SOURCES} - ${sunnonlinsol_SOURCES}) - - if(UNIX) - target_link_libraries(sundials_ida_shared m) - endif() - - # Set the library name and make sure it is not deleted - set_target_properties(sundials_ida_shared - PROPERTIES OUTPUT_NAME sundials_ida CLEAN_DIRECT_OUTPUT 1) - - # Set VERSION and SOVERSION for shared libraries - set_target_properties(sundials_ida_shared - PROPERTIES VERSION ${idalib_VERSION} SOVERSION ${idalib_SOVERSION}) - - # Install the IDA library - install(TARGETS sundials_ida_shared DESTINATION ${CMAKE_INSTALL_LIBDIR}) - -endif(BUILD_SHARED_LIBS) - -# Install the IDA header files -install(FILES ${ida_HEADERS} DESTINATION include/ida) - -# -message(STATUS "Added IDA module") diff --git a/src/sundials/ida/LICENSE b/src/sundials/ida/LICENSE deleted file mode 100644 index 2966cbb..0000000 --- a/src/sundials/ida/LICENSE +++ /dev/null @@ -1,29 +0,0 @@ -BSD 3-Clause License - -Copyright (c) 2002-2019, Lawrence Livermore National Security and Southern Methodist University. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -* Neither the name of the copyright holder nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/src/sundials/ida/NOTICE b/src/sundials/ida/NOTICE deleted file mode 100644 index 329b142..0000000 --- a/src/sundials/ida/NOTICE +++ /dev/null @@ -1,21 +0,0 @@ -This work was produced under the auspices of the U.S. Department of -Energy by Lawrence Livermore National Laboratory under Contract -DE-AC52-07NA27344. - -This work was prepared as an account of work sponsored by an agency of -the United States Government. Neither the United States Government nor -Lawrence Livermore National Security, LLC, nor any of their employees -makes any warranty, expressed or implied, or assumes any legal liability -or responsibility for the accuracy, completeness, or usefulness of any -information, apparatus, product, or process disclosed, or represents that -its use would not infringe privately owned rights. - -Reference herein to any specific commercial product, process, or service -by trade name, trademark, manufacturer, or otherwise does not necessarily -constitute or imply its endorsement, recommendation, or favoring by the -United States Government or Lawrence Livermore National Security, LLC. - -The views and opinions of authors expressed herein do not necessarily -state or reflect those of the United States Government or Lawrence -Livermore National Security, LLC, and shall not be used for advertising -or product endorsement purposes. \ No newline at end of file diff --git a/src/sundials/ida/README.md b/src/sundials/ida/README.md deleted file mode 100644 index 6f7719a..0000000 --- a/src/sundials/ida/README.md +++ /dev/null @@ -1,64 +0,0 @@ -# IDA -### Version 5.2.0 (Mar 2020) - -**Alan C. Hindmarsh and Radu Serban - Center for Applied Scientific Computing, LLNL** - -IDA is a package for the solution of differential-algebraic equation (DAE) -systems -``` -F(t,y,y') = 0, y(t0) = y0, y'(t0) = y0'. -``` -The integration methods used in IDA are variable-order, variable-coefficient BDF -(Backward Differentiation Formula) methods in fixed-leading-coefficient form. - -IDA is part of the SUNDIALS Suite of Nonlinear and Differential/Algebraic -equation Solvers which consists of ARKode, CVODE, CVODES, IDA, IDAS and KINSOL. -It is written in ANSI standard C, but is derived from the package DASPK, which -is written in FORTRAN. IDA can be used in a variety of computing environments -including serial, shared memory, distributed memory, and accelerator-based -(e.g., GPU) systems. This flexibility is obtained from a modular design that -leverages the shared vector, matrix, linear solver, and nonlinear solver APIs -used across SUNDIALS packages. - -For use with Fortran applications, a set of Fortran/C interface routines, called -FIDA, is also supplied. These are written in C, but assume that the user calling -program and all user-supplied routines are in Fortran. - -## Documentation - -See the [IDA User Guide](/doc/ida/ida_guide.pdf) and -[IDA Examples](/doc/ida/ida_examples.pdf) document for more information -about IDA usage and the provided example programs respectively. - -## Installation - -For installation instructions see the [INSTALL_GUIDE](/INSTALL_GUIDE.pdf) -or the "Installation Procedure" chapter in the IDA User Guide. - -## Release History - -Information on recent changes to IDA can be found in the "Introduction" -chapter of the IDA User Guide and a complete release history is available in -the "SUNDIALS Release History" appendix of the IDA User Guide. - -## References - -* A. C. Hindmarsh, R. Serban, and A. Collier, "User Documentation for IDA v5.2.0," - LLNL technical report UCRL-SM-208112, Mar 2020. - -* A. C. Hindmarsh, R. Serban, and A. Collier, "Example Programs for IDA v5.2.0," - LLNL technical report UCRL-SM-208113, Mar 2020. - -* A. C. Hindmarsh, P. N. Brown, K. E. Grant, S. L. Lee, R. Serban, - D. E. Shumaker, and C. S. Woodward, "SUNDIALS, Suite of Nonlinear and - Differential/Algebraic Equation Solvers," ACM Trans. Math. Softw., - 31(3), pp. 363-396, 2005. - -* P. N. Brown, A. C. Hindmarsh, and L. R. Petzold, Using Krylov Methods - in the Solution of Large-Scale Differential-Algebraic Systems, - SIAM J. Sci. Comp., 15 (1994), pp. 1467-1488. - -* P. N. Brown, A. C. Hindmarsh, and L. R. Petzold, Consistent Initial - Condition Calculation for Differential-Algebraic Systems, - SIAM J. Sci. Comp., 19 (1998), pp. 1495-1512. diff --git a/src/sundials/nvector/serial/CMakeLists.txt b/src/sundials/nvector/serial/CMakeLists.txt deleted file mode 100644 index 0cfd7e1..0000000 --- a/src/sundials/nvector/serial/CMakeLists.txt +++ /dev/null @@ -1,105 +0,0 @@ -# --------------------------------------------------------------- -# Programmer(s): Radu Serban @ LLNL -# --------------------------------------------------------------- -# SUNDIALS Copyright Start -# Copyright (c) 2002-2020, 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 -# --------------------------------------------------------------- -# CMakeLists.txt file for the serial NVECTOR library -# --------------------------------------------------------------- - -install(CODE "MESSAGE(\"\nInstall NVECTOR_SERIAL\n\")") - -# Add F90 module if F2003 interface is enabled -if(F2003_FOUND AND F2003_INTERFACE_ENABLE) - add_subdirectory(fmod) -endif(F2003_FOUND AND F2003_INTERFACE_ENABLE) - -# Add variable nvecserial_SOURCES with the sources for the NVECSERIAL lib -set(nvecserial_SOURCES nvector_serial.c) - -# Add variable shared_SOURCES with the common SUNDIALS sources which will -# also be included in the NVECSERIAL library -set(shared_SOURCES - ${sundials_SOURCE_DIR}/src/sundials/sundials_nvector.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_math.c - ) - -# Add variable nvecserial_HEADERS with the exported NVECSERIAL header files -set(nvecserial_HEADERS - ${sundials_SOURCE_DIR}/include/nvector/nvector_serial.h - ) - -# Add source directory to include directories -include_directories(.) - -# Define C preprocessor flag -DBUILD_SUNDIALS_LIBRARY -add_definitions(-DBUILD_SUNDIALS_LIBRARY) - -# Rules for building and installing the static library: -# - Add the build target for the NVECSERIAL library -# - Set the library name and make sure it is not deleted -# - Install the NVECSERIAL library -if(BUILD_STATIC_LIBS) - add_library(sundials_nvecserial_static STATIC ${nvecserial_SOURCES} ${shared_SOURCES}) - set_target_properties(sundials_nvecserial_static - PROPERTIES OUTPUT_NAME sundials_nvecserial CLEAN_DIRECT_OUTPUT 1) - install(TARGETS sundials_nvecserial_static DESTINATION ${CMAKE_INSTALL_LIBDIR}) -endif(BUILD_STATIC_LIBS) - -# Rules for building and installing the shared library: -# - Add the build target for the NVECSERIAL library -# - Set the library name and make sure it is not deleted -# - Set VERSION and SOVERSION for shared libraries -# - Install the NVECSERIAL library -if(BUILD_SHARED_LIBS) - add_library(sundials_nvecserial_shared SHARED ${nvecserial_SOURCES} ${shared_SOURCES}) - - if(UNIX) - target_link_libraries(sundials_nvecserial_shared m) - endif() - - set_target_properties(sundials_nvecserial_shared - PROPERTIES OUTPUT_NAME sundials_nvecserial CLEAN_DIRECT_OUTPUT 1) - set_target_properties(sundials_nvecserial_shared - PROPERTIES VERSION ${nveclib_VERSION} SOVERSION ${nveclib_SOVERSION}) - install(TARGETS sundials_nvecserial_shared DESTINATION ${CMAKE_INSTALL_LIBDIR}) -endif(BUILD_SHARED_LIBS) - -# Install the NVECSERIAL header files -install(FILES ${nvecserial_HEADERS} DESTINATION include/nvector) - -# If FCMIX is enabled, build and install the FNVECSERIAL library -if(F77_INTERFACE_ENABLE AND F77_FOUND) - set(fnvecserial_SOURCES fnvector_serial.c) - - if(BUILD_STATIC_LIBS) - add_library(sundials_fnvecserial_static STATIC ${fnvecserial_SOURCES}) - set_target_properties(sundials_fnvecserial_static - PROPERTIES OUTPUT_NAME sundials_fnvecserial CLEAN_DIRECT_OUTPUT 1) - install(TARGETS sundials_fnvecserial_static DESTINATION ${CMAKE_INSTALL_LIBDIR}) - endif(BUILD_STATIC_LIBS) - - if(BUILD_SHARED_LIBS) - add_library(sundials_fnvecserial_shared ${fnvecserial_SOURCES}) - - # fnvecserial depends on nvecserial - target_link_libraries(sundials_fnvecserial_shared sundials_nvecserial_shared) - - set_target_properties(sundials_fnvecserial_shared - PROPERTIES OUTPUT_NAME sundials_fnvecserial CLEAN_DIRECT_OUTPUT 1) - set_target_properties(sundials_fnvecserial_shared - PROPERTIES VERSION ${nveclib_VERSION} SOVERSION ${nveclib_SOVERSION}) - install(TARGETS sundials_fnvecserial_shared DESTINATION ${CMAKE_INSTALL_LIBDIR}) - endif(BUILD_SHARED_LIBS) - -endif(F77_INTERFACE_ENABLE AND F77_FOUND) - -# -message(STATUS "Added NVECTOR_SERIAL module") diff --git a/src/sundials/nvector/serial/fnvector_serial.c b/src/sundials/nvector/serial/fnvector_serial.c deleted file mode 100644 index c5b5bde..0000000 --- a/src/sundials/nvector/serial/fnvector_serial.c +++ /dev/null @@ -1,154 +0,0 @@ -/* - * ----------------------------------------------------------------- - * Programmer(s): Radu Serban @ LLNL - * ----------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2020, 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 file (companion of nvector_serial.h) contains the - * implementation needed for the Fortran initialization of serial - * vector operations. - * ----------------------------------------------------------------- - */ - -#include -#include - -#include "fnvector_serial.h" - -/* Define global vector variables */ - -N_Vector F2C_CVODE_vec; -N_Vector F2C_CVODE_vecQ; -N_Vector *F2C_CVODE_vecS; -N_Vector F2C_CVODE_vecB; -N_Vector F2C_CVODE_vecQB; - -N_Vector F2C_IDA_vec; -N_Vector F2C_IDA_vecQ; -N_Vector *F2C_IDA_vecS; -N_Vector F2C_IDA_vecB; -N_Vector F2C_IDA_vecQB; - -N_Vector F2C_KINSOL_vec; - -N_Vector F2C_ARKODE_vec; - -/* Fortran callable interfaces */ - -void FNV_INITS(int *code, long int *N, int *ier) -{ - *ier = 0; - - switch(*code) { - case FCMIX_CVODE: - F2C_CVODE_vec = NULL; - F2C_CVODE_vec = N_VNewEmpty_Serial((sunindextype)(*N)); - if (F2C_CVODE_vec == NULL) *ier = -1; - break; - case FCMIX_IDA: - F2C_IDA_vec = NULL; - F2C_IDA_vec = N_VNewEmpty_Serial((sunindextype)(*N)); - if (F2C_IDA_vec == NULL) *ier = -1; - break; - case FCMIX_KINSOL: - F2C_KINSOL_vec = NULL; - F2C_KINSOL_vec = N_VNewEmpty_Serial((sunindextype)(*N)); - if (F2C_KINSOL_vec == NULL) *ier = -1; - break; - case FCMIX_ARKODE: - F2C_ARKODE_vec = NULL; - F2C_ARKODE_vec = N_VNewEmpty_Serial((sunindextype)(*N)); - if (F2C_ARKODE_vec == NULL) *ier = -1; - break; - default: - *ier = -1; - } -} - -void FNV_INITS_Q(int *code, long int *Nq, int *ier) -{ - *ier = 0; - - switch(*code) { - case FCMIX_CVODE: - F2C_CVODE_vecQ = NULL; - F2C_CVODE_vecQ = N_VNewEmpty_Serial((sunindextype)(*Nq)); - if (F2C_CVODE_vecQ == NULL) *ier = -1; - break; - case FCMIX_IDA: - F2C_IDA_vecQ = NULL; - F2C_IDA_vecQ = N_VNewEmpty_Serial((sunindextype)(*Nq)); - if (F2C_IDA_vecQ == NULL) *ier = -1; - break; - default: - *ier = -1; - } -} - -void FNV_INITS_B(int *code, long int *NB, int *ier) -{ - *ier = 0; - - switch(*code) { - case FCMIX_CVODE: - F2C_CVODE_vecB = NULL; - F2C_CVODE_vecB = N_VNewEmpty_Serial((sunindextype)(*NB)); - if (F2C_CVODE_vecB == NULL) *ier = -1; - break; - case FCMIX_IDA: - F2C_IDA_vecB = NULL; - F2C_IDA_vecB = N_VNewEmpty_Serial((sunindextype)(*NB)); - if (F2C_IDA_vecB == NULL) *ier = -1; - break; - default: - *ier = -1; - } -} - -void FNV_INITS_QB(int *code, long int *NqB, int *ier) -{ - *ier = 0; - - switch(*code) { - case FCMIX_CVODE: - F2C_CVODE_vecQB = NULL; - F2C_CVODE_vecQB = N_VNewEmpty_Serial((sunindextype)(*NqB)); - if (F2C_CVODE_vecQB == NULL) *ier = -1; - break; - case FCMIX_IDA: - F2C_IDA_vecQB = NULL; - F2C_IDA_vecQB = N_VNewEmpty_Serial((sunindextype)(*NqB)); - if (F2C_IDA_vecQB == NULL) *ier = -1; - break; - default: - *ier = -1; - } -} - -void FNV_INITS_S(int *code, int *Ns, int *ier) -{ - *ier = 0; - - switch(*code) { - case FCMIX_CVODE: - F2C_CVODE_vecS = NULL; - F2C_CVODE_vecS = (N_Vector *) N_VCloneVectorArrayEmpty_Serial(*Ns, F2C_CVODE_vec); - if (F2C_CVODE_vecS == NULL) *ier = -1; - break; - case FCMIX_IDA: - F2C_IDA_vecS = NULL; - F2C_IDA_vecS = (N_Vector *) N_VCloneVectorArrayEmpty_Serial(*Ns, F2C_IDA_vec); - if (F2C_IDA_vecS == NULL) *ier = -1; - break; - default: - *ier = -1; - } -} diff --git a/src/sundials/nvector/serial/fnvector_serial.h b/src/sundials/nvector/serial/fnvector_serial.h deleted file mode 100644 index 5ab7452..0000000 --- a/src/sundials/nvector/serial/fnvector_serial.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * ----------------------------------------------------------------- - * Programmer(s): Radu Serban and Aaron Collier @ LLNL - * ----------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2020, 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 file (companion of nvector_serial.h) contains the - * definitions needed for the initialization of serial - * vector operations in Fortran. - * ----------------------------------------------------------------- - */ - -#ifndef _FNVECTOR_SERIAL_H -#define _FNVECTOR_SERIAL_H - -#include -#include - -#ifdef __cplusplus /* wrapper to enable C++ usage */ -extern "C" { -#endif - -#if defined(SUNDIALS_F77_FUNC) -#define FNV_INITS SUNDIALS_F77_FUNC(fnvinits, FNVINITS) -#else -#define FNV_INITS fnvinits_ -#endif - -#if defined(SUNDIALS_F77_FUNC_) - -#define FNV_INITS_Q SUNDIALS_F77_FUNC_(fnvinits_q, FNVINITS_Q) -#define FNV_INITS_S SUNDIALS_F77_FUNC_(fnvinits_s, FNVINITS_S) -#define FNV_INITS_B SUNDIALS_F77_FUNC_(fnvinits_b, FNVINITS_B) -#define FNV_INITS_QB SUNDIALS_F77_FUNC_(fnvinits_qb, FNVINITS_QB) - -#else - -#define FNV_INITS_Q fnvinits_q_ -#define FNV_INITS_S fnvinits_s_ -#define FNV_INITS_B fnvinits_b_ -#define FNV_INITS_QB fnvinits_qb_ - -#endif - -/* Declarations of global variables */ - -extern N_Vector F2C_CVODE_vec; -extern N_Vector F2C_CVODE_vecQ; -extern N_Vector *F2C_CVODE_vecS; -extern N_Vector F2C_CVODE_vecB; -extern N_Vector F2C_CVODE_vecQB; - -extern N_Vector F2C_IDA_vec; -extern N_Vector F2C_IDA_vecQ; -extern N_Vector *F2C_IDA_vecS; -extern N_Vector F2C_IDA_vecB; -extern N_Vector F2C_IDA_vecQB; - -extern N_Vector F2C_KINSOL_vec; - -extern N_Vector F2C_ARKODE_vec; - -/* - * Prototypes of exported functions - * - * FNV_INITS - initializes serial vector operations for main problem - * FNV_INITS_Q - initializes serial vector operations for quadratures - * FNV_INITS_S - initializes serial vector operations for sensitivities - * FNV_INITS_B - initializes serial vector operations for adjoint problem - * FNV_INITS_QB - initializes serial vector operations for adjoint quadratures - * - */ - -void FNV_INITS(int *code, long int *neq, int *ier); -void FNV_INITS_Q(int *code, long int *Nq, int *ier); -void FNV_INITS_S(int *code, int *Ns, int *ier); -void FNV_INITS_B(int *code, long int *NB, int *ier); -void FNV_INITS_QB(int *code, long int *NqB, int *ier); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/sundials/sundials/CMakeLists.txt b/src/sundials/sundials/CMakeLists.txt deleted file mode 100644 index 72a0dd4..0000000 --- a/src/sundials/sundials/CMakeLists.txt +++ /dev/null @@ -1,94 +0,0 @@ -# --------------------------------------------------------------- -# Programmer(s): Radu Serban and Cody J. Balos @ LLNL -# --------------------------------------------------------------- -# SUNDIALS Copyright Start -# Copyright (c) 2002-2020, 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 -# --------------------------------------------------------------- -# CMakeLists.txt file for the generic SUNDIALS modules -# --------------------------------------------------------------- - -# From here we only install the generic SUNDIALS headers. -# The implementations themselves are incorporated in the individual SUNDIALS solver libraries. - -install(CODE "MESSAGE(\"\nInstall shared components\n\")") - -# Add F90 module if F2003 interface is enabled -if(F2003_FOUND AND F2003_INTERFACE_ENABLE) - add_subdirectory(fmod) -endif(F2003_FOUND AND F2003_INTERFACE_ENABLE) - -# Add variable sundials_HEADERS with the exported SUNDIALS header files -set(sundials_HEADERS - sundials_band.h - sundials_dense.h - sundials_direct.h - sundials_fnvector.h - sundials_futils.h - sundials_iterative.h - sundials_linearsolver.h - sundials_math.h - sundials_matrix.h - sundials_nonlinearsolver.h - sundials_mpi_types.h - sundials_nvector.h - sundials_types.h - sundials_version.h - ) - -# Add prefix with complete path to the SUNDIALS header files -add_prefix(${sundials_SOURCE_DIR}/include/sundials/ sundials_HEADERS) - -# Define C preprocessor flag -DBUILD_SUNDIALS_LIBRARY -add_definitions(-DBUILD_SUNDIALS_LIBRARY) - -# Create an object library out of the generic sundials modules -if(BUILD_STATIC_LIBS) - add_library(sundials_generic_static_obj OBJECT - sundials_band.c - sundials_dense.c - sundials_direct.c - sundials_futils.c - sundials_iterative.c - sundials_linearsolver.c - sundials_math.c - sundials_matrix.c - sundials_nonlinearsolver.c - sundials_nvector.c - sundials_nvector_senswrapper.c - sundials_version.c) -endif() - -if(BUILD_SHARED_LIBS) - add_library(sundials_generic_shared_obj OBJECT - sundials_band.c - sundials_dense.c - sundials_direct.c - sundials_futils.c - sundials_iterative.c - sundials_linearsolver.c - sundials_math.c - sundials_matrix.c - sundials_nonlinearsolver.c - sundials_nvector.c - sundials_nvector_senswrapper.c - sundials_version.c) - set_target_properties(sundials_generic_shared_obj PROPERTIES - POSITION_INDEPENDENT_CODE TRUE) -endif() - -# Install the SUNDIALS header files -install(FILES ${sundials_HEADERS} DESTINATION include/sundials) - -# If Blas/Lapack support was enabled, install the Lapack interface headers -if(LAPACK_FOUND) - set(sundials_BL_HEADERS sundials_lapack.h) - add_prefix(${sundials_SOURCE_DIR}/include/sundials/ sundials_BL_HEADERS) - install(FILES ${sundials_BL_HEADERS} DESTINATION include/sundials) -endif(LAPACK_FOUND) diff --git a/src/sundials/sundials/sundials_futils.c b/src/sundials/sundials/sundials_futils.c deleted file mode 100644 index 33cad23..0000000 --- a/src/sundials/sundials/sundials_futils.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ----------------------------------------------------------------- - * Programmer(s): Cody J. Balos - * ----------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2020, 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 - * ----------------------------------------------------------------- - * SUNDIALS Fortran 2003 interface utility implementations. - * -----------------------------------------------------------------*/ - -#include - -/* Create a file pointer with the given file name and mode. */ -FILE* SUNDIALSFileOpen(const char* filename, const char* mode) -{ - return fopen(filename, mode); -} - -/* Close a file pointer with the given file name. */ -void SUNDIALSFileClose(FILE* fp) -{ - fclose(fp); -} diff --git a/src/sundials/sunlinsol/band/CMakeLists.txt b/src/sundials/sunlinsol/band/CMakeLists.txt deleted file mode 100644 index 3fdc800..0000000 --- a/src/sundials/sunlinsol/band/CMakeLists.txt +++ /dev/null @@ -1,141 +0,0 @@ -# --------------------------------------------------------------- -# Programmer(s): Daniel R. Reynolds @ SMU -# --------------------------------------------------------------- -# SUNDIALS Copyright Start -# Copyright (c) 2002-2020, 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 -# --------------------------------------------------------------- -# CMakeLists.txt file for the band SUNLinearSolver library -# --------------------------------------------------------------- - -install(CODE "MESSAGE(\"\nInstall SUNLINSOL_BAND\n\")") - -# Source files for the library -set(sunlinsolband_SOURCES sunlinsol_band.c) - -# Common SUNDIALS sources included in the library -set(shared_SOURCES - ${sundials_SOURCE_DIR}/src/sundials/sundials_linearsolver.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_band.c) - -# Exported header files -set(sunlinsolband_HEADERS - ${sundials_SOURCE_DIR}/include/sunlinsol/sunlinsol_band.h) - -# Rules for building and installing the static library: -# - Add the build target for the library -# - Set the library name and make sure it is not deleted -# - Install the library -if(BUILD_STATIC_LIBS) - - add_library(sundials_sunlinsolband_static - STATIC ${sunlinsolband_SOURCES} ${shared_SOURCES}) - - set_target_properties(sundials_sunlinsolband_static - PROPERTIES - OUTPUT_NAME sundials_sunlinsolband - CLEAN_DIRECT_OUTPUT 1) - - # depends on sunmatrixband - target_link_libraries(sundials_sunlinsolband_static - PUBLIC sundials_sunmatrixband_static) - - target_compile_definitions(sundials_sunlinsolband_static - PUBLIC -DBUILD_SUNDIALS_LIBRARY) - - install(TARGETS sundials_sunlinsolband_static - DESTINATION ${CMAKE_INSTALL_LIBDIR}) - -endif(BUILD_STATIC_LIBS) - -# Rules for building and installing the shared library: -# - Add the build target for the library -# - Set the library name and make sure it is not deleted -# - Set VERSION and SOVERSION for shared libraries -# - Install the library -if(BUILD_SHARED_LIBS) - - add_library(sundials_sunlinsolband_shared - SHARED ${sunlinsolband_SOURCES} ${shared_SOURCES}) - - set_target_properties(sundials_sunlinsolband_shared - PROPERTIES - OUTPUT_NAME sundials_sunlinsolband - CLEAN_DIRECT_OUTPUT 1 - VERSION ${sunlinsollib_VERSION} - SOVERSION ${sunlinsollib_SOVERSION}) - - # depends on sunmatrixband - target_link_libraries(sundials_sunlinsolband_shared - PUBLIC sundials_sunmatrixband_shared) - - target_compile_definitions(sundials_sunlinsolband_shared - PUBLIC -DBUILD_SUNDIALS_LIBRARY) - - install(TARGETS sundials_sunlinsolband_shared - DESTINATION ${CMAKE_INSTALL_LIBDIR}) - -endif(BUILD_SHARED_LIBS) - -# Install the header files -install(FILES ${sunlinsolband_HEADERS} DESTINATION include/sunlinsol) - -# -message(STATUS "Added SUNLINSOL_BAND module") - -# If FCMIX is enabled, build and install the Fortran77 library -if(F77_INTERFACE_ENABLE AND F77_FOUND) - - set(fsunlinsolband_SOURCES fsunlinsol_band.c) - - if(BUILD_STATIC_LIBS) - add_library(sundials_fsunlinsolband_static - STATIC ${fsunlinsolband_SOURCES}) - set_target_properties(sundials_fsunlinsolband_static - PROPERTIES - OUTPUT_NAME sundials_fsunlinsolband - CLEAN_DIRECT_OUTPUT 1) - # depends on fnvecserial, fsunmatrixband, sunlinsolband - target_link_libraries(sundials_fsunlinsolband_static - PUBLIC - sundials_fnvecserial_static - sundials_fsunmatrixband_static - sundials_sunlinsolband_static) - install(TARGETS sundials_fsunlinsolband_static - DESTINATION ${CMAKE_INSTALL_LIBDIR}) - endif(BUILD_STATIC_LIBS) - - if(BUILD_SHARED_LIBS) - add_library(sundials_fsunlinsolband_shared - SHARED ${fsunlinsolband_SOURCES}) - set_target_properties(sundials_fsunlinsolband_shared - PROPERTIES - OUTPUT_NAME sundials_fsunlinsolband - CLEAN_DIRECT_OUTPUT 1 - VERSION ${sunlinsollib_VERSION} - SOVERSION ${sunlinsollib_SOVERSION}) - # depends on fnvecserial, fsunmatrixband, sunlinsolband - target_link_libraries(sundials_fsunlinsolband_shared - PUBLIC - sundials_fnvecserial_shared - sundials_fsunmatrixband_shared - sundials_sunlinsolband_shared) - install(TARGETS sundials_fsunlinsolband_shared - DESTINATION ${CMAKE_INSTALL_LIBDIR}) - endif(BUILD_SHARED_LIBS) - - # - message(STATUS "Added SUNLINSOL_BAND F77 interface") - -endif(F77_INTERFACE_ENABLE AND F77_FOUND) - -# Add F90 module if F2003 interface is enabled -if(F2003_FOUND AND F2003_INTERFACE_ENABLE) - add_subdirectory(fmod) -endif(F2003_FOUND AND F2003_INTERFACE_ENABLE) diff --git a/src/sundials/sunlinsol/band/fsunlinsol_band.c b/src/sundials/sunlinsol/band/fsunlinsol_band.c deleted file mode 100644 index 8e5dba8..0000000 --- a/src/sundials/sunlinsol/band/fsunlinsol_band.c +++ /dev/null @@ -1,96 +0,0 @@ -/* - * ----------------------------------------------------------------- - * Programmer(s): Daniel Reynolds @ SMU - * ----------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2020, 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 file (companion of fsunlinsol_band.h) contains the - * implementation needed for the Fortran initialization of band - * linear solver operations. - * ----------------------------------------------------------------- - */ - -#include -#include - -#include "fsunlinsol_band.h" - -/* Define global linsol variables */ - -SUNLinearSolver F2C_CVODE_linsol; -SUNLinearSolver F2C_IDA_linsol; -SUNLinearSolver F2C_KINSOL_linsol; -SUNLinearSolver F2C_ARKODE_linsol; -SUNLinearSolver F2C_ARKODE_mass_sol; - -/* Declarations of external global variables */ - -extern SUNMatrix F2C_CVODE_matrix; -extern SUNMatrix F2C_IDA_matrix; -extern SUNMatrix F2C_KINSOL_matrix; -extern SUNMatrix F2C_ARKODE_matrix; -extern SUNMatrix F2C_ARKODE_mass_matrix; - -extern N_Vector F2C_CVODE_vec; -extern N_Vector F2C_IDA_vec; -extern N_Vector F2C_KINSOL_vec; -extern N_Vector F2C_ARKODE_vec; - -/* Fortran callable interfaces */ - -void FSUNBANDLINSOL_INIT(int *code, int *ier) -{ - *ier = 0; - - switch(*code) { - case FCMIX_CVODE: - if (F2C_CVODE_linsol) SUNLinSolFree(F2C_CVODE_linsol); - F2C_CVODE_linsol = NULL; - F2C_CVODE_linsol = SUNLinSol_Band(F2C_CVODE_vec, - F2C_CVODE_matrix); - if (F2C_CVODE_linsol == NULL) *ier = -1; - break; - case FCMIX_IDA: - if (F2C_IDA_linsol) SUNLinSolFree(F2C_IDA_linsol); - F2C_IDA_linsol = NULL; - F2C_IDA_linsol = SUNLinSol_Band(F2C_IDA_vec, - F2C_IDA_matrix); - if (F2C_IDA_linsol == NULL) *ier = -1; - break; - case FCMIX_KINSOL: - if (F2C_KINSOL_linsol) SUNLinSolFree(F2C_KINSOL_linsol); - F2C_KINSOL_linsol = NULL; - F2C_KINSOL_linsol = SUNLinSol_Band(F2C_KINSOL_vec, - F2C_KINSOL_matrix); - if (F2C_KINSOL_linsol == NULL) *ier = -1; - break; - case FCMIX_ARKODE: - if (F2C_ARKODE_linsol) SUNLinSolFree(F2C_ARKODE_linsol); - F2C_ARKODE_linsol = NULL; - F2C_ARKODE_linsol = SUNLinSol_Band(F2C_ARKODE_vec, - F2C_ARKODE_matrix); - if (F2C_ARKODE_linsol == NULL) *ier = -1; - break; - default: - *ier = -1; - } -} - - -void FSUNMASSBANDLINSOL_INIT(int *ier) -{ - *ier = 0; - if (F2C_ARKODE_mass_sol) SUNLinSolFree(F2C_ARKODE_mass_sol); - F2C_ARKODE_mass_sol = NULL; - F2C_ARKODE_mass_sol = SUNLinSol_Band(F2C_ARKODE_vec, - F2C_ARKODE_mass_matrix); - if (F2C_ARKODE_mass_sol == NULL) *ier = -1; -} diff --git a/src/sundials/sunlinsol/band/fsunlinsol_band.h b/src/sundials/sunlinsol/band/fsunlinsol_band.h deleted file mode 100644 index f07a245..0000000 --- a/src/sundials/sunlinsol/band/fsunlinsol_band.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * ----------------------------------------------------------------- - * Programmer(s): Daniel Reynolds @ SMU - * ----------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2020, 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 file (companion of fsunlinsol_band.c) contains the - * definitions needed for the initialization of band - * linear solver operations in Fortran. - * ----------------------------------------------------------------- - */ - -#ifndef _FSUNLINSOL_BAND_H -#define _FSUNLINSOL_BAND_H - -#include -#include - -#ifdef __cplusplus /* wrapper to enable C++ usage */ -extern "C" { -#endif - -#if defined(SUNDIALS_F77_FUNC) -#define FSUNBANDLINSOL_INIT SUNDIALS_F77_FUNC(fsunbandlinsolinit, FSUNBANDLINSOLINIT) -#define FSUNMASSBANDLINSOL_INIT SUNDIALS_F77_FUNC(fsunmassbandlinsolinit, FSUNMASSBANDLINSOLINIT) -#else -#define FSUNBANDLINSOL_INIT fsunbandlinsolinit_ -#define FSUNMASSBANDLINSOL_INIT fsunmassbandlinsolinit_ -#endif - - -/* Declarations of global variables */ - -extern SUNLinearSolver F2C_CVODE_linsol; -extern SUNLinearSolver F2C_IDA_linsol; -extern SUNLinearSolver F2C_KINSOL_linsol; -extern SUNLinearSolver F2C_ARKODE_linsol; -extern SUNLinearSolver F2C_ARKODE_mass_sol; - -/* - * Prototypes of exported functions - * - * FSUNBANDLINSOL_INIT - initializes band linear solver for main problem - * FSUNMASSBANDLINSOL_INIT - initializes band linear solver for mass matrix solve - */ - -void FSUNBANDLINSOL_INIT(int *code, int *ier); -void FSUNMASSBANDLINSOL_INIT(int *ier); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/sundials/sunlinsol/dense/CMakeLists.txt b/src/sundials/sunlinsol/dense/CMakeLists.txt deleted file mode 100644 index ddba973..0000000 --- a/src/sundials/sunlinsol/dense/CMakeLists.txt +++ /dev/null @@ -1,141 +0,0 @@ -# --------------------------------------------------------------- -# Programmer(s): Daniel R. Reynolds and Ashley Crawford @ SMU -# --------------------------------------------------------------- -# SUNDIALS Copyright Start -# Copyright (c) 2002-2020, 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 -# --------------------------------------------------------------- -# CMakeLists.txt file for the dense SUNLinearSolver library -# --------------------------------------------------------------- - -install(CODE "MESSAGE(\"\nInstall SUNLINSOL_DENSE\n\")") - -# Source files for the library -set(sunlinsoldense_SOURCES sunlinsol_dense.c) - -# Common SUNDIALS sources included in the library -set(shared_SOURCES - ${sundials_SOURCE_DIR}/src/sundials/sundials_linearsolver.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_dense.c) - -# Exported header files -set(sunlinsoldense_HEADERS - ${sundials_SOURCE_DIR}/include/sunlinsol/sunlinsol_dense.h) - -# Rules for building and installing the static library: -# - Add the build target for the library -# - Set the library name and make sure it is not deleted -# - Install the library -if(BUILD_STATIC_LIBS) - - add_library(sundials_sunlinsoldense_static - STATIC ${sunlinsoldense_SOURCES} ${shared_SOURCES}) - - set_target_properties(sundials_sunlinsoldense_static - PROPERTIES - OUTPUT_NAME sundials_sunlinsoldense - CLEAN_DIRECT_OUTPUT 1) - - # sunlinsoldense depends on sunmatrixdense - target_link_libraries(sundials_sunlinsoldense_static - PUBLIC sundials_sunmatrixdense_static) - - target_compile_definitions(sundials_sunlinsoldense_static - PUBLIC -DBUILD_SUNDIALS_LIBRARY) - - install(TARGETS sundials_sunlinsoldense_static - DESTINATION ${CMAKE_INSTALL_LIBDIR}) - -endif(BUILD_STATIC_LIBS) - -# Rules for building and installing the shared library: -# - Add the build target for the library -# - Set the library name and make sure it is not deleted -# - Set VERSION and SOVERSION for shared libraries -# - Install the library -if(BUILD_SHARED_LIBS) - - add_library(sundials_sunlinsoldense_shared - SHARED ${sunlinsoldense_SOURCES} ${shared_SOURCES}) - - set_target_properties(sundials_sunlinsoldense_shared - PROPERTIES - OUTPUT_NAME sundials_sunlinsoldense - CLEAN_DIRECT_OUTPUT 1 - VERSION ${sunlinsollib_VERSION} - SOVERSION ${sunlinsollib_SOVERSION}) - - # sunlinsoldense depends on sunmatrixdense - target_link_libraries(sundials_sunlinsoldense_shared - PUBLIC sundials_sunmatrixdense_shared) - - target_compile_definitions(sundials_sunlinsoldense_shared - PUBLIC -DBUILD_SUNDIALS_LIBRARY) - - install(TARGETS sundials_sunlinsoldense_shared - DESTINATION ${CMAKE_INSTALL_LIBDIR}) - -endif(BUILD_SHARED_LIBS) - -# Install the header files -install(FILES ${sunlinsoldense_HEADERS} DESTINATION include/sunlinsol) - -# -message(STATUS "Added SUNLINSOL_DENSE module") - -# If FCMIX is enabled, build and install the Fortran77 library -if(F77_INTERFACE_ENABLE AND F77_FOUND) - - set(fsunlinsoldense_SOURCES fsunlinsol_dense.c) - - if(BUILD_STATIC_LIBS) - add_library(sundials_fsunlinsoldense_static - STATIC ${fsunlinsoldense_SOURCES}) - set_target_properties(sundials_fsunlinsoldense_static - PROPERTIES - OUTPUT_NAME sundials_fsunlinsoldense - CLEAN_DIRECT_OUTPUT 1) - # depends on fnvecserial, fsunmatrixdense, sunlinsoldense - target_link_libraries(sundials_fsunlinsoldense_static - PUBLIC - sundials_fnvecserial_static - sundials_fsunmatrixdense_static - sundials_sunlinsoldense_static) - install(TARGETS sundials_fsunlinsoldense_static - DESTINATION ${CMAKE_INSTALL_LIBDIR}) - endif(BUILD_STATIC_LIBS) - - if(BUILD_SHARED_LIBS) - add_library(sundials_fsunlinsoldense_shared - SHARED ${fsunlinsoldense_SOURCES}) - set_target_properties(sundials_fsunlinsoldense_shared - PROPERTIES - OUTPUT_NAME sundials_fsunlinsoldense - CLEAN_DIRECT_OUTPUT 1 - VERSION ${sunlinsollib_VERSION} - SOVERSION ${sunlinsollib_SOVERSION}) - # depends on fnvecserial, fsunmatrixdense, sunlinsoldense - target_link_libraries(sundials_fsunlinsoldense_shared - PUBLIC - sundials_fnvecserial_shared - sundials_fsunmatrixdense_shared - sundials_sunlinsoldense_shared) - install(TARGETS sundials_fsunlinsoldense_shared - DESTINATION ${CMAKE_INSTALL_LIBDIR}) - endif(BUILD_SHARED_LIBS) - - # - message(STATUS "Added SUNLINSOL_DENSE F77 interface") - -endif(F77_INTERFACE_ENABLE AND F77_FOUND) - -# Add F90 module if F2003 interface is enabled -if(F2003_FOUND AND F2003_INTERFACE_ENABLE) - add_subdirectory(fmod) -endif(F2003_FOUND AND F2003_INTERFACE_ENABLE) diff --git a/src/sundials/sunlinsol/dense/fsunlinsol_dense.c b/src/sundials/sunlinsol/dense/fsunlinsol_dense.c deleted file mode 100644 index 1b0fa30..0000000 --- a/src/sundials/sunlinsol/dense/fsunlinsol_dense.c +++ /dev/null @@ -1,96 +0,0 @@ -/* - * ----------------------------------------------------------------- - * Programmer(s): Daniel Reynolds @ SMU - * ----------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2020, 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 file (companion of fsunlinsol_dense.h) contains the - * implementation needed for the Fortran initialization of dense - * linear solver operations. - * ----------------------------------------------------------------- - */ - -#include -#include - -#include "fsunlinsol_dense.h" - -/* Define global linsol variables */ - -SUNLinearSolver F2C_CVODE_linsol; -SUNLinearSolver F2C_IDA_linsol; -SUNLinearSolver F2C_KINSOL_linsol; -SUNLinearSolver F2C_ARKODE_linsol; -SUNLinearSolver F2C_ARKODE_mass_sol; - -/* Declarations of external global variables */ - -extern SUNMatrix F2C_CVODE_matrix; -extern SUNMatrix F2C_IDA_matrix; -extern SUNMatrix F2C_KINSOL_matrix; -extern SUNMatrix F2C_ARKODE_matrix; -extern SUNMatrix F2C_ARKODE_mass_matrix; - -extern N_Vector F2C_CVODE_vec; -extern N_Vector F2C_IDA_vec; -extern N_Vector F2C_KINSOL_vec; -extern N_Vector F2C_ARKODE_vec; - -/* Fortran callable interfaces */ - -void FSUNDENSELINSOL_INIT(int *code, int *ier) -{ - *ier = 0; - - switch(*code) { - case FCMIX_CVODE: - if (F2C_CVODE_linsol) SUNLinSolFree(F2C_CVODE_linsol); - F2C_CVODE_linsol = NULL; - F2C_CVODE_linsol = SUNLinSol_Dense(F2C_CVODE_vec, - F2C_CVODE_matrix); - if (F2C_CVODE_linsol == NULL) *ier = -1; - break; - case FCMIX_IDA: - if (F2C_IDA_linsol) SUNLinSolFree(F2C_IDA_linsol); - F2C_IDA_linsol = NULL; - F2C_IDA_linsol = SUNLinSol_Dense(F2C_IDA_vec, - F2C_IDA_matrix); - if (F2C_IDA_linsol == NULL) *ier = -1; - break; - case FCMIX_KINSOL: - if (F2C_KINSOL_linsol) SUNLinSolFree(F2C_KINSOL_linsol); - F2C_KINSOL_linsol = NULL; - F2C_KINSOL_linsol = SUNLinSol_Dense(F2C_KINSOL_vec, - F2C_KINSOL_matrix); - if (F2C_KINSOL_linsol == NULL) *ier = -1; - break; - case FCMIX_ARKODE: - if (F2C_ARKODE_linsol) SUNLinSolFree(F2C_ARKODE_linsol); - F2C_ARKODE_linsol = NULL; - F2C_ARKODE_linsol = SUNLinSol_Dense(F2C_ARKODE_vec, - F2C_ARKODE_matrix); - if (F2C_ARKODE_linsol == NULL) *ier = -1; - break; - default: - *ier = -1; - } -} - - -void FSUNMASSDENSELINSOL_INIT(int *ier) -{ - *ier = 0; - if (F2C_ARKODE_mass_sol) SUNLinSolFree(F2C_ARKODE_mass_sol); - F2C_ARKODE_mass_sol = NULL; - F2C_ARKODE_mass_sol = SUNLinSol_Dense(F2C_ARKODE_vec, - F2C_ARKODE_mass_matrix); - if (F2C_ARKODE_mass_sol == NULL) *ier = -1; -} diff --git a/src/sundials/sunlinsol/dense/fsunlinsol_dense.h b/src/sundials/sunlinsol/dense/fsunlinsol_dense.h deleted file mode 100644 index 700d57e..0000000 --- a/src/sundials/sunlinsol/dense/fsunlinsol_dense.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * ----------------------------------------------------------------- - * Programmer(s): Daniel Reynolds, Ashley Crawford @ SMU - * ----------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2020, 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 file (companion of fsunlinsol_dense.c) contains the - * definitions needed for the initialization of dense - * linear solver operations in Fortran. - * ----------------------------------------------------------------- - */ - -#ifndef _FSUNLINSOL_DENSE_H -#define _FSUNLINSOL_DENSE_H - -#include -#include - -#ifdef __cplusplus /* wrapper to enable C++ usage */ -extern "C" { -#endif - -#if defined(SUNDIALS_F77_FUNC) -#define FSUNDENSELINSOL_INIT SUNDIALS_F77_FUNC(fsundenselinsolinit, FSUNDENSELINSOLINIT) -#define FSUNMASSDENSELINSOL_INIT SUNDIALS_F77_FUNC(fsunmassdenselinsolinit, FSUNMASSDENSELINSOLINIT) -#else -#define FSUNDENSELINSOL_INIT fsundenselinsolinit_ -#define FSUNMASSDENSELINSOL_INIT fsunmassdenselinsolinit_ -#endif - - -/* Declarations of global variables */ - -extern SUNLinearSolver F2C_CVODE_linsol; -extern SUNLinearSolver F2C_IDA_linsol; -extern SUNLinearSolver F2C_KINSOL_linsol; -extern SUNLinearSolver F2C_ARKODE_linsol; -extern SUNLinearSolver F2C_ARKODE_mass_sol; - -/* - * Prototypes of exported functions - * - * FSUNDENSELINSOL_INIT - initializes dense linear solver for main problem - * FSUNMASSDENSELINSOL_INIT - initializes dense linear solver for mass matrix solve - */ - -void FSUNDENSELINSOL_INIT(int *code, int *ier); -void FSUNMASSDENSELINSOL_INIT(int *ier); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/sundials/sunmatrix/band/CMakeLists.txt b/src/sundials/sunmatrix/band/CMakeLists.txt deleted file mode 100644 index 893173a..0000000 --- a/src/sundials/sunmatrix/band/CMakeLists.txt +++ /dev/null @@ -1,106 +0,0 @@ -# --------------------------------------------------------------- -# Programmer(s): Daniel R. Reynolds @ SMU -# --------------------------------------------------------------- -# SUNDIALS Copyright Start -# Copyright (c) 2002-2020, 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 -# --------------------------------------------------------------- -# CMakeLists.txt file for the band SUNMatrix library -# --------------------------------------------------------------- - -install(CODE "MESSAGE(\"\nInstall SUNMATRIX_BAND\n\")") - -# Add variable sunmatrixband_SOURCES with the sources for the SUNMATRIXBAND lib -set(sunmatrixband_SOURCES sunmatrix_band.c) - -# Add F90 module if F2003 interface is enabled -if(F2003_FOUND AND F2003_INTERFACE_ENABLE) - add_subdirectory(fmod) -endif(F2003_FOUND AND F2003_INTERFACE_ENABLE) - -# Add variable shared_SOURCES with the common SUNDIALS sources which will -# also be included in the SUNMATRIXBAND library -set(shared_SOURCES - ${sundials_SOURCE_DIR}/src/sundials/sundials_nvector.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_matrix.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_math.c - ) - -# Add variable sunmatrixband_HEADERS with the exported SUNMATRIXBAND header files -set(sunmatrixband_HEADERS - ${sundials_SOURCE_DIR}/include/sunmatrix/sunmatrix_band.h - ) - -# Add source directory to include directories -include_directories(.) - -# Define C preprocessor flag -DBUILD_SUNDIALS_LIBRARY -add_definitions(-DBUILD_SUNDIALS_LIBRARY) - -# Rules for building and installing the static library: -# - Add the build target for the SUNMATRIXBAND library -# - Set the library name and make sure it is not deleted -# - Install the SUNMATRIXBAND library -if(BUILD_STATIC_LIBS) - add_library(sundials_sunmatrixband_static STATIC ${sunmatrixband_SOURCES} ${shared_SOURCES}) - set_target_properties(sundials_sunmatrixband_static - PROPERTIES OUTPUT_NAME sundials_sunmatrixband CLEAN_DIRECT_OUTPUT 1) - install(TARGETS sundials_sunmatrixband_static DESTINATION ${CMAKE_INSTALL_LIBDIR}) -endif(BUILD_STATIC_LIBS) - -# Rules for building and installing the shared library: -# - Add the build target for the SUNMATRIXBAND library -# - Set the library name and make sure it is not deleted -# - Set VERSION and SOVERSION for shared libraries -# - Install the SUNMATRIXBAND library -if(BUILD_SHARED_LIBS) - add_library(sundials_sunmatrixband_shared SHARED ${sunmatrixband_SOURCES} ${shared_SOURCES}) - - if(UNIX) - target_link_libraries(sundials_sunmatrixband_shared m) - endif() - - set_target_properties(sundials_sunmatrixband_shared - PROPERTIES OUTPUT_NAME sundials_sunmatrixband CLEAN_DIRECT_OUTPUT 1) - set_target_properties(sundials_sunmatrixband_shared - PROPERTIES VERSION ${sunmatrixlib_VERSION} SOVERSION ${sunmatrixlib_SOVERSION}) - install(TARGETS sundials_sunmatrixband_shared DESTINATION ${CMAKE_INSTALL_LIBDIR}) -endif(BUILD_SHARED_LIBS) - -# Install the SUNMATRIXBAND header files -install(FILES ${sunmatrixband_HEADERS} DESTINATION include/sunmatrix) - -# If FCMIX is enabled, build and install the FSUNMATRIXBAND library -if(F77_INTERFACE_ENABLE AND F77_FOUND) - set(fsunmatrixband_SOURCES fsunmatrix_band.c) - - if(BUILD_STATIC_LIBS) - add_library(sundials_fsunmatrixband_static STATIC ${fsunmatrixband_SOURCES}) - set_target_properties(sundials_fsunmatrixband_static - PROPERTIES OUTPUT_NAME sundials_fsunmatrixband CLEAN_DIRECT_OUTPUT 1) - install(TARGETS sundials_fsunmatrixband_static DESTINATION ${CMAKE_INSTALL_LIBDIR}) - endif(BUILD_STATIC_LIBS) - - if(BUILD_SHARED_LIBS) - add_library(sundials_fsunmatrixband_shared ${fsunmatrixband_SOURCES}) - - # fsunmatrixband depends on sunmatrixband - target_link_libraries(sundials_fsunmatrixband_shared sundials_sunmatrixband_shared) - - set_target_properties(sundials_fsunmatrixband_shared - PROPERTIES OUTPUT_NAME sundials_fsunmatrixband CLEAN_DIRECT_OUTPUT 1) - set_target_properties(sundials_fsunmatrixband_shared - PROPERTIES VERSION ${sunmatrixlib_VERSION} SOVERSION ${sunmatrixlib_SOVERSION}) - install(TARGETS sundials_fsunmatrixband_shared DESTINATION ${CMAKE_INSTALL_LIBDIR}) - endif(BUILD_SHARED_LIBS) - -endif(F77_INTERFACE_ENABLE AND F77_FOUND) - -# -message(STATUS "Added SUNMATRIX_BAND module") diff --git a/src/sundials/sunmatrix/band/fsunmatrix_band.c b/src/sundials/sunmatrix/band/fsunmatrix_band.c deleted file mode 100644 index a15a31c..0000000 --- a/src/sundials/sunmatrix/band/fsunmatrix_band.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * ----------------------------------------------------------------- - * Programmer(s): Daniel Reynolds @ SMU - * ----------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2020, 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 file (companion of fsunmatrix_band.h) contains the - * implementation needed for the Fortran initialization of band - * vector operations. - * ----------------------------------------------------------------- - */ - -#include -#include - -#include "fsunmatrix_band.h" - -/* Define global matrix variables */ - -SUNMatrix F2C_CVODE_matrix; -SUNMatrix F2C_IDA_matrix; -SUNMatrix F2C_KINSOL_matrix; -SUNMatrix F2C_ARKODE_matrix; -SUNMatrix F2C_ARKODE_mass_matrix; - -/* Fortran callable interfaces */ - -void FSUNBANDMAT_INIT(int *code, long int *N, long int *mu, - long int *ml, int *ier) -{ - *ier = 0; - - switch(*code) { - case FCMIX_CVODE: - if (F2C_CVODE_matrix) SUNMatDestroy(F2C_CVODE_matrix); - F2C_CVODE_matrix = NULL; - F2C_CVODE_matrix = SUNBandMatrix((sunindextype)(*N), - (sunindextype)(*mu), - (sunindextype)(*ml)); - if (F2C_CVODE_matrix == NULL) *ier = -1; - break; - case FCMIX_IDA: - if (F2C_IDA_matrix) SUNMatDestroy(F2C_IDA_matrix); - F2C_IDA_matrix = NULL; - F2C_IDA_matrix = SUNBandMatrix((sunindextype)(*N), - (sunindextype)(*mu), - (sunindextype)(*ml)); - if (F2C_IDA_matrix == NULL) *ier = -1; - break; - case FCMIX_KINSOL: - if (F2C_KINSOL_matrix) SUNMatDestroy(F2C_KINSOL_matrix); - F2C_KINSOL_matrix = NULL; - F2C_KINSOL_matrix = SUNBandMatrix((sunindextype)(*N), - (sunindextype)(*mu), - (sunindextype)(*ml)); - if (F2C_KINSOL_matrix == NULL) *ier = -1; - break; - case FCMIX_ARKODE: - if (F2C_ARKODE_matrix) SUNMatDestroy(F2C_ARKODE_matrix); - F2C_ARKODE_matrix = NULL; - F2C_ARKODE_matrix = SUNBandMatrix((sunindextype)(*N), - (sunindextype)(*mu), - (sunindextype)(*ml)); - if (F2C_ARKODE_matrix == NULL) *ier = -1; - break; - default: - *ier = -1; - } -} - - -void FSUNBANDMASSMAT_INIT(long int *N, long int *mu, - long int *ml, int *ier) -{ - *ier = 0; - if (F2C_ARKODE_mass_matrix) SUNMatDestroy(F2C_ARKODE_mass_matrix); - F2C_ARKODE_mass_matrix = NULL; - F2C_ARKODE_mass_matrix = SUNBandMatrix((sunindextype)(*N), - (sunindextype)(*mu), - (sunindextype)(*ml)); - if (F2C_ARKODE_mass_matrix == NULL) *ier = -1; -} diff --git a/src/sundials/sunmatrix/band/fsunmatrix_band.h b/src/sundials/sunmatrix/band/fsunmatrix_band.h deleted file mode 100644 index 18d9128..0000000 --- a/src/sundials/sunmatrix/band/fsunmatrix_band.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * ----------------------------------------------------------------- - * Programmer(s): Daniel Reynolds @ SMU - * ----------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2020, 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 file (companion of fsunmatrix_band.c) contains the - * definitions needed for the initialization of band - * matrix operations in Fortran. - * ----------------------------------------------------------------- - */ - -#ifndef _FSUNMATRIX_BAND_H -#define _FSUNMATRIX_BAND_H - -#include -#include - -#ifdef __cplusplus /* wrapper to enable C++ usage */ -extern "C" { -#endif - -#if defined(SUNDIALS_F77_FUNC) -#define FSUNBANDMAT_INIT SUNDIALS_F77_FUNC(fsunbandmatinit, FSUNBANDMATINIT) -#define FSUNBANDMASSMAT_INIT SUNDIALS_F77_FUNC(fsunbandmassmatinit, FSUNBANDMASSMATINIT) -#else -#define FSUNBANDMAT_INIT fsunbandmatinit_ -#define FSUNBANDMASSMAT_INIT fsunbandmassmatinit_ -#endif - - -/* Declarations of global variables */ - -extern SUNMatrix F2C_CVODE_matrix; -extern SUNMatrix F2C_IDA_matrix; -extern SUNMatrix F2C_KINSOL_matrix; -extern SUNMatrix F2C_ARKODE_matrix; -extern SUNMatrix F2C_ARKODE_mass_matrix; - -/* - * Prototypes of exported functions - * - * FSUNBANDMAT_INIT - initializes band matrix operations for main problem - * FSUNBANDMASSMAT_INIT - initializes band matrix operations for mass matrix solve - */ - -void FSUNBANDMAT_INIT(int *code, long int *N, long int *mu, long int *ml, int *ier); -void FSUNBANDMASSMAT_INIT(long int *N, long int *mu, long int *ml, int *ier); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/sundials/sunmatrix/dense/CMakeLists.txt b/src/sundials/sunmatrix/dense/CMakeLists.txt deleted file mode 100644 index db135e7..0000000 --- a/src/sundials/sunmatrix/dense/CMakeLists.txt +++ /dev/null @@ -1,107 +0,0 @@ -# --------------------------------------------------------------- -# Programmer(s): Daniel R. Reynolds @ SMU -# Cody J. Balos @ LLNL -# --------------------------------------------------------------- -# SUNDIALS Copyright Start -# Copyright (c) 2002-2020, 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 -# --------------------------------------------------------------- -# CMakeLists.txt file for the dense SUNMatrix library -# --------------------------------------------------------------- - -install(CODE "MESSAGE(\"\nInstall SUNMATRIX_DENSE\n\")") - -# Add F90 module if F2003 interface is enabled -if(F2003_FOUND AND F2003_INTERFACE_ENABLE) - add_subdirectory(fmod) -endif(F2003_FOUND AND F2003_INTERFACE_ENABLE) - -# Add variable sunmatrixdense_SOURCES with the sources for the SUNMATRIXDENSE lib -set(sunmatrixdense_SOURCES sunmatrix_dense.c) - -# Add variable shared_SOURCES with the common SUNDIALS sources which will -# also be included in the SUNMATRIXDENSE library -set(shared_SOURCES - ${sundials_SOURCE_DIR}/src/sundials/sundials_nvector.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_matrix.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_math.c - ) - -# Add variable sunmatrixdense_HEADERS with the exported SUNMATRIXDENSE header files -set(sunmatrixdense_HEADERS - ${sundials_SOURCE_DIR}/include/sunmatrix/sunmatrix_dense.h - ) - -# Add source directory to include directories -include_directories(.) - -# Define C preprocessor flag -DBUILD_SUNDIALS_LIBRARY -add_definitions(-DBUILD_SUNDIALS_LIBRARY) - -# Rules for building and installing the static library: -# - Add the build target for the SUNMATRIXDENSE library -# - Set the library name and make sure it is not deleted -# - Install the SUNMATRIXDENSE library -if(BUILD_STATIC_LIBS) - add_library(sundials_sunmatrixdense_static STATIC ${sunmatrixdense_SOURCES} ${shared_SOURCES}) - set_target_properties(sundials_sunmatrixdense_static - PROPERTIES OUTPUT_NAME sundials_sunmatrixdense CLEAN_DIRECT_OUTPUT 1) - install(TARGETS sundials_sunmatrixdense_static DESTINATION ${CMAKE_INSTALL_LIBDIR}) -endif(BUILD_STATIC_LIBS) - -# Rules for building and installing the shared library: -# - Add the build target for the SUNMATRIXDENSE library -# - Set the library name and make sure it is not deleted -# - Set VERSION and SOVERSION for shared libraries -# - Install the SUNMATRIXDENSE library -if(BUILD_SHARED_LIBS) - add_library(sundials_sunmatrixdense_shared SHARED ${sunmatrixdense_SOURCES} ${shared_SOURCES}) - - if(UNIX) - target_link_libraries(sundials_sunmatrixdense_shared m) - endif() - - set_target_properties(sundials_sunmatrixdense_shared - PROPERTIES OUTPUT_NAME sundials_sunmatrixdense CLEAN_DIRECT_OUTPUT 1) - set_target_properties(sundials_sunmatrixdense_shared - PROPERTIES VERSION ${sunmatrixlib_VERSION} SOVERSION ${sunmatrixlib_SOVERSION}) - install(TARGETS sundials_sunmatrixdense_shared DESTINATION ${CMAKE_INSTALL_LIBDIR}) -endif(BUILD_SHARED_LIBS) - -# Install the SUNMATRIXDENSE header files -install(FILES ${sunmatrixdense_HEADERS} DESTINATION include/sunmatrix) - -# If FCMIX is enabled, build and install the FSUNMATRIXDENSE library -if(F77_INTERFACE_ENABLE AND F77_FOUND) - set(fsunmatrixdense_SOURCES fsunmatrix_dense.c) - - if(BUILD_STATIC_LIBS) - add_library(sundials_fsunmatrixdense_static STATIC ${fsunmatrixdense_SOURCES}) - set_target_properties(sundials_fsunmatrixdense_static - PROPERTIES OUTPUT_NAME sundials_fsunmatrixdense CLEAN_DIRECT_OUTPUT 1) - install(TARGETS sundials_fsunmatrixdense_static DESTINATION ${CMAKE_INSTALL_LIBDIR}) - endif(BUILD_STATIC_LIBS) - - if(BUILD_SHARED_LIBS) - add_library(sundials_fsunmatrixdense_shared ${fsunmatrixdense_SOURCES}) - - # fsunmatrixdense depends on sunmatrixdense - target_link_libraries(sundials_fsunmatrixdense_shared sundials_sunmatrixdense_shared) - - set_target_properties(sundials_fsunmatrixdense_shared - PROPERTIES OUTPUT_NAME sundials_fsunmatrixdense CLEAN_DIRECT_OUTPUT 1) - set_target_properties(sundials_fsunmatrixdense_shared - PROPERTIES VERSION ${sunmatrixlib_VERSION} SOVERSION ${sunmatrixlib_SOVERSION}) - install(TARGETS sundials_fsunmatrixdense_shared DESTINATION ${CMAKE_INSTALL_LIBDIR}) - endif(BUILD_SHARED_LIBS) - -endif(F77_INTERFACE_ENABLE AND F77_FOUND) - -# -message(STATUS "Added SUNMATRIX_DENSE module") diff --git a/src/sundials/sunmatrix/dense/fsunmatrix_dense.c b/src/sundials/sunmatrix/dense/fsunmatrix_dense.c deleted file mode 100644 index b33bf73..0000000 --- a/src/sundials/sunmatrix/dense/fsunmatrix_dense.c +++ /dev/null @@ -1,83 +0,0 @@ -/* - * ----------------------------------------------------------------- - * Programmer(s): Daniel Reynolds @ SMU - * ----------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2020, 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 file (companion of fsunmatrix_dense.h) contains the - * implementation needed for the Fortran initialization of dense - * vector operations. - * ----------------------------------------------------------------- - */ - -#include -#include - -#include "fsunmatrix_dense.h" - -/* Define global matrix variables */ - -SUNMatrix F2C_CVODE_matrix; -SUNMatrix F2C_IDA_matrix; -SUNMatrix F2C_KINSOL_matrix; -SUNMatrix F2C_ARKODE_matrix; -SUNMatrix F2C_ARKODE_mass_matrix; - -/* Fortran callable interfaces */ - -void FSUNDENSEMAT_INIT(int *code, long int *M, long int *N, int *ier) -{ - *ier = 0; - - switch(*code) { - case FCMIX_CVODE: - if (F2C_CVODE_matrix) SUNMatDestroy(F2C_CVODE_matrix); - F2C_CVODE_matrix = NULL; - F2C_CVODE_matrix = SUNDenseMatrix((sunindextype)(*M), - (sunindextype)(*N)); - if (F2C_CVODE_matrix == NULL) *ier = -1; - break; - case FCMIX_IDA: - if (F2C_IDA_matrix) SUNMatDestroy(F2C_IDA_matrix); - F2C_IDA_matrix = NULL; - F2C_IDA_matrix = SUNDenseMatrix((sunindextype)(*M), - (sunindextype)(*N)); - if (F2C_IDA_matrix == NULL) *ier = -1; - break; - case FCMIX_KINSOL: - if (F2C_KINSOL_matrix) SUNMatDestroy(F2C_KINSOL_matrix); - F2C_KINSOL_matrix = NULL; - F2C_KINSOL_matrix = SUNDenseMatrix((sunindextype)(*M), - (sunindextype)(*N)); - if (F2C_KINSOL_matrix == NULL) *ier = -1; - break; - case FCMIX_ARKODE: - if (F2C_ARKODE_matrix) SUNMatDestroy(F2C_ARKODE_matrix); - F2C_ARKODE_matrix = NULL; - F2C_ARKODE_matrix = SUNDenseMatrix((sunindextype)(*M), - (sunindextype)(*N)); - if (F2C_ARKODE_matrix == NULL) *ier = -1; - break; - default: - *ier = -1; - } -} - - -void FSUNDENSEMASSMAT_INIT(long int *M, long int *N, int *ier) -{ - *ier = 0; - if (F2C_ARKODE_mass_matrix) SUNMatDestroy(F2C_ARKODE_mass_matrix); - F2C_ARKODE_mass_matrix = NULL; - F2C_ARKODE_mass_matrix = SUNDenseMatrix((sunindextype)(*M), - (sunindextype)(*N)); - if (F2C_ARKODE_mass_matrix == NULL) *ier = -1; -} diff --git a/src/sundials/sunmatrix/dense/fsunmatrix_dense.h b/src/sundials/sunmatrix/dense/fsunmatrix_dense.h deleted file mode 100644 index a218acb..0000000 --- a/src/sundials/sunmatrix/dense/fsunmatrix_dense.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * ----------------------------------------------------------------- - * Programmer(s): Daniel Reynolds @ SMU - * ----------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2020, 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 file (companion of fsunmatrix_dense.c) contains the - * definitions needed for the initialization of dense - * matrix operations in Fortran. - * ----------------------------------------------------------------- - */ - -#ifndef _FSUNMATRIX_DENSE_H -#define _FSUNMATRIX_DENSE_H - -#include -#include - -#ifdef __cplusplus /* wrapper to enable C++ usage */ -extern "C" { -#endif - -#if defined(SUNDIALS_F77_FUNC) -#define FSUNDENSEMAT_INIT SUNDIALS_F77_FUNC(fsundensematinit, FSUNDENSEMATINIT) -#define FSUNDENSEMASSMAT_INIT SUNDIALS_F77_FUNC(fsundensemassmatinit, FSUNDENSEMASSMATINIT) -#else -#define FSUNDENSEMAT_INIT fsundensematinit_ -#define FSUNDENSEMASSMAT_INIT fsundensemassmatinit_ -#endif - - -/* Declarations of global variables */ - -extern SUNMatrix F2C_CVODE_matrix; -extern SUNMatrix F2C_IDA_matrix; -extern SUNMatrix F2C_KINSOL_matrix; -extern SUNMatrix F2C_ARKODE_matrix; -extern SUNMatrix F2C_ARKODE_mass_matrix; - -/* - * Prototypes of exported functions - * - * FSUNDENSEMAT_INIT - initializes dense matrix operations for main problem - * FSUNDENSEMASSMAT_INIT - initializes dense matrix operations for mass matrix solver - */ - -void FSUNDENSEMAT_INIT(int *code, long int *M, long int *N, int *ier); -void FSUNDENSEMASSMAT_INIT(long int *M, long int *N, int *ier); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/sundials/sunnonlinsol/CMakeLists.txt b/src/sundials/sunnonlinsol/CMakeLists.txt deleted file mode 100644 index fafb21b..0000000 --- a/src/sundials/sunnonlinsol/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -# ------------------------------------------------------------------------------ -# Programmer(s): David J. Gardner @ LLNL -# ------------------------------------------------------------------------------ -# SUNDIALS Copyright Start -# Copyright (c) 2002-2020, 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 -# ------------------------------------------------------------------------------ -# nonlinear solver level CMakeLists.txt for SUNDIALS -# ------------------------------------------------------------------------------ - -# Always add SUNDIALS provided nonlinear solver modules -add_subdirectory(newton) -add_subdirectory(fixedpoint) - -if(PETSC_ENABLE AND PETSC_FOUND) - add_subdirectory(petscsnes) -endif(PETSC_ENABLE AND PETSC_FOUND) diff --git a/src/sundials/sunnonlinsol/fixedpoint/CMakeLists.txt b/src/sundials/sunnonlinsol/fixedpoint/CMakeLists.txt deleted file mode 100644 index 548c67c..0000000 --- a/src/sundials/sunnonlinsol/fixedpoint/CMakeLists.txt +++ /dev/null @@ -1,108 +0,0 @@ -# ------------------------------------------------------------------------------ -# Programmer(s): Daniel R. Reynolds @ SMU -# ------------------------------------------------------------------------------ -# SUNDIALS Copyright Start -# Copyright (c) 2002-2020, 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 -# ------------------------------------------------------------------------------ -# CMakeLists.txt file for the fixed-point SUNNonlinearSolver library -# ------------------------------------------------------------------------------ - -install(CODE "MESSAGE(\"\nInstall SUNNONLINSOL_FIXEDPOINT\n\")") - -# Add F90 module if F2003 interface is enabled -if(F2003_FOUND AND F2003_INTERFACE_ENABLE) - add_subdirectory(fmod) -endif(F2003_FOUND AND F2003_INTERFACE_ENABLE) - -# Add variable with the sources for the library -set(lib_SOURCES sunnonlinsol_fixedpoint.c) - -# Add variable with the common SUNDIALS sources to be included in the library -set(shared_SOURCES - ${sundials_SOURCE_DIR}/src/sundials/sundials_math.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_nvector.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_nvector_senswrapper.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_nonlinearsolver.c - ) - -# Add variable with the exported header files -set(lib_HEADERS - ${sundials_SOURCE_DIR}/include/sunnonlinsol/sunnonlinsol_fixedpoint.h - ) - -# Add source directory to include directories -include_directories(.) - -# Define C preprocessor flag -DBUILD_SUNDIALS_LIBRARY -add_definitions(-DBUILD_SUNDIALS_LIBRARY) - -# Rules for building and installing the static library: -# - Add the build target for the library -# - Set the library name and make sure it is not deleted -# - Install the library -if(BUILD_STATIC_LIBS) - add_library(sundials_sunnonlinsolfixedpoint_static STATIC ${lib_SOURCES} ${shared_SOURCES}) - set_target_properties(sundials_sunnonlinsolfixedpoint_static - PROPERTIES OUTPUT_NAME sundials_sunnonlinsolfixedpoint CLEAN_DIRECT_OUTPUT 1) - install(TARGETS sundials_sunnonlinsolfixedpoint_static DESTINATION ${CMAKE_INSTALL_LIBDIR}) -endif() - -# Rules for building and installing the shared library: -# - Add the build target for the library -# - Set the library name and make sure it is not deleted -# - Set VERSION and SOVERSION for shared libraries -# - Install the library -if(BUILD_SHARED_LIBS) - add_library(sundials_sunnonlinsolfixedpoint_shared SHARED ${lib_SOURCES} ${shared_SOURCES}) - - if(UNIX) - target_link_libraries(sundials_sunnonlinsolfixedpoint_shared m) - endif() - - set_target_properties(sundials_sunnonlinsolfixedpoint_shared - PROPERTIES OUTPUT_NAME sundials_sunnonlinsolfixedpoint CLEAN_DIRECT_OUTPUT 1) - set_target_properties(sundials_sunnonlinsolfixedpoint_shared - PROPERTIES VERSION ${sunnonlinsollib_VERSION} SOVERSION ${sunnonlinsollib_SOVERSION}) - install(TARGETS sundials_sunnonlinsolfixedpoint_shared DESTINATION ${CMAKE_INSTALL_LIBDIR}) -endif() - -# Install the header files -install(FILES ${lib_HEADERS} DESTINATION include/sunnonlinsol) - -# If FCMIX is enabled, build and install the F library -if(F77_INTERFACE_ENABLE AND F77_FOUND) - set(flib_SOURCES fsunnonlinsol_fixedpoint.c) - - if(BUILD_STATIC_LIBS) - add_library(sundials_fsunnonlinsolfixedpoint_static STATIC ${flib_SOURCES}) - set_target_properties(sundials_fsunnonlinsolfixedpoint_static - PROPERTIES OUTPUT_NAME sundials_fsunnonlinsolfixedpoint CLEAN_DIRECT_OUTPUT 1) - install(TARGETS sundials_fsunnonlinsolfixedpoint_static DESTINATION ${CMAKE_INSTALL_LIBDIR}) - endif() - - if(BUILD_SHARED_LIBS) - add_library(sundials_fsunnonlinsolfixedpoint_shared ${flib_SOURCES}) - - # depends on fnvecserial and sunnonlinsolfixedpoint - target_link_libraries(sundials_fsunnonlinsolfixedpoint_shared - sundials_fnvecserial_shared - sundials_sunnonlinsolfixedpoint_shared) - - set_target_properties(sundials_fsunnonlinsolfixedpoint_shared - PROPERTIES OUTPUT_NAME sundials_fsunnonlinsolfixedpoint CLEAN_DIRECT_OUTPUT 1) - set_target_properties(sundials_fsunnonlinsolfixedpoint_shared - PROPERTIES VERSION ${sunnonlinsollib_VERSION} SOVERSION ${sunnonlinsollib_SOVERSION}) - install(TARGETS sundials_fsunnonlinsolfixedpoint_shared DESTINATION ${CMAKE_INSTALL_LIBDIR}) - endif() - -endif() - -# -message(STATUS "Added SUNNONLINSOL_FIXEDPOINT module") diff --git a/src/sundials/sunnonlinsol/fixedpoint/fsunnonlinsol_fixedpoint.c b/src/sundials/sunnonlinsol/fixedpoint/fsunnonlinsol_fixedpoint.c deleted file mode 100644 index 77314bd..0000000 --- a/src/sundials/sunnonlinsol/fixedpoint/fsunnonlinsol_fixedpoint.c +++ /dev/null @@ -1,95 +0,0 @@ -/* ----------------------------------------------------------------------------- - * Programmer(s): Daniel R. Reynolds @ SMU - *----------------------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2020, 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 file contains the implementation of functions needed for initialization - * of the SUNNonlinearSolver fixed point module operations in Fortran. - *---------------------------------------------------------------------------*/ - -#include -#include - -#include "fsunnonlinsol_fixedpoint.h" - -/* Define global nonlinsol variables */ - -SUNNonlinearSolver F2C_CVODE_nonlinsol; -SUNNonlinearSolver F2C_IDA_nonlinsol; -SUNNonlinearSolver F2C_ARKODE_nonlinsol; - -/* Declarations of external global variables */ - -extern N_Vector F2C_CVODE_vec; -extern N_Vector F2C_IDA_vec; -extern N_Vector F2C_ARKODE_vec; - -/* Fortran callable interfaces */ - -void FSUNFIXEDPOINT_INIT(int *code, int *m, int *ier) -{ - *ier = 0; - - switch(*code) { - case FCMIX_CVODE: - if (F2C_CVODE_nonlinsol) SUNNonlinSolFree(F2C_CVODE_nonlinsol); - F2C_CVODE_nonlinsol = NULL; - F2C_CVODE_nonlinsol = SUNNonlinSol_FixedPoint(F2C_CVODE_vec, *m); - if (F2C_CVODE_nonlinsol == NULL) *ier = -1; - break; - case FCMIX_IDA: - if (F2C_IDA_nonlinsol) SUNNonlinSolFree(F2C_IDA_nonlinsol); - F2C_IDA_nonlinsol = NULL; - F2C_IDA_nonlinsol = SUNNonlinSol_FixedPoint(F2C_IDA_vec, *m); - if (F2C_IDA_nonlinsol == NULL) *ier = -1; - break; - case FCMIX_ARKODE: - if (F2C_ARKODE_nonlinsol) SUNNonlinSolFree(F2C_ARKODE_nonlinsol); - F2C_ARKODE_nonlinsol = NULL; - F2C_ARKODE_nonlinsol = SUNNonlinSol_FixedPoint(F2C_ARKODE_vec, *m); - if (F2C_ARKODE_nonlinsol == NULL) *ier = -1; - break; - default: - *ier = -1; - } -} - - -void FSUNFIXEDPOINT_SETMAXITERS(int *code, int *maxiters, int *ier) -{ - *ier = 0; - - switch(*code) { - case FCMIX_CVODE: - if (!F2C_CVODE_nonlinsol) { - *ier = -1; - return; - } - *ier = SUNNonlinSolSetMaxIters(F2C_CVODE_nonlinsol, *maxiters); - break; - case FCMIX_IDA: - if (!F2C_IDA_nonlinsol) { - *ier = -1; - return; - } - *ier = SUNNonlinSolSetMaxIters(F2C_IDA_nonlinsol, *maxiters); - break; - case FCMIX_ARKODE: - if (!F2C_ARKODE_nonlinsol) { - *ier = -1; - return; - } - *ier = SUNNonlinSolSetMaxIters(F2C_ARKODE_nonlinsol, *maxiters); - break; - default: - *ier = -1; - } -} diff --git a/src/sundials/sunnonlinsol/fixedpoint/fsunnonlinsol_fixedpoint.h b/src/sundials/sunnonlinsol/fixedpoint/fsunnonlinsol_fixedpoint.h deleted file mode 100644 index e84e962..0000000 --- a/src/sundials/sunnonlinsol/fixedpoint/fsunnonlinsol_fixedpoint.h +++ /dev/null @@ -1,56 +0,0 @@ -/*----------------------------------------------------------------------------- - * Programmer(s): Daniel R. Reynolds @ SMU - *----------------------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2020, 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 file contains the definitions needed for initialization of the - * SUNNonlinearSolver fixed-point moudule operations in Fortran. - *---------------------------------------------------------------------------*/ - -#ifndef _FSUNNONLINSOL_FIXEDPOINT_H -#define _FSUNNONLINSOL_FIXEDPOINT_H - -#include /* FCMIX_* solver IDs */ -#include - -#ifdef __cplusplus /* wrapper to enable C++ usage */ -extern "C" { -#endif - -#if defined(SUNDIALS_F77_FUNC) -#define FSUNFIXEDPOINT_INIT SUNDIALS_F77_FUNC(fsunfixedpointinit, FSUNFIXEDPOINTINIT) -#define FSUNFIXEDPOINT_SETMAXITERS SUNDIALS_F77_FUNC(fsunfixedpointsetmaxiters, FSUNFIXEDPOINTSETMAXITERS) -#else -#define FSUNFIXEDPOINT_INIT fsunfixedpointinit_ -#define FSUNFIXEDPOINT_SETMAXITERS fsunfixedpointsetmaxiters_ -#endif - -/* Declarations of global variables */ - -extern SUNNonlinearSolver F2C_CVODE_nonlinsol; -extern SUNNonlinearSolver F2C_IDA_nonlinsol; -extern SUNNonlinearSolver F2C_ARKODE_nonlinsol; - -/*----------------------------------------------------------------------------- - Prototypes of exported functions - - FSUNFIXEDPOINT_INIT - initializes fixed point nonlinear solver for main problem - FSUNFIXEDPOINT_SETMAXITERS - sets the maximum number of nonlinear iterations - ---------------------------------------------------------------------------*/ - -void FSUNFIXEDPOINT_INIT(int *code, int *m, int *ier); -void FSUNFIXEDPOINT_SETMAXITERS(int *code, int *maxiters, int *ier); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/sundials/sunnonlinsol/newton/CMakeLists.txt b/src/sundials/sunnonlinsol/newton/CMakeLists.txt deleted file mode 100644 index aa27199..0000000 --- a/src/sundials/sunnonlinsol/newton/CMakeLists.txt +++ /dev/null @@ -1,109 +0,0 @@ -# ------------------------------------------------------------------------------ -# Programmer(s): David J. Gardner @ LLNL -# ------------------------------------------------------------------------------ -# SUNDIALS Copyright Start -# Copyright (c) 2002-2020, 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 -# ------------------------------------------------------------------------------ -# CMakeLists.txt file for the Newton SUNNonlinearSolver library -# ------------------------------------------------------------------------------ - -install(CODE "MESSAGE(\"\nInstall SUNNONLINSOL_NEWTON\n\")") - -# Add F90 module if F2003 interface is enabled -if(F2003_FOUND AND F2003_INTERFACE_ENABLE) - add_subdirectory(fmod) -endif(F2003_FOUND AND F2003_INTERFACE_ENABLE) - -# Add variable with the sources for the library -set(lib_SOURCES sunnonlinsol_newton.c) - -# Add variable with the common SUNDIALS sources to be included in the library -set(shared_SOURCES - ${sundials_SOURCE_DIR}/src/sundials/sundials_math.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_nvector.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_nvector_senswrapper.c - ${sundials_SOURCE_DIR}/src/sundials/sundials_nonlinearsolver.c - ) - -# Add variable with the exported header files -set(lib_HEADERS - ${sundials_SOURCE_DIR}/include/sunnonlinsol/sunnonlinsol_newton.h - ) - -# Add source directory to include directories -include_directories(.) - -# Define C preprocessor flag -DBUILD_SUNDIALS_LIBRARY -add_definitions(-DBUILD_SUNDIALS_LIBRARY) - -# Rules for building and installing the static library: -# - Add the build target for the library -# - Set the library name and make sure it is not deleted -# - Install the library -if(BUILD_STATIC_LIBS) - add_library(sundials_sunnonlinsolnewton_static STATIC ${lib_SOURCES} ${shared_SOURCES}) - set_target_properties(sundials_sunnonlinsolnewton_static - PROPERTIES OUTPUT_NAME sundials_sunnonlinsolnewton CLEAN_DIRECT_OUTPUT 1) - install(TARGETS sundials_sunnonlinsolnewton_static DESTINATION ${CMAKE_INSTALL_LIBDIR}) -endif() - -# Rules for building and installing the shared library: -# - Add the build target for the library -# - Set the library name and make sure it is not deleted -# - Set VERSION and SOVERSION for shared libraries -# - Install the library -if(BUILD_SHARED_LIBS) - add_library(sundials_sunnonlinsolnewton_shared SHARED ${lib_SOURCES} ${shared_SOURCES}) - - if(UNIX) - target_link_libraries(sundials_sunnonlinsolnewton_shared m) - endif() - - set_target_properties(sundials_sunnonlinsolnewton_shared - PROPERTIES OUTPUT_NAME sundials_sunnonlinsolnewton CLEAN_DIRECT_OUTPUT 1) - set_target_properties(sundials_sunnonlinsolnewton_shared - PROPERTIES VERSION ${sunnonlinsollib_VERSION} SOVERSION ${sunnonlinsollib_SOVERSION}) - install(TARGETS sundials_sunnonlinsolnewton_shared DESTINATION ${CMAKE_INSTALL_LIBDIR}) -endif() - -# Install the header files -install(FILES ${lib_HEADERS} DESTINATION include/sunnonlinsol) - -# If FCMIX is enabled, build and install the F library -if(F77_INTERFACE_ENABLE AND F77_FOUND) - - set(flib_SOURCES fsunnonlinsol_newton.c) - - if(BUILD_STATIC_LIBS) - add_library(sundials_fsunnonlinsolnewton_static STATIC ${flib_SOURCES}) - set_target_properties(sundials_fsunnonlinsolnewton_static - PROPERTIES OUTPUT_NAME sundials_fsunnonlinsolnewton CLEAN_DIRECT_OUTPUT 1) - install(TARGETS sundials_fsunnonlinsolnewton_static DESTINATION ${CMAKE_INSTALL_LIBDIR}) - endif() - - if(BUILD_SHARED_LIBS) - add_library(sundials_fsunnonlinsolnewton_shared ${flib_SOURCES}) - - # depends on fnvecserial and sunnonlinsolnewton - target_link_libraries(sundials_fsunnonlinsolnewton_shared - sundials_fnvecserial_shared - sundials_sunnonlinsolnewton_shared) - - set_target_properties(sundials_fsunnonlinsolnewton_shared - PROPERTIES OUTPUT_NAME sundials_fsunnonlinsolnewton CLEAN_DIRECT_OUTPUT 1) - set_target_properties(sundials_fsunnonlinsolnewton_shared - PROPERTIES VERSION ${sunnonlinsollib_VERSION} SOVERSION ${sunnonlinsollib_SOVERSION}) - install(TARGETS sundials_fsunnonlinsolnewton_shared DESTINATION ${CMAKE_INSTALL_LIBDIR}) - endif() - -endif() - -# -message(STATUS "Added SUNNONLINSOL_NEWTON module") diff --git a/src/sundials/sunnonlinsol/newton/fsunnonlinsol_newton.c b/src/sundials/sunnonlinsol/newton/fsunnonlinsol_newton.c deleted file mode 100644 index b1028f1..0000000 --- a/src/sundials/sunnonlinsol/newton/fsunnonlinsol_newton.c +++ /dev/null @@ -1,95 +0,0 @@ -/* ----------------------------------------------------------------------------- - * Programmer(s): David J. Gardner @ LLNL - * ----------------------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2020, 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 file contains the implementation of functions needed for initialization - * of the SUNNonlinearSolver Newton moudule operations in Fortran. - * ---------------------------------------------------------------------------*/ - -#include -#include - -#include "fsunnonlinsol_newton.h" - -/* Define global nonlinsol variables */ - -SUNNonlinearSolver F2C_CVODE_nonlinsol; -SUNNonlinearSolver F2C_IDA_nonlinsol; -SUNNonlinearSolver F2C_ARKODE_nonlinsol; - -/* Declarations of external global variables */ - -extern N_Vector F2C_CVODE_vec; -extern N_Vector F2C_IDA_vec; -extern N_Vector F2C_ARKODE_vec; - -/* Fortran callable interfaces */ - -void FSUNNEWTON_INIT(int *code, int *ier) -{ - *ier = 0; - - switch(*code) { - case FCMIX_CVODE: - if (F2C_CVODE_nonlinsol) SUNNonlinSolFree(F2C_CVODE_nonlinsol); - F2C_CVODE_nonlinsol = NULL; - F2C_CVODE_nonlinsol = SUNNonlinSol_Newton(F2C_CVODE_vec); - if (F2C_CVODE_nonlinsol == NULL) *ier = -1; - break; - case FCMIX_IDA: - if (F2C_IDA_nonlinsol) SUNNonlinSolFree(F2C_IDA_nonlinsol); - F2C_IDA_nonlinsol = NULL; - F2C_IDA_nonlinsol = SUNNonlinSol_Newton(F2C_IDA_vec); - if (F2C_IDA_nonlinsol == NULL) *ier = -1; - break; - case FCMIX_ARKODE: - if (F2C_ARKODE_nonlinsol) SUNNonlinSolFree(F2C_ARKODE_nonlinsol); - F2C_ARKODE_nonlinsol = NULL; - F2C_ARKODE_nonlinsol = SUNNonlinSol_Newton(F2C_ARKODE_vec); - if (F2C_ARKODE_nonlinsol == NULL) *ier = -1; - break; - default: - *ier = -1; - } -} - - -void FSUNNEWTON_SETMAXITERS(int *code, int *maxiters, int *ier) -{ - *ier = 0; - - switch(*code) { - case FCMIX_CVODE: - if (!F2C_CVODE_nonlinsol) { - *ier = -1; - return; - } - *ier = SUNNonlinSolSetMaxIters(F2C_CVODE_nonlinsol, *maxiters); - break; - case FCMIX_IDA: - if (!F2C_IDA_nonlinsol) { - *ier = -1; - return; - } - *ier = SUNNonlinSolSetMaxIters(F2C_IDA_nonlinsol, *maxiters); - break; - case FCMIX_ARKODE: - if (!F2C_ARKODE_nonlinsol) { - *ier = -1; - return; - } - *ier = SUNNonlinSolSetMaxIters(F2C_ARKODE_nonlinsol, *maxiters); - break; - default: - *ier = -1; - } -} diff --git a/src/sundials/sunnonlinsol/newton/fsunnonlinsol_newton.h b/src/sundials/sunnonlinsol/newton/fsunnonlinsol_newton.h deleted file mode 100644 index ffc8443..0000000 --- a/src/sundials/sunnonlinsol/newton/fsunnonlinsol_newton.h +++ /dev/null @@ -1,56 +0,0 @@ -/* ----------------------------------------------------------------------------- - * Programmer(s): David J. Gardner @ LLNL - * ----------------------------------------------------------------------------- - * SUNDIALS Copyright Start - * Copyright (c) 2002-2020, 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 file contains the definitions needed for initialization of the - * SUNNonlinearSolver Newton moudule operations in Fortran. - * ---------------------------------------------------------------------------*/ - -#ifndef _FSUNNONLINSOL_NEWTON_H -#define _FSUNNONLINSOL_NEWTON_H - -#include /* FCMIX_* solver IDs */ -#include - -#ifdef __cplusplus /* wrapper to enable C++ usage */ -extern "C" { -#endif - -#if defined(SUNDIALS_F77_FUNC) -#define FSUNNEWTON_INIT SUNDIALS_F77_FUNC(fsunnewtoninit, FSUNNEWTONINIT) -#define FSUNNEWTON_SETMAXITERS SUNDIALS_F77_FUNC(fsunnewtonsetmaxiters, FSUNNEWTONSETMAXITERS) -#else -#define FSUNNEWTON_INIT fsunnewtoninit_ -#define FSUNNEWTON_SETMAXITERS fsunnewtonsetmaxiters_ -#endif - -/* Declarations of global variables */ - -extern SUNNonlinearSolver F2C_CVODE_nonlinsol; -extern SUNNonlinearSolver F2C_IDA_nonlinsol; -extern SUNNonlinearSolver F2C_ARKODE_nonlinsol; - -/* ----------------------------------------------------------------------------- - * Prototypes of exported functions - * - * FSUNNEWTON_INIT - initializes Newton nonlinear solver for main problem - * FSUNNEWTON_SETMAXITERS - sets the maximum number of nonlinear iterations - * ---------------------------------------------------------------------------*/ - -void FSUNNEWTON_INIT(int *code, int *ier); -void FSUNNEWTON_SETMAXITERS(int *code, int *maxiters, int *ier); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/vignettes/my-vignette.Rmd b/vignettes/my-vignette.Rmd index 3e1c97b..4700b92 100644 --- a/vignettes/my-vignette.Rmd +++ b/vignettes/my-vignette.Rmd @@ -4,7 +4,7 @@ author: "Satyaprakash Nayak" date: "`r Sys.Date()`" output: rmarkdown::html_vignette vignette: > - %\VignetteIndexEntry{sundialr - A wrapper around CVODE, CVODES solvers from SUNDIALS} + %\VignetteIndexEntry{sundialr - An Interface to 'SUNDIALS' Ordinary Differential Equation (ODE) Solvers} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- @@ -17,7 +17,7 @@ knitr::opts_chunk$set( ``` ## Introduction -Ordinary Differential Equations (ODEs) describe the rate of change of dependent variables with respect to a single independent variable and are used in many fields to model behavior of the system. There are many good `C` libraries available to solve (i.e., integrate systems of ODEs) and [SUNDIALS](https://computation.llnl.gov/projects/sundials/sundials-software) available from the Lawrence Livermore National Laboratory is a one of the most popular and well-respected `C` library for solving non-stiff and stiff systems of ODEs. +Ordinary Differential Equations (ODEs) describe the rate of change of dependent variables with respect to a single independent variable and are used in many fields to model behavior of the system. There are many good `C` libraries available to solve (i.e., integrate systems of ODEs) and [SUNDIALS](https://computing.llnl.gov/projects/sundials/sundials-software) available from the Lawrence Livermore National Laboratory is a one of the most popular and well-respected `C` library for solving non-stiff and stiff systems of ODEs. Currently, this package provides an interface to the `CVODE` and `CVODES` function (serial version) in the library which is used to solve ODEs (or Initial Value Problems) and calculate sensitivities. @@ -116,7 +116,7 @@ NumericVector ODE_Rcpp (double t, NumericVector y){ } ``` -The above is a re-write of the `cvRoberts_dns.c` example in the documentation of `CVODE`. The original example can be found the document [here](https://computation.llnl.gov/sites/default/files/public/cv_examples.pdf). +The above is a re-write of the `cvRoberts_dns.c` example in the documentation of `CVODE`. ### Putting everything together The entire `R` file to create right hand side of ODE function (which calculates rates of change) is as follows (also found [here](https://github.com/sn248/sundialr/blob/master/inst/examples/cv_Roberts_dns.r)): diff --git a/vignettes/my-vignette.html b/vignettes/my-vignette.html index 5913360..09d204e 100644 --- a/vignettes/my-vignette.html +++ b/vignettes/my-vignette.html @@ -12,30 +12,35 @@ - + sundialr - An Interface to ‘SUNDIALS’ Ordinary Differential Equation (ODE) Solvers - + + + - + + + @@ -315,13 +141,13 @@

sundialr - An Interface to ‘SUNDIALS’ Ordinary Differential Equation (ODE) Solvers

Satyaprakash Nayak

-

2020-05-31

+

2021-05-16

Introduction

-

Ordinary Differential Equations (ODEs) describe the rate of change of dependent variables with respect to a single independent variable and are used in many fields to model behavior of the system. There are many good C libraries available to solve (i.e., integrate systems of ODEs) and SUNDIALS available from the Lawrence Livermore National Laboratory is a one of the most popular and well-respected C library for solving non-stiff and stiff systems of ODEs.

+

Ordinary Differential Equations (ODEs) describe the rate of change of dependent variables with respect to a single independent variable and are used in many fields to model behavior of the system. There are many good C libraries available to solve (i.e., integrate systems of ODEs) and SUNDIALS available from the Lawrence Livermore National Laboratory is a one of the most popular and well-respected C library for solving non-stiff and stiff systems of ODEs.

Currently, this package provides an interface to the CVODE and CVODES function (serial version) in the library which is used to solve ODEs (or Initial Value Problems) and calculate sensitivities.

The four exported functions from the package are:

    @@ -353,121 +179,121 @@

    Writing the Differential Equations

    Using R

    Differential equations can be written as an R function or as an Rcpp function. Differential equations function must be written as

    -
    function(t, y, p){
    -  # code to write differential equations
    -  # using parameter vector (p) and state/entity vector (y)
    -  # should return `ydot`, the vector representing
    -  # rate of change of entities in `y`
    -  # length of `ydot` must be equal to `y1
    -}
    +
    function(t, y, p){
    +  # code to write differential equations
    +  # using parameter vector (p) and state/entity vector (y)
    +  # should return `ydot`, the vector representing
    +  # rate of change of entities in `y`
    +  # length of `ydot` must be equal to `y1
    +}

    where t represents time, y is the vector describing the values of states/entities of the ODE system at time t and p is the vector of parameters used to define the ODEs. The output of this function is a vector of rate of change of entities of y.

    The key aspect to keep in mind is that the signature of the function must be function(t,y,p). As an example, we try to solve the cv_Roberts_dns.c problem described above, the original code can be found here. An example of an R function is as follows:

    -
    ODE_R <- function(t, y, p){
    -
    -   ## initialize the derivative vector
    -   ydot <- vector(mode = "numeric", length = length(y))
    -   
    -   ## p (parameter vector input) is  [-0.04 1e04 3e07]
    -   
    -   ydot[1] = p[1]*y[1] + p[2]*y[2]*y[3]
    -   ydot[2] = -p[1]*y[1] - p[2]*y[2]*y[3] - p[3]*y[2]*y[2]
    -   ydot[3] = p[3]*y[2]*y[2]
    -
    -   ydot      ## return ydot
    -}
    +
    ODE_R <- function(t, y, p){
    +
    +   ## initialize the derivative vector
    +   ydot <- vector(mode = "numeric", length = length(y))
    +   
    +   ## p (parameter vector input) is  [-0.04 1e04 3e07]
    +   
    +   ydot[1] = p[1]*y[1] + p[2]*y[2]*y[3]
    +   ydot[2] = -p[1]*y[1] - p[2]*y[2]*y[3] - p[3]*y[2]*y[2]
    +   ydot[3] = p[3]*y[2]*y[2]
    +
    +   ydot      ## return ydot
    +}

    where p is a parameter vector with the values [-0.04 1e04 3e07].

    Using Rcpp

    Also, since this package using Rcpp to bundle the C code, we can use the notation used in Rcpp to describe the system of ODEs. The cv_Roberts_dns problem describe above can be described in an Rcpp function as follows (indices in C++ start from 0, functions need to declare their return type, here NumericVector and every expression ends in a semicolon, ;) :

    -
    #include <Rcpp.h>
    -using namespace Rcpp;
    -
    -// [[Rcpp::export]]
    -NumericVector ODE_Rcpp (double t, NumericVector y){
    -
    -  // Initialize ydot filled with zeros
    -  NumericVector ydot(y.length());
    -
    -  // p (parameter vector) is [-0.04 1e04 3e07]
    -  ydot[0] = p[0] * y[0] + p[1] * y[1] * y[2];
    -  ydot[1] = -p[0]*y[0] - p[1]*y[1]*y[2] - p[2]*y[1]*y[1]
    -  ydot[2] = p[2] * y[1] * y[1];
    -
    -  return ydot;
    -
    -}
    -

    The above is a re-write of the cvRoberts_dns.c example in the documentation of CVODE. The original example can be found the document here.

    +
    #include <Rcpp.h>
    +using namespace Rcpp;
    +
    +// [[Rcpp::export]]
    +NumericVector ODE_Rcpp (double t, NumericVector y){
    +
    +  // Initialize ydot filled with zeros
    +  NumericVector ydot(y.length());
    +
    +  // p (parameter vector) is [-0.04 1e04 3e07]
    +  ydot[0] = p[0] * y[0] + p[1] * y[1] * y[2];
    +  ydot[1] = -p[0]*y[0] - p[1]*y[1]*y[2] - p[2]*y[1]*y[1]
    +  ydot[2] = p[2] * y[1] * y[1];
    +
    +  return ydot;
    +
    +}
    +

    The above is a re-write of the cvRoberts_dns.c example in the documentation of CVODE.

    Putting everything together

    The entire R file to create right hand side of ODE function (which calculates rates of change) is as follows (also found here):

    -
    # ODEs described by an R function
    -ODE_R <- function(t, y, p){
    -
    -   ## initialize the derivative vector
    -   ydot <- vector(mode = "numeric", length = length(y))
    -   
    -   ## p (parameter vector) is  [-0.04 1e04 3e07]
    -   
    -   ydot[1] = p[1]*y[1] + p[2]*y[2]*y[3]
    -   ydot[2] = -p[1]*y[1] - p[2]*y[2]*y[3] - p[3]*y[2]*y[2]
    -   ydot[3] = p[3]*y[2]*y[2]
    -
    -   ydot      ## return ydot
    -}
    -
    -# ODEs can also be described using Rcpp
    -Rcpp::sourceCpp(code = '
    -
    -#include <Rcpp.h>
    -using namespace Rcpp;
    -
    -// [[Rcpp::export]]
    -NumericVector ODE_Rcpp (double t, NumericVector y){
    -
    -  // Initialize ydot filled with zeros
    -  NumericVector ydot(y.length());
    -
    -  // p (parameter vector) is [-0.04 1e04 3e07]
    -  ydot[0] = p[0] * y[0] + p[1] * y[1] * y[2];
    -  ydot[1] = -p[0]*y[0] - p[1]*y[1]*y[2] - p[2]*y[1]*y[1]
    -  ydot[2] = p[2] * y[1] * y[1];
    -
    -  return ydot;
    -
    -}')
    -
    -# Generate time vector, IC and call cvode to solve the equations
    -# R code to genrate time vector, IC and solve the equations
    -time_vec <- c(0.0, 0.4, 4.0, 40.0, 4E2, 4E3, 4E4, 4E5, 4E6, 4E7, 4E8, 4E9, 4E10)
    -IC <- c(1,0,0)
    -params <- c(0.04, 10000, 30000000)
    -reltol <- 1e-04
    -abstol <- c(1e-8,1e-14,1e-6)
    -
    -## Solving the ODEs using cvode function
    -df1 <- cvode(time_vec, IC, ODE_R , params, reltol, abstol)           ## using R
    -df2 <- cvode(time_vec, IC, ODE_Rcpp , params, reltol, abstol)        ## using Rcpp
    -
    -## Check that both solutions are identical
    -# identical(df1, df2)
    +
    # ODEs described by an R function
    +ODE_R <- function(t, y, p){
    +
    +   ## initialize the derivative vector
    +   ydot <- vector(mode = "numeric", length = length(y))
    +   
    +   ## p (parameter vector) is  [-0.04 1e04 3e07]
    +   
    +   ydot[1] = p[1]*y[1] + p[2]*y[2]*y[3]
    +   ydot[2] = -p[1]*y[1] - p[2]*y[2]*y[3] - p[3]*y[2]*y[2]
    +   ydot[3] = p[3]*y[2]*y[2]
    +
    +   ydot      ## return ydot
    +}
    +
    +# ODEs can also be described using Rcpp
    +Rcpp::sourceCpp(code = '
    +
    +#include <Rcpp.h>
    +using namespace Rcpp;
    +
    +// [[Rcpp::export]]
    +NumericVector ODE_Rcpp (double t, NumericVector y){
    +
    +  // Initialize ydot filled with zeros
    +  NumericVector ydot(y.length());
    +
    +  // p (parameter vector) is [-0.04 1e04 3e07]
    +  ydot[0] = p[0] * y[0] + p[1] * y[1] * y[2];
    +  ydot[1] = -p[0]*y[0] - p[1]*y[1]*y[2] - p[2]*y[1]*y[1]
    +  ydot[2] = p[2] * y[1] * y[1];
    +
    +  return ydot;
    +
    +}')
    +
    +# Generate time vector, IC and call cvode to solve the equations
    +# R code to genrate time vector, IC and solve the equations
    +time_vec <- c(0.0, 0.4, 4.0, 40.0, 4E2, 4E3, 4E4, 4E5, 4E6, 4E7, 4E8, 4E9, 4E10)
    +IC <- c(1,0,0)
    +params <- c(0.04, 10000, 30000000)
    +reltol <- 1e-04
    +abstol <- c(1e-8,1e-14,1e-6)
    +
    +## Solving the ODEs using cvode function
    +df1 <- cvode(time_vec, IC, ODE_R , params, reltol, abstol)           ## using R
    +df2 <- cvode(time_vec, IC, ODE_Rcpp , params, reltol, abstol)        ## using Rcpp
    +
    +## Check that both solutions are identical
    +# identical(df1, df2)

    The final output is the df1 matrix in which first column is time, second, third and fourth column are the values of y1, y2 and y3 respectively.

    -
    > df1
    -       [,1]         [,2]         [,3]       [,4]
    - [1,] 0e+00 1.000000e+00 0.000000e+00 0.00000000
    - [2,] 4e-01 9.851641e-01 3.386242e-05 0.01480205
    - [3,] 4e+00 9.055097e-01 2.240338e-05 0.09446793
    - [4,] 4e+01 7.158016e-01 9.185043e-06 0.28418924
    - [5,] 4e+02 4.505209e-01 3.222826e-06 0.54947590
    - [6,] 4e+03 1.832217e-01 8.943516e-07 0.81677741
    - [7,] 4e+04 3.898091e-02 1.621669e-07 0.96101893
    - [8,] 4e+05 4.936971e-03 1.984450e-08 0.99506301
    - [9,] 4e+06 5.170103e-04 2.069098e-09 0.99948299
    -[10,] 4e+07 5.204927e-05 2.082078e-10 0.99994795
    -[11,] 4e+08 5.184946e-06 2.073989e-11 0.99999482
    -[12,] 4e+09 5.246212e-07 2.098486e-12 0.99999948
    -[13,] 4e+10 6.043000e-08 2.417200e-13 0.99999994
    +
    > df1
    +       [,1]         [,2]         [,3]       [,4]
    + [1,] 0e+00 1.000000e+00 0.000000e+00 0.00000000
    + [2,] 4e-01 9.851641e-01 3.386242e-05 0.01480205
    + [3,] 4e+00 9.055097e-01 2.240338e-05 0.09446793
    + [4,] 4e+01 7.158016e-01 9.185043e-06 0.28418924
    + [5,] 4e+02 4.505209e-01 3.222826e-06 0.54947590
    + [6,] 4e+03 1.832217e-01 8.943516e-07 0.81677741
    + [7,] 4e+04 3.898091e-02 1.621669e-07 0.96101893
    + [8,] 4e+05 4.936971e-03 1.984450e-08 0.99506301
    + [9,] 4e+06 5.170103e-04 2.069098e-09 0.99948299
    +[10,] 4e+07 5.204927e-05 2.082078e-10 0.99994795
    +[11,] 4e+08 5.184946e-06 2.073989e-11 0.99999482
    +[12,] 4e+09 5.246212e-07 2.098486e-12 0.99999948
    +[13,] 4e+10 6.043000e-08 2.417200e-13 0.99999994
@@ -488,56 +314,56 @@

Solving a system of Differential-Algebraic Equations

res_3 &= y_1 + y_2 + y_3 - 1 \end{aligned} \] Here is the complete code for solving this system of DAEs,

-
DAE_R <- function(t, y, ydot, p){
-
-  # vector containing the residuals
-  res = vector(mode = "numeric", length = length(y))
-
-  # R indices start from 1
-  res[1] <- -0.04 * y[1] + 10000 * y[2] * y[3] - ydot[1]
-  res[2] <- -res[1] - 30000000 * y[2] * y[2] - ydot[2]
-  res[3] <- y[1] + y[2] + y[3] - 1.0
-
-  res
-}
-
-# R code to genrate time vector, IC and solve the equations
-time_vec <- c(0.0, 0.4, 4.0, 40.0, 4E2, 4E3, 4E4, 4E5, 4E6, 4E7, 4E8, 4E9, 4E10)
-IC <- c(1,0,0)                  # Initial value of y
-IRes <- c(-0.4, 0.4, 0)         # Initial value of ydot
-params <- c(0.04, 10000, 30000000)
-reltol <- 1e-04
-abstol <- c(1e-8,1e-14,1e-6)
-
-## Solving the DAEs using the ida function
-df1 <- sundialr::ida(time_vec, IC, IRes, DAE_R , params, reltol, abstol) 
+
DAE_R <- function(t, y, ydot, p){
+
+  # vector containing the residuals
+  res = vector(mode = "numeric", length = length(y))
+
+  # R indices start from 1
+  res[1] <- -0.04 * y[1] + 10000 * y[2] * y[3] - ydot[1]
+  res[2] <- -res[1] - 30000000 * y[2] * y[2] - ydot[2]
+  res[3] <- y[1] + y[2] + y[3] - 1.0
+
+  res
+}
+
+# R code to genrate time vector, IC and solve the equations
+time_vec <- c(0.0, 0.4, 4.0, 40.0, 4E2, 4E3, 4E4, 4E5, 4E6, 4E7, 4E8, 4E9, 4E10)
+IC <- c(1,0,0)                  # Initial value of y
+IRes <- c(-0.4, 0.4, 0)         # Initial value of ydot
+params <- c(0.04, 10000, 30000000)
+reltol <- 1e-04
+abstol <- c(1e-8,1e-14,1e-6)
+
+## Solving the DAEs using the ida function
+df1 <- sundialr::ida(time_vec, IC, IRes, DAE_R , params, reltol, abstol) 

Solving an ODE system with discontinuties in solution

The cvsolve function defined in sundialr package provides a convenience interface to solve ODEs with one or more discontinuities in solution. An example of such a system of ODEs would be pharmacokinetics of a drug with repeated bolus administration. Let’s look at a simple example of multiple doses of a drug with a first-order degradation administered intravenously. The ODE system for the drug is \[ \frac{dC}{dt} = -k_{el} * C \] where \(C\) is the concentration of the drug and \(k_{el}\) is the elimination rate of the drug. The \(R\) code for such a system is

-
ODErepeated_R <- function(t, y, p){
-
-  # vector containing the right hand side gradients
-  ydot = vector(mode = "numeric", length = length(y))
-
-  # R indices start from 1
-  ydot[1] = -p[1]*y[1]
-
-  ydot
-
-}
+
ODErepeated_R <- function(t, y, p){
+
+  # vector containing the right hand side gradients
+  ydot = vector(mode = "numeric", length = length(y))
+
+  # R indices start from 1
+  ydot[1] = -p[1]*y[1]
+
+  ydot
+
+}

We also need to define when the multiple doses are given and the state to which they are to be applied (here to be applied to the only state in the model, \(C\)). This is provided via the \(Events\) dataframe (here, \(TDOSE\) or the dosing dataframe).

-
TDOSE <- data.frame(ID = 1, TIMES = c(0, 10, 20, 30, 40, 50), VAL = 100)
-TDOSE
-#>   ID TIMES VAL
-#> 1  1     0 100
-#> 2  1    10 100
-#> 3  1    20 100
-#> 4  1    30 100
-#> 5  1    40 100
-#> 6  1    50 100
+
TDOSE <- data.frame(ID = 1, TIMES = c(0, 10, 20, 30, 40, 50), VAL = 100)
+TDOSE
+#>   ID TIMES VAL
+#> 1  1     0 100
+#> 2  1    10 100
+#> 3  1    20 100
+#> 4  1    30 100
+#> 5  1    40 100
+#> 6  1    50 100

TDOSE is a data frame with the index of the state to which discontinuity is to be applied (represented by ID), the times at which the discontinuity is to be applied (represented by TIMES) at the value to be added to the value of the state at that time-point. A typical example would be addition of the dose amount to the value of the concentration at the specified times, e.g., the TDOSE data frame says that a value of 100 is to be added to the concentration of the 1st state (the only state in this system) at the times specified by the TIMES column. In summary,

  • ID represents the index of the state with discontinuity

  • @@ -545,39 +371,39 @@

    Solving an ODE system with discontinuties in solution

  • VAL represents the value added to the value of the state at specified times.

The complete code for simulating such a system is

-
# Example of solving a set of ODEs with multiple discontinuities using cvsolve
-# A simple One dimensional equation, y = -0.1 * y
-# ODEs described by an R function
-ODE_R <- function(t, y, p){
-
-  # vector containing the right hand side gradients
-  ydot = vector(mode = "numeric", length = length(y))
-
-  # R indices start from 1
-  ydot[1] = -p[1]*y[1]
-
-  ydot
-
-}
-
-# R code to generate time vector, IC and solve the equations
-TSAMP <- seq(from = 0, to = 100, by = 0.1)      # sampling time points
-IC <- c(1)
-params <- c(0.1)
-
-# A dataset describing the dosing at times at which additions to y[1] are to be done
-# Names of the columns don't matter, but they MUST be in the order of state index,
-# times and Values at discontinuity.
-TDOSE <- data.frame(ID = 1, TIMES = c(0, 10, 20, 30, 40, 50), VAL = 100)
-
-df1 <- sundialr::cvsolve(TSAMP, c(1), ODE_R, params)         # solving without any discontinuity
-df2 <- sundialr::cvsolve(TSAMP, c(1), ODE_R, params, TDOSE)  # solving with discontinuity
-
-## Plot the solution with discontinuities
-## first column is time, second column is the state
-time <- df2[,1]
-y1 <- df2[,2]
-plot(time, y1, type = "l", lty = 1, main = "An ODE system with discontinuties", frame.plot = F)   
+
# Example of solving a set of ODEs with multiple discontinuities using cvsolve
+# A simple One dimensional equation, y = -0.1 * y
+# ODEs described by an R function
+ODE_R <- function(t, y, p){
+
+  # vector containing the right hand side gradients
+  ydot = vector(mode = "numeric", length = length(y))
+
+  # R indices start from 1
+  ydot[1] = -p[1]*y[1]
+
+  ydot
+
+}
+
+# R code to generate time vector, IC and solve the equations
+TSAMP <- seq(from = 0, to = 100, by = 0.1)      # sampling time points
+IC <- c(1)
+params <- c(0.1)
+
+# A dataset describing the dosing at times at which additions to y[1] are to be done
+# Names of the columns don't matter, but they MUST be in the order of state index,
+# times and Values at discontinuity.
+TDOSE <- data.frame(ID = 1, TIMES = c(0, 10, 20, 30, 40, 50), VAL = 100)
+
+df1 <- sundialr::cvsolve(TSAMP, c(1), ODE_R, params)         # solving without any discontinuity
+df2 <- sundialr::cvsolve(TSAMP, c(1), ODE_R, params, TDOSE)  # solving with discontinuity
+
+## Plot the solution with discontinuities
+## first column is time, second column is the state
+time <- df2[,1]
+y1 <- df2[,2]
+plot(time, y1, type = "l", lty = 1, main = "An ODE system with discontinuties", frame.plot = F)   

Note that in the example above, TSAMP is the sampling time at which the solution is desired. Also, even though an Initial Value of \(y_1\) of 1 is provided by the IC parameter, it is overwritten by the value of 100 provided in the TDOSE data frame. In general, the values in the initial conditions are overwritten by values in the Events input.

@@ -613,26 +439,26 @@

System of ODEs for Parameter Sensitivities

Calculation of Sensitivities using CVODES

Once, the system of ODEs has been defined using the instructions provided above, sensitivities can be easily calculated using the cvodes function using the function call below (the entire code can be found at this link)

-
df1 <- cvodes(time_vec, IC, ODE_R , params, reltol, abstol,"STG",F)  ## using R
-df2 <- cvodes(time_vec, IC, ODE_Rcpp , params, reltol, abstol,"STG",F)  ## using Rcpp
+
df1 <- cvodes(time_vec, IC, ODE_R , params, reltol, abstol,"STG",F)  ## using R
+df2 <- cvodes(time_vec, IC, ODE_Rcpp , params, reltol, abstol,"STG",F)  ## using Rcpp

The additional arguments in cvodes specify the senstivity calculation method to be used (STG for STAGGERED or SIM for SIMULATENOUS) and flag for error control (either T or F).

The output of cvodes is a matrix with number of rows equal to the length of the time vector (time_vec) and the number of columns being equal to length of (y \(\times\) p + 1). The first columns is for time. Currently, the sensitivity of every enitity is calculated with respect to every parameter in model. For example, for the current model with 3 entities (ODEs) and 3 parameters, a total of 9 sensitivities are calculated at each output time, i.e. y1 w.r.t p1, p2, p3, y2 w.r.t. p1, p2, p3 and so on. The first 3 (length(y)) columns give sensitivity w.r.t the first parameter, the next 3 (length(y)) columns give sensitivity w.r.t the second parameter and so on.

In the Sensitivity Matrix output for the systems of equations described above, the first column gives output time, the next 3 columns provide sensitivity of y1, y2 and y3 w.r.t first parameter (say p1), the next three columns provide sensitivity of y1, y2 and y3 w.r.t. the second parameter (p2) and so on. The output Sensitivity Matrix is given below. The sensitivity values match with the values provided in the CVODES documentation.

-
> df1
-       [,1]          [,2]          [,3]         [,4]         [,5]          [,6]          [,7]          [,8]          [,9]        [,10]
- [1,] 0e+00  0.000000e+00  0.000000e+00 0.000000e+00 0.000000e+00  0.000000e+00  0.000000e+00  0.000000e+00  0.000000e+00 0.000000e+00
- [2,] 4e-01 -3.561085e-01  3.902252e-04 3.557183e-01 9.483149e-08 -2.132509e-10 -9.461823e-08 -1.573297e-11 -5.289692e-13 1.626194e-11
- [3,] 4e+00 -1.876130e+00  1.792229e-04 1.875951e+00 2.961233e-06 -5.830758e-10 -2.960650e-06 -4.932970e-10 -2.762408e-13 4.935732e-10
- [4,] 4e+01 -4.247395e+00  4.592812e-05 4.247349e+00 1.372964e-05 -2.357270e-10 -1.372941e-05 -2.288274e-09 -1.138015e-13 2.288387e-09
- [5,] 4e+02 -5.958192e+00  3.545986e-06 5.958189e+00 2.273754e-05 -2.260807e-11 -2.273752e-05 -3.789554e-09 -4.994795e-14 3.789604e-09
- [6,] 4e+03 -4.750132e+00 -5.991971e-06 4.750138e+00 1.880937e-05  2.312156e-11 -1.880939e-05 -3.134824e-09 -1.875976e-14 3.134843e-09
- [7,] 4e+04 -1.574902e+00 -2.761679e-06 1.574905e+00 6.288404e-06  1.100645e-11 -6.288415e-06 -1.047876e-09 -4.536508e-15 1.047881e-09
- [8,] 4e+05 -2.363168e-01 -4.584043e-07 2.363173e-01 9.450741e-07  1.832930e-12 -9.450760e-07 -1.574929e-10 -6.362045e-16 1.574935e-10
- [9,] 4e+06 -2.566355e-02 -5.105587e-08 2.566361e-02 1.026491e-07  2.042044e-13 -1.026493e-07 -1.711080e-11 -6.851356e-17 1.711087e-11
-[10,] 4e+07 -2.597859e-03 -5.190342e-09 2.597864e-03 1.039134e-08  2.076100e-14 -1.039136e-08 -1.732552e-12 -6.930923e-18 1.732559e-12
-[11,] 4e+08 -2.601996e-04 -5.199259e-10 2.602002e-04 1.040802e-09  2.079717e-15 -1.040804e-09 -1.737821e-13 -6.951356e-19 1.737828e-13
-[12,] 4e+09 -2.648142e-05 -5.616896e-11 2.648147e-05 1.059193e-10  2.246502e-16 -1.059195e-10 -1.804535e-14 -7.218146e-20 1.804542e-14
-[13,] 4e+10 -2.899376e-06 -7.759920e-12 2.899383e-06 1.159764e-11  3.104024e-17 -1.159768e-11 -1.727574e-15 -6.910296e-21 1.727581e-15
+
> df1
+       [,1]          [,2]          [,3]         [,4]         [,5]          [,6]          [,7]          [,8]          [,9]        [,10]
+ [1,] 0e+00  0.000000e+00  0.000000e+00 0.000000e+00 0.000000e+00  0.000000e+00  0.000000e+00  0.000000e+00  0.000000e+00 0.000000e+00
+ [2,] 4e-01 -3.561085e-01  3.902252e-04 3.557183e-01 9.483149e-08 -2.132509e-10 -9.461823e-08 -1.573297e-11 -5.289692e-13 1.626194e-11
+ [3,] 4e+00 -1.876130e+00  1.792229e-04 1.875951e+00 2.961233e-06 -5.830758e-10 -2.960650e-06 -4.932970e-10 -2.762408e-13 4.935732e-10
+ [4,] 4e+01 -4.247395e+00  4.592812e-05 4.247349e+00 1.372964e-05 -2.357270e-10 -1.372941e-05 -2.288274e-09 -1.138015e-13 2.288387e-09
+ [5,] 4e+02 -5.958192e+00  3.545986e-06 5.958189e+00 2.273754e-05 -2.260807e-11 -2.273752e-05 -3.789554e-09 -4.994795e-14 3.789604e-09
+ [6,] 4e+03 -4.750132e+00 -5.991971e-06 4.750138e+00 1.880937e-05  2.312156e-11 -1.880939e-05 -3.134824e-09 -1.875976e-14 3.134843e-09
+ [7,] 4e+04 -1.574902e+00 -2.761679e-06 1.574905e+00 6.288404e-06  1.100645e-11 -6.288415e-06 -1.047876e-09 -4.536508e-15 1.047881e-09
+ [8,] 4e+05 -2.363168e-01 -4.584043e-07 2.363173e-01 9.450741e-07  1.832930e-12 -9.450760e-07 -1.574929e-10 -6.362045e-16 1.574935e-10
+ [9,] 4e+06 -2.566355e-02 -5.105587e-08 2.566361e-02 1.026491e-07  2.042044e-13 -1.026493e-07 -1.711080e-11 -6.851356e-17 1.711087e-11
+[10,] 4e+07 -2.597859e-03 -5.190342e-09 2.597864e-03 1.039134e-08  2.076100e-14 -1.039136e-08 -1.732552e-12 -6.930923e-18 1.732559e-12
+[11,] 4e+08 -2.601996e-04 -5.199259e-10 2.602002e-04 1.040802e-09  2.079717e-15 -1.040804e-09 -1.737821e-13 -6.951356e-19 1.737828e-13
+[12,] 4e+09 -2.648142e-05 -5.616896e-11 2.648147e-05 1.059193e-10  2.246502e-16 -1.059195e-10 -1.804535e-14 -7.218146e-20 1.804542e-14
+[13,] 4e+10 -2.899376e-06 -7.759920e-12 2.899383e-06 1.159764e-11  3.104024e-17 -1.159768e-11 -1.727574e-15 -6.910296e-21 1.727581e-15

In future, I intend to provide options to select specific entities and parameters with respect to which sensitivities are to be computed as the sensitivity matrix can get very large for medium to large models.