Jump to content
Geochemist's Workbench Support Forum
Helge

cannot retrieve concentration if species with squared brackets in their name

Recommended Posts

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

Share this post


Link to post
Share on other sites

Hi Helge,

 

When species contain brackets in the name you will need to put quotes around the name. It is preferred to name species with parenthesis instead of brackets to avoid having to add these quotes. Both single and double quotes will work.

Since your string is already inside single quotes, adding double quotes around the name would be easiest:

myGWB.results('concentration aqueous "Ca3[Nd(OH)6]+++"', 'molal')

Hope this helps,

Dan

Share this post


Link to post
Share on other sites

Works perfectly, thank you very much 🙂

Helge

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×