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
Update dependencies and cleanup
  • Loading branch information
g-bauer committed Apr 8, 2022
commit 3b64710539864183777b3e834c86d969a111f956
5 changes: 2 additions & 3 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ crate-type = ["cdylib"]
[dependencies]
quantity = { version = "0.5", features = ["python"] }
feos-core = { git = "https://github.com/feos-org/feos-core", features = ["python"] }
feos-dft = { git = "https://github.com/feos-org/feos-dft", features = ["python"], branch = "v0.2.0" }
feos-pcsaft = { git = "https://github.com/feos-org/feos-pcsaft", features = ["python"] }
feos-pets = { git = "https://github.com/feos-org/feos-pets", features = ["python"] }
feos-dft = { git = "https://github.com/feos-org/feos-dft", features = ["python"], branch = "new_dft_struct" }
feos-pcsaft = { git = "https://github.com/feos-org/feos-pcsaft", features = ["python"], branch = "new_dft_struct" }
feos-pets = { path = "../feos-pets", features = ["python"] }
numpy = { version = "0.16" }
ndarray = { version = "0.15", features=["approx"] }

Expand Down
49 changes: 25 additions & 24 deletions src/dft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,34 @@ pub enum FunctionalVariant {
PetsFunctional(PetsFunctional),
}

impl From<DFT<PcSaftFunctional>> for FunctionalVariant {
fn from(f: DFT<PcSaftFunctional>) -> Self {
Self::PcSaftFunctional(f.functional)
impl From<PcSaftFunctional> for FunctionalVariant {
fn from(f: PcSaftFunctional) -> Self {
Self::PcSaftFunctional(f)
}
}

impl From<DFT<PetsFunctional>> for FunctionalVariant {
fn from(f: DFT<PetsFunctional>) -> Self {
Self::PetsFunctional(f.functional)
impl From<PetsFunctional> for FunctionalVariant {
fn from(f: PetsFunctional) -> Self {
Self::PetsFunctional(f)
}
}

impl HelmholtzEnergyFunctional for FunctionalVariant {
fn subset(&self, component_list: &[usize]) -> DFT<Self> {
match self {
FunctionalVariant::PcSaftFunctional(functional) => DFT::new_homosegmented(
functional.subset(component_list).into(),
&functional.parameters.m,
),
FunctionalVariant::PetsFunctional(functional) => DFT::new_homosegmented(
functional.subset(component_list).into(),
&Array1::<f64>::ones(functional.parameters.sigma.len()),
),
FunctionalVariant::PcSaftFunctional(functional) => {
functional.subset(component_list).into()
}
FunctionalVariant::PetsFunctional(functional) => {
functional.subset(component_list).into()
}
}
}

fn molecule_shape(&self) -> MoleculeShape {
match self {
FunctionalVariant::PcSaftFunctional(functional) => functional.molecule_shape(),
FunctionalVariant::PetsFunctional(functional) => functional.molecule_shape(),
}
}

Expand Down Expand Up @@ -100,8 +105,8 @@ impl FluidParameters for FunctionalVariant {

fn m(&self) -> Array1<f64> {
match self {
FunctionalVariant::PcSaftFunctional(functional) => functional.m(),
FunctionalVariant::PetsFunctional(functional) => functional.m(),
FunctionalVariant::PcSaftFunctional(functional) => FluidParameters::m(functional),
FunctionalVariant::PetsFunctional(functional) => FluidParameters::m(functional),
}
}
}
Expand Down Expand Up @@ -166,11 +171,9 @@ impl PyFunctional {
tol_cross_assoc,
dq_variant: dq_variant.into(),
};
let m = parameters.0.m.clone();
Self(Rc::new(DFT::new_homosegmented(
Self(Rc::new(
PcSaftFunctional::with_options(parameters.0, fmt_version, options).into(),
&m,
)))
))
}

/// PeTS Helmholtz energy functional without simplifications
Expand All @@ -193,11 +196,9 @@ impl PyFunctional {
#[pyo3(text_signature = "(parameters, fmt_version, max_eta)")]
fn pets(parameters: PyPetsParameters, fmt_version: FMTVersion, max_eta: f64) -> Self {
let options = PetsOptions { max_eta };
let m = Array1::<f64>::ones(parameters.0.sigma.len());
Self(Rc::new(DFT::new_homosegmented(
Self(Rc::new(
PetsFunctional::with_options(parameters.0, fmt_version, options).into(),
&m,
)))
))
}
}

Expand Down