我有以下odeint程序:
#include <boost/array.hpp>
#include <boost/numeric/odeint.hpp>
using namespace std;
typedef boost::array< double , 1 > state_type;
void eqsystem(const state_type &x, state_type &dxdt, double t) {
dxdt[0] = 3;
}
void write_system( const state_type &x , const double t ) {
cout << t << '\t' << x[0] << endl;
}
int main(){
double t0=0, t1=100;
double tstep0=0.01;
state_type x = {{ 0 }};
cout<<"t\tValue"<<endl;
boost::numeric::odeint::integrate( eqsystem , x , t0 , t1 , tstep0 , write_system );
}每次t是10的倍数时,我都想设置x[0]=0.1。
也就是说,我希望有一个递归的增量函数。
或者,如果我可以让增量函数在有限的时间点上出现,我将能够近似递归。
不幸的是,我在odeint中找不到增量函数的文档。有谁知道如何做到这一点吗?
发布于 2013-01-16 01:07:14
这在odeint中是不可能的,至少在一般情况下是不可能的。您有两种选择:
首先,用非常敏锐的高斯近似增量峰值。
第二,整合到高峰期的时间点。应用增量峰值,即向您现有的解决方案添加一个步骤,并开始从这一点集成到下一个峰值,依此类推。
对于具有不连续性的ODE,有als“奇异”方法,但它们通常处理当ODE本身具有不连续性而不是外部驱动时的情况。
https://stackoverflow.com/questions/14342063
复制相似问题