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

Commit 950ec5d

Browse files
authored
Add dq_variant to PcSaftOptions (#11)
1 parent fee5f57 commit 950ec5d

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

src/eos/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ pub struct PcSaftOptions {
3434
pub max_eta: f64,
3535
pub max_iter_cross_assoc: usize,
3636
pub tol_cross_assoc: f64,
37+
pub dq_variant: DQVariants,
3738
}
3839

3940
impl Default for PcSaftOptions {
@@ -42,6 +43,7 @@ impl Default for PcSaftOptions {
4243
max_eta: 0.5,
4344
max_iter_cross_assoc: 50,
4445
tol_cross_assoc: 1e-10,
46+
dq_variant: DQVariants::DQ35,
4547
}
4648
}
4749
}
@@ -82,7 +84,7 @@ impl PcSaft {
8284
if parameters.ndipole > 0 && parameters.nquadpole > 0 {
8385
contributions.push(Box::new(DipoleQuadrupole {
8486
parameters: parameters.clone(),
85-
variant: DQVariants::DQ35,
87+
variant: options.dq_variant,
8688
}));
8789
};
8890
match parameters.nassoc {

src/python/eos.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use super::parameters::PyPcSaftParameters;
2+
use crate::eos::polar::DQVariants;
23
use crate::eos::{PcSaft, PcSaftOptions};
34
use feos_core::python::{PyContributions, PyVerbosity};
45
use feos_core::utils::{
@@ -14,6 +15,16 @@ use quantity::si::*;
1415
use std::collections::HashMap;
1516
use std::rc::Rc;
1617

18+
impl From<&str> for DQVariants {
19+
fn from(str: &str) -> Self {
20+
match str {
21+
"dq35" => Self::DQ35,
22+
"dq44" => Self::DQ44,
23+
_ => panic!("dq_variant must be either \"dq35\" or \"dq44\""),
24+
}
25+
}
26+
}
27+
1728
/// Initialize PC-SAFT equation of state.
1829
///
1930
/// Parameters
@@ -26,16 +37,16 @@ use std::rc::Rc;
2637
/// Maximum number of iterations for cross association. Defaults to 50.
2738
/// tol_cross_assoc : float
2839
/// Tolerance for convergence of cross association. Defaults to 1e-10.
40+
/// dq_variant : {'dq35', 'dq44'}, optional
41+
/// Combination rule used in the dipole/quadrupole term. Defaults to 'dq35'
2942
///
3043
/// Returns
3144
/// -------
3245
/// PcSaft
3346
/// The PC-SAFT equation of state that can be used to compute thermodynamic
3447
/// states.
3548
#[pyclass(name = "PcSaft", unsendable)]
36-
#[pyo3(
37-
text_signature = "(parameters, max_eta, max_iter_cross_assoc, tol_cross_assoc, joback_parameters)"
38-
)]
49+
#[pyo3(text_signature = "(parameters, max_eta, max_iter_cross_assoc, tol_cross_assoc, dq_variant)")]
3950
#[derive(Clone)]
4051
pub struct PyPcSaft(pub Rc<PcSaft>);
4152

@@ -45,18 +56,21 @@ impl PyPcSaft {
4556
#[args(
4657
max_eta = "0.5",
4758
max_iter_cross_assoc = "50",
48-
tol_cross_assoc = "1e-10"
59+
tol_cross_assoc = "1e-10",
60+
dq_variant = "\"dq35\""
4961
)]
5062
fn new(
5163
parameters: PyPcSaftParameters,
5264
max_eta: f64,
5365
max_iter_cross_assoc: usize,
5466
tol_cross_assoc: f64,
67+
dq_variant: &str,
5568
) -> Self {
5669
let options = PcSaftOptions {
5770
max_eta,
5871
max_iter_cross_assoc,
5972
tol_cross_assoc,
73+
dq_variant: dq_variant.into(),
6074
};
6175
Self(Rc::new(PcSaft::with_options(parameters.0, options)))
6276
}

0 commit comments

Comments
 (0)