mathhook_core/calculus/
pde.rs

1//! Partial Differential Equation (PDE) Solvers
2//!
3//! This module provides a comprehensive framework for solving partial differential equations.
4//! It includes classification, various solution methods, and support for standard PDEs like
5//! heat, wave, and Laplace equations.
6//!
7//! # Organization
8//!
9//! - `types`: Core PDE types and boundary/initial conditions
10//! - `classification`: PDE classification algorithms (order, linearity, type)
11//! - `registry`: Registry-based solver dispatch (O(1) lookup, extensible)
12//! - `methods`: Solution methods (separation of variables, method of characteristics)
13//! - `standard`: Standard PDE solvers (heat, wave, Laplace)
14//! - `common`: Shared utilities for PDE solving
15//!
16//! # Examples
17//!
18//! ```rust
19//! use mathhook_core::calculus::pde;
20//! use mathhook_core::{symbol, expr};
21//!
22//! let u = symbol!(u);
23//! let x = symbol!(x);
24//! let t = symbol!(t);
25//! let equation = expr!(u);
26//! let pde = pde::Pde::new(equation, u, vec![x, t]);
27//!
28//! // Solve using automatic solver selection
29//! let solution = pde::solve(&pde).unwrap();
30//! ```
31
32pub mod classification;
33pub mod types;
34
35// Registry pattern for solver dispatch
36pub mod registry;
37
38// Solution methods
39pub mod method_of_characteristics;
40pub mod separation_of_variables;
41
42// Standard PDEs
43pub mod standard;
44
45// Common utilities
46pub mod common;
47
48// Educational wrapper
49pub mod educational;
50
51// Re-exports
52pub use educational::*;
53pub use method_of_characteristics::*;
54pub use registry::{PDEError, PDEResult, PDESolver, PDESolverRegistry};
55pub use separation_of_variables::*;
56pub use types::*;
57
58/// Solves a PDE using automatic solver selection.
59///
60/// Classifies the PDE and dispatches to the appropriate solver based on PDE type
61/// (parabolic, hyperbolic, elliptic) using the registry system.
62///
63/// # Arguments
64///
65/// * `pde` - The partial differential equation to solve
66///
67/// # Returns
68///
69/// Returns the PDE solution wrapped in `PDESolution` type, or an error if solving fails.
70///
71/// # Examples
72///
73/// ```rust
74/// use mathhook_core::calculus::pde;
75/// use mathhook_core::{symbol, expr};
76///
77/// let u = symbol!(u);
78/// let x = symbol!(x);
79/// let t = symbol!(t);
80/// let equation = expr!(u);
81/// let pde = pde::Pde::new(equation, u, vec![x, t]);
82///
83/// let solution = pde::solve(&pde).unwrap();
84/// ```
85///
86/// # Errors
87///
88/// Returns `PDEError` if:
89/// - PDE classification fails
90/// - No solver available for the PDE type
91/// - Solver execution fails
92pub fn solve(pde: &Pde) -> PDEResult {
93    let registry = PDESolverRegistry::new();
94    registry.solve(pde)
95}