Error messages from Phreeqpy

150 views
Skip to first unread message

ispmarin

unread,
Nov 13, 2012, 3:01:10 PM11/13/12
to phreeqp...@googlegroups.com
Hi all,

I'm using Phreeqpy in both windows and Linux platforms. It is correctly called and runs a first run_string, but when I call SOLUTION_MODIFY, get_array returns empty. Here is an example code:

import phreeqpy.iphreeqc.phreeqc_dll as phreeqc_mod

class phreeqc_conc(object):
    '''
    classdocs
    '''

    def __init__(self):
        self.phreeqc = phreeqc_mod.IPhreeqc()
        self.phreeqc.load_database(r"phreeqc.dat")
        
        selected_output = """
            SOLUTION 1
              ph 7 charge
              temp 25
             
              C(4) 1 CO2(g) -3.5
            
            EQUILIBRIUM_PHASES    0
                Calcite    0.0    5
            
            SELECTED_OUTPUT 
               -reset false
               -totals C(4)
               -molalities CO2 
               -molalities HCO3- 
               -molalities CO3-2 
               -molalities Ca+2
            END
        """
        
        print self.phreeqc.run_string(selected_output)
        print self.phreeqc.get_selected_output_array()
        
        
        modify_output="""
        SOLUTION_MODIFY 1
            -totals
            CO2(g)    1.0
        END
        """
        
        print self.phreeqc.run_string(modify_output)
        print self.phreeqc.get_selected_output_array()

Is there a way to get any error messages that a wrong SOLUTION_MODIFY is throwing out, to debug the string? 

Also, the exact same program runs in windows, but segfaults in Linux, with iphreeqc compiled with the intel compiler.

Cheers

Dr. Mike Mueller

unread,
Nov 13, 2012, 3:58:38 PM11/13/12
to phreeqp...@googlegroups.com, ispm...@gmail.com
Hi ispmarin,

It looks like Phreeqpy is doing the right thing.
You get an empty array since nothing happens.

I added:

RUN_CELLS
-cells 1

to your string for the run after the modification. The
whole program is shown below. Now it gives a line of output
for the second run.

It works for me on Windows. I have not tested it on Linux
yet. Maybe you use a 64-bit iphreeqc and a 32-bit Python on Linux?

Cheers,
Mike


import pprint
import phreeqpy.iphreeqc.phreeqc_dll as phreeqc_mod

class phreeqc_conc(object):
'''
classdocs
'''

def __init__(self):
self.phreeqc = phreeqc_mod.IPhreeqc()
self.phreeqc.load_database(r"phreeqc.dat")

selected_output = """
SOLUTION 1
ph 7 charge
temp 25

C(4) 1 CO2(g) -3.5

EQUILIBRIUM_PHASES 0
Calcite 0.0 5

SELECTED_OUTPUT
-reset false
-totals C(4)
-molalities CO2
-molalities HCO3-
-molalities CO3-2
-molalities Ca+2
END
"""

self.phreeqc.run_string(selected_output)
pprint.pprint(self.phreeqc.get_selected_output_array())


modify_output="""
SOLUTION_MODIFY 1
-totals
CO2(g) 1.0
RUN_CELLS
-cells 1
END
"""

self.phreeqc.run_string(modify_output)
print '#' * 60
pprint.pprint(self.phreeqc.get_selected_output_array())

if __name__ == '__main__':
phreeqc_conc()


Am 13.11.12 21:01, schrieb ispmarin:
> --
> You received this message because you are subscribed to the Google Groups
> ""phreeqpy-users" group.
> To post to this group, send email to phreeqp...@googlegroups.com.
> To unsubscribe from this group, send email to
> phreeqpy-user...@googlegroups.com.
> For more options, visit this group at
> https://groups.google.com/d/forum/phreeqpy-users?hl=en.
>
> More information about PhreeqPy can found at http://www.phreeqpy.com.
>
>


ispmarin

unread,
Nov 13, 2012, 4:24:20 PM11/13/12
to phreeqp...@googlegroups.com
Hey there,

Thanks for the fast update. With the RUN_CELLS it works. Just be clear, every time some change is made in the solution, considering just one batch reaction, RUN_CELL must be called? The scenario is a transport-geochemical coupled simulation, where the transport is done completely outside Phreeqc. 

Also, is there any documentation for error handling for IPhreeqc and PhreeqPy?

Thanks again,

Dr. Mike Mueller

unread,
Nov 14, 2012, 7:55:25 PM11/14/12
to phreeqp...@googlegroups.com
Am 13.11.12 22:24, schrieb ispmarin:
> Hey there,
>
> Thanks for the fast update. With the RUN_CELLS it works. Just be clear, every
> time some change is made in the solution, considering just one batch reaction,
> RUN_CELL must be called? The scenario is a transport-geochemical coupled
> simulation, where the transport is done completely outside Phreeqc.

