pyEQL 1.1.1__py3-none-any.whl → 1.1.2__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/engines.py +5 -14
- pyEQL/solution.py +31 -26
- {pyEQL-1.1.1.dist-info → pyEQL-1.1.2.dist-info}/METADATA +1 -1
- {pyEQL-1.1.1.dist-info → pyEQL-1.1.2.dist-info}/RECORD +9 -9
- {pyEQL-1.1.1.dist-info → pyEQL-1.1.2.dist-info}/AUTHORS.md +0 -0
- {pyEQL-1.1.1.dist-info → pyEQL-1.1.2.dist-info}/COPYING +0 -0
- {pyEQL-1.1.1.dist-info → pyEQL-1.1.2.dist-info}/LICENSE.txt +0 -0
- {pyEQL-1.1.1.dist-info → pyEQL-1.1.2.dist-info}/WHEEL +0 -0
- {pyEQL-1.1.1.dist-info → pyEQL-1.1.2.dist-info}/top_level.txt +0 -0
pyEQL/engines.py
CHANGED
|
@@ -229,10 +229,7 @@ class NativeEOS(EOS):
|
|
|
229
229
|
d[key] = str(mol / solv_mass)
|
|
230
230
|
|
|
231
231
|
# tell PHREEQC which species to use for charge balance
|
|
232
|
-
if (
|
|
233
|
-
solution.balance_charge is not None
|
|
234
|
-
and solution.balance_charge in solution.get_components_by_element()[el]
|
|
235
|
-
):
|
|
232
|
+
if solution.balance_charge is not None and solution._cb_species in solution.get_components_by_element()[el]:
|
|
236
233
|
d[key] += " charge"
|
|
237
234
|
|
|
238
235
|
# create the PHREEQC solution object
|
|
@@ -698,18 +695,12 @@ class NativeEOS(EOS):
|
|
|
698
695
|
if charge_adjust != 0:
|
|
699
696
|
logger.warning(
|
|
700
697
|
"After equilibration, the charge balance of the solution was not electroneutral."
|
|
701
|
-
f" {charge_adjust} eq of charge were added via {solution.
|
|
698
|
+
f" {charge_adjust} eq of charge were added via {solution._cb_species}"
|
|
702
699
|
)
|
|
703
700
|
|
|
704
|
-
if solution.balance_charge is None:
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
solution.components["H+"] += charge_adjust
|
|
708
|
-
elif solution.balance_charge == "pE":
|
|
709
|
-
raise NotImplementedError
|
|
710
|
-
else:
|
|
711
|
-
z = solution.get_property(solution.balance_charge, "charge")
|
|
712
|
-
solution.add_amount(solution.balance_charge, f"{charge_adjust/z} mol")
|
|
701
|
+
if solution.balance_charge is not None:
|
|
702
|
+
z = solution.get_property(solution._cb_species, "charge")
|
|
703
|
+
solution.add_amount(solution._cb_species, f"{charge_adjust/z} mol")
|
|
713
704
|
|
|
714
705
|
# rescale the solvent mass to ensure the total mass of solution does not change
|
|
715
706
|
# this is important because PHREEQC and the pyEQL database may use slightly different molecular
|
pyEQL/solution.py
CHANGED
|
@@ -261,39 +261,44 @@ class Solution(MSONable):
|
|
|
261
261
|
for item in self._solutes:
|
|
262
262
|
self.add_solute(*item)
|
|
263
263
|
|
|
264
|
-
#
|
|
264
|
+
# determine the species that will be used for charge balancing, when needed.
|
|
265
|
+
# this is necessary to do even if the composition is already electroneutral,
|
|
266
|
+
# because the appropriate species also needs to be passed to equilibrate
|
|
267
|
+
# to keep from distorting the charge balance.
|
|
265
268
|
cb = self.charge_balance
|
|
269
|
+
if self.balance_charge is None:
|
|
270
|
+
self._cb_species = None
|
|
271
|
+
elif self.balance_charge == "pH":
|
|
272
|
+
self._cb_species = "H[+1]"
|
|
273
|
+
elif self.balance_charge == "pE":
|
|
274
|
+
raise NotImplementedError("Balancing charge via redox (pE) is not yet implemented!")
|
|
275
|
+
elif self.balance_charge == "auto":
|
|
276
|
+
# add the most abundant ion of the opposite charge
|
|
277
|
+
if cb <= 0:
|
|
278
|
+
self._cb_species = max(self.cations, key=self.cations.get)
|
|
279
|
+
elif cb > 0:
|
|
280
|
+
self._cb_species = max(self.anions, key=self.anions.get)
|
|
281
|
+
else:
|
|
282
|
+
ions = set().union(*[self.cations, self.anions]) # all ions
|
|
283
|
+
self._cb_species = self.balance_charge
|
|
284
|
+
if self._cb_species not in ions:
|
|
285
|
+
raise ValueError(
|
|
286
|
+
f"Charge balancing species {self._cb_species} was not found in the solution!. "
|
|
287
|
+
f"Species {ions} were found."
|
|
288
|
+
)
|
|
289
|
+
|
|
290
|
+
# adjust charge balance, if necessary
|
|
266
291
|
if not np.isclose(cb, 0, atol=1e-8) and self.balance_charge is not None:
|
|
267
292
|
balanced = False
|
|
268
293
|
self.logger.info(
|
|
269
|
-
f"Solution is not electroneutral (C.B. = {cb} eq/L). Adding {
|
|
294
|
+
f"Solution is not electroneutral (C.B. = {cb} eq/L). Adding {self._cb_species} to compensate."
|
|
270
295
|
)
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
) # if C.B. is negative, we need to add cations. H+ is 1 eq/mol
|
|
296
|
+
z = self.get_property(self._cb_species, "charge")
|
|
297
|
+
self.components[self._cb_species] += -1 * cb / z * self.volume.to("L").magnitude
|
|
298
|
+
if np.isclose(self.charge_balance, 0, atol=1e-8):
|
|
275
299
|
balanced = True
|
|
276
|
-
elif self.balance_charge == "pE":
|
|
277
|
-
raise NotImplementedError("Balancing charge via redox (pE) is not yet implemented!")
|
|
278
|
-
else:
|
|
279
|
-
ions = set().union(*[self.cations, self.anions]) # all ions
|
|
280
|
-
if self.balance_charge == "auto":
|
|
281
|
-
# add the most abundant ion of the opposite charge
|
|
282
|
-
if cb <= 0:
|
|
283
|
-
self.balance_charge = max(self.cations, key=self.cations.get)
|
|
284
|
-
elif cb > 0:
|
|
285
|
-
self.balance_charge = max(self.anions, key=self.anions.get)
|
|
286
|
-
if self.balance_charge not in ions:
|
|
287
|
-
raise ValueError(
|
|
288
|
-
f"Charge balancing species {self.balance_charge} was not found in the solution!. "
|
|
289
|
-
f"Species {ions} were found."
|
|
290
|
-
)
|
|
291
|
-
z = self.get_property(self.balance_charge, "charge")
|
|
292
|
-
self.components[self.balance_charge] += -1 * cb / z * self.volume.to("L").magnitude
|
|
293
|
-
balanced = True
|
|
294
|
-
|
|
295
300
|
if not balanced:
|
|
296
|
-
warnings.warn(f"Unable to balance charge using species {self.
|
|
301
|
+
warnings.warn(f"Unable to balance charge using species {self._cb_species}")
|
|
297
302
|
|
|
298
303
|
@property
|
|
299
304
|
def mass(self) -> Quantity:
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
pyEQL/__init__.py,sha256=OCp_PiQEPyVoi1VX0ursBzHJWN6nDS1Id6bTBOgqCYs,1999
|
|
2
2
|
pyEQL/activity_correction.py,sha256=eOixjgTd5hTrTRD5s6aPCCG12lAIH7-lRN0Z1qHu678,37151
|
|
3
|
-
pyEQL/engines.py,sha256=
|
|
3
|
+
pyEQL/engines.py,sha256=kE4ZtV2Z-zhOwtkH0cbv95oG1CETJmqMOoT0UfDuJeo,35221
|
|
4
4
|
pyEQL/equilibrium.py,sha256=YCtoAJSgn1WC9NJnc3H4FTJdKQvogsvCuj7HqlKMtww,8307
|
|
5
5
|
pyEQL/functions.py,sha256=nc-Hc61MmW-ELBR1PByJvQnELxM7PZexMHbU_O5-Bnw,10584
|
|
6
6
|
pyEQL/salt_ion_match.py,sha256=0nCZXmeo67VqcyYWQpPx-81hjSvnsg8HFB3fIyfjW_k,4070
|
|
7
7
|
pyEQL/solute.py,sha256=no00Rc3tRfHmyht4wm2UXA1KZhKC45tWMO5QEkZY6yg,5140
|
|
8
|
-
pyEQL/solution.py,sha256=
|
|
8
|
+
pyEQL/solution.py,sha256=vtC2xRUt1y2wTv_L1o7Qs3wr8b_X7wvkUsp56499baQ,113898
|
|
9
9
|
pyEQL/utils.py,sha256=DWLtNm71qw5j4-jqBp5v3LssEjWgJnVvI6a_H60c5ic,6670
|
|
10
10
|
pyEQL/database/geothermal.dat,sha256=kksnfcBtWdOTpNn4CLXU1Mz16cwas2WuVKpuMU8CaVI,234230
|
|
11
11
|
pyEQL/database/llnl.dat,sha256=jN-a0kfUFbQlYMn2shTVRg1JX_ZhLa-tJ0lLw2YSpLU,751462
|
|
@@ -17,10 +17,10 @@ pyEQL/presets/rainwater.yaml,sha256=S0WHZNDfCJyjSSFxNFdkypjn2s3P0jJGCiYIxvi1ibA,
|
|
|
17
17
|
pyEQL/presets/seawater.yaml,sha256=oryc1CkhRz20RpWE6uiGiT93HoZnqlB0s-0PmBWr3-U,843
|
|
18
18
|
pyEQL/presets/urine.yaml,sha256=0Njtc-H1fFRo7UhquHdiSTT4z-8VZJ1utDCk02qk28M,679
|
|
19
19
|
pyEQL/presets/wastewater.yaml,sha256=jTTFBpmKxczaEtkCZb0xUULIPZt7wfC8eAJ6rthGnmw,502
|
|
20
|
-
pyEQL-1.1.
|
|
21
|
-
pyEQL-1.1.
|
|
22
|
-
pyEQL-1.1.
|
|
23
|
-
pyEQL-1.1.
|
|
24
|
-
pyEQL-1.1.
|
|
25
|
-
pyEQL-1.1.
|
|
26
|
-
pyEQL-1.1.
|
|
20
|
+
pyEQL-1.1.2.dist-info/AUTHORS.md,sha256=K9ZLhKFwZ2zLlFXwN62VuUYCpr5T6n4mOUCUHlytTUs,415
|
|
21
|
+
pyEQL-1.1.2.dist-info/COPYING,sha256=Ww2oUywfFTn242v9ksCgQdIVSpcMXJiKKePn0GFm25E,7649
|
|
22
|
+
pyEQL-1.1.2.dist-info/LICENSE.txt,sha256=2Zf1F7RzbpeposgIxUydpurqNCMoMgDi2gAB65_GjwQ,969
|
|
23
|
+
pyEQL-1.1.2.dist-info/METADATA,sha256=1mxAOqZ5yuBRO4iDo2RZN7gpAcJMXYOfY_KKFPFMzQQ,6096
|
|
24
|
+
pyEQL-1.1.2.dist-info/WHEEL,sha256=Wyh-_nZ0DJYolHNn1_hMa4lM7uDedD_RGVwbmTjyItk,91
|
|
25
|
+
pyEQL-1.1.2.dist-info/top_level.txt,sha256=QMOaZjCAm_lS4Njsjh4L0B5aWnJFGQMYKhuH88CG1co,6
|
|
26
|
+
pyEQL-1.1.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|