naginterfaces.library.pde.dim1_parab_convdiff¶
- naginterfaces.library.pde.dim1_parab_convdiff(ts, tout, numflx, bndary, u, x, acc, tsmax, comm, itask, itrace, ind, pdedef=None, data=None, io_manager=None, spiked_sorder='C')[source]¶
dim1_parab_convdiff
integrates a system of linear or nonlinear convection-diffusion equations in one space dimension, with optional source terms. The system must be posed in conservative form. Convection terms are discretized using a sophisticated upwind scheme involving a user-supplied numerical flux function based on the solution of a Riemann problem at each mesh point. The method of lines is employed to reduce the PDEs to a system of ordinary differential equations (ODEs), and the resulting system is solved using a backward differentiation formula (BDF) method.For full information please refer to the NAG Library document for d03pf
https://www.nag.com/numeric/nl/nagdoc_28.7/flhtml/d03/d03pff.html
- Parameters
- tsfloat
The initial value of the independent variable .
- toutfloat
The final value of to which the integration is to be carried out.
- numflxcallable (flux, ires) = numflx(t, x, uleft, uright, ires, data=None)
must supply the numerical flux for each PDE given the left and right values of the solution vector . is called approximately midway between each pair of mesh points in turn by
dim1_parab_convdiff
.- Parameters
- tfloat
The current value of the independent variable .
- xfloat
The current value of the space variable .
- uleftfloat, ndarray, shape
contains the left value of the component , for .
- urightfloat, ndarray, shape
contains the right value of the component , for .
- iresint
Set to or .
- dataarbitrary, optional, modifiable in place
User-communication data for callback functions.
- Returns
- fluxfloat, array-like, shape
must be set to the numerical flux , for .
- iresint
Should usually remain unchanged. However, you may set to force the integration function to take certain actions as described below:
Indicates to the integrator that control should be passed back immediately to the calling function with the error indicator set to = 6.
Indicates to the integrator that the current time step should be abandoned and a smaller time step used instead. You may wish to set when a physically meaningless input or output value has been generated. If you consecutively set ,
dim1_parab_convdiff
returns to the calling function with the error indicator set to = 4.
- bndarycallable (g, ires) = bndary(t, x, u, ibnd, ires, data=None)
must evaluate the functions and which describe the physical and numerical boundary conditions, as given by (7) and (8).
- Parameters
- tfloat
The current value of the independent variable .
- xfloat, ndarray, shape
The mesh points in the spatial direction. corresponds to the left-hand boundary, , and corresponds to the right-hand boundary, .
- ufloat, ndarray, shape
Contains the value of solution components in the boundary region.
If , contains the value of the component at , for , for .
If , contains the value of the component at , for , for .
- ibndint
Specifies which boundary conditions are to be evaluated.
must evaluate the left-hand boundary condition at .
must evaluate the right-hand boundary condition at .
- iresint
Set to or .
- dataarbitrary, optional, modifiable in place
User-communication data for callback functions.
- Returns
- gfloat, array-like, shape
must contain the th component of either or in (7) and (8), depending on the value of , for .
- iresint
Should usually remain unchanged. However, you may set to force the integration function to take certain actions as described below:
Indicates to the integrator that control should be passed back immediately to the calling function with the error indicator set to = 6.
Indicates to the integrator that the current time step should be abandoned and a smaller time step used instead. You may wish to set when a physically meaningless input or output value has been generated. If you consecutively set ,
dim1_parab_convdiff
returns to the calling function with the error indicator set to = 4.
- ufloat, array-like, shape
must contain the initial value of at and , for , for .
- xfloat, array-like, shape
The mesh points in the space direction. must specify the left-hand boundary, , and must specify the right-hand boundary, .
- accfloat, array-like, shape
The components of contain the relative and absolute error tolerances used in the local error test in the time integration.
If is the estimated error for at the th mesh point, the error test is
- tsmaxfloat
The maximum absolute step size to be allowed in the time integration. If then no maximum is imposed.
- commdict, communication object, modified in place
Communication structure.
On initial entry: need not be set.
- itaskint
The task to be performed by the ODE integrator.
Normal computation of output values at (by overshooting and interpolating).
Take one step in the time direction and return.
Stop at first internal integration point at or beyond .
- itraceint
The level of trace information required from
dim1_parab_convdiff
and the underlying ODE solver. may take the value , , , or .No output is generated.
Only warning messages from the PDE solver are printed.
Output from the underlying ODE solver is printed. This output contains details of Jacobian entries, the nonlinear iteration and the time integration during the computation of the ODE system.
If , is assumed and similarly if , is assumed.
The advisory messages are given in greater detail as increases. You are advised to set , unless you are experienced with submodule
ode
.- indint
Indicates whether this is a continuation call or a new integration.
Starts or restarts the integration in time.
Continues the integration after an earlier exit from the function. In this case, only the argument should be reset between calls to
dim1_parab_convdiff
.- pdedefNone or callable (p, c, d, s, ires) = pdedef(t, x, u, ux, ires, data=None), optional
Note: if this argument is None then a NAG-supplied facility will be used.
must evaluate the functions , , and which partially define the system of PDEs. , and may depend on , and ; may depend on , , and . is called approximately midway between each pair of mesh points in turn by
dim1_parab_convdiff
. None may be used for for problems in the form (2).- Parameters
- tfloat
The current value of the independent variable .
- xfloat
The current value of the space variable .
- ufloat, ndarray, shape
contains the value of the component , for .
- uxfloat, ndarray, shape
contains the value of the component , for .
- iresint
Set to or .
- dataarbitrary, optional, modifiable in place
User-communication data for callback functions.
- Returns
- pfloat, array-like, shape
must be set to the value of , for , for .
- cfloat, array-like, shape
must be set to the value of , for .
- dfloat, array-like, shape
must be set to the value of , for .
- sfloat, array-like, shape
must be set to the value of , for .
- iresint
Should usually remain unchanged. However, you may set to force the integration function to take certain actions as described below:
Indicates to the integrator that control should be passed back immediately to the calling function with the error indicator set to = 6.
Indicates to the integrator that the current time step should be abandoned and a smaller time step used instead. You may wish to set when a physically meaningless input or output value has been generated. If you consecutively set ,
dim1_parab_convdiff
returns to the calling function with the error indicator set to = 4.
- dataarbitrary, optional
User-communication data for callback functions.
- io_managerFileObjManager, optional
Manager for I/O in this routine.
- spiked_sorderstr, optional
If is spiked (i.e., has unit extent in all but one dimension, or has size ), selects the storage order to associate with it in the NAG Engine:
- spiked_sorder =
row-major storage will be used;
- spiked_sorder =
column-major storage will be used.
Two-dimensional arrays returned from callback functions in this routine must then use the same storage order.
- Returns
- tsfloat
The value of corresponding to the solution values in . Normally .
- ufloat, ndarray, shape
will contain the computed solution at and , for , for .
- indint
.
- Raises
- NagValueError
- (errno )
On entry, on initial entry .
Constraint: on initial entry .
- (errno )
On entry, .
Constraint: or .
- (errno )
On entry, , , and .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, and are both zero.
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: , or .
- (errno )
On entry, is too small: and .
- (errno )
On entry, and .
Constraint: .
- (errno )
In setting up the ODE system an internal auxiliary was unable to initialize the derivative. This could be due to your setting in , , or .
- (errno )
Singular Jacobian of ODE system. Check problem formulation.
- (errno )
Values in are too small to start integration: , .
- (errno )
set to an invalid value in call to , , or .
- (errno )
Serious error in internal call to an auxiliary. Increase for further details.
- (errno )
Error during Jacobian formulation for ODE system. Increase for further details.
- (errno )
The functions , , or appear to depend on time derivatives.
- Warns
- NagAlgorithmicWarning
- (errno )
Underlying ODE solver cannot make further progress from the point with the supplied values of . , , .
- (errno )
Repeated errors in an attempted step of underlying ODE solver. Integration was successful as far as : .
- (errno )
In evaluating residual of ODE system, has been set in , , or . Integration is successful as far as : .
- (errno )
Integration completed, but small changes in are unlikely to result in a changed solution. , .
- Notes
dim1_parab_convdiff
integrates the system of convection-diffusion equations in conservative form:or the hyperbolic convection-only system:
for , where the vector is the set of solution values
The functions , , and depend on , and ; and depends on , , and , where is the spatial derivative of . Note that , , and must not depend on any space derivatives; and none of the functions may depend on time derivatives. In terms of conservation laws, , and are the convective flux, diffusion and source terms respectively.
The integration in time is from to , over the space interval , where and are the leftmost and rightmost points of a user-defined mesh . The initial values of the functions must be given at .
The PDEs are approximated by a system of ODEs in time for the values of at mesh points using a spatial discretization method similar to the central-difference scheme used in
dim1_parab_fd()
,dim1_parab_dae_fd()
anddim1_parab_remesh_fd()
, but with the flux replaced by a numerical flux, which is a representation of the flux taking into account the direction of the flow of information at that point (i.e., the direction of the characteristics). Simple central differencing of the numerical flux then becomes a sophisticated upwind scheme in which the correct direction of upwinding is automatically achieved.The numerical flux vector, say, must be calculated by you in terms of the left and right values of the solution vector (denoted by and respectively), at each mid-point of the mesh , for . The left and right values are calculated by
dim1_parab_convdiff
from two adjacent mesh points using a standard upwind technique combined with a Van Leer slope-limiter (see LeVeque (1990)). The physically correct value for is derived from the solution of the Riemann problem given bywhere , i.e., corresponds to , with discontinuous initial values for and for , using an approximate Riemann solver. This applies for either of the systems (1) and (2); the numerical flux is independent of the functions , , and . A description of several approximate Riemann solvers can be found in LeVeque (1990) and Berzins et al. (1989). Roe’s scheme (see Roe (1981)) is perhaps the easiest to understand and use, and a brief summary follows. Consider the system of PDEs or equivalently . Provided the system is linear in , i.e., the Jacobian matrix does not depend on , the numerical flux is given by
where () is the flux calculated at the left (right) value of , denoted by (); the are the eigenvalues of ; the are the right eigenvectors of ; and the are defined by
If the system is nonlinear, Roe’s scheme requires that a linearized Jacobian is found (see Roe (1981)).
The functions , , and (but not ) must be specified in a . The numerical flux must be supplied in a separate . For problems in the form (2), the actual argument None may be used for . This sets the matrix with entries to the identity matrix, and the functions , and to zero.
The boundary condition specification has sufficient flexibility to allow for different types of problems. For second-order problems, i.e., depending on , a boundary condition is required for each PDE at both boundaries for the problem to be well-posed. If there are no second-order terms present, then the continuous PDE problem generally requires exactly one boundary condition for each PDE, that is boundary conditions in total. However, in common with most discretization schemes for first-order problems, a numerical boundary condition is required at the other boundary for each PDE. In order to be consistent with the characteristic directions of the PDE system, the numerical boundary conditions must be derived from the solution inside the domain in some manner (see below). You must supply both types of boundary conditions, i.e., a total of conditions at each boundary point.
The position of each boundary condition should be chosen with care. In simple terms, if information is flowing into the domain then a physical boundary condition is required at that boundary, and a numerical boundary condition is required at the other boundary. In many cases the boundary conditions are simple, e.g., for the linear advection equation. In general you should calculate the characteristics of the PDE system and specify a physical boundary condition for each of the characteristic variables associated with incoming characteristics, and a numerical boundary condition for each outgoing characteristic.
A common way of providing numerical boundary conditions is to extrapolate the characteristic variables from the inside of the domain. Note that only linear extrapolation is allowed in this function (for greater flexibility the function
dim1_parab_convdiff_dae()
should be used). For problems in which the solution is known to be uniform (in space) towards a boundary during the period of integration then extrapolation is unnecessary; the numerical boundary condition can be supplied as the known solution at the boundary.The boundary conditions must be specified in in the form
at the left-hand boundary, and
at the right-hand boundary.
Note that spatial derivatives at the boundary are not passed explicitly to , but they can be calculated using values of at and adjacent to the boundaries if required. However, it should be noted that instabilities may occur if such one-sided differencing opposes the characteristic direction at the boundary.
The problem is subject to the following restrictions:
, , and must not depend on any space derivatives;
, , , and must not depend on any time derivatives;
, so that integration is in the forward direction;
The evaluation of the terms , , and is done by calling the at a point approximately midway between each pair of mesh points in turn. Any discontinuities in these functions must, therefore, be at one or more of the mesh points ;
At least one of the functions must be nonzero so that there is a time derivative present in the PDE problem.
In total there are ODEs in the time direction. This system is then integrated forwards in time using a BDF method.
For further details of the algorithm, see Pennington and Berzins (1994) and the references therein.
- References
Berzins, M, Dew, P M and Furzeland, R M, 1989, Developing software for time-dependent problems using the method of lines and differential-algebraic integrators, Appl. Numer. Math. (5), 375–397
Hirsch, C, 1990, Numerical Computation of Internal and External Flows, Volume 2: Computational Methods for Inviscid and Viscous Flows, John Wiley
LeVeque, R J, 1990, Numerical Methods for Conservation Laws, Birkhäuser Verlag
Pennington, S V and Berzins, M, 1994, New NAG Library software for first-order partial differential equations, ACM Trans. Math. Softw. (20), 63–99
Roe, P L, 1981, Approximate Riemann solvers, parameter vectors, and difference schemes, J. Comput. Phys. (43), 357–372