pub struct EulerLagrangeSolver {
pub a: f64,
pub b: f64,
pub ya: f64,
pub yb: f64,
pub n_interior: usize,
pub step_size: f64,
}Expand description
Finite-difference Euler-Lagrange solver for 1D problems.
Minimises J[y] = ∫_a^b L(x, y, y’) dx subject to y(a) = ya, y(b) = yb using a gradient-descent iteration on the interior grid nodes.
Fields§
§a: f64Left endpoint a.
b: f64Right endpoint b.
ya: f64Boundary value y(a).
yb: f64Boundary value y(b).
n_interior: usizeNumber of interior grid points.
step_size: f64Step size τ for gradient descent.
Implementations§
Source§impl EulerLagrangeSolver
impl EulerLagrangeSolver
Sourcepub fn new(
a: f64,
b: f64,
ya: f64,
yb: f64,
n_interior: usize,
step_size: f64,
) -> Self
pub fn new( a: f64, b: f64, ya: f64, yb: f64, n_interior: usize, step_size: f64, ) -> Self
Create a new solver on [a, b] with n+1 subintervals.
Sourcepub fn linear_initial_guess(&self) -> Vec<f64>
pub fn linear_initial_guess(&self) -> Vec<f64>
Linear initial guess interpolating the boundary conditions.
Sourcepub fn solve_arc_length(&self, max_iter: usize) -> Vec<f64>
pub fn solve_arc_length(&self, max_iter: usize) -> Vec<f64>
Run max_iter gradient-descent steps minimising the arc-length functional
J[y] = ∫ sqrt(1 + y’²) dx (geodesic in the plane).
Returns the interior y-values at convergence.
Sourcepub fn arc_length(&self, y_interior: &[f64]) -> f64
pub fn arc_length(&self, y_interior: &[f64]) -> f64
Evaluate the discrete arc-length functional on the given interior values.
Trait Implementations§
Source§impl Clone for EulerLagrangeSolver
impl Clone for EulerLagrangeSolver
Source§fn clone(&self) -> EulerLagrangeSolver
fn clone(&self) -> EulerLagrangeSolver
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for EulerLagrangeSolver
impl RefUnwindSafe for EulerLagrangeSolver
impl Send for EulerLagrangeSolver
impl Sync for EulerLagrangeSolver
impl Unpin for EulerLagrangeSolver
impl UnsafeUnpin for EulerLagrangeSolver
impl UnwindSafe for EulerLagrangeSolver
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