Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
70c3e74
Merge feos-ad functionalities into feos
prehner Aug 18, 2025
81b045e
rebase
prehner Aug 18, 2025
9ab473a
use first_derivative from quantity for virial coefficients
prehner Aug 18, 2025
3be6e39
Minor optimizations for the ideal gas models
prehner Aug 18, 2025
afaced3
Fix robustness issue in vle_pure_t and revive Estimator interface wit…
prehner Aug 18, 2025
58a038f
fix import
prehner Aug 18, 2025
f0fb586
fix Cargo.toml
prehner Aug 19, 2025
8e9757a
moved GcPcSaftAD and therefore concluded the feos-ad integration
prehner Aug 19, 2025
25c789e
update workflow
prehner Aug 19, 2025
81fc7f8
fix python for gc_pcsaft
prehner Aug 19, 2025
6640601
fixed for gc-pcsaft
prehner Aug 25, 2025
982f421
newest lints
prehner Aug 25, 2025
ba7d6ec
use derivatives with units for state properties
prehner Aug 25, 2025
6112b2a
remove nshare dependency
prehner Aug 25, 2025
3dd4d15
fix dft for PC-SAFT
prehner Aug 29, 2025
71eb3ac
Updated SAFT-VR Mie model
g-bauer Aug 27, 2025
15ff86e
Updated PeTS
g-bauer Aug 27, 2025
23b9348
fix test
prehner Aug 29, 2025
2826fa4
finalized adaption of PC-SAFT family
prehner Aug 30, 2025
24aeafe
update to pyo3 0.26
prehner Aug 30, 2025
9cfafbc
python bindings for the libraries that are already updated
prehner Aug 30, 2025
f80b34e
make ndarray optional (a bit of a mess in the polar terms though :/)
prehner Sep 3, 2025
38147a9
fix dft
prehner Sep 3, 2025
79c76d9
fix sign in hc term
prehner Sep 3, 2025
5d9dc3d
implement AD for all state constructors
prehner Sep 3, 2025
5664a09
updated saftvrqmie and UV
prehner Sep 4, 2025
c2fca34
bikeshedding for the IdealGas traits
prehner Sep 5, 2025
424b778
more ideal gas bikeshedding
prehner Sep 5, 2025
687212a
final(?) ideal gas bikeshed
prehner Sep 5, 2025
4738d5c
fixed stability_analysis
prehner Sep 9, 2025
b6dcf3f
fix markdown and String representations of states
prehner Sep 9, 2025
043875b
fix some regression in the parameter handling in python
prehner Sep 9, 2025
e182cc9
add getters for Identifier
prehner Sep 9, 2025
3d631bc
remove some string allocations
prehner Sep 9, 2025
987bd7f
rebase
prehner Sep 12, 2025
01e98ab
pretty significant bug, no idea why it did not show earlier
prehner Sep 12, 2025
0277e02
fixes for num_dual change
prehner Sep 17, 2025
e575ae6
Fix bubble Newton step for bubble points at given pressure
prehner Sep 17, 2025
b03222a
Add tests for newton methods within bubble and dew point iterations
prehner Sep 17, 2025
f6be6aa
reactivate (and fix) PC-SAFT tests
prehner Sep 17, 2025
d352ed7
update num-dual and quantity dependencies
prehner Sep 28, 2025
bb8f5e5
get rid of most Arcs
prehner Sep 28, 2025
935b651
remove the ResidualConst trait
prehner Sep 29, 2025
6472647
replace PureProperty and BinaryProperty with new Estimator struct
prehner Sep 29, 2025
d51c8d9
rebase
prehner Oct 10, 2025
898c917
adding final docstrings to feos-core
prehner Oct 10, 2025
ba952f5
removed stuff that accidentally ended up here
prehner Oct 10, 2025
3ed1307
make python package usable without the "ad" feature
prehner Oct 10, 2025
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
adding final docstrings to feos-core
  • Loading branch information
prehner committed Oct 10, 2025
commit 898c9177a54d10da559d895709eb753628a31542
1 change: 1 addition & 0 deletions crates/feos-core/src/equation_of_state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ pub trait IdealGas<D = f64> {
fn ideal_gas_model(&self) -> &'static str;
}

/// A total Helmholtz energy model consisting of a [Residual] model and an [IdealGas] part.
pub trait Total<N: Dim = Dyn, D: DualNum<f64> + Copy = f64>: Residual<N, D>
where
DefaultAllocator: Allocator<N>,
Expand Down
1 change: 1 addition & 0 deletions crates/feos-core/src/equation_of_state/residual.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ where
}
}

