Skip to content

Commit d135ce1

Browse files
committed
Merge branch 'master' of github.com:CalebBell/chemicals
2 parents 2faa1f0 + 8d76e60 commit d135ce1

File tree

6 files changed

+13
-11
lines changed

6 files changed

+13
-11
lines changed

chemicals/reaction.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,6 @@ def balance_stoichiometry(matrix, rounding=9, allow_fractional=False):
10671067
>>> balance_stoichiometry(matrix, allow_fractional=True)
10681068
[1.0, 1.25, 1.0, 1.5]
10691069
1070-
This algorithm relies on `scipy`.
10711070
The behavior of this function for inputs which do not have a unique
10721071
solution is undefined.
10731072
@@ -1090,11 +1089,14 @@ def balance_stoichiometry(matrix, rounding=9, allow_fractional=False):
10901089
Maple To Obtain Chemical Equations." Journal of Chemical Education
10911090
74, no. 11 (November 1, 1997): 1369. https://doi.org/10.1021/ed074p1369.
10921091
'''
1093-
import scipy.linalg
1094-
done = scipy.linalg.null_space(matrix, rcond=None)
1095-
if len(done[0]) > 1:
1096-
raise ValueError("No solution")
1097-
d = done[:, 0].tolist()
1092+
from fluids.numerics import null_space
1093+
null_vectors = null_space(matrix, rcond=None)
1094+
1095+
if not null_vectors or len(null_vectors[0]) == 0:
1096+
raise ValueError("No solution found")
1097+
1098+
# Take the first null vector (assuming unique solution)
1099+
d = [row[0] for row in null_vectors]
10981100
min_value_inv = 1.0/min(d, key=abs)
10991101
d = [i*min_value_inv for i in d]
11001102
d = [round_to_significant(v, rounding) for v in d]

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
numpy
22
scipy>=1.6.0
33
pandas
4-
fluids>=1.0.27
4+
fluids>=1.1.0

requirements_docs.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ scipy
33
numpydoc
44
pint
55
nbsphinx
6-
fluids>=1.0.27
6+
fluids>=1.1.0
77
IPython
88
ipython
99
numba

requirements_test.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ numpy
22
scipy
33
pandas
44
sympy
5-
fluids>=1.0.27
5+
fluids>=1.1.0
66
pytest
77
pytest-cov
88
coveralls

requirements_test_multiarch.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
sympy
2-
fluids>=1.0.27
2+
fluids>=1.1.0
33
pytest
44
pytest-cov
55
pint

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def run(self):
115115
version = '1.3.2',
116116
description = 'Chemical properties component of Chemical Engineering Design Library (ChEDL)',
117117
author = 'Caleb Bell',
118-
install_requires=['fluids>=1.0.27', "scipy>=1.6.0", 'numpy', 'pandas'],
118+
install_requires=['fluids>=1.1.0', "scipy>=1.6.0", 'numpy', 'pandas'],
119119
extras_require = {
120120
'Coverage documentation': ['wsgiref>=0.1.2', 'coverage>=4.0.3']
121121
},

0 commit comments

Comments
 (0)