Jump to content
Geochemist's Workbench Support Forum

explicit access to 'time' in custom script


Dino

Recommended Posts

I am trying to dissolve two phases in water.  In one I use a first order dissolution rate law.  For the other, I want to use a rate law that is independent of the solution concentrations and depends only on the time since the start of dissolution process, e.g. something like diffusion with a square root of time dependence.  I have not found a way of accessing the 'time' parameter that is used outside of the script environment.  For example, I'd like to use something like '...t = time...rate = rate_con*t^0.5...'  All attempts to date have failed and a search of the users group failed to turn up anything definitive.  I am using GWB standard.

Thanks for your help,

Denis

Link to comment
Share on other sites

Hi Dino,

The GWB by default uses a built-in rate law in the form of surface area* rate_constant * (1-Q/K). It sounds like for your purpose, you would need to prescribe a customized rate law, where the rate is dependent on the time since the simulation began. If the rate law you are trying to prescribe is relatively simple, you might want to consider setting the rate law directly as a set of character strings. To do so, go to your kinetic mineral in the Reactant pane, select the 'equation' option for the rate law from the dropdown menu. You can find a list of parameters used by the GWB in Table 5.1 and the syntax for writing the equation in section 5 Custom Rate Laws in the GWB Rxn Modeling User Guide. Note that the parameter for time is "Time" and the default unit is in seconds. 

If your custom rate law is more complex, you might want to use a rate law script written in the BASIC language. For more information, please refer to section 5.2 Rate law scripts in the Reaction Modeling Guide. 

If you would like to troubleshoot further, please attach your input file, thermo dataset, and/or the rate law script so someone can take a closer look.

Hope this helps,
Jia Wang

 

Link to comment
Share on other sites

Jia,

Thanks for the clues.  I'll try again.  I believe I've tried "t", "time", and "Time," but i'll try again.  I've included print statements like "Print  "Step 1", Time" and such.  Every time the parameter Time is shown as 0.  As I say, I'll try again.

Denis

Link to comment
Share on other sites

Hmmm.  I've still got something wrong.  I get a report of the time, but it does not vary.  Eventually something becomes unstable and the calculated rate goes from a large positive number to an equally large, but negative number.  This probably something quite simple, but I'm stumped.  I've attached the .bas file.  What i'm trying to do is to react a glass that normally contains Li and Na.  I've changed the composition of the glass so that it has no alkali and another 'glass' that is just the alkali.  The glass without alkali behaves correctly, but the one without alkali does not.  If i change the alkali glass to a simple reactant and allow x nmol to react over the time period, I get the results I expect.  It is only when i try to use the rate law for the alkali that i get in trouble.  If you need the complete data set let me know.

WAK IX.bas

Link to comment
Share on other sites

Hi Dino,

Thank you for the basic script file. It is difficult to say why you're encountering the stability issue without your input file and your thermo dataset.

I can see that your basic script includes the variable X2 but it is not defined in the script and it's not GWB parameter, so by default, it is evaluated as a 0 value. In this case, your X1 variable is just equal to your time. You can add Time to the list of variables you are printing out and check to see if it is the same as X1. To check whether or not time was changing throughout the simulation to calculate your rate, I used your rate law script for a simulation of a simple kinetic dissolution of quartz (Ch26_quartz.rea), an example file that came with the GWB installation in the GBRM subfolder, where GWB is installed. When I added the Time parameter to the variables for printing out, I saw that it was varying throughout the simulation. If you would like someone to look further into the stability issue, please attach your input file and your thermo dataset. And also, what release version of the software are you using? 

Best regards,
Jia Wang

Link to comment
Share on other sites

Hi Denis,

I took a quick look at your scripts and noticed that you have set a really large rate constant for the mineral WAK (alk). As a result of your rate law, the high dissolution rate is extremely high at the start of your simulation. The program cannot converge because of that really high dissolution rate. To see this, you can do a "go initial" (Run --> Go initial) run on your WAK IX.2.rea file and navigate to plot the dissolution rate to plot on the y-axis. The dissolution rate for WAK Glass (alk) is ~69,000 mmol/kg/s. Considering that you only have 10 mmol of glass in your simulation, the glass dissolved almost instantaneously. I would suggest simplifying your model setup to use an equilibrium approach if your glass is dissolving that fast. 

Best regards,
Jia Wang

Link to comment
Share on other sites

Thanks, Jia.  I am sorry for bothering you.  I appears to be a bonehead mistake on my part...after you called it out.  I went back a looked at my Excel graph and...I had not coverted from 'mol' to 'mmol'.  Again sorry to have bothered you ...and wasted a bunch of my own time chasing something that I should have checked at the start.

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