Isotherms#

Base Isotherm#

Contains the Isotherm base class.

class pygaps.core.baseisotherm.BaseIsotherm(material: str | dict | Material | None = None, adsorbate: str | Adsorbate | None = None, temperature: float | str | None = None, **properties: dict)[source]#

Class which contains the general data for an isotherm, real or model.

The isotherm class is the parent class that both PointIsotherm and ModelIsotherm inherit. It is designed to contain the information about an isotherm (such as material, adsorbate, data units etc.) but without any of the data itself.

Think of this class as a extended python dictionary.

Parameters:
  • material (str) -- Name of the material on which the isotherm is measured.

  • adsorbate (str) -- Isotherm adsorbate.

  • temperature (float) -- Isotherm temperature.

Other Parameters:
  • pressure_mode (str, optional) -- The pressure mode, either 'absolute' pressure or 'relative' ('relative%') in the form of p/p0.

  • pressure_unit (str, optional) -- Unit of pressure, if applicable.

  • loading_basis (str, optional) -- Whether the adsorbed amount is in terms of either 'volume_gas' 'volume_liquid', 'molar', 'mass', or a fraction/percent basis.

  • loading_unit (str, optional) -- Unit in which the loading basis is expressed.

  • material_basis (str, optional) -- Whether the underlying material is in terms of 'per volume' 'per molar amount' or 'per mass' of material.

  • material_unit (str, optional) -- Unit in which the material basis is expressed.

Notes

The class is also used to prevent duplication of code within the child classes, by calling the common inherited function before any other specific implementation additions.

The minimum arguments required to instantiate the class are material, temperature', ``adsorbate.

property iso_id: str#

Return an unique identifier of the isotherm.

property material: Material#

Return underlying material.

property adsorbate: Adsorbate#

Return underlying adsorbate.

property temperature: float#

Return underlying temperature, always in kelvin.

property units: dict#

Return a dictionary of all isotherm units

to_dict() dict[source]#

Returns a dictionary of the isotherm class Is the same dictionary that was used to create it.

Returns:

dict -- Dictionary of all parameters.

to_json(path=None, **kwargs) None | str[source]#

Convert the isotherm to a JSON representation.

Parameters:
  • path -- File path or object. If not specified, the result is returned as a string.

  • kwargs -- Custom arguments to be passed to "json.dump", like indent.

Returns:

None or str -- If path is None, returns the resulting json as a string. Otherwise returns None.

to_csv(path=None, separator=',', **kwargs) None | str[source]#

Convert the isotherm to a CSV representation.

Parameters:
  • path -- File path or object. If not specified, the result is returned as a string.

  • separator (str, optional) -- Separator used int the csv file. Defaults to '',''.

Returns:

None or str -- If path is None, returns the resulting csv as a string. Otherwise returns None.

to_xl(path, **kwargs)[source]#

Save the isotherm as an Excel file.

Parameters:

path -- Path where to save Excel file.

to_aif(path=None, **kwargs) None | str[source]#

Convert the isotherm to a AIF representation.

Parameters:

path -- File path or object. If not specified, the result is returned as a string.

Returns:

None or str -- If path is None, returns the resulting AIF as a string. Otherwise returns None.

to_db(db_path: str | None = None, verbose: bool = True, autoinsert_material: bool = True, autoinsert_adsorbate: bool = True, **kwargs)[source]#

Upload the isotherm to an sqlite database.

Parameters:
  • db_path (str, None) -- Path to the database. If none is specified, internal database is used.

  • autoinsert_material (bool, True) -- Whether to automatically insert an isotherm material if it is not found in the database.

  • autoinsert_adsorbate (bool, True) -- Whether to automatically insert an isotherm adsorbate if it is not found in the database.

  • verbose (bool) -- Extra information printed to console.

convert_temperature(unit_to: str, verbose: bool = False)[source]#

Convert isotherm temperature from one unit to another.

Parameters:
  • unit_to (str) -- The unit into which the internal temperature should be converted to.

  • verbose (bool) -- Print out steps taken.

Point Isotherm#

This module contains the main class that describes an isotherm through discrete points.

class pygaps.core.pointisotherm.PointIsotherm(pressure: List[float] | None = None, loading: List[float] | None = None, isotherm_data: DataFrame | None = None, pressure_key: str | None = None, loading_key: str | None = None, branch: str | List[bool] = 'guess', **other_properties)[source]#

