Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix pets and python bindings
  • Loading branch information
prehner committed Jul 8, 2022
commit ef6e28edc2b3df792cdb9d74ccca90255dd8feeb
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ estimator = []
pcsaft = ["feos-saft/association"]
gc_pcsaft = ["feos-saft/association"]
uvtheory = ["lazy_static"]
pets = []
pets = ["feos-saft"]
python = ["pyo3", "numpy", "feos-core/python", "feos-dft?/python", "feos-saft?/python"]
all_models = ["dft", "estimator", "pcsaft", "gc_pcsaft", "uvtheory", "pets"]
1 change: 1 addition & 0 deletions feos-saft/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ feos-dft = { version = "0.2", path = "../feos-dft", optional = true }
ndarray = { version = "0.15", features = ["serde"] }
pyo3 = { version = "0.16", optional = true }
serde = "1.0"
serde_json = "1.0"

[features]
default = []
Expand Down
6 changes: 4 additions & 2 deletions feos-saft/src/association/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ use std::fmt;
use std::rc::Rc;

#[cfg(feature = "dft")]
pub(crate) mod dft;
mod dft;
#[cfg(feature = "python")]
pub(crate) mod python;
mod python;
#[cfg(feature = "python")]
pub use python::PyAssociationRecord;

/// Pure component association parameters
#[derive(Serialize, Deserialize, Clone, Default)]
Expand Down
2 changes: 2 additions & 0 deletions feos-saft/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ pub use hard_sphere::{HardSphere, HardSphereProperties, MonomerShape};

#[cfg(feature = "association")]
mod association;
#[cfg(all(feature = "association", feature = "python"))]
pub use association::PyAssociationRecord;
#[cfg(feature = "association")]
pub use association::{Association, AssociationParameters, AssociationRecord};
3 changes: 2 additions & 1 deletion src/gc_pcsaft/python/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
use super::dft::GcPcSaftFunctionalParameters;
use super::eos::GcPcSaftEosParameters;
use super::record::GcPcSaftRecord;
use crate::association::python::PyAssociationRecord;
use feos_core::joback::JobackRecord;
use feos_core::parameter::{
BinaryRecord, IdentifierOption, ParameterError, ParameterHetero, SegmentRecord,
};
use feos_core::python::joback::PyJobackRecord;
use feos_core::python::parameter::{PyBinarySegmentRecord, PyChemicalRecord, PyIdentifier};
use feos_core::{impl_json_handling, impl_parameter_from_segments, impl_segment_record};
use feos_saft::PyAssociationRecord;
#[cfg(feature = "dft")]
use numpy::{PyArray2, ToPyArray};
use pyo3::prelude::*;
Expand Down Expand Up @@ -151,6 +151,7 @@ pub fn gc_pcsaft(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
m.add_class::<PyIdentifier>()?;
m.add_class::<PyChemicalRecord>()?;
m.add_class::<PyJobackRecord>()?;
m.add_class::<PyAssociationRecord>()?;

m.add_class::<PyGcPcSaftRecord>()?;
m.add_class::<PySegmentRecord>()?;
Expand Down
3 changes: 2 additions & 1 deletion src/pcsaft/python.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use super::parameters::{PcSaftBinaryRecord, PcSaftParameters, PcSaftRecord};
use crate::association::python::PyAssociationRecord;
use feos_core::joback::JobackRecord;
use feos_core::parameter::{
BinaryRecord, Identifier, IdentifierOption, Parameter, ParameterError, PureRecord,
Expand All @@ -8,6 +7,7 @@ use feos_core::parameter::{
use feos_core::python::joback::PyJobackRecord;
use feos_core::python::parameter::*;
use feos_core::*;
use feos_saft::PyAssociationRecord;
use numpy::{PyArray2, PyReadonlyArray2, ToPyArray};
use pyo3::exceptions::PyTypeError;
use pyo3::prelude::*;
Expand Down Expand Up @@ -161,6 +161,7 @@ pub fn pcsaft(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
m.add_class::<PyIdentifier>()?;
m.add_class::<PyChemicalRecord>()?;
m.add_class::<PyJobackRecord>()?;
m.add_class::<PyAssociationRecord>()?;

m.add_class::<PyPcSaftRecord>()?;
m.add_class::<PyPureRecord>()?;
Expand Down
12 changes: 3 additions & 9 deletions src/pets/dft/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ use feos_core::joback::Joback;
use feos_core::parameter::Parameter;
use feos_core::{IdealGasContribution, MolarWeight};
use feos_dft::adsorption::FluidParameters;
use feos_dft::fundamental_measure_theory::{
FMTContribution, FMTProperties, FMTVersion, MonomerShape,
};
use feos_dft::solvation::PairPotential;
use feos_dft::{FunctionalContribution, HelmholtzEnergyFunctional, MoleculeShape, DFT};
use ndarray::{Array, Array1, Array2};
use feos_saft::{FMTContribution, FMTVersion, HardSphereProperties, MonomerShape};
use ndarray::{Array1, Array2};
use num_dual::DualNum;
use pure_pets_functional::*;
use quantity::si::*;
Expand Down Expand Up @@ -117,11 +115,7 @@ impl MolarWeight<SIUnit> for PetsFunctional {
}
}

impl FMTProperties for PetsParameters {
fn component_index(&self) -> Array1<usize> {
Array::from_shape_fn(self.sigma.len(), |i| i)
}

impl HardSphereProperties for PetsParameters {
fn monomer_shape<N: DualNum<f64>>(&self, _: N) -> MonomerShape<N> {
MonomerShape::Spherical(self.sigma.len())
}
Expand Down
2 changes: 1 addition & 1 deletion src/pets/dft/pure_pets_functional.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::pets::eos::dispersion::{A, B};
use crate::pets::parameters::PetsParameters;
use feos_core::{EosError, EosResult};
use feos_dft::fundamental_measure_theory::FMTVersion;
use feos_dft::{
FunctionalContributionDual, WeightFunction, WeightFunctionInfo, WeightFunctionShape,
};
use feos_saft::FMTVersion;
use ndarray::*;
use num_dual::*;
use std::f64::consts::{FRAC_PI_6, PI};
Expand Down
3 changes: 1 addition & 2 deletions tests/gc_pcsaft/dft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
use approx::assert_relative_eq;
use feos::gc_pcsaft::{
GcPcSaft, GcPcSaftEosParameters, GcPcSaftFunctional, GcPcSaftFunctionalParameters,
GcPcSaftRecord,
};
use feos_core::parameter::{
self, ChemicalRecord, Identifier, IdentifierOption, ParameterHetero, SegmentRecord,
ChemicalRecord, Identifier, IdentifierOption, ParameterHetero, SegmentRecord,
};
use feos_core::{PhaseEquilibrium, State, StateBuilder, Verbosity};
use feos_dft::adsorption::{ExternalPotential, Pore1D, PoreSpecification};
Expand Down