GPEC module

Global Phase Equilibria Calculations.

Module that implements the GPEC algorithm for calculation of GPEDs and its derivatives to obtain isopleths, isotherms and isobars.

class GPEC(model: ArModel, max_pressure=2500, max_points=10000, stability_analysis=True, step_21=0.01, step_12=1e-05, x20=0.9999, x10=0.999999999)[source]

Bases: object

Global Phase Equilibria Calculation.

This class implements the GPEC algorithm for calculation of global phase equilibria diagrams (GPEDs) and their usage to obtain isotherms, isobars and isopleths. It is designed to work with a given thermodynamic model that implements the necessary methods for phase equilibria calculations.

Parameters:
  • model (ArModel) – The thermodynamic model to be used for phase equilibria calculations.

  • max_pressure (float, optional) – The maximum pressure for the calculations (default is 2500).

  • max_points (int, optional) – The maximum number of points to be calculated in the critical line (default is 10000).

  • stability_analysis (bool, optional) – Whether to perform stability analysis (default is True).

  • step_21 (float, optional) – Step size for the critical line that starts from the almost pure second component (default is 1e-2).

  • step_12 (float, optional) – Step size for the critical line that starts from the almost pure first component (default is 1e-5).

  • x20 (float, optional) – Initial mole fraction of the second component for the critical line starting from the almost pure second component (default is 0.9999).

  • x10 (float, optional) – Initial mole fraction of the first component for the critical line starting from the almost pure first component (default is 0.99999).

_z0

Initial composition of the system, representing the almost pure second component.

Type:

np.ndarray

_zi

Initial composition of the system, representing the almost pure first component.

Type:

np.ndarray

_model

The thermodynamic model used for phase equilibria calculations.

Type:

ArModel

_pures

List of pure saturation pressures for each component in the system.

Type:

list

_cl21

Critical line data starting from the almost pure second component.

Type:

dict

_cep21

Critical endpoint data starting from the almost pure second component.

Type:

dict

_cl12

Critical line data starting from the almost pure first component, or None if not applicable.

Type:

dict or None

_cep12

Critical endpoint data starting from the almost pure first component, or None if not applicable.

Type:

dict or None

_cl_ll

Critical line data for liquid-liquid critical line.

Type:

dict

_cep_ll

Critical endpoint data for liquid-liquid critical line.

Type:

dict

plot_gped()[source]

Plot the global phase equilibria diagram (GPED).

This method plots the critical lines and pure saturation pressures for the components in the system. It visualizes the phase behavior of the system across different temperatures and pressures.

calc_pxy(temperature, x10=0.9999, x20=0.9999, dx10=0.001, dx20=0.001, dxll0=0.0001)[source]

Calculate a Pxy phase diagram.

This method calculates the Pxy phase diagram for the system at a given temperature. It uses the critical lines and pure saturation pressures to determine the phase behavior of the system.

Parameters:
  • temperature (float) – The temperature at which to calculate the Pxy phase diagram.

  • x10 (float, optional) – Initial molar fraction of the first component for the line that starts from the almost pure first component (default is 1e-5).

  • x20 (float, optional) – Initial molar fraction of the second component for the line that starts from the almost pure second component (default is 1e-5).

  • dx10 (float, optional) – Step size for the line that starts from the almost pure first component (default is 1e-3).

  • dx20 (float, optional) – Step size for the line that starts from the almost pure second component (default is 1e-3).

  • dxll0 (float, optional) – Step size for the line that starts from the liquid-liquid critical point (default is 1e-4).

Returns:

A list containing the calculated Pxy phase diagrams.

  • Starting from the almost pure first component. If below its Tc.

  • Starting from the almost pure second component. If below its Tc.

  • Starting from liquid-liquid critical line, if it exists.

Return type:

list

plot_pxy(temperature, x10=0.9999, x20=0.9999, dx10=0.001, dx20=0.001, dxll0=0.0001, **plot_kwargs)[source]

Plot a Pxy phase diagram.

This method plots the Pxy phase diagram for the system at a given temperature. It visualizes the phase behavior of the system across different compositions of the components.

Parameters:
  • temperature (float) – The temperature at which to plot the Pxy phase diagram.

  • x10 (float, optional) – Initial molar fraction of the first component for the line that starts from the almost pure first component (default is 1e-5).

  • x20 (float, optional) – Initial molar fraction of the second component for the line that starts from the almost pure second component (default is 1e-5).

  • dx10 (float, optional) – Step size for the line that starts from the almost pure first component (default is 1e-3).

  • dx20 (float, optional) – Step size for the line that starts from the almost pure second component (default is 1e-3).

  • dxll0 (float, optional) – Step size for the line that starts from the liquid-liquid critical point (default is 1e-4).

  • plot_kwargs (dict, optional) – Additional keyword arguments to be passed to the plot function.

calc_txy(pressure, y10=0.9999, y20=0.9999, dy10=0.001, dy20=0.001, dyll0=0.0001)[source]

Calculate a Txy phase diagram.

This method calculates the Txy phase diagram for the system at a given pressure. It uses the critical lines and pure saturation pressures to determine the phase behavior of the system.

Parameters:
  • pressure (float) – The pressure at which to calculate the Txy phase diagram.

  • y10 (float, optional) – Initial molar fraction of the first component for the line that starts from the almost pure first component (default is 1e-5).

  • y20 (float, optional) – Initial molar fraction of the second component for the line that starts from the almost pure second component (default is 1e-5).

  • dy10 (float, optional) – Step size for the line that starts from the almost pure first component (default is -1e-3).

  • dy20 (float, optional) – Step size for the line that starts from the almost pure second component (default is 1e-3).

  • dyll0 (float, optional) – Step size for the line that starts from the liquid-liquid critical point (default is 1e-4).

Returns:

A list containing the calculated Txy envelopes. They are sorted in the order of:

  • Starting from the almost pure first component.

  • Starting from the almost pure second component.

  • Starting from liquid-liquid critical line if it exists.

Return type:

list

plot_txy(pressure, y10=0.9999, y20=0.9999, dy10=0.001, dy20=0.001, dyll0=0.0001, **plot_kwargs)[source]

Plot a Txy phase diagram.

This method plots the Txy phase diagram for the system at a given pressure.

Parameters:
  • pressure (float) – The pressure at which to plot the Txy phase diagram.

  • y10 (float, optional) – Initial molar fraction of the first component for the line that starts from the almost pure first component (default is 0.9999).

  • y20 (float, optional) – Initial molar fraction of the second component for the line that starts from the almost pure second component (default is 0.9999).

  • dy10 (float, optional) – Step size for the line that starts from the almost pure first component (default is -1e-3).

  • dy20 (float, optional) – Step size for the line that starts from the almost pure second component (default is 1e-3).

  • dyll0 (float, optional) – Step size for the line that starts from the liquid-liquid critical point (default is 1e-4).

  • plot_kwargs (dict, optional) – Additional keyword arguments to be passed to the plot function.