Skip to content

Commit

Permalink
Migrate FeOs to new quantity crate (#257)
Browse files Browse the repository at this point in the history
  • Loading branch information
prehner authored Oct 28, 2024
1 parent 124098c commit a167f8f
Show file tree
Hide file tree
Showing 121 changed files with 1,086 additions and 2,414 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,19 @@ jobs:
path: dist
windows:
runs-on: windows-latest
strategy:
matrix:
target: [x64, x86]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.9
architecture: ${{ matrix.target }}
architecture: x64
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
target: x64
args: --release --out dist
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.target }}
name: wheel-windows-x86_64
path: dist
45 changes: 35 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
[package]
name = "feos"
version = "0.7.0"
authors = ["Gernot Bauer <bauer@itt.uni-stuttgart.de>", "Philipp Rehner <prehner@ethz.ch>"]
authors = [
"Gernot Bauer <bauer@itt.uni-stuttgart.de>",
"Philipp Rehner <prehner@ethz.ch>",
]
edition = "2021"
readme = "README.md"
license = "MIT OR Apache-2.0"
description = "FeOs - A framework for equations of state and classical density functional theory."
homepage = "https://github.com/feos-org"
repository = "https://github.com/feos-org/feos"
keywords = ["physics", "thermodynamics", "equations_of_state", "phase_equilibria"]
keywords = [
"physics",
"thermodynamics",
"equations_of_state",
"phase_equilibria",
]
categories = ["science"]

[package.metadata.docs.rs]
features = ["all_models", "rayon"]
rustdoc-args = [ "--html-in-header", "./docs-header.html" ]
rustdoc-args = ["--html-in-header", "./docs-header.html"]

[workspace]
members = ["feos-core", "feos-dft", "feos-derive"]
Expand All @@ -22,13 +30,13 @@ members = ["feos-core", "feos-dft", "feos-derive"]
crate-type = ["rlib", "cdylib"]

[dependencies]
quantity = { version = "0.8", optional = true }
num-dual = "0.9"
quantity = "0.9"
num-dual = "0.10"
feos-core = { version = "0.7", path = "feos-core" }
feos-dft = { version = "0.7", path = "feos-dft", optional = true }
feos-derive = { version = "0.5", path = "feos-derive" }
numpy = { version = "0.21", optional = true }
ndarray = { version = "0.15", features = ["approx"] }
numpy = { version = "0.22", optional = true }
ndarray = { version = "0.16", features = ["approx"] }
petgraph = { version = "0.6", optional = true }
thiserror = "1.0"
conv = "0.3"
Expand All @@ -42,7 +50,7 @@ itertools = "0.13"
typenum = "1.16"

[dependencies.pyo3]
version = "0.21"
version = "0.22"
features = ["extension-module", "abi3", "abi3-py37"]
optional = true

Expand Down Expand Up @@ -74,8 +82,25 @@ pets = []
saftvrqmie = []
saftvrmie = []
rayon = ["dep:rayon", "ndarray/rayon", "feos-core/rayon", "feos-dft?/rayon"]
python = ["pyo3", "numpy", "quantity/python", "feos-core/python", "feos-dft?/python", "rayon"]
all_models = ["dft", "estimator", "pcsaft", "epcsaft", "gc_pcsaft", "uvtheory", "pets", "saftvrqmie", "saftvrmie"]
python = [
"pyo3",
"numpy",
"quantity/python_numpy",
"feos-core/python",
"feos-dft?/python",
"rayon",
]
all_models = [
"dft",
"estimator",
"pcsaft",
"epcsaft",
"gc_pcsaft",
"uvtheory",
"pets",
"saftvrqmie",
"saftvrmie",
]

