Fitting

yaeos fitting module.

This module provides classes and functions for fitting binary interaction parameters to experimental data.

class BinaryFitter(model_setter, model_setter_args, data, verbose=False)[source]

Bases: object

BinaryFitter class.

This class is used to fit binary interaction parameters to experimental data. The objective function is defined as the sum of the squared errors between the experimental data and the model predictions.

Parameters:
  • model_setter (callable) – A function that returns a model object. The function should take the optimization parameters as the first argument and any other arguments as the following arguments.

  • model_setter_args (tuple) – A tuple with the arguments to pass to the model_setter function.

  • data (pandas.DataFrame) – A DataFrame with the experimental data. The DataFrame should have the following columns: - kind: str, the kind of data point (bubble, dew, liquid-liquid, PT, critical) - x1: float, the mole fraction of component 1 - y1: float, the mole fraction of component 1 - T: float, the temperature in K - P: float, the pressure in bar

  • verbose (bool, optional) – If True, print the objective function value and the optimization

objective_function(x_values)[source]

Objective function to minimize when fitting interaction parameters.

Parameters:

x_values (array-like) – The interaction parameters to fit.

fit(x0, bounds, method='Nelder-Mead')[source]

Fit the model to the data.

Fit the model to the data using the objective function defined in the objective_function method. The optimization is performed using the scipy.optimize.minimize function. The optimization result is stored in the .solution property. Which

Parameters:
  • x0 (array-like) – Initial guess for the fitting parameters.

  • bounds (array-like) – Bounds for the fitting parameters.

  • method (str, optional) – The optimization method to use. Default is ‘Nelder-Mead’.

Return type:

None

property solution
fit_kij_lij(x, model, fit_kij, fit_lij)[source]

Set the kij and/or lij parameter of the model.

solve_pt(model, p, t, kind)[source]

Solve a point at a given P and T.