-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathcubic.rs
More file actions
73 lines (64 loc) · 2.08 KB
/
cubic.rs
File metadata and controls
73 lines (64 loc) · 2.08 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
use crate::cubic::{PengRobinsonParameters, PengRobinsonRecord};
use crate::joback::JobackRecord;
use crate::parameter::{
BinaryRecord, Identifier, IdentifierOption, Parameter, ParameterError, PureRecord,
};
use crate::python::joback::PyJobackRecord;
use crate::python::parameter::PyIdentifier;
use crate::*;
use ndarray::Array2;
use numpy::{PyArray2, PyReadonlyArray2, ToPyArray};
use pyo3::exceptions::PyTypeError;
use pyo3::prelude::*;
use std::convert::{TryFrom, TryInto};
use std::sync::Arc;
/// A pure substance parameter for the Peng-Robinson equation of state.
#[pyclass(name = "PengRobinsonRecord")]
#[derive(Clone)]
pub struct PyPengRobinsonRecord(PengRobinsonRecord);
#[pymethods]
impl PyPengRobinsonRecord {
#[new]
fn new(tc: f64, pc: f64, acentric_factor: f64) -> Self {
Self(PengRobinsonRecord::new(tc, pc, acentric_factor))
}
fn __repr__(&self) -> PyResult<String> {
Ok(self.0.to_string())
}
}
impl_json_handling!(PyPengRobinsonRecord);
impl_pure_record!(
PengRobinsonRecord,
PyPengRobinsonRecord,
JobackRecord,
PyJobackRecord
);
impl_binary_record!();
/// Create a set of Peng-Robinson parameters from records.
///
/// Parameters
/// ----------
/// pure_records : List[PureRecord]
/// pure substance records.
/// binary_records : List[BinaryRecord], optional
/// binary parameter 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
/// -------
/// PengRobinsonParameters
#[pyclass(name = "PengRobinsonParameters")]
#[derive(Clone)]
pub struct PyPengRobinsonParameters(pub Arc<PengRobinsonParameters>);
impl_parameter!(PengRobinsonParameters, PyPengRobinsonParameters);
#[pymethods]
impl PyPengRobinsonParameters {
fn __repr__(&self) -> PyResult<String> {
Ok(self.0.to_string())
}
}