pdeDomain1D
First version: 3.00.6.1
Syntax
pdeDomain1D(xGrid)
Details
Defines the spatial domain and grid discretization for solving one-dimensional partial differential equations (PDEs).
When solving PDEs numerically, the continuous spatial domain must first be discretized into separate nodes. pdeDomain1D wraps the specified node vector (xGrid) into a domain object that can be recognized by the solver pdeSolver.
Main use cases:
Defining computational boundaries: determine the physical range to solve over from the start and end points of the grid.
Controlling computational accuracy: use a denser grid in regions with rapid changes, such as near the strike price in option pricing, and a sparser grid in smoother regions to balance speed and accuracy.
Parameters
xGrid A numeric vector that specifies all computational nodes in space.
The nodes must be valid finite numeric values and must not contain NULL, NaN, or Inf. They must be strictly increasing.
It must contain at least 3 points. Generally, more points produce a more accurate numerical solution, but also increase computation time.
The range of the grid (the difference between the maximum and minimum values) must be finite.
You can use the
pdeGrid1Dfunction to construct the nodes.
Returns
Returns a dictionary containing the following fields:
type: STRING scalar, fixed to "structured1D".
dim: INT scalar, fixed to 1.
xGrid: DOUBLE vector, the normalized spatial node vector.
Note: Grid statistics, such as the number of nodes, spacing, and uniformity, are not directly included in the returned dictionary. Use pdeInfo(domain) to query them.
Examples
Example 1. Construct a uniform one-dimensional grid
// Construct a uniform grid from 0 to 1 with 101 nodes
xGrid = (0..100) / 100.0
domain = pdeDomain1D(xGrid)
Example 2. Construct a non-uniform one-dimensional grid
// Manually specify non-uniformly distributed nodes
xGrid = 0.0 0.05 0.15 0.4 1.0
domain = pdeDomain1D(xGrid)
Example 3. Use with pdeGrid1D
// Use the sinh method to refine the grid around 100
spotGrid = pdeGrid1D(0.0, 300.0, 401, "sinh", 100.0, 3.0)
domain = pdeDomain1D(spotGrid)
