找回密码
 注册
查看: 891|回复: 0

R语言 rootSolve包 stodes()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-9-27 23:01:17 | 显示全部楼层 |阅读模式
stodes(rootSolve)
stodes()所属R语言包:rootSolve

                                         Steady-state solver for ordinary differential equations (ODE) with a sparse jacobian.
                                         稳态求解常微分方程(ODE)与稀疏Jacobian。

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

Estimates the steady-state condition for a system of ordinary differential equations (ODE) in the form:
估计的稳定状态,系统的常微分方程(ODE)的形式:

and where the jacobian matrix df/dy has an arbitrary sparse structure.
和雅可比矩阵DF / DY具有任意的稀疏结构。

Uses a newton-raphson method, implemented in Fortran.
采用了Newton-Raphson方法,Fortran语言实现的。

The system of ODE's is written as an R function or defined in compiled code that has been dynamically loaded.
该系统的ODE的书面一个R函数或定义在编译的代码已被动态加载。


用法----------Usage----------


stodes(y, time = 0, func, parms = NULL, rtol = 1e-6, atol = 1e-8,
       ctol = 1e-8, sparsetype = "sparseint", verbose = FALSE,
       nnz = NULL, inz = NULL, lrw = NULL, ngp = NULL,
       positive = FALSE, maxiter = 100, ynames = TRUE,
       dllname = NULL, initfunc = dllname, initpar = parms,
       rpar = NULL, ipar = NULL, nout = 0, outnames = NULL,
       forcings = NULL, initforc = NULL, fcontrol = NULL,
       spmethod = "yale", control = NULL,...)



参数----------Arguments----------

参数:y
the initial guess of (state) values for the ode system, a vector. If y has a name attribute, the names will be used to label the output matrix.  
(州)的初始估计值,的颂歌系统,一个向量。 y如果有一个name属性,名称将被用于标记输出矩阵。


参数:time
time for which steady-state is wanted; the default is time=0.  
想稳定状态的时间,默认为time= 0。


参数:func
either a user-supplied function that computes the values of the derivatives in the ode system (the model definition) at time time, or a character string giving the name of a compiled function in a dynamically loaded shared library.  If func  is a user-supplied function, it must be called as: yprime = func(t, y, parms).  t is the time point at which the steady-state is wanted, y is the current estimate of the variables in the ode system.  If the initial values y has a names attribute, the names will be available inside func. parms is a vector of parameters (which may have a names attribute).  The return value of func should be a list, whose first element is a vector containing the derivatives of y with respect to time, and whose next elements (possibly with a names attribute) are global values that are required as output.  The derivatives should be specified in the same order as the state variables y.  If func is a string, then dllname must give the name of the shared library (without extension) which must be loaded before stodes() is called.  see Details for more information.  
任何一个用户提供的函数,计算在的颂歌系统(模型定义)的衍生工具的价值time,或者是一个字符串给一个已编译的函数动态加载的共享库的名称。如果func是一个用户提供的函数,它必须被称为:yprime = func(t, y, parms)。 t是在稳定状态的时间点被通缉,y是目前估计的颂歌系统中的变量。如果初始值y有一个名称属性,名称将是提供内func。 parms是一个向量的参数(其可以有一个名称属性)。 func的返回值应该是一个列表的第一个元素是一个包含y衍生工具的矢量就到time外,而其下一个元素(可能与一个names 属性)是全球所需要的值作为输出。衍生工具应以相同的顺序指定的作为状态变量y。如果func是一个字符串,然后dllname必须放弃之前必须加载stodes()被称为共享库(没有扩展名)的名称。查看更多信息。


参数:parms
other parameters passed to func.  
其他参数传递给func。


参数:rtol
relative error tolerance, either a scalar or a vector, one value for each y.  
相对误差,无论是一个标量或向量,每个y的一个值。


参数:atol
absolute error tolerance, either a scalar or a vector, one value for each y.  
绝对误差,无论是一个标量或向量,每个y的一个值。


参数:ctol
if between two iterations, the maximal change in y is less than this amount, steady-state is assumed to be reached.  
如果两次迭代之间,在y最大的变化是低于这一数额,被假定为达到稳态。


