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
added uv-theory
  • Loading branch information
g-bauer committed May 10, 2022
commit 7fe2b92d559cea201ed60934404540ee98ee16b7
23 changes: 22 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ feos-core = "0.2"
feos-dft = "0.2"
feos-pcsaft = { version = "0.2", features = ["python"] }
feos-gc-pcsaft = { version = "0.1", features = ["python"] }
feos-pets = { git = "https://github.com/feos-org/feos-pets", features = ["python"] }
feos-estimator = { path = "../feos-estimator", features = ["python"] }
feos-pets = { version = "0.1", features = ["python"] }
feos-uvtheory = { git = "https://github.com/feos-org/feos-uvtheory", features = ["python"], tag = "v0.1.0" }
feos-estimator = { git = "https://github.com/feos-org/feos-estimator", features = ["python"], tag = "v0.1.0" }
numpy = "0.16"
ndarray = { version = "0.15", features=["approx"] }
petgraph = "0.6"
Expand Down
390 changes: 390 additions & 0 deletions examples/uvtheory.ipynb

Large diffs are not rendered by default.

37 changes: 37 additions & 0 deletions src/eos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use feos_pcsaft::python::PyPcSaftParameters;
use feos_pcsaft::{PcSaft, PcSaftOptions};
use feos_pets::python::PyPetsParameters;
use feos_pets::{Pets, PetsOptions};
use feos_uvtheory::python::PyUVParameters;
use feos_uvtheory::{Perturbation, UVTheory, UVTheoryOptions};
use ndarray::Array1;
use numpy::convert::ToPyArray;
use numpy::{PyArray1, PyArray2};
Expand All @@ -24,6 +26,7 @@ pub enum EosVariant {
PengRobinson(PengRobinson),
Python(PyEoSObj),
Pets(Pets),
UVTheory(UVTheory),
}

impl EquationOfState for EosVariant {
Expand All @@ -34,6 +37,7 @@ impl EquationOfState for EosVariant {
EosVariant::PengRobinson(eos) => eos.components(),
EosVariant::Python(eos) => eos.components(),
EosVariant::Pets(eos) => eos.components(),
EosVariant::UVTheory(eos) => eos.components(),
}
}

Expand All @@ -44,6 +48,7 @@ impl EquationOfState for EosVariant {
EosVariant::PengRobinson(eos) => eos.compute_max_density(moles),
EosVariant::Python(eos) => eos.compute_max_density(moles),
EosVariant::Pets(eos) => eos.compute_max_density(moles),
EosVariant::UVTheory(eos) => eos.compute_max_density(moles),
}
}

Expand All @@ -54,6 +59,7 @@ impl EquationOfState for EosVariant {
EosVariant::PengRobinson(eos) => Self::PengRobinson(eos.subset(component_list)),
EosVariant::Python(eos) => Self::Python(eos.subset(component_list)),
EosVariant::Pets(eos) => Self::Pets(eos.subset(component_list)),
EosVariant::UVTheory(eos) => Self::UVTheory(eos.subset(component_list)),
}
}

Expand All @@ -64,6 +70,7 @@ impl EquationOfState for EosVariant {
EosVariant::PengRobinson(eos) => eos.residual(),
EosVariant::Python(eos) => eos.residual(),
EosVariant::Pets(eos) => eos.residual(),
EosVariant::UVTheory(eos) => eos.residual(),
}
}
}
Expand All @@ -76,6 +83,7 @@ impl MolarWeight<SIUnit> for EosVariant {
EosVariant::PengRobinson(eos) => eos.molar_weight(),
EosVariant::Python(eos) => eos.molar_weight(),
EosVariant::Pets(eos) => eos.molar_weight(),
_ => unimplemented!(),
}
}
}
Expand Down Expand Up @@ -299,6 +307,35 @@ impl PyEosVariant {
options,
))))
}

/// UV-Theory equation of state.
///
/// Parameters
/// ----------
/// parameters : PetsParameters
/// The parameters of the PeTS equation of state to use.
/// max_eta : float, optional
/// Maximum packing fraction. Defaults to 0.5.
/// perturbation : Perturbation, optional
///
/// Returns
/// -------
/// EquationOfState
/// The UV-Theory equation of state that can be used to compute thermodynamic
/// states.
#[args(max_eta = "0.5", perturbation = "Perturbation::WeeksChandlerAndersen")]
#[staticmethod]
#[pyo3(text_signature = "(parameters, max_eta, perturbation)")]
fn uvtheory(parameters: PyUVParameters, max_eta: f64, perturbation: Perturbation) -> Self {
let options = UVTheoryOptions {
max_eta,
perturbation,
};
Self(Rc::new(EosVariant::UVTheory(UVTheory::with_options(
parameters.0,
options,
))))
}
}

impl_equation_of_state!(PyEosVariant);
Expand Down
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ mod gc_pcsaft;
use gc_pcsaft::__PYO3_PYMODULE_DEF_GC_PCSAFT;
mod pets;
use pets::__PYO3_PYMODULE_DEF_PETS;
mod uvtheory;
use uvtheory::__PYO3_PYMODULE_DEF_UVTHEORY;
mod estimator;
use estimator::__PYO3_PYMODULE_DEF_ESTIMATOR;

Expand All @@ -27,6 +29,7 @@ pub fn feos(py: Python<'_>, m: &PyModule) -> PyResult<()> {
m.add_wrapped(wrap_pymodule!(pcsaft))?;
m.add_wrapped(wrap_pymodule!(gc_pcsaft))?;
m.add_wrapped(wrap_pymodule!(pets))?;
m.add_wrapped(wrap_pymodule!(uvtheory))?;
m.add_wrapped(wrap_pymodule!(estimator))?;
py.run(
"\
Expand All @@ -43,6 +46,7 @@ sys.modules['feos.cubic'] = cubic
sys.modules['feos.pcsaft'] = pcsaft
sys.modules['feos.gc_pcsaft'] = gc_pcsaft
sys.modules['feos.pets'] = pets
sys.modules['feos.uvtheory'] = uvtheory
sys.modules['feos.estimator'] = estimator
",
None,
Expand Down
19 changes: 19 additions & 0 deletions src/uvtheory.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use feos_core::python::parameter::*;
use feos_uvtheory::{
python::{PyPureRecord, PyUVParameters, PyUVRecord},
Perturbation,
};
use pyo3::prelude::*;

#[pymodule]
pub fn uvtheory(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
m.add_class::<PyIdentifier>()?;
m.add_class::<PyChemicalRecord>()?;

m.add_class::<Perturbation>()?;
m.add_class::<PyUVRecord>()?;
m.add_class::<PyPureRecord>()?;
m.add_class::<PyBinaryRecord>()?;
m.add_class::<PyUVParameters>()?;
Ok(())
}