Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
ecc6f54
Revised handling of ideal gas contribution
prehner Jun 1, 2023
5e55d55
ignore some specialized functionalities
prehner Jun 1, 2023
eb01939
added some residual properties.todo: check ideal gas parts
g-bauer Jun 1, 2023
d4bd127
feos-core compiles again
prehner Jun 1, 2023
75e24a3
Fancy StateBuilder
prehner Jun 1, 2023
89d6d8e
Adjusted parameters, cubic and Joback. Added EquationOfState and test…
g-bauer Jun 2, 2023
4476475
Added EntropyScaling in core, adjusted derive macros, started adjusti…
g-bauer Jun 2, 2023
a8cb089
Adjusted python interface, currently panics for residual properties w…
g-bauer Jun 2, 2023
0668a63
Phase equilibria routine; moved dmu_dni to residual_properties; UNTESTED
prehner Jun 2, 2023
9d18ad5
Added missing files for feos-derive
g-bauer Jun 2, 2023
48e98ba
moved subset to new Components trait, eliminated DeBroglieWavelength …
prehner Jun 4, 2023
5b6eed1
new file in feos-derive
prehner Jun 4, 2023
8191f15
First tiny steps for DFT implementation
prehner Jun 4, 2023
c8e453a
DFT almost implemented
prehner Jun 5, 2023
c538018
fix ln_phi
prehner Jun 5, 2023
b685380
Fixed rest of models. Python part still needs to be done.
g-bauer Jun 6, 2023
134b788
Change Joback parameters for test case
g-bauer Jun 6, 2023
5f63e75
Expose IdealGasModel and ResidualModel
g-bauer Jun 6, 2023
454100f
Fix calculation of critical points and some phase equilibria
prehner Jun 6, 2023
61fc6f3
Fix `init_pure_p`
prehner Jun 6, 2023
6ce52df
fix pdgt
prehner Jun 6, 2023
b62cd1b
revive DeBroglieWavelength traits
prehner Jun 6, 2023
6b2b895
Fix Python for basic equations of state (including user defined)
prehner Jun 6, 2023
4070732
docstrings, cleanup and tests
prehner Jun 6, 2023
1598705
Explicitly handle non-additive properties and simplify the rest
prehner Jun 6, 2023
cae0991
updated theory guide
prehner Jun 7, 2023
4cc8d31
Adjustment for Python interface. DFT + Python not yet working
g-bauer Jun 7, 2023
9d48a17
make ideal gas in DFT actually usable
prehner Jun 7, 2023
c6e9d35
Fix remaining tests and functionals
prehner Jun 7, 2023
21e471e
fix estimator
prehner Jun 7, 2023
cfeb488
clear Cargo.toml
prehner Jun 7, 2023
25ed0c9
WIP Python interface for DFT
g-bauer Jun 7, 2023
84a1a0d
Python wheels online
prehner Jun 7, 2023
5da4973
Pore equilibrium algorithm that does not rely on the ideal gas model.…
prehner Jun 9, 2023
a072af1
Final cleanup of rust code, moved Verbosity and SolverOptions to lib.rs
prehner Jun 9, 2023
dc02390
Cargo.toml once again
prehner Jun 9, 2023
46f7403
revert changes to pets
prehner Jun 9, 2023
003a214
Proper parameter treatment for Joback, renamed function in deBroglieW…
g-bauer Jun 15, 2023
e60e551
Updated tests
g-bauer Jun 15, 2023
daad0cf
Added Joback parameters for tests
g-bauer Jun 15, 2023
dd9e23d
Fix calculation of dln_phi_dt
prehner Jun 16, 2023
42f9501
Fix critical_point_binary_p
prehner Jun 16, 2023
3f11197
Updated changelog for feos-core
g-bauer Jun 19, 2023
5f2b0a0
Updated changelog for feos-dft
g-bauer Jun 19, 2023
a3e7f03
fix total_gibbs energy and hence accelerated successive substitution
prehner Jul 3, 2023
6b7cdb9
clarify docstring of residual Helmholtz and Gibbs energy
prehner Jul 5, 2023
6c6f023
update changelog
prehner Jul 7, 2023
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
Adjustment for Python interface. DFT + Python not yet working
  • Loading branch information
