Jump to content
Geochemist's Workbench Support Forum

Helge

Members
  • Posts

    43
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by Helge

  1. Sorry for opening this thread again, but I am again having trouble using the python plugin. 

    I call the python script from cmd-line using 

    python 0293.py

    Error message is that it can't find the given module (?)

    I enclose the database, the script, and the env-variables. Python version is 3.10.5

    I use GWB Professional, version 17.? (can't figure out where to retrieve the version number)

    I know for certain that the enclosed script worked February last year. Every help appreciated. 

    Best regards,

    Helge

     

    0293.zip

  2. Hello Jia,

    this is number 81 in a series of calculations, run in a normal windows command prompt. At number 81 the output in the prompt stopped. But indeed, if I wait long enough, the calculation converges. 

    Please excuse my impatience. 🙂

    In fact, we encounter numerical problems every once in a while, but usually epsilon, delxi, or pickup entire are our friends. 

    Best regards,

    Helge

  3. This is an interesting case. Using GWB and the attached rea-script the equilibrium is found. Translating to python and running again the equilibrium is found, too. But the calculation has to be killed manually, the attached log-file has 44 MB. Addmittedly, it is a tricky calculation because SI of Na2CO3:7H2O(s) is -0.0065 at this point, also pretty much close to saturation. 

    I wonder whether the command epsilon = 5e-6 is correctly transferred using python.

    Best regards,

    Helge

    gwb.zip

  4. Dear Jia,

    thanks for the advice, it works. The beginning of the script now reads 

    #!/usr/bin/env python
    import os, glob, sys, string, math
    
    
    # To find the plugin
    sys.path.append('c:/program files/gwb/src')
    os.add_dll_directory('c:/program files/gwb')
    
    
    # import GWBplugin class
    from GWBplugin import *

    Indeed the problem didn't arise with a colleague who uses python 3.8 (I am using 3.10). 

    Best regards,

    Helge

  5. Hello,

    I fail to run a python script which worked on a different computer and I simply cannot figure out where is the problem. Enclosed you find

    • python script
    • database 
    • settings for path variables
    • output on the command line

    In case it is important: I am working from remote ("Home Office") on the computer where the executables are located. 

    Many thanks,

    Helge

    python-problem.zip

  6. As to my knowledge there are experimental data at higher temperature which could allow for the determination of Pitzer coefficients for Si- and Al-Species. But this work (compiling suitable experimental data, critical assessment, fitting procedure) simply has not been done yet. A project to pursue this goal has been outlined and we are waiting for funding. 🙂

    Best regards,

    Helge

     

  7. Hello Yumeng,

    please look here: https://www.thereda.de/en/datenabfrage/download

    Please note that depending on the particular system the valid temperature range for Pitzer coefficients is different. This is marked in the (quite bulky) parameterfile. 

    Note 2: Pitzer coefficients for Si- and Al-Species are only estimates and valid for 25°C only. However, if the solubility of the solid phase in question is very low, then the database might give a good estimate. Whether the assumption of thermodynamic equilibrium between a silicate mineral and an aqueous solution is valid needs to be ascertained in any particular case.

    If you apply THEREDA to real systems for which experimental data are available, we are always very interested in your results!

    Best regards,

    Helge 

    • Like 1
  8. Hello Vincent,

    I am not aware of any thermodynamic database which is able to calculate equilibria down to -80°C. Perhaps it helps to consult

    https://apps.dtic.mil/dtic/tr/fulltext/u2/a288456.pdf

    In the context of martian geochemistry some publications are available, e. g. https://www.sciencedirect.com/science/article/abs/pii/S0016703707005844

    Another hint: look into Craig Bethkes book about geochemical modeling, chapter on activity coefficients. Water activity is calculated from osmotic coefficient, which in turn is subject of Pitzer coefficients for dissolved salts and of Aphi. In pure water the calculation of water activity boils down to the Debye-Hückel equation where the impact of Aphi prevails. I think GWB calculates Aphi temperature dependent (Debye-Hückel coefficients), but I am sure the underlying temperature function has never been tested down to such a low temperature.

    In salt solutions situation is even worse. I encountered a similar situation, though for elevated temperatures, where a temperature function for a single Pitzer coefficient beyond 170°C went mad all of a sudden. In your specific situation you had to inspect the temperature function for every single Pitzer coefficient in your database - a formidable task!

    Best regards,
    Helge

  9. Hello Jia,

    I cannot believe that there is no way to retrieve the total concentration of all species being formed from a single redox species. But I cannot see any way to get this result in gtplot either. Also in Tedit I don't see product species grouped into their respective oxidation state. In the present (very special) case the total element concentration gives indeed the correct answer. But this doesn't offer a general solution to the problem, e. g. for those cases, where you have two oxidation states of one basis species in comparable concentration.

    Thank you for the replay anyway.

    Helge

  10. I am trying to write the log10 total molality of Np(V) to file using python. The present line looks like this:

    fobj_ResultFile.write(Testcase + '\t' + '1180' + '\t' + 'log10(conc_oxidationstate(NpO2<+>))' + '\t'+ str(math.log10(myGWB.results('concentration "NpO2+"', 'molal')[0])) + '\n')

    A normal export for a single species looks like this

    fobj_ResultFile.write(Testcase + '\t' + '1181' + '\t' + 'log10(conc_solute(Ca[NpO2(OH)2]<+>))' + '\t'+ str(math.log10(myGWB.results('concentration aqueous "Ca[NpO2(OH)2]+"', 'molal')[0])) + '\n')

    My opinion was that by omitting the "aqueous" behind "concentration" would cause GWB to export the total molality of the given oxidationstate, as defined by the redox species (NpO2+ in this case). Instead, what I observe, is that the concentration of the species NpO2+ is exported. What I would like to have is the total sum of all Np(V)-species in solution.

    Any ideas appreciated.

    Helge

  11. Hello everybody,

    in the attached test case I can retrieve all concentrations with 

      species = myGWB.results("species")
        conc = myGWB.results("concentration aqueous", "mol/kg")
        print "\nThere are" , len(species) , "aqueous species.\n"
        for i in range(len(species)):
            print "%-4s = %10.4g mol/kg" % (species[i], conc[i])

    However, if I export the results to file with   

     ResultFile = Testcase + '_mod.out'
        fobj_ResultFile = open(ResultFile,'w')
        fobj_ResultFile.write(Testcase + '\t' + 'pcH' + '\t' + str(-(math.log10(myGWB.results('concentration aqueous H+', 'molal')[0]))) + '\n')
        fobj_ResultFile.write(Testcase + '\t' + 'conc_element(Nd)' + '\t' + str(myGWB.results('concentration Neodymium', 'molal')[0]) + '\n')
        fobj_ResultFile.write(Testcase + '\t' + 'conc_solute(Nd(OH)2<+>)' + '\t' + str(myGWB.results('concentration aqueous Nd(OH)2+', 'molal')[0]) + '\n')
        fobj_ResultFile.write(Testcase + '\t' + 'conc_solute(Nd(OH)<2+>)' + '\t' + str(myGWB.results('concentration aqueous Nd(OH)++', 'molal')[0]) + '\n')
        fobj_ResultFile.write(Testcase + '\t' + 'conc_solute(Nd<3+>)' + '\t' + str(myGWB.results('concentration aqueous Nd+++', 'molal')[0]) + '\n')
        fobj_ResultFile.write(Testcase + '\t' + 'conc_solute(Nd(OH)3<0>)' + '\t' + str(myGWB.results('concentration aqueous Nd(OH)3', 'molal')[0]) + '\n')
        fobj_ResultFile.write(Testcase + '\t' + 'conc_solute(Nd(OH)4<->)' + '\t' + str(myGWB.results('concentration aqueous Nd(OH)4-', 'molal')[0]) + '\n')
        fobj_ResultFile.write(Testcase + '\t' + 'conc_solute(NdCl<2+>)' + '\t' + str(myGWB.results('concentration aqueous NdCl++', 'molal')[0]) + '\n')
        fobj_ResultFile.write(Testcase + '\t' + 'conc_solute(NdCl2<+>)' + '\t' + str(myGWB.results('concentration aqueous NdCl2+', 'molal')[0]) + '\n')
        fobj_ResultFile.write(Testcase + '\t' + 'conc_solute(Ca[Nd(OH)3]<2+>)' + '\t' + str(myGWB.results('concentration aqueous Ca[Nd(OH)3]++', 'molal')[0]) + '\n')
        fobj_ResultFile.write(Testcase + '\t' + 'conc_solute(Ca2[Nd(OH)4]<3+>)' + '\t' + str(myGWB.results('concentration aqueous Ca2[Nd(OH)4]+++', 'molal')[0]) + '\n')
        fobj_ResultFile.write(Testcase + '\t' + 'conc_solute(Ca3[Nd(OH)6]<3+>)' + '\t' + str(myGWB.results('concentration aqueous Ca3[Nd(OH)6]+++', 'molal')[0]) + '\n')
        fobj_ResultFile.close()

    concentrations for species whose name contains [ and ] are exported as -999999.0. I fail to locate my mistake.

    Best regards,

    Helge

     

     

    Helge

     

     

    0043.rea

    Nd.dat

    0043_mod.py

    0043_mod.out

  12. Hello everybody,

    I can't retrieve the molal H+ concentration. With

    #######

        species = myGWB.results("species")
        conc = myGWB.results("concentration aqueous", "molal")
        print "\nThere are" , len(species) , "aqueous species.\n"
        for i in range(len(species)):
            print "%-4s = %10.4g mol/kg" % (species, conc)
        print "concentration H+ = ", myGWB.results('concentration H+', 'molal')[0]

    #######

    I get

    Y:\Rechnungen\gwb>0001_test.py

    There are 9 aqueous species.

    H+   =  3.027e-07 mol/kg
    HSO4- =  3.231e-06 mol/kg
    K+   =     0.7233 mol/kg
    KMg(SO4)+ =  6.463e-05 mol/kg
    Mg(OH)+ =  3.447e-06 mol/kg
    Mg++ =      3.114 mol/kg
    Mg3(OH)4++ =  8.826e-15 mol/kg
    OH-  =  8.746e-08 mol/kg
    SO4-- =      3.475 mol/kg
    concentration H+ =  -3.47366172108e-10

    It seems that with myGWB.results('concentration H+', 'molal')[0] I retrieve something else (charge balance?) but not the H+ molality. Of course I could work around the problem and get the H+ molality from the aqueous species list,  but this wouldn't be elegant.

    Helge

     

     

  13. Hello everybody,

    I have a problem getting started with the GWB Python plugin. On running the example script I get:

    ###############################
    Y:\THEREDA\Arbeitsergebnisse\Testrechnungen\meinGWB>GWBplugin_Python_example2.py
    Starting program SpecE8
    Traceback (most recent call last):
      File "Y:\THEREDA\Arbeitsergebnisse\Testrechnungen\meinGWB\GWBplugin_Python_example2.py", line 20, in <module>
        -s \"c:/program files/gwb/gtdata/feoh.dat\""):
      File "Y:\THEREDA\Arbeitsergebnisse\Testrechnungen\meinGWB\GWBplugin.py", line 11, in initialize
        return cdll.gwbplugin.c_initialize(byref(self.plugin), c_char_p(app_name), c_char_p(file_name), c_char_p(cmds))
      File "C:\Python27-x64\lib\ctypes\__init__.py", line 436, in __getattr__
        dll = self._dlltype(name)
      File "C:\Python27-x64\lib\ctypes\__init__.py", line 366, in __init__
        self._handle = _dlopen(self._name, mode)
    WindowsError: [Error 126] Das angegebene Modul wurde nicht gefunden
    ###############################

    I get the same result with Python 3.7.x and also when calling module react (in a different script). To me it appears that GWB is having trouble with my Python installation. The requested file C:\Python27-x64\lib\ctypes\__init__.py exists. I use GWB 12 Professional.

    Thanks for help.

    Helge

     

     

×
×
  • Create New...