Automatic Time Step and Order Selection in Time-Dependent Problems

2019年6月20日

在跟踪与时间有关的模拟的日志时,您可以观察到求解器使用不同的时间步骤和离散订单。在仿真过程中,您可能会发现时间步骤越小,解决方案需要很长时间才能完成。在这里,我们将讨论用于选择时间步长和离散订单的机制。在即将到来的博客文章中,我们将解释在小时步骤的情况下采取哪些措施来提高模拟效率。

瞬态模拟

瞬态仿真需要计算反映时间演变的离散解决方案。从初始值开始,未知的瞬态自由度是通过时间整合方案确定的。如果解决方案符合给定公差的预定义误差界限,则从时间步中的计算解决方案将被接受。自适应时间步长算法可能会使用太大的时间步骤,因此错误测试不会通过已经采取的步骤传递。在这些情况下,时间步长会减少并重复步骤。如果非线性求解器无法在最大迭代次数内求解代数方程,则时间步长也会减少。这两种机制都涉及额外的工作,因此可以导致更长时间的时间依赖性模拟。

该博客文章旨在帮助了解幕后使用的机制,并帮助阅读和解释求解器日志中提供的信息。在此博客文章的后续过程中,我们将利用对这些机制的理解来说明如何在遇到小时步骤时使时间步变更加高效和健壮。让我们首先查看求解器日志,看看我们可以从中了解什么。

时间相关的求解器日志

时间相关求解器的典型求解器日志看起来像这样:

时间 步长 Res 雅克 溶胶 命令 tfail NLfail LinErr Linres
0 0 -out 2 3 2 0 8E-14 3.5e-15
1 0.1 0.1 11 5 11 1 0 1 2.6e-16 2.4e-16
。。。 。。。 。。。 。。。 。。。 。。。 。。。 。。。 。。。 。。。 。。。

日志显示迭代计数器为了the time integration loop at the current时间where步长是当前时间步骤的大小。接下来的三列详细介绍了残差组装总数(Res),the total number of Jacobian assembles (雅克),和the total number of linear algebraic system solutions (溶胶)。

In this blog post, we are particularly interested in watching the discretization order of the time-stepping scheme (命令),自适应阶梯尺寸选择的故障数(tfail),以及代数(非线性)求解器的总失败(NLfail)。We discuss the meaning of these failures in the following sections. Information about the solutions of the last linear problem for each time step is available in terms of the linear algebraic system error estimate (LinErr) and the size of the linear algebraic system residuals (Linres)。

If you cannot find all of the time steps listed in the solver log, you can set the日志采样(墙壁锁)to 0 in the一般的section of the先进的node for the时间依赖性求解器。Sometimes it is helpful to add printouts from the individual algebraic solver iterations to the solver log by setting the溶胶ver logto详细的。这variation of the time step in the course of the simulation can be found illustrated in the corresponding收敛图, 在哪里theReciprocal of step sizeis printed for all time steps. Larger values in this plot indicate smaller time steps.

屏幕截图显示了ComsolMultiphysics®中的收敛图。

If you observe that the solver is taking very small time steps, it can be caused by several different reasons. One reason can be that your model is approaching some sort of singularity (physical or not), or that the solution is shooting off to infinity. Another reason can be that the model does not give a smooth time variation (for example, due to a too coarse mesh), which means that the error estimates will be difficult to fulfill for any time step. A third reason can be that the nonlinearities are difficult to handle (the algebraic solver does not converge). In order to see what the time step changes mean in detail, we have to dive deeper into the determination of the time step. Let us take a look at some time-stepping schemes used by the COMSOL® software.

离散的时间步变方案

时间依赖性求解器在comsolMultiphysics®软件中提供了三种不同的时间步骤方法:隐式落后公式(BDF),广义α方法,和显式runge – kutta方法家族。

BDF求解器是一种隐式求解器,它使用具有可变离散订单和自动步长选择的后退分化公式。当解决方案的质量允许时,使用高阶方案,并且在需要额外的鲁棒性时使用低阶方案。BDF方法are known for their stability and they are, by default, used for problems involving diffusion, convection, and reactions.

广义αmethod is a second-order implicit scheme that is popular for structural mechanics problems, but it is also well suited for wave propagation problems. The广义α方案使我们能够控制高频的阻尼,并且通常比二阶的阻尼较少BDF方案。在许多情况下,它比BDF但也不太稳定。

