### Install SurfPack from Source Source: https://thermotools.github.io/SurfPack/v1.0.0/installation.html Install SurfPack by cloning the GitHub repository and then running the pip install command from the project directory. This is useful for development or if you need a specific version not yet on PyPI. ```bash git clone https://github.com/thermotools/SurfPack.git cd SurfPack pip install . ``` -------------------------------- ### Initialize SphericalGrid with Domain Start Source: https://thermotools.github.io/SurfPack/v1.0.0/getting_started.html Shows how to create a SphericalGrid with a specified domain start, useful for modeling regions away from the origin. The grid extends from domain_start to domain_start + domain_size. ```python from surfpack import Grid, PlanarGrid, SphericalGrid, Geometry n_points = 500 domain_size = 40 # Å domain_start = 10 # Å grid = SphericalGrid(n_points, domain_size, domain_start=domain_start) ``` -------------------------------- ### Initialize PlanarGrid with Domain Start Source: https://thermotools.github.io/SurfPack/v1.0.0/getting_started.html Illustrates the creation of a PlanarGrid with a specified domain start. The grid will span from the domain_start value to domain_start + domain_size along the z-axis. ```python from surfpack import Grid, PlanarGrid, SphericalGrid, Geometry n_points = 500 domain_size = 30 # Å domain_start = 10 # Å grid = PlanarGrid(n_points, domain_size, domain_start=domain_start) ``` -------------------------------- ### Install SurfPack using pip Source: https://thermotools.github.io/SurfPack/v1.0.0/installation.html Use this command to install the latest stable version of SurfPack from the Python Package Index (PyPI). ```bash pip install surfpack ``` -------------------------------- ### Compute Surface Tension of Single Component Source: https://thermotools.github.io/SurfPack/v1.0.0/getting_started.html Compute the surface tension of a single component as a function of temperature. This example initializes models for pure hexane and a propane/hexane mixture, then plots the surface tension of hexane. ```python import matplotlib.pyplot as plt from surfpack.pcsaft import PC_SAFT dft_hex = PC_SAFT('NC6') # Initialise PC-SAFT DFT model for pure hexane dft_mix = PC_SAFT('C3,NC6') # Initialise PC-SAFT DFT model for propane/hexane mixture # Compute the surface tension of hexane as a function of temperature, at 10 points from # 0.7 * T_c to 0.9 * T_c, where T_c is the critical temperature obtained from the eos. surf_tens, temps = dft_hex.surface_tension_singlecomp(n_points=10, t_min=0.7, t_max=0.9) plt.plot(temps, surf_tens, label='NC6') plt.xlabel('T [K]') plt.ylabel(r'$\gamma$ [J Å$^{-2}$]') # NOTE: Units of Å for length plt.show() ``` -------------------------------- ### interface_thickness Source: https://thermotools.github.io/SurfPack/v1.0.0/Functional_methods.html Calculates the thickness of an interface, with an option to also return the start and end positions. ```APIDOC ## interface_thickness(self, profile, positions=False) ### Description Find the thickness of an interface. ### Method Signature `interface_thickness(self, profile, positions=False)` ### Parameters #### Args: - **profile** (Profile) : The density profile - **positions** (bool) : Also return the position where the interface starts and stops. ### Returns - **float** : The thickness of the interface. ``` -------------------------------- ### get_load_dir Source: https://thermotools.github.io/SurfPack/v1.0.0/Functional_methods.html Get the current directory used to search and load Profiles. ```APIDOC ## get_load_dir(self) ### Description Get the current directory used to search and load Profiles. ### Returns * **str** - Path to the current load directory. ``` -------------------------------- ### get_sigma Source: https://thermotools.github.io/SurfPack/v1.0.0/SAFT_methods.html Gets the sigma parameter for a specified component. ```APIDOC ## get_sigma ### Description Get the sigma parameter ### Method `get_sigma(self, ic)` ### Parameters #### Path Parameters - **ic** (int) - Required - Component index (zero-indexed) ### Returns - **float** - Model sigma-parameter [m] ``` -------------------------------- ### get_weights Source: https://thermotools.github.io/SurfPack/v1.0.0/SAFT_methods.html Get all the weights used for weighted densities. This method retrieves all weights, including FMT weights and dispersion weights, for calculating weighted densities. ```APIDOC ## get_weights(self, T, dwdT=False) ### Description Get all the weights used for weighted densities in a 2D array, indexed as weight[][], where weight[:6] are the FMT weights, (w0, w1, w2, w3, wv1, wv2), and weight[6] is the list of dispersion weights (one for each component). ### Method Signature `get_weights(self, T: float, dwdT: bool = False) -> list[list[Analytical]]` ### Parameters #### Args: - **T** (float): Temperature [K], used to get hard sphere diameters - **dwdT** (bool): Compute temperature differentials ### Returns - **2D array [Analytical]**: Weight functions, indexed as weight[][] ``` -------------------------------- ### get_fmt_weights Source: https://thermotools.github.io/SurfPack/v1.0.0/SAFT_methods.html Get the FMT weight functions. This method calculates the weight functions used in the SAFT equation of state for the Fractionation Model Theory (FMT). ```APIDOC ## get_fmt_weights(self, T, dwdT=False) ### Description Get the FMT weight functions. ### Method Signature `get_fmt_weights(self, T: float, dwdT: bool = False) -> list[list[WeightFunction]]` ### Parameters #### Args: - **T** (float): Temperature [K] - **dwdT** (bool, optional): Compute derivative instead. Defaults to False. ### Returns - **list[list[WeightFunction]]**: FMT weight functions, indexed as wts[][] ``` -------------------------------- ### get_eps_div_k Source: https://thermotools.github.io/SurfPack/v1.0.0/SAFT_methods.html Gets the epsilon parameter divided by Boltzmann's constant for a specified component. ```APIDOC ## get_eps_div_k ### Description Get the epsilon parameter ### Method `get_eps_div_k(self, ic)` ### Parameters #### Path Parameters - **ic** (int) - Required - Component index (zero-indexed) ### Returns - **float** - Model epsilon-parameter, divided by Boltzmanns constant [K] ``` -------------------------------- ### __init__ Source: https://thermotools.github.io/SurfPack/v1.0.0/Functional_methods.html Handles initialization common to all functionals, requiring the number of components. ```APIDOC ## __init__(self, ncomps) ### Description Handles initialisation that is common for all functionals ### Method Signature `__init__(self, ncomps)` ### Parameters #### Args: - **ncomps** (int) : Number of components ``` -------------------------------- ### __init__ Source: https://thermotools.github.io/SurfPack/v1.0.0/PC_SAFT_methods.html Initialises a PC-SAFT model with specified components, hard-sphere model, and parameter reference. ```APIDOC ## __init__(self, comps, hs_model=, parameter_ref='default') ### Description Initialises a PC-SAFT model. ### Parameters #### Args: - **comps** (str) - Required - Comma separated component identifiers, following thermopack convention. - **hs_model** (SAFT_HardSphere) - Optional - Model to use for the hard-sphere contribution. Default is SAFT_WhiteBear. - **parameter_ref** (str) - Optional - Reference for parameter set to use (see ThermoPack). ``` -------------------------------- ### get_save_dir Source: https://thermotools.github.io/SurfPack/v1.0.0/Functional_methods.html Get the current directory used to save Profiles. ```APIDOC ## get_save_dir(self) ### Description Get the current directory used to save Profiles. ### Returns * **str** - Path to the current save directory. ``` -------------------------------- ### Initialize Grid and PlanarGrid Source: https://thermotools.github.io/SurfPack/v1.0.0/getting_started.html Demonstrates the initialization of Grid and PlanarGrid objects with specified number of points, geometry type, and domain size. PlanarGrid is shown as an equivalent to Grid with Geometry.PLANAR. ```python from surfpack import Grid, PlanarGrid, SphericalGrid, Geometry n_points = 500 domain_size = 30 # Å grid1 = Grid(n_points, Geometry.PLANAR, domain_size) grid2 = PlanarGrid(n_points, domain_size) # Exactly equal to grid1 grid3 = Grid(n_points, Geometry.SPHERICAL, domain_size) grid4 = SphericalGrid(n_points, domain_size) # Exactly equal to grid3 ``` -------------------------------- ### Initialize PC-SAFT DFT Model Source: https://thermotools.github.io/SurfPack/v1.0.0/getting_started.html Initializes the PC-SAFT DFT model for a specified mixture. This is a prerequisite for computing profile properties like surface tension and adsorption. ```python from surfpack.pcsaft import PC_SAFT dft = PC_SAFT('C3,NC6') # Initialise PC-SAFT DFT model for propane/hexane mixture T = 300 # K # ... Compute equilibrium density profiles for some set of conditions ... rho = # The density profiles surf_tens = dft.surface_tension(rho, T, dividing_surface='t') # Compute the surface tension at the surface of tension ads = dft.adsorbtion(rho, T, dividing_surface='e') # Compute adsorbtion at the equimolar surface ``` -------------------------------- ### Compute Density Profile with External Potential (Hard Wall) Source: https://thermotools.github.io/SurfPack/v1.0.0/getting_started.html Demonstrates the calculation of density profiles in the presence of an external potential, specifically a HardWall, for a given temperature, pressure, bulk composition, and grid. The external potential is provided as a list, one for each component. ```python import matplotlib.pyplot as plt from surfpack.external_potential import HardWall from surfpack import PlanarGrid from surfpack.pcsaft import PC_SAFT dft = PC_SAFT('C3,NC6') # Initialise PC-SAFT DFT model for propane/hexane mixture T = 600 # K p = 1e5 z = [0.2, 0.8] # Bulk composition # The external potential is a list, with one potential for each component Vext = [HardWall(1, is_pore=False), HardWall(1, is_pore=False)] # A hard wall, positioned a 1 Å n_points = 500 domain_size = 30 # Å grid = PlanarGrid(n_points, domain_size) # Setting up grid for computation rho = dft.density_profile_wall_tp(T, p, z, grid, Vext) plt.plot(rho[0].grid.z, rho[0], label='C3') plt.plot(rho[1].grid.z, rho[1], label='NC6') plt.xlabel('Position [Å]') plt.ylabel(r'Density [Å$^{-3}$]') plt.legend() plt.show() ``` -------------------------------- ### Compute Density Profile for Planar Interface (Vapour Phase) Source: https://thermotools.github.io/SurfPack/v1.0.0/getting_started.html Computes the density profile for the vapor phase of a mixture at a planar interface, using specified mole fractions for the vapor. The plot uses the adapted grid from the computation results. ```python # Specifying the vapour composition y = [0.4, 0.6] rho = dft.density_profile_tz(T, y, grid, z_phase=dft.VAPPH) # Indicating that specified mole fractions apply to vapour plt.plot(rho[0].grid.z, rho[0], label='C3') plt.plot(rho[1].grid.z, rho[1], label='NC6') plt.xlabel(r'Position [Å]') plt.ylabel(r'Density [particles / Å$^3$]') plt.show() ``` -------------------------------- ### Compute Density Profile from Temperature, Pressure, and Composition Source: https://thermotools.github.io/SurfPack/v1.0.0/getting_started.html Calculates the density profile using temperature, pressure, and bulk composition. A warning is issued if the specified state corresponds to a pure vapor or liquid phase. ```python # Continiued z = [0.7, 0.3] p = 1e6 T = 300 rho = dft.density_profile_tp(T, p, z, grid) ``` -------------------------------- ### Initialize PC-SAFT DFT Model Source: https://thermotools.github.io/SurfPack/v1.0.0/getting_started.html Initialize a PC-SAFT DFT model by providing a comma-separated string of component identifiers. This sets up the model for mixture calculations. ```python from surfpack.pcsaft import PC_SAFT dft = PC_SAFT('C3,NC6') # Initialise PC-SAFT DFT model for propane-hexane mixture ``` -------------------------------- ### Configure Automatic Caching for PC-SAFT Source: https://thermotools.github.io/SurfPack/v1.0.0/getting_started.html Set a cache directory for PC-SAFT models to automatically save and search for previously computed density profiles. The directory will be created if it doesn't exist. ```python from surfpack.pcsaft import PC_SAFT dft = PC_SAFT('AR,KR') # pc-saft for argon/krypton mixture dft.set_cache_dir('directory/to/save/profiles/in') # This directory will be created if it does not exist ``` -------------------------------- ### adsorbtion Source: https://thermotools.github.io/SurfPack/v1.0.0/Functional_methods.html Computes the adsorption of each component at the interface given a density profile. ```APIDOC ## adsorbtion(self, rho, T=None, dividing_surface='e') ### Description Compute the adsorbtion of each on the interface in a given density profile. ### Parameters #### Path Parameters - **rho** (list[Profile]) - Required - The density profile for each component [1 / Å^3] - **T** (float) - Optional - Temperature [K], only required if `dividing_surface` is ‘t’ or ‘tension’ - **dividing_surface** (str) - Optional - The dividing surface to use: ‘e’ or ‘equimolar’ for equimolar surface, ‘t’ or ‘tension’ for surface of tension ### Returns #### Success Response (200) - **1D array** - The adsobtion of each component [1 / Å^2] ``` -------------------------------- ### fugacity Source: https://thermotools.github.io/SurfPack/v1.0.0/Functional_methods.html Compute the fugacity at given density and temperature. ```APIDOC ## fugacity(self, rho, T, Vext=None) ### Description Compute the fugacity at given density and temperature. ### Parameters #### Path Parameters * **rho** (list[float]) - Required - Particle density of each species * **T** (float) - Required - Temperature [K] * **Vext** (ExternalPotential, optional) - External potential for each particle ### Returns * **1d array (float)** - The fugacity of each species. ``` -------------------------------- ### adsorbtion_isotherm Source: https://thermotools.github.io/SurfPack/v1.0.0/Functional_methods.html Compute the adsorbtion as a function of molar composition along an isotherm. ```APIDOC ## adsorbtion_isotherm(self, T, n_points=30, dividing_surface='t', x_min=0.001, x_max=0.999, solver=None, rho0=None, calc_lve=False, verbose=False) ### Description Compute the adsorbtion as a function of molar composition along an isotherm. ### Parameters #### Path Parameters - **T** (float) - Required - Temperature [K] - **n_points** (int) - Optional - Number of points to compute. Defaults to 30. - **dividing_surface** (str) - Optional - Which dividing surface to use. Defaults to 't'. - **x_min** (float) - Optional - Minimum molar composition. Defaults to 0.001. - **x_max** (float) - Optional - Maximum molar composition. Defaults to 0.999. - **solver** (any) - Optional - Solver to use. Defaults to None. - **rho0** (any) - Optional - Initial density profile. Defaults to None. - **calc_lve** (bool) - Optional - Whether to calculate the liquid-vapor equilibrium. Defaults to False. - **verbose** (bool) - Optional - Whether to print verbose output. Defaults to False. ``` -------------------------------- ### Save and Load Density Profiles Source: https://thermotools.github.io/SurfPack/v1.0.0/getting_started.html Use `Profile.save_list` to store computed profiles to a JSON file and `Profile.load_file` to retrieve them later. Ensure the path is valid. ```python from surfpack import Profile rho = # ... some previously computed profile Profile.save_list(rho, 'path/to/my_profile.json') # Saving the profile rho_saved = Profile.load_file('path/to/my_profile.json') # Retriving the profile ``` -------------------------------- ### Compute Density Profile for Planar Interface (Liquid Phase) Source: https://thermotools.github.io/SurfPack/v1.0.0/getting_started.html Calculates the density profile of components in a mixture for a planar interface, specifying the liquid phase composition. The grid may be adapted, so use the grid from the returned profiles for plotting. ```python import matplotlib.pyplot as plt from surfpack.pcsaft import PC_SAFT from surfpack import PlanarGrid dft = PC_SAFT('C3,NC6') # Initialise PC-SAFT DFT model for propane/hexane mixture T = 300 # K x = [0.2, 0.8] # Liquid composition n_points = 500 domain_size = 30 # Å grid = PlanarGrid(n_points, domain_size) # Setting up grid for computation rho = dft.density_profile_tz(T, x, grid, z_phase=dft.LIQPH) # Indicating that the specified mole fractions apply to the liquid # NOTE: The grid may be adapted during computation if it is initially too narrow to fit the profile extending into the bulk # phase on each side of the interface. We should therefore use the grid held by the returned profiles to plot. plt.plot(rho[0].grid.z, rho[0], label='C3') plt.plot(rho[1].grid.z, rho[1], label='NC6') plt.xlabel(r'Position [Å]') plt.ylabel(r'Density [particles / Å$^3$]') plt.show() ``` -------------------------------- ### get_weights Source: https://thermotools.github.io/SurfPack/v1.0.0/PC_SAFT_methods.html Computes the weights for the system. ```APIDOC ## get_weights(self) ### Description Computes the weights for the system. #### Returns: - **Not specified in source** ``` -------------------------------- ### density_profile_wall Source: https://thermotools.github.io/SurfPack/v1.0.0/Functional_methods.html Calculates the equilibrium density profile for a given external potential. ```APIDOC ## density_profile_wall(self, rho_b, T, grid, Vext=None, rho_0=None, verbose=False) ### Description Calculate equilibrium density profile for a given external potential. Note: Uses lazy evaluation for (rho_b, T, x, grid, Vext) to return a copy of previous result if the same calculation is done several times. ### Args: - **rho_b** (list[float]) - Required - The bulk densities [particles / Å^3] - **T** (float) - Required - Temperature [K] - **grid** (Grid) - Required - Spatial discretization - **Vext** (ExtPotential) - Optional - External potential as a function of position (default : Vext(r) = 0). Must be hashable, to use with lazy evaluation. Recomended: Use the callable classes inherriting ExtPotential. - **rho_0** (list[Profile]) - Optional - Initial guess for density profiles. - **verbose** (bool) - Optional - Print progression information during run (default: False) ### Returns: - **list[Profile]** - The equilibrium density profiles ``` -------------------------------- ### density_profile_wall_tp Source: https://thermotools.github.io/SurfPack/v1.0.0/Functional_methods.html Calculates the equilibrium density profile for a given external potential using temperature and pressure. ```APIDOC ## density_profile_wall_tp(self, T, p, z, grid, Vext, rho0=None, verbose=0) ### Description Calculate equilibrium density profile for a given external potential. ### Args: - **T** (float) - Required - Temperature [K] - **p** (float) - Required - Pressure [Pa] - **z** (list[float]) - Required - Bulk composition - **grid** (Grid) - Required - Spatial discretization - **Vext** (ExtPotential) - Optional - External potential as a function of position (default : Vext(r) = 0). Must be hashable, to use with lazy evaluation. Recomended: Use the callable classes inherriting ExtPotential. - **rho0** (list[Profile]) - Optional - Initial guess for density profiles. - **verbose** (bool) - Optional - Print progression information during run (default: 0) ### Returns: - **list[Profile]** - The equilibrium density profiles ``` -------------------------------- ### surface_tension Source: https://thermotools.github.io/SurfPack/v1.0.0/Functional_methods.html Compute the surface tension for a given density profile. ```APIDOC ## surface_tension(self, rho, T, Vext=None, dividing_surface='equimolar') ### Description Compute the surface tension for a given density profile. ### Parameters #### Path Parameters - **rho** (list[Profile]) - Required - Density profile for each component [particles / Å^3] - **T** (float) - Required - Temperature [K] - **Vext** (list[callable], optional) - Optional - External potential. - **dividing_surface** (str, optional) - Optional - Which dividing surface to use ‘e’ or ‘equimolar’ for Equimolar surface ‘t’ or ‘tension’ for Surface of tension. Defaults to 'equimolar'. ### Returns - **float** - Surface tension [J / Å^2]. ``` -------------------------------- ### Compute Surface Tension with VLE Data Source: https://thermotools.github.io/SurfPack/v1.0.0/getting_started.html Calculates surface tension and vapor-liquid equilibrium (VLE) data simultaneously. The VLE data includes liquid composition, vapor composition, and saturation pressure. Requires `matplotlib` for plotting. ```python import matplotlib.pyplot as plt surf_tens, lve = dft_mix.surface_tension_isotherm(300, n_points=10, calc_lve=True) _, axs = plt.subplots(1, 3, sharey='row') axs[0].plot(lve[0], surf_tens) axs[0].set_xlabel('Liquid mole fraction C3') axs[1].plot(lve[1], surf_tens) axs[1].set_xlabel('Vapour mole fraction C3') axs[2].plot(lve[2], surf_tens) axs[2].set_xlabel('Pressure [Pa]') axs[0].set_ylabel(r'$\gamma$ [J Å$^{-2}$]') plt.show() ``` -------------------------------- ### __repr__ Source: https://thermotools.github.io/SurfPack/v1.0.0/PC_SAFT_methods.html Generates a unique string representation of the PC-SAFT model, including parameter and hard-sphere model information. ```APIDOC ## __repr__(self) ### Description Generates a unique string for this model, containing information about the parameters and hard-sphere model. ``` -------------------------------- ### surface_tension_singlecomp Source: https://thermotools.github.io/SurfPack/v1.0.0/Functional_methods.html Compute the surface tension of a pure component for a series of temperatures. ```APIDOC ## surface_tension_singlecomp(self, n_points=30, t_min=0.5, t_max=0.99, grid=None, solver=None, rho0=None, verbose=0) ### Description Compute the surface tension of a pure component for a series of temperatures. ### Parameters #### Path Parameters * **n_points** (int) - Optional - Number of points to compute * **t_min** (float) - Optional - Start temperature, if 0 < t_min < 1, start temperature will be t_min * Tc, where Tc is the critical temperature. * **t_max** (float) - Optional - Stop temperature, if 0 < t_max < 1, stop temperature will be t_max * Tc, where Tc is the critical temperature. * **grid** (Grid) - Optional - Grid to use for initial calculation. * **solver** (Solver) - Optional - Solver to use for all calculations * **rho0** (list[Profile]) - Optional - Initial guess for first density profile. * **verbose** (int) - Optional - Larger number gives more output during progress. ### Returns * **tuple(gamma, T)** - Where gamma and T are matching 1d arrays of the surface tension and temperature. ``` -------------------------------- ### Compute Surface Tension Isotherm Source: https://thermotools.github.io/SurfPack/v1.0.0/getting_started.html Calculates the surface tension of a mixture as a function of composition at a constant temperature. Requires `matplotlib` for plotting. ```python import matplotlib.pyplot as plt # Compute the surface tension of the mixture as a function of composition, at a given temperature (300 K) surf_tens, x_C3 = dft_mix.surface_tension_isotherm(300, n_points=10) plt.plot(x_C3, surf_tens) plt.xlabel(r'Mole fraction Propane in Liquid') plt.ylabel(r'$\gamma$ [J Å$^{-2}$]') plt.show() ``` -------------------------------- ### Compute Adsorption Isotherms Source: https://thermotools.github.io/SurfPack/v1.0.0/getting_started.html Calculates adsorption isotherms for a mixture. This function also returns vapor-liquid equilibrium data, which can be plotted against adsorption. Requires `matplotlib` for plotting. ```python # Continiued import matplotlib.pyplot as plt ads, lve = dft_mix.adsorbtion_isotherm(300, n_points=10, calc_lve=True) plt.plot(lve[0], ads[0], label='C3') plt.plot(lve[0], ads[1], label='NC6') plt.xlabel('Liquid mole fraction Propane') plt.ylabel('Adsorbtion [particles / Å$^2$]') plt.legend() plt.show() ``` -------------------------------- ### get_chain_weighted_densities Source: https://thermotools.github.io/SurfPack/v1.0.0/PC_SAFT_methods.html Computes the chain-weighted densities for the system. ```APIDOC ## get_chain_weighted_densities(self) ### Description Computes the chain-weighted densities for the system. #### Returns: - **Not specified in source** ``` -------------------------------- ### __repr__ Source: https://thermotools.github.io/SurfPack/v1.0.0/Functional_methods.html Provides a unique string representation of the functional, used for generating hashes. It should include the model name and all parameters. ```APIDOC ## __repr__(self) ### Description All Functionals must implement a unique `__repr__`, as these are used to generate the hashes that are used when saving profiles. The `__repr__` should contain a human-readable text with (at least) the name of the model and all model parameters. ### Method Signature `__repr__(self)` ``` -------------------------------- ### surface_tension_isotherm Source: https://thermotools.github.io/SurfPack/v1.0.0/Functional_methods.html Computes the surface tension as a function of molar composition along an isotherm. It can optionally return liquid and vapor compositions at the liquid-vapor equilibrium. ```APIDOC ## surface_tension_isotherm(self, T, n_points=30, dividing_surface='t', solver=None, rho0=None, calc_lve=False, verbose=False, cache_dir='') ### Description Compute the surface tension as a function of molar composition along an isotherm. ### Method `surface_tension_isotherm` ### Parameters #### Path Parameters - **T** (float) - Required - Temperature [K] - **n_points** (int) - Optional - Number of (evenly distributed) points to compute. If an array is supplied, those points are used instead. - **dividing_surface** (str, optional) - Optional - ‘t’ or ‘tension’ for surface of tension, ‘e’ or ‘equimolar’ for equimolar surface. - **solver** (SequentialSolver, optional) - Optional - Custom solver object to use. - **rho0** (list[Profile], optional) - Optional - Initial guess for density profile at x = [0, 1]. - **calc_lve** (bool, optional) - Optional - If true, return a tuple (x, y, p) with pressure (p), liquid (x) and vapour (y) composition. If false, return only liquid composition. - **verbose** (int, optional) - Optional - Print progress information, higher number gives more output, default 0. - **cache_dir** (str, optional) - Optional - Directory for caching results. ### Returns **tuple(gamma, x) or tuple(gamma, lve)** - Surface tension and composition (of first component) ``` -------------------------------- ### get_weighted_densities Source: https://thermotools.github.io/SurfPack/v1.0.0/SAFT_methods.html Computes the general weighted densities required for various Helmholtz energy contributions. It clarifies the structure of the output for different derivative calculations. ```APIDOC ## get_weighted_densities(self, rho, T, bulk=False, dndrho=False, dndT=False) ### Description Compute the weighted densities. This method is crucial for various Helmholtz energy contributions and clarifies the output structure for derivatives. ### Method `get_weighted_densities` ### Parameters #### Args: - **rho** (list[Profile] or list[float]) - Required - Particle densities of each species. - **T** (float) - Required - Temperature [K]. - **bulk** (bool) - Optional - Default False. Set to True if `rho` is `list[float]`. - **dndrho** (bool) - Optional - Whether to compute derivatives with respect to density. - **dndT** (bool) - Optional - Compute temperature derivatives. ### Notes: - `dphidn` is a list[Profile], indexed as `dphidn[][]`, where the inner index gives the weight used for computation. - Each weight results in one weighted density, summed over components, except for the dispersion weight which yields `ncomps` weighted densities (one per component). ``` -------------------------------- ### set_pure_assoc_param Source: https://thermotools.github.io/SurfPack/v1.0.0/SAFT_methods.html Sets the pure-component association parameters. ```APIDOC ## set_pure_assoc_param ### Description Set pure-conponent association parameters ### Method `set_pure_assoc_param(self, ic, eps, beta)` ### Parameters #### Path Parameters - **ic** (int) - Required - Component index (zero indexed) - **eps** (float) - Required - Association energy [J / mol] - **beta** (float) - Required - Associaiton volume [-] ``` -------------------------------- ### chemical_potential Source: https://thermotools.github.io/SurfPack/v1.0.0/Functional_methods.html Computes the chemical potential for a given density, temperature, and property flag. ```APIDOC ## chemical_potential(self, rho, T, bulk=True, property_flag='IR') ### Description Compute the chemical potential [J]. ### Args: - **rho** (list[float]) - Required - Density [particles / Å^3] - **T** (float) - Required - Temperature [K] - **bulk** (bool) - Required - Only True is implemented (default: True) - **property_flag** (str) - Optional - ‘I’ for ideal, ‘R’ for residual, ‘IR’ for total. (default: 'IR') ### Returns: - **1d array (float)** - The chemical potentials [J / particle] ``` -------------------------------- ### radial_distribution_functions Source: https://thermotools.github.io/SurfPack/v1.0.0/Functional_methods.html Computes the radial distribution functions gi,j for a specified component using the Percus trick. It includes a strategy to help convergence by using a planar geometry profile as an initial guess for the spherical case. ```APIDOC ## radial_distribution_functions(self, rho_b, T, comp_idx=0, grid=None) ### Description Compute the radial distribution functions gi,jgi,j for i=i= `comp_idx` using the “Percus trick”. To help convergence: First converge the profile for a planar geometry, exposed to an ExtendedSoft potential with a core radius 5R5R, where RR is the maximum `characteristic_length` of the mixture. Then, shift that profile to the left, and use it as an initial guess for the spherical case. If that doesn’t work, the profile can be shifted in several steps (by gradually reducing the core radius of the ExtendedSoft potential). The latter possibility is not implemented, but is just a matter of putting the “shift and recompute” part of this method in a for-loop, and adding some appropriate kwargs. ### Method `radial_distribution_functions` ### Parameters #### Path Parameters - **rho_b** (list[float]) - Required - The bulk densities [particles / Å^3] - **T** (float) - Required - Temperature [K] - **comp_idx** (int) - Optional - The first component in the pair, defaults to the first component. - **grid** (Grid) - Optional - The spatial discretisation (should have Spherical geometry for results to make sense) ### Returns **list[Profile]** - The radial distribution functions around a particle of type `comp_idx` ``` -------------------------------- ### get_weighted_densities Source: https://thermotools.github.io/SurfPack/v1.0.0/PC_SAFT_methods.html Computes the weighted densities for the system. ```APIDOC ## get_weighted_densities(self) ### Description Computes the weighted densities for the system. #### Returns: - **Not specified in source** ``` -------------------------------- ### N_adsorbed Source: https://thermotools.github.io/SurfPack/v1.0.0/Functional_methods.html Computes the adsorption of each component at the interface given a density profile. ```APIDOC ## N_adsorbed(self, rho, T=None, dividing_surface='e') ### Description Compute the adsorbtion of each on the interface in a given density profile ### Parameters #### Path Parameters - **rho** (list[Profile]) - Required - The density profile for each component [1 / Å^3] - **T** (float) - Optional - Temperature [K], only required if `dividing_surface` is ‘t’ or ‘tension’ - **dividing_surface** (str) - Optional - The dividing surface to use: ‘e’ or ‘equimolar’ for equimolar surface, ‘t’ or ‘tension’ for surface of tension ### Returns #### Success Response (200) - **1D array** - The adsobtion of each component [1 / Å^2] ``` -------------------------------- ### pressure_tv Source: https://thermotools.github.io/SurfPack/v1.0.0/SAFT_methods.html Calculate pressure given density and temperature. This is a deprecated method and may be removed in the future. ```APIDOC ## pressure_tv(self, rho, T) ### Description Calculate pressure given density and temperature. ### Method Signature `pressure_tv(self, rho: Any, T: Any)` ### Parameters #### Args: - **rho**: Density - **T**: Temperature ``` -------------------------------- ### Access ThermoPack EOS Functionality Source: https://thermotools.github.io/SurfPack/v1.0.0/getting_started.html Access the internal equation of state object ('eos') from an initialized DFT model to utilize ThermoPack's full functionality, such as computing binary properties. ```python # Continiued T = 300 # Kelvin vle, l1ve, l2ve = dft.eos.get_binary_pxy(T) # Computed using ThermoPack pc-saft eos with the same parameters as the DFT is using ``` -------------------------------- ### get_chain_weights Source: https://thermotools.github.io/SurfPack/v1.0.0/PC_SAFT_methods.html Computes the chain weights for the system. ```APIDOC ## get_chain_weights(self) ### Description Computes the chain weights for the system. #### Returns: - **Not specified in source** ``` -------------------------------- ### adsorbed_thickness Source: https://thermotools.github.io/SurfPack/v1.0.0/Functional_methods.html Determines the thickness of an adsorbed film. ```APIDOC ## adsorbed_thickness(self, profile) ### Description Find the thickness of an adsorbed film. ### Method Signature `adsorbed_thickness(self, profile)` ### Parameters #### Args: - **profile** (Profile) : The density profile ### Returns - **float** : The thickness of the adsorbed layer. ``` -------------------------------- ### get_chain_weights Source: https://thermotools.github.io/SurfPack/v1.0.0/PC_SAFT_methods.html Retrieves the weight functions for the chain contribution. These weights are related to local density and specific equations described in Sauer & Gross (10.1021/acs.iecr.6b04551). It can compute temperature derivatives. ```APIDOC ## get_chain_weights(self, T, dwdT=False) ### Description Get the weight functions for the chain contribution, indexed as wts[][]. The weights wts[0] correspond to the local density, wts[1] are eq. Eq. 53 in Sauer & Gross, 10.1021/acs.iecr.6b04551 (lambda) and wts[1] are Eq. 54 in the same paper. ### Method get_chain_weights ### Parameters #### Args: - **T** (float) - Temperature [K] - **dwdT** (bool) - Compute derivative instead. #### Returns: - **list[list[Analytical]]** - The weight functions, shape (3 * ncomps, ncomps) ``` -------------------------------- ### get_weighted_densities Source: https://thermotools.github.io/SurfPack/v1.0.0/PC_SAFT_methods.html Computes all necessary weighted densities for the model. This method is versatile and can handle both profile and bulk density inputs, with options for derivative calculations. ```APIDOC ## get_weighted_densities(self, rho, T, bulk=False, dndrho=False, dndT=False) ### Description Compute all neccessary weighted densities for this model. ### Method get_weighted_densities ### Parameters #### Args: - **rho** (list[Profile] or list[float]) - The particle density of each species - **T** (float) - Temperature [K] - **bulk** (bool) - Default False. Set to True if `rho` is `list[float]` - **dndrho** (bool) - Compute derivative (only for `bulk=True`) - **dndT** (bool) - Compute derivative #### Returns: - **list[Profile] or list[float]** - Weighted densities - **Optional 2d array (float)** - dndrho, derivatives of weighted densities, indexed as dndrho[][] ``` -------------------------------- ### reduced_helmholtz_energy_density Source: https://thermotools.github.io/SurfPack/v1.0.0/PC_SAFT_methods.html Computes the reduced Helmholtz energy density for a given density profile and temperature, with options for derivative calculations. ```APIDOC ## reduced_helmholtz_energy_density(self, rho, T, dphidn=False, bulk=False, asarray=False, dphidT=False, dphidrho=False) ### Description Compute the the reduced Helmholtz energy density #### Args: - **rho** (list[Profile] or list[float]) - Required - Particle density for each species - **T** (float) - Required - Temperature [K] - **bulk** (bool) - Optional - Default False. Set to True if `rho` is `list[float]` - **dphidn** (bool) - Optional - Compute derivative - **dphidT** (bool) - Optional - Compute derivative - **dphidrho** (bool) - Optional - Compute derivative - **asarray** (bool) - Optional - Not specified in source, assuming optional based on context. - **n_chain** (list[Profile], optional) - Optional - Pre-computed weighted densities. #### Returns: - **Profile or float** - The (reduced) chain helmholtz energy density [-] ``` -------------------------------- ### get_weights Source: https://thermotools.github.io/SurfPack/v1.0.0/PC_SAFT_methods.html Retrieves all weight functions used for weighted densities in a 2D array. This method can compute temperature differentials. ```APIDOC ## get_weights(self, T, dwdT=False) ### Description Get all the weights used for weighted densities in a 2D array, indexed as weight[][]. ### Method get_weights ### Parameters #### Args: - **T** (float) - Temperature [K], used to get hard sphere diameters - **dwdT** (bool) - Compute temperature differentials #### Returns: - **2D array [Analytical]** - Weight functions, indexed as weight[][] ``` -------------------------------- ### get_fmt_weighted_densities Source: https://thermotools.github.io/SurfPack/v1.0.0/SAFT_methods.html Computes weighted densities based on the Fundamental Measure Theory (FMT) model. Supports derivative calculations. ```APIDOC ## get_fmt_weighted_densities(self, rho, T, bulk=False, dndrho=False, dndT=False) ### Description Compute weighted densities from the FMT model. This method can also compute derivatives with respect to density and temperature. ### Method `get_fmt_weighted_densities` ### Parameters #### Args: - **rho** (list[Profile] or list[float]) - Required - Particle densities of each species. - **T** (float) - Required - Temperature [K]. - **bulk** (bool) - Optional - Default False. Set to True if `rho` is `list[float]`. - **dndrho** (bool) - Optional - Also compute derivatives (only for bulk). - **dndT** (bool) - Optional - Also compute temperature derivatives. #### Returns: - **list[Profile] or list[float]** - The weighted densities and optionally one differential. ``` -------------------------------- ### adsorbed_mean_density Source: https://thermotools.github.io/SurfPack/v1.0.0/Functional_methods.html Computes the mean density of an adsorbed film. ```APIDOC ## adsorbed_mean_density(self, profile) ### Description Compute the mean density of an adsorbed film. ### Method Signature `adsorbed_mean_density(self, profile)` ### Parameters #### Args: - **profile** (Profile) : The density profile ### Returns - **float** : The mean density. ``` -------------------------------- ### get_association_weights Source: https://thermotools.github.io/SurfPack/v1.0.0/PC_SAFT_methods.html Retrieves the weight functions for association weighted densities, equivalent to component weights from FMT. It can compute temperature derivatives. ```APIDOC ## get_association_weights(self, T, dwdT=False) ### Description Get the weight functions for the association weighted densities, indexed as wts[][], equivalent to the component weights from FMT. ### Method get_association_weights ### Parameters #### Args: - **T** (float) - Temperature [K] - **dwdT** (bool) - Compute derivative #### Returns: - **list[list[Analytical]]** - The weight functions. ``` -------------------------------- ### density_profile_tz Source: https://thermotools.github.io/SurfPack/v1.0.0/Functional_methods.html Computes the density profile separating two phases at a given temperature and composition. ```APIDOC ## density_profile_tz(self, T, z, grid, z_phase=1, rho_0=None, solver=None, verbose=0) ### Description Compute the density profile separating two phases at temperature T, with liquid (or optionally vapour) composition x. ### Args: - **T** (float) - Required - Temperature [K] - **z** (ndarray[float]) - Required - Molar composition of liquid phase (unless x_phase=2) - **grid** (Grid or GridSpec) - Required - The spatial discretization - **z_phase** (int) - Optional - ThermoPack Phase flag, indicating which phase has composition `x`. `x_phase=1` for liquid (default), `x_phase=2` for vapour. (default: 1) - **rho_0** (list[Profile]) - Optional - Initial guess - **solver** (SequentialSolver or GridRefiner) - Optional - Solver to use - **verbose** (int) - Optional - Print debugging information (higher number gives more output), default 0 ### Returns: - **list[Profile]** - The converged density profiles. ``` -------------------------------- ### set_load_dir Source: https://thermotools.github.io/SurfPack/v1.0.0/Functional_methods.html Sets the directory from which computed profiles will be automatically searched and loaded. ```APIDOC ## set_load_dir(self, load_dir) ### Description Sets this model to automatically search for computed profiles in `load_dir`. ### Method Signature `set_load_dir(self, load_dir)` ### Parameters #### Args: - **load_dir** (str) : Name of directory to load files from. ### Raises - **NotADirectoryError** : If load_dir does not exist. ``` -------------------------------- ### grand_potential_density Source: https://thermotools.github.io/SurfPack/v1.0.0/Functional_methods.html Compute the Grand Potential density. ```APIDOC ## grand_potential_density(self, rho, T, Vext=None, property_flag='IR') ### Description Compute the Grand Potential density. ### Parameters #### Path Parameters - **rho** (list[Profile] or Iterable[float]) - Required - The density profile for each component, or the bulk density of each component [particles / Å^3] - **T** (float) - Required - Temperature [K] - **Vext** (list[callable] or callable) - Optional - External potential for each component, it is recomended to use the callables inherriting ExtPotential in external_potential.py. Defaults to None. - **property_flag** (str) - Optional - Return Residual (‘R’), Ideal (‘I’) or total (‘IR’) grand potential density. Defaults to 'IR'. ### Returns - **Profile** - The Grand Potential density [J / Å^3]. ``` -------------------------------- ### density_profile_tp Source: https://thermotools.github.io/SurfPack/v1.0.0/Functional_methods.html Computes the equilibrium density profile across a gas-liquid interface given temperature, pressure, and spatial discretization. It handles multicomponent systems by using twophase_tpflash for phase composition calculations. ```APIDOC ## density_profile_tp(self, T, p, z, grid, rho_0=None, solver=None, verbose=False) ### Description Compute the equilibrium density profile across a gas-liquid interface. For multicomponent systems, twophase_tpflash is used to compute the composition of the two phases. For single component systems, p is ignored, and pressure is computed from dew_pressure. ### Method `density_profile_tp` ### Parameters #### Path Parameters - **T** (float) - Required - Temperature [K] - **p** (float) - Required - Pressure [Pa] - **z** (float) - Required - Height of the interface [m] - **grid** (Grid) - Required - Spatial discretisation - **rho_0** (list[Profile], optional) - Optional - Initial guess for density profile - **solver** (SequentialSolver or GridRefiner) - Optional - Solver to use, uses a default SequentialSolver if none is supplied - **verbose** (bool, optional) - Optional - Whether to print progress info ### Returns **list[Profile]** - The density profile for each component across the interface. ``` -------------------------------- ### reduced_helmholtz_energy_density Source: https://thermotools.github.io/SurfPack/v1.0.0/Functional_methods.html Returns the reduced, residual helmholtz energy density, ϕϕ (i.e. the integrand of eq. 3.4 in “introduction to DFT”). ```APIDOC ## reduced_helmholtz_energy_density(self, *args, **kwargs) ### Description Returns the reduced, residual helmholtz energy density, ϕϕ (i.e. the integrand of eq. 3.4 in “introduction to DFT”) \(\\phi = \\frac{a^{res}}{k_B T}\\) where aresares is the residual helmholtz energy density (per particle), in [J Å−3−3] ### Parameters No parameters are explicitly documented for this method. ``` -------------------------------- ### get_assoc_weighted_densities Source: https://thermotools.github.io/SurfPack/v1.0.0/PC_SAFT_methods.html Computes the association-weighted densities for the system. ```APIDOC ## get_assoc_weighted_densities(self) ### Description Computes the association-weighted densities for the system. #### Returns: - **Not specified in source** ```