Skip to main content

FitGraphBuilder

Struct FitGraphBuilder 

Source
pub struct FitGraphBuilder { /* private fields */ }
Expand description

Fluent builder for a FitGraphSpec.

Internal state is just (Vec<ModelNodeSpec>, Vec<ExprEdge>). Each add_<model> arm wires the right ModelTypeStr variant — derived from ModelTypeStr::as_str (no hand-written wire keys) — and constructs a ParameterSpec per ordered kernel parameter. Default ranges are unbounded (±∞) and vary = true, matching the JSON the Python side writes when a user does not pin bounds explicitly.

Implementations§

Source§

impl FitGraphBuilder

Source

pub fn new() -> Self

Create an empty builder.

Source

pub fn available_models() -> Vec<&'static str>

List every model wire-key the builder can produce.

Mirror of the ModelTypeStr registry — the parity test in this crate pins it against model_from_str so a missing variant is caught at cargo test time.

Source

pub fn tie( self, target_node: impl Into<String>, target_param: impl Into<String>, expression: impl Into<String>, ) -> Self

Add a parameter expression edge (a tied parameter).

Equivalent to a ExprEdge JSON entry: the named target_param on target_node is driven by expression instead of varied freely.

Source

pub fn build(self) -> FitGraphSpec

Finish building and return the underlying FitGraphSpec.

Source

pub fn add_gaussian( self, id: &str, amplitude: f64, center: f64, sigma: f64, ) -> Self

Add a Gaussian peak: A · exp(−(x−c)² / (2σ²)).

Parameters (in order): amplitude, center, sigma.

Source

pub fn add_gaussian2d( self, id: &str, amplitude: f64, center_x: f64, center_y: f64, sigma_x: f64, sigma_y: f64, ) -> Self

Add an axis-aligned 2-D Gaussian peak (n_dims == 2).

Parameters (in order): amplitude, center_x, center_y, sigma_x, sigma_y.

Source

pub fn add_gaussian_nd( self, id: &str, amplitude: f64, center_0: f64, sigma_0: f64, ) -> Self

Add a parametric N-D Gaussian peak (gaussian_nd).

This fluent helper adds the 1-D instance (amplitude, center_0, sigma_0) — the dimensionality the compiler infers from the indexed center_<i> parameters. For higher D, construct the node directly with center_0..center_{D-1} / sigma_0..sigma_{D-1} parameters; the builder helper covers the roundtrip/registry contract for the variant.

Source

pub fn add_lorentzian( self, id: &str, amplitude: f64, center: f64, sigma: f64, ) -> Self

Add a Lorentzian (Cauchy) peak.

Parameters (in order): amplitude, center, sigma.

Source

pub fn add_voigt( self, id: &str, amplitude: f64, center: f64, sigma: f64, fraction: f64, ) -> Self

Add the Voigt kernel.

Note: the voigt wire key is the pseudo-Voigt linear mixture (A·(fraction·L + (1−fraction)·G)) — its fourth parameter is the mixing weight fraction (canonical name per docs/reference/models/index.md), not gamma. Use Self::add_true_voigt for the Faddeeva-function convolution.

Parameters (in order): amplitude, center, sigma, fraction.

Source

pub fn add_constant(self, id: &str, c: f64) -> Self

Add a constant offset: f(x) = c.

Source

pub fn add_linear(self, id: &str, slope: f64, intercept: f64) -> Self

Add a linear baseline: slope·x + intercept.

Source

pub fn add_quadratic( self, id: &str, amplitude: f64, center: f64, offset: f64, ) -> Self

Add a quadratic bowl: amplitude · (x − center)² + offset.

Source

pub fn add_arctan_step( self, id: &str, amplitude: f64, center: f64, sigma: f64, ) -> Self

Add an arctangent step.

Parameters (in order): amplitude, center, sigma.

Source

pub fn add_tanh_step( self, id: &str, amplitude: f64, center: f64, sigma: f64, ) -> Self

Add a hyperbolic tangent step.

Parameters (in order): amplitude, center, sigma.

Source

pub fn add_erfc_step( self, id: &str, amplitude: f64, center: f64, sigma: f64, ) -> Self

Add a complementary-error-function step.

Parameters (in order): amplitude, center, sigma.

Source

pub fn add_pseudo_voigt( self, id: &str, amplitude: f64, center: f64, sigma: f64, fraction: f64, ) -> Self

Add a pseudo-Voigt linear-mixture peak.

Parameters (in order): amplitude, center, sigma, fraction.

Source

pub fn add_fano( self, id: &str, amplitude: f64, center: f64, gamma: f64, q: f64, ) -> Self

Add a Fano resonance lineshape.

Parameters (in order): amplitude, center, gamma, q.

Source

pub fn add_double_exponential( self, id: &str, a1: f64, lam1: f64, a2: f64, lam2: f64, ) -> Self

Add a double-exponential decay: A₁·exp(−λ₁·x) + A₂·exp(−λ₂·x).

Source

pub fn add_saturating_exponential( self, id: &str, amplitude: f64, rate: f64, ) -> Self

Add a saturating exponential rise: A·(1 − exp(−k·x)).

Parameters (in order): amplitude, rate.

Source

pub fn add_power_saturation(self, id: &str, amplitude: f64, rate: f64) -> Self

Add a power-law saturation: A·(1 − (1 + rate·x/2)^(−2)) (Misra1b model).

