In this notebook we will look at how ChemPy can formulate non-linear systems of equations based on precipitation. For more backgroud on the non-linear equation system you may want to look at the notebook "conditional" in the pyneqsys repo.
In [ ]:
from chempy.chemistry import Species, Equilibrium
from chempy.equilibria import EqSystem
In [ ]:
Na_p = Species('Na+', 1, composition={11: 1})
Cl_m = Species('Cl-', -1, composition={17: 1})
NaCl = Species('NaCl', phase_idx=1, composition={11: 1, 17: 1})
eq = Equilibrium({'NaCl': 1}, {'Na+': 1, 'Cl-': 1}, 4.0)
eqsys = EqSystem([eq], [Na_p, Cl_m, NaCl])
In [ ]:
sol, info, sane = eqsys.root({'Na+': 5, 'Cl-': 5, 'NaCl': 0})
assert info['success'] and sane
sol
In [ ]:
sol, info, sane = eqsys.root({'Na+': 1, 'Cl-': 1, 'NaCl': 0})
assert info['success'] and sane
sol
In [ ]:
sol, info, sane = eqsys.root({'Na+': 2, 'Cl-': 2, 'NaCl': 0})
assert info['success'] and sane
sol
In [ ]:
sol, info, sane = eqsys.root({'Na+': 0, 'Cl-': 0, 'NaCl': 2})
assert info['success'] and sane
sol
In [ ]:
sol, info, sane = eqsys.root({'Na+': 0, 'Cl-': 0, 'NaCl': 5.0})
assert info['success'] and sane
sol
In [ ]:
sol, info, sane = eqsys.root({'Na+': 0, 'Cl-': 0, 'NaCl': 5.0}, rref_preserv=True)
assert info['success'] and sane
sol
In [ ]:
from chempy.equilibria import NumSysLog
sol, info, sane = eqsys.root({'Na+': 0, 'Cl-': 0, 'NaCl': 5.0}, rref_preserv=True, NumSys=NumSysLog)
assert info['success'] and sane
sol
In [ ]:
from chempy.equilibria import NumSysLin
sol, info, sane = eqsys.root({'Na+': 0, 'Cl-': 0, 'NaCl': 5.0}, rref_preserv=True, NumSys=(NumSysLog, NumSysLin))
assert info['success'] and sane
sol