thermolib 0.8.0__tar.gz → 0.9.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 (54) hide show
  1. {thermolib-0.8.0 → thermolib-0.9.0}/Cargo.lock +40 -76
  2. thermolib-0.9.0/Cargo.toml +23 -0
  3. {thermolib-0.8.0 → thermolib-0.9.0}/LICENSE +1 -1
  4. thermolib-0.9.0/PKG-INFO +17 -0
  5. thermolib-0.9.0/README.md +6 -0
  6. thermolib-0.9.0/scripts/algorithms/brent_zero.py +79 -0
  7. thermolib-0.9.0/scripts/pc_saft/c_term.md +16 -0
  8. thermolib-0.9.0/scripts/pc_saft/c_term.py +48 -0
  9. thermolib-0.9.0/scripts/pc_saft/x_term.md +30 -0
  10. thermolib-0.9.0/scripts/pc_saft/x_term.py +93 -0
  11. {thermolib-0.8.0 → thermolib-0.9.0}/src/algorithms.rs +10 -11
  12. thermolib-0.9.0/src/lib.rs +21 -0
  13. thermolib-0.9.0/src/pc_saft/disp_term.rs +810 -0
  14. thermolib-0.9.0/src/pc_saft/gii_term.rs +110 -0
  15. thermolib-0.9.0/src/pc_saft/hs_term.rs +81 -0
  16. thermolib-0.9.0/src/pc_saft/macros.rs +684 -0
  17. thermolib-0.9.0/src/pc_saft/pc_saft_gly.rs +946 -0
  18. thermolib-0.9.0/src/pc_saft.rs +44 -0
  19. thermolib-0.9.0/src/python.rs +15 -0
  20. thermolib-0.8.0/Cargo.toml +0 -30
  21. thermolib-0.8.0/PKG-INFO +0 -303
  22. thermolib-0.8.0/README.md +0 -292
  23. thermolib-0.8.0/res/22DimethylButane.json +0 -285
  24. thermolib-0.8.0/res/23DimethylButane.json +0 -276
  25. thermolib-0.8.0/res/3MethylPentane.json +0 -289
  26. thermolib-0.8.0/res/C4F10.json +0 -269
  27. thermolib-0.8.0/res/C5F12.json +0 -270
  28. thermolib-0.8.0/res/C6F14.json +0 -270
  29. thermolib-0.8.0/res/NH3.json +0 -445
  30. thermolib-0.8.0/res/SO2.json +0 -279
  31. thermolib-0.8.0/src/helmholtz/alpha.rs +0 -373
  32. thermolib-0.8.0/src/helmholtz/alpha_i.rs +0 -107
  33. thermolib-0.8.0/src/helmholtz/alpha_r.rs +0 -253
  34. thermolib-0.8.0/src/helmholtz/anc_eqn.rs +0 -77
  35. thermolib-0.8.0/src/helmholtz/assoc.rs +0 -71
  36. thermolib-0.8.0/src/helmholtz/rho_ini.rs +0 -44
  37. thermolib-0.8.0/src/helmholtz.rs +0 -49
  38. thermolib-0.8.0/src/ideal_gas.rs +0 -56
  39. thermolib-0.8.0/src/lib.rs +0 -37
  40. thermolib-0.8.0/src/liquid_metal/eta.rs +0 -201
  41. thermolib-0.8.0/src/liquid_metal/lambda.rs +0 -241
  42. thermolib-0.8.0/src/liquid_metal/metals.md +0 -34
  43. thermolib-0.8.0/src/liquid_metal/rho.rs +0 -281
  44. thermolib-0.8.0/src/liquid_metal.rs +0 -152
  45. thermolib-0.8.0/src/pc_saft.rs +0 -2015
  46. thermolib-0.8.0/src/pr.rs +0 -259
  47. thermolib-0.8.0/src/python.rs +0 -29
  48. thermolib-0.8.0/src/rk.rs +0 -249
  49. thermolib-0.8.0/src/srk.rs +0 -254
  50. thermolib-0.8.0/src/vdw.rs +0 -250
  51. thermolib-0.8.0/tests/plot_ceos.py +0 -119
  52. thermolib-0.8.0/tests/test_fluids.rs +0 -105
  53. {thermolib-0.8.0 → thermolib-0.9.0}/.gitignore +0 -0
  54. {thermolib-0.8.0 → thermolib-0.9.0}/pyproject.toml +0 -0
