Jump to content

two reacting minerals


Dino
 Share

Recommended Posts

I am trying to react two mineral with kinetic rate laws.  The dissolution rate of the first mineral (Min A) is used in the calculation of the rate in the second mineral.  I've tried several routes with scripts, but each attempt indicate I have an error in line 9 (script shown below and line in red).  The error is probably obvious, but....  I know the rate laws alone for Min A and Min B work under a separate scripts.   I can run both minerals together when I just use just the last two lines for MIn B. The REACTANTS in the React input file are both Min A and MIn B with the custom rate law for Min B pointing to the file containing the script below.  I've tried several versions of line 9 with no success (error = syntax).

etaa = 1
Ea = 44400
Ew = 67800
etab = 0.75
Eb = 49700
T1 = activity("H+")^(etaa)*exp(-Ea/(8.314*TK))
T2 = exp(-Ew/(8.314*TK))
T3 = (activity("OH-")^(etab))*exp(-Eb/(8.314*TK))
kinetic "Min A" rate law = "(surface*rate_con*(T1 + T2 + T3))*(1.000-QoverK)"
a = rate*23.089
kinetic "Min B"
rate = surface*rate_con*a*(Time)^(-0.79)
RETURN rate
 

Link to comment
Share on other sites

Hello Dino, 

I think the issue here is that the program is not recognizing the variable kinetic "Min A" rate law, you can just simply call it rate or use another variable name (e.g. MinA_rate). Then set that variable in the following line in place of rate. I am not really sure you need the line 'kinetic "Min B"'. 

Try replacing


kinetic "Min A" rate law = "(surface*rate_con*(T1 + T2 + T3))*(1.000-QoverK)"
a = rate*23.089

with... 

MinA_rate = (surface*rate_con*(T1 + T2 + T3))*(1.000-QoverK)
a = MinA_rate*23.089

If this doesn't help, please attach your input file and your rate law scripts so we can troubleshoot. 

Best regards,
Jia Wang

Link to comment
Share on other sites

Jia

Thanks for your response.  I believe the problem is that the REACTANTS input has two reactants Min A and Min B.  The script appears in the rate law input for Min B, but the first rate that I want to calculate is Min A because the input that I need to calculate the Min B rate is a constant (conversion to m/s) times the rate from Min A.  I was trying to avoid confusion by indicating that the rate I need is that of Min A.  Is there a way of determining this without invoking the Min A rate equation in the Min B script?  If I use your suggestion, does the rate calculated in 

MinA_rate = (surface*rate_con*(T1 + T2 + T3))*(1.000-QoverK)

that of MIn A (as I mean it to be) or is there confusion and that is why the context bombs?

Link to comment
Share on other sites

  • 2 weeks later...

Hello Denis,

React won’t recognize the rate of another mineral being called in the rate law script (i.e. trying to call kinetic “Min A” rate law” in the initial post). If your reaction rate law for mineral A is relatively simple, then you might be able to replicate it in the custom script for mineral B using constant values. However, variables such as “surface” and “rate_con” are always going to refer to the values set for the kinetic mineral that you are providing the rate law script for. So if this is a script for mineral B, then calling the variables “rate_con” and “surface” at any point in the script, would refer to the rate constant and surface area of mineral B. React cannot refer to the rate constant of another mineral in the rate law script but you might consider entering the numerical value of the rate constant for mineral A in your script directly. Another feature that might be useful here is helper functions. These functions allow you to call a property value for a specific species, minerals, or gas and use it in the custom rate law. For a list of complete helper functions, please see Table 5.3 in the Reaction Modeling User Guide. You might be particularly interested in using the mass() helper function to figure out the surface area of mineral A or using the function QoverK().

Hope this helps, 
Jia Wang
 

Link to comment
Share on other sites

Thanks, Jia.

your suggestions are very good.  I had thought of using one of the elements to calculate the input I need for Min B, but you have put it in a much better context.  This should be particularly useful since there are elements that are not common between the two minerals.  I’ll give it a try.

having you as a resource is invaluable.  Thanks again and I wish you and your family a very happy new year.

Denis

Link to comment
Share on other sites

Jia,

It looks like I should be able to use a controlling script to do what I want...correct?  If, as part of the controlling script, I read the dissolution rate for Min A at the current time step and use that to calculate a new rate constant for Min B, will that work?  I assume here that at each time step in REACT, both Min A and Min B are run and the existing "React_Output..." file is updated to the current time step...correct?  If so, can I interrogate that file and extract the last reported value for the dissolution rate and use it in the calculation of a new rate constant for Min B (it may be a time step off, but if the rates are changing slowly then the error should be small)?  From what I read in the manual on Tcl and controlling scripts I should be able to do this, but my working knowledge is, admittedly, limited.

Or, is there a way to print the needed data to a file at each time step and read that file?

Denis

Link to comment
Share on other sites

JIa,

I wrote wrote a post last week about using the 'remote' technique to solve the problem of accessing the rate constant from Min A in the Min B script.  However, it occurred to me that running two react simulations simultaneously might also be a possibility.  I installed Visual Studio and imported RC_example2.app and, after making the appropriate change to the RC_helper.h directory and pasting the script into the Visual edit screen, encountered no less than 450 errors when I tested jus the first line of the code!!  I would have thought that this would have been a more straight forward operation.  My colleague is going to try FORTRAN with with he has more experience.  What I was hoping to do is run the first REACT (script 1 in the example of Chapter 11.2) and before calling script 2, get the value of the rate from Min A, perform a simple calculation to get a value for the rate constant for script 2, then calling script 2.  Is this likely to work or is it doomed to failure?

Thanks for your help.

Denis

Link to comment
Share on other sites

Hello Denis,
 
The remote control feature is now a legacy feature that is replaced by the Plugin feature. If you would like to pursue this route, I would recommend using the Plugin feature instead of Remote Control.
 
On the other hand, if you or your colleague is planning to do a little programming, I think you might have better luck with what you're doing using a compiled rate law instead. The advantage to using this method is that you can call information from specific vectors that are available in the data structure stored in the program run that is not available in a normal rate law script or the equation option. If you would like to look further into this option, I would like to point you to section 5.3 Compiled Rate Laws in the GWB Reaction Modeling User Guide. The get_context.h and rate_param.h files referenced in this section are found in the src folder where your GWB software is installed.
 
I believe the kinetic rate for reactants that you're interested in is stored in a data structure call "reactant status" as the variable dndt. Just note that order of your reactant will matter in this case. For referencing a rate of an existing reactant, make sure the reactant's rate you're referencing is listed before the reactant you're calling it for.
 
Hope this helps,
Jia Wang
 
Link to comment
Share on other sites

  • 1 year later...

Hi Denis,

The GWB 2022 release includes a new "reaction_rate" Custom Rate Law "helper function" that should be of use to you. By using the helper function, the custom rate law for one mineral can reference the current reaction rate for another. For more information, please see Table 5.2 in the GWB Reaction Modeling Guide.

Regards,

Brian Farrell
Aqueous Solutions

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

×
×
  • Create New...