thermolib 0.7.6__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.
Files changed (40) hide show
  1. thermolib-0.8.0/Cargo.lock +252 -0
  2. {thermolib-0.7.6 → thermolib-0.8.0}/Cargo.toml +1 -2
  3. {thermolib-0.7.6 → thermolib-0.8.0}/PKG-INFO +1 -1
  4. {thermolib-0.7.6 → thermolib-0.8.0}/src/helmholtz/alpha.rs +35 -28
  5. thermolib-0.8.0/src/ideal_gas.rs +56 -0
  6. {thermolib-0.7.6 → thermolib-0.8.0}/src/lib.rs +3 -0
  7. {thermolib-0.7.6 → thermolib-0.8.0}/src/liquid_metal.rs +15 -7
  8. {thermolib-0.7.6 → thermolib-0.8.0}/src/pc_saft.rs +165 -153
  9. {thermolib-0.7.6 → thermolib-0.8.0}/src/pr.rs +33 -25
  10. {thermolib-0.7.6 → thermolib-0.8.0}/src/python.rs +2 -0
  11. {thermolib-0.7.6 → thermolib-0.8.0}/src/rk.rs +32 -24
  12. {thermolib-0.7.6 → thermolib-0.8.0}/src/srk.rs +33 -25
  13. {thermolib-0.7.6 → thermolib-0.8.0}/src/vdw.rs +32 -24
  14. thermolib-0.7.6/Cargo.lock +0 -4125
  15. thermolib-0.7.6/src/bin/liquid_metal.rs +0 -100
  16. {thermolib-0.7.6 → thermolib-0.8.0}/.gitignore +0 -0
  17. {thermolib-0.7.6 → thermolib-0.8.0}/LICENSE +0 -0
  18. {thermolib-0.7.6 → thermolib-0.8.0}/README.md +0 -0
  19. {thermolib-0.7.6 → thermolib-0.8.0}/pyproject.toml +0 -0
  20. {thermolib-0.7.6 → thermolib-0.8.0}/res/22DimethylButane.json +0 -0
  21. {thermolib-0.7.6 → thermolib-0.8.0}/res/23DimethylButane.json +0 -0
  22. {thermolib-0.7.6 → thermolib-0.8.0}/res/3MethylPentane.json +0 -0
  23. {thermolib-0.7.6 → thermolib-0.8.0}/res/C4F10.json +0 -0
  24. {thermolib-0.7.6 → thermolib-0.8.0}/res/C5F12.json +0 -0
  25. {thermolib-0.7.6 → thermolib-0.8.0}/res/C6F14.json +0 -0
  26. {thermolib-0.7.6 → thermolib-0.8.0}/res/NH3.json +0 -0
  27. {thermolib-0.7.6 → thermolib-0.8.0}/res/SO2.json +0 -0
  28. {thermolib-0.7.6 → thermolib-0.8.0}/src/algorithms.rs +0 -0
  29. {thermolib-0.7.6 → thermolib-0.8.0}/src/helmholtz/alpha_i.rs +0 -0
  30. {thermolib-0.7.6 → thermolib-0.8.0}/src/helmholtz/alpha_r.rs +0 -0
  31. {thermolib-0.7.6 → thermolib-0.8.0}/src/helmholtz/anc_eqn.rs +0 -0
  32. {thermolib-0.7.6 → thermolib-0.8.0}/src/helmholtz/assoc.rs +0 -0
  33. {thermolib-0.7.6 → thermolib-0.8.0}/src/helmholtz/rho_ini.rs +0 -0
  34. {thermolib-0.7.6 → thermolib-0.8.0}/src/helmholtz.rs +0 -0
  35. {thermolib-0.7.6 → thermolib-0.8.0}/src/liquid_metal/eta.rs +0 -0
  36. {thermolib-0.7.6 → thermolib-0.8.0}/src/liquid_metal/lambda.rs +0 -0
  37. {thermolib-0.7.6 → thermolib-0.8.0}/src/liquid_metal/metals.md +0 -0
  38. {thermolib-0.7.6 → thermolib-0.8.0}/src/liquid_metal/rho.rs +0 -0
  39. {thermolib-0.7.6 → thermolib-0.8.0}/tests/plot_ceos.py +0 -0
  40. {thermolib-0.7.6 → thermolib-0.8.0}/tests/test_fluids.rs +0 -0