@@ -1,12 +1,12 @@
1
1
  # This file is automatically @generated by Cargo.
2
2
  # It is not intended for manual editing.
3
- version = 3
3
+ version = 4
4
4
 
5
5
  [[package]]
6
6
  name = "anyhow"
7
- version = "1.0.95"
7
+ version = "1.0.96"
8
8
  source = "registry+https://github.com/rust-lang/crates.io-index"
9
- checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04"
9
+ checksum = "6b964d184e89d9b6b67dd2715bc8e74cf3107fb2b529990c90cf517326150bf4"
10
10
 
11
11
  [[package]]
12
12
  name = "autocfg"
@@ -33,22 +33,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
33
33
  checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5"
34
34
 
35
35
  [[package]]
36
- name = "itoa"
37
- version = "1.0.14"
36
+ name = "inventory"
37
+ version = "0.3.19"
38
38
  source = "registry+https://github.com/rust-lang/crates.io-index"
39
- checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674"
39
+ checksum = "54b12ebb6799019b044deaf431eadfe23245b259bba5a2c0796acec3943a3cdb"
40
+ dependencies = [
41
+ "rustversion",
42
+ ]
40
43
 
41
44
  [[package]]
42
45
  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"
46
+ version = "0.2.170"
50
47
  source = "registry+https://github.com/rust-lang/crates.io-index"
51
- checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
48
+ checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828"
52
49
 
53
50
  [[package]]
54
51
  name = "memoffset"
