Class AbstractEquationSolver<E extends Equation>

java.lang.Object
io.github.andreipunko.math.pde.solver.AbstractEquationSolver<E>
Type Parameters:
E - the type of equation this solver handles
All Implemented Interfaces:
EquationSolver<E>
Direct Known Subclasses:
HyperbolicEquationSolver, ParabolicEquationSolver

public abstract class AbstractEquationSolver<E extends Equation> extends Object implements EquationSolver<E>
Abstract base class for partial differential equation solvers. Provides common functionality and utility methods used by specific equation solvers. Implements the core numerical methods and algorithms shared across different types of PDE solvers.

Step sizes passed to buildArea(io.github.andreipunko.math.pde.equation.Equation, double, double) are validated for finiteness and positivity only; physical or discrete stability of the chosen h and tau is not enforced (see this package's summary documentation).

See Also:
  • Constructor Details

    • AbstractEquationSolver

      protected AbstractEquationSolver()
      Constructor for use by concrete solver subclasses.
  • Method Details

    • buildArea

      protected Area buildArea(Equation eqn, double h, double tau)
      Builds a space-time computational domain for the equation solution. Creates a grid with specified spatial and temporal step sizes.
      Parameters:
      eqn - the equation to solve
      h - spatial step size (must be positive)
      tau - temporal step size (must be positive)
      Returns:
      the computational domain with defined grid points
      Throws:
      IllegalArgumentException - if eqn is null, or if h or tau are not finite or not positive
    • prepare

      protected Matrix2D prepare(Equation eqn, Area area)
      Builds the grid Matrix2D filled with the initial condition on the first time row. The same instance is updated during the time march and passed into Solution.matrix().
      Parameters:
      eqn - the equation to solve
      area - the computational domain where the solution will be computed
      Returns:
      working grid matrix (becomes Solution.matrix() in the returned Solution)
    • solve3DiagonalEquationsSystem

      public static double[] solve3DiagonalEquationsSystem(double[] A, double[] B, double[] C, double[] F, AbstractEquationSolver.KappaNu leftCond, AbstractEquationSolver.KappaNu rightCond)
      Solves a tridiagonal system of linear algebraic equations using the Thomas algorithm. The system has the form: A[i]*y[i-1] - C[i]*y[i] + B[i]*y[i+1] = -F[i], 0<i<N

      The algorithm consists of two phases:

      1. Forward phase: computes coefficients Alpha[i] and Beta[i]
      2. Backward phase: computes the solution Y[i]

      Variable notations follow "Tikhonov, Samarskii - Equations of Mathematical Physics", p.590-592

      Parameters:
      A - coefficients for y[i-1] terms
      B - coefficients for y[i+1] terms
      C - coefficients for y[i] terms
      F - right-hand side terms
      leftCond - left boundary condition parameters
      rightCond - right boundary condition parameters
      Returns:
      solution vector Y[i]
      Throws:
      IllegalArgumentException - if arrays have different lengths, if coefficients are invalid, or if a forward / right-boundary denominator is zero or numerically too small (singular or ill-conditioned sweep)
    • calcKappaNu

      protected AbstractEquationSolver.KappaNu calcKappaNu(BorderCondition borderCondition, double h, double time)
      Calculates Kappa and Nu parameters for the tridiagonal algorithm based on boundary conditions. These parameters are used to incorporate different types of boundary conditions into the solution.
      Parameters:
      borderCondition - the boundary condition to process
      h - spatial step size
      time - current time point
      Returns:
      KappaNu record containing calculated parameters
      Throws:
      IllegalArgumentException - if borderCondition is null
      IllegalStateException - if an unsupported boundary condition type is encountered