Jump to content
Geochemist's Workbench Support Forum

Setting the end step as the initial condition for another React run


WeiX

Recommended Posts

Hello,

I want to know if there is a command or anyway to set the end step status (including minerals present, pH, aqueous concentrations, etc...) of a React run as the initial condition for another React run with additional reactants. I could manually check the last step in txt file and put in those. But I want to know if there is any easier way so that I can do it in batch.

Thanks,

Wei

Link to comment
Share on other sites

Hello Wei,

The pickup command would allow you to use the composition at the end of a simulation and set it as a starting point for a new run. For more information and examples on using on the pickup command, please see sections 3.10 Picking up the results of a run and 4.8 Chaining together kinetic paths in the GWB Reaction Modeling User Guide. To view all specific options of implementing the pickup command, please see 6.64 pickup in the GWB Command Reference. 

Hope this helps,
Jia Wang

Link to comment
Share on other sites

Hello Jia,

Thanks for the advice. I tried pickup command. It works well with constant inputs. However, when I tried to change the initial reactants in a for loop in the script, a window would pop out saying no results were pick up. Can you help check it? I noted the problem below. 

# React script, batch run example
data = "C:\Program Files\Gwb\Gtdata\thermo.tdat" verify
clear all
temperature = 25 C
H2O   = .006 kg
Na+   = 1450 mg/l
Ca++  = 20.7 mg/l
Mg++  = 9.07 mg/l
K+    = 4.84 mg/l
Cl-   = 454 mg/l
SO4-- = 2120 mg/l
Br-   = 2.17 mg/l
HCO3- = 387 mg/l
SiO2(aq)     = 1e-7 mg/l
Al+++        = 1e-7 mg/l
Fe++         = 1e-7 mg/l

script start
set out_id [open "Pickup_output.txt" w]
fconfigure $out_id -encoding unicode
puts $out_id "CO2(aq)(mol/kg)\tCalcite(g)\tpH\tNa+(mol/kg)"

# Q: if I change the calcite to just React 1 g Calcite, this script run well and gives the results. But it would not work with for loop. 

for {set j_a 0} {$j_a<2} {incr j_a 1} {
React $j_a g Calcite

React 1 g Albite
React 1 g Anorthite
React 1 g Annite
React 1 g Phlogopite
React 1 g Ripidolit-14A
React 80 g of Quartz
React 10 g of Kaolinite
balance on H+
go

pickup 

swap CO2(aq) for HCO3-
for {set i 0} {$i<11} {incr i 1} {
set input_CO2 [expr {0.6/10*$i+0.005}]
eval {"CO2(aq)=" $input_CO2 mol/kg}
fix activity of CO2(aq)
balance on H+
go

report set_digits 4
report set_units ?
set go_final_pH [eval report pH]
set go_final_Na [eval report concentration aqueous Na+]

puts "CO2 = $input_CO2 mol/kg"
puts "calcite = $j_a g"
puts "pH = $go_final_pH"
puts "Ca++ = $go_final_Ca mol/kg"

foreach a [lrange $out_id 0 end] {
puts -nonewline $out_id "$input_CO2\t"
puts -nonewline $out_id "$j_a\t"
puts -nonewline $out_id "$go_final_pH\t"
puts $out_id "$go_final_Na"

}
}
}
close $out_id

Thanks,

Wei

Link to comment
Share on other sites

Hello Wei,

I think some variables in your script are not defined. When I tried to run your script directly, I received the error "go_final_Ca: no such variable". 

Perhaps there are different ways to do this but if you are trying to run your initial basis concentrations and react with different amounts of calcite, then I think you need to put the basis constraints inside your for loop as well. I made a simple example with just Na+ and Cl- and I had no issues with the pickup command within the for loop. The example below will set the basis with 1 kg of H2O, 1 mmol Na+, balance on Cl-, and then do the first run. The results are then picked up and some amount of of Na+ (0 to 9 mmol) are titrated into the picked up fluid at each iteration. I have the script print out the Na+ component concentration after the initial equilibration and after the titration to the Command pane. 

I also added the reset command at the end  so that the script starts as a clean slate after one iteration of the loop. For more information on reset, please refer to the GWB Command Reference.

data = "C:\Program Files\Gwb\Gtdata\thermo.tdat" verify
script start

for {set j_a 0} {$j_a<10} {incr j_a 1} {
	temperature = 25 C
	H2O   = 1 kg
	Na+   = 1 mmol
	balance on Cl-	
	go
	#prints the counter
	puts "j_a= $j_a mmol" 
	set before_pickup_Na [eval report concentration Na+ mmol]
	puts "Na+_before_pickup = $before_pickup_Na mmol" 
	pickup
	#react j_a mmol of Na with the fluid
	React $j_a mmol Na+  
	go
	set final_Na [eval report concentration Na+ mmol]
	#Na component composition after the first go run
	puts "Na+ final= $final_Na mmol \n" 
	#resets command to begin defining the system again with a clean slate
	reset 
	}

Hope this helps,
Jia

Link to comment
Share on other sites

Thanks, Jia. I will check this out. I have a question about the error window. Sometimes when the script is too long, the error window would be too long to fully show up on my computer screen. There is no minimize or maximize button on that error window, only close "x". I move the window around but it won't let me see the bottom part. I cannot copy and paste the error information to a text file either. Did you have this issue with the error window? 

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