Jump to content
Geochemist's Workbench Support Forum

Modeling Cation Exchange


Recommended Posts

I thought I had posted this question yesterday, but it seems to be lost. Anyway, I have been trying to model cation exchange in X1t without having to build a dll library in C++. Instead, I was wondering if this could be done with a simple basic script. Again, I am following the approach of Park et al. (2009), and have added the "pseudo-minerals" Na2EX2 and CaEX2 to the thermo-tdat data base. I also wrote basic scripts (example for Na2EX2 rate law) to see if X1t will evaluate them. However, I can't seem to coax X1t to recognize the "pseudo-minerals". Do I absolutely need to instead write a C++ code and compile it as per Park et al (2009) to get this to work?

Na2EX2_Rate.bas.pdf Kinetic Ion Exchange.pdf Park et al._script.pdf

Link to comment
Share on other sites

Hello Karen,

I think you can use the basic script files but I am not sure why X1t is not able to recognize the pseudo-minerals without seeing your database. Perhaps the thermo dataset is not properly loaded? This paper was published before kinetic sorption was integrated into GWB and thus the use of the pseudo minerals for ion exchange surfaces. Starting with Release 9, the GWB has added capabilities to incorporate surface complexation and sorption as a kinetic reaction using the species available in the surface dataset loaded. You can load the ion exchange dataset by going to "File" --> Open --> Sorbing surfaces. Once loaded, you can go to the Reactants pane and add in Kinetic sorbed species. You can set the rate law using the basic file in the screenshot you provided. This way, there wouldn't be a need to add the pseudo minerals for the exchange surfaces. For more information on kinetic complexation and sorption, please see section 4.4 in the GWB Reaction Modeling User Guide. 

Best regards,
Jia Wang

 

Link to comment
Share on other sites

  • 2 weeks later...

Hi Jia,

I have made pseudo minerals before (e.g., "arsenogoethite" in a paper I published in GCA at the end of 2019), so I was perplexed by the modified thermo.tdat database not seeing it when I tried to run X1t. I like to work from scripts and less so from the GUI, but maybe I'll try this approach you outline above. I wasn't making a surface dataset, because I was following the approach of Park et al. (2009) to add the pseudo minerals Na2EX2 and CaEX2 directly to the thermo.tdat file. I need to be able to "turn on" the cation exchange reaction for only a portion of the flow path because it appears to only begin to become important after about 26 km of flow. This is also why I was following the script of Park et al. Eventually, when I have the model running and doing a good job of simulating the major ion chemistry along the flow path, my final addition to the model will be for simulating the fate and transport along the flow path of a set of trace elements. I have already built the FeOH_trace element.sdat surface database for that. I have done this (make SCM surface databases) before for arsenic species, tungsten, organic matter, and so forth. 

At the moment I am trying to compile C++ dll files, but haven't had any luck. I used to be able to do these things without any problem when I was just using a clunky old Dell PC clone. Something about using Parallels and compiling C++ codes is truly perplexing to me. I should be able to do this as all my other PC compatible software, including GWB, runs fine on my Mac using Parallels. If I can solve this issue, then I am hoping my question above will be answered once and for all. I had a similar issue when I was running microbial respiration for Fe(III) oxides with GWB. I could compile the C++ code on my Dell, but could never get it to work in my Mac using Parallels.

Thanks,

Karen

 

Link to comment
Share on other sites

  • 1 month later...

Dear Jia,

I haven't yet tried to use your suggestion because I am perplexed that when I try to run my script, X1t does not seem to recognize either of the pseudo minerals that Park et al. (2009) provide the recipe for adding to the thermo.tdat dataset. I have been able to get the compiling worked out by downloading the compiler for VS 2019. Also, when I try to run my script, the proper database is loaded "thermo_ionx.tdat", which is the thermo.tdat modified by inclusion of the pseudo minerals Na2EX2 and CaEX2 as per Park et al. 

If I open up the X1t module, and load thermo_ionx.tdat, and add Ca++ or Na+ to the basis, I can swap them for the pseudo minerals CaEX2 and Na2EX2, respectively. But when I try to run my script with kinetic Na2EX2 or CaEX2, I get an error that says "Could not identify reactant species Na2EX2" (see attached). I have attached another script I used in a previous paper where I made up a pseudo mineral that I called Arsenogoethite that runs fine. I am perplexed. I don't know why this is not reading Na2EX2 or CaEX2. Any suggestions would be greatly appreciated. 

Best wishes,

Karen

Error_X1t.jpg

Arsenogoethite.jpg

Link to comment
Share on other sites

Hi Karen,

It's really difficult to diagnose the issue without being able to test your input script and thermo dataset that you are using. I tried adding the two pseudo-minerals to thermo.tdat and tested it in a simple run in X1t and did not encounter the issue above.

Can you attach the input files and the thermo dataset so we can take a closer look? If the files are too large or you prefer to email them, please send it to us at support@gwb.com. Also, what release version of The GWB are you running on?

Best regards,
Jia

Link to comment
Share on other sites

Hello Karen,

Thank you for sending us the files. I think I have found the issue. The new minerals added have a type associated. The database format for adding the mineral type does not have a space between "type" and the equal sign. As a result, the program recognizes the mineral names as  "Na2EX2                   type = ion exchange"  and "CaEX2                   type = ion exchange". This leads to the error that you saw when running input script. I think deleting the space should solve this issue. If you want to see this more clearly, you can open up the dataset in TEdit and go to the mineral entry.

Also, I noticed that there are tabs instead of spaces used in the text file. It is not causing an issue in this case but in general, it will be better to use spaces instead of tabs to be consistent with the formatting. 

Hope this helps,
Jia 

Link to comment
Share on other sites

Hi Jia,

Wow. I would have never caught that extra space. I have made a number of databases in the past and never had an issue. I reckon I never added a space there before. I also eliminated the tabs and changed them all to spaces. I'll give the model a run and see what happens. I hope this works. Assuming it does, then the next step will be "tuning" the kinetic mineral rate constants to fit our data as best as possible. Thanks.

Karen

Link to comment
Share on other sites

  • 2 weeks later...

Hi again Jia,

I have another question, which may be very easy to answer. I have been running that script I sent you, and iterating to find mineral dissolution rates that best reproduce my major ion concentrations along the flow path I am studying. For some reason is I chose an "effective" rate constant for anorthite dissolution/precipitation that exceeds 2e-19 mol/cm3/s, the X1t just seems to stop or get hung up. I am attaching a screenshot of X1t where I have set the effective rate constant for anorthite at 2.5e-19 mol/cm3/s. The program will not go any further than this. If I use a larger effective rate constant it stops at an even lower Xi value. I am also attaching my script, again, but note I am still iterating and trying to come up with the best fits to me actual data.  Do you have any suggestions that I might try so that the X1t will complete the simulation with larger values of the effective rate constant for anorthite dissolution? For example, changing the tolerances of the numerical iterations....

Best wishes,

Karen

 

 

Example.jpg

Carrizo_Weathering_5.x1t

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...