pyEQL 0.5.2__py3-none-any.whl → 1.1.0__py3-none-any.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.
- pyEQL/__init__.py +50 -43
- pyEQL/activity_correction.py +481 -707
- pyEQL/database/geothermal.dat +5693 -0
- pyEQL/database/llnl.dat +19305 -0
- pyEQL/database/phreeqc_license.txt +54 -0
- pyEQL/database/pyeql_db.json +35902 -0
- pyEQL/engines.py +793 -0
- pyEQL/equilibrium.py +148 -228
- pyEQL/functions.py +121 -416
- pyEQL/pint_custom_units.txt +2 -2
- pyEQL/presets/Ringers lactate.yaml +20 -0
- pyEQL/presets/normal saline.yaml +17 -0
- pyEQL/presets/rainwater.yaml +17 -0
- pyEQL/presets/seawater.yaml +29 -0
- pyEQL/presets/urine.yaml +26 -0
- pyEQL/presets/wastewater.yaml +21 -0
- pyEQL/salt_ion_match.py +53 -284
- pyEQL/solute.py +126 -191
- pyEQL/solution.py +2163 -2090
- pyEQL/utils.py +165 -0
- pyEQL-1.1.0.dist-info/AUTHORS.md +13 -0
- {pyEQL-0.5.2.dist-info → pyEQL-1.1.0.dist-info}/COPYING +1 -1
- pyEQL-0.5.2.dist-info/LICENSE → pyEQL-1.1.0.dist-info/LICENSE.txt +3 -7
- pyEQL-1.1.0.dist-info/METADATA +129 -0
- pyEQL-1.1.0.dist-info/RECORD +27 -0
- {pyEQL-0.5.2.dist-info → pyEQL-1.1.0.dist-info}/WHEEL +2 -1
- pyEQL/chemical_formula.py +0 -1006
- pyEQL/database/Erying_viscosity.tsv +0 -18
- pyEQL/database/Jones_Dole_B.tsv +0 -32
- pyEQL/database/Jones_Dole_B_inorganic_Jenkins.tsv +0 -75
- pyEQL/database/LICENSE +0 -4
- pyEQL/database/dielectric_parameter.tsv +0 -30
- pyEQL/database/diffusion_coefficient.tsv +0 -116
- pyEQL/database/hydrated_radius.tsv +0 -35
- pyEQL/database/ionic_radius.tsv +0 -35
- pyEQL/database/partial_molar_volume.tsv +0 -22
- pyEQL/database/pitzer_activity.tsv +0 -169
- pyEQL/database/pitzer_volume.tsv +0 -132
- pyEQL/database/template.tsv +0 -14
- pyEQL/database.py +0 -300
- pyEQL/elements.py +0 -4552
- pyEQL/logging_system.py +0 -53
- pyEQL/parameter.py +0 -435
- pyEQL/tests/__init__.py +0 -32
- pyEQL/tests/test_activity.py +0 -578
- pyEQL/tests/test_bulk_properties.py +0 -86
- pyEQL/tests/test_chemical_formula.py +0 -279
- pyEQL/tests/test_debye_length.py +0 -79
- pyEQL/tests/test_density.py +0 -106
- pyEQL/tests/test_dielectric.py +0 -153
- pyEQL/tests/test_effective_pitzer.py +0 -276
- pyEQL/tests/test_mixed_electrolyte_activity.py +0 -154
- pyEQL/tests/test_osmotic_coeff.py +0 -99
- pyEQL/tests/test_pyeql_volume_concentration.py +0 -428
- pyEQL/tests/test_salt_matching.py +0 -337
- pyEQL/tests/test_solute_properties.py +0 -251
- pyEQL/water_properties.py +0 -352
- pyEQL-0.5.2.dist-info/AUTHORS +0 -7
- pyEQL-0.5.2.dist-info/METADATA +0 -72
- pyEQL-0.5.2.dist-info/RECORD +0 -47
- pyEQL-0.5.2.dist-info/entry_points.txt +0 -3
- {pyEQL-0.5.2.dist-info → pyEQL-1.1.0.dist-info}/top_level.txt +0 -0
|
@@ -1,428 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
pyEQL volume and concentration methods test suite
|
|
3
|
-
=================================================
|
|
4
|
-
|
|
5
|
-
This file contains tests for the volume and concentration-related methods
|
|
6
|
-
used by pyEQL's Solution class
|
|
7
|
-
"""
|
|
8
|
-
|
|
9
|
-
import pyEQL
|
|
10
|
-
import unittest
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class Test_empty_solution(unittest.TestCase, pyEQL.CustomAssertions):
|
|
14
|
-
"""
|
|
15
|
-
test behavior when creating an empty solution
|
|
16
|
-
------------------------------------------------
|
|
17
|
-
|
|
18
|
-
"""
|
|
19
|
-
|
|
20
|
-
# create an empty solution
|
|
21
|
-
def setUp(self):
|
|
22
|
-
self.s1 = pyEQL.Solution()
|
|
23
|
-
|
|
24
|
-
# It should return type Solution
|
|
25
|
-
def test_empty_solution_1(self):
|
|
26
|
-
expected = pyEQL.solution.Solution
|
|
27
|
-
|
|
28
|
-
self.assertIsInstance(self.s1, expected)
|
|
29
|
-
|
|
30
|
-
# It should have exactly 1L volume
|
|
31
|
-
def test_empty_solution_2(self):
|
|
32
|
-
result = self.s1.get_volume().to("L").magnitude
|
|
33
|
-
expected = 1.0
|
|
34
|
-
|
|
35
|
-
self.assertEqual(result, expected)
|
|
36
|
-
|
|
37
|
-
# the solvent should be water
|
|
38
|
-
def test_empty_solution_3(self):
|
|
39
|
-
result = self.s1.get_solvent().get_name()
|
|
40
|
-
expected = "H2O"
|
|
41
|
-
|
|
42
|
-
self.assertEqual(result, expected)
|
|
43
|
-
|
|
44
|
-
# It should have 0.997 kg water mass
|
|
45
|
-
def test_empty_solution_4(self):
|
|
46
|
-
result = self.s1.get_solvent_mass().to("kg").magnitude
|
|
47
|
-
expected = 0.9970415
|
|
48
|
-
|
|
49
|
-
self.assertAlmostEqual(result, expected)
|
|
50
|
-
|
|
51
|
-
# the temperature should be 25 degC
|
|
52
|
-
def test_empty_solution_5(self):
|
|
53
|
-
result = self.s1.get_temperature().to("degC").magnitude
|
|
54
|
-
expected = 25
|
|
55
|
-
|
|
56
|
-
self.assertEqual(result, expected)
|
|
57
|
-
|
|
58
|
-
# the pressure should be 1 atm
|
|
59
|
-
def test_empty_solution_6(self):
|
|
60
|
-
result = self.s1.get_pressure().to("atm").magnitude
|
|
61
|
-
expected = 1
|
|
62
|
-
|
|
63
|
-
self.assertEqual(result, expected)
|
|
64
|
-
|
|
65
|
-
# the pH should be 7.0
|
|
66
|
-
def test_empty_solution_7(self):
|
|
67
|
-
result = self.s1.get_activity("H+")
|
|
68
|
-
expected = 1e-7
|
|
69
|
-
|
|
70
|
-
self.assertAlmostEqual(result, expected, 9)
|
|
71
|
-
|
|
72
|
-
# it should contain H2O, H+, and OH- species
|
|
73
|
-
def test_empty_solution_8(self):
|
|
74
|
-
result = self.s1.list_solutes()
|
|
75
|
-
expected = ["H2O", "OH-", "H+"]
|
|
76
|
-
|
|
77
|
-
self.assertCountEqual(result, expected)
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
class Test_solute_addition(unittest.TestCase, pyEQL.CustomAssertions):
|
|
81
|
-
"""
|
|
82
|
-
test behavior of various methods for adding solutes to a solution
|
|
83
|
-
-----------------------------------------------------------------
|
|
84
|
-
|
|
85
|
-
"""
|
|
86
|
-
|
|
87
|
-
# create an empty and test solutions with the same volume using substance / volume,
|
|
88
|
-
# substance/mass, and substance units
|
|
89
|
-
def setUp(self):
|
|
90
|
-
self.s1 = pyEQL.Solution(volume="2 L")
|
|
91
|
-
self.s2 = pyEQL.Solution([["Na+", "4 mol/L"], ["Cl-", "4 mol/L"]], volume="2 L")
|
|
92
|
-
self.s3 = pyEQL.Solution(
|
|
93
|
-
[["Na+", "4 mol/kg"], ["Cl-", "4 mol/kg"]], volume="2 L"
|
|
94
|
-
)
|
|
95
|
-
self.s4 = pyEQL.Solution([["Na+", "8 mol"], ["Cl-", "8 mol"]], volume="2 L")
|
|
96
|
-
|
|
97
|
-
# if solutes are added at creation-time with substance / volume units,
|
|
98
|
-
# then the total volume of the solution should not change (should remain at 2 L)
|
|
99
|
-
def test_solute_addition_1(self):
|
|
100
|
-
result = self.s2.get_volume().to("L").magnitude
|
|
101
|
-
expected = 2
|
|
102
|
-
|
|
103
|
-
self.assertEqual(result, expected)
|
|
104
|
-
|
|
105
|
-
# if solutes are added at creation-time with substance / volume units,
|
|
106
|
-
# then the resulting mol/L concentrations should be exactly what was specified
|
|
107
|
-
def test_solute_addition_2(self):
|
|
108
|
-
result = self.s2.get_amount("Na+", "mol/L").magnitude
|
|
109
|
-
expected = 4
|
|
110
|
-
|
|
111
|
-
self.assertEqual(result, expected)
|
|
112
|
-
|
|
113
|
-
# if solutes are added at creation-time with substance / mass units,
|
|
114
|
-
# then the resulting mol/kg concentrations should be exactly what was specified
|
|
115
|
-
def test_solute_addition_3(self):
|
|
116
|
-
result = self.s3.get_amount("Na+", "mol/kg").magnitude
|
|
117
|
-
expected = 4
|
|
118
|
-
|
|
119
|
-
self.assertEqual(result, expected)
|
|
120
|
-
|
|
121
|
-
# the water mass of solution s2 should be less than that of s3, because
|
|
122
|
-
# of the volume recalculation
|
|
123
|
-
def test_solute_addition_4(self):
|
|
124
|
-
result_molL = self.s2.get_solvent_mass().to("kg").magnitude
|
|
125
|
-
result_molkg = self.s3.get_solvent_mass().to("kg").magnitude
|
|
126
|
-
|
|
127
|
-
self.assertLess(result_molL, result_molkg)
|
|
128
|
-
|
|
129
|
-
# if solutes are added at creation-time with substance units,
|
|
130
|
-
# then the resulting mol amounts should be exactly what was specified
|
|
131
|
-
def test_solute_addition_4a(self):
|
|
132
|
-
result = self.s4.get_amount("Na+", "mol").magnitude
|
|
133
|
-
expected = 8
|
|
134
|
-
|
|
135
|
-
self.assertEqual(result, expected)
|
|
136
|
-
|
|
137
|
-
# the water mass of solution s2 should be less than that of s4, because
|
|
138
|
-
# of the volume recalculation
|
|
139
|
-
def test_solute_addition_4b(self):
|
|
140
|
-
result_molL = self.s2.get_solvent_mass().to("kg").magnitude
|
|
141
|
-
result_mol = self.s4.get_solvent_mass().to("kg").magnitude
|
|
142
|
-
|
|
143
|
-
self.assertLess(result_molL, result_mol)
|
|
144
|
-
|
|
145
|
-
"""
|
|
146
|
-
Tests for set_amount() method
|
|
147
|
-
"""
|
|
148
|
-
|
|
149
|
-
# If the concentration of a solute is directly set with a substance / volume
|
|
150
|
-
# unit, the volume should not change
|
|
151
|
-
def test_solute_addition_5(self):
|
|
152
|
-
self.s2.set_amount("Na+", "5 mol/L")
|
|
153
|
-
self.s2.set_amount("Cl-", "5 mol/L")
|
|
154
|
-
result = self.s2.get_volume().to("L").magnitude
|
|
155
|
-
expected = 2
|
|
156
|
-
|
|
157
|
-
self.assertEqual(result, expected)
|
|
158
|
-
|
|
159
|
-
# If the concentration of a solute is directly set with a substance / volume
|
|
160
|
-
# unit, the water mass should be reduced
|
|
161
|
-
def test_solute_addition_6(self):
|
|
162
|
-
original = self.s2.get_solvent_mass().to("kg").magnitude
|
|
163
|
-
self.s2.set_amount("Na+", "5 mol/L")
|
|
164
|
-
self.s2.set_amount("Cl-", "5 mol/L")
|
|
165
|
-
result = self.s2.get_solvent_mass().to("kg").magnitude
|
|
166
|
-
|
|
167
|
-
self.assertLess(result, original)
|
|
168
|
-
|
|
169
|
-
# If the concentration of a solute is directly set with a substance / volume
|
|
170
|
-
# unit, the resulting concentration should be exactly what was specified
|
|
171
|
-
def test_solute_addition_7(self):
|
|
172
|
-
self.s2.set_amount("Na+", "5 mol/L")
|
|
173
|
-
self.s2.set_amount("Cl-", "5 mol/L")
|
|
174
|
-
result = self.s2.get_amount("Na+", "mol/L").magnitude
|
|
175
|
-
expected = 5
|
|
176
|
-
|
|
177
|
-
self.assertEqual(result, expected)
|
|
178
|
-
|
|
179
|
-
# If the concentration of a solute is directly set with a substance / mass
|
|
180
|
-
# unit, the volume should increase
|
|
181
|
-
def test_solute_addition_8(self):
|
|
182
|
-
original = self.s2.get_volume().to("L").magnitude
|
|
183
|
-
self.s2.set_amount("Na+", "5 mol/kg")
|
|
184
|
-
self.s2.set_amount("Cl-", "5 mol/kg")
|
|
185
|
-
result = self.s2.get_volume().to("L").magnitude
|
|
186
|
-
|
|
187
|
-
self.assertGreater(result, original)
|
|
188
|
-
|
|
189
|
-
# If the concentration of a solute is directly set with a substance / mass
|
|
190
|
-
# unit, the water mass should not change
|
|
191
|
-
def test_solute_addition_9(self):
|
|
192
|
-
original = self.s2.get_solvent_mass().to("kg").magnitude
|
|
193
|
-
self.s2.set_amount("Na+", "5 mol/kg")
|
|
194
|
-
self.s2.set_amount("Cl-", "5 mol/kg")
|
|
195
|
-
result = self.s2.get_solvent_mass().to("kg").magnitude
|
|
196
|
-
|
|
197
|
-
self.assertEqual(result, original)
|
|
198
|
-
|
|
199
|
-
# If the concentration of a solute is directly set with a substance / mass
|
|
200
|
-
# unit, the resulting concentration should be exactly what was specified
|
|
201
|
-
def test_solute_addition_10(self):
|
|
202
|
-
self.s2.set_amount("Na+", "5 mol/kg")
|
|
203
|
-
self.s2.set_amount("Cl-", "5 mol/kg")
|
|
204
|
-
result = self.s2.get_amount("Na+", "mol/kg").magnitude
|
|
205
|
-
expected = 5
|
|
206
|
-
|
|
207
|
-
self.assertEqual(result, expected)
|
|
208
|
-
|
|
209
|
-
# If the concentration of a solute is directly set with a substance
|
|
210
|
-
# unit, the volume should increase
|
|
211
|
-
def test_solute_addition_8a(self):
|
|
212
|
-
original = self.s2.get_volume().to("L").magnitude
|
|
213
|
-
self.s2.set_amount("Na+", "10 mol")
|
|
214
|
-
self.s2.set_amount("Cl-", "10 mol")
|
|
215
|
-
result = self.s2.get_volume().to("L").magnitude
|
|
216
|
-
|
|
217
|
-
self.assertGreater(result, original)
|
|
218
|
-
|
|
219
|
-
# If the concentration of a solute is directly set with a substance
|
|
220
|
-
# unit, the water mass should not change
|
|
221
|
-
def test_solute_addition_9a(self):
|
|
222
|
-
original = self.s2.get_solvent_mass().to("kg").magnitude
|
|
223
|
-
self.s2.set_amount("Na+", "10 mol")
|
|
224
|
-
self.s2.set_amount("Cl-", "10 mol")
|
|
225
|
-
result = self.s2.get_solvent_mass().to("kg").magnitude
|
|
226
|
-
|
|
227
|
-
self.assertEqual(result, original)
|
|
228
|
-
|
|
229
|
-
# If the concentration of a solute is directly set with a substance / mass
|
|
230
|
-
# unit, the resulting concentration should be exactly what was specified
|
|
231
|
-
def test_solute_addition_10a(self):
|
|
232
|
-
self.s2.set_amount("Na+", "10 mol")
|
|
233
|
-
self.s2.set_amount("Cl-", "10 mol")
|
|
234
|
-
result = self.s2.get_amount("Na+", "mol").magnitude
|
|
235
|
-
expected = 10
|
|
236
|
-
|
|
237
|
-
self.assertEqual(result, expected)
|
|
238
|
-
|
|
239
|
-
"""
|
|
240
|
-
Tests for add_amount() method
|
|
241
|
-
"""
|
|
242
|
-
|
|
243
|
-
# substance / volume units
|
|
244
|
-
|
|
245
|
-
# If the concentration of a solute is directly increased with a substance / volume
|
|
246
|
-
# unit, the volume should not change
|
|
247
|
-
def test_solute_addition_11(self):
|
|
248
|
-
self.s2.add_amount("Na+", "1 mol/L")
|
|
249
|
-
self.s2.add_amount("Cl-", "1 mol/L")
|
|
250
|
-
result = self.s2.get_volume().to("L").magnitude
|
|
251
|
-
expected = 2
|
|
252
|
-
|
|
253
|
-
self.assertEqual(result, expected)
|
|
254
|
-
|
|
255
|
-
# If the concentration of a solute is directly increased with a substance / volume
|
|
256
|
-
# unit, the water mass should be reduced
|
|
257
|
-
def test_solute_addition_12(self):
|
|
258
|
-
original = self.s2.get_solvent_mass().to("kg").magnitude
|
|
259
|
-
self.s2.add_amount("Na+", "1 mol/L")
|
|
260
|
-
self.s2.add_amount("Cl-", "1 mol/L")
|
|
261
|
-
result = self.s2.get_solvent_mass().to("kg").magnitude
|
|
262
|
-
|
|
263
|
-
self.assertLess(result, original)
|
|
264
|
-
|
|
265
|
-
# If the concentration of a solute is directly increased with a substance / volume
|
|
266
|
-
# unit, the resulting concentration should be exactly what was specified
|
|
267
|
-
def test_solute_addition_13(self):
|
|
268
|
-
self.s2.add_amount("Na+", "1 mol/L")
|
|
269
|
-
self.s2.add_amount("Cl-", "1 mol/L")
|
|
270
|
-
result = self.s2.get_amount("Na+", "mol/L").magnitude
|
|
271
|
-
expected = 5
|
|
272
|
-
|
|
273
|
-
self.assertEqual(result, expected)
|
|
274
|
-
|
|
275
|
-
# substance / mass units
|
|
276
|
-
|
|
277
|
-
# If the concentration of a solute is directly increased with a substance / mass
|
|
278
|
-
# unit, the volume should increase
|
|
279
|
-
def test_solute_addition_14(self):
|
|
280
|
-
original = self.s3.get_volume().to("L").magnitude
|
|
281
|
-
self.s3.add_amount("Na+", "1 mol/kg")
|
|
282
|
-
self.s3.add_amount("Cl-", "1 mol/kg")
|
|
283
|
-
result = self.s3.get_volume().to("L").magnitude
|
|
284
|
-
|
|
285
|
-
self.assertGreater(result, original)
|
|
286
|
-
|
|
287
|
-
# If the concentration of a solute is directly increased with a substance / mass
|
|
288
|
-
# unit, the water mass should not change
|
|
289
|
-
def test_solute_addition_15(self):
|
|
290
|
-
original = self.s3.get_solvent_mass().to("kg").magnitude
|
|
291
|
-
self.s3.add_amount("Na+", "1 mol/kg")
|
|
292
|
-
self.s3.add_amount("Cl-", "1 mol/kg")
|
|
293
|
-
result = self.s3.get_solvent_mass().to("kg").magnitude
|
|
294
|
-
|
|
295
|
-
self.assertEqual(result, original)
|
|
296
|
-
|
|
297
|
-
# If the concentration of a solute is directly increased with a substance / mass
|
|
298
|
-
# unit, the resulting concentration should be exactly what was specified
|
|
299
|
-
def test_solute_addition_16(self):
|
|
300
|
-
self.s3.add_amount("Na+", "1 mol/kg")
|
|
301
|
-
self.s3.add_amount("Cl-", "1 mol/kg")
|
|
302
|
-
result = self.s3.get_amount("Na+", "mol/kg").magnitude
|
|
303
|
-
expected = 5
|
|
304
|
-
|
|
305
|
-
self.assertEqual(result, expected)
|
|
306
|
-
|
|
307
|
-
# substance units
|
|
308
|
-
|
|
309
|
-
# If the concentration of a solute is directly increased with a substance
|
|
310
|
-
# unit, the volume should increase
|
|
311
|
-
def test_solute_addition_14a(self):
|
|
312
|
-
original = self.s2.get_volume().to("L").magnitude
|
|
313
|
-
self.s2.add_amount("Na+", "2 mol")
|
|
314
|
-
self.s2.add_amount("Cl-", "2 mol")
|
|
315
|
-
result = self.s2.get_volume().to("L").magnitude
|
|
316
|
-
|
|
317
|
-
self.assertGreater(result, original)
|
|
318
|
-
|
|
319
|
-
# If the concentration of a solute is directly increased with a substance
|
|
320
|
-
# unit, the water mass should not change
|
|
321
|
-
def test_solute_addition_15a(self):
|
|
322
|
-
original = self.s2.get_solvent_mass().to("kg").magnitude
|
|
323
|
-
self.s2.add_amount("Na+", "2 mol")
|
|
324
|
-
self.s2.add_amount("Cl-", "2 mol")
|
|
325
|
-
result = self.s2.get_solvent_mass().to("kg").magnitude
|
|
326
|
-
|
|
327
|
-
self.assertEqual(result, original)
|
|
328
|
-
|
|
329
|
-
# If the concentration of a solute is directly increased with a substance
|
|
330
|
-
# unit, the resulting concentration should be exactly what was specified
|
|
331
|
-
def test_solute_addition_16a(self):
|
|
332
|
-
self.s2.add_amount("Na+", "2 mol")
|
|
333
|
-
self.s2.add_amount("Cl-", "2 mol")
|
|
334
|
-
result = self.s2.get_amount("Na+", "mol").magnitude
|
|
335
|
-
expected = 10
|
|
336
|
-
|
|
337
|
-
self.assertEqual(result, expected)
|
|
338
|
-
|
|
339
|
-
# negative substance units
|
|
340
|
-
# If the concentration of a solute is directly decreased with a substance
|
|
341
|
-
# unit, the volume should decrease
|
|
342
|
-
def test_solute_addition_14b(self):
|
|
343
|
-
original = self.s2.get_volume().to("L").magnitude
|
|
344
|
-
self.s2.add_amount("Na+", "-2 mol")
|
|
345
|
-
self.s2.add_amount("Cl-", "-2 mol")
|
|
346
|
-
result = self.s2.get_volume().to("L").magnitude
|
|
347
|
-
|
|
348
|
-
self.assertLess(result, original)
|
|
349
|
-
|
|
350
|
-
# If the concentration of a solute is directly changed with a substance
|
|
351
|
-
# unit, the water mass should not change
|
|
352
|
-
def test_solute_addition_15b(self):
|
|
353
|
-
original = self.s2.get_solvent_mass().to("kg").magnitude
|
|
354
|
-
self.s2.add_amount("Na+", "-2 mol")
|
|
355
|
-
self.s2.add_amount("Cl-", "-2 mol")
|
|
356
|
-
result = self.s2.get_solvent_mass().to("kg").magnitude
|
|
357
|
-
|
|
358
|
-
self.assertEqual(result, original)
|
|
359
|
-
|
|
360
|
-
# If the concentration of a solute is directly changed with a substance
|
|
361
|
-
# unit, the resulting concentration should be exactly what was specified
|
|
362
|
-
def test_solute_addition_16b(self):
|
|
363
|
-
self.s2.add_amount("Na+", "-2 mol")
|
|
364
|
-
self.s2.add_amount("Cl-", "-2 mol")
|
|
365
|
-
result = self.s2.get_amount("Na+", "mol").magnitude
|
|
366
|
-
expected = 6
|
|
367
|
-
|
|
368
|
-
self.assertEqual(result, expected)
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
class Test_get_amount(unittest.TestCase, pyEQL.CustomAssertions):
|
|
372
|
-
"""
|
|
373
|
-
test the get_amount() method on a 1 mol/L NaCl solution
|
|
374
|
-
----------------------------
|
|
375
|
-
1 mol NaCl / L = 58.44 g/L
|
|
376
|
-
Na+ = 22.98977 g/mol
|
|
377
|
-
|
|
378
|
-
"""
|
|
379
|
-
|
|
380
|
-
# create the 1 M NaCl solution
|
|
381
|
-
def setUp(self):
|
|
382
|
-
self.s1 = pyEQL.Solution([["Na+", "1 mol/L"], ["Cl-", "1 mol/L"]])
|
|
383
|
-
|
|
384
|
-
# get_amount() - mol/L
|
|
385
|
-
def test_get_amount_molL(self):
|
|
386
|
-
result = self.s1.get_amount("Na+", "mol/L").magnitude
|
|
387
|
-
expected = 1
|
|
388
|
-
|
|
389
|
-
self.assertAlmostEqual(result, expected, 9)
|
|
390
|
-
|
|
391
|
-
# get_amount() - mol/kg
|
|
392
|
-
def test_get_amount_molkg(self):
|
|
393
|
-
result = self.s1.get_amount("Na+", "mol/kg").magnitude
|
|
394
|
-
expected = 1.02181221888
|
|
395
|
-
|
|
396
|
-
self.assertAlmostEqual(result, expected, 9)
|
|
397
|
-
|
|
398
|
-
# get_amount() - g/L
|
|
399
|
-
def test_get_amount_gL(self):
|
|
400
|
-
result = self.s1.get_amount("Na+", "g/L").magnitude
|
|
401
|
-
expected = 22.98977
|
|
402
|
-
|
|
403
|
-
self.assertAlmostEqual(result, expected, 9)
|
|
404
|
-
|
|
405
|
-
# get_amount() - mg
|
|
406
|
-
def test_get_amount_mg(self):
|
|
407
|
-
result = self.s1.get_amount("Na+", "mg").magnitude
|
|
408
|
-
expected = 22989.77
|
|
409
|
-
|
|
410
|
-
self.assertAlmostEqual(result, expected, 9)
|
|
411
|
-
|
|
412
|
-
# get_amount() - mol
|
|
413
|
-
def test_get_amount_mol(self):
|
|
414
|
-
result = self.s1.get_amount("Na+", "mol").magnitude
|
|
415
|
-
expected = 1
|
|
416
|
-
|
|
417
|
-
self.assertAlmostEqual(result, expected, 9)
|
|
418
|
-
|
|
419
|
-
# get_amount() - fraction
|
|
420
|
-
def test_get_amount_fraction(self):
|
|
421
|
-
result = self.s1.get_amount("Na+", "fraction")
|
|
422
|
-
expected = 0.01775457254
|
|
423
|
-
|
|
424
|
-
self.assertAlmostEqual(result, expected, 9)
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
if __name__ == "__main__":
|
|
428
|
-
unittest.main()
|