runge – kutta方法家族是通常用于普通微分方程(ODE)系统的明确方法。对于解决问题的问题,它们通常不那么有效有限元方法(FEM)。

In this blog post, we focus on theBDFtime-stepping scheme. TheBDF可以在时间步入section of the时间依赖性求解器。根据模型的物理,可以选择它。

屏幕快照,显示求解器设置中BDF方案的选择。

Settings for Time Step Selection

在里面时间Dependentstudy step, you provide the时代通过指定从开始时间到结束时间和中间步骤的明确列表来列表。使用范围操作员可以是指定中间点列表的快速方法。普遍的误解是,这些中间时间点是求解器采取的指定时间步骤,但是这些点是将解决方案存储用于后处理和评估的输出时间。默认情况下,求解器采取的时间步骤是由试图将错误(对于每个时间步)保持在所需限制内的算法确定的。以下设置可用于求解器采取的步骤在里面时间步入section of the时间依赖性求解器in order to affect the actual selection of the time steps:

  • Free:根据本地错误估计选择自适应时间步长。根据与公差相关的当前误差估计,时间步长减少或增加。如果采取步骤仍无法满足误差估计,则该步骤是通过减少步骤重做的(tfail记录在求解器日志中)。因此,由于失败的步骤徒劳无功,因此这种类型的阶梯尺寸减小是昂贵的。如果非线性求解器循环不在最大迭代次数范围内收敛,也会减少时间步长(NLfail记录在求解器日志中)。这specified output times are not related to the time steps taken by the solver. The solutions at the specified output times are computed by interpolation between steps taken by the solver.
  • 严格的:和Free设置,但是求解器正在调整其时间步长以解决指定的输出时间。
  • 中间的:和Freesetting, but the solver is adjusting its time step to solve also for at least one time in each of the subintervals defined by the output times.
  • 手动的:采取用户指定的时间步骤,而不是自动步骤。时间步可以是常数,全局变量表达式,也可以是从单调时间值列表之间的分离确定的。因此,该时间步已完全控制用户,并且禁用时间步的错误测试。但是请注意,代数求解器的误差估计仍然是活跃的,因此公差仍然很重要。如果在最大迭代次数之后未实现代数误差估计,则时间步长会减少。

在以下各节中,我们专注于Free时间步入。中间的和严格的time stepping can be used to combine the advantage of an adaptive time step selection with the manual enforcement of certain important modeling times or modeling time steps.严格的时间步进还避免了用户指定的时间列表的插值,这对于某些应用程序可能很重要。但是,请注意,也可以避免使用该输出的插值Free通过选择方法时代to store: Steps taken by solver

时间Discretization

在comsol多物理学中,通过有限元元素空间离散化,一种与时间相关的偏微分方程(PDE)系统变成了一个隐式ODES(或差分 - 代数方程;即DAE)的隐式系统。(请注意,不连续的Galerkin方法不是这种情况。)时间离散化(在最简单的情况下,向后的Euler方案)用于生成一组为未知自由度的代数方程。在每个时间步骤中,代数方程都是通过类似牛顿的方法求解的(通常是AFully Coupled求解器或a隔离solver with a damped Newton solver) using automatic linearization. The resulting linear equations are either solved by means of direct solvers (e.g., MUMPS or PARDISO) or by means of iterative solvers.

来自comsol多物理学中有限元离散化的隐式ode系统通过用户提供的相对和绝对公差的预定精度要求解决。有两种不同类型的要求,一种用于时间步长(求解器)错误,另一种用于代数方程(求解器)误差。第一种类型为活动Free,中间的, 和严格的方法,但不是手动的方法。第二个要求始终是活跃的。

相信不使用公差时,当时不使用公差是一种误解手动的使用方法。时间步长误差要求基于所使用方法的局部截断误差的估计。代数求解器误差正在使用非常相似的要求,就像解决固定问题时一样,即基于解决方案向量的增量的大小。但是,此误差估计值的归一化适用于时间依赖性求解器使用的归一化。这样做是为了使代数误差规范可与时间步长误差规范相媲美,从而减少代数求解器误差的标量因子(公差因子) should suppress the algebraic error evenly compared to the time-stepping error. It is sometimes important to reduce this factor to avoid polluting the computed solution with algebraic errors. In fact, if the algebraic error is not smaller than the time-stepping error, it can result in other problems, like time-stepping instabilities or failed error tests.

