Vitens / phreeqpython

Object-oriented python wrapper for the VIPhreeqc module
Apache License 2.0
68 stars 19 forks source link

custom phases? #22

Closed uliw closed 1 year ago

uliw commented 1 year ago

I have the following in my phreeqc input file

PHASES
BaSO4 = 1.0000 SO4-2 + 1.0000 Ba+2
    -analytic   3.630937e+003   1.218154e+000   -1.393850e+005  -1.437233e+003  5.362526e+006   -4.566328e-004
    -Vm  52.1000

is it possible to do this with phreeqpython, either as a python statement or as a startupfile?

Great tool BTW!

AbelHeinsbroek commented 1 year ago

Great to hear you like our work!

Sure thing, you can run custom snippets of PHREEQC code using: pp.ip.run_string(cmd)

import phreeqpython

pp = phreeqpython.PhreeqPython()

cmd = """
PHASES
TestPhase
BaSO4 = 1.0000 SO4-2 + 1.0000 Ba+2
    -analytic   3.630937e+003   1.218154e+000   -1.393850e+005  -1.437233e+003  5.362526e+006   -4.566328e-004
    -Vm  52.1000
"""

pp.ip.run_string(cmd)

sol = pp.add_solution({
    'units': 'mg/l',
    'Ba': 5,
    'S(6)': '5 as SO4',
})
sol.phases

Results in

{'Barite': 1.1787188714263994,
 'Fix_pH': -7.0,
 'H2(g)': -22.048923033678367,
 'H2O(g)': -1.5028233204748613,
 'O2(g)': -39.18764240620709,
 'TestPhase': 1.1839856543479588}
uliw commented 1 year ago

awesome! Thx!