Skip to content
This repository was archived by the owner on Sep 14, 2022. It is now read-only.
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
60 changes: 37 additions & 23 deletions build_wheel/src/dft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand All @@ -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<DFT<PcSaftFunctional>>);

#[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,
)))
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/dft/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ pub struct PcSaftFunctional {

impl PcSaftFunctional {
pub fn new(parameters: Rc<PcSaftParameters>) -> DFT<Self> {
Self::new_with_options(parameters, FMTVersion::WhiteBear, PcSaftOptions::default())
Self::with_options(parameters, FMTVersion::WhiteBear, PcSaftOptions::default())
}

pub fn new_full(parameters: Rc<PcSaftParameters>, fmt_version: FMTVersion) -> DFT<Self> {
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<PcSaftParameters>,
fmt_version: FMTVersion,
saft_options: PcSaftOptions,
Expand Down Expand Up @@ -106,7 +106,7 @@ impl PcSaftFunctional {

impl HelmholtzEnergyFunctional for PcSaftFunctional {
fn subset(&self, component_list: &[usize]) -> DFT<Self> {
Self::new_with_options(
Self::with_options(
Rc::new(self.parameters.subset(component_list)),
self.fmt_version,
self.options,
Expand Down