这two requirements mentioned, described further below, are central to solving an ODE system. But when this system stems from an FEM discretization, it is important to keep in mind that other sources of error are不是考虑到。示例是FEM方法的截断误差,使用数值方法近似有限元积分近似的正交误差,以及实际几何形状的多项式表示形式产生的几何近似误差。

本地和全局截断错误以及离散错误

让我们仔细研究截断错误。根据有限元离散化,我们获得了表单的隐式颂歌

l(\ dot {u},u,t)= 0,\ \ u(0)= u^0

whereu = [u_1(t),…,u_n(t)]is the vector of unknowns or the time-dependent degrees of freedoms andLis called the residual vector.

在这里,我们假设它仅包含一阶时间导数,并且我们无视约束处理以简单性。这BDFmethod of orderq带有可变步长\ tau_k通过使用关系来定义

u^k \ oit sum_ {i = 1}^q \ alpha_ {k,i} u^{k-i} + \ tau_k \ beta_k \ beta_k \ dot {u}(t_k)

符号的位置u^kis used as the approximation of the solutionu(t_k)with step-dependent coefficients\alpha_{k,i}\beta_k

此表示说明了名称向后分化公式。This formula can be used to eliminate the time derivative and to obtain an algebraic problem

l \ left(\ frac {u^k- \ sum_ {i = 1}^q \ alpha_ {k,i} u^{k-i}}} {\ tau_k \ beta_k},u^k,u^k,u^k,t_k \ right)= 0。

这local truncation error at timeT_Kis defined ase_ {k}:= u^k - u(t_k; u^{k-1}), 在哪里u(t_k; u^{k-1})is the exact solution fulfillingU(t_{k-1}) = U^{k-1}。通过泰勒的扩展,我们获得了

l(\ dot {u}(t_k; u^{k-1}) + o(e_k/\ tau_k) + o(\ tau_ {k}^q),u(t_k; u^{k-1})+e_k,t_k)= 0,


如果我们也泰勒扩大了残差,我们会得到

l(\ dot {u}(t_k; u^{k-1}),u(t_k; u^{k-1}),t_k)+\ frac {\ partial l} {\ partial l} {\ partial \ dot {u}}(o(e_k/\ tau_k) + o(\ tau_ {k}^q)) + \ frac {\ partial l} {\ partial u} e_k + {\ rm h。o。t。} = 0,


where the first term is identically zero per definition.

在质量矩阵的条件下D = -\frac{\partial{L}}{\partial \dot{U}}是可逆的,它遵循

| E_K |= o(\ tau_k^{q+1})

对于秩序q

For a noninvertible mass matrix, we have a DAE, and the error analysis is more elaborate, but the principles for adaptive time stepping are the same. Here, we have also assumed that the different time steps are somewhat related to each other so that the time steps do not change arbitrarily much from step to step. The global truncation errore^k:= u^k-u(t_k)是重要的。此错误会从所有本地错误中获得贡献;从概念上讲,所有本地错误累积。对于暂时的秩序方案q,并且有持续的时间步骤\ tau_k = \ tau,我们发现(合适的归一化)

|E^{k}| \le C \tau^q

在合适的假设下。在这里,常数Cis strongly problem dependent. The local errors for an actual ODE problem can both be amplified or damped by the nature of the equation, so the notion of a simple sum of the local errors should be taken with a grain of salt. For the case of amplification of errors, for example, the constant can be very large. Furthermore, the local errors obtained with a constant time step can be vastly different during the simulation. These observations suggest that a good strategy for choosing the time step is to keep the local errors at the same level during the time stepping. It should also be possible to adjust the level for the local errors so that the global error can be controlled and, if necessary, reduced.

对于给定的离散方案,可以以

e_ {k} = c_k \ tau^{q+1} u^{(q+1)}(t_k)+o(\ tau^{q+2})

whereC_K是可计算的功能q和过去的步骤尺寸\ tau_j,\,j \ le k

For example, an explicit analog ofBDFcan be used to compute a predictor

