Skip to content
This repository was archived by the owner on Jul 28, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 41 additions & 26 deletions src/python/adsorption/external_potential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@ use pyo3::prelude::*;
use quantity::python::{PySIArray2, PySINumber};
use quantity::si::*;

/// A collection of external potentials.
#[pyclass(name = "ExternalPotential", unsendable)]
#[derive(Clone)]
pub struct PyExternalPotential(pub ExternalPotential<SIUnit>);

#[pymethods]
#[allow(non_snake_case)]
impl PyExternalPotential {
/// A hard wall potential
/// Hard wall potential
///
/// .. math:: V_i^\mathrm{ext}(z)=\begin{cases}\infty&z\leq\sigma_{si}\\\\0&z>\sigma_{si}\end{cases},~~~~\sigma_{si}=\frac{1}{2}\left(\sigma_{ss}+\sigma_{ii}\right)
///
/// Parameters
/// ----------
/// sigma_ss : f64
/// sigma_ss : float
/// Segment diameter of the solid.
///
/// Returns
Expand All @@ -30,15 +33,17 @@ impl PyExternalPotential {
Self(ExternalPotential::HardWall { sigma_ss })
}

/// Create a Lennard-Jones-9-3 potential.
/// 9-3 Lennard-Jones potential
///
/// .. math:: V_i^\mathrm{ext}(z)=\frac{2\pi}{45} m_i\varepsilon_{si}\sigma_{si}^3\rho_s\left(2\left(\frac{\sigma_{si}}{z}\right)^9-15\left(\frac{\sigma_{si}}{z}\right)^3\right),~~~~\varepsilon_{si}=\sqrt{\varepsilon_{ss}\varepsilon_{ii}},~~~~\sigma_{si}=\frac{1}{2}\left(\sigma_{ss}+\sigma_{ii}\right)
///
/// Parameters
/// ----------
/// sigma_ss : f64
/// sigma_ss : float
/// Segment diameter of the solid.
/// epsilon_k_ss : f64
/// epsilon_k_ss : float
/// Energy parameter of the solid.
/// rho_s : f64
/// rho_s : float
/// Density of the solid.
///
/// Returns
Expand All @@ -55,13 +60,15 @@ impl PyExternalPotential {
})
}

/// Create a simple Lennard-Jones-9-3 potential.
/// Simple 9-3 Lennard-Jones potential
///
/// .. math:: V_i^\mathrm{ext}(z)=\varepsilon_{si}\left(\left(\frac{\sigma_{si}}{z}\right)^9-\left(\frac{\sigma_{si}}{z}\right)^3\right),~~~~\varepsilon_{si}=\sqrt{\varepsilon_{ss}\varepsilon_{ii}},~~~~\sigma_{si}=\frac{1}{2}\left(\sigma_{ss}+\sigma_{ii}\right)
///
/// Parameters
/// ----------
/// sigma_ss : f64
/// sigma_ss : float
/// Segment diameter of the solid.
/// epsilon_k_ss : f64
/// epsilon_k_ss : float
/// Energy parameter of the solid.
///
/// Returns
Expand All @@ -77,13 +84,15 @@ impl PyExternalPotential {
})
}

/// Create a custom Lennard-Jones-9-3 potential.
/// Custom 9-3 Lennard-Jones potential
///
/// .. math:: V_i^\mathrm{ext}(z)=\varepsilon_{si}\left(\left(\frac{\sigma_{si}}{z}\right)^9-\left(\frac{\sigma_{si}}{z}\right)^3\right)
///
/// Parameters
/// ----------
/// sigma_sf : PyArray
/// sigma_sf : numpy.ndarray[float]
/// Solid-fluid interaction diameters.
/// epsilon_k_sf : PyArray
/// epsilon_k_sf : numpy.ndarray[float]
/// Solid-fluid interaction energies.
///
/// Returns
Expand All @@ -99,17 +108,19 @@ impl PyExternalPotential {
})
}

