diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f22e72..b58ab1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/src/adsorption/pore.rs b/src/adsorption/pore.rs index 0b04109..4f5d3cc 100644 --- a/src/adsorption/pore.rs +++ b/src/adsorption/pore.rs @@ -10,14 +10,13 @@ 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 { - functional: Rc>, +pub struct Pore1D { + // functional: Rc>, geometry: AxisGeometry, pore_size: QuantityScalar, potential: ExternalPotential, @@ -25,9 +24,8 @@ pub struct Pore1D { potential_cutoff: Option, } -impl Pore1D { +impl Pore1D { pub fn new( - functional: &Rc>, geometry: AxisGeometry, pore_size: QuantityScalar, potential: ExternalPotential, @@ -35,7 +33,6 @@ impl Pore1D { potential_cutoff: Option, ) -> Self { Self { - functional: functional.clone(), geometry, pore_size, potential, @@ -46,8 +43,7 @@ impl Pore1D { } /// Parameters required to specify a 3D pore. -pub struct Pore3D { - functional: Rc>, +pub struct Pore3D { system_size: [QuantityScalar; 3], n_grid: [usize; 3], coordinates: QuantityArray2, @@ -57,9 +53,8 @@ pub struct Pore3D { cutoff_radius: Option>, } -impl Pore3D { +impl Pore3D { pub fn new( - functional: &Rc>, system_size: [QuantityScalar; 3], n_grid: [usize; 3], coordinates: QuantityArray2, @@ -69,7 +64,6 @@ impl Pore3D { cutoff_radius: Option>, ) -> Self { Self { - functional: functional.clone(), system_size, n_grid, coordinates, @@ -156,7 +150,7 @@ where } impl PoreSpecification - for Pore1D + for Pore1D { fn initialize( &self, @@ -169,7 +163,7 @@ impl 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)?, @@ -183,7 +177,7 @@ impl PoreSpecificati self.pore_size, bulk.temperature, &self.potential, - &self.functional.functional, + &bulk.eos.functional, &axis, self.potential_cutoff, ) @@ -209,8 +203,8 @@ impl PoreSpecificati } } -impl PoreSpecification - for Pore3D +impl PoreSpecification + for Pore3D { fn initialize( &self, @@ -238,7 +232,7 @@ impl 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, diff --git a/src/python/adsorption/external_potential.rs b/src/python/adsorption/external_potential.rs index 1c74fe9..99034d5 100644 --- a/src/python/adsorption/external_potential.rs +++ b/src/python/adsorption/external_potential.rs @@ -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, }) } } diff --git a/src/python/adsorption/pore.rs b/src/python/adsorption/pore.rs index 4fd7513..ad787f7 100644 --- a/src/python/adsorption/pore.rs +++ b/src/python/adsorption/pore.rs @@ -5,8 +5,6 @@ macro_rules! impl_pore { /// /// Parameters /// ---------- - /// functional : HelmholtzEnergyFunctional - /// The Helmholtz energy functional. /// geometry : Geometry /// The pore geometry. /// pore_size : SINumber @@ -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); + #[pyo3(text_signature = "(geometry, pore_size, potential, n_grid=None, potential_cutoff=None)")] + pub struct PyPore1D(Pore1D); #[pyclass(name = "PoreProfile1D", unsendable)] pub struct PyPoreProfile1D(PoreProfile1D); @@ -35,7 +33,6 @@ macro_rules! impl_pore { impl PyPore1D { #[new] fn new( - functional: &$py_func, geometry: PyGeometry, pore_size: PySINumber, potential: PyExternalPotential, @@ -43,7 +40,6 @@ macro_rules! impl_pore { potential_cutoff: Option, ) -> Self { Self(Pore1D::new( - &functional.0, geometry.0, pore_size.into(), potential.0, @@ -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] @@ -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); + #[pyo3(text_signature = "(system_size, n_grid, coordinates, sigma_ss, epsilon_k_ss, potential_cutoff=None, cutoff_radius=None)")] + pub struct PyPore3D(Pore3D); #[pyclass(name = "PoreProfile3D", unsendable)] pub struct PyPoreProfile3D(PoreProfile3D); @@ -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, @@ -140,7 +133,6 @@ macro_rules! impl_pore { cutoff_radius: Option, ) -> Self { Self(Pore3D::new( - &functional.0, [system_size[0].into(), system_size[1].into(), system_size[2].into()], n_grid, coordinates.clone().into(),