Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91612582
butcher_tableau.hpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Nov 12, 17:21
Size
3 KB
Mime Type
text/x-c++
Expires
Thu, Nov 14, 17:21 (2 d)
Engine
blob
Format
Raw Data
Handle
22293060
Attached To
rSPECMICP SpecMiCP / ReactMiCP
butcher_tableau.hpp
View Options
/*-------------------------------------------------------
- Module : odeint
- File : butcher_tableau.hpp
- Author : Fabien Georget
Copyright (c) 2014, Fabien Georget, Princeton University
---------------------------------------------------------*/
#ifndef SPECMICP_ODEINT_BUTCHERTABLEAU_HPP
#define SPECMICP_ODEINT_BUTCHERTABLEAU_HPP
//! \file butcher_tableau.hpp Butcher tableau for embedded runge kutta method
#include <array>
namespace specmicp {
namespace odeint {
template <int order, int s>
class ButcherTableau {
public:
static const int RK_order = order;
static const int RK_evaluations = s+1;
ButcherTableau(const std::array<double, s>& aa,
const std::array<std::array<double, s>, s>& ba,
const std::array<double, s+1>& ca,
const std::array<double, s+1>& csa
):
m_a(aa), m_b(ba), m_c(ca), m_cs(csa)
{}
ButcherTableau(std::array<double, s>&& aa,
std::array<std::array<double, s>, s>&& ba,
std::array<double, s+1>&& ca,
std::array<double, s+1>&& csa
):
m_a(aa), m_b(ba), m_c(ca), m_cs(csa)
{}
double a(int i) const {return m_a[i-2];}
double b(int i, int j) const {return m_b[i-2][j-1];}
double c(int i) const {return m_c[i-1];}
double cs(int i) const {return m_cs[i-1];}
private:
std::array<double, s> m_a;
std::array<std::array<double,s>, s> m_b;
std::array<double, s+1> m_c;
std::array<double, s+1> m_cs;
};
const ButcherTableau<5, 5> butcher_cash_karp45({1.0/5.0, 3.0/10.0, 3.0/5.0, 1.0, 7.0/8.0},
{ {{1.0/5.0, 0, 0, 0, 0},
{3.0/40.0, 9.0/40.0, 0, 0, 0},
{3.0/10.0, -9.0/10.0, 6.0/5.0, 0, 0},
{-11.0/54.0, 5.0/2.0, -70.0/27.0, 35.0/27.0, 0},
{1631.0/55296.0, 175.0/512.0, 575.0/13824.0, 44275.0/110592.0, 253.0/4096.0}
}},
{37.0/378.0, 0.0, 250.0/621.0, 125.0/594.0, 0.0, 512.0/1771.0},
{2825.0/27648.0, 0.0, 18575.0/48384.0, 13525.0/55296.0, 277.0/14336.0, 1.0/4.0}
);
using ButcherTableauCashKarp_t = ButcherTableau<5, 5>;
const ButcherTableau<5, 6> butcher_dormand_prince45(
{1.0/5.0, 3.0/10.0, 4.0/5.0, 8.0/9.0, 1.0, 1.0},
{ {{1.0/5.0, 0, 0, 0, 0, 0},
{3.0/40.0, 9.0/40.0, 0, 0, 0, 0},
{44.0/45.0, -56.0/15.0, 32.0/9.0, 0, 0, 0},
{19372.0/6561.0, -25360.0/2187.0, 64448.0/6561.0, -212.0/729.0, 0, 0},
{9017.0/3168.0, -355.0/33.0, 46732.0/5247.0, 49.0/176.0, -5103.0/18656.0, 0},
{35.0/384.0, 0.0, 500.0/1113.0, 125.0/192.0, -2187.0/6784.0, 11.0/84.0}
}},
{35.0/384.0, 0.0, 500.0/1113.0, 125.0/192.0, -2187.0/6784.0, 11.0/84.0, 0.0},
{5179.0/57600.0, 0.0, 7571.0/16695.0, 393.0/640.0, -92097.0/339200.0, 187.0/2100.0, 1.0/40.0}
);
using ButcherTableauDormandPrince_t = ButcherTableau<5, 6>;
} // end namespace odeint
} // end namespace specmicp
#endif // SPECMICP_ODEINT_BUTCHERTABLEAU_HPP
Event Timeline
Log In to Comment