diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bbdd00..6fefcf6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - `PcSaftFunctional` now always uses `Joback` as ideal gas model if parameters are available. [#25](https://github.com/feos-org/feos-pcsaft/pull/25) +### Changed +- Added optional arguments to the constructor of `PcSaftFunctional` in Python to make it more analogous to `PcSaft`. [#34](https://github.com/feos-org/feos-pcsaft/pull/34) + ## [0.1.0] - 2022-01-12 ### Added - Initial release diff --git a/build_wheel/src/dft.rs b/build_wheel/src/dft.rs index 3f5fa4c..8e66a46 100644 --- a/build_wheel/src/dft.rs +++ b/build_wheel/src/dft.rs @@ -6,7 +6,7 @@ use feos_dft::python::*; use feos_dft::solvation::*; use feos_dft::*; use feos_pcsaft::python::*; -use feos_pcsaft::PcSaftFunctional; +use feos_pcsaft::{PcSaftFunctional, PcSaftOptions}; use numpy::*; use pyo3::exceptions::PyValueError; use pyo3::prelude::*; @@ -21,41 +21,55 @@ use std::rc::Rc; /// ---------- /// parameters: PcSaftParameters /// 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. +/// dq_variant : {'dq35', 'dq44'}, optional +/// Combination rule used in the dipole/quadrupole term. Defaults to 'dq35' /// /// Returns /// ------- /// PcSaftFunctional #[pyclass(name = "PcSaftFunctional", unsendable)] -#[pyo3(text_signature = "(parameters)")] +#[pyo3( + text_signature = "(parameters, fmt_version, max_eta, max_iter_cross_assoc, tol_cross_assoc, dq_variant)" +)] #[derive(Clone)] pub struct PyPcSaftFunctional(pub Rc>); #[pymethods] impl PyPcSaftFunctional { #[new] - fn new(parameters: PyPcSaftParameters) -> Self { - Self(Rc::new(PcSaftFunctional::new(parameters.0))) - } - - /// PCP SAFT Helmholtz energy functional without simplifications - /// for pure components. - /// - /// Parameters - /// ---------- - /// parameters: PcSaftParameters - /// The set of SAFT parameters. - /// fmt_version: FMTVersion - /// Specify the FMT term. - /// - /// Returns - /// ------- - /// PcSaftFunctional - #[staticmethod] - #[pyo3(text_signature = "(parameters, fmt_version)")] - fn new_full(parameters: PyPcSaftParameters, fmt_version: FMTVersion) -> Self { - Self(Rc::new(PcSaftFunctional::new_full( + #[args( + fmt_version = "FMTVersion::WhiteBear", + max_eta = "0.5", + max_iter_cross_assoc = "50", + tol_cross_assoc = "1e-10", + dq_variant = "\"dq35\"" + )] + fn new( + parameters: PyPcSaftParameters, + fmt_version: FMTVersion, + max_eta: f64, + max_iter_cross_assoc: usize, + tol_cross_assoc: f64, + dq_variant: &str, + ) -> Self { + let options = PcSaftOptions { + max_eta, + max_iter_cross_assoc, + tol_cross_assoc, + dq_variant: dq_variant.into(), + }; + Self(Rc::new(PcSaftFunctional::with_options( parameters.0, fmt_version, + options, ))) } } diff --git a/src/dft/mod.rs b/src/dft/mod.rs index 417bf97..07e0b8f 100644 --- a/src/dft/mod.rs +++ b/src/dft/mod.rs @@ -34,14 +34,14 @@ pub struct PcSaftFunctional { impl PcSaftFunctional { pub fn new(parameters: Rc) -> DFT { - Self::new_with_options(parameters, FMTVersion::WhiteBear, PcSaftOptions::default()) + Self::with_options(parameters, FMTVersion::WhiteBear, PcSaftOptions::default()) } pub fn new_full(parameters: Rc, fmt_version: FMTVersion) -> DFT { - Self::new_with_options(parameters, fmt_version, PcSaftOptions::default()) + Self::with_options(parameters, fmt_version, PcSaftOptions::default()) } - fn new_with_options( + pub fn with_options( parameters: Rc, fmt_version: FMTVersion, saft_options: PcSaftOptions, @@ -106,7 +106,7 @@ impl PcSaftFunctional { impl HelmholtzEnergyFunctional for PcSaftFunctional { fn subset(&self, component_list: &[usize]) -> DFT { - Self::new_with_options( + Self::with_options( Rc::new(self.parameters.subset(component_list)), self.fmt_version, self.options,