Yes, according to the IPhreeqc documentation:

"""
The RUN_CELLS data block streamlines the process of setting up, running, and
saving the results of a calculation for a cell. For cells selected by the data
block specifications, all of the reactants with a given cell number are brought
together and reacted, after which, the resulting compositions of the solution
and reactants are saved back to the given cell number.
"""

After modifying the data you need to trigger a new calculation.
Compare the advect.py in the example directory of PhreeqPy. It also uses
RUN_CELLS and it also does transport fully outside PHREEQC.

> Also, is there any documentation for error handling for IPhreeqc and PhreeqPy?

I am about to make a new release of PhreeqPy. This has better error handling.
It works but needs some more documentation. I've been just too busy with other
things lately.

PHREEQC 3 will be released soon-ish. Its documentation will have more
information about all these new features. Seems like you work at the
bleeding-edge. ;)

Mike

> Thanks again,

Ivan M

unread,
Nov 19, 2012, 4:36:22 PM11/19/12
to phreeqp...@googlegroups.com
Hello again Mike,

It seems indeed! I'm starting to work with Phreeqc and PhreeqPy, and I'm highly interested in the inner workings of both. Please let me know if I can help somehow.

I'm trying to wrap my head around the SOLUTION_MODIFY part, as is still not very clear to me. (And please let me know if this is not the right place to ask these questions. I'll gladly ask somewhere else.)

Let's say that I want to mix 2.0e-3 CO2 in solution of pure water:

SOLUTION 1
   ph 7 charge
   temp 25
   C(4) 2.0 as CO2
END

Dandy. It dissolves, the pH changes correspondingly. So now I do a transport step. I can output the molalities of all dissolved components:

SELECTED_OUTPUT 
   -reset false
   -totals C(4)
   -molalities CO2
   -molalities HCO3-
   -molalities CO3-2
END

Perfect, I get the total carbon and each component molality. Now I want to track, on my transport simulation, CO2, not total carbon. So I change outside Phreeqc the CO2 concentration, and now I need to set back the transported concentration to Phreeqc, to calculate again the equilibrium. So I tried

SOLUTION_MODIFY 1
   -totals
     CO2    0.05
RUN_CELLS
   -cells 1
END

And I get a seg fault with Linux/Phreeqpy and an empyt array in Windows/Phreeqpy if I don't use an element in -totals. It only works if I use

SOLUTION_MODIFY 1
   -totals
     C(4)   0.05
RUN_CELLS
   -cells 1
END

But then it's not what I desire. So two things: first, how can I identify and prevent the segfault with the wrong SOLUTION_MODIFY part, and second, how can I input again in Phreeqc using SOLUTION_MODIFY a component (like CO2) and not an element?

Thanks again,

Cheers


_________________________________________
Ivan S.P. Marin, PhD
 
Postdoctoral Associate
Département de géologie et de génie géologique
Pavillon Adrien-Pouliot, local 3744
1065. ave de la Médecine
Université Laval
Québec (Québec) Canada
G1V 0A6
418-656-2131 poste 7246



2012/11/14 Dr. Mike Mueller <mmue...@hydrocomputing.com>
Am 13.11.12 22:24, schrieb ispmarin:
> Hey there,
>
> Thanks for the fast update. With the RUN_CELLS it works. Just be clear, every
> time some change is made in the solution, considering just one batch reaction,
> RUN_CELL must be called? The scenario is a transport-geochemical coupled
> simulation, where the transport is done completely outside Phreeqc.

Yes, according to the IPhreeqc documentation:

"""
The RUN_CELLS data block streamlines the process of setting up, running, and
saving the results of a calculation for a cell. For cells selected by the data
block specifications, all of the reactants with a given cell number are brought
together and reacted, after which, the resulting compositions of the solution
and reactants are saved back to the given cell number.
"""

After modifying the data you need to trigger a new calculation.
Compare the advect.py in the example directory of PhreeqPy. It also uses
RUN_CELLS and it also does transport fully outside PHREEQC.

> Also, is there any documentation for error handling for IPhreeqc and PhreeqPy?

I am about to make a new release of PhreeqPy. This has better error handling.
It works but needs some more documentation. I've been just too busy with other
things lately.

PHREEQC 3 will be released soon-ish. Its documentation will have more
information about all these new features. Seems like you work at the
bleeding-edge. ;)

Mike

> Thanks again,
Reply all
Reply to author
Forward
0 new messages