g-bauer committed Jun 7, 2023
commit 4cc8d31c89b1547e89f1c3acadb35e1ea868fdb7
2 changes: 1 addition & 1 deletion feos-core/src/python/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub mod cubic;
mod equation_of_state;
pub mod joback;
pub mod parameter;
// mod phase_equilibria;
mod phase_equilibria;
mod state;
pub mod user_defined;

Expand Down
14 changes: 0 additions & 14 deletions feos-core/src/python/phase_equilibria.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,20 +237,6 @@ macro_rules! impl_phase_equilibrium {
PyState(self.0.liquid().clone())
}

/// Calculate a new PhaseEquilibrium with the given chemical potential.
/// The temperature remains constant, but the states are not in
/// a mechanical equilibrium anymore.
///
/// Parameters
/// ----------
/// chemical_potential: SIArray1
/// The new chemical potential
///
fn update_chemical_potential(slf: &PyCell<Self>, chemical_potential: &PySIArray1) -> PyResult<()> {
slf.borrow_mut().0.update_chemical_potential(chemical_potential)?;
Ok(())
}

/// Calculate the pure component vapor-liquid equilibria for all
/// components in the system.
///
Expand Down
22 changes: 4 additions & 18 deletions feos-core/src/python/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -696,18 +696,11 @@ macro_rules! impl_state {

/// Return partial molar entropy of each component.
///
/// Parameters
/// ----------
/// contributions: Contributions, optional
/// the contributions of the helmholtz energy.
/// Defaults to Contributions.Total.
///
/// Returns
/// -------
/// SIArray1
#[pyo3(signature = (contributions=Contributions::Total), text_signature = "($self, contributions)")]
fn partial_molar_entropy(&self, contributions: Contributions) -> PySIArray1 {
PySIArray1::from(self.0.partial_molar_entropy(contributions))
fn partial_molar_entropy(&self) -> PySIArray1 {
PySIArray1::from(self.0.partial_molar_entropy())
}

/// Return enthalpy.
Expand Down Expand Up @@ -745,18 +738,11 @@ macro_rules! impl_state {

/// Return partial molar enthalpy of each component.
///
/// Parameters
/// ----------
/// contributions: Contributions, optional
/// the contributions of the helmholtz energy.
/// Defaults to Contributions.Total.
///
/// Returns
/// -------
/// SIArray1
#[pyo3(signature = (contributions=Contributions::Total), text_signature = "($self, contributions)")]
fn partial_molar_enthalpy(&self, contributions: Contributions) -> PySIArray1 {
PySIArray1::from(self.0.partial_molar_enthalpy(contributions))
fn partial_molar_enthalpy(&self) -> PySIArray1 {
PySIArray1::from(self.0.partial_molar_enthalpy())
}

/// Return helmholtz_energy.
Expand Down
11 changes: 0 additions & 11 deletions feos-derive/src/dft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,6 @@ fn impl_helmholtz_energy_functional(
Self::#name(functional) => functional.contributions()
}
});
let ideal_gas = variants.iter().map(|v| {
let name = &v.ident;
quote! {
Self::#name(functional) => functional.ideal_gas()
}
});

let mut bond_lengths = Vec::new();
for v in variants.iter() {
Expand Down Expand Up @@ -145,11 +139,6 @@ fn impl_helmholtz_energy_functional(
#(#contributions,)*
}
}
fn ideal_gas(&self) -> &dyn IdealGasContribution {
match self {
#(#ideal_gas,)*
}
}
fn bond_lengths(&self, temperature: f64) -> UnGraph<(), f64> {
match self {
#(#bond_lengths,)*
Expand Down
4 changes: 2 additions & 2 deletions feos-dft/src/adsorption/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
use super::functional::{HelmholtzEnergyFunctional, DFT};
use super::solver::DFTSolver;
use feos_core::{
Components, Contributions, DensityInitialization, EosError, EosResult, EosUnit, Residual,
SolverOptions, State, StateBuilder,
Components, Contributions, DensityInitialization, EosResult, EosUnit, Residual, SolverOptions,
State, StateBuilder,
};
use ndarray::{Array1, Dimension, Ix1, Ix3, RemoveAxis};
use quantity::si::{SIArray1, SIArray2, SINumber, SIUnit};
Expand Down
10 changes: 1 addition & 9 deletions src/gc_pcsaft/python/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ use super::dft::GcPcSaftFunctionalParameters;
use super::eos::GcPcSaftEosParameters;
use super::record::GcPcSaftRecord;
use crate::association::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};
#[cfg(feature = "dft")]
Expand Down Expand Up @@ -77,12 +75,7 @@ impl PyGcPcSaftRecord {

impl_json_handling!(PyGcPcSaftRecord);

impl_segment_record!(
GcPcSaftRecord,
PyGcPcSaftRecord,
JobackRecord,
PyJobackRecord
);
impl_segment_record!(GcPcSaftRecord, PyGcPcSaftRecord);

#[pyclass(name = "GcPcSaftEosParameters")]
#[pyo3(
Expand Down Expand Up @@ -156,7 +149,6 @@ pub fn gc_pcsaft(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
m.add_class::<PyIdentifier>()?;
m.add_class::<IdentifierOption>()?;
m.add_class::<PyChemicalRecord>()?;
m.add_class::<PyJobackRecord>()?;
m.add_class::<PyAssociationRecord>()?;

m.add_class::<PyGcPcSaftRecord>()?;
Expand Down
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
#![warn(clippy::all)]
#![allow(clippy::too_many_arguments)]
#![allow(deprecated)]
// #[cfg(feature = "dft")]
// mod dft;
// #[cfg(feature = "dft")]
// pub use dft::FunctionalVariant;
#[cfg(feature = "dft")]
mod dft;
#[cfg(feature = "dft")]
pub use dft::FunctionalVariant;
mod eos;
pub use eos::{IdealGasModel, ResidualModel};

Expand Down
2 changes: 0 additions & 2 deletions src/pcsaft/python.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
use super::parameters::{PcSaftBinaryRecord, PcSaftParameters, PcSaftRecord};
use super::DQVariants;
use feos_core::joback::JobackRecord;
use feos_core::parameter::{
BinaryRecord, Identifier, IdentifierOption, Parameter, ParameterError, PureRecord,
SegmentRecord,
};
use feos_core::python::joback::PyJobackRecord;
use feos_core::python::parameter::*;
use feos_core::*;
use ndarray::Array2;
Expand Down
14 changes: 1 addition & 13 deletions src/pets/dft/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ use super::eos::PetsOptions;
use super::parameters::PetsParameters;
use crate::hard_sphere::{FMTContribution, FMTVersion};
use dispersion::AttractiveFunctional;
use feos_core::joback::Joback;
use feos_core::parameter::Parameter;
use feos_core::{IdealGasContribution, MolarWeight};
use feos_core::MolarWeight;
use feos_dft::adsorption::FluidParameters;
use feos_dft::solvation::PairPotential;
use feos_dft::{FunctionalContribution, HelmholtzEnergyFunctional, MoleculeShape, DFT};
Expand All @@ -25,7 +24,6 @@ pub struct PetsFunctional {
fmt_version: FMTVersion,
options: PetsOptions,
contributions: Vec<Box<dyn FunctionalContribution>>,
joback: Joback,
}

impl PetsFunctional {
Expand Down Expand Up @@ -74,17 +72,11 @@ impl PetsFunctional {
contributions.push(Box::new(att));
}

let joback = match &parameters.joback_records {
Some(joback_records) => Joback::new(joback_records.clone()),
None => Joback::default(parameters.sigma.len()),
};

Self {
parameters,
fmt_version,
options: pets_options,
contributions,
joback,
}
.into()
}
Expand All @@ -111,10 +103,6 @@ impl HelmholtzEnergyFunctional for PetsFunctional {
fn contributions(&self) -> &[Box<dyn FunctionalContribution>] {
&self.contributions
}

fn ideal_gas(&self) -> &dyn IdealGasContribution {
&self.joback
}
}

impl MolarWeight for PetsFunctional {
Expand Down
7 changes: 1 addition & 6 deletions src/pets/python.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use super::parameters::*;
use feos_core::joback::JobackRecord;
use feos_core::parameter::*;
use feos_core::python::joback::PyJobackRecord;
use feos_core::python::parameter::*;
use feos_core::{impl_binary_record, impl_json_handling, impl_parameter, impl_pure_record};
use ndarray::Array2;
Expand Down Expand Up @@ -69,7 +67,7 @@ impl PyPetsRecord {
}

impl_json_handling!(PyPetsRecord);
impl_pure_record!(PetsRecord, PyPetsRecord, JobackRecord, PyJobackRecord);
impl_pure_record!(PetsRecord, PyPetsRecord);

#[pyclass(name = "PetsBinaryRecord")]
#[pyo3(
Expand Down Expand Up @@ -180,7 +178,6 @@ impl PyPetsParameters {
identifier,
molarweight.as_ref().map_or(1.0, |v| v[i]),
model_record,
None,
)
// Hier Ideal Gas anstatt None???
})
Expand Down Expand Up @@ -239,7 +236,6 @@ impl PyPetsParameters {
),
molarweight.map_or(1.0, |v| v),
PetsRecord::new(sigma, epsilon_k, viscosity, diffusion, thermal_conductivity),
None,
);
Self(Arc::new(PetsParameters::new_pure(pure_record)))
}
Expand All @@ -265,7 +261,6 @@ pub fn pets(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
m.add_class::<PyIdentifier>()?;
m.add_class::<IdentifierOption>()?;
m.add_class::<PyChemicalRecord>()?;
m.add_class::<PyJobackRecord>()?;

m.add_class::<PyPetsRecord>()?;
m.add_class::<PyPureRecord>()?;
Expand Down
1 change: 0 additions & 1 deletion src/python/cubic.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use feos_core::python::cubic::*;
use feos_core::python::joback::PyJobackRecord;
use feos_core::python::parameter::*;
use pyo3::prelude::*;

Expand Down
15 changes: 10 additions & 5 deletions src/python/dft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use crate::saftvrqmie::python::PySaftVRQMieParameters;
#[cfg(feature = "saftvrqmie")]
use crate::saftvrqmie::{FeynmanHibbsOrder, SaftVRQMieFunctional, SaftVRQMieOptions};

use crate::eos::IdealGasModel;
use feos_core::*;
use feos_dft::adsorption::*;
use feos_dft::interface::*;
Expand All @@ -33,14 +34,14 @@ use pyo3::exceptions::{PyIndexError, PyValueError};
use pyo3::prelude::*;
#[cfg(feature = "estimator")]
use pyo3::wrap_pymodule;
use quantity::python::{PySINumber, PySIArray1, PySIArray2, PySIArray3, PySIArray4};
use quantity::python::{PySIArray1, PySIArray2, PySIArray3, PySIArray4, PySINumber};
use quantity::si::*;
use std::collections::HashMap;
use std::sync::Arc;

#[pyclass(name = "HelmholtzEnergyFunctional")]
#[derive(Clone)]
pub struct PyFunctionalVariant(pub Arc<DFT<FunctionalVariant>>);
pub struct PyFunctionalVariant(pub Arc<DFT<EquationOfState<IdealGasModel, FunctionalVariant>>>);

#[pymethods]
impl PyFunctionalVariant {
Expand Down Expand Up @@ -84,9 +85,13 @@ impl PyFunctionalVariant {
tol_cross_assoc,
dq_variant,
};
Self(Arc::new(
PcSaftFunctional::with_options(parameters.0, fmt_version, options).into(),
))
let functional = Arc::new(PcSaftFunctional::with_options(
parameters.0,
fmt_version,
options,
));
let ideal_gas = Arc::new(IdealGasModel::NoModel(functional.components()));
Self(Arc::new(EquationOfState::new(ideal_gas, functional).into()))
}

/// (heterosegmented) group contribution PC-SAFT Helmholtz energy functional.
Expand Down
20 changes: 10 additions & 10 deletions src/python/eos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ use pyo3::prelude::*;
#[cfg(feature = "estimator")]
use pyo3::wrap_pymodule;
use quantity::python::{PySINumber, PySIArray1, PySIArray2};
use std::sync::Arc;
use quantity::si::*;
use std::collections::HashMap;
use std::sync::Arc;

/// Collection of equations of state.
#[pyclass(name = "EquationOfState")]
Expand Down Expand Up @@ -93,7 +93,7 @@ impl PyEquationOfState {
parameters.0,
options,
)));
let ideal_gas = Arc::new(IdealGasModel::NoModel);
let ideal_gas = Arc::new(IdealGasModel::NoModel(residual.components()));
Self(Arc::new(EquationOfState::new(ideal_gas, residual)))
}