/// A model from which models for subsets of its components can be extracted.
pub trait Subset {
/// Return a model consisting of the components
/// contained in component_list.
Expand Down
3 changes: 2 additions & 1 deletion crates/feos-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub use equation_of_state::{
EquationOfState, IdealGas, Molarweight, NoResidual, Residual, ResidualDyn, Subset, Total,
};
pub use errors::{FeosError, FeosResult};
pub use parameter_fit::{Estimator, ParametersAD};
pub use parameter_fit::{ParameterFit, ParametersAD};
#[cfg(feature = "ndarray")]
pub use phase_equilibria::{PhaseDiagram, PhaseDiagramHetero};
pub use phase_equilibria::{PhaseEquilibrium, TemperatureOrPressure};
Expand Down Expand Up @@ -133,6 +133,7 @@ const fn powi(x: f64, n: i32) -> f64 {
}
}

/// Conversion between reduced units and SI units.
pub trait ReferenceSystem {
type Inner;
type T: Integer;
Expand Down
2 changes: 1 addition & 1 deletion crates/feos-core/src/parameter_fit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use nalgebra::{Const, U1};
use num_dual::{Derivative, DualSVec};

mod properties;
pub use properties::Estimator;
pub use properties::ParameterFit;

use crate::Residual;

Expand Down
6 changes: 4 additions & 2 deletions crates/feos-core/src/parameter_fit/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ use quantity::{Density, Pressure, Temperature};
#[cfg(feature = "rayon")]
use quantity::{KELVIN, KILO, METER, MOL, PASCAL};

pub struct Estimator;
/// A collection of functions that calculate fit properties and their derivatives
/// with respect to model parameters.
pub struct ParameterFit;

impl Estimator {
impl ParameterFit {
pub fn vapor_pressure<E: Residual<U1, Gradient<P>>, const P: usize>(
eos: &E,
temperature: Temperature,
Expand Down
14 changes: 7 additions & 7 deletions crates/feos/src/pcsaft/eos/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ mod tests_parameter_fit {
use approx::assert_relative_eq;
use feos_core::DensityInitialization::Liquid;
use feos_core::{Contributions, ReferenceSystem};
use feos_core::{Estimator, FeosResult, ParametersAD, PhaseEquilibrium, State};
use feos_core::{FeosResult, ParameterFit, ParametersAD, PhaseEquilibrium, State};
use nalgebra::{U1, U3, U8, vector};
use num_dual::{DualStruct, DualVec};
use quantity::{BAR, KELVIN, LITER, MOL, PASCAL};
Expand Down Expand Up @@ -683,7 +683,7 @@ mod tests_parameter_fit {
let (pcsaft, _) = pcsaft()?;
let pcsaft_ad = PcSaftPure::<_, 8>::from_parameter_slice(&pcsaft.0, pcsaft_params);
let temperature = 250.0 * KELVIN;
let p = Estimator::vapor_pressure(&pcsaft_ad, temperature)?;
let p = ParameterFit::vapor_pressure(&pcsaft_ad, temperature)?;
let p = p.convert_into(PASCAL);
let (p, grad) = (p.re, p.eps.unwrap_generic(U8, U1));

Expand Down Expand Up @@ -716,7 +716,7 @@ mod tests_parameter_fit {
let pcsaft_ad =
PcSaftPure::<_, 4>::from_parameter_slice(&pcsaft.0, ["m", "sigma", "epsilon_k"]);
let temperature = 150.0 * KELVIN;
let p = Estimator::vapor_pressure(&pcsaft_ad, temperature)?;
let p = ParameterFit::vapor_pressure(&pcsaft_ad, temperature)?;
let p = p.convert_into(PASCAL);
let (p, grad) = (p.re, p.eps.unwrap_generic(U3, U1));

Expand Down Expand Up @@ -749,7 +749,7 @@ mod tests_parameter_fit {
let pcsaft_ad =
PcSaftPure::<_, 4>::from_parameter_slice(&pcsaft.0, ["m", "sigma", "epsilon_k"]);
let temperature = 150.0 * KELVIN;
let (p, rho) = Estimator::equilibrium_liquid_density(&pcsaft_ad, temperature)?;
let (p, rho) = ParameterFit::equilibrium_liquid_density(&pcsaft_ad, temperature)?;
let p = p.convert_into(PASCAL);
let rho = rho.convert_into(MOL / LITER);
let (p, p_grad) = (p.re, p.eps.unwrap_generic(U3, U1));
Expand Down Expand Up @@ -791,7 +791,7 @@ mod tests_parameter_fit {
PcSaftPure::<_, 4>::from_parameter_slice(&pcsaft.0, ["m", "sigma", "epsilon_k"]);
let temperature = 150.0 * KELVIN;
let pressure = BAR;
let rho = Estimator::liquid_density(&pcsaft_ad, temperature, pressure)?;
let rho = ParameterFit::liquid_density(&pcsaft_ad, temperature, pressure)?;
let rho = rho.convert_into(MOL / LITER);
let (rho, grad) = (rho.re, rho.eps.unwrap_generic(U3, U1));

Expand Down Expand Up @@ -830,7 +830,7 @@ mod tests_parameter_fit {
let pcsaft_ad = pcsaft.named_derivatives(["k_ij"]);
let temperature = 500.0 * KELVIN;
let x = vector![0.5, 0.5];
let p = Estimator::bubble_point_pressure(&pcsaft_ad, temperature, None, x)?;
let p = ParameterFit::bubble_point_pressure(&pcsaft_ad, temperature, None, x)?;
let p = p.convert_into(BAR);
let (p, [[grad]]) = (p.re, p.eps.unwrap_generic(U1, U1).data.0);

Expand Down Expand Up @@ -868,7 +868,7 @@ mod tests_parameter_fit {
let pcsaft_ad: PcSaftBinary<_, 8> = PcSaftBinary::named_derivatives(&pcsaft, ["k_ij"]);
let temperature = 500.0 * KELVIN;
let y = vector![0.5, 0.5];
let p = Estimator::dew_point_pressure(&pcsaft_ad, temperature, None, y)?;
let p = ParameterFit::dew_point_pressure(&pcsaft_ad, temperature, None, y)?;
let p = p.convert_into(BAR);
let (p, [[grad]]) = (p.re, p.eps.unwrap_generic(U1, U1).data.0);

Expand Down
2 changes: 1 addition & 1 deletion py-feos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ feos-derive = { workspace = true }
feos-dft = { workspace = true, optional = true }

[features]
default = ["pcsaft"]
default = []
dft = ["feos/dft", "feos-dft", "petgraph", "rayon"]
pcsaft = ["feos/pcsaft"]
epcsaft = ["feos/epcsaft"]
Expand Down
12 changes: 6 additions & 6 deletions py-feos/src/ad/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#[cfg(feature = "pcsaft")]
use feos::pcsaft::{PcSaftBinary, PcSaftPure};
use feos_core::{Estimator, ParametersAD};
use feos_core::{ParameterFit, ParametersAD};
use numpy::{PyArray1, PyArray2, PyReadonlyArray2, ToPyArray};
use paste::paste;
use pyo3::prelude::*;
Expand All @@ -26,8 +26,8 @@ impl From<PyModel> for BinaryModels {
}
}

#[pyclass(name = "Estimator")]
pub struct PyEstimator;
#[pyclass(name = "ParameterFit")]
pub struct PyParameterFit;

type GradResult<'py> = (
Bound<'py, PyArray1<f64>>,
Expand All @@ -38,7 +38,7 @@ type GradResult<'py> = (
macro_rules! expand_models {
($enum:ty, $prop:ident, $($model:ident: $type:ty),*) => {
#[pymethods]
impl PyEstimator {
impl PyParameterFit {
#[staticmethod]
fn $prop<'py>(
model: PyModel,
Expand Down Expand Up @@ -79,9 +79,9 @@ macro_rules! impl_evaluate_gradients {
let (value, grad, status) =
$(
if let Ok(p) = parameter_names.extract::<[String; $p]>() {
Estimator::[<$prop _parallel>]::<R, $p>(p, parameters.as_array(), input.as_array())
ParameterFit::[<$prop _parallel>]::<R, $p>(p, parameters.as_array(), input.as_array())
} else)* if let Ok(p) = parameter_names.extract::<[String; $max]>() {
Estimator::[<$prop _parallel>]::<R, $max>(p, parameters.as_array(), input.as_array())
ParameterFit::[<$prop _parallel>]::<R, $max>(p, parameters.as_array(), input.as_array())
} else {
panic!("Gradients can only be evaluated for up to {} parameters!", $max)
};
Expand Down
2 changes: 1 addition & 1 deletion py-feos/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ fn feos(m: &Bound<'_, PyModule>) -> PyResult<()> {
// AD
#[cfg(feature = "ad")]
{
m.add_class::<ad::PyEstimator>()?;
m.add_class::<ad::PyParameterFit>()?;
m.add_class::<ad::PyModel>()?;
}

Expand Down