@@ -0,0 +1,252 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 3
4
+
5
+ [[package]]
6
+ name = "anyhow"
7
+ version = "1.0.95"
8
+ source = "registry+https://github.com/rust-lang/crates.io-index"
9
+ checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04"
10
+
11
+ [[package]]
12
+ name = "autocfg"
13
+ version = "1.4.0"
14
+ source = "registry+https://github.com/rust-lang/crates.io-index"
15
+ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
16
+
17
+ [[package]]
18
+ name = "cfg-if"
19
+ version = "1.0.0"
20
+ source = "registry+https://github.com/rust-lang/crates.io-index"
21
+ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
22
+
23
+ [[package]]
24
+ name = "heck"
25
+ version = "0.5.0"
26
+ source = "registry+https://github.com/rust-lang/crates.io-index"
27
+ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
28
+
29
+ [[package]]
30
+ name = "indoc"
31
+ version = "2.0.5"
32
+ source = "registry+https://github.com/rust-lang/crates.io-index"
33
+ checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5"
34
+
35
+ [[package]]
36
+ name = "itoa"
37
+ version = "1.0.14"
38
+ source = "registry+https://github.com/rust-lang/crates.io-index"
39
+ checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674"
40
+
41
+ [[package]]
42
+ name = "libc"
43
+ version = "0.2.169"
44
+ source = "registry+https://github.com/rust-lang/crates.io-index"
45
+ checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a"
46
+
47
+ [[package]]
48
+ name = "memchr"
49
+ version = "2.7.4"
50
+ source = "registry+https://github.com/rust-lang/crates.io-index"
51
+ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
52
+
53
+ [[package]]
54
+ name = "memoffset"
55
+ version = "0.9.1"
56
+ source = "registry+https://github.com/rust-lang/crates.io-index"
57
+ checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
58
+ dependencies = [
59
+ "autocfg",
60
+ ]
61
+
62
+ [[package]]
63
+ name = "once_cell"
64
+ version = "1.20.2"
65
+ source = "registry+https://github.com/rust-lang/crates.io-index"
66
+ checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
67
+
68
+ [[package]]
69
+ name = "portable-atomic"
70
+ version = "1.10.0"
71
+ source = "registry+https://github.com/rust-lang/crates.io-index"
72
+ checksum = "280dc24453071f1b63954171985a0b0d30058d287960968b9b2aca264c8d4ee6"
73
+
74
+ [[package]]
75
+ name = "proc-macro2"
76
+ version = "1.0.92"
77
+ source = "registry+https://github.com/rust-lang/crates.io-index"
78
+ checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0"
79
+ dependencies = [
80
+ "unicode-ident",
81
+ ]
82
+
83
+ [[package]]
84
+ name = "pyo3"
85
+ version = "0.22.6"
86
+ source = "registry+https://github.com/rust-lang/crates.io-index"
87
+ checksum = "f402062616ab18202ae8319da13fa4279883a2b8a9d9f83f20dbade813ce1884"
88
+ dependencies = [
89
+ "anyhow",
90
+ "cfg-if",
91
+ "indoc",
92
+ "libc",
93
+ "memoffset",
94
+ "once_cell",
95
+ "portable-atomic",
96
+ "pyo3-build-config",
97
+ "pyo3-ffi",
98
+ "pyo3-macros",
99
+ "unindent",
100
+ ]
101
+
102
+ [[package]]
103
+ name = "pyo3-build-config"
104
+ version = "0.22.6"
105
+ source = "registry+https://github.com/rust-lang/crates.io-index"
106
+ checksum = "b14b5775b5ff446dd1056212d778012cbe8a0fbffd368029fd9e25b514479c38"
107
+ dependencies = [
108
+ "once_cell",
109
+ "target-lexicon",
110
+ ]
111
+
112
+ [[package]]
113
+ name = "pyo3-ffi"
114
+ version = "0.22.6"
115
+ source = "registry+https://github.com/rust-lang/crates.io-index"
116
+ checksum = "9ab5bcf04a2cdcbb50c7d6105de943f543f9ed92af55818fd17b660390fc8636"
117
+ dependencies = [
118
+ "libc",
119
+ "pyo3-build-config",
120
+ ]
121
+
122
+ [[package]]
123
+ name = "pyo3-macros"
124
+ version = "0.22.6"
125
+ source = "registry+https://github.com/rust-lang/crates.io-index"
126
+ checksum = "0fd24d897903a9e6d80b968368a34e1525aeb719d568dba8b3d4bfa5dc67d453"
127
+ dependencies = [
128
+ "proc-macro2",
129
+ "pyo3-macros-backend",
130
+ "quote",
131
+ "syn",
132
+ ]
133
+
134
+ [[package]]
135
+ name = "pyo3-macros-backend"
136
+ version = "0.22.6"
137
+ source = "registry+https://github.com/rust-lang/crates.io-index"
138
+ checksum = "36c011a03ba1e50152b4b394b479826cad97e7a21eb52df179cd91ac411cbfbe"
139
+ dependencies = [
140
+ "heck",
141
+ "proc-macro2",
142
+ "pyo3-build-config",
143
+ "quote",
144
+ "syn",
145
+ ]
146
+
147
+ [[package]]
148
+ name = "quote"
149
+ version = "1.0.38"
150
+ source = "registry+https://github.com/rust-lang/crates.io-index"
151
+ checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc"
152
+ dependencies = [
153
+ "proc-macro2",
154
+ ]
155
+
156
+ [[package]]
157
+ name = "ryu"
158
+ version = "1.0.18"
159
+ source = "registry+https://github.com/rust-lang/crates.io-index"
160
+ checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
161
+
162
+ [[package]]
163
+ name = "serde"
164
+ version = "1.0.217"
165
+ source = "registry+https://github.com/rust-lang/crates.io-index"
166
+ checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70"
167
+ dependencies = [
168
+ "serde_derive",
169
+ ]
170
+
171
+ [[package]]
172
+ name = "serde_derive"
173
+ version = "1.0.217"
174
+ source = "registry+https://github.com/rust-lang/crates.io-index"
175
+ checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0"
176
+ dependencies = [
177
+ "proc-macro2",
178
+ "quote",
179
+ "syn",
180
+ ]
181
+
182
+ [[package]]
183
+ name = "serde_json"
184
+ version = "1.0.134"
185
+ source = "registry+https://github.com/rust-lang/crates.io-index"
186
+ checksum = "d00f4175c42ee48b15416f6193a959ba3a0d67fc699a0db9ad12df9f83991c7d"
187
+ dependencies = [
188
+ "itoa",
189
+ "memchr",
190
+ "ryu",
191
+ "serde",
192
+ ]
193
+
194
+ [[package]]
195
+ name = "syn"
196
+ version = "2.0.93"
197
+ source = "registry+https://github.com/rust-lang/crates.io-index"
198
+ checksum = "9c786062daee0d6db1132800e623df74274a0a87322d8e183338e01b3d98d058"
199
+ dependencies = [
200
+ "proc-macro2",
201
+ "quote",
202
+ "unicode-ident",
203
+ ]
204
+
205
+ [[package]]
206
+ name = "target-lexicon"
207
+ version = "0.12.16"
208
+ source = "registry+https://github.com/rust-lang/crates.io-index"
209
+ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
210
+
211
+ [[package]]
212
+ name = "thermolib"
213
+ version = "0.8.0"
214
+ dependencies = [
215
+ "anyhow",
216
+ "pyo3",
217
+ "serde",
218
+ "serde_json",
219
+ "thiserror",
220
+ ]
221
+
222
+ [[package]]
223
+ name = "thiserror"
224
+ version = "1.0.69"
225
+ source = "registry+https://github.com/rust-lang/crates.io-index"
226
+ checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
227
+ dependencies = [
228
+ "thiserror-impl",
229
+ ]
230
+
231
+ [[package]]
232
+ name = "thiserror-impl"
233
+ version = "1.0.69"
234
+ source = "registry+https://github.com/rust-lang/crates.io-index"
235
+ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
236
+ dependencies = [
237
+ "proc-macro2",
238
+ "quote",
239
+ "syn",
240
+ ]
241
+
242
+ [[package]]
243
+ name = "unicode-ident"
244
+ version = "1.0.14"
245
+ source = "registry+https://github.com/rust-lang/crates.io-index"
246
+ checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
247
+
248
+ [[package]]
249
+ name = "unindent"
250
+ version = "0.2.3"
251
+ source = "registry+https://github.com/rust-lang/crates.io-index"
252
+ checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce"
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "thermolib"
3
- version = "0.7.6"
3
+ version = "0.8.0"
4
4
  edition = "2021"