U^{k(0)} = \sum_{i=1}^q \alpha_{k,i}^{\rm pred} U^{k-i} + \tau_k \beta_k^{\rm pred} \dot{U}(t_{k-1}).

渐近分析给出了

u^k– U^{k(0)} = \bar{C}_k \tau ^{q+1} U^{(q+1)}(t_k) + O(\tau^{q+2})

具有可计算常数\bar{C}_k

因此,根据

| e_ {k} |\大约| \ bar {e} _K |:= \ frac {c_k} {\ bar {c} _k} | u^k-u^{k(0)} |。

该计算表达式在comsol多物理学中用作局部截断误差的近似值,而局部截断误差又用于控制或适应时间步。

BDF时间步长方案的时间步长控制

迈入的时间步骤BDF如果计时计划被接受|\bar{e}_{k}| \le A + R |U^{k}|为了绝对宽容A和相对容忍度,R。In case ofMfields withN_j田野自由度j,如果误差估计的加权根平方规范,时间步长就会接受

\ | \ bar {} _ {k,i}(q)|^2} {(a_i + r | u^{k} _i |)^2} <1

is less than1。这里,\ bar {e} _ {k,i}是对缩放或未缩放的字段组件的局部截断误差的估计值u_i^k时间T_K以及缩放或未量化的绝对耐受性A_I。请参阅该部分的“隐式时间有关的求解器算法”comsol多物理参考手册有关缩放和未量化版本的详细信息。

我们发现,每个时间步的错误取决于两个因素:

  1. 这size of the time step,\ tau_k
  2. 命令q的discretization scheme

Higher-order schemes give higher accuracy at higher costs, since the scheme involves more work to do. Shorter time steps give higher accuracy at higher costs because more time steps need to be computed in total. The adaptiveBDF时间步变方案,适应订单和时间步长,试图在保持所需准确性的同时最大程度地减少成本。它对时间步和顺序进行了复杂的猜测,但仍然可以是当前时间步长的结果不遵守错误限制。在这种情况下,时间步将通过较小的时间步长重复\ tau_k’和a step failuretfail被记录。

Controlling the Impact of the Algebraic Error

请注意,对于非线性问题,需要在每个时间步骤中求解一个非线性方程系统。这通常是通过牛顿样迭代方法来完成的,这些迭代方法会导致额外的代数误差。此外,牛顿方法中的线性化方程可能会用迭代线性求解器求解,该迭代线性求解器仅在一定程度上近似线性化系统的精确解。

这nonlinear solver might be failing to converge given a predefined number of iterations. In this case, the Jacobian matrix is updated and the time step is reduced, if necessary. In the log, you find that the counterNLfailis increased. The algebraic solver error is estimated by checking the increments\ delta^{k,m}:= u^{k,m} -u^{k,m-​​1}mthiteration in time stepk, 在哪里u^{k,m}is the approximation tou^k在里面Newton iterationm(see, for example,圣迪亚尔:非线性和差分/代数方程求解器的套件)。

这algebraic error| u^k-u^{k,m} |可能会污染截断误差并影响稳定性。您需要确保代数错误足够小。这公差因子(在Method and Terminationsection of theFully Coupled隔离求解器)是一个安全因子,可用于抑制与截断误差相比抑制代数误差。用于截断误差的加权规范以相似的形式用于代数误差。减少公差因子typically leads to an increasing (or the same) number of iterations in the nonlinear solver.

对于单独的时间步骤,解决方程较小的方程式更为昂贵公差因子。Note, however, that using a公差因子太大会导致代数错误,干扰时间步长的方法,并导致时间步长选择,不准确的方法或不稳定的方法。最后两个效果也可以是手动的时间步变方法。

时间步Selection and Order Selection

接下来,我们描述了时间步长选择方法BDF方案。对于时间依赖的求解器,绝对和相对公差控制每个集成步骤中的误差。相对容忍度,R,通常由物理设置确定,但我们可以切换到手动控制时间Dependentstudy step. The default value isR=0.01。绝对容忍度,A, can be set in the绝对宽容section of the时间依赖性求解器。为了因素选项in公差法,绝对公差是相对公差乘以指定因子。这手动的option allows us to specify a detailed value where the default isa = 0.001。这absolute tolerance can be applied individually to every field by using the变量列表。

