-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathjoback.rs
More file actions
99 lines (89 loc) · 2.76 KB
/
joback.rs
File metadata and controls
99 lines (89 loc) · 2.76 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
87
88
89
90
91
92
93
94
95
96
97
98
99
use std::sync::Arc;
use crate::joback::{JobackBinaryRecord, JobackParameters, JobackRecord};
use crate::parameter::*;
use crate::python::parameter::*;
use crate::{
impl_binary_record, impl_json_handling, impl_parameter, impl_parameter_from_segments,
impl_pure_record, impl_segment_record,
};
use numpy::{PyArray2, PyReadonlyArray2, ToPyArray};
use pyo3::exceptions::PyTypeError;
use pyo3::prelude::*;
use std::convert::{TryFrom, TryInto};
/// Create a set of Joback ideal gas heat capacity parameters
/// for a segment or a pure component.
///
/// The fourth order coefficient `e` is not present in the
/// orginial publication by Joback and Reid but is required
/// for correlations for some pure components that are modeled
/// using the same polynomial approach.
///
/// Parameters
/// ----------
/// a : float
/// zeroth order coefficient
/// b : float
/// first order coefficient
/// c : float
/// second order coefficient
/// d : float
/// third order coefficient
/// e : float
/// fourth order coefficient
///
/// Returns
/// -------
/// JobackRecord
#[pyclass(name = "JobackRecord")]
#[derive(Clone)]
pub struct PyJobackRecord(pub JobackRecord);
#[pymethods]
impl PyJobackRecord {
#[new]
fn new(a: f64, b: f64, c: f64, d: f64, e: f64) -> Self {
Self(JobackRecord::new(a, b, c, d, e))
}
fn __repr__(&self) -> PyResult<String> {
Ok(self.0.to_string())
}
}
impl_json_handling!(PyJobackRecord);
impl_pure_record!(JobackRecord, PyJobackRecord);
impl_segment_record!(JobackRecord, PyJobackRecord);
#[pyclass(name = "JobackBinaryRecord")]
#[derive(Clone)]
pub struct PyJobackBinaryRecord(pub JobackBinaryRecord);
impl_binary_record!(JobackBinaryRecord, PyJobackBinaryRecord);
/// Create a set of Joback parameters from records.
///
/// Parameters
/// ----------
/// pure_records : List[PureRecord]
/// pure substance records.
/// substances : List[str], optional
/// The substances to use. Filters substances from `pure_records` according to
/// `search_option`.
/// When not provided, all entries of `pure_records` are used.
/// search_option : {'Name', 'Cas', 'Inchi', 'IupacName', 'Formula', 'Smiles'}, optional, defaults to 'Name'.
/// Identifier that is used to search substance.
///
/// Returns
/// -------
/// JobackParameters
#[pyclass(name = "JobackParameters")]
#[pyo3(text_signature = "(pure_records, substances=None, search_option='Name')")]
#[derive(Clone)]
pub struct PyJobackParameters(pub Arc<JobackParameters>);
impl_parameter!(
JobackParameters,
PyJobackParameters,
PyJobackRecord,
PyJobackBinaryRecord
);
impl_parameter_from_segments!(JobackParameters, PyJobackParameters);
#[pymethods]
impl PyJobackParameters {
// fn _repr_markdown_(&self) -> String {
// self.0.to_markdown()
// }
}