/// Create a Steele potential.
/// Steele potential
///
/// .. math:: V_i^\mathrm{ext}(z)=2\pi m_i\xi\varepsilon_{si}\sigma_{si}^2\Delta\rho_s\left(0.4\left(\frac{\sigma_{si}}{z}\right)^{10}-\left(\frac{\sigma_{si}}{z}\right)^4-\frac{\sigma_{si}^4}{3\Delta\left(z+0.61\Delta\right)^3}\right),~~~~\varepsilon_{si}=\sqrt{\varepsilon_{ss}\varepsilon_{ii}},~~~~\sigma_{si}=\frac{1}{2}\left(\sigma_{ss}+\sigma_{ii}\right),~~~~\Delta=3.35
///
/// Parameters
/// ----------
/// sigma_ss : f64
/// sigma_ss : float
/// Segment diameter of the solid.
/// epsilon_k_ss : f64
/// epsilon_k_ss : float
/// Energy parameter of the solid.
/// rho_s : f64
/// rho_s : float
/// Density of the solid.
/// xi : f64, optional
/// xi : float, optional
/// Binary wall-fluid interaction parameter.
///
/// Returns
Expand All @@ -127,17 +138,19 @@ impl PyExternalPotential {
})
}

/// Create a Double-Well potential.
/// Double well potential
///
/// .. math:: V_i^\mathrm{ext}(z)=\mathrm{min}\left(\frac{2\pi}{45} m_i\varepsilon_{2si}\sigma_{si}^3\rho_s\left(2\left(\frac{2\sigma_{si}}{z}\right)^9-15\left(\frac{2\sigma_{si}}{z}\right)^3\right),0\right)+\frac{2\pi}{45} m_i\varepsilon_{1si}\sigma_{si}^3\rho_s\left(2\left(\frac{\sigma_{si}}{z}\right)^9-15\left(\frac{\sigma_{si}}{z}\right)^3\right),~~~~\varepsilon_{1si}=\sqrt{\varepsilon_{1ss}\varepsilon_{ii}},~~~~\varepsilon_{2si}=\sqrt{\varepsilon_{2ss}\varepsilon_{ii}},~~~~\sigma_{si}=\frac{1}{2}\left(\sigma_{ss}+\sigma_{ii}\right)
///
/// Parameters
/// ----------
/// sigma_ss : f64
/// sigma_ss : float
/// Segment diameter of the solid.
/// epsilon1_k_ss : f64
/// epsilon1_k_ss : float
/// Energy parameter of the first well.
/// epsilon2_k_ss : f64
/// epsilon2_k_ss : float
/// Energy parameter of the second well.
/// rho_s : f64
/// rho_s : float
/// Density of the solid.
///
/// Returns
Expand All @@ -155,15 +168,17 @@ impl PyExternalPotential {
})
}

/// Create a Free-Energy averaged potential.
/// Free-energy averaged potential
///
/// for details see: `J. Eller, J. Gross (2021) <https://pubs.acs.org/doi/abs/10.1021/acs.langmuir.0c03287>`_
///
/// Parameters
/// ----------
/// coordinates: SIArray2
/// The positions of all interaction sites in the solid.
/// sigma_ss : Array1
/// sigma_ss : numpy.ndarray[float]
/// The size parameters of all interaction sites.
/// epsilon_k_ss : Array1
/// epsilon_k_ss : numpy.ndarray[float]
/// The energy parameter of all interaction sites.
/// pore_center : [SINumber; 3]
/// The cartesian coordinates of the center of the pore
Expand Down Expand Up @@ -202,7 +217,7 @@ impl PyExternalPotential {
}
}

