Jump to content
Geochemist's Workbench Support Forum

WeiX

Members
  • Posts

    7
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

WeiX's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. 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?
  2. 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
  3. 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
  4. The output file works now. For the non-integer increment, I did not succeed with expr command. It just could not recognize it somehow. But I change the unit of reacted calcite to mg. Then change the increment to 500. 500 mg is 0.5 g anyway. Problem solved anyway. Thanks a lot, Jia!
  5. Hi Jia, This very helpful. I successfully reported results in the command panel. The final results of each run is what we need for now. I added one more variable (changing calcite to react) in the script and I have two more questions regarding the updated script (noted below). Question 1: How do I react non-integral amount of calcite? I tried to put expr{$j+0.5} directly in the react command but it would not work. I also tried to set a new variable input_cal as $j+0.5 and put $input_cal in React, did not work. eval Calcite= $input_cal did not work either with React. The only way works with increasing calcite amount is to put $j directly after React. Question 2: In the txt result report file, It only listed the result from the last run. I tried a few different foreach commands but they did not work. How do I put the result line by line in the txt file? # React script, batch run example data = "C:\Program Files\Gwb\Gtdata\thermo.tdat" verify temperature = 25 C H2O = .005 kg Na+ = 1000 mg/l Ca++ = 20 mg/l Cl- = 500 mg/l SO4-- = 2000 mg/l swap CO2(aq) for HCO3- SiO2(aq) = 1e-7 mg/l Al+++ = 1e-7 mg/l script start clear all # vary CO2(aq) input for {set i 0} {$i<4} {incr i 1} { set input_CO2 [expr {1.2/3*$i+0.005}] eval {"CO2(aq)=" $input_CO2 mol/kg} fix activity of CO2(aq) # vary calcite input for {set j 0} {$j<4} {incr j 1} { # Question 1 react minerals non-integer amount react $j g Calcite react 80 g of Quartz react 10 g of Kaolinite react 2.5 g of Albite balance on H+ go report set_digits 4 report set_units ? set go_final_pH [eval report pH] set go_final_Ca [eval report concentration aqueous Ca++] # report in command puts "CO2(aq) = $input_CO2 mol/kg" puts "calcite = $j g" puts "pH = $go_final_pH" puts "Ca++ = $go_final_Ca mol/kg" # Question 2 report in txt set out_id [open "Batch_output.txt" w] fconfigure $out_id -encoding unicode puts $out_id "CO2(aq)(mol/kg)\tCalcite(g)\tpH\tCa++" foreach a [lrange $out_id 0 end] { puts -nonewline $out_id "$input_CO2\t" puts -nonewline $out_id "$j\t" puts -nonewline $out_id "$go_final_pH\t" puts $out_id "$go_final_Ca" } } } close $out_id Thanks, Wei
  6. Thanks. The Notepad was exactly what I was asking. I tried to add a few loops to change the CO2(aq) input. It seems it did run for 11 iterations in the Result panel (with 11 successful reaction paths and 116 steps in each path. However, when I click the view results, it only gave me the most recent reaction path results. How do I report result after each iteration? Currently, I don't even know if the CO2(aq) is changing in each iteration... the result panel only shows the general status of each iteration. For example, if I want to report pH at step #0 of each CO2(aq) input, my script is below. But it won't report what I want, I only see the normal result txt file with the CO2(aq)=1.2 mol/kg iteration. # React script, batch run example data = "C:\Program Files\Gwb\Gtdata\thermo.tdat" verify temperature = 25 C H2O = .005 kg Na+ = 1000 mg/l Ca++ = 20 mg/l Cl- = 500 mg/l SO4-- = 2000 mg/l swap CO2(aq) for HCO3- SiO2(aq) = 1e-7 mg/l Al+++ = 1e-7 mg/l script start for {set i 0} {$i<11} {incr i 1} { eval {"CO2(aq)=" [expr {1.2/10*$i}] mol/kg} balance on H+ react 80 g of Quartz react 10 g of Kaolinite react 2.5 g of Albite react 5 g of Calcite fix activity of CO2(aq) go puts "The control script $i iteration" report pH 0 }
  7. Hi, I am doing a reaction path modeling in React. React 5 minerals with a ground water and see the equilibrium status with different fixed CO2(aq) concentrations. I am trying to change the CO2(aq) input from 0 to 1.2 mol/kg (and other parameters in the future). I did this manually for 10 input concentrations and realized it's labor-intensive. The results we want are the Step #0 and the last Step. I have to open the txt result file and manually find these two steps. I learnt that I can write script in GWB command window to add in some loops to run and report in batches. I got stuck in the first step. In the command window of React, it would not allow me to type and edit script once I hit "enter". Is there a different window or a command I need to put in to write React script without running each line? Like a Python shell window? Thanks. (I may have other questions regarding the script in the future and I will put in here in the same topic)
×
×
  • Create New...