-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathcubic.rs
More file actions
52 lines (43 loc) · 1.33 KB
/
cubic.rs
File metadata and controls
52 lines (43 loc) · 1.33 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
use crate::cubic::{PengRobinsonParameters, PengRobinsonRecord};
use crate::parameter::{
BinaryRecord, Identifier, IdentifierOption, Parameter, ParameterError, PureRecord,
};
use crate::python::parameter::PyIdentifier;
use crate::*;
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);
impl_binary_record!();
#[pyclass(name = "PengRobinsonParameters")]
#[derive(Clone)]
pub struct PyPengRobinsonParameters(pub Arc<PengRobinsonParameters>);
impl_parameter!(
PengRobinsonParameters,
PyPengRobinsonParameters,
PyPengRobinsonRecord,
f64
);
#[pymethods]
impl PyPengRobinsonParameters {
fn __repr__(&self) -> PyResult<String> {
Ok(self.0.to_string())
}
}