loloyohe Posted January 10, 2020 Share Posted January 10, 2020 I have two Tcl scripts designed to heat up samples in the first script, and save this to output. I then have a second script that reads in this output from script1 and then mixes and reacts the samples in the second loop. In the first script, the output writes nicely to a file (see output "Output_SW_HOT.txt"). In the second script, any output from the reaction (obtained via the "report" function) only will write to the console and refuses to write to the output. Any other text, including rewriting the input to the outfile is okay. It is just when I am trying to obtain the values with report that it will not write these values to output. I am (1) confused as to why this does this, and (2) even more confused as to why I don't have a problem with this in the first script. I am using GWB v. 10 React console to run the scripts. Here is the first script for heating the samples: #React script, saved Mon Dec 18 2019 by DDS script script start data = "500nocSS.dat" verify #Set up the input and output set in_id [open "SO4_SW_Spreadsheet.txt" r] set out_id [open "Output_SW_HOT.txt" w] fconfigure $out_id -encoding unicode set in_id [open "SO4_SW_Spreadsheet.txt" r] fconfigure $in_id -encoding unicode gets $in_id headers puts $out_id "Temperature\tpH\tH2O\tNa+\tCl-\tSO4--\tH2(aq)\tMg++\tFe++\tCa++" #Loop through remaining lines gets $in_id aline while {$aline != ""} { set i 0 balance on Cl- report set_digits 4 foreach a [lrange $aline 1 end] { incr i 1 if {[lindex $headers $i] == "pH"} { pH = $a } elseif {[lindex $headers $i] == "H2O"} { H2O = $a [lindex $headers $i] kg } else { $a = [lindex $headers $i] mmol/kg } } temperature initial = 25 C, final = 250 C go puts $out_id \ "[report Temperature]\t[report pH]\t[report soln_mass]\t[report concentration Na+]\t[report concentration Cl-]\t[report concentration SO4--]\t[report concentration H2(aq)]\t[report concentration Mg++]\t[report concentration Fe++]\t[report concentration Ca++]" gets $in_id aline } script script start close $in_id close $out_id Here is the second script for mixing the samples: #Set up the input and output set in_id2 [open "Output_SW_HOT.txt" r] set out_id2 [open "Output_HF_SW_MIX.txt" w] fconfigure $out_id2 -encoding unicode set in_id2 [open "Output_SW_HOT.txt" r] fconfigure $in_id2 -encoding unicode gets $in_id2 headers puts $out_id2 "$headers\tTemperature\tpH\tH2O\tNa+\tCl-\tSO4--\tH2(aq)\tMg++\tFe++\tCa++" #Loop through remaining lines gets $in_id2 aline while {$aline != ""} { set i 0 balance on Cl- report set_digits 4 foreach a [lrange $aline 1 end] { incr i 1 if {[lindex $headers $i] == "pH"} { pH = $a } elseif {[lindex $headers $i] == "H2O"} { H2O = $a [lindex $headers $i] kg } else { $a = [lindex $headers $i] mol/kg } } go pickup reactants = fluid temperature initial = 400 C, reactants = 250 C H2O = 2 free kg Na+ = 550 mmol/kg Cl- = 550 mmol/kg balance on Cl- Fe++ = 16.56 mmol/kg pH = 5 swap H2S(aq) for SO4-- H2S(aq) = 19.77 mmol/kg swap H2(aq) for O2(aq) H2(aq) = 19.1 mmol/kg Ca++ = 40 mmol/kg Mg++ = 1e-10 mmol/kg go foreach a [lrange $aline 0 end] { puts -nonewline $out_id2 "$a\t" } puts $out_id2 \ "[report Temperature]\t[report pH]\t[report soln_mass]\t[report concentration Na+]\t[report concentration Cl-]\t[report concentration SO4--]\t[report concentration H2(aq)]\t[report concentration Mg++]\t[report concentration Fe++]\t[report concentration Ca++]" reset reactants gets $in_id2 aline } #Clean up. script script start close $in_id2 close $out_id2 Thank you for your help and insight. Output_SW_HOT.txt Output_HF_SW_MIX.txt SO4_SW_Spreadsheet.txt 500nocSS.dat Quote Link to comment Share on other sites More sharing options...
Jia Wang Posted January 17, 2020 Share Posted January 17, 2020 Hello, It seems like the issue arises from within the second script when the reset command is executed. When the reset command is not executed from within a .rea file, it will turn scripting off. When the pickup reactant command is used, the program implicitly runs the reset command. As a result, none of your simulation output are written to your output file. You can try adding the ‘script start’ command after the “pickup reactants = fluid” line and “reset reactants” line to start scripting again. We’ll evaluate changes to this behavior for future releases. Hope this helps, Best regards, Jia Wang Quote Link to comment Share on other sites More sharing options...
loloyohe Posted January 21, 2020 Author Share Posted January 21, 2020 Thank you, Jia. This worked great. Looking forward to moving forward. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.