Expand Down Expand Up @@ -136,7 +136,7 @@ impl PyEquationOfState {
parameters.0,
options,
)));
let ideal_gas = Arc::new(IdealGasModel::NoModel);
let ideal_gas = Arc::new(IdealGasModel::NoModel(residual.components()));
Self(Arc::new(EquationOfState::new(ideal_gas, residual)))
}

Expand Down Expand Up @@ -200,7 +200,7 @@ impl PyEquationOfState {
parameters.0,
options,
)));
let ideal_gas = Arc::new(IdealGasModel::NoModel);
let ideal_gas = Arc::new(IdealGasModel::NoModel(residual.components()));
Self(Arc::new(EquationOfState::new(ideal_gas, residual)))
}

Expand Down Expand Up @@ -243,9 +243,9 @@ impl PyEquationOfState {
let residual = Arc::new(ResidualModel::UVTheory(UVTheory::with_options(
parameters.0,
options,
)));
let ideal_gas = Arc::new(IdealGasModel::NoModel);
Self(Arc::new(EquationOfState::new(ideal_gas, residual)))
)?));
let ideal_gas = Arc::new(IdealGasModel::NoModel(residual.components()));
Ok(Self(Arc::new(EquationOfState::new(ideal_gas, residual))))
}

/// SAFT-VRQ Mie equation of state.
Expand Down Expand Up @@ -288,7 +288,7 @@ impl PyEquationOfState {
parameters.0,
options,
)));
let ideal_gas = Arc::new(IdealGasModel::NoModel);
let ideal_gas = Arc::new(IdealGasModel::NoModel(residual.components()));
Self(Arc::new(EquationOfState::new(ideal_gas, residual)))
}

