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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Changed
- Removed the `functional` field in `Pore1D` and `Pore3D`. [#9](https://github.com/feos-org/feos-core/pull/9)

### Fixed
- Fixed the units of default values for adsorption isotherms. [#8](https://github.com/feos-org/feos-core/pull/8)

Expand Down
28 changes: 11 additions & 17 deletions src/adsorption/pore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,29 @@ use ndarray::Axis as Axis_nd;
use ndarray::Zip;
use ndarray_stats::QuantileExt;
use quantity::{QuantityArray2, QuantityScalar};
use std::rc::Rc;

const POTENTIAL_OFFSET: f64 = 2.0;
const DEFAULT_GRID_POINTS: usize = 2048;

/// Parameters required to specify a 1D pore.
pub struct Pore1D<U, F> {
functional: Rc<DFT<F>>,
pub struct Pore1D<U> {
// functional: Rc<DFT<F>>,
geometry: AxisGeometry,
pore_size: QuantityScalar<U>,
potential: ExternalPotential<U>,
n_grid: Option<usize>,
potential_cutoff: Option<f64>,
}

impl<U: EosUnit, F: HelmholtzEnergyFunctional> Pore1D<U, F> {
impl<U: EosUnit> Pore1D<U> {
pub fn new(
functional: &Rc<DFT<F>>,
geometry: AxisGeometry,
pore_size: QuantityScalar<U>,
potential: ExternalPotential<U>,
n_grid: Option<usize>,
potential_cutoff: Option<f64>,
) -> Self {
Self {
functional: functional.clone(),
geometry,
pore_size,
potential,
Expand All @@ -46,8 +43,7 @@ impl<U: EosUnit, F: HelmholtzEnergyFunctional> Pore1D<U, F> {
}

/// Parameters required to specify a 3D pore.
pub struct Pore3D<U, F> {
functional: Rc<DFT<F>>,
pub struct Pore3D<U> {
system_size: [QuantityScalar<U>; 3],
n_grid: [usize; 3],
coordinates: QuantityArray2<U>,
Expand All @@ -57,9 +53,8 @@ pub struct Pore3D<U, F> {
cutoff_radius: Option<QuantityScalar<U>>,
}

impl<U, F> Pore3D<U, F> {
impl<U> Pore3D<U> {
pub fn new(
functional: &Rc<DFT<F>>,
system_size: [QuantityScalar<U>; 3],
n_grid: [usize; 3],
coordinates: QuantityArray2<U>,
Expand All @@ -69,7 +64,6 @@ impl<U, F> Pore3D<U, F> {
cutoff_radius: Option<QuantityScalar<U>>,
) -> Self {
Self {
functional: functional.clone(),
system_size,
n_grid,
coordinates,
Expand Down Expand Up @@ -156,7 +150,7 @@ where
}

impl<U: EosUnit, F: HelmholtzEnergyFunctional + FluidParameters> PoreSpecification<U, Ix1, F>
for Pore1D<U, F>
for Pore1D<U>
{
fn initialize(
&self,
Expand All @@ -169,7 +163,7 @@ impl<U: EosUnit, F: HelmholtzEnergyFunctional + FluidParameters> PoreSpecificati
let axis = match self.geometry {
AxisGeometry::Cartesian => {
let potential_offset =
POTENTIAL_OFFSET * self.functional.functional.sigma_ff().max().unwrap();
POTENTIAL_OFFSET * bulk.eos.functional.sigma_ff().max().unwrap();
Axis::new_cartesian(n_grid, 0.5 * self.pore_size, Some(potential_offset))?
}
AxisGeometry::Polar => Axis::new_polar(n_grid, self.pore_size)?,
Expand All @@ -183,7 +177,7 @@ impl<U: EosUnit, F: HelmholtzEnergyFunctional + FluidParameters> PoreSpecificati
self.pore_size,
bulk.temperature,
&self.potential,
&self.functional.functional,
&bulk.eos.functional,
&axis,
self.potential_cutoff,
)
Expand All @@ -209,8 +203,8 @@ impl<U: EosUnit, F: HelmholtzEnergyFunctional + FluidParameters> PoreSpecificati
}
}

impl<U: EosUnit, F: HelmholtzEnergyFunctional, P: FluidParameters> PoreSpecification<U, Ix3, F>
for Pore3D<U, P>
impl<U: EosUnit, F: HelmholtzEnergyFunctional + FluidParameters> PoreSpecification<U, Ix3, F>
for Pore3D<U>
{
fn initialize(
&self,
Expand Down Expand Up @@ -238,7 +232,7 @@ impl<U: EosUnit, F: HelmholtzEnergyFunctional, P: FluidParameters> PoreSpecifica
let external_potential = external_potential.map_or_else(
|| {
external_potential_3d(
&self.functional.functional,
&bulk.eos.functional,
[&x, &y, &z],
self.system_size,
coordinates,
Expand Down
4 changes: 2 additions & 2 deletions src/python/adsorption/external_potential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,13 @@ impl PyExternalPotential {
coordinates: coordinates.clone().into(),
sigma_ss: sigma_ss.to_owned_array(),
epsilon_k_ss: epsilon_k_ss.to_owned_array(),
pore_center: pore_center,
pore_center,
system_size: [
system_size[0].into(),
system_size[1].into(),
system_size[2].into(),
],
n_grid: n_grid,
n_grid,
})
}
}
Expand Down
16 changes: 4 additions & 12 deletions src/python/adsorption/pore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ macro_rules! impl_pore {
///
/// Parameters
/// ----------
/// functional : HelmholtzEnergyFunctional
/// The Helmholtz energy functional.
/// geometry : Geometry
/// The pore geometry.
/// pore_size : SINumber
Expand All @@ -23,8 +21,8 @@ macro_rules! impl_pore {
/// Pore1D
///
#[pyclass(name = "Pore1D", unsendable)]
#[pyo3(text_signature = "(functional, geometry, pore_size, potential, n_grid=None, potential_cutoff=None)")]
pub struct PyPore1D(Pore1D<SIUnit, $func>);
#[pyo3(text_signature = "(geometry, pore_size, potential, n_grid=None, potential_cutoff=None)")]
pub struct PyPore1D(Pore1D<SIUnit>);

#[pyclass(name = "PoreProfile1D", unsendable)]
pub struct PyPoreProfile1D(PoreProfile1D<SIUnit, $func>);
Expand All @@ -35,15 +33,13 @@ macro_rules! impl_pore {
impl PyPore1D {
#[new]
fn new(
functional: &$py_func,
geometry: PyGeometry,
pore_size: PySINumber,
potential: PyExternalPotential,
n_grid: Option<usize>,
potential_cutoff: Option<f64>,
) -> Self {
Self(Pore1D::new(
&functional.0,
geometry.0,
pore_size.into(),
potential.0,
Expand Down Expand Up @@ -96,8 +92,6 @@ macro_rules! impl_pore {
///
/// Parameters
/// ----------
/// functional : HelmholtzEnergyFunctional
/// The Helmholtz energy functional.
/// system_size : [SINumber; 3]
/// The size of the unit cell.
/// n_grid : [int; 3]
Expand All @@ -118,8 +112,8 @@ macro_rules! impl_pore {
/// Pore3D
///
#[pyclass(name = "Pore3D", unsendable)]
#[pyo3(text_signature = "(functional, system_size, n_grid, coordinates, sigma_ss, epsilon_k_ss, potential_cutoff=None, cutoff_radius=None)")]
pub struct PyPore3D(Pore3D<SIUnit, $func>);
#[pyo3(text_signature = "(system_size, n_grid, coordinates, sigma_ss, epsilon_k_ss, potential_cutoff=None, cutoff_radius=None)")]
pub struct PyPore3D(Pore3D<SIUnit>);

#[pyclass(name = "PoreProfile3D", unsendable)]
pub struct PyPoreProfile3D(PoreProfile3D<SIUnit, $func>);
Expand All @@ -130,7 +124,6 @@ macro_rules! impl_pore {
impl PyPore3D {
#[new]
fn new(
functional: &$py_func,
system_size: [PySINumber; 3],
n_grid: [usize; 3],
coordinates: &PySIArray2,
Expand All @@ -140,7 +133,6 @@ macro_rules! impl_pore {
cutoff_radius: Option<PySINumber>,
) -> Self {
Self(Pore3D::new(
&functional.0,
[system_size[0].into(), system_size[1].into(), system_size[2].into()],
n_grid,
coordinates.clone().into(),
Expand Down