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
impl FitGraphBuilder
Sourcepub fn available_models() -> Vec<&'static str>
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.
Sourcepub fn tie(
self,
target_node: impl Into<String>,
target_param: impl Into<String>,
expression: impl Into<String>,
) -> Self
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.
Sourcepub fn build(self) -> FitGraphSpec
pub fn build(self) -> FitGraphSpec
Finish building and return the underlying FitGraphSpec.
Sourcepub fn add_gaussian(
self,
id: &str,
amplitude: f64,
center: f64,
sigma: f64,
) -> Self
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.
Sourcepub fn add_gaussian2d(
self,
id: &str,
amplitude: f64,
center_x: f64,
center_y: f64,
sigma_x: f64,
sigma_y: f64,
) -> Self
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.
Sourcepub fn add_gaussian_nd(
self,
id: &str,
amplitude: f64,
center_0: f64,
sigma_0: f64,
) -> Self
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.
Sourcepub fn add_lorentzian(
self,
id: &str,
amplitude: f64,
center: f64,
sigma: f64,
) -> Self
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.
Sourcepub fn add_voigt(
self,
id: &str,
amplitude: f64,
center: f64,
sigma: f64,
fraction: f64,
) -> Self
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.
Sourcepub fn add_constant(self, id: &str, c: f64) -> Self
pub fn add_constant(self, id: &str, c: f64) -> Self
Add a constant offset: f(x) = c.
Sourcepub fn add_linear(self, id: &str, slope: f64, intercept: f64) -> Self
pub fn add_linear(self, id: &str, slope: f64, intercept: f64) -> Self
Add a linear baseline: slope·x + intercept.
Sourcepub fn add_quadratic(
self,
id: &str,
amplitude: f64,
center: f64,
offset: f64,
) -> Self
pub fn add_quadratic( self, id: &str, amplitude: f64, center: f64, offset: f64, ) -> Self
Add a quadratic bowl: amplitude · (x − center)² + offset.
Sourcepub fn add_arctan_step(
self,
id: &str,
amplitude: f64,
center: f64,
sigma: f64,
) -> Self
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.
Sourcepub fn add_tanh_step(
self,
id: &str,
amplitude: f64,
center: f64,
sigma: f64,
) -> Self
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.
Sourcepub fn add_erfc_step(
self,
id: &str,
amplitude: f64,
center: f64,
sigma: f64,
) -> Self
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.
Sourcepub fn add_pseudo_voigt(
self,
id: &str,
amplitude: f64,
center: f64,
sigma: f64,
fraction: f64,
) -> Self
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.
Sourcepub fn add_fano(
self,
id: &str,
amplitude: f64,
center: f64,
gamma: f64,
q: f64,
) -> Self
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.
Sourcepub fn add_double_exponential(
self,
id: &str,
a1: f64,
lam1: f64,
a2: f64,
lam2: f64,
) -> Self
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).
Sourcepub fn add_saturating_exponential(
self,
id: &str,
amplitude: f64,
rate: f64,
) -> Self
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.
Sourcepub fn add_power_saturation(self, id: &str, amplitude: f64, rate: f64) -> Self
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.
Sourcepub fn add_power_law_offset(
self,
id: &str,
amplitude: f64,
offset: f64,
shape: f64,
) -> Self
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.
Sourcepub fn add_mgh09_rational(
self,
id: &str,
amplitude: f64,
num_lin: f64,
den_lin: f64,
den_const: f64,
) -> Self
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.
Sourcepub fn add_true_voigt(
self,
id: &str,
amplitude: f64,
center: f64,
sigma: f64,
gamma: f64,
) -> Self
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.
Sourcepub fn add_skewed_gaussian(
self,
id: &str,
amplitude: f64,
center: f64,
sigma: f64,
gamma: f64,
) -> Self
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.
Sourcepub fn add_exp_gaussian(
self,
id: &str,
amplitude: f64,
center: f64,
sigma: f64,
gamma: f64,
) -> Self
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.
Sourcepub fn add_doniach_sunjic(
self,
id: &str,
amplitude: f64,
center: f64,
sigma: f64,
gamma: f64,
) -> Self
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.
Sourcepub fn add_log_normal(
self,
id: &str,
amplitude: f64,
center: f64,
sigma: f64,
) -> Self
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.
Sourcepub fn add_pearson7(
self,
id: &str,
amplitude: f64,
center: f64,
sigma: f64,
m: f64,
) -> Self
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.
Sourcepub fn add_split_gaussian(
self,
id: &str,
amplitude: f64,
center: f64,
sigma_l: f64,
sigma_r: f64,
) -> Self
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.
Sourcepub fn add_moffat(
self,
id: &str,
amplitude: f64,
center: f64,
sigma: f64,
beta: f64,
) -> Self
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.
Sourcepub fn add_students_t(
self,
id: &str,
amplitude: f64,
center: f64,
sigma: f64,
nu: f64,
) -> Self
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.
Sourcepub fn add_split_pearson7(
self,
id: &str,
amplitude: f64,
center: f64,
sigma_l: f64,
sigma_r: f64,
m_l: f64,
m_r: f64,
) -> Self
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.
Sourcepub fn add_breit_wigner(
self,
id: &str,
amplitude: f64,
center: f64,
sigma: f64,
q: f64,
) -> Self
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.
Sourcepub fn add_asym_ir(
self,
id: &str,
amplitude: f64,
center: f64,
sigma: f64,
k: f64,
) -> Self
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.
Sourcepub fn add_harmonic_ir(
self,
id: &str,
amplitude: f64,
center: f64,
sigma: f64,
) -> Self
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.
Sourcepub fn add_tauc(
self,
id: &str,
amplitude: f64,
e_gap: f64,
exponent: f64,
) -> Self
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.
Trait Implementations§
Source§impl Clone for FitGraphBuilder
impl Clone for FitGraphBuilder
Source§fn clone(&self) -> FitGraphBuilder
fn clone(&self) -> FitGraphBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more