pub struct PhysicsInformedInterp { /* private fields */ }Expand description
Physics-informed RBF interpolator.
Enforces a PDE constraint at a grid of collocation points by augmenting the standard RBF least-squares system with additional penalty rows.
§Example
use scirs2_interpolate::physics_interp::{
PhysicsInformedInterp, PhysicsInterpConfig, LaplaceResidual,
};
let config = PhysicsInterpConfig {
pde_weight: 0.5,
n_collocation: 9,
rbf_epsilon: 2.0,
..PhysicsInterpConfig::default()
};
let mut interp = PhysicsInformedInterp::new(config);
let points = vec![[0.0_f64, 0.0], [1.0, 0.0], [0.5, 1.0]];
let values = vec![0.0, 1.0, 0.5];
let pde = LaplaceResidual { f: 0.0 };
interp.fit(&points, &values, &pde).expect("fit should succeed");
let out = interp.evaluate(&points).expect("evaluate should succeed");Implementations§
Source§impl PhysicsInformedInterp
impl PhysicsInformedInterp
Sourcepub fn new(config: PhysicsInterpConfig) -> Self
pub fn new(config: PhysicsInterpConfig) -> Self
Create a new interpolator with the given configuration.
Sourcepub fn fit<P: PdeResidual>(
&mut self,
points: &[[f64; 2]],
values: &[f64],
pde: &P,
) -> Result<(), InterpolateError>
pub fn fit<P: PdeResidual>( &mut self, points: &[[f64; 2]], values: &[f64], pde: &P, ) -> Result<(), InterpolateError>
Fit the physics-informed RBF to points / values with PDE pde.
Internally, collocation points are placed on a regular grid inside the bounding box of the data. The combined least-squares system is solved via normal equations (Φᵀ Φ w = Φᵀ y) using Gaussian elimination.
Sourcepub fn evaluate(
&self,
query_points: &[[f64; 2]],
) -> Result<Vec<f64>, InterpolateError>
pub fn evaluate( &self, query_points: &[[f64; 2]], ) -> Result<Vec<f64>, InterpolateError>
Evaluate the fitted interpolant at query_points.
Sourcepub fn pde_residual_norm<P: PdeResidual>(&self, pde: &P) -> f64
pub fn pde_residual_norm<P: PdeResidual>(&self, pde: &P) -> f64
Compute the RMS PDE residual norm at the collocation points.
Returns 0.0 if no collocation points exist or the interpolant is not fitted.
Sourcepub fn total_loss<P: PdeResidual>(&self, pde: &P) -> f64
pub fn total_loss<P: PdeResidual>(&self, pde: &P) -> f64
Total loss = data_fit_mse + pde_weight * pde_residual_mse.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PhysicsInformedInterp
impl RefUnwindSafe for PhysicsInformedInterp
impl Send for PhysicsInformedInterp
impl Sync for PhysicsInformedInterp
impl Unpin for PhysicsInformedInterp
impl UnsafeUnpin for PhysicsInformedInterp
impl UnwindSafe for PhysicsInformedInterp
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.