求解器设置的屏幕截图,以进行时间步长和订单选择。

具体来说,BDF计算局部截断误差的估计值kth时间步长并需要误差估计以满足不平等\ | \ bar {e} _ {k} \ | _ {\ rm wrms} <1。在时间步长机制中,有一个特殊处理的初始阶段。对于前几个步骤,步长大小\ tau_k增加一倍,并提高订单,以获取价值Q = 1,2,3,…in every step until the local error test\ | \ bar {e} _ {k} \ | _ {\ rm wrms} <1失败;命令qis reduced by a mechanism that checks the smoothness of the solution; or the orderq达到最大顺序,Q = 5。选择订单BDF方案基于规模规范的要求| \ tau^k u^{(k)} |are monotonically decreasing ink为了knearq。这se norms are again estimated using the fact that

\ tau^{q+1} u^{(q+1)} \ lib t(q):=(q+1)\ bar {e} _k。

步骤和顺序选择始于测试单调性t(q)。下降的价值t(q)表明该解决方案是平滑的,并且可以增加订单。如果订单减少,如果t(q)随着q。Otherwise, the orderq保持。接下来,执行本地错误测试,如果失败,则该步骤是按顺序重做的Q’= Q和一个新的步骤大小\tau’。这latter is based on theo(\ tau^{q+1})渐近行为\bar{e}_k。和\bar{e}_{k,\tau} > A + R |U|,我们要求在更正的时间步骤\tau’, 至少\ bar {e} _ {k,\ tau’} = a+r | u |holds true, which gives rise to the new time step\tau’。Via

\frac{A+R|U|}{\bar{e}_{k,\tau}}= \frac{\bar{e}_{k,\tau’}}{\bar{e}_{k,\tau}} = \left( \frac{\tau’}{\tau} \right)^{q+1} < 1

we derive

\ tau’= \ left(\ frac {a+r | u |} {\ bar {e} _ {k,\ tau}}} \ right) ^{1/(q+1)} \ tau

where additional safety factors are used in the implementation.

如果误差小于允许的误差,则有一个所谓的“ DeadBeat”区域,在该区域中,直到误差比允许的误差小16倍之前,时间步长才增加。然后,时间步长增加了两个倍。请注意,确定时间步骤主要由限制器调节。调节器仅基于线性斜率方案中的给定公式。当估计的本地错误大于应有的情况,并且需要减少时间步长时,该制度正在裁定。在下图(类似于相应的图参考。1),you can identify the slope-1/(q+1)在里面linear slope regime, where\ log(\ tau_ {k+1}/\ tau_ {k})被印在\ log(| \ bar {e} _k |/(a+r | u^k |))

A plot of the linear slope regime for a time-dependent problem.

如果本地错误测试通过,则调整下一步的步骤和顺序。如果在上一步中更改了顺序,则没有更改。如果最后Q+1按恒定顺序采取步骤Q <5和a constant step size,BDF考虑提高或减少订单。命令q如果增加t(q)正在减少q, 和it is decreased ift(q)正在增加q。More details and heuristics can be found in the documentation of the非线性和差分/代数方程求解器(sundials)的IDA求解器

关于自动时间步长和订单选择的结论

在这篇博客文章中,我们讨论了BDF时间步变方案的自动步长和订单选择机制。这些机制旨在根据规定的公差以低成本和最大鲁棒性来确保溶液的准确性。实际上,我们发现这种机制可以导致很少的时间步骤和较长的模拟时间。太微小的时间步骤和时间依赖性和非线性求解器步骤的重复故障表明,可能需要对模型配置和求解器设置进行进一步调整。我们还应始终确保通过合理的解决方案很好地提出了基础模型。

在即将发布的博客文章中,我们将研究示例,并讨论在太微妙的时间步骤的情况下可以调整哪些求解器设置。敬请关注!

进一步阅读

通过浏览COMSOL知识库来获取有关解决时间依赖模型的更多详细信息:

参考

  1. G.Söderlind,L。Wang,“自适应时间稳定和计算稳定性“,J. Comp。并应用。数学。, vol. 185, pp. 225–243, 2006.

Comments (1)

发表评论
Log In | Registration
加载...
Mohammad Hdaib
Mohammad Hdaib
2021年5月20日

太感谢了

探索comsol乐动体育赛事播报博客