landau.interpolate¶
- class landau.interpolate.ConcentrationInterpolator[source]¶
Bases:
Interpolator
- class landau.interpolate.Interpolator[source]¶
Bases:
ABCThis class acts as a factory for an interplation.
Call
fit()to obtain a specific interpolation.Implementations should be hashable and immutable to allow caching in the thermodynamics module.
- class landau.interpolate.PolyFit(nparam, regularizer_strength=1e-08, enforce_curvature=False)[source]¶
Bases:
TemperatureInterpolator,ConcentrationInterpolator- enforce_curvature: bool = False¶
Ensure that the interpolation has negative curvature as expected for thermodynamic potentials.
- nparam: int | Literal['auto']¶
Number of parameters, if “auto” fit a 10 parameter polynomial under L1 and discard parameters <1e-10, then refit.
- regularizer_strength: float = 1e-08¶
Strength of L2-norm regularization.
- class landau.interpolate.RedlichKister(nparam)[source]¶
Bases:
ConcentrationInterpolatorFits the “enthalpic” part of a Redlich-Kister expansion, i.e. without the ideal configuration entropy.
- nparam: int¶
- class landau.interpolate.RedlichKisterInterpolation(df, f0, rk_parameters)[source]¶
Bases:
object- df: float¶
Change in mixing “enthalpy” across composition range.
- f0: float¶
Absolute “enthalpy” at concentration 0
- rk_parameters: ndarray[float]¶
Redlich-Kister parameters.
- class landau.interpolate.SGTE(nparam)[source]¶
Bases:
TemperatureInterpolator- nparam: int¶
- class landau.interpolate.SoftplusFit(n_softplus=2, loss='soft_l1', max_nfev=100, f_scale=1.0)[source]¶
Bases:
ConcentrationInterpolator,TemperatureInterpolatorFits data using a sum of softplus functions for smooth, flexible interpolation.
The softplus function provides numerically stable, smooth approximations suitable for thermodynamic data. This interpolator uses multiple softplus terms to capture complex behavior.
fit()runs a local Levenberg–Marquardt / trust-region fit with analytical Jacobian.- f_scale: float = 1.0¶
Soft margin between inlier and outlier residuals for the robust loss (see
scipy.optimize.least_squares()). Larger values weaken the influence of the robust loss — at the limit it behaves quadratically over the full residual range, equivalent toloss='linear'. Has no effect whenloss='linear'.
- fit(x, y)[source]¶
Local nonlinear least-squares fit with analytical Jacobian.
- Return type:
Callable[[float],float]
- loss: Literal['linear', 'soft_l1', 'huber', 'cauchy', 'arctan'] = 'soft_l1'¶
Loss function for robust fitting.
- max_nfev: int = 100¶
Maximum number of function evaluations for the local fit.
- n_softplus: int = 2¶
Number of softplus terms to fit.
- class landau.interpolate.StitchedFit(interpolating=SGTE(nparam=4), low=None, upp=PolyFit(nparam=2, regularizer_strength=1e-08, enforce_curvature=False), edge=10)[source]¶
Bases:
TemperatureInterpolatorAn interpolator with more control over the extrapolation regions.
- edge: int = 10¶
- interpolating: TemperatureInterpolator = SGTE(nparam=4)¶
- low: TemperatureInterpolator | None = None¶
- upp: TemperatureInterpolator | None = PolyFit(nparam=2, regularizer_strength=1e-08, enforce_curvature=False)¶
How many samples near the edges to use to fit the extrapolating interpolator.
- class landau.interpolate.TemperatureInterpolator[source]¶
Bases:
Interpolator
- class landau.interpolate.WhitneyTemperatureInterpolator(kernel='thin_plate_spline', smoothing=0.0, degree=2, epsilon=1.0, grad_eps=0.0001)[source]¶
Bases:
TemperatureInterpolatorA
TemperatureInterpolatorbacked byWhitneyRBFInterpolator.Fits a 1-D Whitney RBF on temperature data and returns a callable that extrapolates smoothly outside the training range.
Warning
Fitting this interpolator can be very slow, especially when taking data e.g. from calphy as is. It’s better to pre-smooth raw free energies with a plain interpolator or sub set data and then feeding it to this class.
- Parameters:
kernel (
str)smoothing (
float)degree (
int)epsilon (
float)grad_eps (
float)
- degree: int = 2¶
- epsilon: float = 1.0¶
- fit(T, y)[source]¶
Fit the interpolator.
- Parameters:
T ((N,) array-like — temperature values)
y ((N,) array-like — target values)
- Returns:
callable
- Return type:
(M,) ndarray -> (M,) ndarray
- grad_eps: float = 0.0001¶
- kernel: str = 'thin_plate_spline'¶
- smoothing: float = 0.0¶