diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2775bc39d..5604c51d2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -118,4 +118,4 @@ jobs: steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - - run: cargo publish --token ${{ secrets.CRATES_IO_TOKEN }} + - run: cargo publish --workspace --exclude py_feos --token ${{ secrets.CRATES_IO_TOKEN }} diff --git a/.github/workflows/release_core.yml b/.github/workflows/release_core.yml deleted file mode 100644 index e011d6180..000000000 --- a/.github/workflows/release_core.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Release feos-core - -on: - push: - tags: ["feos-core-v*"] - -jobs: - release-crates-io: - name: Release crates.io - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - uses: katyo/publish-crates@v1 - with: - registry-token: ${{ secrets.CRATES_IO_TOKEN }} - path: './feos-core' diff --git a/.github/workflows/release_derive.yml b/.github/workflows/release_derive.yml deleted file mode 100644 index 34587f27b..000000000 --- a/.github/workflows/release_derive.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Release feos-derive - -on: - push: - tags: ["feos-derive-v*"] - -jobs: - release-crates-io: - name: Release crates.io - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - uses: katyo/publish-crates@v1 - with: - registry-token: ${{ secrets.CRATES_IO_TOKEN }} - path: './feos-derive' diff --git a/.github/workflows/release_dft.yml b/.github/workflows/release_dft.yml deleted file mode 100644 index be02cd4b3..000000000 --- a/.github/workflows/release_dft.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Release feos-dft - -on: - push: - tags: ["feos-dft-v*"] - -jobs: - release-crates-io: - name: Release crates.io - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - uses: katyo/publish-crates@v1 - with: - registry-token: ${{ secrets.CRATES_IO_TOKEN }} - path: './feos-dft' diff --git a/CHANGELOG.md b/CHANGELOG.md index 63dda2f3b..bcac75fe9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.9.0] - 2025-11-08 +### Added +- Integrated the functionalities of [`feos-ad`](https://github.com/feos-org/feos-ad). [#289](https://github.com/feos-org/feos/pull/289) + - In Rust: Full access to arbitrary derivatives of properties and phase equilibria with respect to model parameters. See, e.g., [`feos-campd`](https://github.com/feos-org/feos-campd) for an application to molecular design. + - In Python: Specialized functions for the parallel evaluation of relevant properties (vapor pressure, liquid density, bubble/dew point pressure) including the gradients with respect to model parameters for parameter estimations or the inclusion in backpropagation frameworks. +- Implement pure-component multiparameter equations of state from CoolProp. [#301](https://github.com/feos-org/feos/pull/301) + +### Changed +- :warning: Changed the format of parameter files. The contents of the old `model_record` field are now flattened into the `PureRecord`/`SegmentRecord`. [#233](https://github.com/feos-org/feos/pull/233) +- Generalized the implementation of association to allow for arbitrarily many association sites per molecule or group and full control over each interaction. [#233](https://github.com/feos-org/feos/pull/233) [#290](https://github.com/feos-org/feos/pull/290) +- Reimplemented the Python interface to avoid the necessity of having multiple classes with the same name. + - `feos.eos.State` and `feos.dft.State` (and analogous classes) are combined into `feos.State`. [#274](https://github.com/feos-org/feos/pull/274) + - All `feos..PureRecord` (and similar classes) are combined into `feos.PureRecord`. [#271](https://github.com/feos-org/feos/pull/271) +- All Python classes are exported at the package root. [#309](https://github.com/feos-org/feos/pull/309) +- Add initial density as optional argument to critical point algorithms. [#300](https://github.com/feos-org/feos/pull/300) + +### Packaging +- Updated `quantity` dependency to 0.12. +- Updated `num-dual` dependency to 0.12. +- Updated `numpy`, `PyO3` and `pythonize` dependencies to 0.27. +- Updated `nalgebra` dependency to 0.34. + ## [0.8.0] - 2024-12-28 ### Fixed - Fixed the handling of association records in combination with induced association in PC-SAFT [#264](https://github.com/feos-org/feos/pull/264) diff --git a/Cargo.toml b/Cargo.toml index 5713e11ee..809cf67ff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ members = ["crates/*", "py-feos"] default-members = ["crates/feos"] [workspace.package] -version = "0.8.0" +version = "0.9.0" edition = "2024" authors = [ "Gernot Bauer ", @@ -22,7 +22,7 @@ keywords = [ categories = ["science"] [workspace.dependencies] -quantity = "0.11" +quantity = "0.12" num-dual = "0.12" ndarray = "0.16" nalgebra = "0.34" @@ -44,10 +44,10 @@ approx = "0.5" criterion = "0.7" paste = "1.0" -feos-core = { version = "0.8", path = "crates/feos-core" } -feos-dft = { version = "0.8", path = "crates/feos-dft" } -feos-derive = { version = "0.6", path = "crates/feos-derive" } -feos = { version = "0.8", path = "crates/feos" } +feos-core = { version = "0.9", path = "crates/feos-core" } +feos-dft = { version = "0.9", path = "crates/feos-dft" } +feos-derive = { version = "0.9", path = "crates/feos-derive" } +feos = { version = "0.9", path = "crates/feos" } [profile.release-lto] inherits = "release" diff --git a/README.md b/README.md index b0d228896..4627a2234 100644 --- a/README.md +++ b/README.md @@ -1,33 +1,46 @@ # FeOs - A Framework for Equations of State and Classical Density Functional Theory -[![crate](https://img.shields.io/crates/v/feos.svg)](https://crates.io/crates/feos) -[![documentation](https://docs.rs/feos/badge.svg)](https://docs.rs/feos) -[![documentation](https://img.shields.io/badge/docs-github--pages-blue)](https://feos-org.github.io/feos/) -[![repository](https://img.shields.io/pypi/v/feos)](https://pypi.org/project/feos/) +[![crate](https://img.shields.io/crates/v/feos?logo=rust)](https://crates.io/crates/feos) +[![documentation](https://img.shields.io/docsrs/feos?logo=rust)](https://docs.rs/feos) +[![repository](https://img.shields.io/pypi/v/feos?logo=python)](https://pypi.org/project/feos/) +[![documentation](https://img.shields.io/badge/docs-github--pages-blue?logo=python)](https://feos-org.github.io/feos/) +[![FeOs Publication](https://img.shields.io/badge/DOI-10.1021/acs.iecr.2c04561-passing)](https://pubs.acs.org/doi/10.1021/acs.iecr.2c04561) The `FeOs` package provides Rust implementations of different equation of state and Helmholtz energy functional models and corresponding Python bindings. ```python -from feos.eos import EquationOfState, State -from feos.pcsaft import PcSaftParameters, PcSaftRecord +import feos +import si_units as si # PC-SAFT parameters for methanol (Gross and Sadowski 2002) -record = PcSaftRecord(1.5255, 3.23, 188.9, kappa_ab=0.035176, epsilon_k_ab=2899.5, na=1, nb=1) +record = feos.PureRecord( + feos.Identifier(name="methanol"), + molarweight=32.04, + m=1.5255, + sigma=3.23, + epsilon_k=188.9, + association_sites=[{ + "kappa_ab": 0.035176, + "epsilon_k_ab": 2899.5, + "na": 1, + "nb": 1, + }] +) # Build an equation of state -parameters = PcSaftParameters.from_model_records([record]) -eos = EquationOfState.pcsaft(parameters) +parameters = feos.Parameters.new_pure(record) +eos = feos.EquationOfState.pcsaft(parameters) # Define thermodynamic conditions -critical_point = State.critical_point(eos) +critical_point = feos.State.critical_point(eos) # Compute properties p = critical_point.pressure() t = critical_point.temperature -print(f'Critical point for methanol: T={t}, p={p}.') +print(f"Critical point for methanol: T={t/si.KELVIN:.1f} K, p={p/si.BAR:.1f} bar.") ``` ```terminal -Critical point for methanol: T=531.5 K, p=10.7 MPa. +Critical point for methanol: T=531.5 K, p=106.5 bar. ``` ## Models @@ -55,6 +68,14 @@ Other public repositories that implement models within the `FeOs` framework, but ## Parameters In addition to the source code for the Rust and Python packages, this repository contains JSON files with previously published [parameters](https://github.com/feos-org/feos/tree/main/parameters) for the different models including group contribution methods. The parameter files can be read directly from Rust or Python. +> [!WARNING] +> The format for parameter files changed between releases `0.8.0` and `0.9.0`. You find parameters for new versions in the [parameters](https://github.com/feos-org/feos/tree/main/parameters) directory and for versions up to `0.8.0` in the [parameters_old](https://github.com/feos-org/feos/tree/main/parameters_old) directory.