Class which contains the points from an adsorption isotherm.

This class is designed to be a complete description of a discrete isotherm. It extends the BaseIsotherm class, which contains all the description of the isotherm parameters, but also holds the datapoints recorded during an experiment or simulation.

The minimum arguments required to instantiate the class, besides those required for the parent BaseIsotherm, is the actual data, specified either as pressure + loading arrays or as isotherm_data (a pandas.DataFrame) + keys for the columns of the dataframe which have the loading and the pressure data.

Parameters:
  • pressure (list) -- Create an isotherm directly from an array. Values for pressure. If the isotherm_data dataframe is specified, these values are ignored.

  • loading (list) -- Create an isotherm directly from an array. Values for loading. If the isotherm_data dataframe is specified, these values are ignored.

  • isotherm_data (pandas.DataFrame) -- Pure-component adsorption isotherm data.

  • pressure_key (str) -- The title of the pressure data in the DataFrame provided.

  • loading_key (str) -- The title of the loading data in the DataFrame provided.

  • branch (['guess', ads', 'des', iterable], optional) -- The branch of the isotherm. The code will automatically attempt to guess if there's an adsorption and desorption branch. The user can instead tell the framework that all points are part of an adsorption ('ads') or desorption ('des') curve. Alternatively, an iterable can be passed which contains detailed info for each data point if adsorption points ('False') or desorption points ('True'). eg: [False, False, True, True...] or as a column of the isotherm_data.

  • material (str) -- Name of the material on which the isotherm is measured.

  • adsorbate (str) -- Isotherm adsorbate.

  • temperature (float) -- Isotherm temperature.

Other Parameters:
  • pressure_mode (str, optional) -- The pressure mode, either 'absolute' pressure or 'relative' ('relative%') in the form of p/p0.

  • pressure_unit (str, optional) -- Unit of pressure, if applicable.

  • loading_basis (str, optional) -- Whether the adsorbed amount is in terms of either 'volume_gas' 'volume_liquid', 'molar', 'mass', or a fraction/percent basis.

  • loading_unit (str, optional) -- Unit in which the loading basis is expressed.

  • material_basis (str, optional) -- Whether the underlying material is in terms of 'per volume' 'per molar amount' or 'per mass' of material.

  • material_unit (str, optional) -- Unit in which the material basis is expressed.

Notes

This class assumes that the datapoints do not contain noise. Detection of adsorption/desorption branches will not work if data is noisy.

classmethod from_isotherm(isotherm: BaseIsotherm, pressure: List[float] | None = None, loading: List[float] | None = None, isotherm_data: DataFrame | None = None, pressure_key: str | None = None, loading_key: str | None = None)[source]#

Construct a point isotherm using a parent isotherm as the template for all the parameters.

Parameters:
  • isotherm (Isotherm) -- An instance of the Isotherm parent class.

  • pressure (list) -- Create an isotherm directly from an array. Values for pressure. If the isotherm_data dataframe is specified, these values are ignored.

  • loading (list) -- Create an isotherm directly from an array. Values for loading. If the isotherm_data dataframe is specified, these values are ignored.

  • isotherm_data (pandas.DataFrame) -- Pure-component adsorption isotherm data.

  • loading_key (str) -- Column of the pandas DataFrame where the loading is stored.

  • pressure_key (str) -- Column of the pandas DataFrame where the pressure is stored.

classmethod from_modelisotherm(modelisotherm, pressure_points: List[float] | None = None, loading_points: List[float] | None = None)[source]#

Construct a PointIsotherm from a ModelIsothem class.

This class method allows for the model to be converted into a list of points calculated by using the model in the isotherm.

Parameters:
  • modelisotherm (ModelIsotherm) -- The isotherm containing the model.

  • pressure_points (None or List or PointIsotherm) -- How the pressure points should be chosen for the resulting PointIsotherm.

    • If None, the PointIsotherm returned has a fixed number of equidistant points

    • If an array, the PointIsotherm returned has points at each of the values of the array

    • If a PointIsotherm is passed, the values will be calculated at each of the pressure points in the passed isotherm. This is useful for comparing a model overlap with the real isotherm.

convert(pressure_mode: str | None = None, pressure_unit: str | None = None, loading_basis: str | None = None, loading_unit: str | None = None, material_basis: str | None = None, material_unit: str | None = None, verbose: bool = False)[source]#

Convenience function for permanently converting any isotherm mode/basis/units.

Parameters:
  • pressure_mode ({'absolute', 'relative', 'relative%'}) -- The mode in which the isotherm should be converted.

  • pressure_unit (str) -- The unit into which the internal pressure should be converted to. Only makes sense if converting to absolute pressure.

  • loading_basis ({'mass', 'molar', 'volume_gas', 'volume_liquid', 'percent', 'fraction'}) -- The basis in which the isotherm should be converted.

  • loading_unit (str) -- The unit into which the internal loading should be converted to.

  • material_basis ({'mass', 'molar', 'volume'}) -- The basis in which the isotherm should be converted.

  • material_unit (str) -- The unit into which the material should be converted to.

  • verbose (bool) -- Print out steps taken.

convert_pressure(mode_to: str | None = None, unit_to: str | None = None, verbose: bool = False)[source]#

Convert isotherm pressure from one unit to another and the pressure mode from absolute to relative.

Only applicable in the case of isotherms taken below critical point of adsorbate.

Parameters:
  • mode_to ({'absolute', 'relative', 'relative%'}) -- The mode in which the isotherm should be converted.

  • unit_to (str) -- The unit into which the internal pressure should be converted to. Only makes sense if converting to absolute pressure.

  • verbose (bool) -- Print out steps taken.

convert_loading(basis_to: str | None = None, unit_to: str | None = None, verbose: bool = False)[source]#

Convert isotherm loading from one unit to another and the basis of the isotherm loading to be either 'mass', 'molar' or 'percent'/'fraction'.

Parameters:
  • basis_to ({'mass', 'molar', 'volume_gas', 'volume_liquid', 'percent', 'fraction'}) -- The basis in which the isotherm should be converted.

  • unit_to (str) -- The unit into which the internal loading should be converted to.

  • verbose (bool) -- Print out steps taken.

convert_material(basis_to: str | None = None, unit_to: str | None = None, verbose: bool = False)[source]#

Convert the material of the isotherm from one unit to another and the basis of the isotherm loading to be either 'per mass' or 'per volume' or 'per mole' of material.

Only applicable to materials that have been loaded in memory with a 'density' or 'molar mass' property respectively.

Parameters:
  • basis ({'mass', 'molar', 'volume'}) -- The basis in which the isotherm should be converted.

  • unit_to (str) -- The unit into which the material should be converted to.

  • verbose (bool) -- Print out steps taken.

print_info(**plot_iso_args)[source]#

Print a short summary of all the isotherm parameters and a graph.

Parameters:

show (bool, optional) -- Specifies if the graph is shown automatically or not.

Other Parameters:

plot_iso_args (dict) -- options to be passed to pygaps.plot_iso()

Returns:

axes (matplotlib.axes.Axes or numpy.ndarray of them)

plot(**plot_iso_args)[source]#

Plot the isotherm using pygaps.plot_iso().

Parameters:

show (bool, optional) -- Specifies if the graph is shown automatically or not.

Other Parameters:

plot_iso_args (dict) -- options to be passed to pygaps.plot_iso()

Returns:

axes (matplotlib.axes.Axes or numpy.ndarray of them)

data(branch: str | None = None) DataFrame[source]#

Return underlying isotherm data.

Parameters:

branch ({None, 'ads', 'des'}) -- The branch of the isotherm to return. If None, returns entire dataset.

Returns:

DataFrame -- The pandas DataFrame containing all isotherm data.

pressure(branch: str | None = None, pressure_unit: str | None = None, pressure_mode: str | None = None, limits: Tuple[float, float] | None = None, indexed: bool = False) ndarray | Series[source]#

Return pressure points as an array.

Parameters:
  • branch ({None, 'ads', 'des'}) -- The branch of the pressure to return. If None, returns entire dataset.

  • pressure_unit (str, optional) -- Unit in which the pressure should be returned. If None it defaults to which pressure unit the isotherm is currently in.

  • pressure_mode ({None, 'absolute', 'relative', 'relative%'}) -- The mode in which to return the pressure, if possible. If None, returns mode the isotherm is currently in.

  • limits ([float, float], optional) -- Minimum and maximum pressure limits. Put None or -+np.inf for no limit.

  • indexed (bool, optional) -- If this is specified to true, then the function returns an indexed pandas.Series instead of an array.

Returns:

array or Series -- The pressure slice corresponding to the parameters passed.

loading(branch: str | None = None, loading_unit: str | None = None, loading_basis: str | None = None, material_unit: str | None = None, material_basis: str | None = None, limits: Tuple[float, float] | None = None, indexed: bool = False) ndarray | Series[source]#

Return loading points as an array.

Parameters:
  • branch ({None, 'ads', 'des'}) -- The branch of the loading to return. If None, returns entire dataset.

  • loading_unit (str, optional) -- Unit in which the loading should be returned. If None it defaults to which loading unit the isotherm is currently in.

  • loading_basis ({None, 'mass', 'volume_gas', 'volume_liquid', 'molar'}) -- The basis on which to return the loading, if possible. If None, returns on the basis the isotherm is currently in.

  • material_unit (str, optional) -- Unit in which the material should be returned. If None it defaults to which loading unit the isotherm is currently in.

  • material_basis ({None, 'mass', 'volume', 'molar'}) -- The basis on which to return the material, if possible. If None, returns on the basis the isotherm is currently in.

  • limits ([float, float], optional) -- Minimum and maximum loading limits. Put None or -+np.inf for no limit.

  • indexed (bool, optional) -- If this is specified to true, then the function returns an indexed pandas.Series instead of an array.

Returns:

Array or Series -- The loading slice corresponding to the parameters passed.

property other_keys#

Return column names of any supplementary data points.

other_data(key: str, branch: str | None = None, limits: Tuple[float, float] | None = None, indexed: bool = False) ndarray | Series[source]#

Return supplementary data points as an array.

Parameters:
  • key (str) -- Key in the isotherm DataFrame containing the data to select.

  • branch ({None, 'ads', 'des'}) -- The branch of the data to return. If None, returns entire dataset.

  • limits ([float, float], optional) -- Minimum and maximum data limits. Put None or -+np.inf for no limit.

  • indexed (bool, optional) -- If this is specified to true, then the function returns an indexed pandas.Series instead of an array.

Returns:

array or Series -- The data slice corresponding to the parameters passed.

has_branch(branch: str) bool[source]#

Check if the isotherm has an specific branch.

Parameters:

branch ({None, 'ads', 'des'}) -- The branch of the data to check for.

Returns:

bool -- Whether the data exists or not.

pressure_at(loading: List[float], branch: str = 'ads', interpolation_type: str = 'linear', interp_fill: float | Tuple[float, float] | str | None = None, pressure_unit: str | None = None, pressure_mode: str | None = None, loading_unit: str | None = None, loading_basis: str | None = None, material_unit: str | None = None, material_basis: str | None = None) ndarray[source]#

Interpolate isotherm to compute pressure at any loading given.

Parameters:
  • loading (float) -- Loading at which to compute pressure.

  • branch ({'ads', 'des'}) -- The branch of the use for calculation. Defaults to adsorption.

  • interpolation_type (str) -- The type of scipy.interp1d used: linear, nearest, zero, slinear, quadratic, cubic. It defaults to linear.

  • interp_fill (array-like or (array-like, array_like) or “extrapolate”, optional) -- Parameter to determine what to do outside data bounds. Passed to the scipy.interpolate.interp1d function as fill_value. If blank, interpolation will not predict outside the bounds of data.

  • pressure_unit (str) -- Unit the pressure is returned in. If None, it defaults to internal isotherm units.

  • pressure_mode (str) -- The mode the pressure is returned in. If None, it defaults to internal isotherm mode.

  • loading_unit (str) -- Unit the loading is specified in. If None, it defaults to internal isotherm units.

  • loading_basis ({None, 'mass', 'molar', 'volume_gas', 'volume_liquid'}) -- The basis the loading is specified in. If None, assumes the basis the isotherm is currently in.

  • material_unit (str, optional) -- Unit in which the material is passed in. If None it defaults to which loading unit the isotherm is currently in

  • material_basis (str) -- The basis the loading is passed in. If None, it defaults to internal isotherm basis.

Returns:

float -- Predicted pressure at loading specified.

loading_at(pressure: List[float], branch: str = 'ads', interpolation_type: str = 'linear', interp_fill: float | Tuple[float, float] | str | None = None, pressure_unit: str | None = None, pressure_mode: str | None = None, loading_unit: str | None = None, loading_basis: str | None = None, material_unit: str | None = None, material_basis: str | None = None) ndarray[source]#

Interpolate isotherm to compute loading at any pressure given.

Parameters:
  • pressure (float or array) -- Pressure at which to compute loading.

  • branch ({'ads', 'des'}) -- The branch the interpolation takes into account.

  • interpolation_type (str) -- The type of scipy.interp1d used: linear, nearest, zero, slinear, quadratic, cubic. It defaults to linear.

  • interp_fill (array-like or (array-like, array_like) or “extrapolate”, optional) -- Parameter to determine what to do outside data bounds. Passed to the scipy.interpolate.interp1d function as fill_value. If blank, interpolation will not predict outside the bounds of data.

  • pressure_unit (str) -- Unit the pressure is specified in. If None, it defaults to internal isotherm units.

  • pressure_mode (str) -- The mode the pressure is passed in. If None, it defaults to internal isotherm mode.

  • loading_unit (str, optional) -- Unit in which the loading should be returned. If None it defaults to which loading unit the isotherm is currently in.

  • loading_basis ({None, 'mass', 'molar', 'volume_gas', 'volume_liquid'}) -- The basis on which to return the loading, if possible. If None, returns on the basis the isotherm is currently in.

  • material_unit (str, optional) -- Material unit in which the data should be returned. If None it defaults to which loading unit the isotherm is currently in.

  • material_basis ({None, 'mass', 'volume', 'molar'}) -- Material basis on which to return the data, if possible. If None, returns on the basis the isotherm is currently in.

Returns:

float or array -- Predicted loading at pressure P.

spreading_pressure_at(pressure: List[float], branch: str = 'ads', pressure_unit: str | None = None, pressure_mode: str | None = None, loading_unit: str | None = None, loading_basis: str | None = None, material_unit: str | None = None, material_basis: str | None = None, interp_fill: float | Tuple[float, float] | str | None = None) ndarray[source]#

Calculate reduced spreading pressure at a bulk adsorbate pressure P.

Use numerical quadrature on isotherm data points to compute the reduced spreading pressure via the integral:

\[\Pi(p) = \int_0^p \frac{q(\hat{p})}{ \hat{p}} d\hat{p}.\]

In this integral, the isotherm \(q(\hat{p})\) is represented by a linear interpolation of the data.

For in-detail explanations, check reference [1].

Parameters:
  • pressure (float) -- Pressure (in corresponding units as data in instantiation).

  • branch ({'ads', 'des'}) -- The branch of the use for calculation. Defaults to adsorption.

  • loading_unit (str) -- Unit the loading is specified in. If None, it defaults to internal isotherm units.

  • pressure_unit (str) -- Unit the pressure is returned in. If None, it defaults to internal isotherm units.

  • material_basis (str) -- The basis the loading is passed in. If None, it defaults to internal isotherm basis.

  • pressure_mode (str) -- The mode the pressure is returned in. If None, it defaults to internal isotherm mode.

  • interp_fill (array-like or (array-like, array_like) or “extrapolate”, optional) -- Parameter to determine what to do outside data bounds. Passed to the scipy.interpolate.interp1d function as fill_value. If blank, interpolation will not predict outside the bounds of data.

Returns:

float -- Spreading pressure, \(\Pi\).

References

Model Isotherm#

Class representing a model of and isotherm.

class pygaps.core.modelisotherm.ModelIsotherm(pressure: List[float] | None = None, loading: List[float] | None = None, isotherm_data: DataFrame | None = None, pressure_key: str | None = None, loading_key: str | None = None, branch: str = 'ads', model: str | List[str] | Any | None = None, param_guess: dict | None = None, param_bounds: dict | None = None, optimization_params: dict | None = None, verbose: bool = False, **other_properties)[source]#

Class to characterize pure-component isotherm data with an analytical model. Data fitting is done during instantiation.

A ModelIsotherm class is instantiated by passing it the pure-component adsorption isotherm in the form of a Pandas DataFrame.

Parameters:
  • pressure (list) -- Create an isotherm directly from an array. Values for pressure. If the isotherm_data dataframe is specified, these values are ignored.

  • loading (list) -- Create an isotherm directly from an array. Values for loading. If the isotherm_data dataframe is specified, these values are ignored.

  • isotherm_data (DataFrame) -- Pure-component adsorption isotherm data.

  • pressure_key (str) -- Column of the pandas DataFrame where the pressure is stored.

  • loading_key (str) -- Column of the pandas DataFrame where the loading is stored.

  • model (str or Model class) -- The model to be used to describe the isotherm.

  • param_guess (dict) -- Starting guess for model parameters in the data fitting routine.

  • param_bounds (dict) -- Bounds for model parameters in the data fitting routine (applicable to some models).

  • branch (['ads', 'des'], optional) -- The branch on which the model isotherm is based on. It is assumed to be the adsorption branch, as it is the most commonly modelled part, although may set to desorption as well.

  • material (str) -- Name of the material on which the isotherm is measured.

  • adsorbate (str) -- Isotherm adsorbate.

  • temperature (float) -- Isotherm temperature.

Other Parameters:
  • optimization_params (dict) -- Dictionary to be passed to the minimization function to use in fitting model to data. See here.

  • pressure_mode (str, optional) -- The pressure mode, either 'absolute' pressure or 'relative' ('relative%') in the form of p/p0.

  • pressure_unit (str, optional) -- Unit of pressure, if applicable.

  • loading_basis (str, optional) -- Whether the adsorbed amount is in terms of either 'volume_gas' 'volume_liquid', 'molar', 'mass', or a fraction/percent basis.

  • loading_unit (str, optional) -- Unit in which the loading basis is expressed.

  • material_basis (str, optional) -- Whether the underlying material is in terms of 'per volume' 'per molar amount' or 'per mass' of material.

  • material_unit (str, optional) -- Unit in which the material basis is expressed.

Notes

Models supported are found in :mod:modelling. Here, \(L\) is the adsorbate uptake and \(P\) is pressure (fugacity technically).

classmethod from_isotherm(isotherm: BaseIsotherm, pressure: List[float] | None = None, loading: List[float] | None = None, isotherm_data: DataFrame | None = None, pressure_key: str | None = None, loading_key: str | None = None, branch: str = 'ads', model: str | List[str] | Any | None = None, param_guess: dict | None = None, param_bounds: dict | None = None, optimization_params: dict | None = None, verbose: bool = False)[source]#

Construct a ModelIsotherm using a parent isotherm as the template for all the parameters.

Parameters:
  • isotherm (BaseIsotherm) -- An instance of the BaseIsotherm parent class.

  • pressure (list) -- Create an isotherm directly from an array. Values for pressure. If the isotherm_data dataframe is specified, these values are ignored.

  • loading (list) -- Create an isotherm directly from an array. Values for loading. If the isotherm_data dataframe is specified, these values are ignored.

  • isotherm_data (DataFrame) -- Pure-component adsorption isotherm data.

  • pressure_key (str) -- Column of the pandas DataFrame where the pressure is stored.

  • loading_key (str) -- Column of the pandas DataFrame where the loading is stored.

  • branch (['ads', 'des'], optional) -- The branch on which the model isotherm is based on. It is assumed to be the adsorption branch, as it is the most commonly modelled.

  • model (str) -- The model to be used to describe the isotherm.

  • param_guess (dict) -- Starting guess for model parameters in the data fitting routine.

  • param_bounds (dict) -- Bounds for model parameters in the data fitting routine.

  • optimization_params (dict) -- Dictionary to be passed to the minimization function to use in fitting model to data. See here. Defaults to "Nelder-Mead".

  • verbose (bool) -- Prints out extra information about steps taken.

classmethod from_pointisotherm(isotherm, branch: str = 'ads', model: str | List[str] | Any | None = None, param_guess: dict | None = None, param_bounds: dict | None = None, optimization_params: dict | None = None, verbose: bool = False)[source]#

Constructs a ModelIsotherm using data from a PointIsotherm and all its parameters.

Parameters:
  • isotherm (PointIsotherm) -- An instance of the PointIsotherm parent class to model.

  • branch ([None, 'ads', 'des'], optional) -- Branch of isotherm to model. Defaults to adsorption branch.

  • model (str, list, 'guess') -- The model to be used to describe the isotherm. Give a single model name ("Langmuir") to fit it. Give a list of many model names to try them all and return the best fit ([`Henry, Langmuir]`). Specify "guess" to try all available models.

  • param_guess (dict, optional) -- Starting guess for model parameters in the data fitting routine.

  • param_bounds (dict) -- Bounds for model parameters in the data fitting routine.

  • optimization_params (dict, optional) -- Dictionary to be passed to the minimization function to use in fitting model to data. See here.

  • verbose (bool) -- Prints out extra information about steps taken.

classmethod guess(pressure: List[float] | None = None, loading: List[float] | None = None, isotherm_data: DataFrame | None = None, pressure_key: str | None = None, loading_key: str | None = None, branch: str = 'ads', models='guess', optimization_params: dict | None = None, verbose: bool = False, **other_properties)[source]#

Attempt to model the data using supplied list of model names, then return the one with the best RMS fit.

May take a long time depending on the number of datapoints.

Parameters:
  • pressure (list) -- Create an isotherm directly from an array. Values for pressure. If the isotherm_data dataframe is specified, these values are ignored.

  • loading (list) -- Create an isotherm directly from an array. Values for loading. If the isotherm_data dataframe is specified, these values are ignored.

  • isotherm_data (DataFrame) -- Pure-component adsorption isotherm data.

  • pressure_key (str) -- Column of the pandas DataFrame where the pressure is stored.

  • loading_key (str) -- Column of the pandas DataFrame where the loading is stored.

  • models ('guess', list of model names) -- Attempt to guess which model best fits the isotherm data from the model name list supplied. If set to 'guess' A calculation of all models available will be performed, therefore it will take a longer time.

  • optimization_params (dict) -- Dictionary to be passed to the minimization function to use in fitting model to data. See here.

  • branch (['ads', 'des'], optional) -- The branch on which the model isotherm is based on. It is assumed to be the adsorption branch, as it is the most commonly modelled part, although may set to desorption as well.

  • verbose (bool, optional) -- Prints out extra information about steps taken.

  • other_properties -- Any other parameters of the isotherm which should be stored internally.

print_info(**plot_iso_args)[source]#

Print a short summary of the isotherm parameters and a graph.

Parameters:

show (bool, optional) -- Specifies if the graph is shown automatically or not.

Other Parameters:

plot_iso_args (dict) -- options to be passed to pygaps.plot_iso()

Returns:

axes (matplotlib.axes.Axes or numpy.ndarray of them)

plot(**plot_iso_args)[source]#

Plot the isotherm using pygaps.plot_iso().

Parameters:

show (bool, optional) -- Specifies if the graph is shown automatically or not.

Other Parameters:

plot_iso_args (dict) -- options to be passed to pygaps.plot_iso()

Returns:

axes (matplotlib.axes.Axes or numpy.ndarray of them)

has_branch(branch: str) bool[source]#

Check if the isotherm has an specific branch.

Parameters:

branch ({None, 'ads', 'des'}) -- The branch of the data to check for.

Returns:

bool -- Whether the data exists or not.

pressure(points: int = 60, branch: str | None = None, pressure_unit: str | None = None, pressure_mode: str | None = None, limits: Tuple[float, float] | None = None, indexed: bool = False)[source]#

Return a numpy.linspace generated array with a fixed number of equidistant points within the pressure range the model was created.

Parameters:
  • points (int) -- The number of points to get.

  • branch ({None, 'ads', 'des'}) -- The branch of the pressure to return. If None, returns the branch the isotherm is modelled on.

  • pressure_unit (str, optional) -- Unit in which the pressure should be returned. If None it defaults to which pressure unit the isotherm is currently in.

  • pressure_mode ({None, 'absolute', 'relative', 'relative%'}) -- The mode in which to return the pressure, if possible. If None, returns mode the isotherm is currently in.

  • limits ([float, float], optional) -- Minimum and maximum pressure limits. Put None or -+np.inf for no limit.

  • indexed (bool, optional) -- If this is specified to true, then the function returns an indexed pandas.Series with the columns requested instead of an array.

Returns:

numpy.array or pandas.Series -- Pressure points in the model pressure range.

loading(points: int = 60, branch: str | None = None, loading_unit: str | None = None, loading_basis: str | None = None, material_unit: str | None = None, material_basis: str | None = None, limits: Tuple[float, float] | None = None, indexed: bool = False)[source]#

Return the loading calculated at equidistant pressure points within the pressure range the model was created.

Parameters:
  • points (int) -- The number of points to get.

  • branch ({None, 'ads', 'des'}) -- The branch of the loading to return. If None, returns entire dataset.

  • loading_unit (str, optional) -- Unit in which the loading should be returned. If None it defaults to which loading unit the isotherm is currently in.

  • loading_basis ({None, 'mass', 'volume_gas', 'volume_liquid'}) -- The basis on which to return the loading, if possible. If None, returns on the basis the isotherm is currently in.

  • material_unit (str, optional) -- Unit in which the material should be returned. If None it defaults to which loading unit the isotherm is currently in.

  • material_basis ({None, 'mass', 'volume'}) -- The basis on which to return the material, if possible. If None, returns on the basis the isotherm is currently in.

  • limits ([float, float], optional) -- Minimum and maximum loading limits. Put None or -+np.inf for no limit.

  • indexed (bool, optional) -- If this is specified to true, then the function returns an indexed pandas.Series with the columns requested instead of an array.

Returns:

numpy.array or pandas.Series -- Loading calculated at points the model pressure range.

property other_keys#

Return column names of any supplementary data points.

pressure_at(loading: float | List[float], branch: str | None = None, pressure_unit: str | None = None, pressure_mode: str | None = None, loading_unit: str | None = None, loading_basis: str | None = None, material_unit: str | None = None, material_basis: str | None = None)[source]#

Compute pressure at loading L, given stored model parameters.

Depending on the model, may be calculated directly or through a numerical minimisation.

Parameters:
  • loading (float or array) -- Loading at which to compute pressure.

  • branch ({None, 'ads', 'des'}) -- The branch the calculation is based on.

  • pressure_unit (str) -- Unit the pressure is returned in. If None, it defaults to internal isotherm units.

  • pressure_mode (str) -- The mode the pressure is returned in. If None, it defaults to internal isotherm mode.

  • loading_unit (str) -- Unit the loading is specified in. If None, it defaults to internal isotherm units.

  • loading_basis ({None, 'mass', 'volume_gas', 'volume_liquid'}) -- The basis the loading is specified in. If None, assumes the basis the isotherm is currently in.

  • material_unit (str, optional) -- Unit in which the material is passed in. If None it defaults to which loading unit the isotherm is currently in

  • material_basis (str) -- The basis the loading is passed in. If None, it defaults to internal isotherm basis.

Returns:

float or array -- Predicted pressure at loading L using fitted model parameters.

loading_at(pressure: float | List[float], branch: str | None = None, pressure_unit: str | None = None, pressure_mode: str | None = None, loading_unit: str | None = None, loading_basis: str | None = None, material_unit: str | None = None, material_basis: str | None = None)[source]#

Compute loading at pressure P, given stored model parameters.

Depending on the model, may be calculated directly or through a numerical minimisation.

Parameters:
  • pressure (float or array) -- Pressure at which to compute loading.

  • branch ({None, 'ads', 'des'}) -- The branch the calculation is based on.

  • pressure_unit (str) -- Unit the pressure is specified in. If None, it defaults to internal isotherm units.

  • pressure_mode (str) -- The mode the pressure is passed in. If None, it defaults to internal isotherm mode.

  • loading_unit (str, optional) -- Unit in which the loading should be returned. If None it defaults to which loading unit the isotherm is currently in.

  • loading_basis ({None, 'mass', 'volume_gas', 'volume_liquid'}) -- The basis on which to return the loading, if possible. If None, returns on the basis the isotherm is currently in.

  • material_unit (str, optional) -- Unit in which the material should be returned. If None it defaults to which loading unit the isotherm is currently in.

  • material_basis ({None, 'mass', 'volume'}) -- The basis on which to return the material, if possible. If None, returns on the basis the isotherm is currently in.

Returns:

float or array -- Predicted loading at pressure P using fitted model parameters.

spreading_pressure_at(pressure: float | List[float], branch: str | None = None, pressure_unit: str | None = None, pressure_mode: str | None = None)[source]#

Calculate reduced spreading pressure at a bulk gas pressure P.

The reduced spreading pressure is an integral involving the isotherm \(L(P)\):

\[\Pi(p) = \int_0^p \frac{L(\hat{p})}{ \hat{p}} d\hat{p},\]

which is computed analytically or numerically, depending on the model used.

Parameters:
  • pressure (float) -- Pressure (in corresponding units as data in instantiation)

  • branch ({'ads', 'des'}) -- The branch of the use for calculation. Defaults to adsorption.

  • pressure_unit (str) -- Unit the pressure is returned in. If None, it defaults to internal isotherm units.

  • pressure_mode (str) -- The mode the pressure is returned in. If None, it defaults to internal isotherm mode.

Returns:

float -- Spreading pressure, \(\Pi\).