Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Packaging
- Updated `quantity` dependency to 0.13 and removed the `typenum` dependency. [#328](https://github.com/feos-org/feos/pull/328)
- Added `csv` as a `feos-core` dependency for the new dataset module. [#358](https://github.com/feos-org/feos/pull/358)
- Updated `pyo3`, `pythonize` and `numpy` dependencies to 0.29. [#360](https://github.com/feos-org/feos/pull/360)
- Updated `quantity` and `num-dual` dependencies to 0.14. [#360](https://github.com/feos-org/feos/pull/360)
- Updated `nalgebra` dependency to 0.35. [#360](https://github.com/feos-org/feos/pull/360)
- Updated `gauss-quad` dependency to 0.3. [#360](https://github.com/feos-org/feos/pull/360)

## [Unreleased]
### Added
Expand Down
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ keywords = [
categories = ["science"]

[workspace.dependencies]
quantity = "0.13"
num-dual = "0.13"
quantity = "0.14"
num-dual = "0.14"
ndarray = "0.17"
nalgebra = "0.34"
nalgebra = "0.35"
thiserror = "2.0"
conv = "0.3"
num-traits = "0.2"
Expand All @@ -38,7 +38,7 @@ petgraph = "0.8"
rustdct = "0.7"
rustfft = "6.0"
libm = "0.2"
gauss-quad = "0.2"
gauss-quad = "0.3"
approx = "0.5"
criterion = "0.8"
paste = "1.0"
Expand Down
11 changes: 8 additions & 3 deletions crates/feos-dft/src/adsorption/fea_potential.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use super::pore3d::{calculate_distance2, evaluate_lj_potential};
use crate::profile::{CUTOFF_RADIUS, MAX_POTENTIAL};
use crate::Geometry;
use crate::profile::{CUTOFF_RADIUS, MAX_POTENTIAL};
use feos_core::ReferenceSystem;
use gauss_quad::GaussLegendre;
use ndarray::{Array1, Array2, Zip};
use quantity::Length;
use std::f64::consts::PI;
use std::num::NonZero;

// Calculate free-energy average potential for given solid structure.
#[expect(clippy::too_many_arguments)]
Expand Down Expand Up @@ -55,7 +56,9 @@ pub fn calculate_fea_potential(
}
Geometry::Spherical | Geometry::Cylindrical => {
let (unscaled_nodes, unscaled_weights) =
GaussLegendre::new(n_grid[0]).unwrap().into_iter().unzip();
GaussLegendre::new(NonZero::new(n_grid[0]).unwrap())
.into_iter()
.unzip();

let nodes = PI + Array1::from_vec(unscaled_nodes) * PI;
let weights = Array1::from_vec(unscaled_weights) * PI;
Expand All @@ -80,7 +83,9 @@ pub fn calculate_fea_potential(
}
Geometry::Spherical => {
let (unscaled_nodes, unscaled_weights) =
GaussLegendre::new(n_grid[1]).unwrap().into_iter().unzip();
GaussLegendre::new(NonZero::new(n_grid[1]).unwrap())
.into_iter()
.unzip();

let nodes = PI / 2.0 + Array1::from_vec(unscaled_nodes) * PI / 2.0;
let weights = Array1::from_vec(unscaled_weights) * PI / 2.0
Expand Down
6 changes: 3 additions & 3 deletions py-feos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ name = "feos"
crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = "0.27", features = [
pyo3 = { version = "0.29", features = [
"multiple-pymethods",
"indexmap"
] }
pythonize = "0.27"
numpy = { version = "0.27" }
pythonize = "0.29"
numpy = { version = "0.29" }

quantity = { workspace = true, features = ["python", "python_numpy"] }
num-dual = { workspace = true, features = ["python_macro"] }
Expand Down
2 changes: 1 addition & 1 deletion py-feos/src/ad/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use pyo3::prelude::*;
pub mod dataset;
pub use dataset::{PyBinaryDataset, PyPureDataset};

#[pyclass(name = "EquationOfStateAD", eq, eq_int)]
#[pyclass(name = "EquationOfStateAD", eq, eq_int, from_py_object)]
#[derive(Clone, Copy, PartialEq)]
pub enum PyEquationOfStateAD {
PcSaftNonAssoc,
Expand Down
4 changes: 2 additions & 2 deletions py-feos/src/dft/adsorption/external_potential.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use feos_dft::adsorption::ExternalPotential;
use ndarray::Array2;
use numpy::prelude::*;
use numpy::PyArray1;
use numpy::prelude::*;
use pyo3::prelude::*;
use quantity::Length;

/// A collection of external potentials.
#[pyclass(name = "ExternalPotential")]
#[pyclass(name = "ExternalPotential", from_py_object)]
#[derive(Clone)]
pub struct PyExternalPotential(pub ExternalPotential);

Expand Down
8 changes: 4 additions & 4 deletions py-feos/src/dft/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::eos::{parse_molefracs, PyEquationOfState};
use crate::eos::{PyEquationOfState, parse_molefracs};
use crate::ideal_gas::IdealGasModel;
use crate::residual::ResidualModel;
use feos::hard_sphere::{FMTFunctional, FMTVersion};
Expand All @@ -24,7 +24,7 @@ pub(crate) use solver::{PyDFTSolver, PyDFTSolverLog};

/// Geometries of individual axes.
#[derive(Clone, Copy, PartialEq)]
#[pyclass(name = "Geometry", eq, eq_int)]
#[pyclass(name = "Geometry", eq, eq_int, from_py_object)]
pub enum PyGeometry {
Cartesian,
Cylindrical,
Expand Down Expand Up @@ -53,7 +53,7 @@ impl From<PyGeometry> for Geometry {

/// Different versions of fundamental measure theory.
#[derive(Clone, Copy, PartialEq)]
#[pyclass(name = "FMTVersion", eq, eq_int)]
#[pyclass(name = "FMTVersion", eq, eq_int, from_py_object)]
pub enum PyFMTVersion {
/// White Bear ([Roth et al., 2002](https://doi.org/10.1088/0953-8984/14/46/313)) or modified ([Yu and Wu, 2002](https://doi.org/10.1063/1.1520530)) fundamental measure theory
WhiteBear,
Expand Down Expand Up @@ -84,7 +84,7 @@ impl From<PyFMTVersion> for FMTVersion {
}

/// Collection of Helmholtz energy functionals.
#[pyclass(name = "HelmholtzEnergyFunctional")]
#[pyclass(name = "HelmholtzEnergyFunctional", from_py_object)]
#[derive(Clone)]
pub struct PyHelmholtzEnergyFunctional;

Expand Down
4 changes: 2 additions & 2 deletions py-feos/src/dft/solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use quantity::Time;
/// Returns
/// -------
/// DFTSolver
#[pyclass(name = "DFTSolver")]
#[pyclass(name = "DFTSolver", from_py_object)]
#[derive(Clone)]
pub struct PyDFTSolver(pub DFTSolver);

Expand Down Expand Up @@ -160,7 +160,7 @@ impl PyDFTSolver {
}
}

#[pyclass(name = "DFTSolverLog")]
#[pyclass(name = "DFTSolverLog", from_py_object)]
#[derive(Clone)]
pub struct PyDFTSolverLog(pub DFTSolverLog);

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 @@ -19,7 +19,7 @@ pub(crate) mod user_defined;

/// Output level for phase equilibrium solvers.
#[derive(Debug, Clone, Copy, PartialEq)]
#[pyclass(name = "Verbosity", eq, eq_int)]
#[pyclass(name = "Verbosity", eq, eq_int, from_py_object)]
pub(crate) enum PyVerbosity {
/// Do not print output.
None,
Expand Down
4 changes: 2 additions & 2 deletions py-feos/src/parameter/chemical_record.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::fragmentation::{fragment_molecule, PySmartsRecord};
use super::fragmentation::{PySmartsRecord, fragment_molecule};
use super::identifier::{PyIdentifier, PyIdentifierOption};
use crate::error::PyFeosError;
use feos_core::parameter::{ChemicalRecord, Identifier};
Expand All @@ -7,7 +7,7 @@ use pyo3::prelude::*;
use serde::{Deserialize, Serialize};

/// Information about segments and bonds of a molecule.
#[pyclass(name = "ChemicalRecord")]
#[pyclass(name = "ChemicalRecord", from_py_object)]
#[derive(Deserialize, Serialize, Debug, Clone)]
pub(crate) struct PyChemicalRecord(ChemicalRecord);

Expand Down
2 changes: 1 addition & 1 deletion py-feos/src/parameter/fragmentation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::error::PyFeosError;

/// SMARTS code, required to fragmentize molecules into segments.
#[derive(Clone, Serialize, Deserialize)]
#[pyclass(name = "SmartsRecord")]
#[pyclass(name = "SmartsRecord", from_py_object)]
pub(crate) struct PySmartsRecord {
group: String,
smarts: String,
Expand Down
4 changes: 2 additions & 2 deletions py-feos/src/parameter/identifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use pyo3::prelude::*;
use serde::{Deserialize, Serialize};

/// Identifier to match on while reading parameters from files.
#[pyclass(name = "IdentifierOption", eq, eq_int)]
#[pyclass(name = "IdentifierOption", eq, eq_int, from_py_object)]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq)]
pub enum PyIdentifierOption {
Cas,
Expand Down Expand Up @@ -43,7 +43,7 @@ impl From<PyIdentifierOption> for IdentifierOption {
}

/// Different common identifiers for chemicals.
#[pyclass(name = "Identifier")]
#[pyclass(name = "Identifier", from_py_object)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PyIdentifier(pub Identifier);

Expand Down
4 changes: 2 additions & 2 deletions py-feos/src/parameter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub(crate) use model_record::{PyBinaryRecord, PyPureRecord};
pub(crate) use segment::{PyBinarySegmentRecord, PySegmentRecord};

/// Set of parameters that fully characterizes a mixture.
#[pyclass(name = "Parameters")]
#[pyclass(name = "Parameters", from_py_object)]
#[derive(Clone, Serialize, Deserialize)]
pub struct PyParameters {
pub pure_records: Vec<PureRecord<Value, Value>>,
Expand Down Expand Up @@ -521,7 +521,7 @@ impl PyParameters {

/// Combination of chemical information and segment parameters that is used to
/// parametrize a group-contribution model.
#[pyclass(name = "GcParameters")]
#[pyclass(name = "GcParameters", from_py_object)]
#[derive(Clone, Serialize, Deserialize)]
pub struct PyGcParameters {
chemical_records: Vec<ChemicalRecord>,
Expand Down
4 changes: 2 additions & 2 deletions py-feos/src/parameter/model_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use serde_json::Value;
#[derive(Serialize, Deserialize, Clone)]
#[serde(from = "PureRecord<Value, Value>")]
#[serde(into = "PureRecord<Value, Value>")]
#[pyclass(name = "PureRecord")]
#[pyclass(name = "PureRecord", from_py_object)]
pub struct PyPureRecord {
#[pyo3(get)]
pub identifier: PyIdentifier,
Expand Down Expand Up @@ -128,7 +128,7 @@ impl PyPureRecord {
#[derive(Serialize, Deserialize, Clone)]
#[serde(from = "BinaryRecord<Identifier, Value, Value>")]
#[serde(into = "BinaryRecord<Identifier, Value, Value>")]
#[pyclass(name = "BinaryRecord")]
#[pyclass(name = "BinaryRecord", from_py_object)]
pub struct PyBinaryRecord {
#[pyo3(get)]
pub id1: PyIdentifier,
Expand Down
4 changes: 2 additions & 2 deletions py-feos/src/parameter/segment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use serde_json::Value;
#[derive(Serialize, Deserialize, Clone)]
#[serde(from = "SegmentRecord<Value, Value>")]
#[serde(into = "SegmentRecord<Value, Value>")]
#[pyclass(name = "SegmentRecord")]
#[pyclass(name = "SegmentRecord", from_py_object)]
pub struct PySegmentRecord {
#[pyo3(get)]
identifier: String,
Expand Down Expand Up @@ -113,7 +113,7 @@ impl PySegmentRecord {
#[derive(Serialize, Deserialize, Clone)]
#[serde(from = "BinaryRecord<String, Value, Value>")]
#[serde(into = "BinaryRecord<String, Value, Value>")]
#[pyclass(name = "BinarySegmentRecord")]
#[pyclass(name = "BinarySegmentRecord", from_py_object)]
pub struct PyBinarySegmentRecord {
#[pyo3(get)]
pub id1: String,
Expand Down
4 changes: 2 additions & 2 deletions py-feos/src/phase_equilibria.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use std::ops::Deref;
use std::sync::Arc;

/// A thermodynamic two phase equilibrium state.
#[pyclass(name = "PhaseEquilibrium")]
#[pyclass(name = "PhaseEquilibrium", from_py_object)]
#[derive(Clone)]
pub struct PyPhaseEquilibrium(
pub PhaseEquilibrium<Arc<EquationOfState<Vec<IdealGasModel>, ResidualModel>>, 2>,
Expand Down Expand Up @@ -582,7 +582,7 @@ impl PyPhaseEquilibrium {
}

/// A thermodynamic three phase equilibrium state.
#[pyclass(name = "ThreePhaseEquilibrium")]
#[pyclass(name = "ThreePhaseEquilibrium", from_py_object)]
#[derive(Clone)]
struct PyThreePhaseEquilibrium(
PhaseEquilibrium<Arc<EquationOfState<Vec<IdealGasModel>, ResidualModel>>, 3>,
Expand Down
4 changes: 2 additions & 2 deletions py-feos/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type InvP<T> = Quantity<T, <_Pressure as Neg>::Output>;

/// Possible contributions that can be computed.
#[derive(Clone, Copy, PartialEq)]
#[pyclass(name = "Contributions", eq, eq_int)]
#[pyclass(name = "Contributions", eq, eq_int, from_py_object)]
pub enum PyContributions {
/// Only compute the ideal gas contribution
IdealGas,
Expand Down Expand Up @@ -94,7 +94,7 @@ impl From<PyContributions> for Contributions {
/// ------
/// Error
/// When the state cannot be created using the combination of input.
#[pyclass(name = "State")]
#[pyclass(name = "State", from_py_object)]
#[derive(Clone)]
pub struct PyState(pub State<Arc<EquationOfState<Vec<IdealGasModel>, ResidualModel>>>);

Expand Down
4 changes: 2 additions & 2 deletions py-feos/src/user_defined.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ macro_rules! impl_residual {

macro_rules! state {
($py_state_id:ident, $py_hd_id:ident, $hd_ty:ty) => {
#[pyclass]
#[pyclass(from_py_object)]
#[derive(Clone)]
struct $py_state_id(StateHD<$hd_ty>);

Expand Down Expand Up @@ -233,7 +233,7 @@ macro_rules! state {

macro_rules! dual_number {
($py_hd_id:ident, $hd_ty:ty, $py_field_ty:ty) => {
#[pyclass]
#[pyclass(from_py_object)]
#[derive(Clone)]
struct $py_hd_id($hd_ty);
impl_dual_num!($py_hd_id, $hd_ty, $py_field_ty);
Expand Down
Loading