Coder Social home page Coder Social logo

kylebaron / fatodec Goto Github PK

View Code? Open in Web Editor NEW

This project forked from metrumresearchgroup/fatodec

0.0 1.0 0.0 480 KB

C/C++ bindings of FATODE solver library

License: GNU General Public License v3.0

Makefile 0.19% C 0.59% C++ 56.02% Fortran 43.21%

fatodec's Introduction

FATODEc

C/C++ bindings of FATODE solver library. Currently doesn't support sparse matrix solvers, as the application is mainly for PKPD modeling.

Build

To make libfatode.a, in FATODEc run

make all

Quick start

One can find the following example in example/sho. Consult FATODE user guide for details.

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#include <fatodec.h>

static void f(int*, double*, double[], double[]);

int main(int argc, char *argv[])
{

  double tin = 0.0;
  double tout = 10.0;
  int nvar = 2;
  double   fy[2] = { 0.0, 2.0 };
  double rtol[2] = { 1.E-6, 1.E-6 };
  double atol[2] = { 1.E-10, 1.E-10 };
  int icntrl_u[20];
  double rcntrl_u[20];
  int istatus_u[20];
  double rstatus_u[20];
  int ierr_u;

  icntrl_u[0] = 0;
  icntrl_u[1] = 0;
  icntrl_u[2] = 4;
  icntrl_u[3] = 1000;

  rcntrl_u[0] = 1.E-4;
  rcntrl_u[1] = 0.1;
  rcntrl_u[2] = 0.1;
  rcntrl_u[3] = 0.2;
  rcntrl_u[4] = 6.0;
  rcntrl_u[5] = 0.1;
  rcntrl_u[6] = 0.9;
  rcntrl_u[9] = 1.0;
  rcntrl_u[10] = 1.2;

  integrate_fatode_fwd_erk( &tin, &tout, &nvar, fy, rtol, atol, f, icntrl_u, rcntrl_u, istatus_u, rstatus_u, &ierr_u );    

  printf("No. of function calls                          :  %d\n", istatus_u[0]);
  printf("No. of jacobian calls                          :  %d\n", istatus_u[1]);
  printf("No. of steps                                   :  %d\n", istatus_u[2]);
  printf("No. of accepted steps                          :  %d\n", istatus_u[3]);
  printf("No. of rejected steps (except at the beginning :  %d\n", istatus_u[4]);
  printf("No. of LU decompositions                       :  %d\n", istatus_u[5]);
  printf("No. of forward/backward substitutions          :  %d\n", istatus_u[6]);
  printf("No. of singular matrix decompositions          :  %d\n", istatus_u[7]);

  printf("T at exit                                      :  %f\n", rstatus_u[0]);
  printf("H at exit                                      :  %f\n", rstatus_u[1]);
  printf("H new                                          :  %f\n", rstatus_u[2]);

  return 0;
}

static void f(int* n, double* t, double y[], double fy[]) {
  double theta = 0.15;
  fy[0] = y[1];
  fy[1] = -y[0] - theta * y[1];
}

Sample output

No. of function calls                          :  728
No. of jacobian calls                          :  0
No. of steps                                   :  104
No. of accepted steps                          :  103
No. of rejected steps (except at the beginning :  0
No. of LU decompositions                       :  0
No. of forward/backward substitutions          :  0
No. of singular matrix decompositions          :  0
T at exit                                      :  10.000000
H at exit                                      :  0.020000
H new                                          :  0.100000

Test

In test

make all; ./roberts_test; ./sho_test; ./species_test; 

Use

Use C header FATODEc/include/fatodec.h or C++ header FATODEc/include/fatode_cc.hpp. The C++ interface is in namespace fatode_cc. Currently neither SUPER-LU or UMFPACK linear solver is supported.

Forward integration solvers(FWD)

  • Explicit Runge-Kutta integrate_fatode_fwd_erk (C & C++)
  • Fully Implicit Runge-Kutta methods integrate_fatode_fwd_rk (C & C++)
  • Rosenbrock methods integrate_fatode_fwd_ros (C & C++)
  • Singly Diagonally Implicit Runge-Kutta methods integrate_fatode_fwd_sdirk (C & C++)

Tangential linear model(TLM)

  • Explicit Runge-Kutta integrate_fatode_tlm_erk (C & C++)
  • Rosenbrock methods integrate_fatode_tlm_ros (C & C++)

TO-DO

Tangential linear model(TLM)

  • Fully Implicit Runge-Kutta methods integrate_fatode_tlm_rk
  • Singly Diagonally Implicit Runge-Kutta methods integrate_fatode_tlm_sdirk

Adjoint sensitivity solvers(ADJ)

  • Explicit Runge-Kutta integrate_fatode_adj_erk
  • Fully Implicit Runge-Kutta methods integrate_fatode_adj_rk
  • Rosenbrock methods integrate_fatode_adj_ros
  • Singly Diagonally Implicit Runge-Kutta methods integrate_fatode_adj_sdirk

fatodec's People

Contributors

yizhang-yiz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.