Helge Posted April 24, 2019 Share Posted April 24, 2019 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 Quote Link to comment Share on other sites More sharing options...
dan saalfeld Posted April 24, 2019 Share Posted April 24, 2019 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 Quote Link to comment Share on other sites More sharing options...
Helge Posted April 25, 2019 Author Share Posted April 25, 2019 Works perfectly, thank you very much ? Helge Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.