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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordRecord class to store boundary condition parameters for the tridiagonal algorithm. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructor for use by concrete solver subclasses. -
Method Summary
Modifier and TypeMethodDescriptionprotected AreaBuilds a space-time computational domain for the equation solution.protected AbstractEquationSolver.KappaNucalcKappaNu(BorderCondition borderCondition, double h, double time) Calculates Kappa and Nu parameters for the tridiagonal algorithm based on boundary conditions.protected Matrix2DBuilds the gridMatrix2Dfilled with the initial condition on the first time row.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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.github.andreipunko.math.pde.solver.EquationSolver
solve
-
Constructor Details
-
AbstractEquationSolver
protected AbstractEquationSolver()Constructor for use by concrete solver subclasses.
-
-
Method Details
-
buildArea
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 solveh- 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
Builds the gridMatrix2Dfilled with the initial condition on the first time row. The same instance is updated during the time march and passed intoSolution.matrix().- Parameters:
eqn- the equation to solvearea- the computational domain where the solution will be computed- Returns:
- working grid matrix (becomes
Solution.matrix()in the returnedSolution)
-
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<NThe algorithm consists of two phases:
- Forward phase: computes coefficients Alpha[i] and Beta[i]
- 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] termsB- coefficients for y[i+1] termsC- coefficients for y[i] termsF- right-hand side termsleftCond- left boundary condition parametersrightCond- 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 processh- spatial step sizetime- current time point- Returns:
- KappaNu record containing calculated parameters
- Throws:
IllegalArgumentException- if borderCondition is nullIllegalStateException- if an unsupported boundary condition type is encountered
-