+If you maintain your own parameter files, there are two adjustments you need to make when upgrading to `feos 0.9.0`: +> - Flatten the contents of the `model_record` field directly into the pure or segment record. +> - Move association parameters into a list called `association_sites`. +> +> The structure of the JSON files and the `PureRecord` and `SegmentRecord` classes in Python is identical. + ## Properties and phase equilibria The crate makes use of [generalized (hyper-) dual numbers](https://github.com/itt-ustutt/num-dual) to generically calculate exact partial derivatives from Helmholtz energy equations of state. The derivatives are used to calculate @@ -107,10 +128,11 @@ See the *Building from source* section for information about building the wheel ### Building from source -To compile the code you need the Rust compiler and `maturin` (>=0.13,<0.14) installed. +To compile the code you need the Rust compiler and `maturin` installed. To install the package directly into the active environment (virtualenv or conda), use ``` +cd py-feos maturin develop --release ``` @@ -119,7 +141,7 @@ which uses the `python` and `all_models` feature as specified in the `pyproject. Alternatively, you can specify the models or features that you want to include in the python package explicitly, e.g. ``` -maturin develop --release --features "python pcsaft dft" +maturin develop --release --features "pcsaft dft" ``` for the PC-SAFT equation of state and Helmholtz energy functional. @@ -134,7 +156,7 @@ which will use the `python` and `all_models` features specified in the `pyprojec Use the following command to build a wheel with specific features: ``` -maturin build --profile="release-lto" --features "python ..." +maturin build --profile="release-lto" --features "pcsaft ..." ``` LTO increases compile times measurably but the resulting wheel is more performant and has a smaller size. @@ -146,7 +168,7 @@ For a documentation of the Python API, Python examples, and a guide to the under ## Benchmarks -Check out the [benches](https://github.com/feos-org/feos/tree/main/feos-benchmarks) directory for information about provided Rust benchmarks and how to run them. +Check out the [benches](https://github.com/feos-org/feos/tree/main/crates/feos/benches) directory for information about provided Rust benchmarks and how to run them. ## Developers diff --git a/crates/feos-core/CHANGELOG.md b/crates/feos-core/CHANGELOG.md index efde60c03..f5c25722f 100644 --- a/crates/feos-core/CHANGELOG.md +++ b/crates/feos-core/CHANGELOG.md @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +> [!IMPORTANT] +> This file contains changes up to `feos-core` v0.8.0. For newer versions, changes are documented for the entire project rather than individual crates [here](../../CHANGELOG.md). + ## Unreleased ## [0.8.0] - 2024-12-28 diff --git a/crates/feos-core/README.md b/crates/feos-core/README.md index 64d48beae..8e8102f26 100644 --- a/crates/feos-core/README.md +++ b/crates/feos-core/README.md @@ -10,14 +10,4 @@ The crate makes use of [generalized (hyper-) dual numbers](https://github.com/it - **critical points**, - and **phase equilibria**. -In addition to that, utilities are provided to assist in the handling of **parameters** for both molecular equations of state and (homosegmented) group contribution methods. Mainly as a simple test case, a **cubic** equation of state is published as part of this crate. Implementations of more sophisticated models can be found in the [feos](https://github.com/feos-org/feos) repository. - -For information on how to implement your own equation of state, check out the [documentation](https://feos-org.github.io/feos/rustguide/index.html). - -## Installation - -Add this to your `Cargo.toml` - -```toml -[dependencies] -feos-core = "0.7" +In addition to that, utilities are provided to assist in the handling of **parameters** for both molecular equations of state and (homosegmented) group contribution methods. Mainly as a simple test case, a **cubic** equation of state is published as part of this crate. Implementations of more sophisticated models can be found in the [feos](https://crates.io/crates/feos) crate. \ No newline at end of file diff --git a/crates/feos-core/src/lib.rs b/crates/feos-core/src/lib.rs index 08c8b9271..b883193ca 100644 --- a/crates/feos-core/src/lib.rs +++ b/crates/feos-core/src/lib.rs @@ -45,9 +45,10 @@ pub use phase_equilibria::{PhaseEquilibrium, TemperatureOrPressure}; pub use state::{Contributions, DensityInitialization, State, StateBuilder, StateHD, StateVec}; /// Level of detail in the iteration output. -#[derive(Copy, Clone, PartialOrd, PartialEq, Eq)] +#[derive(Copy, Clone, PartialOrd, PartialEq, Eq, Default)] pub enum Verbosity { /// Do not print output. + #[default] None, /// Print information about the success of failure of the iteration. Result, @@ -55,12 +56,6 @@ pub enum Verbosity { Iter, } -impl Default for Verbosity { - fn default() -> Self { - Self::None - } -} - /// Options for the various phase equilibria solvers. /// /// If the values are [None], solver specific default diff --git a/crates/feos-derive/Cargo.toml b/crates/feos-derive/Cargo.toml index bc3251c88..5a944fe12 100644 --- a/crates/feos-derive/Cargo.toml +++ b/crates/feos-derive/Cargo.toml @@ -1,22 +1,14 @@ [package] name = "feos-derive" -version = "0.6.0" -authors = [ - "Gernot Bauer ", - "Philipp Rehner ", -] -edition = "2021" -readme = "README.md" -description = "Macros for the EquationOfState and HelmholtzEnergyFunctional traits in FeOs" -license = "MIT OR Apache-2.0" -homepage = "https://github.com/feos-org" -repository = "https://github.com/feos-org/feos" -keywords = [ - "physics", - "thermodynamics", - "equations_of_state", - "phase_equilibria", -] +edition.workspace = true +version.workspace = true +authors.workspace = true +homepage.workspace = true +license.workspace = true +repository.workspace = true +keywords.workspace = true +categories.workspace = true +description = "Macros for the automatic implementation of traits in FeOs" [lib] proc-macro = true diff --git a/crates/feos-derive/README.md b/crates/feos-derive/README.md index b2becdf5c..90f82a89f 100644 --- a/crates/feos-derive/README.md +++ b/crates/feos-derive/README.md @@ -9,6 +9,6 @@ ## What it does -The `feos-derive` crate contains two macros that provide boilerplate for the implementation of the `EquationOfState` and the `HelmholtzEnergyFunctional` trait for the `EosVariant` and `FunctionalVariant` enums of the `feos` crate. With these macros, new equations of state and functionals can be added to the variants without any further implementations needed. +The `feos-derive` crate contains macros that provide boilerplate for the implementation of several traits from `feos-core` and `feos-dft` for the FFI conform enums in `feos`. With these macros, new equations of state and functionals can be added straightforwardly to the Python interface or other FFIs. diff --git a/crates/feos-dft/CHANGELOG.md b/crates/feos-dft/CHANGELOG.md index d1a22acff..4d1b29bbf 100644 --- a/crates/feos-dft/CHANGELOG.md +++ b/crates/feos-dft/CHANGELOG.md @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +> [!IMPORTANT] +> This file contains changes up to `feos-dft` v0.8.0. For newer versions, changes are documented for the entire project rather than individual crates [here](../../CHANGELOG.md). + ## [Unreleased] ## [0.8.0] - 2024-12-28 diff --git a/crates/feos-dft/Cargo.toml b/crates/feos-dft/Cargo.toml index 568a62edb..9a010add0 100644 --- a/crates/feos-dft/Cargo.toml +++ b/crates/feos-dft/Cargo.toml @@ -9,7 +9,6 @@ repository.workspace = true keywords.workspace = true categories.workspace = true description = "Generic classical DFT implementations for the `feos` project." -exclude = ["/.github/*", "*.ipynb"] [package.metadata.docs.rs] rustdoc-args = ["--html-in-header", "./docs-header.html"] diff --git a/crates/feos-dft/README.md b/crates/feos-dft/README.md index 3cbbcf501..1be7b42e2 100644 --- a/crates/feos-dft/README.md +++ b/crates/feos-dft/README.md @@ -10,12 +10,3 @@ The crate makes use of efficient numerical methods to calculate density profiles - Automatic calculation of partial derivatives of Helmholtz energy densities (including temperature derivatives) using automatic differentiation with [generalized (hyper-) dual numbers](https://github.com/itt-ustutt/num-dual). - Modeling of heterosegmented molecules, including branched molecules. - Functionalities for calculating surface tensions, adsorption isotherms, pair correlation functions, and solvation free energies. - -## Installation - -Add this to your `Cargo.toml` - -```toml -[dependencies] -feos-dft = "0.7" -``` \ No newline at end of file diff --git a/crates/feos/README.md b/crates/feos/README.md new file mode 120000 index 000000000..fe8400541 --- /dev/null +++ b/crates/feos/README.md @@ -0,0 +1 @@ +../../README.md \ No newline at end of file diff --git a/crates/feos/src/pcsaft/eos/polar.rs b/crates/feos/src/pcsaft/eos/polar.rs index 56e52f691..096bdc1c2 100644 --- a/crates/feos/src/pcsaft/eos/polar.rs +++ b/crates/feos/src/pcsaft/eos/polar.rs @@ -91,7 +91,6 @@ pub enum Multipole { } impl MeanSegmentNumbers { - #[expect(clippy::needless_range_loop)] pub fn new(parameters: &PcSaftPars, polarity: Multipole) -> Self { let (npoles, comp) = match polarity { Multipole::Dipole => (parameters.ndipole, ¶meters.dipole_comp), diff --git a/docs/conf.py b/docs/conf.py index a95c1edbe..5fb6772d5 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -42,9 +42,5 @@ # -- Options for HTML output ------------------------------------------------- html_theme = 'furo' -html_title = "FeOs" -html_static_path = ['_static'] -html_css_files = [ - 'style.css', -] +html_title = f'FeOs v{feos.__version__}' diff --git a/license-apache b/license-apache index aafc2037d..afc82c3c8 100644 --- a/license-apache +++ b/license-apache @@ -1,4 +1,4 @@ - Copyright (c) 2021-present feos-org and Contributors. https://github.com/feos-org/feos + Copyright (c) 2021-2025 feos-org and Contributors. https://github.com/feos-org/feos Apache License Version 2.0, January 2004 diff --git a/license-mit b/license-mit index d37df21be..ef2c6c20b 100644 --- a/license-mit +++ b/license-mit @@ -1,4 +1,4 @@ -Copyright (c) 2023 Gernot Bauer, Philipp Rehner +Copyright (c) 2021-2025 feos-org and Contributors. https://github.com/feos-org/feos Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/py-feos/.python-version b/py-feos/.python-version deleted file mode 100644 index e4fba2183..000000000 --- a/py-feos/.python-version +++ /dev/null @@ -1 +0,0 @@ -3.12 diff --git a/py-feos/Cargo.toml b/py-feos/Cargo.toml index 06bcec3f5..e272ccdbd 100644 --- a/py-feos/Cargo.toml +++ b/py-feos/Cargo.toml @@ -1,21 +1,27 @@ [package] name = "py_feos" -version = "0.1.0" -edition = "2021" +edition.workspace = true +version.workspace = true +authors.workspace = true +homepage.workspace = true +license.workspace = true +repository.workspace = true +keywords.workspace = true +categories.workspace = true [lib] name = "feos" crate-type = ["cdylib"] [dependencies] -pyo3 = { version = "0.26", features = [ +pyo3 = { version = "0.27", features = [ "extension-module", - "abi3-py39", + "abi3-py310", "multiple-pymethods", "indexmap" ] } -pythonize = "0.26" -numpy = { version = "0.26" } +pythonize = "0.27" +numpy = { version = "0.27" } quantity = { workspace = true, features = ["python", "python_numpy"] } num-dual = { workspace = true, features = ["python_macro"] } diff --git a/py-feos/README.md b/py-feos/README.md deleted file mode 100644 index 43f48ab80..000000000 --- a/py-feos/README.md +++ /dev/null @@ -1,203 +0,0 @@ -

