Skip to content
This repository has been archived by the owner on Sep 14, 2022. It is now read-only.

Commit

Permalink
Release v0.1.0 (#2)
Browse files Browse the repository at this point in the history
* Release v0.1.0

* fix module name and bonds

* add basic documentation
  • Loading branch information
prehner committed Apr 24, 2022
1 parent e5cc2f3 commit d531b34
Show file tree
Hide file tree
Showing 32 changed files with 1,595 additions and 1,436 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Release

on:
push:
tags: ["v*"]

jobs:
release-crates-io:
name: Release crates.io
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: login
args: ${{ secrets.CRATES_IO_TOKEN }}
- uses: actions-rs/cargo@v1
with:
command: publish
2 changes: 0 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Install openBLAS
run: sudo apt-get install -y libopenblas-dev
- name: Build
run: cargo build --release
- name: Run tests
Expand Down
81 changes: 81 additions & 0 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Build Wheels
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Build Wheels
uses: messense/maturin-action@v1
with:
maturin-version: latest
manylinux: auto
command: build
args: --release --out dist --no-sdist -m build_wheel/Cargo.toml
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
name: dist
path: dist
macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.9
architecture: x64
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
default: true
- name: Build wheels - x86_64
uses: messense/maturin-action@main
with:
target: x86_64
args: --release --out dist --no-sdist -m build_wheel/Cargo.toml
- name: Build wheels - universal2
uses: messense/maturin-action@main
with:
args: --release --universal2 --out dist --no-sdist -m build_wheel/Cargo.toml
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
name: dist
path: dist
windows:
runs-on: windows-latest
strategy:
matrix:
target: [x64, x86]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.9
architecture: ${{ matrix.target }}
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
default: true
- name: Build wheels
uses: messense/maturin-action@main
with:
target: ${{ matrix.target }}
args: --release --out dist --no-sdist -m build_wheel/Cargo.toml
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
name: dist
path: dist
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Changelog
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).

## [Unreleased]

## [0.1.0] - 2022-04-22
### Added
- Initial release
11 changes: 2 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ version = "0.1.0"
authors = ["Philipp Rehner <prehner@ethz.ch>", "Gernot Bauer <bauer@itt.uni-stuttgart.de>"]
edition = "2018"

[lib]
name = "feos_gc_pcsaft"
crate-type = ["rlib", "cdylib"]

[dependencies]
quantity = "0.5"
feos-core = "0.2"
Expand All @@ -22,15 +18,12 @@ lazy_static = "1.4.0"
thiserror = "1.0"
petgraph = "0.6"
numpy = { version = "0.16", optional = true }
pyo3 = { version = "0.16", optional = true }

[dev-dependencies]
approx = "0.4"

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

[features]
default = []
python = ["pyo3", "numpy", "feos-dft/python"]
micelles = []
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# FeOs - gc-PC-SAFT