/// Geometry of the 1-dimensional pore.
/// Geometry of a one-dimensional pore.
///
/// Returns
/// -------
Expand Down
34 changes: 18 additions & 16 deletions src/python/adsorption/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ pub use external_potential::{PyExternalPotential, PyGeometry};
#[macro_export]
macro_rules! impl_adsorption {
($func:ty, $py_func:ty) => {
/// Container structure for adsorption isotherms in 1D pores.
#[pyclass(name = "Adsorption1D", unsendable)]
pub struct PyAdsorption1D(Adsorption1D<SIUnit, $func>);

/// Container structure for adsorption isotherms in 3D pores.
#[pyclass(name = "Adsorption3D", unsendable)]
pub struct PyAdsorption3D(Adsorption3D<SIUnit, $func>);

Expand Down Expand Up @@ -44,24 +46,24 @@ macro_rules! impl_adsorption_isotherm {
///
/// Parameters
/// ----------
/// functional : $func
/// functional : HelmholtzEnergyFunctional
/// The Helmholtz energy functional.
/// temperature : SINumber
/// The temperature.
/// pressure : {(SINumber, SINumber, int), SIArray1}
/// The pressures for which the profiles are calculated. Either
/// a tuple containing the minimum pressure, the maximum pressure,
/// and the number of points, or an array containing specific values.
/// pore : $py_pore
/// pore : Pore
/// The pore parameters.
/// molefracs: PyArray, optional
/// molefracs: numpy.ndarray[float], optional
/// For a mixture, the molefracs of the bulk system.
/// solver: DFTSolver, optional
/// Custom solver options.
///
/// Returns
/// -------
/// $adsorption
/// Adsorption
///
#[staticmethod]
#[pyo3(text_signature = "(functional, temperature, pressure, pore, molefracs=None, solver=None)")]
Expand Down Expand Up @@ -89,24 +91,24 @@ macro_rules! impl_adsorption_isotherm {
///
/// Parameters
/// ----------
/// functional : $func
/// functional : HelmholtzEnergyFunctional
/// The Helmholtz energy functional.
/// temperature : SINumber
/// The temperature.
/// pressure : {(SINumber, SINumber, int), SIArray1}
/// The pressures for which the profiles are calculated. Either
/// a tuple containing the minimum pressure, the maximum pressure,
/// and the number of points, or an array containing specific values.
/// pore : $py_pore
/// pore : Pore
/// The pore parameters.
/// molefracs: PyArray, optional
/// molefracs: numpy.ndarray[float], optional
/// For a mixture, the molefracs of the bulk system.
/// solver: DFTSolver, optional
/// Custom solver options.
///
/// Returns
/// -------
/// $adsorption
/// Adsorption
///
#[staticmethod]
#[pyo3(text_signature = "(functional, temperature, pressure, pore, molefracs=None, solver=None)")]
Expand Down Expand Up @@ -137,24 +139,24 @@ macro_rules! impl_adsorption_isotherm {
///
/// Parameters
/// ----------
/// functional : $func
/// functional : HelmholtzEnergyFunctional
/// The Helmholtz energy functional.
/// temperature : SINumber
/// The temperature.
/// pressure : {(SINumber, SINumber, int), SIArray1}
/// The pressures for which the profiles are calculated. Either
/// a tuple containing the minimum pressure, the maximum pressure,
/// and the number of points, or an array containing specific values.
/// pore : $py_pore
/// pore : Pore
/// The pore parameters.
/// molefracs: PyArray, optional
/// molefracs: numpy.ndarray[float], optional
/// For a mixture, the molefracs of the bulk system.
/// solver: DFTSolver, optional
/// Custom solver options.
///
/// Returns
/// -------
/// $adsorption
/// Adsorption
///
#[staticmethod]
#[pyo3(text_signature = "(functional, temperature, pressure, pore, molefracs=None, solver=None)")]
Expand All @@ -180,17 +182,17 @@ macro_rules! impl_adsorption_isotherm {
///
/// Parameters
/// ----------
/// functional : $func
/// functional : HelmholtzEnergyFunctional
/// The Helmholtz energy functional.
/// temperature : SINumber
/// The temperature.
/// p_min : SINumber
/// A suitable lower limit for the pressure.
/// p_max : SINumber
/// A suitable upper limit for the pressure.
/// pore : $py_pore
/// pore : Pore
/// The pore parameters.
/// molefracs: PyArray, optional
/// molefracs: numpy.ndarray[float], optional
/// For a mixture, the molefracs of the bulk system.
/// solver: DFTSolver, optional
/// Custom solver options.
Expand All @@ -203,7 +205,7 @@ macro_rules! impl_adsorption_isotherm {
///
/// Returns
/// -------
/// $adsorption
/// Adsorption
///
#[staticmethod]
#[pyo3(text_signature = "(functional, temperature, p_min, p_max, pore, molefracs=None, solver=None, max_iter=None, tol=None, verbosity=None)")]
Expand Down
26 changes: 13 additions & 13 deletions src/python/adsorption/pore.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#[macro_export]
macro_rules! impl_pore {
($func:ty, $py_func:ty) => {
/// A one-dimensional density profile of a fluid in a pore.
/// Parameters required to specify a 1D pore.
///
/// Parameters
/// ----------
/// functional : $func
/// functional : HelmholtzEnergyFunctional
/// The Helmholtz energy functional.
/// geometry : Geometry
/// The pore geometry.
Expand Down Expand Up @@ -52,21 +52,21 @@ macro_rules! impl_pore {
))
}

/// Initialize the pore for the given bulk state
/// Initialize the pore for the given bulk state.
///
/// Parameters
/// ----------
/// bulk : State
/// The bulk state in equilibrium with the pore.
/// external_potential : Array2, optional
/// external_potential : numpy.ndarray[float], optional
/// The external potential in the pore. Used to
/// save computation time in the case of costly
/// evaluations of external potentials.
///
/// Returns
/// -------
/// PoreProfile1D
#[pyo3(text_signature = "(bulk, external_potential=None)")]
#[pyo3(text_signature = "($self, bulk, external_potential=None)")]
fn initialize(
&self,
bulk: &PyState,
Expand All @@ -92,21 +92,21 @@ macro_rules! impl_pore {
}
}

/// A three-dimensional density profile of a fluid in a pore.
/// Parameters required to specify a 3D pore.
///
/// Parameters
/// ----------
/// functional : $func
/// functional : HelmholtzEnergyFunctional
/// The Helmholtz energy functional.
/// system_size : [SINumber; 3]
/// The size of the unit cell.
/// n_grid : [int; 3]
/// The number of grid points in each direction.
/// coordinates : SIArray2
/// coordinates : numpy.ndarray[float]
/// The positions of all interaction sites in the solid.
/// sigma_ss : Array1
/// sigma_ss : numpy.ndarray[float]
/// The size parameters of all interaction sites.
/// epsilon_k_ss : Array1
/// epsilon_k_ss : numpy.ndarray[float]
/// The energy parameter of all interaction sites.
/// potential_cutoff: float, optional
/// Maximum value for the external potential.
Expand Down Expand Up @@ -151,21 +151,21 @@ macro_rules! impl_pore {
))
}

/// Initialize the pore for the given bulk state
/// Initialize the pore for the given bulk state.
///
/// Parameters
/// ----------
/// bulk : State
/// The bulk state in equilibrium with the pore.
/// external_potential : Array4, optional
/// external_potential : numpy.ndarray[float], optional
/// The external potential in the pore. Used to
/// save computation time in the case of costly
/// evaluations of external potentials.
///
/// Returns
/// -------
/// PoreProfile3D
#[pyo3(text_signature = "(bulk, external_potential=None)")]
#[pyo3(text_signature = "($self, bulk, external_potential=None)")]
fn initialize(
&self,
bulk: &PyState,
Expand Down
Loading