Expand Down Expand Up @@ -320,7 +320,7 @@ impl PyEquationOfState {
/// -------
/// EquationOfState
fn joback(&self, parameters: Vec<PyJobackRecord>) -> Self {
let records = Arc::new(parameters.iter().map(|p| p.0.clone()).collect());
let records = parameters.iter().map(|p| p.0.clone()).collect();
let ideal_gas = Arc::new(IdealGasModel::Joback(Joback::new(records)));
Self(Arc::new(EquationOfState::new(ideal_gas, self.0.residual.clone())))
}
Expand All @@ -331,7 +331,7 @@ impl_virial_coefficients!(PyEquationOfState);
impl_state!(EquationOfState<IdealGasModel, ResidualModel>, PyEquationOfState);
impl_state_molarweight!(EquationOfState<IdealGasModel, ResidualModel>, PyEquationOfState);
impl_state_entropy_scaling!(EquationOfState<IdealGasModel, ResidualModel>, PyEquationOfState);
// impl_phase_equilibrium!(IdealGasModel, ResidualModel, PyEquationOfState);
impl_phase_equilibrium!(EquationOfState<IdealGasModel, ResidualModel>, PyEquationOfState);

#[cfg(feature = "estimator")]
impl_estimator!(EquationOfState<IdealGasModel, ResidualModel>, PyEquationOfState);
Expand Down
1 change: 0 additions & 1 deletion src/python/ideal_gas.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use feos_core::python::joback::PyJobackRecord;
use feos_core::python::parameter::*;
use pyo3::prelude::*;

#[pymodule]
Expand Down
Loading