[![crate](https://img.shields.io/crates/v/feos-gc-pcsaft.svg)](https://crates.io/crates/feos-gc-pcsaft)
[![documentation](https://docs.rs/feos-gc-pcsaft/badge.svg)](https://docs.rs/feos-gc-pcsaft)
[![documentation](https://img.shields.io/badge/docs-github--pages-blue)](https://feos-org.github.io/feos/)

Implementation of the (heterosegmented) group contribution PC-SAFT equation of state[^gross2003][^sauer2014] and corresponding Helmholtz energy functional[^mairhofer2018][^rehner2021] within the FeOs project. This project contains a Rust implementation as well as bindings to Python.

## Usage in Python

If you want to use `feos-gc-pcsaft` in Python, take a look at the [`feos`-repository](https://github.com/feos-org/feos). `feos` contains multiple equation of state implementations in a single, easy-to-use Python package.

## FeOs

> FeOs is a framework for equations of state and classical density function theory
You can learn more about the principles behind `FeOs` [here](https://feos-org.github.io/feos/).

## Installation

Add this to your `Cargo.toml`

```toml
[dependencies]
feos-gc-pcsaft = "0.1"
```

## Test building python wheel

From within a Python virtual environment with `maturin` installed, type

```
maturin build --release --out dist --no-sdist -m build_wheel/Cargo.toml
```

[^gross2003]: [J. Gross, O. Spuhl, F. Tumakaka and G. Sadowski (2003). *Industrial & Engineering Chemistry Research*, 42(6), 1266-1274.](https://doi.org/10.1021/ie020509y)
[^sauer2014]: [E. Sauer, M. Stavrou and J. Gross (2014). *Industrial & Engineering Chemistry Research*, 53(38), 14854-14864.](https://doi.org/10.1021/ie502203w)
[^mairhofer2018]: [J. Mairhofer, B. Xiao and J. Gross (2018). *Fluid Phase Equilibria*, 472, 117-127.](https://doi.org/10.1016/j.fluid.2018.05.016)
[^rehner2021]: [P. Rehner, B. Bursik and J. Gross (2021). *Industrial & Engineering Chemistry Research*, 60(19), 7111-7123.](https://doi.org/10.1021/acs.iecr.1c00169)
16 changes: 16 additions & 0 deletions build_wheel/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "feos_gc_pcsaft"
version = "0.1.0"
authors = ["Philipp Rehner <prehner@ethz.ch", "Gernot Bauer <bauer@itt.uni-stuttgart.de>"]
edition = "2021"

[lib]
crate-type = ["cdylib"]

[dependencies]
quantity = "0.5"
feos-core = "0.2"
feos-dft = "0.2"
feos-gc-pcsaft = { path = "..", features = ["python", "micelles"] }
pyo3 = { version = "0.16", features = ["extension-module", "abi3", "abi3-py37"] }
numpy = "0.16"
51 changes: 40 additions & 11 deletions src/python/dft.rs → build_wheel/src/dft.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
use super::parameter::*;
use crate::dft::GcPcSaftFunctional;
use crate::impl_micelle_profile;
use crate::micelles::*;
use feos_core::*;
use feos_dft::adsorption::*;
use feos_dft::fundamental_measure_theory::FMTVersion;
use feos_dft::interface::*;
use feos_dft::python::*;
use feos_dft::solvation::*;
use feos_dft::*;
use feos_gc_pcsaft::micelles::*;
use feos_gc_pcsaft::python::*;
use feos_gc_pcsaft::*;
use numpy::*;
use pyo3::exceptions::PyValueError;
use pyo3::prelude::*;
Expand All @@ -21,22 +20,53 @@ use std::rc::Rc;
///
/// Parameters
/// ----------
/// parameters: GcPcSaftFunctionalParameters
/// The set of gc-PC-SAFT parameters.
/// parameters: GcPcSaftParameters
/// The set of PC-SAFT parameters.
/// fmt_version: FMTVersion, optional
/// The specific variant of the FMT term. Defaults to FMTVersion.WhiteBear
/// max_eta : float, optional
/// Maximum packing fraction. Defaults to 0.5.
/// max_iter_cross_assoc : unsigned integer, optional
/// Maximum number of iterations for cross association. Defaults to 50.
/// tol_cross_assoc : float
/// Tolerance for convergence of cross association. Defaults to 1e-10.
///
/// Returns
/// -------
/// GcPcSaftFunctional
#[pyclass(name = "GcPcSaftFunctional", unsendable)]
#[pyo3(text_signature = "(parameters)")]
#[pyo3(
text_signature = "(parameters, fmt_version, max_eta, max_iter_cross_assoc, tol_cross_assoc)"
)]
#[derive(Clone)]
pub struct PyGcPcSaftFunctional(pub Rc<DFT<GcPcSaftFunctional>>);

#[pymethods]
impl PyGcPcSaftFunctional {
#[new]
fn new(parameters: PyGcPcSaftFunctionalParameters) -> Self {
Self(Rc::new(GcPcSaftFunctional::new(parameters.0.clone())))
#[args(
fmt_version = "FMTVersion::WhiteBear",
max_eta = "0.5",
max_iter_cross_assoc = "50",
tol_cross_assoc = "1e-10"
)]
fn new(
parameters: PyGcPcSaftFunctionalParameters,
fmt_version: FMTVersion,
max_eta: f64,
max_iter_cross_assoc: usize,
tol_cross_assoc: f64,
) -> Self {
let options = GcPcSaftOptions {
max_eta,
max_iter_cross_assoc,
tol_cross_assoc,
};
Self(Rc::new(GcPcSaftFunctional::with_options(
parameters.0,
fmt_version,
options,
)))
}
}

Expand All @@ -57,7 +87,7 @@ impl_solvation_profile!(GcPcSaftFunctional);
impl_micelle_profile!(GcPcSaftFunctional);

#[pymodule]
pub fn gc_pcsaft_dft(_: Python<'_>, m: &PyModule) -> PyResult<()> {
pub fn dft(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
m.add_class::<PyGcPcSaftFunctional>()?;
m.add_class::<PyState>()?;
m.add_class::<PyPhaseDiagram>()?;
Expand All @@ -74,6 +104,5 @@ pub fn gc_pcsaft_dft(_: Python<'_>, m: &PyModule) -> PyResult<()> {
m.add_class::<PySolvationProfile>()?;
m.add_class::<FMTVersion>()?;
m.add_class::<PyMicelleProfile>()?;

Ok(())
}
35 changes: 26 additions & 9 deletions src/python/eos.rs → build_wheel/src/eos.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use super::parameter::PyGcPcSaftEosParameters;
use crate::eos::{GcPcSaft, GcPcSaftOptions};
use feos_core::EquationOfState;
use feos_core::*;
use feos_gc_pcsaft::python::PyGcPcSaftEosParameters;
use feos_gc_pcsaft::{GcPcSaft, GcPcSaftOptions};
use numpy::convert::ToPyArray;
use numpy::{PyArray1, PyArray2};
use pyo3::exceptions::PyValueError;
Expand All @@ -11,6 +10,24 @@ use quantity::si::*;
use std::collections::HashMap;
use std::rc::Rc;

/// Initialize PC-SAFT equation of state.
///
/// Parameters
/// ----------
/// parameters : GcPcSaftParameters
/// The parameters of the gc-PC-Saft equation of state to use.
/// max_eta : float, optional
/// Maximum packing fraction. Defaults to 0.5.
/// max_iter_cross_assoc : unsigned integer, optional
/// Maximum number of iterations for cross association. Defaults to 50.
/// tol_cross_assoc : float
/// Tolerance for convergence of cross association. Defaults to 1e-10.
///
/// Returns
/// -------
/// GcPcSaft
/// The gc-PC-SAFT equation of state that can be used to compute thermodynamic
/// states.
#[pyclass(name = "GcPcSaft", unsendable)]
#[pyo3(text_signature = "(parameters, max_eta, max_iter_cross_assoc, tol_cross_assoc)")]
#[derive(Clone)]
Expand All @@ -35,22 +52,22 @@ impl PyGcPcSaft {
max_iter_cross_assoc,
tol_cross_assoc,
};
Self(Rc::new(GcPcSaft::with_options(
parameters.0.clone(),
options,
)))
Self(Rc::new(GcPcSaft::with_options(parameters.0, options)))
}
}

impl_equation_of_state!(PyGcPcSaft);
impl_virial_coefficients!(PyGcPcSaft);

impl_state!(GcPcSaft, PyGcPcSaft);
impl_state_molarweight!(GcPcSaft, PyGcPcSaft);
impl_phase_equilibrium!(GcPcSaft, PyGcPcSaft);

pub fn gc_pcsaft_eos(_: Python<'_>, m: &PyModule) -> PyResult<()> {
#[pymodule]
pub fn eos(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
m.add_class::<PyGcPcSaft>()?;
m.add_class::<PyState>()?;
m.add_class::<PyPhaseDiagram>()?;
m.add_class::<PyPhaseEquilibrium>()?;

Ok(())
}
Loading

0 comments on commit d531b34

Please sign in to comment.