5
5
  license = "MIT"
6
6
  description = "An open-source library for the calculation of fluid properties"
@@ -11,7 +11,6 @@ repository = "https://github.com/shaw-yu2020/thermolib"
11
11
  [dependencies]
12
12
  anyhow = "1.0"
13
13
  thiserror = "1.0"
14
- eframe = "0.27.2"
15
14
  serde_json = "1.0.110"
16
15
 
17
16
  [dependencies.serde]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: thermolib
3
- Version: 0.7.6
3
+ Version: 0.8.0
4
4
  License-File: LICENSE
5
5
  Summary: An open-source library for the calculation of fluid properties
6
6
  License: MIT
@@ -3,6 +3,7 @@ use super::{HelmholtzErr, Phase};
3
3
  use super::{IdealHelmholtz, ResidualHelmholtz};
4
4
  use super::{PsEqn, RholEqn, RhovEqn};
5
5
  use anyhow::anyhow;
6
+ #[cfg(feature = "with_pyo3")]
6
7
  use pyo3::{pyclass, pymethods};
7
8
  use serde::{Deserialize, Serialize};
8
9
  /// Helmholtz EOS
@@ -26,7 +27,7 @@ use serde::{Deserialize, Serialize};
26
27
  /// assert_eq!(96.51, (SO2.s().unwrap() * 1e2).round() / 1e2);
