/** * General 1-D parabolic PDE solver via the method of lines (MOL). * * Solves * * u_t = D(x)·u_xx + c(x)·u_x + f(x, t, u) * * on `x ∈ [x0, x1]`, `t ∈ [0, T]`, with initial condition `u(x,0) = u0(x)` and * Dirichlet or Neumann boundary conditions at each end. * * The spatial domain is discretised on a uniform grid of `nx` points (spacing * `h`). The second derivative uses the standard central second difference * `u_xx ≈ (u_{i-1} − 2u_i + u_{i+1})/h²` and the first derivative the central * difference `u_x ≈ (u_{i+1} − u_{i-1})/(2h)` — both second-order accurate, so * the scheme converges as `O(h²)` in space. This semi-discretisation turns the * PDE into a **stiff** ODE system `U'(t) = RHS(t, U)` in the nodal values (the * diffusion term gives the Jacobian eigenvalues ≈ −D/h², very stiff for fine * grids), which is integrated with the variable-order BDF stiff solver * ({@link bdfSolve}) — implicit, so there is no explicit-Euler CFL step cap. * * This is a NEW public entry point; the legacy explicit-Euler heat-only * {@link solvePDE} is intentionally left unchanged. * * @packageDocumentation */ /** A spatially-varying coefficient `D(x)` / `c(x)`; a plain number means constant. */ export type SpaceCoefficient = number | ((x: number) => number); /** A time-varying boundary datum `g(t)`; a plain number means constant in time. */ export type BoundaryDatum = number | ((t: number) => number); /** * Boundary condition at one end of the domain. * - `dirichlet`: prescribes the value `u = g(t)`. * - `neumann`: prescribes the spatial derivative `u_x = g(t)` (a second-order * ghost-node closure is used so overall `O(h²)` accuracy is preserved). */ export interface ParabolicBC { type: 'dirichlet' | 'neumann'; value: BoundaryDatum; } /** Reaction / source term `f(x, t, u)`. */ export type ParabolicSource = (x: number, t: number, u: number) => number; /** Options for {@link solveParabolicPDE}. */ export interface SolveParabolicPDEOptions { /** Diffusion coefficient `D(x)` (constant if a number). Must be > 0 for a well-posed problem. */ diffusion: SpaceCoefficient; /** Advection coefficient `c(x)` in `c(x)·u_x` (default 0 — pure diffusion/reaction). */ advection?: SpaceCoefficient; /** Reaction/source `f(x, t, u)` (default 0). */ source?: ParabolicSource; /** Left domain endpoint. */ x0: number; /** Right domain endpoint (`x1 > x0`). */ x1: number; /** Final integration time (`T > 0`). */ T: number; /** Number of grid points including both boundaries (`nx ≥ 3`). Spacing `h = (x1−x0)/(nx−1)`. */ nx: number; /** Initial condition `u0(x)`. */ u0: (x: number) => number; /** Left (`x = x0`) boundary condition. */ bcLeft: ParabolicBC; /** Right (`x = x1`) boundary condition. */ bcRight: ParabolicBC; /** Relative tolerance for the BDF integrator (default 1e-6). */ tol?: number; /** Maximum BDF step size (default: no cap). */ maxStep?: number; /** * Explicit output times at which to report the solution (each in `[0, T]`). * When omitted the solver's own accepted time steps are returned (the last is * exactly `T`). When given, the free-node states are linearly interpolated * between accepted steps and the boundary nodes evaluated exactly at each time. */ times?: number[]; } /** Solution returned by {@link solveParabolicPDE}. */ export interface ParabolicPDESolution { /** The `nx` spatial grid points. */ x: number[]; /** The output times (length `nt`). */ t: number[]; /** Solution values `u[timeIndex][spaceIndex]`, full grid including boundary nodes. */ u: number[][]; } /** * Solve the general 1-D parabolic PDE `u_t = D(x)·u_xx + c(x)·u_x + f(x, t, u)` * by the method of lines onto the BDF stiff ODE solver. * * @example * // Heat equation u_t = u_xx, u(x,0)=sin(πx), Dirichlet 0 → u = e^{−π²t} sin(πx) * const sol = solveParabolicPDE({ * diffusion: 1, x0: 0, x1: 1, T: 0.1, nx: 81, * u0: (x) => Math.sin(Math.PI * x), * bcLeft: { type: 'dirichlet', value: 0 }, * bcRight: { type: 'dirichlet', value: 0 }, * }); * // sol.u[sol.t.length - 1] ≈ e^{−π²·0.1} sin(πx) */ export declare function solveParabolicPDE(options: SolveParabolicPDEOptions): ParabolicPDESolution; //# sourceMappingURL=solveParabolicPDE.d.ts.map