pdeCoeff2D

First version: 3.00.6.1

Syntax

pdeCoeff2D(xx, yy, [xy=0], [x=0], [y=0], [u=0], [source=0], [mass=1])

Details

Constructs a coefficient dictionary in operator form for a two-dimensional partial differential equation (PDE).

This function wraps the equation coefficients, including second-order derivative terms, first-order derivative terms, the zero-order term, source term, and mass term, into a coefficient dictionary object that can be recognized by the solver pdeSolver. The returned result can be used directly as the coeff parameter in the two-dimensional solving path of pdeSolver. It supports both constant coefficients (scalars) and variable coefficients (functions).

Parameters

xx Numeric scalar or function that specifies the coefficient of the second-order derivative term in the x direction.

yy Numeric scalar or function that specifies the coefficient of the second-order derivative term in the y direction.

xy (optional) Numeric scalar or function that specifies the coefficient of the mixed derivative term. The default value is 0.

x (optional) Numeric scalar or function that specifies the coefficient of the first-order derivative term in the x direction. The default value is 0.

y (optional) Numeric scalar or function that specifies the coefficient of the first-order derivative term in the y direction. The default value is 0.

u (optional) Numeric scalar or function that specifies the coefficient of the zero-order term. The default value is 0.

source (optional) Numeric scalar or function that specifies the source term coefficient. The default value is 0.

mass (optional) Numeric scalar or function that specifies the mass coefficient. The default value is 1.

Note:

  • If a coefficient is a scalar, it must be a finite valid value, that is, not NULL, NaN, or Inf.

  • If a coefficient is a function, the function must accept 3 parameters, usually representing spatial positions x and y and time t.

  • During the solving stage, the mass coefficient must always be positive and finite.

Returns

Returns a dictionary containing the following fields:

  • type: STRING scalar, fixed to "operator2D".

  • dim: INT scalar, fixed to 2.

  • form: STRING scalar, fixed to "operator".

  • mass: DOUBLE scalar or function, the normalized mass value, default value, or original function object.

  • xx: DOUBLE scalar or function, the normalized xx value or original function object.

  • yy: DOUBLE scalar or function, the normalized yy value or original function object.

  • xy: DOUBLE scalar or function, the normalized xy value, default value, or original function object.

  • x: DOUBLE scalar or function, the normalized x value, default value, or original function object.

  • y: DOUBLE scalar or function, the normalized y value, default value, or original function object.

  • u: DOUBLE scalar or function, the normalized u value, default value, or original function object.

  • source: DOUBLE scalar or function, the normalized source value, default value, or original function object.

Note: Diagnostic information such as coefficient names, coefficient input types, mixed terms, and dependencies can be queried by using pdeInfo(coeff).

Examples

Example 1. Construct two-dimensional diffusion coefficients without a mixed term

coeff = pdeCoeff2D(xx=0.01, yy=0.02)

Example 2. Construct two-dimensional convection-diffusion coefficients

coeff = pdeCoeff2D(
    xx=0.01,
    yy=0.01,
    x=-0.3,
    y=0.1,
    source=2.5
)

Example 3. Construct a constant-coefficient operator with a mixed term

coeff = pdeCoeff2D(
    xx=0.1,
    yy=0.2,
    xy=-0.05
)

Example 4. Construct Heston PDE coefficients

coeff = pdeCoeff2D(
    xx=def(S, v, tau) {
        return 0.5 * v * S * S
    },
    yy=def(S, v, tau) {
        return 0.5 * 0.3 * 0.3 * v
    },
    xy=def(S, v, tau) {
        return -0.7 * 0.3 * v * S
    },
    x=def(S, v, tau) {
        return 0.05 * S
    },
    y=def(S, v, tau) {
        return 2.0 * (0.04 - v)
    },
    u=-0.05
)

Example 5. Construct coefficients for a manufactured solution with space-time dependence

coeff = pdeCoeff2D(
    xx=def(x, y, t) { return 0.0 },
    yy=def(x, y, t) { return 0.0 },
    source=def(x, y, t) { return 1.0 },
    mass=def(x, y, t) { return 1.0 }
)

Related Functions: pdeInfo, pdeSolver