cvode-不收敛与min step的问题

博客讨论了在使用CVODE求解器时如何处理不收敛的步长问题。解答指出,虽然CVODE有最小步长设置,但这并不能强制求解器在不收敛时继续进行。建议使用更宽松的容差来允许在困难区域中损失精度,并在过后恢复精度。此外,给出了一个示例,说明如何在达到最小步长时动态调整容差,确保求解器能够继续推进并适时收紧容差。
摘要由CSDN通过智能技术生成

https://groups.google.com/g/sundials-users/c/AFjXpOtdmME/m/jmIPhD-rBQAJ


Question:

Hi there,

before using CVODE I was writing single-step, implicit solvers with
variable time steps. And depending on the convergence criteria the
time step could get very small. However, in order not to break out the
solution I enforced a minimum time step (accepting the reduction in
accuracy).

Can this be done with CVODE as well? I mean, force the solver to go on
even if he can’t converge at a certain time step which would normally
cause him to slow down?

Thanks for any suggestions!
Bye - Andreas

CVODE在不收敛的时候,能否通过设置min step来跳过这些不收敛的点?


回答一

Although CVODE has an option for setting a minimum value for the step
size (CVodeSetMinStep), this will not help your problem. The hmin value
in CVODE has a role opposite to what you want: you can look at it as a
mechanism for stopping the integrator when accuracy requirements would
drive the step size below the prescribed limit.

CVODE strives to satisfy first the tolerance requirements and not
limitations on step size.

The answer to your problem is hidden in your question itself! You say
that in such regions, you are willing to accept a loss of accuracy. Then
you should just use looser tolerances in that region and then tighten
them back after you’re past the tough spot. You can change tolerances
between calls to CVode without having to restart it by using the
CVodeSetTolerances function (you can also change directly the variables
that you used to pass tolerances to CVodeMalloc, since CVODE stores them
by reference and not value. However, I am currently working on changes
to the code that will not allow this anymore, for different reasons, and
when the new codes will be released – probably in a week or so – this
option will not be available anymore).

Of course, to do this you’d have to call CVode in ONE_STEP mode. If you
do not know beforehand where these tough regions are, you should be able
to detect them by specifying minimum and maximum step sizes and by
monitoring the CVODE solver statistics and/or return values.

CVODE 首要是满足精确度要求,其次才是min step.
ONE_STEP模式可能可以解决你的问题。


回答二:

Since another user has asked the same question, I thought I’ll share an example on how tolerances can be controlled in order to enforce a minimum step size.

The attached file (cvdx1.c) is a modification of the cvdx CVODE/CVODES example:

  • When HMIN is reached (CV_ERR_FAILURE or CV_CONV_FAILURE return from CVode), looser tolerances are estimated such that
    the solver can proceed with order 1 without the step size going below HMIN.
  • The absolute tolerance estimates are based on the current value of y’’ (see comments for function loosen_tol).
  • While proceeding with looser tolerances, we check for sufficient increase in the step size and, when it reaches
    H_FACT*HMIN, we tighten the tolerances back to their original values and reset the maximum order to 5 (BDF).
  • Note that one could tighten the tolerances in stages and continue with backward Euler until the tolerances reached
    their original values.

See the comments in cvdx1.c for more details on the absolute tolerance control strategy. Note that cvdx1 uses CVODES. To
use it with CVODE, just replace
#include “cvodes.h”
with
#include “cvode.h”

IMPORTANT: Unfortunately, the current implementation of CVodeSetMaxOrd in CVODE/CVODES does not allow an increase in the
maximum order. This is a limitation that we have already removed in the development version. Until the next release, you
can just comment out the test
if (maxord > qmax) {

}
in the function CVodeSetMaxOrd (files cvodeio.c and cvodesio.c in CVODE and CVODES, respectively). However, make sure
you never increase the maximum order beyond the value it had whenever CVodeMalloc was called (the default values for
qmax are 12 and 5 for Adams and BDF, respectively).

I hope this example is helpful.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值