参数:sparsetype
the sparsity pattern, several options are available,  but to date only "sparseint", sparse jacobian, estimated internally by stodes is probably needed. See details.  
稀疏模式,有几个选项,但至今只有“sparseint”,稀疏Jacobian,估计内部stodes的可能需要。查看详细信息。


参数:verbose
if TRUE: full output to the screen, e.g. will output the steady-state settings.  
如果为TRUE:完整的输出到屏幕上,例如将输出的稳定状态设置。


参数:nnz
the number of nonzero elements in the sparse Jacobian (if this is unknown, use an estimate); If NULL, a guess will be made, and if not sufficient, stodes will return with a message indicating the size actually required.  If a solution is found, the minimal value of nnz actually required is returned by the solver (1st element of attribute dims).  
数非零元素的稀疏Jacobian(如果这是未知的,使用的估计),如果为NULL,猜测,如果没有足够的,stodes将返回一条消息,表明实际需要的大小。如果找到了解决办法,最小的值nnz实际需要的求解器返回(1日元素的属性dims)的。


参数:inz
(row,column) indices to the nonzero elements in the sparse Jacobian. If this is NULL, the sparsity will be determined by stodes.  
(行,列)指数的稀疏Jacobian中的非零元素。如果这是NULL,稀疏将由stodes。


参数:lrw
the length of the work array of solver; due to the sparsicity, this cannot be readily predicted. If NULL, a guess will be made, and if not sufficient, stodes will return with a message indicating the size actually required. Therefore, some experimentation may be necessary to estimate the value of lrw  If a solution is found, the minimal value of lrw actually required is returned by the solver (3rd element of attribute dims).  
求解器的工作阵列的长度;由于到sparsicity,不能很容易地预测。如果为NULL,猜测,如果没有足够的,stodes将返回一条消息,表明实际需要的大小。因此,一些实验可能需要估计的价值lrw如果找到了解决办法,最小的值lrw返回实际需要,通过求解器(第三个元素的属性dims) 。


