thermolib 0.8.1__cp39-abi3-win_amd64.whl
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/__init__.py
ADDED
thermolib/thermolib.pyd
ADDED
Binary file
|
@@ -0,0 +1,218 @@
|
|
1
|
+
Metadata-Version: 2.3
|
2
|
+
Name: thermolib
|
3
|
+
Version: 0.8.1
|
4
|
+
License-File: LICENSE
|
5
|
+
Summary: An open-source library for the calculation of fluid properties
|
6
|
+
License: MIT
|
7
|
+
Requires-Python: >=3.9
|
8
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
9
|
+
Project-URL: Source Code, https://github.com/shaw-yu2020/thermolib
|
10
|
+
|
11
|
+
|
12
|
+
thermolib
|
13
|
+
=========
|
14
|
+
|
15
|
+
An open-source library for the calculation of fluid properties.
|
16
|
+
|
17
|
+
# Cubic EOS {Vdw, Rk, Srk, Pr}
|
18
|
+
|
19
|
+
| Flash Calculation | Get Corresponding Properties |
|
20
|
+
| :---: | :---: |
|
21
|
+
| `t_flash(Ts)` | `T_s()` <br> `p_s()` <br> `rho_v()` <br> `rho_l()` <br> |
|
22
|
+
| `tp_flash(T,p)` | `T()` <br> `p()` <br> `rho()` <br> |
|
23
|
+
|
24
|
+
## Flash Calculation
|
25
|
+
|
26
|
+
```rust
|
27
|
+
use thermolib::{Vdw, Rk, Srk, Pr};
|
28
|
+
let crit_t = 430.64; // critical temperature of sulfur dioxide // K
|
29
|
+
let crit_p = 7886600.0; // critical pressure of sulfur dioxide // Pa
|
30
|
+
let acentric_factor = 0.256;
|
31
|
+
let mut fluid_vdw = Vdw::new_fluid(crit_t, crit_p);
|
32
|
+
let mut fluid_rk = Rk::new_fluid(crit_t, crit_p);
|
33
|
+
let mut fluid_srk = Srk::new_fluid(crit_t, crit_p, acentric_factor);
|
34
|
+
let mut fluid_pr = Pr::new_fluid(crit_t, crit_p, acentric_factor);
|
35
|
+
```
|
36
|
+
|
37
|
+
```python
|
38
|
+
from thermolib import Vdw, Rk, Srk, Pr
|
39
|
+
TC = 430.64
|
40
|
+
PC = 7886600
|
41
|
+
OMEGA = 0.256
|
42
|
+
fluid_vdw = Vdw(TC, PC)
|
43
|
+
fluid_rk = Rk(TC, PC)
|
44
|
+
fluid_srk = Srk(TC, PC, OMEGA)
|
45
|
+
fluid_pr = Pr(TC, PC, OMEGA)
|
46
|
+
```
|
47
|
+
|
48
|
+
## Get Corresponding Properties
|
49
|
+
|
50
|
+
```rust
|
51
|
+
if let Ok(_) = fluid.t_flash(273.15) {
|
52
|
+
println!("T_s={}", fluid.T_s().unwrap());
|
53
|
+
println!("p_s={}", fluid.p_s().unwrap());
|
54
|
+
println!("rho_v={}", fluid.rho_v().unwrap());
|
55
|
+
println!("rho_l={}", fluid.rho_l().unwrap());
|
56
|
+
}
|
57
|
+
fluid.tp_flash(273.15, 0.1e6);
|
58
|
+
println!("T={}", fluid.T().unwrap());
|
59
|
+
println!("p={}", fluid.p().unwrap());
|
60
|
+
println!("rho={}", fluid.rho().unwrap());
|
61
|
+
```
|
62
|
+
|
63
|
+
```python
|
64
|
+
fluid.t_flash(273.15)
|
65
|
+
print("T_s =", fluid.T_s())
|
66
|
+
print("p_s =", fluid.p_s())
|
67
|
+
print("rho_v =", fluid.rho_v())
|
68
|
+
print("rho_l =", fluid.rho_l())
|
69
|
+
SO2.tp_flash(273.15, 0.1e6)
|
70
|
+
print("T =", fluid.T())
|
71
|
+
print("p =", fluid.p())
|
72
|
+
print("rho =", fluid.rho())
|
73
|
+
```
|
74
|
+
|
75
|
+
# Helmholtz
|
76
|
+
|
77
|
+
| Flash Calculation | Get Corresponding Properties |
|
78
|
+
| :---: | :---: |
|
79
|
+
| `t_flash(Ts)` | `T_s()` <br> `p_s()` <br> `rho_v()` <br> `rho_l()` <br> |
|
80
|
+
| `tp_flash(T,p)` | `T()` <br> `p()` <br> `rho()` <br> `cv()` <br> `cp()` <br> `w()` <br> |
|
81
|
+
|
82
|
+
```rust
|
83
|
+
use thermolib::Helmholtz;
|
84
|
+
|
85
|
+
let mut SO2 = Helmholtz::read_json("SO2.json").expect("no SO2.json");
|
86
|
+
|
87
|
+
if let Ok(_) = SO2.t_flash(273.15) {
|
88
|
+
println!("T_s={}", SO2.T_s().unwrap()); // temperature = 273.15 K
|
89
|
+
println!("p_s={}", SO2.p_s().unwrap()); // pressure = 0.15549e6 Pa
|
90
|
+
println!("rho_v={}", SO2.rho_v().unwrap()); // vapor density = 71.106 mol/m3
|
91
|
+
println!("rho_l={}", SO2.rho_l().unwrap()); // liquid density = 22403 mol/m3
|
92
|
+
}
|
93
|
+
|
94
|
+
if let Ok(_) = SO2.tp_flash(273.15, 0.1e6) {
|
95
|
+
println!("T={}", SO2.T().unwrap()); // temperature = 273.15 K
|
96
|
+
println!("p={}", SO2.p().unwrap()); // pressure = 0.1e6 Pa
|
97
|
+
println!("rho={}", SO2.rho().unwrap()); // density = 45.093 mol/m3
|
98
|
+
println!("cv={}", SO2.cv().unwrap()); // isochoric heat capacity = 31.953 J/mol/K
|
99
|
+
println!("cp={}", SO2.cp().unwrap()); // isobaric heat capacity = 41.477 J/mol/K
|
100
|
+
println!("w={}", SO2.w().unwrap()); // speed of sound = 209.41 m/s
|
101
|
+
}
|
102
|
+
|
103
|
+
```
|
104
|
+
|
105
|
+
```python
|
106
|
+
from thermolib import Helmholtz
|
107
|
+
|
108
|
+
SO2 = Helmholtz("SO2.json")
|
109
|
+
|
110
|
+
SO2.t_flash(273.15)
|
111
|
+
print("T_s =", SO2.T_s()) # temperature = 273.15 K
|
112
|
+
print("p_s =", SO2.p_s()) # pressure = 0.15549e6 Pa
|
113
|
+
print("rho_v =", SO2.rho_v()) # vapor density = 71.106 mol/m3
|
114
|
+
print("rho_l =", SO2.rho_l()) # liquid density = 22403 mol/m3
|
115
|
+
|
116
|
+
SO2.tp_flash(273.15, 0.1e6)
|
117
|
+
print("T =", SO2.T()) # temperature = 273.15 K
|
118
|
+
print("p =", SO2.p()) # pressure = 0.1e6 Pa
|
119
|
+
print("rho =", SO2.rho()) # density = 45.093 mol/m3
|
120
|
+
print("cv =", SO2.cv()) # isochoric heat capacity = 31.953 J/mol/K
|
121
|
+
print("cp =", SO2.cp()) # isobaric heat capacity = 41.477 J/mol/K
|
122
|
+
print("w =", SO2.w()) # speed of sound = 209.41 m/s
|
123
|
+
|
124
|
+
```
|
125
|
+
|
126
|
+
# LiquidMetal
|
127
|
+
|
128
|
+
| Function | Unit |
|
129
|
+
| :---: | :---: |
|
130
|
+
| `calc_rho(T)` | `kg/m^3` |
|
131
|
+
| `calc_eta(T)` | `mPa*s` |
|
132
|
+
| `calc_lambda(T)` | `W/m/K` |
|
133
|
+
|
134
|
+
```rust
|
135
|
+
use thermolib::LiquidMetal;
|
136
|
+
|
137
|
+
if let Ok(metal) = LiquidMetal::new_metal("Si") {
|
138
|
+
println!("rho = {}", metal.calc_rho(1800.0).unwrap()); // 2520 kg/m3
|
139
|
+
println!("eta = {}", metal.calc_eta(1800.0).unwrap()); // 0.541 mPa*s
|
140
|
+
println!("lambda = {}", metal.calc_lambda(1800.0).unwrap()); // 54.88 W/m/K
|
141
|
+
}
|
142
|
+
|
143
|
+
```
|
144
|
+
|
145
|
+
```python
|
146
|
+
from thermolib import LiquidMetal
|
147
|
+
|
148
|
+
metal = LiquidMetal("Si")
|
149
|
+
print("rho =", metal.calc_rho(1800)) # 2520 kg/m3
|
150
|
+
print("eta =", metal.calc_eta(1800)) # 0.541 mPa*s
|
151
|
+
print("lambda =", metal.calc_lambda(1800)) # 54.88 W/m/K
|
152
|
+
|
153
|
+
```
|
154
|
+
|
155
|
+
# PcSaftPure
|
156
|
+
|
157
|
+
| Flash Calculation | Get Corresponding Properties |
|
158
|
+
| :---: | :---: |
|
159
|
+
| `c_flash()` | `T()` <br> `p()` <br> `rho()` <br> |
|
160
|
+
| `t_flash(Ts)` | `T_s()` <br> `p_s()` <br> `rho_v()` <br> `rho_l()` <br> |
|
161
|
+
| `tp_flash(T,p)` | `T()` <br> `p()` <br> `rho()` <br> |
|
162
|
+
|
163
|
+
```rust
|
164
|
+
use thermolib::PcSaftPure;
|
165
|
+
|
166
|
+
let m = 2.8611;
|
167
|
+
let sigma = 2.6826;
|
168
|
+
let epsilon = 205.35;
|
169
|
+
let mut SO2 = PcSaftPure::new_fluid(m, sigma, epsilon);
|
170
|
+
|
171
|
+
if let Ok(_) = SO2.c_flash() {
|
172
|
+
println!("T_c={}", SO2.T().unwrap());
|
173
|
+
println!("p_c={}", SO2.p().unwrap());
|
174
|
+
println!("rho_c={}", SO2.rho().unwrap());
|
175
|
+
}
|
176
|
+
|
177
|
+
if let Ok(_) = SO2.t_flash(273.15) {
|
178
|
+
println!("T_s={}", SO2.T_s().unwrap());
|
179
|
+
println!("p_s={}", SO2.p_s().unwrap());
|
180
|
+
println!("rho_v={}", SO2.rho_v().unwrap());
|
181
|
+
println!("rho_l={}", SO2.rho_l().unwrap());
|
182
|
+
}
|
183
|
+
|
184
|
+
if let Ok(_) = SO2.tp_flash(273.15, 0.1e6) {
|
185
|
+
println!("T={}", SO2.T().unwrap());
|
186
|
+
println!("p={}", SO2.p().unwrap());
|
187
|
+
println!("rho={}", SO2.rho().unwrap());
|
188
|
+
}
|
189
|
+
|
190
|
+
```
|
191
|
+
|
192
|
+
```python
|
193
|
+
from thermolib import PcSaftPure
|
194
|
+
|
195
|
+
M = 2.8611 # m
|
196
|
+
S = 2.6826 # sigma
|
197
|
+
E = 205.35 # epsilon
|
198
|
+
SO2 = PcSaftPure(M, S, E)
|
199
|
+
|
200
|
+
SO2.c_flash()
|
201
|
+
print("T_c =", SO2.T())
|
202
|
+
print("p_c =", SO2.p())
|
203
|
+
print("rho_c =", SO2.rho())
|
204
|
+
|
205
|
+
SO2.t_flash(273.15)
|
206
|
+
print("T_s =", SO2.T_s())
|
207
|
+
print("p_s =", SO2.p_s())
|
208
|
+
print("rho_v =", SO2.rho_v())
|
209
|
+
print("rho_l =", SO2.rho_l())
|
210
|
+
|
211
|
+
SO2.tp_flash(273.15, 0.1e6)
|
212
|
+
print("T =", SO2.T())
|
213
|
+
print("p =", SO2.p())
|
214
|
+
print("rho =", SO2.rho())
|
215
|
+
|
216
|
+
```
|
217
|
+
|
218
|
+
|
@@ -0,0 +1,6 @@
|
|
1
|
+
thermolib-0.8.1.dist-info/METADATA,sha256=V77ryiZwpp1U_-qq8TXqHX2D3nYPw40kZVLaj15SLik,6249
|
2
|
+
thermolib-0.8.1.dist-info/WHEEL,sha256=Hn9bytZpOGoR6M4U5xUTHC1AJpPD9B1xPrM4STxljEU,94
|
3
|
+
thermolib-0.8.1.dist-info/licenses/LICENSE,sha256=JMhBNMt_3GAAIIcqErqRQ1NWmYkJ5jUYtlODoeypyoc,1087
|
4
|
+
thermolib/__init__.py,sha256=AqTZGT6qtkIxAEPPPLSzZvuCV9fSVKuGrR2c1oauKks,119
|
5
|
+
thermolib/thermolib.pyd,sha256=kTYrQ9BcmXmCHVSXuDKCdxosJOivUigHAor3gA-c2zM,1221632
|
6
|
+
thermolib-0.8.1.dist-info/RECORD,,
|
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2024 shaw-code
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|