Jump to content
Geochemist's Workbench Support Forum

cannot retrieve concentration if species with squared brackets in their name


Helge

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

Link to comment
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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...