参数:ngp
number of groups of independent state variables. Due to the sparsicity, this cannot be readily predicted. If NULL, a guess will be made, and if not sufficient, stodes will return with a message indicating the size actually required. Therefore, some experimentation may be necessary to estimate the value of ngp  If a solution is found, the minimal value of ngp actually required is returned by the solver (2nd element of attribute dims.  
组独立的状态变量的数目。由于的sparsicity,不能很容易地预测。如果为NULL,猜测,如果没有足够的,stodes将返回一条消息,表明实际需要的大小。因此,一些实验可能需要估计的价值ngp如果找到了解决办法,最小的值ngp返回实际需要,通过求解器(第二个元素的属性dims的。


参数:positive
either a logical or a vector with indices of the state variables that have to be non-negative; if TRUE, the state variables are forced to be non-negative numbers.  
逻辑或与具有非负的,如果为TRUE,状态变量被强制为非负数的状态变量的指数,其中的向量。


参数:maxiter
maximal number of iterations during one call to the solver.  
最大的迭代次数,通话过程中的解算器。


参数:ynames
if FALSE: names of state variables are not passed to function func ; this may speed up the simulation especially for multi-D models.  
如果为FALSE:状态变量的名称传递给函数func;这可能加快模拟,特别是对多-D模型。


参数:dllname
a string giving the name of the shared library (without extension) that contains all the compiled function or subroutine definitions referred to in func.  
一个字符串,给出的共享库(不带扩展名),其中包含所有已编译的函数或子程序定义在func的名称。


参数:initfunc
if not NULL, the name of the initialisation function (which initialises values of parameters), as provided in "dllname". See details.  
的初始化功能的名称(初始化的参数的值),如果不为NULL,如设置在dllname。查看详细信息。


参数:initpar
only when "dllname" is specified and an initialisation function initfunc is in the dll: the parameters passed to the initialiser, to initialise the common blocks (FORTRAN) or global variables (C, C++).  
只有当dllname指定一个初始化函数initfunc是在dll中传递的参数的初始化程序,初始化的常见块(FORTRAN)或全局变量(C,C + +) 。


参数:rpar
only when "dllname" is specified: a vector with double precision values passed to the dll-functions whose names are specified by func.  
只有当dllname指定一个向量,其双精度值传递的DLL函数的名称所指定的func。


参数:ipar
only when "dllname" is specified: a vector with integer values passed to the dll-functions whose names are specified by func.  
只有当dllname指定的矢量整数的值传递的dll名字的功能所指定的func。


参数:nout
only used if "dllname" is specified: the number of output variables calculated in the compiled function func, present in the shared library.  
仅用于dllname指定输出的数量计算的变量在编译的函数func,目前在共享库。


参数:outnames
only used if "dllname" is specified and nout > 0: the names of output variables calculated in the compiled function func, present in the shared library.  
如果只使用dllname指定和nout> 0:输出计算的变量在编译的函数func,目前在共享库的名字。


参数:spmethod
the sparse method to be used, one of "yale", "ilut",     "ilutp". The default uses the yale sparse matrix solver; the other  use preconditioned GMRES (generalised minimum residual method) solvers from FORTRAN package sparsekit. ilut stands for incomplete LU  factorisation with trheshold (or tolerances, droptol); the "p" iin ilutp stands for pivoting.  
稀疏的方法被使用,1"yale", "ilut",     "ilutp"。默认情况下使用耶鲁稀疏矩阵解算器,使用预处理的GMRES(广义最小剩余法)求解器从FORTRAN包sparsekit。 ILUT代表的不完全LU因子分解与trheshold(或公差,droptol),“P”代表IIN ilutp旋转。


参数:control
only used if spmethod not equal to "yale", a list with the control options of the preconditioned solvers. The  default is list( droptol = 1e-3, permtol = 1e-3, fillin = 10,      lenplufac = 2).   droptol is the tolerance in ilut, ilutp to decide when to drop a value. permtol is used in ilutp, to decide whether or not to permute variables. See Saad 1994, the manual of sparskit and Saad 2003, chapter 10 for details.  
如果只使用spmethod不等于到的"yale",的先决条件的解算器的控制选项的列表。默认的list( droptol = 1e-3, permtol = 1e-3, fillin = 10,      lenplufac = 2)。 droptol是宽容在ILUT,ilutp,决定何时丢弃的值。 permtol在ilutp使用,以决定是否重排变量。萨阿德1994年,2003年,第10章sparskit和Saad手册。


参数:forcings
only used if "dllname" is specified: a vector with the  forcing function values, or a list with the forcing function data sets,  each present as a two-columned matrix, with (time,value); interpolation  outside the interval [min(times), max(times)] is done by  taking the value at the closest data extreme.  This feature is here for compatibility with models defined in compiled code from package deSolve; see deSolve's package vignette "compiledCode".  
如果只使用dllname的指定的:与强迫函数值,或与强制函数数据集的列表,每个作为一个两列的矩阵存在,与(时间值)的矢量;插值外分(times),最大(times)是通过在最近的数据极端值。此功能是这里的模型定义在编译后的代码包deSolve的兼容性; deSolve的的包小插曲"compiledCode"。


参数:initforc
if not NULL, the name of the forcing function initialisation function, as provided in "dllname". It MUST be present if forcings has been given a value. See deSolve's package vignette "compiledCode".  
如果不是NULL,强制函数初始化函数的名称,设置在dllname。它必须是forcings如果已被赋予了价值。请参阅deSolve的的包小插曲"compiledCode"。


参数:fcontrol
A list of control parameters for the forcing functions. See deSolve's package vignette "compiledCode".  
列表控制参数的强制功能。请参阅deSolve的的包小插曲"compiledCode"。


参数:...
additional arguments passed to func allowing this to be a generic function.  
额外的参数传递给func这是一个通用的功能。


Details

详细信息----------Details----------

The work is done by a Fortran 77 routine that implements the Newton-Raphson method.
的工作是由一个Fortran 77程序实现了Newton-Raphson方法。

stodes is to be used for problems, where the Jacobian has a sparse structure.
stodes是要用于的问题,其中的雅可比矩阵具有稀疏结构。

There are several choices for the sparsity specification, selected by argument sparsetype.
有多种选择的稀疏性规范,选择参数sparsetype。

sparsetype = "sparseint".  The sparsity is estimated by the solver, based on numerical differences. In this case, it is advisable to provide an estimate of the number of non-zero elements in the Jacobian (nnz). This value can be approximate; upon return the number of nonzero elements actually required will be known (1st element of attribute dims). In this case, inz need not be specified.
sparsetype="sparseint"。稀疏估计的求解,根据数值的差异。在这种情况下,最好是提供中的雅可比矩阵的非零元素的数目的估计值(nnz)。这个值可以是近似的;返回时,实际需要的非零元素是已知的(第一个元素的属性dims)。在这种情况下,inz的需要不能被指定。

sparsetype = "sparseusr". The sparsity is determined by the user. In this case, inz should be a matrix, containing indices  (row, column) to the  nonzero elements in the Jacobian matrix. The number of nonzeros nnz will be set equal to the number of rows in inz.
sparsetype="sparseusr"。的稀疏性是由用户确定的。在这种情况下,inz应该是一个matrix,含指数(行,列)中的雅可比矩阵的非零元素。的nonzerosnnz的数量将被设置等于在inz的行数。

sparsetype = "sparsejan". The sparsity is also determined by the user. In this case, inz should be a vector, containting the ian and  jan elements of the sparse storage format, as used in the sparse solver. Elements of ian should be the first n+1 elements of this vector, and  contain the starting locations in jan of columns 1.. n.  jan contains the row indices of the nonzero locations of    the jacobian, reading in columnwise order. The number of nonzeros nnz will be set equal to the length of inz - (n+1).
sparsetype="sparsejan"。的稀疏性也由用户确定的。在这种情况下,inz应该是一个vector,containtingian和jan元素的稀疏存储格式,用于稀疏求解器。元素的ian应该是第一个n+1这个向量的元素,并包含起始位置jan列1 .. N。 jan包含该行的非零位置的雅可比指标,在按列的顺序阅读。的nonzerosnnz的数量的长度将被设置为等于inz - (n +1)个。

sparsetype = "1D", "2D", "3D".  The sparsity is estimated by the solver, based on numerical differences. Assumes finite differences in a 1D, 2D or 3D regular grid - used by  functions ode.1D, ode.2D, ode.3D. Similar are "2Dmap", and "3Dmap", which also include a  mapping variable (passed in nnz).
sparsetype="1D","2D","3D"。稀疏估计的求解,根据数值的差异。假设在1D,2D或3D的规则网格 - 有限差分函数所使用的ode.1D,ode.2D,ode.3D。类似的是"2Dmap"和"3Dmap",其中还包括一个映射变量(通过NNZ)。

The Jacobian itself is always generated by the solver (i.e. there is no provision to provide an analytic Jacobian).
雅可比本身所产生的解算器(即有没有规定提供的解析雅可比)。

This is done by perturbing simulataneously a combination of state variables that do not affect each other.
这是由扰动标定状态变量的组合,不会相互影响。

This significantly reduces computing time. The number of groups with independent state variables can be given by ngp.
这显着地减少了计算时间。独立的状态变量组的数量可以由ngp。

The input parameters rtol, atol and ctol determine the error control performed by the solver. See help for stode for details.
的输入参数rtol,atol和ctol确定错误的求解器进行控制。请参阅帮助stode的详细信息。

Models may be defined in compiled C or Fortran code, as well as in R. See package vignette for details on how to write models in compiled code.
模型可以被定义在编译的C或Fortran代码,以及在R在编译后的代码如何编写模型的详细信息,请参阅包小插曲。

When the spmethod equals ilut or ilutp, a number of parameters can be specified in argument control. They are:
当spmethod等于ilut或ilutp,一些参数可以指定的参数control。它们分别是:

fillin, the fill-in parameter. Each row of L and each row of U will have a maximum of lfil elements (excluding the  diagonal element). lfil must be >= 0.
填满,填充的参数。 L和每一行的每一行的U lfil元素(不含对角线元素)将具有最大。 lfil必须> = 0。

droptol, sets the threshold for dropping small terms in the factorization.
droptol,设置阈值下降小项的分解。

When ilutp is chosen the following arguments can also be specified:   
当ilutp选择下面的参数也可以指定:

permtol = tolerance ratio used to  determne whether or not to permute two columns.  At step i columns i and j are permuted when  abs(a(i,j))*permtol .gt. abs(a(i,i)) [0 –> never permute; good values 0.1 to 0.01]
用于permtol =公差比determne是否重排两列。在步骤i列i和j置换时,ABS(A(I,J))* permtol GT。 ABS(A(I,I))[0  - >从来没有表,改变,良好值0.1至0.01]

lenplufac   = sets the working array - increase its value if a warning.
lenplufac =设置的工作数组 - 增加其价值,如果一个警告。


值----------Value----------

A list containing
一个列表,其中包含


参数:y
a vector with the state variable values from the last iteration during estimation of steady-state condition of the system of equations. If y has a names attribute, it will be used to label the output values.  
从最后一次迭代在估算过程中的方程系统的稳态状况的状态变量值的一个矢量。如果y有一个名称属性,它会被用来标注的输出值。


参数:...
the number of "global" values returned.  
返回的“全球性”的价值观。

The output will have the attribute steady, which returns TRUE, if steady-state has been reached and the attribute precis with an estimate of the precision attained during each iteration, the mean absolute rate of change (sum(abs(dy))/n).
输出将有steady,它返回的属性TRUE,如果稳态已达到和属性precis达到的精度在每次迭代的估计,平均绝对速度变动(总和(绝对值(DY))/ n)的。


(作者)----------Author(s)----------



Karline Soetaert <karline.soetaert@nioz.nl>




参考文献----------References----------


Numerical Recipes in FORTRAN. The Art of Scientific computing. 2nd edition. Cambridge University Press.
the Yale sparse matrix package:
Yale Sparse Matrix Package. i. The symmetric codes. Int. J. Num. meth. Eng. 18, 1145-1151.

sparse matrix computations. VERSION 2
Industrial and Applied Mathematics.

参见----------See Also----------

steady, for a general interface to most of the steady-state solvers
steady,一个通用的接口,大部分的稳态解算器

steady.band, to find the steady-state of ODE models with a banded Jacobian
steady.band,找到稳定状态的ODE模型的一个带状的雅可比

steady.1D, steady.2D, steady.3D, steady-state solvers for 1-D, 2-D and 3-D partial differential equations.
steady.1D,steady.2D,steady.3D,1-D,2-D和3-D偏微分方程的稳态解算器。

stode, iterative steady-state solver for ODEs with full or banded Jacobian.
stode,常微分方程全部或带状雅可比迭代稳态解算器。

runsteady, steady-state solver by dynamically running to steady-state
runsteady,通过动态运行到稳定状态的稳态求解器


实例----------Examples----------



## =======================================================================[#================================================= ======================]
## 1000 simultaneous equations[#1000联立方程组]
## =======================================================================[#================================================= ======================]

model <- function (time, OC, parms, decay, ing)
{
# model describing C in a sediment,[模型C中的沉积物,]
# Upper boundary = imposed flux, lower boundary = zero-gradient[上边界=施加通量,下边界=零梯度]
Flux  &lt;- v * c(OC[1] ,OC) +              # advection[平流]
          -Kz*diff(c(OC[1],OC,OC[N]))/dx  # diffusion;[扩散;]
Flux[1]&lt;- flux     # imposed flux[征收通量]

# Rate of change= Flux gradient and first-order consumption[变化率=通量梯度和一阶消费]
dOC   <- -diff(Flux)/dx - decay*OC

# Fraction of OC in first 5 layers is translocated to mean depth[业主立案法团的分数被转运至第5层平均深度]
# (layer N/2)[(一层N / 2)]
dOC[1:5]  <- dOC[1:5] - ing*OC[1:5]
dOC[N/2]  <- dOC[N/2] + ing*sum(OC[1:5])
list(dOC)
}

v    &lt;- 0.1    # cm/yr[厘米/年]
flux <- 10
dx   <- 0.01
N    <- 1000
dist <- seq(dx/2, by = dx, len = N)
Kz   &lt;- 1  #bioturbation (diffusion), cm2/yr[生物扰动(扩散),cm2/yr的]
ss   <- stodes(runif(N), func = model, parms = NULL,
               positive = TRUE, decay = 5, ing = 20, verbose = TRUE)

plot(ss$y[1:N], dist, ylim = rev(range(dist)), type = "l", lwd = 2,
     xlab = "Nonlocal exchange", ylab = "sediment depth",
     main = "stodes, sparse jacobian")

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2024-11-25 15:39 , Processed in 0.028220 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表