[[bench]]
name = "state_properties"
Expand Down
2 changes: 1 addition & 1 deletion benches/contributions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use criterion::{criterion_group, criterion_main, Criterion};
use feos::pcsaft::{PcSaft, PcSaftParameters};
use feos_core::parameter::{IdentifierOption, Parameter};
use feos_core::si::*;
use quantity::*;
use feos_core::{DensityInitialization, Derivative, Residual, State};
use ndarray::arr1;
use std::sync::Arc;
Expand Down
2 changes: 1 addition & 1 deletion benches/dft_pore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ use feos::gc_pcsaft::{GcPcSaftFunctional, GcPcSaftFunctionalParameters};
use feos::hard_sphere::{FMTFunctional, FMTVersion};
use feos::pcsaft::{PcSaftFunctional, PcSaftParameters};
use feos_core::parameter::{IdentifierOption, Parameter, ParameterHetero};
use feos_core::si::{ANGSTROM, KELVIN, NAV};
use feos_core::{PhaseEquilibrium, State, StateBuilder};
use feos_dft::adsorption::{ExternalPotential, Pore1D, PoreSpecification};
use feos_dft::{DFTSolver, Geometry};
use ndarray::arr1;
use quantity::{ANGSTROM, KELVIN, NAV};
use std::sync::Arc;
use typenum::P3;

