gaspype 0.0.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.
Potentially problematic release.
This version of gaspype might be problematic. Click here for more details.
- gaspype-0.0.0/PKG-INFO +180 -0
- gaspype-0.0.0/README.md +167 -0
- gaspype-0.0.0/pyproject.toml +31 -0
- gaspype-0.0.0/setup.cfg +4 -0
- gaspype-0.0.0/src/gaspype/__init__.py +2 -0
- gaspype-0.0.0/src/gaspype.egg-info/PKG-INFO +180 -0
- gaspype-0.0.0/src/gaspype.egg-info/SOURCES.txt +7 -0
- gaspype-0.0.0/src/gaspype.egg-info/dependency_links.txt +1 -0
- gaspype-0.0.0/src/gaspype.egg-info/top_level.txt +1 -0
gaspype-0.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: gaspype
|
|
3
|
+
Version: 0.0.0
|
|
4
|
+
Summary: Calculates thermodynamics of gases
|
|
5
|
+
Author-email: Nicolas Kruse <nicolas.kruse@nonan.net>
|
|
6
|
+
Project-URL: Homepage, https://github.com/Nonannet/gaspype
|
|
7
|
+
Project-URL: Issues, https://github.com/Nonannet/gaspype/issues
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.9
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
# Gaspype
|
|
15
|
+
|
|
16
|
+
The Gaspype package will provide an high performance library for thermodynamic calculations.
|
|
17
|
+
|
|
18
|
+
## Usage will be like as follows
|
|
19
|
+
|
|
20
|
+
Gaspype provides two main classes: ```fluid``` and ```elements```.
|
|
21
|
+
|
|
22
|
+
### Fluid
|
|
23
|
+
|
|
24
|
+
A fluid class describes a mixture of molecular species and their individual molar amounts.
|
|
25
|
+
|
|
26
|
+
``` python
|
|
27
|
+
import gaspype as gp
|
|
28
|
+
fl = gp.fluid({'H2O': 1, 'H2':2})
|
|
29
|
+
fl
|
|
30
|
+
```
|
|
31
|
+
```
|
|
32
|
+
Total 3.000e+00 mol
|
|
33
|
+
H2O 33.33 %
|
|
34
|
+
H2 66.67 %
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Its' functions provides thermodynamic, mass balance and ideal gas properties of the mixture.
|
|
38
|
+
|
|
39
|
+
``` python
|
|
40
|
+
cp = fl.get_cp(t=800+273.15)
|
|
41
|
+
mass = fl.get_mass()
|
|
42
|
+
gas_volume = fl.get_v(t=800+273.15, p=1e5)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The arguments can be provided as numpy-arrays:
|
|
46
|
+
|
|
47
|
+
``` python
|
|
48
|
+
t_range = np.linspace(600, 800, 5) + 273.15
|
|
49
|
+
fl.get_density(t=t_range, p=1e5)
|
|
50
|
+
```
|
|
51
|
+
```
|
|
52
|
+
array([0.10122906, 0.09574625, 0.09082685, 0.08638827, 0.08236328])
|
|
53
|
+
```
|
|
54
|
+
A ```fluid``` object can have multiple compositions. A multidimensional ```fluid``` object can be created for example by multiplication with a numpy array:
|
|
55
|
+
|
|
56
|
+
``` python
|
|
57
|
+
fl2 = gp.fluid({'H2O': 1, 'N2':2}) + \
|
|
58
|
+
np.linspace(0, 10, 4) * gp.fluid({'H2': 1})
|
|
59
|
+
fl2
|
|
60
|
+
```
|
|
61
|
+
```
|
|
62
|
+
Total mol:
|
|
63
|
+
array([ 3. , 6.33333333, 9.66666667, 13. ])
|
|
64
|
+
Species:
|
|
65
|
+
H2O N2 H2
|
|
66
|
+
Molar fractions:
|
|
67
|
+
array([[0.33333333, 0.66666667, 0. ],
|
|
68
|
+
[0.15789474, 0.31578947, 0.52631579],
|
|
69
|
+
[0.10344828, 0.20689655, 0.68965517],
|
|
70
|
+
[0.07692308, 0.15384615, 0.76923077]])
|
|
71
|
+
```
|
|
72
|
+
A fluid object can be converted to a pandas dataframe:
|
|
73
|
+
``` python
|
|
74
|
+
import pandas as pd
|
|
75
|
+
pd.DataFrame(list(fl2))
|
|
76
|
+
```
|
|
77
|
+
| | H2O | N2 | H2
|
|
78
|
+
|----|-----|-----|-------
|
|
79
|
+
|0 | 1.0 | 2.0 | 0.000000
|
|
80
|
+
|1 | 1.0 | 2.0 | 3.333333
|
|
81
|
+
|2 | 1.0 | 2.0 | 6.666667
|
|
82
|
+
|3 | 1.0 | 2.0 | 10.000000
|
|
83
|
+
|
|
84
|
+
The broadcasting behavior is not limited to 1D-arrays:
|
|
85
|
+
|
|
86
|
+
``` python
|
|
87
|
+
fl3 = gp.fluid({'H2O': 1}) + \
|
|
88
|
+
np.linspace(0, 10, 4) * gp.fluid({'H2': 1}) + \
|
|
89
|
+
np.expand_dims(np.linspace(1, 3, 3), axis=1) * gp.fluid({'N2': 1})
|
|
90
|
+
fl3
|
|
91
|
+
```
|
|
92
|
+
```
|
|
93
|
+
Total mol:
|
|
94
|
+
array([[ 2. , 5.33333333, 8.66666667, 12. ],
|
|
95
|
+
[ 3. , 6.33333333, 9.66666667, 13. ],
|
|
96
|
+
[ 4. , 7.33333333, 10.66666667, 14. ]])
|
|
97
|
+
Species:
|
|
98
|
+
H2O N2 H2
|
|
99
|
+
Molar fractions:
|
|
100
|
+
array([[[0.5 , 0.5 , 0. ],
|
|
101
|
+
[0.1875 , 0.1875 , 0.625 ],
|
|
102
|
+
[0.11538462, 0.11538462, 0.76923077],
|
|
103
|
+
[0.08333333, 0.08333333, 0.83333333]],
|
|
104
|
+
|
|
105
|
+
[[0.33333333, 0.66666667, 0. ],
|
|
106
|
+
[0.15789474, 0.31578947, 0.52631579],
|
|
107
|
+
[0.10344828, 0.20689655, 0.68965517],
|
|
108
|
+
[0.07692308, 0.15384615, 0.76923077]],
|
|
109
|
+
|
|
110
|
+
[[0.25 , 0.75 , 0. ],
|
|
111
|
+
[0.13636364, 0.40909091, 0.45454545],
|
|
112
|
+
[0.09375 , 0.28125 , 0.625 ],
|
|
113
|
+
[0.07142857, 0.21428571, 0.71428571]]])
|
|
114
|
+
```
|
|
115
|
+
In some cases not the molecular but the atomic composition is of interest. The ```elements``` class can be used for atom based balances and works similar:
|
|
116
|
+
|
|
117
|
+
``` python
|
|
118
|
+
el = gp.elements({'N': 1, 'Cl': 2})
|
|
119
|
+
el.get_mass()
|
|
120
|
+
```
|
|
121
|
+
```
|
|
122
|
+
0.084907
|
|
123
|
+
```
|
|
124
|
+
A ```elements``` object can be as well instantiated from a ```fluid``` object. Arithmetic operations between ```elements``` and ```fluid``` result in an ```elements``` object:
|
|
125
|
+
``` python
|
|
126
|
+
el2 = gp.elements(fl) + el - 0.3 * fl
|
|
127
|
+
el2
|
|
128
|
+
```
|
|
129
|
+
```
|
|
130
|
+
Cl 2.000e+00 mol
|
|
131
|
+
N 1.000e+00 mol
|
|
132
|
+
O 7.000e-01 mol
|
|
133
|
+
H 4.200e+00 mol
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Going from an atomic composition to an molecular composition is a little bit less straight forward, since there is no universal approach. One way is to calculate the thermodynamic equilibrium for a mixture:
|
|
137
|
+
|
|
138
|
+
``` python
|
|
139
|
+
fs = gp.fluid_system('CH4, H2, CO, CO2, O2')
|
|
140
|
+
el3 = gp.elements({'C': 1, 'H': 2, 'O':1}, fs)
|
|
141
|
+
fl3 = gp.equilibrium(el3, t=800)
|
|
142
|
+
fl3
|
|
143
|
+
```
|
|
144
|
+
```
|
|
145
|
+
Total 1.204e+00 mol
|
|
146
|
+
CH4 33.07 %
|
|
147
|
+
H2 16.93 %
|
|
148
|
+
CO 16.93 %
|
|
149
|
+
CO2 33.07 %
|
|
150
|
+
O2 0.00 %
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
The ```equilibrium``` function can be called with a ```fluid``` or ```elements``` object as first argument. ```fluid``` and ```elements``` referencing a ```fluid_system``` object witch can be be set as shown above during the object instantiation. If not provided, a new one will be created automatically. Providing a ```fluid_system``` gives more control over which molecular species are included in derived ```fluid``` objects. Furthermore arithmetic operations between objects with the same ```fluid_system``` are potentially faster:
|
|
154
|
+
|
|
155
|
+
``` python
|
|
156
|
+
fl3 + gp.fluid({'CH4': 1}, fs)
|
|
157
|
+
```
|
|
158
|
+
```
|
|
159
|
+
Total 2.204e+00 mol
|
|
160
|
+
CH4 63.44 %
|
|
161
|
+
H2 9.24 %
|
|
162
|
+
CO 9.24 %
|
|
163
|
+
CO2 18.07 %
|
|
164
|
+
O2 0.00 %
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Especially if the ```fluid_system``` of one of the operants has not a subset of molecular species of the other ```fluid_system``` a new ```fluid_system``` will be created for the operation which might degrade performance:
|
|
168
|
+
|
|
169
|
+
``` python
|
|
170
|
+
fl3 + gp.fluid({'NH3': 1})
|
|
171
|
+
```
|
|
172
|
+
```
|
|
173
|
+
Total 2.204e+00 mol
|
|
174
|
+
NH3 45.38 %
|
|
175
|
+
CH4 18.07 %
|
|
176
|
+
H2 9.24 %
|
|
177
|
+
O2 0.00 %
|
|
178
|
+
CO 9.24 %
|
|
179
|
+
CO2 18.07 %
|
|
180
|
+
```
|
gaspype-0.0.0/README.md
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# Gaspype
|
|
2
|
+
|
|
3
|
+
The Gaspype package will provide an high performance library for thermodynamic calculations.
|
|
4
|
+
|
|
5
|
+
## Usage will be like as follows
|
|
6
|
+
|
|
7
|
+
Gaspype provides two main classes: ```fluid``` and ```elements```.
|
|
8
|
+
|
|
9
|
+
### Fluid
|
|
10
|
+
|
|
11
|
+
A fluid class describes a mixture of molecular species and their individual molar amounts.
|
|
12
|
+
|
|
13
|
+
``` python
|
|
14
|
+
import gaspype as gp
|
|
15
|
+
fl = gp.fluid({'H2O': 1, 'H2':2})
|
|
16
|
+
fl
|
|
17
|
+
```
|
|
18
|
+
```
|
|
19
|
+
Total 3.000e+00 mol
|
|
20
|
+
H2O 33.33 %
|
|
21
|
+
H2 66.67 %
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Its' functions provides thermodynamic, mass balance and ideal gas properties of the mixture.
|
|
25
|
+
|
|
26
|
+
``` python
|
|
27
|
+
cp = fl.get_cp(t=800+273.15)
|
|
28
|
+
mass = fl.get_mass()
|
|
29
|
+
gas_volume = fl.get_v(t=800+273.15, p=1e5)
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The arguments can be provided as numpy-arrays:
|
|
33
|
+
|
|
34
|
+
``` python
|
|
35
|
+
t_range = np.linspace(600, 800, 5) + 273.15
|
|
36
|
+
fl.get_density(t=t_range, p=1e5)
|
|
37
|
+
```
|
|
38
|
+
```
|
|
39
|
+
array([0.10122906, 0.09574625, 0.09082685, 0.08638827, 0.08236328])
|
|
40
|
+
```
|
|
41
|
+
A ```fluid``` object can have multiple compositions. A multidimensional ```fluid``` object can be created for example by multiplication with a numpy array:
|
|
42
|
+
|
|
43
|
+
``` python
|
|
44
|
+
fl2 = gp.fluid({'H2O': 1, 'N2':2}) + \
|
|
45
|
+
np.linspace(0, 10, 4) * gp.fluid({'H2': 1})
|
|
46
|
+
fl2
|
|
47
|
+
```
|
|
48
|
+
```
|
|
49
|
+
Total mol:
|
|
50
|
+
array([ 3. , 6.33333333, 9.66666667, 13. ])
|
|
51
|
+
Species:
|
|
52
|
+
H2O N2 H2
|
|
53
|
+
Molar fractions:
|
|
54
|
+
array([[0.33333333, 0.66666667, 0. ],
|
|
55
|
+
[0.15789474, 0.31578947, 0.52631579],
|
|
56
|
+
[0.10344828, 0.20689655, 0.68965517],
|
|
57
|
+
[0.07692308, 0.15384615, 0.76923077]])
|
|
58
|
+
```
|
|
59
|
+
A fluid object can be converted to a pandas dataframe:
|
|
60
|
+
``` python
|
|
61
|
+
import pandas as pd
|
|
62
|
+
pd.DataFrame(list(fl2))
|
|
63
|
+
```
|
|
64
|
+
| | H2O | N2 | H2
|
|
65
|
+
|----|-----|-----|-------
|
|
66
|
+
|0 | 1.0 | 2.0 | 0.000000
|
|
67
|
+
|1 | 1.0 | 2.0 | 3.333333
|
|
68
|
+
|2 | 1.0 | 2.0 | 6.666667
|
|
69
|
+
|3 | 1.0 | 2.0 | 10.000000
|
|
70
|
+
|
|
71
|
+
The broadcasting behavior is not limited to 1D-arrays:
|
|
72
|
+
|
|
73
|
+
``` python
|
|
74
|
+
fl3 = gp.fluid({'H2O': 1}) + \
|
|
75
|
+
np.linspace(0, 10, 4) * gp.fluid({'H2': 1}) + \
|
|
76
|
+
np.expand_dims(np.linspace(1, 3, 3), axis=1) * gp.fluid({'N2': 1})
|
|
77
|
+
fl3
|
|
78
|
+
```
|
|
79
|
+
```
|
|
80
|
+
Total mol:
|
|
81
|
+
array([[ 2. , 5.33333333, 8.66666667, 12. ],
|
|
82
|
+
[ 3. , 6.33333333, 9.66666667, 13. ],
|
|
83
|
+
[ 4. , 7.33333333, 10.66666667, 14. ]])
|
|
84
|
+
Species:
|
|
85
|
+
H2O N2 H2
|
|
86
|
+
Molar fractions:
|
|
87
|
+
array([[[0.5 , 0.5 , 0. ],
|
|
88
|
+
[0.1875 , 0.1875 , 0.625 ],
|
|
89
|
+
[0.11538462, 0.11538462, 0.76923077],
|
|
90
|
+
[0.08333333, 0.08333333, 0.83333333]],
|
|
91
|
+
|
|
92
|
+
[[0.33333333, 0.66666667, 0. ],
|
|
93
|
+
[0.15789474, 0.31578947, 0.52631579],
|
|
94
|
+
[0.10344828, 0.20689655, 0.68965517],
|
|
95
|
+
[0.07692308, 0.15384615, 0.76923077]],
|
|
96
|
+
|
|
97
|
+
[[0.25 , 0.75 , 0. ],
|
|
98
|
+
[0.13636364, 0.40909091, 0.45454545],
|
|
99
|
+
[0.09375 , 0.28125 , 0.625 ],
|
|
100
|
+
[0.07142857, 0.21428571, 0.71428571]]])
|
|
101
|
+
```
|
|
102
|
+
In some cases not the molecular but the atomic composition is of interest. The ```elements``` class can be used for atom based balances and works similar:
|
|
103
|
+
|
|
104
|
+
``` python
|
|
105
|
+
el = gp.elements({'N': 1, 'Cl': 2})
|
|
106
|
+
el.get_mass()
|
|
107
|
+
```
|
|
108
|
+
```
|
|
109
|
+
0.084907
|
|
110
|
+
```
|
|
111
|
+
A ```elements``` object can be as well instantiated from a ```fluid``` object. Arithmetic operations between ```elements``` and ```fluid``` result in an ```elements``` object:
|
|
112
|
+
``` python
|
|
113
|
+
el2 = gp.elements(fl) + el - 0.3 * fl
|
|
114
|
+
el2
|
|
115
|
+
```
|
|
116
|
+
```
|
|
117
|
+
Cl 2.000e+00 mol
|
|
118
|
+
N 1.000e+00 mol
|
|
119
|
+
O 7.000e-01 mol
|
|
120
|
+
H 4.200e+00 mol
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Going from an atomic composition to an molecular composition is a little bit less straight forward, since there is no universal approach. One way is to calculate the thermodynamic equilibrium for a mixture:
|
|
124
|
+
|
|
125
|
+
``` python
|
|
126
|
+
fs = gp.fluid_system('CH4, H2, CO, CO2, O2')
|
|
127
|
+
el3 = gp.elements({'C': 1, 'H': 2, 'O':1}, fs)
|
|
128
|
+
fl3 = gp.equilibrium(el3, t=800)
|
|
129
|
+
fl3
|
|
130
|
+
```
|
|
131
|
+
```
|
|
132
|
+
Total 1.204e+00 mol
|
|
133
|
+
CH4 33.07 %
|
|
134
|
+
H2 16.93 %
|
|
135
|
+
CO 16.93 %
|
|
136
|
+
CO2 33.07 %
|
|
137
|
+
O2 0.00 %
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
The ```equilibrium``` function can be called with a ```fluid``` or ```elements``` object as first argument. ```fluid``` and ```elements``` referencing a ```fluid_system``` object witch can be be set as shown above during the object instantiation. If not provided, a new one will be created automatically. Providing a ```fluid_system``` gives more control over which molecular species are included in derived ```fluid``` objects. Furthermore arithmetic operations between objects with the same ```fluid_system``` are potentially faster:
|
|
141
|
+
|
|
142
|
+
``` python
|
|
143
|
+
fl3 + gp.fluid({'CH4': 1}, fs)
|
|
144
|
+
```
|
|
145
|
+
```
|
|
146
|
+
Total 2.204e+00 mol
|
|
147
|
+
CH4 63.44 %
|
|
148
|
+
H2 9.24 %
|
|
149
|
+
CO 9.24 %
|
|
150
|
+
CO2 18.07 %
|
|
151
|
+
O2 0.00 %
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Especially if the ```fluid_system``` of one of the operants has not a subset of molecular species of the other ```fluid_system``` a new ```fluid_system``` will be created for the operation which might degrade performance:
|
|
155
|
+
|
|
156
|
+
``` python
|
|
157
|
+
fl3 + gp.fluid({'NH3': 1})
|
|
158
|
+
```
|
|
159
|
+
```
|
|
160
|
+
Total 2.204e+00 mol
|
|
161
|
+
NH3 45.38 %
|
|
162
|
+
CH4 18.07 %
|
|
163
|
+
H2 9.24 %
|
|
164
|
+
O2 0.00 %
|
|
165
|
+
CO 9.24 %
|
|
166
|
+
CO2 18.07 %
|
|
167
|
+
```
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "gaspype"
|
|
3
|
+
version = "0.0.0"
|
|
4
|
+
authors = [
|
|
5
|
+
{ name="Nicolas Kruse", email="nicolas.kruse@nonan.net" },
|
|
6
|
+
]
|
|
7
|
+
description = "Calculates thermodynamics of gases"
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
requires-python = ">=3.9"
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Programming Language :: Python :: 3",
|
|
12
|
+
"License :: OSI Approved :: MIT License",
|
|
13
|
+
"Operating System :: OS Independent",
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
[project.urls]
|
|
17
|
+
Homepage = "https://github.com/Nonannet/gaspype"
|
|
18
|
+
Issues = "https://github.com/Nonannet/gaspype/issues"
|
|
19
|
+
|
|
20
|
+
[build-system]
|
|
21
|
+
requires = ["setuptools>=61.0"]
|
|
22
|
+
build-backend = "setuptools.build_meta"
|
|
23
|
+
|
|
24
|
+
[tool.setuptools.packages.find]
|
|
25
|
+
where = ["src"]
|
|
26
|
+
|
|
27
|
+
[tool.pytest.ini_options]
|
|
28
|
+
minversion = "6.0"
|
|
29
|
+
addopts = "-ra -q"
|
|
30
|
+
testpaths = ["tests"]
|
|
31
|
+
pythonpath = ["src"]
|
gaspype-0.0.0/setup.cfg
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: gaspype
|
|
3
|
+
Version: 0.0.0
|
|
4
|
+
Summary: Calculates thermodynamics of gases
|
|
5
|
+
Author-email: Nicolas Kruse <nicolas.kruse@nonan.net>
|
|
6
|
+
Project-URL: Homepage, https://github.com/Nonannet/gaspype
|
|
7
|
+
Project-URL: Issues, https://github.com/Nonannet/gaspype/issues
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.9
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
# Gaspype
|
|
15
|
+
|
|
16
|
+
The Gaspype package will provide an high performance library for thermodynamic calculations.
|
|
17
|
+
|
|
18
|
+
## Usage will be like as follows
|
|
19
|
+
|
|
20
|
+
Gaspype provides two main classes: ```fluid``` and ```elements```.
|
|
21
|
+
|
|
22
|
+
### Fluid
|
|
23
|
+
|
|
24
|
+
A fluid class describes a mixture of molecular species and their individual molar amounts.
|
|
25
|
+
|
|
26
|
+
``` python
|
|
27
|
+
import gaspype as gp
|
|
28
|
+
fl = gp.fluid({'H2O': 1, 'H2':2})
|
|
29
|
+
fl
|
|
30
|
+
```
|
|
31
|
+
```
|
|
32
|
+
Total 3.000e+00 mol
|
|
33
|
+
H2O 33.33 %
|
|
34
|
+
H2 66.67 %
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Its' functions provides thermodynamic, mass balance and ideal gas properties of the mixture.
|
|
38
|
+
|
|
39
|
+
``` python
|
|
40
|
+
cp = fl.get_cp(t=800+273.15)
|
|
41
|
+
mass = fl.get_mass()
|
|
42
|
+
gas_volume = fl.get_v(t=800+273.15, p=1e5)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The arguments can be provided as numpy-arrays:
|
|
46
|
+
|
|
47
|
+
``` python
|
|
48
|
+
t_range = np.linspace(600, 800, 5) + 273.15
|
|
49
|
+
fl.get_density(t=t_range, p=1e5)
|
|
50
|
+
```
|
|
51
|
+
```
|
|
52
|
+
array([0.10122906, 0.09574625, 0.09082685, 0.08638827, 0.08236328])
|
|
53
|
+
```
|
|
54
|
+
A ```fluid``` object can have multiple compositions. A multidimensional ```fluid``` object can be created for example by multiplication with a numpy array:
|
|
55
|
+
|
|
56
|
+
``` python
|
|
57
|
+
fl2 = gp.fluid({'H2O': 1, 'N2':2}) + \
|
|
58
|
+
np.linspace(0, 10, 4) * gp.fluid({'H2': 1})
|
|
59
|
+
fl2
|
|
60
|
+
```
|
|
61
|
+
```
|
|
62
|
+
Total mol:
|
|
63
|
+
array([ 3. , 6.33333333, 9.66666667, 13. ])
|
|
64
|
+
Species:
|
|
65
|
+
H2O N2 H2
|
|
66
|
+
Molar fractions:
|
|
67
|
+
array([[0.33333333, 0.66666667, 0. ],
|
|
68
|
+
[0.15789474, 0.31578947, 0.52631579],
|
|
69
|
+
[0.10344828, 0.20689655, 0.68965517],
|
|
70
|
+
[0.07692308, 0.15384615, 0.76923077]])
|
|
71
|
+
```
|
|
72
|
+
A fluid object can be converted to a pandas dataframe:
|
|
73
|
+
``` python
|
|
74
|
+
import pandas as pd
|
|
75
|
+
pd.DataFrame(list(fl2))
|
|
76
|
+
```
|
|
77
|
+
| | H2O | N2 | H2
|
|
78
|
+
|----|-----|-----|-------
|
|
79
|
+
|0 | 1.0 | 2.0 | 0.000000
|
|
80
|
+
|1 | 1.0 | 2.0 | 3.333333
|
|
81
|
+
|2 | 1.0 | 2.0 | 6.666667
|
|
82
|
+
|3 | 1.0 | 2.0 | 10.000000
|
|
83
|
+
|
|
84
|
+
The broadcasting behavior is not limited to 1D-arrays:
|
|
85
|
+
|
|
86
|
+
``` python
|
|
87
|
+
fl3 = gp.fluid({'H2O': 1}) + \
|
|
88
|
+
np.linspace(0, 10, 4) * gp.fluid({'H2': 1}) + \
|
|
89
|
+
np.expand_dims(np.linspace(1, 3, 3), axis=1) * gp.fluid({'N2': 1})
|
|
90
|
+
fl3
|
|
91
|
+
```
|
|
92
|
+
```
|
|
93
|
+
Total mol:
|
|
94
|
+
array([[ 2. , 5.33333333, 8.66666667, 12. ],
|
|
95
|
+
[ 3. , 6.33333333, 9.66666667, 13. ],
|
|
96
|
+
[ 4. , 7.33333333, 10.66666667, 14. ]])
|
|
97
|
+
Species:
|
|
98
|
+
H2O N2 H2
|
|
99
|
+
Molar fractions:
|
|
100
|
+
array([[[0.5 , 0.5 , 0. ],
|
|
101
|
+
[0.1875 , 0.1875 , 0.625 ],
|
|
102
|
+
[0.11538462, 0.11538462, 0.76923077],
|
|
103
|
+
[0.08333333, 0.08333333, 0.83333333]],
|
|
104
|
+
|
|
105
|
+
[[0.33333333, 0.66666667, 0. ],
|
|
106
|
+
[0.15789474, 0.31578947, 0.52631579],
|
|
107
|
+
[0.10344828, 0.20689655, 0.68965517],
|
|
108
|
+
[0.07692308, 0.15384615, 0.76923077]],
|
|
109
|
+
|
|
110
|
+
[[0.25 , 0.75 , 0. ],
|
|
111
|
+
[0.13636364, 0.40909091, 0.45454545],
|
|
112
|
+
[0.09375 , 0.28125 , 0.625 ],
|
|
113
|
+
[0.07142857, 0.21428571, 0.71428571]]])
|
|
114
|
+
```
|
|
115
|
+
In some cases not the molecular but the atomic composition is of interest. The ```elements``` class can be used for atom based balances and works similar:
|
|
116
|
+
|
|
117
|
+
``` python
|
|
118
|
+
el = gp.elements({'N': 1, 'Cl': 2})
|
|
119
|
+
el.get_mass()
|
|
120
|
+
```
|
|
121
|
+
```
|
|
122
|
+
0.084907
|
|
123
|
+
```
|
|
124
|
+
A ```elements``` object can be as well instantiated from a ```fluid``` object. Arithmetic operations between ```elements``` and ```fluid``` result in an ```elements``` object:
|
|
125
|
+
``` python
|
|
126
|
+
el2 = gp.elements(fl) + el - 0.3 * fl
|
|
127
|
+
el2
|
|
128
|
+
```
|
|
129
|
+
```
|
|
130
|
+
Cl 2.000e+00 mol
|
|
131
|
+
N 1.000e+00 mol
|
|
132
|
+
O 7.000e-01 mol
|
|
133
|
+
H 4.200e+00 mol
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Going from an atomic composition to an molecular composition is a little bit less straight forward, since there is no universal approach. One way is to calculate the thermodynamic equilibrium for a mixture:
|
|
137
|
+
|
|
138
|
+
``` python
|
|
139
|
+
fs = gp.fluid_system('CH4, H2, CO, CO2, O2')
|
|
140
|
+
el3 = gp.elements({'C': 1, 'H': 2, 'O':1}, fs)
|
|
141
|
+
fl3 = gp.equilibrium(el3, t=800)
|
|
142
|
+
fl3
|
|
143
|
+
```
|
|
144
|
+
```
|
|
145
|
+
Total 1.204e+00 mol
|
|
146
|
+
CH4 33.07 %
|
|
147
|
+
H2 16.93 %
|
|
148
|
+
CO 16.93 %
|
|
149
|
+
CO2 33.07 %
|
|
150
|
+
O2 0.00 %
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
The ```equilibrium``` function can be called with a ```fluid``` or ```elements``` object as first argument. ```fluid``` and ```elements``` referencing a ```fluid_system``` object witch can be be set as shown above during the object instantiation. If not provided, a new one will be created automatically. Providing a ```fluid_system``` gives more control over which molecular species are included in derived ```fluid``` objects. Furthermore arithmetic operations between objects with the same ```fluid_system``` are potentially faster:
|
|
154
|
+
|
|
155
|
+
``` python
|
|
156
|
+
fl3 + gp.fluid({'CH4': 1}, fs)
|
|
157
|
+
```
|
|
158
|
+
```
|
|
159
|
+
Total 2.204e+00 mol
|
|
160
|
+
CH4 63.44 %
|
|
161
|
+
H2 9.24 %
|
|
162
|
+
CO 9.24 %
|
|
163
|
+
CO2 18.07 %
|
|
164
|
+
O2 0.00 %
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Especially if the ```fluid_system``` of one of the operants has not a subset of molecular species of the other ```fluid_system``` a new ```fluid_system``` will be created for the operation which might degrade performance:
|
|
168
|
+
|
|
169
|
+
``` python
|
|
170
|
+
fl3 + gp.fluid({'NH3': 1})
|
|
171
|
+
```
|
|
172
|
+
```
|
|
173
|
+
Total 2.204e+00 mol
|
|
174
|
+
NH3 45.38 %
|
|
175
|
+
CH4 18.07 %
|
|
176
|
+
H2 9.24 %
|
|
177
|
+
O2 0.00 %
|
|
178
|
+
CO 9.24 %
|
|
179
|
+
CO2 18.07 %
|
|
180
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
gaspype
|