@@ -61,34 +58,35 @@ dependencies = [
61
58
 
62
59
  [[package]]
63
60
  name = "once_cell"
64
- version = "1.20.2"
61
+ version = "1.20.3"
65
62
  source = "registry+https://github.com/rust-lang/crates.io-index"
66
- checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
63
+ checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e"
67
64
 
68
65
  [[package]]
69
66
  name = "portable-atomic"
70
- version = "1.10.0"
67
+ version = "1.11.0"
71
68
  source = "registry+https://github.com/rust-lang/crates.io-index"
72
- checksum = "280dc24453071f1b63954171985a0b0d30058d287960968b9b2aca264c8d4ee6"
69
+ checksum = "350e9b48cbc6b0e028b0473b114454c6316e57336ee184ceab6e53f72c178b3e"
73
70
 
74
71
  [[package]]
75
72
  name = "proc-macro2"
76
- version = "1.0.92"
73
+ version = "1.0.93"
77
74
  source = "registry+https://github.com/rust-lang/crates.io-index"
78
- checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0"
75
+ checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99"
79
76
  dependencies = [
80
77
  "unicode-ident",
81
78
  ]
82
79
 
83
80
  [[package]]
84
81
  name = "pyo3"
85
- version = "0.22.6"
82
+ version = "0.23.5"
86
83
  source = "registry+https://github.com/rust-lang/crates.io-index"
87
- checksum = "f402062616ab18202ae8319da13fa4279883a2b8a9d9f83f20dbade813ce1884"
84
+ checksum = "7778bffd85cf38175ac1f545509665d0b9b92a198ca7941f131f85f7a4f9a872"
88
85
  dependencies = [
89
86
  "anyhow",
90
87
  "cfg-if",
91
88
  "indoc",
89
+ "inventory",
92
90
  "libc",
93
91
  "memoffset",
94
92
  "once_cell",
@@ -101,9 +99,9 @@ dependencies = [
101
99
 
102
100
  [[package]]
103
101
  name = "pyo3-build-config"
104
- version = "0.22.6"
102
+ version = "0.23.5"
105
103
  source = "registry+https://github.com/rust-lang/crates.io-index"
106
- checksum = "b14b5775b5ff446dd1056212d778012cbe8a0fbffd368029fd9e25b514479c38"
104
+ checksum = "94f6cbe86ef3bf18998d9df6e0f3fc1050a8c5efa409bf712e661a4366e010fb"
107
105
  dependencies = [
108
106
  "once_cell",
109
107
  "target-lexicon",
@@ -111,9 +109,9 @@ dependencies = [
111
109
 
112
110
  [[package]]
113
111
  name = "pyo3-ffi"
114
- version = "0.22.6"
112
+ version = "0.23.5"
115
113
  source = "registry+https://github.com/rust-lang/crates.io-index"
116
- checksum = "9ab5bcf04a2cdcbb50c7d6105de943f543f9ed92af55818fd17b660390fc8636"
114
+ checksum = "e9f1b4c431c0bb1c8fb0a338709859eed0d030ff6daa34368d3b152a63dfdd8d"
117
115
  dependencies = [
118
116
  "libc",
119
117
  "pyo3-build-config",
@@ -121,9 +119,9 @@ dependencies = [
121
119
 
122
120
  [[package]]
123
121
  name = "pyo3-macros"
124
- version = "0.22.6"
122
+ version = "0.23.5"
125
123
  source = "registry+https://github.com/rust-lang/crates.io-index"
126
- checksum = "0fd24d897903a9e6d80b968368a34e1525aeb719d568dba8b3d4bfa5dc67d453"
124
+ checksum = "fbc2201328f63c4710f68abdf653c89d8dbc2858b88c5d88b0ff38a75288a9da"
127
125
  dependencies = [
128
126
  "proc-macro2",
129
127
  "pyo3-macros-backend",
@@ -133,9 +131,9 @@ dependencies = [
133
131
 
134
132
  [[package]]
135
133
  name = "pyo3-macros-backend"
136
- version = "0.22.6"
134
+ version = "0.23.5"
137
135
  source = "registry+https://github.com/rust-lang/crates.io-index"
138
- checksum = "36c011a03ba1e50152b4b394b479826cad97e7a21eb52df179cd91ac411cbfbe"
136
+ checksum = "fca6726ad0f3da9c9de093d6f116a93c1a38e417ed73bf138472cf4064f72028"
139
137
  dependencies = [
140
138
  "heck",
141
139
  "proc-macro2",
@@ -154,48 +152,16 @@ dependencies = [
154
152
  ]
155
153
 
156
154
  [[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"
155
+ name = "rustversion"
156
+ version = "1.0.19"
165
157
  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
- ]
158
+ checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4"
193
159
 
194
160
  [[package]]
195
161
  name = "syn"
196
- version = "2.0.93"
162
+ version = "2.0.98"
197
163
  source = "registry+https://github.com/rust-lang/crates.io-index"
198
- checksum = "9c786062daee0d6db1132800e623df74274a0a87322d8e183338e01b3d98d058"
164
+ checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1"
199
165
  dependencies = [
200
166
  "proc-macro2",
201
167
  "quote",
@@ -210,29 +176,27 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
210
176
 
211
177
  [[package]]
212
178
  name = "thermolib"
213
- version = "0.8.0"
179
+ version = "0.9.0"
214
180
  dependencies = [
215
181
  "anyhow",
216
182
  "pyo3",
217
- "serde",
218
- "serde_json",
219
183
  "thiserror",
220
184
  ]
221
185
 
222
186
  [[package]]
223
187
  name = "thiserror"
224
- version = "1.0.69"
188
+ version = "2.0.11"
225
189
  source = "registry+https://github.com/rust-lang/crates.io-index"
226
- checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
190
+ checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc"
227
191
  dependencies = [
228
192
  "thiserror-impl",
229
193
  ]
230
194
 
231
195
  [[package]]
232
196
  name = "thiserror-impl"
233
- version = "1.0.69"
197
+ version = "2.0.11"
234
198
  source = "registry+https://github.com/rust-lang/crates.io-index"
235
- checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
199
+ checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2"
236
200
  dependencies = [
237
201
  "proc-macro2",
238
202
  "quote",
@@ -241,9 +205,9 @@ dependencies = [
241
205
 
242
206
  [[package]]
243
207
  name = "unicode-ident"
244
- version = "1.0.14"
208
+ version = "1.0.17"
245
209
  source = "registry+https://github.com/rust-lang/crates.io-index"
246
- checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
210
+ checksum = "00e2473a93778eb0bad35909dff6a10d28e63f792f16ed15e404fca9d5eeedbe"
247
211
 
248
212
  [[package]]
249
213
  name = "unindent"
@@ -0,0 +1,23 @@
1
+ [package]
2
+ name = "thermolib"
3
+ version = "0.9.0"
4
+ edition = "2024"
5
+ license = "MIT"
6
+ description = "An open-source library for the calculation of fluid properties."
7
+ repository = "https://github.com/shaw-yu2020/thermolib"
8
+
9
+ [dependencies]
10
+ anyhow = "1.0"
11
+ thiserror = "2.0"
12
+
13
+ [dependencies.pyo3]
14
+ version = "0.23.5"
15
+ features = ["multiple-pymethods", "extension-module", "abi3-py39", "anyhow"]
16
+
17
+ [lib]
18
+ name = "thermolib"
19
+ crate-type = ["cdylib" ,"rlib"]
20
+
21
+ [features]
22
+ with_pyo3 = []
23
+
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 shaw-code
3
+ Copyright (c) 2025 shaw
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -0,0 +1,17 @@
1
+ Metadata-Version: 2.3
2
+ Name: thermolib
3
+ Version: 0.9.0
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
+
@@ -0,0 +1,6 @@
1
+
2
+ thermolib
3
+ =========
4
+
5
+ An open-source library for the calculation of fluid properties.
6
+
@@ -0,0 +1,79 @@
1
+ """brent_zero"""
2
+
3
+ import sys
4
+ import numpy as np
5
+
6
+
7
+ EPS = np.sqrt(sys.float_info.epsilon)
8
+
9
+
10
+ def brent_zero(f, a, b): # pylint: disable=R0912
11
+ """brent_zero"""
12
+ (fa, fb) = (f(a), f(b))
13
+ (c, fc) = (a, fa)
14
+ d = b - a
15
+ e = b - a
16
+ while True:
17
+ if abs(fc) < abs(fb):
18
+ (a, fa) = (b, fb)
19
+ (b, fb) = (c, fc)
20
+ (c, fc) = (a, fa)
21
+ tol = 2.0 * EPS * abs(b) + 10 * EPS
22
+ m = 0.5 * (c - b)
23
+ if abs(m) <= tol or fb == 0.0:
24
+ break
25
+ if abs(e) < tol or abs(fa) <= abs(fb):
26
+ e = m
27
+ d = e
28
+ else:
29
+ s = fb / fa
30
+ if a == c:
31
+ p = 2.0 * m * s
32
+ q = 1.0 - s
33
+ else:
34
+ q = fa / fc
35
+ r = fb / fc
36
+ p = s * (2.0 * m * q * (q - r) - (b - a) * (r - 1.0))
37
+ q = (q - 1.0) * (r - 1.0) * (s - 1.0)
38
+ if 0.0 < p:
39
+ q = -q
40
+ else:
41
+ p = -p
42
+ s = e
43
+ e = d
44
+ if 2.0 * p < 3.0 * m * q - abs(tol * q) and p < abs(0.5 * s * q):
45
+ d = p / q
46
+ else:
47
+ e = m
48
+ d = e
49
+ (a, fa) = (b, fb)
50
+ if tol < abs(d):
51
+ b = b + d
52
+ elif 0.0 < m:
53
+ b = b + tol
54
+ else:
55
+ b = b - tol
56
+ fb = f(b)
57
+ if (0.0 < fb and 0.0 < fc) or (fb <= 0.0 and fc <= 0.0):
58
+ (c, fc) = (a, fa)
59
+ e = b - a
60
+ d = e
61
+ return b
62
+
63
+
64
+ def main():
65
+ """main"""
66
+ print("f(x) = sin(x) - x / 2")
67
+ print(f"x = {brent_zero(lambda x: np.sin(x) - x / 2, 1.0, 2.0):.10e}")
68
+ print("f(x) = 2 * x - exp(-x)")
69
+ print(f"x = {brent_zero(lambda x: 2 * x - np.exp(-x), 0.0, 1.0):.10e}")
70
+ print("f(x) = x * exp(-x)")
71
+ print(f"x = { brent_zero(lambda x: x * np.exp(-x), -1.0, 0.5):.10e}")
72
+ print("f(x) = exp(x) - 1 / 100 / x / x")
73
+ print(f"x = {brent_zero(lambda x: np.exp(x) - 1 / 100 / x / x, 0.0001, 20.0):.10e}")
74
+ print("f(x) = (x + 3) * (x - 1) * (x - 1)")
75
+ print(f"x = {brent_zero(lambda x: (x + 3) * (x - 1) * (x - 1), -5.0, 2.0):.10e}")
76
+
77
+
78
+ if __name__ == "__main__":
79
+ main()
@@ -0,0 +1,16 @@
1
+ $m_{n}$
2
+ $$ \frac{4 \left(n^{2} - 5 n - 2\right)}{\left(n - 1\right)^{5}} $$
3
+ $m1_{n}$
4
+ $$ \frac{2 \left(n^{3} + 6 n^{2} - 24 n + 20\right)}{\left(n - 2\right)^{3} \left(n - 1\right)^{3}} $$
5
+ $m_{nn}$
6
+ $$ - \frac{12 \left(n^{2} - 6 n - 5\right)}{\left(n - 1\right)^{6}} $$
7
+ $m1_{nn}$
8
+ $$ - \frac{6 \left(n^{4} + 8 n^{3} - 48 n^{2} + 80 n - 44\right)}{\left(n - 2\right)^{4} \left(n - 1\right)^{4}} $$
9
+ $m_{nnn}$
10
+ $$ \frac{48 \left(n^{2} - 7 n - 9\right)}{\left(n - 1\right)^{7}} $$
11
+ $m1_{nnn}$
12
+ $$ \frac{24 \left(n^{5} + 10 n^{4} - 80 n^{3} + 200 n^{2} - 220 n + 92\right)}{\left(n - 2\right)^{5} \left(n - 1\right)^{5}} $$
13
+ $m_{nnnn}$
14
+ $$ - \frac{240 \left(n^{2} - 8 n - 14\right)}{\left(n - 1\right)^{8}} $$
15
+ $m1_{nnnn}$
16
+ $$ - \frac{120 \left(n^{6} + 12 n^{5} - 120 n^{4} + 400 n^{3} - 660 n^{2} + 552 n - 188\right)}{\left(n - 2\right)^{6} \left(n - 1\right)^{6}} $$
@@ -0,0 +1,48 @@
1
+ """C_term"""
2
+
3
+ import sympy as sp
4
+
5
+
6
+ n = sp.symbols("n")
7
+ m = (8 * n - 2 * n**2) / (1 - n) ** 4
8
+ m1 = (20 * n - 27 * n**2 + 12 * n**3 - 2 * n**4) / (n**2 - 3 * n + 2) ** 2
9
+
10
+
11
+ m_n = sp.diff(m, n)
12
+ print("$m_{n}$")
13
+ print("$$", sp.latex(m_n.factor()), "$$")
14
+
15
+
16
+ m1_n = sp.diff(m1, n)
17
+ print("$m1_{n}$")
18
+ print("$$", sp.latex(m1_n.factor()), "$$")
19
+
20
+
21
+ m_nn = sp.diff(m_n, n)
22
+ print("$m_{nn}$")
23
+ print("$$", sp.latex(m_nn.factor()), "$$")
24
+
25
+
26
+ m1_nn = sp.diff(m1_n, n)
27
+ print("$m1_{nn}$")
28
+ print("$$", sp.latex(m1_nn.factor()), "$$")
29
+
30
+
31
+ m_nnn = sp.diff(m_nn, n)
32
+ print("$m_{nnn}$")
33
+ print("$$", sp.latex(m_nnn.factor()), "$$")
34
+
35
+
36
+ m1_nnn = sp.diff(m1_nn, n)
37
+ print("$m1_{nnn}$")
38
+ print("$$", sp.latex(m1_nnn.factor()), "$$")
39
+
40
+
41
+ m_nnnn = sp.diff(m_nnn, n)
42
+ print("$m_{nnnn}$")
43
+ print("$$", sp.latex(m_nnnn.factor()), "$$")
44
+
45
+
46
+ m1_nnnn = sp.diff(m1_nnn, n)
47
+ print("$m1_{nnnn}$")
48
+ print("$$", sp.latex(m1_nnnn.factor()), "$$")
@@ -0,0 +1,30 @@
1
+ $t_{X}$
2
+ $$ \frac{X - 2}{X^{3}} $$
3
+ $X_{t}$
4
+ $$ \frac{X^{3}}{X - 2} $$
5
+ $X_{tt}$
6
+ $$ \frac{2 X^{5} \left(X - 3\right)}{\left(X - 2\right)^{3}} $$
7
+ $X_{ttt}$
8
+ $$ \frac{6 X^{7} \left(X^{2} - 6 X + 10\right)}{\left(X - 2\right)^{5}} $$
9
+ $X_{tttt}$
10
+ $$ \frac{24 X^{9} \left(X^{3} - 9 X^{2} + 29 X - 35\right)}{\left(X - 2\right)^{7}} $$
11
+ $t_{X}$
12
+ $$ \frac{2 X^{2} - 4 X + 1}{X^{2} \left(2 X - 1\right)^{2}} $$
13
+ $X_{t}$
14
+ $$ \frac{X^{2} \left(2 X - 1\right)^{2}}{2 X^{2} - 4 X + 1} $$
15
+ $X_{tt}$
16
+ $$ \frac{2 X^{3} \left(2 X - 1\right)^{3} \left(4 X^{3} - 12 X^{2} + 6 X - 1\right)}{\left(2 X^{2} - 4 X + 1\right)^{3}} $$
17
+ $X_{ttt}$
18
+ $$ \frac{6 X^{4} \left(2 X - 1\right)^{4} \left(16 X^{6} - 96 X^{5} + 200 X^{4} - 160 X^{3} + 62 X^{2} - 12 X + 1\right)}{\left(2 X^{2} - 4 X + 1\right)^{5}} $$
19
+ $X_{tttt}$
20
+ $$ \frac{24 X^{5} \left(2 X - 1\right)^{5} \left(64 X^{9} - 576 X^{8} + 2080 X^{7} - 3808 X^{6} + 3696 X^{5} - 2084 X^{4} + 716 X^{3} - 150 X^{2} + 18 X - 1\right)}{\left(2 X^{2} - 4 X + 1\right)^{7}} $$
21
+ $t_{X}$
22
+ $$ \frac{X^{2} - 2 X - 1}{X^{2} \left(X + 1\right)^{2}} $$
23
+ $X_{t}$
24
+ $$ \frac{X^{2} \left(X + 1\right)^{2}}{X^{2} - 2 X - 1} $$
25
+ $X_{tt}$
26
+ $$ \frac{2 X^{3} \left(X + 1\right)^{3} \left(X^{3} - 3 X^{2} - 3 X - 1\right)}{\left(X^{2} - 2 X - 1\right)^{3}} $$
27
+ $X_{ttt}$
28
+ $$ \frac{6 X^{4} \left(X + 1\right)^{4} \left(X^{6} - 6 X^{5} + 5 X^{4} + 20 X^{3} + 17 X^{2} + 6 X + 1\right)}{\left(X^{2} - 2 X - 1\right)^{5}} $$
29
+ $X_{tttt}$
30
+ $$ \frac{24 X^{5} \left(X + 1\right)^{5} \left(X^{9} - 9 X^{8} + 22 X^{7} + 14 X^{6} - 84 X^{5} - 146 X^{4} - 106 X^{3} - 42 X^{2} - 9 X - 1\right)}{\left(X^{2} - 2 X - 1\right)^{7}} $$
@@ -0,0 +1,93 @@
1
+ """X_term"""
2
+
3
+ import sympy as sp
4
+
5
+
6
+ X = sp.symbols("X")
7
+
8
+
9
+ # AssocType::2B
10
+ t = (1 - X) / X**2
11
+
12
+
13
+ tX = sp.diff(t, X)
14
+ print("$t_{X}$")
15
+ print("$$", sp.latex(tX.factor()), "$$")
16
+
17
+
18
+ Xt = 1 / tX
19
+ print("$X_{t}$")
20
+ print("$$", sp.latex(Xt.factor()), "$$")
21
+
22
+
23
+ Xtt = sp.diff(Xt, X) * Xt
24
+ print("$X_{tt}$")
25
+ print("$$", sp.latex(Xtt.factor()), "$$")
26
+
27
+
28
+ Xttt = sp.diff(Xtt, X) * Xt
29
+ print("$X_{ttt}$")
30
+ print("$$", sp.latex(Xttt.factor()), "$$")
31
+
32
+
33
+ Xtttt = sp.diff(Xttt, X) * Xt
34
+ print("$X_{tttt}$")
35
+ print("$$", sp.latex(Xtttt.factor()), "$$")
36
+
37
+
38
+ # AssocType::3B => XA and XB
39
+ t = (1 - X) / (2 * X**2 - X)
40
+
41
+
42
+ tX = sp.diff(t, X)
43
+ print("$t_{X}$")
44
+ print("$$", sp.latex(tX.factor()), "$$")
45
+
46
+
47
+ Xt = 1 / tX
48
+ print("$X_{t}$")
49
+ print("$$", sp.latex(Xt.factor()), "$$")
50
+
51
+
52
+ Xtt = sp.diff(Xt, X) * Xt
53
+ print("$X_{tt}$")
54
+ print("$$", sp.latex(Xtt.factor()), "$$")
55
+
56
+
57
+ Xttt = sp.diff(Xtt, X) * Xt
58
+ print("$X_{ttt}$")
59
+ print("$$", sp.latex(Xttt.factor()), "$$")
60
+
61
+
62
+ Xtttt = sp.diff(Xttt, X) * Xt
63
+ print("$X_{tttt}$")
64
+ print("$$", sp.latex(Xtttt.factor()), "$$")
65
+
66
+
67
+ # AssocType::3B => XC
68
+ t = (1 - X) / (X**2 + X)
69
+
70
+
71
+ tX = sp.diff(t, X)
72
+ print("$t_{X}$")
73
+ print("$$", sp.latex(tX.factor()), "$$")
74
+
75
+
76
+ Xt = 1 / tX
77
+ print("$X_{t}$")
78
+ print("$$", sp.latex(Xt.factor()), "$$")
79
+
80
+
81
+ Xtt = sp.diff(Xt, X) * Xt
82
+ print("$X_{tt}$")
83
+ print("$$", sp.latex(Xtt.factor()), "$$")
84
+
85
+
86
+ Xttt = sp.diff(Xtt, X) * Xt
87
+ print("$X_{ttt}$")
88
+ print("$$", sp.latex(Xttt.factor()), "$$")
89
+
90
+
91
+ Xtttt = sp.diff(Xttt, X) * Xt
92
+ print("$X_{tttt}$")
93
+ print("$$", sp.latex(Xtttt.factor()), "$$")
@@ -6,7 +6,6 @@ where
6
6
  F: FnMut(f64) -> f64,
7
7
  {
8
8
  let macheps = f64::EPSILON.sqrt();
9
- let t = 10.0 * f64::EPSILON.sqrt();
10
9
  let (mut a, mut fa) = (a, f(a));
11
10
  let (mut b, mut fb) = (b, f(b));
12
11
  if (fa * fb) > 0.0 {
@@ -21,7 +20,7 @@ where
21
20
  (b, fb) = (c, fc);
22
21
  (c, fc) = (a, fa);
23
22
  }
24
- tol = 2.0 * macheps * b.abs() + t;
23
+ tol = macheps * (2.0 * b.abs() + 10.0);
25
24
  m = 0.5 * (c - b);
26
25
  if m.abs() <= tol || fb == 0.0 {
27
26
  return b;
@@ -75,7 +74,7 @@ where
75
74
  /// C. J. F. RIDDERS
76
75
  /// Accurate computation of F'(x) and F'(x) F"(x)
77
76
  /// Adv. Eng. Software, 1982, Vol. 4, No. 2, 75-76.
78
- const N_DIM: usize = 10;
77
+ const N_DIM: usize = 11;
79
78
  pub fn romberg_diff<F>(mut f: F, x: f64) -> f64
80
79
  where
81
80
  F: FnMut(f64) -> f64,
@@ -102,22 +101,22 @@ where
102
101
  mod tests {
103
102
  use super::*;
104
103
  #[test]
105
- fn test_algorithm() {
104
+ fn test_algorithms() {
106
105
  // test brent_zero
107
- let x0 = brent_zero(|x: f64| x.sin() - 0.5 * x, 1.0, 2.0);
108
- let (x1, digits) = (1.89549, 10_f64.powi(5));
106
+ let x0 = brent_zero(|x: f64| x.sin() - x / 2.0, 1.0, 2.0);
107
+ let (x1, digits) = (1.8954942796e+00, 10_f64.powi(10));
109
108
  assert_eq!(x1, (x0 * digits).round() / digits);
110
109
  let x0 = brent_zero(|x: f64| 2.0 * x - (-x).exp(), 0.0, 1.0);
111
- let (x1, digits) = (0.351734, 10_f64.powi(6));
110
+ let (x1, digits) = (3.5173365631e-01, 10_f64.powi(11));
112
111
  assert_eq!(x1, (x0 * digits).round() / digits);
113
112
  let x0 = brent_zero(|x: f64| x * (-x).exp(), -1.0, 0.5);
114
- let (x1, digits) = (-4.03522e-10, 10_f64.powi(15));
113
+ let (x1, digits) = (-4.0352160429e-10, 10_f64.powi(20));
115
114
  assert_eq!(x1, (x0 * digits).round() / digits);
116
115
  let x0 = brent_zero(|x: f64| x.exp() - 1.0 / 100.0 / x / x, 0.0001, 20.0);
117
- let (x1, digits) = (0.0953446, 10_f64.powi(7));
116
+ let (x1, digits) = (9.5344620258e-02, 10_f64.powi(12));
118
117
  assert_eq!(x1, (x0 * digits).round() / digits);
119
- let x0 = brent_zero(|x: f64| (x + 3.0) * (x - 1.0) * (x - 1.0), -5.0, 20.0);
120
- let (x1, digits) = (-3.0, 10_f64.powi(0));
118
+ let x0 = brent_zero(|x: f64| (x + 3.0) * (x - 1.0) * (x - 1.0), -5.0, 2.0);
119
+ let (x1, digits) = (-3.0000000000e+00, 10_f64.powi(10));
121
120
  assert_eq!(x1, (x0 * digits).round() / digits);
122
121
  // test romberg_diff
123
122
  let (df0, digits) = (140.7377356, 10_f64.powi(7)); // real = 140.7377355
@@ -0,0 +1,21 @@
1
+ //!
2
+ //! thermolib
3
+ //! =========
4
+ //!
5
+ //! An open-source library for
6
+ //! the calculation of fluid properties.
7
+ //!
8
+ //!
9
+ /// algorithms
10
+ mod algorithms;
11
+ /// PC-SAFT EOS
12
+ mod pc_saft;
13
+ pub use pc_saft::PcSaftGlyPure;
14
+ /// Python wrappers
15
+ #[cfg(feature = "with_pyo3")]
16
+ mod python;
17
+ /// Fundamental Constants
18
+ mod f64consts {
19
+ pub const NA: f64 = 6.02214076E23; // CODATA2018 (Avogadro constant) mol^-1
20
+ pub const R: f64 = 8.314462618; // CODATA2018 (molar gas constant) J mol^-1 K^-1
21
+ }