thermolib 0.7.7__tar.gz → 0.8.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {thermolib-0.7.7 → thermolib-0.8.0}/Cargo.lock +1 -1
- {thermolib-0.7.7 → thermolib-0.8.0}/Cargo.toml +1 -1
- {thermolib-0.7.7 → thermolib-0.8.0}/PKG-INFO +1 -1
- thermolib-0.8.0/src/ideal_gas.rs +56 -0
- {thermolib-0.7.7 → thermolib-0.8.0}/src/lib.rs +3 -0
- {thermolib-0.7.7 → thermolib-0.8.0}/src/python.rs +2 -0
- {thermolib-0.7.7 → thermolib-0.8.0}/.gitignore +0 -0
- {thermolib-0.7.7 → thermolib-0.8.0}/LICENSE +0 -0
- {thermolib-0.7.7 → thermolib-0.8.0}/README.md +0 -0
- {thermolib-0.7.7 → thermolib-0.8.0}/pyproject.toml +0 -0
- {thermolib-0.7.7 → thermolib-0.8.0}/res/22DimethylButane.json +0 -0
- {thermolib-0.7.7 → thermolib-0.8.0}/res/23DimethylButane.json +0 -0
- {thermolib-0.7.7 → thermolib-0.8.0}/res/3MethylPentane.json +0 -0
- {thermolib-0.7.7 → thermolib-0.8.0}/res/C4F10.json +0 -0
- {thermolib-0.7.7 → thermolib-0.8.0}/res/C5F12.json +0 -0
- {thermolib-0.7.7 → thermolib-0.8.0}/res/C6F14.json +0 -0
- {thermolib-0.7.7 → thermolib-0.8.0}/res/NH3.json +0 -0
- {thermolib-0.7.7 → thermolib-0.8.0}/res/SO2.json +0 -0
- {thermolib-0.7.7 → thermolib-0.8.0}/src/algorithms.rs +0 -0
- {thermolib-0.7.7 → thermolib-0.8.0}/src/helmholtz/alpha.rs +0 -0
- {thermolib-0.7.7 → thermolib-0.8.0}/src/helmholtz/alpha_i.rs +0 -0
- {thermolib-0.7.7 → thermolib-0.8.0}/src/helmholtz/alpha_r.rs +0 -0
- {thermolib-0.7.7 → thermolib-0.8.0}/src/helmholtz/anc_eqn.rs +0 -0
- {thermolib-0.7.7 → thermolib-0.8.0}/src/helmholtz/assoc.rs +0 -0
- {thermolib-0.7.7 → thermolib-0.8.0}/src/helmholtz/rho_ini.rs +0 -0
- {thermolib-0.7.7 → thermolib-0.8.0}/src/helmholtz.rs +0 -0
- {thermolib-0.7.7 → thermolib-0.8.0}/src/liquid_metal/eta.rs +0 -0
- {thermolib-0.7.7 → thermolib-0.8.0}/src/liquid_metal/lambda.rs +0 -0
- {thermolib-0.7.7 → thermolib-0.8.0}/src/liquid_metal/metals.md +0 -0
- {thermolib-0.7.7 → thermolib-0.8.0}/src/liquid_metal/rho.rs +0 -0
- {thermolib-0.7.7 → thermolib-0.8.0}/src/liquid_metal.rs +0 -0
- {thermolib-0.7.7 → thermolib-0.8.0}/src/pc_saft.rs +0 -0
- {thermolib-0.7.7 → thermolib-0.8.0}/src/pr.rs +0 -0
- {thermolib-0.7.7 → thermolib-0.8.0}/src/rk.rs +0 -0
- {thermolib-0.7.7 → thermolib-0.8.0}/src/srk.rs +0 -0
- {thermolib-0.7.7 → thermolib-0.8.0}/src/vdw.rs +0 -0
- {thermolib-0.7.7 → thermolib-0.8.0}/tests/plot_ceos.py +0 -0
- {thermolib-0.7.7 → thermolib-0.8.0}/tests/test_fluids.rs +0 -0
@@ -0,0 +1,56 @@
|
|
1
|
+
#[cfg(feature = "with_pyo3")]
|
2
|
+
use pyo3::{pyclass, pymethods};
|
3
|
+
#[cfg_attr(feature = "with_pyo3", pyclass)]
|
4
|
+
pub struct IdealGas {
|
5
|
+
c: f64,
|
6
|
+
v: Vec<f64>,
|
7
|
+
}
|
8
|
+
impl IdealGas {
|
9
|
+
pub fn new_fluid() -> Self {
|
10
|
+
Self {
|
11
|
+
c: 1.5, // Translation contribution = 1.5
|
12
|
+
v: Vec::new(),
|
13
|
+
}
|
14
|
+
}
|
15
|
+
}
|
16
|
+
#[cfg_attr(feature = "with_pyo3", pymethods)]
|
17
|
+
#[allow(non_snake_case)]
|
18
|
+
impl IdealGas {
|
19
|
+
#[cfg(feature = "with_pyo3")]
|
20
|
+
#[new]
|
21
|
+
pub fn new_py() -> Self {
|
22
|
+
Self::new_fluid()
|
23
|
+
}
|
24
|
+
pub fn set_linear_molecule(&mut self) {
|
25
|
+
// Translation contribution = 1.5
|
26
|
+
// Rotation contribution = 1.0
|
27
|
+
self.c = 2.5;
|
28
|
+
}
|
29
|
+
pub fn set_nonlinear_molecule(&mut self) {
|
30
|
+
// Translation contribution = 1.5
|
31
|
+
// Rotation contribution = 1.5
|
32
|
+
self.c = 3.0;
|
33
|
+
}
|
34
|
+
pub fn set_wave_length(&mut self, waves: Vec<f64>) {
|
35
|
+
self.v = waves.iter().map(|wave| C * wave * 100.0).collect();
|
36
|
+
}
|
37
|
+
pub fn calc_cv(&self, T: f64) -> f64 {
|
38
|
+
R * (self.c
|
39
|
+
+ self
|
40
|
+
.v
|
41
|
+
.iter()
|
42
|
+
.map(|vi| {
|
43
|
+
let temp = -FRAC_H_K * vi / T;
|
44
|
+
temp.exp() * (temp / temp.exp_m1()).powi(2)
|
45
|
+
})
|
46
|
+
.sum::<f64>())
|
47
|
+
}
|
48
|
+
pub fn calc_cp(&self, T: f64) -> f64 {
|
49
|
+
self.calc_cv(T) + R
|
50
|
+
}
|
51
|
+
}
|
52
|
+
const R: f64 = 8.314462618; // CODATA2018 (molar gas constant) J mol^-1 K^-1
|
53
|
+
const C: f64 = 299792458.0; // CODATA2018 (speed of light in vacuum) m s^-1
|
54
|
+
const H: f64 = 6.62607015E-34; // CODATA2018 (Planck constant) J Hz^-1
|
55
|
+
const K: f64 = 1.380649e-23; // CODATA2018 (Boltzmann constant) J K^-1
|
56
|
+
const FRAC_H_K: f64 = H / K; // K / Hz
|
@@ -5,6 +5,7 @@ fn hello() -> PyResult<String> {
|
|
5
5
|
Ok(String::from("Hello, Rust And Python."))
|
6
6
|
}
|
7
7
|
use crate::Helmholtz;
|
8
|
+
use crate::IdealGas;
|
8
9
|
use crate::LiquidMetal;
|
9
10
|
use crate::PcSaftPure;
|
10
11
|
use crate::Pr;
|
@@ -23,5 +24,6 @@ pub fn pylib(m: &Bound<'_, PyModule>) -> PyResult<()> {
|
|
23
24
|
m.add_class::<Helmholtz>()?;
|
24
25
|
m.add_class::<LiquidMetal>()?;
|
25
26
|
m.add_class::<PcSaftPure>()?;
|
27
|
+
m.add_class::<IdealGas>()?;
|
26
28
|
Ok(())
|
27
29
|
}
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|