Vitens / phreeqpython

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

Retrieving phase dissolved or precipitated #43

Open cevans3098 opened 3 months ago

cevans3098 commented 3 months ago

Curious if you could provide some insight on how you can retrieve the amount of moles of a phase dissolved or precipitated. I can see how to do this for individual elements or species, but it is unclear how to do this for a phase.

for example, given the code, where I have water with a pH of 1 and I add Cu metal to the solution. If I equalize to a SI =0 for all phases, how can I see how much of each phase exists in the solution?

from phreeqpython import PhreeqPython
from pathlib import Path

db_dir = Path('C:/Users/Craig/source/repos/eWasteSim/Database')
db = Path('minteq.dat')

pp = PhreeqPython(database= db, database_directory= db_dir, debug= False)

# this is for simulation purposes, in the model this will be a copy of the block from the left
solidsInlet = {
            'CuMetal'           : 10.0, 
            'Atacamite'         : 0.0, 
            'Cu(OH)2'           : 0.0, 
            'Cuprite'           : 0.0, 
            'Melanothallite'    : 0.0, 
            'Nantokite'         : 0.0, 
            'Tenorite'          : 0.0
}

# This is for simulations purposes, in the model this will be a copy of the block from above
liquidsInlet = solution = pp.add_solution({
                            'units' :   'mol/kgw',
                            'pH'    :   1,
                            'temp'  :   50.0,
                            'redox' :   'pe',
                            'Cu'    :   0,
                            'Cl'    :   '1 charge',
                            'O(0)'  :   0
})

liquidsOulet = liquidsInlet.copy()
liquidsOulet.change_temperature(60)

phasesInlet = [k for k in solidsInlet.keys()]
inletMoles = [v for v in solidsInlet.values()]
SI_Target = [0]*len(phasesInlet)

liquidsOulet.equalize(phases= phasesInlet, to_si= SI_Target, in_phase= inletMoles)

This can be more complicated when more than one metal exists and the pH is changing. Can you recommend a method to obtain the moles of a given phase exist?

Thanks