-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathdippr.rs
More file actions
86 lines (76 loc) · 2.15 KB
/
dippr.rs
File metadata and controls
86 lines (76 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
use std::sync::Arc;
use crate::ideal_gas::{Dippr, DipprRecord};
use feos_core::parameter::*;
use feos_core::python::parameter::*;
use feos_core::{impl_json_handling, impl_parameter, impl_pure_record};
use numpy::{PyArray2, PyReadonlyArray2, ToPyArray};
use pyo3::exceptions::PyTypeError;
use pyo3::prelude::*;
use std::convert::{TryFrom, TryInto};
/// DIPPR ideal gas heat capacity parameters for a pure component.
#[pyclass(name = "DipprRecord")]
#[derive(Clone)]
pub struct PyDipprRecord(pub DipprRecord);
#[pymethods]
impl PyDipprRecord {
/// Create a set of parameters for DIPPR eq. # 100.
///
/// Parameters
/// ----------
/// coefs : list[float]
/// Model parameters.
///
/// Returns
/// -------
/// DipprRecord
#[staticmethod]
fn eq100(coefs: Vec<f64>) -> Self {
Self(DipprRecord::eq100(&coefs))
}
/// Create a set of parameters for DIPPR eq. # 107.
///
/// Parameters
/// ----------
/// a-e : float
/// Model parameters.
///
/// Returns
/// -------
/// DipprRecord
#[staticmethod]
fn eq107(a: f64, b: f64, c: f64, d: f64, e: f64) -> Self {
Self(DipprRecord::eq107(a, b, c, d, e))
}
/// Create a set of parameters for DIPPR eq. # 127.
///
/// Parameters
/// ----------
/// a-g : float
/// Model parameters.
///
/// Returns
/// -------
/// DipprRecord
#[staticmethod]
fn eq127(a: f64, b: f64, c: f64, d: f64, e: f64, f: f64, g: f64) -> Self {
Self(DipprRecord::eq127(a, b, c, d, e, f, g))
}
fn __repr__(&self) -> PyResult<String> {
Ok(self.0.to_string())
}
}
impl_json_handling!(PyDipprRecord);
impl_pure_record!(DipprRecord, PyDipprRecord);
/// Ideal gas model based on DIPPR correlations.
#[pyclass(name = "Dippr")]
#[derive(Clone)]
pub struct PyDippr(pub Arc<Dippr>);
impl_parameter!(Dippr, PyDippr, PyDipprRecord);
#[pymodule]
pub fn dippr(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
m.add_class::<PyIdentifier>()?;
m.add_class::<IdentifierOption>()?;
m.add_class::<PyDipprRecord>()?;
m.add_class::<PyPureRecord>()?;
m.add_class::<PyDippr>()
}