Expand Down
2 changes: 1 addition & 1 deletion benches/dual_numbers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! creation.
use criterion::{criterion_group, criterion_main, Criterion};
use feos::pcsaft::{PcSaft, PcSaftParameters};
use feos_core::si::*;
use quantity::*;
use feos_core::{
parameter::{IdentifierOption, Parameter},
Derivative, Residual, State, StateHD,
Expand Down
2 changes: 1 addition & 1 deletion benches/dual_numbers_saftvrmie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
use criterion::{criterion_group, criterion_main, Criterion};
use feos::hard_sphere::HardSphereProperties;
use feos::saftvrmie::{test_utils::test_parameters, SaftVRMie, SaftVRMieParameters};
use feos_core::si::*;
use feos_core::{Derivative, Residual, State, StateHD};
use ndarray::{Array, ScalarOperand};
use num_dual::DualNum;
use quantity::*;
use std::sync::Arc;

/// Helper function to create a state for given parameters.
Expand Down
2 changes: 1 addition & 1 deletion benches/state_creation.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![allow(clippy::type_complexity)]
use criterion::{criterion_group, criterion_main, Criterion};
use feos::pcsaft::{PcSaft, PcSaftParameters};
use feos_core::si::*;
use quantity::*;
use feos_core::{
parameter::{IdentifierOption, Parameter},
Contributions, DensityInitialization, PhaseEquilibrium, Residual, State, TemperatureOrPressure,
Expand Down
2 changes: 1 addition & 1 deletion benches/state_properties.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![allow(clippy::type_complexity)]
use criterion::{criterion_group, criterion_main, Criterion};
use feos::pcsaft::{PcSaft, PcSaftParameters};
use feos_core::si::*;
use quantity::*;
use feos_core::{
parameter::{IdentifierOption, Parameter},
Contributions, Residual, State,
Expand Down
30 changes: 18 additions & 12 deletions feos-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,41 +1,47 @@
[package]
name = "feos-core"
version = "0.7.0"
authors = ["Gernot Bauer <bauer@itt.uni-stuttgart.de>",
"Philipp Rehner <prehner@ethz.ch"]
authors = [
"Gernot Bauer <bauer@itt.uni-stuttgart.de>",
"Philipp Rehner <prehner@ethz.ch",
]
edition = "2021"
rust-version = "1.80"
license = "MIT OR Apache-2.0"
description = "Core traits and functionalities for the `feos` project."
homepage = "https://github.com/feos-org"
readme = "README.md"
repository = "https://github.com/feos-org/feos"
keywords = ["physics", "thermodynamics", "equations_of_state", "phase_equilibria"]
keywords = [
"physics",
"thermodynamics",
"equations_of_state",
"phase_equilibria",
]
categories = ["science"]
workspace = ".."

[package.metadata.docs.rs]
rustdoc-args = [ "--html-in-header", "./docs-header.html" ]
features = [ "rayon" ]
rustdoc-args = ["--html-in-header", "./docs-header.html"]
features = ["rayon"]

[dependencies]
quantity = { version = "0.8", optional = true }
num-dual = { version = "0.9", features = ["linalg"] }
ndarray = { version = "0.15", features = ["serde", "approx-0_5"] }
nalgebra = "0.32"
quantity = { version = "0.9", features = ["approx", "ndarray"] }
num-dual = { version = "0.10", features = ["linalg"] }
ndarray = { version = "0.16", features = ["serde", "approx"] }
nalgebra = "0.33"
num-traits = "0.2"
thiserror = "1.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
indexmap = "2.0"
conv = "0.3"
numpy = { version = "0.21", optional = true }
pyo3 = { version = "0.21", optional = true }
numpy = { version = "0.22", optional = true }
pyo3 = { version = "0.22", features = ["multiple-pymethods"], optional = true }
rayon = { version = "1.5", optional = true }
typenum = "1.16"
approx = "0.5"
regex = "1.9"
ang = "0.6"

[features]
default = []
Expand Down
4 changes: 2 additions & 2 deletions feos-core/src/cubic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
//! [this wikipedia article](https://en.wikipedia.org/wiki/Cubic_equations_of_state#Peng%E2%80%93Robinson_equation_of_state).
use crate::equation_of_state::{Components, Residual};
use crate::parameter::{Identifier, Parameter, ParameterError, PureRecord};
use crate::si::{MolarWeight, GRAM, MOL};
use crate::state::StateHD;
use ndarray::{Array1, Array2, ScalarOperand};
use num_dual::DualNum;
use quantity::{MolarWeight, GRAM, MOL};
use serde::{Deserialize, Serialize};
use std::f64::consts::SQRT_2;
use std::fmt;
Expand Down Expand Up @@ -223,10 +223,10 @@ impl Residual for PengRobinson {
#[cfg(test)]
mod tests {
use super::*;
use crate::si::{KELVIN, PASCAL};
use crate::state::{Contributions, State};
use crate::{EosResult, SolverOptions, Verbosity};
use approx::*;
use quantity::{KELVIN, PASCAL};
use std::sync::Arc;

fn pure_record_vec() -> Vec<PureRecord<PengRobinsonRecord>> {
Expand Down
3 changes: 2 additions & 1 deletion feos-core/src/density_iteration.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use crate::equation_of_state::Residual;
use crate::errors::{EosError, EosResult};
use crate::si::{Density, Moles, Pressure, Temperature};
use crate::state::State;
use crate::ReferenceSystem;
use ndarray::Array1;
use quantity::{Density, Moles, Pressure, Temperature};
use std::sync::Arc;

pub fn density_iteration<E: Residual>(
Expand Down
8 changes: 4 additions & 4 deletions feos-core/src/equation_of_state/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::{
si::{Diffusivity, MolarWeight, Moles, Temperature, ThermalConductivity, Viscosity, Volume},
EosResult,
};
use crate::EosResult;
use ndarray::{Array1, ScalarOperand};
use quantity::{
Diffusivity, MolarWeight, Moles, Temperature, ThermalConductivity, Viscosity, Volume,
};
use std::sync::Arc;

mod ideal_gas;
Expand Down
8 changes: 4 additions & 4 deletions feos-core/src/equation_of_state/residual.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use super::Components;
use crate::si::*;
use crate::StateHD;
use crate::{EosError, EosResult};
use crate::{EosError, EosResult, ReferenceSystem, StateHD};
use ndarray::prelude::*;
use ndarray::ScalarOperand;
use num_dual::*;
use num_traits::{One, Zero};
use quantity::*;
use std::ops::Div;
use typenum::Quot;

/// A reisdual Helmholtz energy model.
pub trait Residual: Components + Send + Sync {
Expand Down Expand Up @@ -75,7 +75,7 @@ pub trait Residual: Components + Send + Sync {
&self,
temperature: Temperature,
moles: Option<&Moles<Array1<f64>>>,
) -> EosResult<<f64 as Div<Density>>::Output> {
) -> EosResult<Quot<f64, Density>> {
let mr = self.validate_moles(moles)?;
let x = (&mr / mr.sum()).into_value();
let mut rho = HyperDual64::zero();
Expand Down
Loading

0 comments on commit a167f8f

Please sign in to comment.