Parameters (in order): amplitude, rate.

Source

pub fn add_power_law_offset( self, id: &str, amplitude: f64, offset: f64, shape: f64, ) -> Self

Add a power-law with offset: amplitude · (offset + x)^(−1/shape) (Bennett5 model).

Parameters (in order): amplitude, offset, shape.

Domain guard: requires offset + x > 0 for all data points; the kernel returns NaN otherwise and the LM solver backs off.

Source

pub fn add_mgh09_rational( self, id: &str, amplitude: f64, num_lin: f64, den_lin: f64, den_const: f64, ) -> Self

Add the Kowalik–Osborne rational function (NIST StRD MGH09).

amplitude · (x² + num_lin·x) / (x² + den_lin·x + den_const)

Parameters (in order): amplitude, num_lin, den_lin, den_const.

Domain guard: requires x² + den_lin·x + den_const ≠ 0; the kernel returns NaN otherwise. At the MGH09 certified parameters the denominator discriminant is negative, keeping D > 0 for all x.

Source

pub fn add_true_voigt( self, id: &str, amplitude: f64, center: f64, sigma: f64, gamma: f64, ) -> Self

Add the true Voigt profile (Gaussian ⊗ Lorentzian) via the Faddeeva function.

Parameters (in order): amplitude, center, sigma, gamma.

Source

pub fn add_skewed_gaussian( self, id: &str, amplitude: f64, center: f64, sigma: f64, gamma: f64, ) -> Self

Add a skewed Gaussian (error-function-modulated asymmetric peak).

Parameters (in order): amplitude, center, sigma, gamma.

Source

pub fn add_exp_gaussian( self, id: &str, amplitude: f64, center: f64, sigma: f64, gamma: f64, ) -> Self

Add an exponentially-modified Gaussian (asymmetric tailing peak).

Parameters (in order): amplitude, center, sigma, gamma.

Source

pub fn add_doniach_sunjic( self, id: &str, amplitude: f64, center: f64, sigma: f64, gamma: f64, ) -> Self

Add a Doniach–Šunjić asymmetric XPS core-level lineshape.

Parameters (in order): amplitude, center, sigma, gamma.

Source

pub fn add_log_normal( self, id: &str, amplitude: f64, center: f64, sigma: f64, ) -> Self

Add a log-normal peak (A·exp(−(ln(x/c))²/(2σ²)) for x > 0).

Parameters (in order): amplitude, center, sigma.

Source

pub fn add_pearson7( self, id: &str, amplitude: f64, center: f64, sigma: f64, m: f64, ) -> Self

Add a Pearson VII peak.

Parameters (in order): amplitude, center, sigma, m.

Source

pub fn add_split_gaussian( self, id: &str, amplitude: f64, center: f64, sigma_l: f64, sigma_r: f64, ) -> Self

Add a split (bi-)Gaussian with different widths each side of center.

Parameters (in order): amplitude, center, sigma_l, sigma_r.

Source

pub fn add_moffat( self, id: &str, amplitude: f64, center: f64, sigma: f64, beta: f64, ) -> Self

Add a Moffat peak.

Parameters (in order): amplitude, center, sigma, beta.

Source

pub fn add_students_t( self, id: &str, amplitude: f64, center: f64, sigma: f64, nu: f64, ) -> Self

Add a Student’s-t peak.

Parameters (in order): amplitude, center, sigma, nu.

Source

pub fn add_split_pearson7( self, id: &str, amplitude: f64, center: f64, sigma_l: f64, sigma_r: f64, m_l: f64, m_r: f64, ) -> Self

Add a split Pearson VII (split width + exponent each side of center).

Parameters (in order): amplitude, center, sigma_l, sigma_r, m_l, m_r.

Source

pub fn add_breit_wigner( self, id: &str, amplitude: f64, center: f64, sigma: f64, q: f64, ) -> Self

Add a Breit-Wigner-Fano resonance.

Parameters (in order): amplitude, center, sigma, q.

Source

pub fn add_asym_ir( self, id: &str, amplitude: f64, center: f64, sigma: f64, k: f64, ) -> Self

Add an asymmetric IR band (Gaussian × logistic sigmoid).

Parameters (in order): amplitude, center, sigma, k.

Source

pub fn add_harmonic_ir( self, id: &str, amplitude: f64, center: f64, sigma: f64, ) -> Self

Add a driven damped harmonic-oscillator IR absorption.

Parameters (in order): amplitude, center, sigma.

Source

pub fn add_tauc( self, id: &str, amplitude: f64, e_gap: f64, exponent: f64, ) -> Self

Add a Tauc optical band-gap edge: A·((x−e_gap)·H(x−e_gap))^p.

Parameters (in order): amplitude, e_gap, exponent.

Source

pub fn add_cauchy_dispersion(self, id: &str, a: f64, b: f64, c: f64) -> Self

Add a Cauchy refractive-index dispersion: a + b/x² + c/x⁴.

Source

pub fn add_kww(self, id: &str, amplitude: f64, tau: f64, beta: f64) -> Self

Add a Kohlrausch–Williams–Watts stretched exponential: A·exp(−(x/τ)^β).

Parameters (in order): amplitude, tau, beta.

Trait Implementations§

Source§

impl Clone for FitGraphBuilder

Source§

fn clone(&self) -> FitGraphBuilder

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FitGraphBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for FitGraphBuilder

Source§

fn default() -> FitGraphBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.