Odeint隐式欧拉的简单例子
odeint implicit euler simple example
我对使用隐式方案解决odeint库的ode系统感兴趣,并且我很难实现一个简单的implicit_euler
示例。
查看文档,我设法使工作显式步进器,自适应步进器,以及rosenbrock4
步进器。前者似乎是半含蓄的。因此,我对实现一个完全隐式的方案很感兴趣(同时在每个时间步检索雅可比矩阵)。但我没有设法找到这个步骤的文档和工作示例。我有的是
typedef boost::numeric::ublas::vector< double > vector_type;
typedef boost::numeric::ublas::matrix< double > matrix_type;`
struct stiff_system
{
void operator()( const vector_type &x , vector_type &dxdt , double /* t */ )
{
dxdt[ 0 ] = -101.0 * x[ 0 ] - 100.0 * x[ 1 ];
dxdt[ 1 ] = x[ 0 ];
}
};
struct stiff_system_jacobi
{
void operator()( const vector_type & /* x */ , matrix_type &J , const double & /* t */ , vector_type &dfdt )
{
J( 0 , 0 ) = -101.0;
J( 0 , 1 ) = -100.0;
J( 1 , 0 ) = 1.0;
J( 1 , 1 ) = 0.0;
dfdt[0] = 0.0;
dfdt[1] = 0.0;
}
};
typedef implicit_euler< double > stepper_IE;
vector_type inout( 2 , 1.0 );
size_t steps = integrate_const( stepper_IE() ,
std::make_pair( stiff_system() , stiff_system_jacobi() ) ,
inout , 0.0 , 5.0 , 0.01, streaming_observer( std::cout, x_vec , times ));
错误如下:
C:boost_1_55_0boostnumericodeintstepperimplicit_euler.hpp:94
:错误:C2064:术语不计算为具有3个参数的函数类没有定义一个"operator()
"或用户定义的转换操作符,该转换操作符指向具有适当数量参数的指针到函数或引用到函数
我现在的问题是:有没有人知道如何使它工作,或者有人能给我指一个比这个更详细的文档:
codeproject上文档
或者这个
主页面
谢谢
不幸的是,隐式欧拉方法和Rosenbrock求解器(另一种隐式求解器)没有相同的接口。详细地说,隐式欧拉期望雅可比矩阵的函数具有以下签名
void jacobian( const state_type &x , matrix_type &jacobi , const value_type t );
因此,您需要将stiff_system_jacobi
的定义更改为
struct stiff_system_jacobi
{
void operator()( const vector_type & , matrix_type &J , const double & ) const
{
J( 0 , 0 ) = -101.0;
J( 0 , 1 ) = -100.0;
J( 1 , 0 ) = 1.0;
J( 1 , 1 ) = 0.0;
}
};
如果你的系统真的是非自治的,你需要通过一个额外的坐标来增强你的状态类型,这个坐标代表时间,并且具有微不足道的动态dt/dt = 1
相关文章:
- 在c++中用vector填充一个简单的动态数组
- (C++)分析树以计算返回错误值的简单算术表达式
- 我的简单if-else语句是如何无法访问的代码
- 使用简单类型列表实现的指数编译时间.为什么
- 如何在BST的这个简单递归实现中消除警告
- 一种在C++中读取TXT配置文件的简单方法
- 关于简单C++函数(is_palindrome)的逻辑的问题
- 显示错误输出的简单数组排序程序
- 当无法使用模板和宏时,生成类型变体C++代码的最简单方法是什么?
- 退出简单while循环时出现问题
- 为什么简单的算术减法在"if"条件下不起作用?
- boost odeint什么时候真正调用观测者
- C++-字符串是否包含一个带有简单循环的单词
- 关于 c++ 函数中指针赋值的简单问题
- 从函数返回任意简单类型的数据
- 如何在没有函数的情况下编写此代码并使C++更简单?
- 如何在C++中使用Thrust和odeint求解简单的常微分方程
- Odeint隐式欧拉的简单例子
- 使用boost:odeint的简单c++程序中的断言错误
- 使用odeint的简单2d系统(使用数组)无法编译