27
28
  /// }
28
29
  /// ```
29
- #[pyclass]
30
+ #[cfg_attr(feature = "with_pyo3", pyclass)]
30
31
  #[derive(Debug, Deserialize, Serialize)]
31
32
  #[allow(non_snake_case)]
32
33
  pub struct Helmholtz {
@@ -44,6 +45,35 @@ pub struct Helmholtz {
44
45
  #[serde(skip, default)]
45
46
  phase: Phase,
46
47
  }
48
+ impl Helmholtz {
49
+ /// read helmholtz equation of state from fluid.json file
50
+ pub fn read_json(path: &str) -> anyhow::Result<Helmholtz> {
51
+ let mut file_json: Option<std::fs::File>;
52
+ file_json = match std::fs::File::open(std::path::Path::new(path)) {
53
+ Ok(file) => Some(file),
54
+ Err(_) => None,
55
+ };
56
+ if file_json.is_none() {
57
+ file_json = match std::fs::File::open(
58
+ std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
59
+ .join("res")
60
+ .join(path),
61
+ ) {
62
+ Ok(file) => Some(file),
63
+ Err(_) => None,
64
+ };
65
+ };
66
+ let mut file_json = file_json.ok_or(anyhow!(HelmholtzErr::NoJson))?;
67
+ let mut str_json = String::new();
68
+ let _ = std::io::Read::read_to_string(&mut file_json, &mut str_json);
69
+ let eos: Option<Helmholtz> = match serde_json::from_str(&str_json) {
70
+ Ok(eos) => Some(eos),
71
+ Err(_) => None,
72
+ };
73
+ let eos = eos.ok_or(anyhow!(HelmholtzErr::NoHelmholtz))?;
74
+ Ok(eos)
75
+ }
76
+ }
47
77
  #[allow(non_snake_case)]
48
78
  impl Helmholtz {
49
79
  fn calc_p(&self, T: f64, rho: f64) -> f64 {
@@ -119,36 +149,13 @@ impl Helmholtz {
119
149
  / delta
120
150
  }
121
151
  }
122
- #[pymethods]
152
+ #[cfg_attr(feature = "with_pyo3", pymethods)]
123
153
  #[allow(non_snake_case)]
124
154
  impl Helmholtz {
125
- /// read helmholtz equation of state from fluid.json file
155
+ #[cfg(feature = "with_pyo3")]
126
156
  #[new]
127
- pub fn read_json(path: &str) -> anyhow::Result<Helmholtz> {
128
- let mut file_json: Option<std::fs::File>;
129
- file_json = match std::fs::File::open(std::path::Path::new(path)) {
130
- Ok(file) => Some(file),
131
- Err(_) => None,
132
- };
133
- if file_json.is_none() {
134
- file_json = match std::fs::File::open(
135
- std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
136
- .join("res")
137
- .join(path),
138
- ) {
139
- Ok(file) => Some(file),
140
- Err(_) => None,
141
- };
142
- };
143
- let mut file_json = file_json.ok_or(anyhow!(HelmholtzErr::NoJson))?;
144
- let mut str_json = String::new();
145
- let _ = std::io::Read::read_to_string(&mut file_json, &mut str_json);
146
- let eos: Option<Helmholtz> = match serde_json::from_str(&str_json) {
147
- Ok(eos) => Some(eos),
148
- Err(_) => None,
149
- };
150
- let eos = eos.ok_or(anyhow!(HelmholtzErr::NoHelmholtz))?;
151
- Ok(eos)
157
+ pub fn new_py(path: &str) -> anyhow::Result<Helmholtz> {
158
+ Self::read_json(path)
152
159
  }
153
160
  pub fn set_molar_unit(&mut self) {
154
161
  if self.R > 10.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
@@ -32,3 +32,6 @@ pub use liquid_metal::LiquidMetal;
32
32
  /// PC-SAFT EOS
33
33
  mod pc_saft;
34
34
  pub use pc_saft::PcSaftPure;
35
+ /// Ideal Gas
36
+ mod ideal_gas;
37
+ pub use ideal_gas::IdealGas;
@@ -1,7 +1,5 @@
1
- use anyhow::anyhow;
1
+ #[cfg(feature = "with_pyo3")]
2
2
  use pyo3::{pyclass, pymethods};
3
- use std::collections::HashMap;
4
- use std::sync::OnceLock;
5
3
  use thiserror::Error;
6
4
  #[derive(Debug, Error)]
7
5
  enum LiquidMetalErr {
@@ -17,9 +15,12 @@ enum LiquidMetalErr {
17
15
  mod eta;
18
16
  mod lambda;
19
17
  mod rho;
18
+ use anyhow::anyhow;
20
19
  use eta::metals2etaparams;
21
20
  use lambda::metals2lambdaparams;
22
21
  use rho::metals2rhoparams;
22
+ use std::collections::HashMap;
23
+ use std::sync::OnceLock;
23
24
  /// liquid metal
24
25
  /// + Density, unit: kg/m3
25
26
  /// + Thermal Conductivity, unit: W/m/K
@@ -35,15 +36,13 @@ use rho::metals2rhoparams;
35
36
  /// let lambda = metal.calc_lambda(T).unwrap(); // W/m/K
36
37
  /// assert_eq!(54.88, (lambda * 1e2).round() / 1e2);
37
38
  /// ```
38
- #[pyclass]
39
+ #[cfg_attr(feature = "with_pyo3", pyclass)]
39
40
  #[allow(non_snake_case)]
40
41
  pub struct LiquidMetal {
41
42
  metal: Metals,
42
43
  }
43
- #[pymethods]
44
- #[allow(non_snake_case)]
45
44
  impl LiquidMetal {
46
- #[new]
45
+ #[allow(non_snake_case)]
47
46
  pub fn new_metal(name: &str) -> anyhow::Result<LiquidMetal> {
48
47
  if let Some(metal) = string2metals().get(name) {
49
48
  Ok(Self {
@@ -53,6 +52,15 @@ impl LiquidMetal {
53
52
  Err(anyhow!(LiquidMetalErr::NoLiquidMetal))
54
53
  }
55
54
  }
55
+ }
56
+ #[cfg_attr(feature = "with_pyo3", pymethods)]
57
+ #[allow(non_snake_case)]
58
+ impl LiquidMetal {
59
+ #[cfg(feature = "with_pyo3")]
60
+ #[new]
61
+ pub fn new_py(name: &str) -> anyhow::Result<LiquidMetal> {
62
+ Self::new_metal(name)
63
+ }
56
64
  /// calculate density of liquid metals at 0.1 MPa, unit: kg/m3
57
65
  pub fn calc_rho(&self, T: f64) -> anyhow::Result<f64> {
58
66
  if let Some(rho_params) = metals2rhoparams().get(&self.metal) {