绑定一个odeint变量 [英] Bound an odeint variable

查看:92
本文介绍了绑定一个odeint变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用odeint来模拟其中存在多个不应小于零的变量的系统。



是否有适当的方法来绑定变量?

解决方案

odeint中没有这种可能性。我猜没有算法可以做到这一点。您必须以某种方式在ODE中对边界进行编码。



如果您只想在系统演进过程中找到边界,请使用

$ b $这样的循环b

  while(t< tmax)
{
stepper.do_step(ode,x,t,dt);
t + = dt;
if(check_bound(x,t))中断;
}

两个边节点,也许是您遇到的问题:


  1. 对于具有守恒律的ODE,有一些特殊算法,该算法可确保守恒律成立,例如,参见辛求解器。 / p>


  2. 如果绑定已经在ODE中以某种方式编码,并且无论如何都达到了绑定,则必须缩短求解器的步长。



I'm using odeint to simulate a system wherein there are several variables which should not go less than zero.

Is there an appropriate way to bound a variable in odeint to a particular range?

解决方案

There is no such possibility in odeint. And I guess there are no algorithms which could do that. You must somehow encode the bound in your ODE.

If you only want to find a bound during the evolution of your system use a loop like

while( t < tmax )
{
    stepper.do_step( ode , x , t , dt );
    t += dt;
    if( check_bound( x , t ) ) break;
}

Two side nodes, maybe this is the case for your problem:

  1. There are special algorithms for ODEs with have conservation laws where the algorithm ensures that the conservation law holds, see the symplectic solvers for example.

  2. If you bound is already encode in some way in your ODE and the bound is anyhow reached you must shorten the stepsize of the solver.

这篇关于绑定一个odeint变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