- FeOs - A Framework for Equations of State and Classical Density Functional Theory -

- -
- - crates.io Latest Release - - - PyPi Latest Release - - - Rust Documentation - - - Documentation - - - FeOs Publication - -
- ---- - -The `FeOs` package provides Rust implementations of different equation of state and Helmholtz energy functional models and corresponding Python bindings. - -```python -from feos import EquationOfState, State -from feos.parameters import PureRecord, Identifier, Parameters - -# PC-SAFT parameters for methanol (Gross and Sadowski 2002) -record = PureRecord( - Identifier(name="methanol"), - molarweight=32.04, - m=1.5255, - sigma=3.23, - epsilon_k=188.9, - kappa_ab=0.035176, - epsilon_k_ab=2899.5, - na=1, - nb=1, -) - -# Build an equation of state -parameters = Parameters.new_pure(record) -eos = EquationOfState.pcsaft(parameters) - -# Define thermodynamic conditions -critical_point = State.critical_point(eos) - -# Compute properties -p = critical_point.pressure() -t = critical_point.temperature -print(f"Critical point for methanol: T={t}, p={p}.") -``` -```terminal -Critical point for methanol: T=531.5 K, p=10.7 MPa. -``` - -## Models -The following models are currently published as part of the `FeOs` framework - -|name|description|eos|dft| -|-|-|:-:|:-:| -|`pcsaft`|perturbed-chain (polar) statistical associating fluid theory|✓|✓| -|`epcsaft`|electrolyte PC-SAFT|✓|| -|`gc-pcsaft`|(heterosegmented) group contribution PC-SAFT|✓|✓| -|`pets`|perturbed truncated and shifted Lennard-Jones mixtures|✓|✓| -|`uvtheory`|equation of state for Mie fluids and mixtures|✓|| -|`saftvrqmie`|equation of state for quantum fluids and mixtures|✓|✓| -|`saftvrmie`|statistical associating fluid theory for variable range interactions of Mie form|✓|| - -The list is being expanded continuously. Currently under development are implementations of Helmholtz energy functionals for the UV theory and for SAFT-VR Mie. - -Other public repositories that implement models within the `FeOs` framework, but are currently not part of the `feos` Python package, are - -|name|description|eos|dft| -|-|-|:-:|:-:| -|[`feos-fused-chains`](https://github.com/feos-org/feos-fused-chains)|heterosegmented fused-sphere chain functional||✓| - -## Parameters -In addition to the source code for the Rust and Python packages, this repository contains JSON files with previously published [parameters](https://github.com/feos-org/feos/tree/main/parameters) for the different models including group contribution methods. The parameter files can be read directly from Rust or Python. - -## Properties and phase equilibria - -The crate makes use of [generalized (hyper-) dual numbers](https://github.com/itt-ustutt/num-dual) to generically calculate exact partial derivatives from Helmholtz energy equations of state. The derivatives are used to calculate -- **equilibrium properties** (pressure, heat capacity, fugacity, and *many* more), -- **transport properties** (viscosity, thermal conductivity, diffusion coefficients) using the entropy scaling approach -- **critical points** and **phase equilibria** for pure components and mixtures. - -In addition to that, utilities are provided to assist in the handling of **parameters** for both molecular equations of state and (homosegmented) group contribution methods and for the generation of phase diagrams for pure components and binary mixtures. - -## Classical density functional theory - -`FeOs` uses efficient numerical methods to calculate density profiles in inhomogeneous systems. Highlights include: -- Fast calculation of convolution integrals in cartesian (1D, 2D and 3D), polar, cylindrical, and spherical coordinate systems using FFT and related algorithms. -- Automatic calculation of partial derivatives of Helmholtz energy densities (including temperature derivatives) using automatic differentiation with [generalized (hyper-) dual numbers](https://github.com/itt-ustutt/num-dual). -- Modeling of heterosegmented molecules, including branched molecules. -- Functionalities for calculating surface tensions, adsorption isotherms, pair correlation functions, and solvation free energies. - -## Cargo features - -Without additional features activated, the command -``` -cargo test --release -``` -will only build and test the core functionalities of the crate. To run unit and integration tests for specific models, run -``` -cargo test --release --features pcsaft -``` -to test, e.g., the implementation of PC-SAFT or -``` -cargo test --release --features all_models -``` -to run tests on all implemented models. - -## Python package - -`FeOs` uses the [`PyO3`](https://github.com/PyO3/pyo3) framework to provide Python bindings. The Python package can be installed via `pip` and runs on Windows, Linux and macOS: - -``` -pip install feos -``` - -If there is no compiled package for your system available from PyPI and you have a Rust compiler installed, you can instead build the python package from source using - -``` -pip install git+https://github.com/feos-org/feos -``` - -This command builds the package without link-time optimization (LTO) that can be used to increase the performance further. -See the *Building from source* section for information about building the wheel including LTO. - -### Building from source - -To compile the code you need the Rust compiler and `maturin` (>=0.13,<0.14) installed. -To install the package directly into the active environment (virtualenv or conda), use - -``` -maturin develop --release -``` - -which uses the `python` and `all_models` feature as specified in the `pyproject.toml` file. - -Alternatively, you can specify the models or features that you want to include in the python package explicitly, e.g. - -``` -maturin develop --release --features "python pcsaft dft" -``` - -for the PC-SAFT equation of state and Helmholtz energy functional. - -To build wheels including link-time optimization (LTO), use - -``` -maturin build --profile="release-lto" -``` - -which will use the `python` and `all_models` features specified in the `pyproject.toml` file. -Use the following command to build a wheel with specific features: - -``` -maturin build --profile="release-lto" --features "python ..." -``` - -LTO increases compile times measurably but the resulting wheel is more performant and has a smaller size. -For development however, we recommend using the `--release` flag. - -## Documentation - -For a documentation of the Python API, Python examples, and a guide to the underlying Rust framework check out the [documentation](https://feos-org.github.io/feos/). - -## Benchmarks - -Check out the [benches](https://github.com/feos-org/feos/tree/main/feos-benchmarks) directory for information about provided Rust benchmarks and how to run them. - -## Developers - -This software is currently maintained by members of the groups of -- Prof. Joachim Gross, [Institute of Thermodynamics and Thermal Process Engineering (ITT), University of Stuttgart](https://www.itt.uni-stuttgart.de/) -- Prof. André Bardow, [Energy and Process Systems Engineering (EPSE), ETH Zurich](https://epse.ethz.ch/) - -## Contributing - -`FeOs` grew from the need to maintain a common codebase used within the scientific work done in our groups. We share the code publicly as a platform to publish our own research but also encourage other researchers and developers to contribute their own models or implementations of existing equations of state. - -If you want to contribute to ``FeOs``, there are several ways to go: improving the documentation and helping with language issues, testing the code on your systems to find bugs, adding new models or algorithms, or providing feature requests. Feel free to message us if you have questions or open an issue to discuss improvements. - -## Cite us - -If you find `FeOs` useful for your own scientific studies, consider citing our [publication](https://pubs.acs.org/doi/full/10.1021/acs.iecr.2c04561) accompanying this library. - -``` -@article{rehner2023feos, - author = {Rehner, Philipp and Bauer, Gernot and Gross, Joachim}, - title = {FeOs: An Open-Source Framework for Equations of State and Classical Density Functional Theory}, - journal = {Industrial \& Engineering Chemistry Research}, - volume = {62}, - number = {12}, - pages = {5347-5357}, - year = {2023}, -} -``` diff --git a/py-feos/README.md b/py-feos/README.md new file mode 120000 index 000000000..32d46ee88 --- /dev/null +++ b/py-feos/README.md @@ -0,0 +1 @@ +../README.md \ No newline at end of file diff --git a/py-feos/pyproject.toml b/py-feos/pyproject.toml index 20246aa8f..e43a7ca27 100644 --- a/py-feos/pyproject.toml +++ b/py-feos/pyproject.toml @@ -1,15 +1,17 @@ [project] name = "feos" -version = "0.1.0" -description = "Add your description here" -readme = "README.md" -authors = [ - { name = "Gernot Bauer", email = "bauer@itt.uni-stuttgart.de" }, - { name = "Philipp Rehner", email = "prehner@ethz.ch"} +dynamic = [ + "version", + "description", + "readme", + "urls", + "authors", + "license", + "keywords", ] -requires-python = ">=3.12" +requires-python = ">=3.10" dependencies = [ - "si_units>=0.11.0", + "si-units>=0.11.0", ] [build-system] @@ -17,24 +19,4 @@ requires = ["maturin>=1.0,<2.0"] build-backend = "maturin" [tool.maturin] -features = ["all_models"] - -[dependency-groups] -dev = [ - "ipykernel>=6.29.5", - "maturin>=1.8.3", -] - -[tool.ruff] -line-length = 80 - -[tool.ruff.lint] -extend-select = [ - "D", # pydocstyle -] - -[tool.ruff.lint.pydocstyle] -convention = "google" # https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings - -[tool.ruff.lint.pycodestyle] -max-doc-length = 80 +features = ["all_models"] \ No newline at end of file diff --git a/py-feos/src/parameter/fragmentation.rs b/py-feos/src/parameter/fragmentation.rs index 7a45f61e4..b011f9fc5 100644 --- a/py-feos/src/parameter/fragmentation.rs +++ b/py-feos/src/parameter/fragmentation.rs @@ -98,10 +98,10 @@ pub(crate) fn fragment_molecule( // Instead of just throwing an error at this point, just try to continue with the first max // occurrences. For some cases (the ethers) this just means that the symetry of C-O-C is broken. // If a necessary segment is eliminated the error will be thrown later. - if let Some(max) = s.max { - if matches.len() > max { - matches = matches[..max].to_vec(); - } + if let Some(max) = s.max + && matches.len() > max + { + matches = matches[..max].to_vec(); } Ok((s.group, matches)) }) diff --git a/py-feos/src/state.rs b/py-feos/src/state.rs index 9925244f1..2b5492d85 100644 --- a/py-feos/src/state.rs +++ b/py-feos/src/state.rs @@ -185,7 +185,7 @@ impl PyState { /// /// Returns /// ------- - /// State : State at critical conditions + /// list[State] : List of pure-substance State objects at critical conditions. #[staticmethod] #[pyo3( text_signature = "(eos, initial_temperature=None, initial_density=None, max_iter=None, tol=None, verbosity=None)"