Jump to content
Geochemist's Workbench Support Forum
Lauren

Script file for rate law

Recommended Posts

Hi! I am very new to GWB, so forgive me if any of this seems rather simplistic.

 

I created a rate law script to try to fix a problem where certain parts of a chemical reaction are going to zero within a few years of a ten-year simulation, causing GWB to crash.

 

Reaction:

Methane(aq) + 8*Fe(OH)3 + 15*H+ -> 8*Fe++ +HCO3- + 21*H2O

 

To fix this, I think I want to set the rate equal to zero every time certain elements in a node dip below a threshold value, but running the simulation with my current script gives the following error message "Could not evaluate rate law script at line 2". I'm guessing I have not set up the indexing of my nodes or time step correctly, but am unsure how to proceed.

 

 

Here is the code as it stands now:

 

i = 1

begin_loop1: If (molality(Methane(aq)(i)) < 1e-20 or mass(Fe(OH)3(i)) < 100)

rate = 0;

return rate;

i = i+1

end_loop1

else

cat = 1.0

i = 1

begin_loop: If i > ncatal THEN GOTO end_loop

cat = cat* acatal(i)^pcatal(i)

i = i+1

GOTO begin_loop

end_loop: rate = Wmass*cat*rate_con*(1.0 - QoverK)

RETURN rate

 

 

I would appreciate any advice on how to adapt my script so that I am correctly indexing nodes at each time step.

 

Thanks!

 

Lauren

Share this post


Link to post
Share on other sites

Hi Lauren,

 

Can you please post the entire X1t input file so that I'm better able to take a look?

 

Thanks,

 

Brian Farrell

Aqueous Solutions LLC

Share this post


Link to post
Share on other sites

Here is my .x2t script. I was using the built in rate law before, and the only change now is substituting in a script for rate law. I cannot attach the document for some reason, but here is what I am using:

 

 

If (molality("Methane(aq)") < 1e-20 or mass("Fe(OH)3") < 100) THEN rate = 0 ELSE 40

RETURN rate

40: cat = 1.0

i = 1

begin_loop: If i > ncatal THEN GOTO end_loop

cat = cat* acatal(i)^pcatal(i)

i = i+1

GOTO begin_loop

end_loop: rate = Wmass*cat*rate_con*(1.0 - QoverK)

RETURN rate

 

 

 

 

 

 

At this point, I am not getting an error message, but the program is not running at all.

Thanks so much!

 

Lauren

methane react test-midscale.x2t

Share this post


Link to post
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...