Jump to content
Geochemist's Workbench Support Forum

multiple analysis in specE8


Azra

Recommended Posts

Hello,

 

I want to use the script file for multiple analyses calculations (in reference manul p.269) to calculate saturation indices for some minerals that i am interested in, but i'd like to use the thermo.com.v8.r6+.dat database file. Could some one tell me how to tell the code to use thermo.com.v8.r6+.dat database instead of the default thermo.dat ? Thanks,

 

Azra

Link to comment
Share on other sites

Hello,

 

I want to use the script file for multiple analyses calculations (in reference manul p.269) to calculate saturation indices for some minerals that i am interested in, but i'd like to use the thermo.com.v8.r6+.dat database file. Could some one tell me how to tell the code to use thermo.com.v8.r6+.dat database instead of the default thermo.dat ? Thanks,

 

Azra

 

Hi Azra:

 

The Appendix on Control Scripts (right before the Multiple Analyses Appendix) gives an example of this. You can do this using the data command. The formal syntax (top of p. 263) is:

 

data {"C:\\Program Files\\Gwb\\Gtdata\\thermo.com.v8.r6+.dat"}

 

In the script given on p. 269, I'd place this right after the "reset; balance... " command, as follows:

 

script start

# Set up the input and output.
set in_id [open "scatter_data_aqqa_example2_wP3212.txt" r]
set out_id [open "Output.txt" w]
fconfigure $out_id -encoding unicode


# First line contains column headers; check for Unicode.
gets $in_id headers
if {![string is ascii $headers]} {
close $in_id
set in_id [open "scatter_data_aqqa_example2_wP3212.txt" r]
fconfigure $in_id -encoding unicode
gets $in_id headers
}
puts $out_id "$headers"


# Loop through remaining lines.
gets $in_id aline
report set_digits 4
while {$aline != ""} {
set i 0
reset; balance on SO4--
data {"C:\\Program Files\\Gwb\\Gtdata\\thermo.com.v8.r6+.dat"}

# Set basis constraints from input data.
foreach a [lrange $aline 1 end] {
	incr i 1
	if {[lindex $headers $i] == "pH"} {
		pH = $a
	} else {
		$a = [lindex $headers $i] mg/kg
	}
}


# Run SpecE8 calculation and write data + results.
go
foreach a [lrange $aline 0 end] {
	puts -nonewline $out_id "$a\t"
}
if {[report success]} {
	puts $out_id \
		"[report fugacity CO2(g)]\t[report SI Calcite]"
} else {
	puts $out_id "Did not converge"
}

puts $out_id \r	

# Next line of input.
gets $in_id aline
}


# Clean up.
close $out_id
close $in_id

quit

 

I had some trouble implementing the script using the exact syntax shown in the user's guide - GWB was unable to find the thermo data file in the place I'd specified. I'm not sure if that's a Windows Vista issue, differences in Tcl versions, or simply my lack of familiarity with Tcl. If you run into the same, the following worked for me:

 

  • place the extended thermo database in the same directory as your script
  • use the following syntax: data "thermo.com.v8.r6+.dat"

 

Please let me know if that addresses the issue.

 

Regards,

 

Tom

Link to comment
Share on other sites

Hi Tom,

You were rigth i needed to place the the script in the same directory as the input file. However the code will keep runnning and never quits. I tried to place the command in various places but wasn't able to solve the problem.

 

script start

# Set up the input and output.

set in_id [open "SI Calculations Shallow Wells_thermov8.txt" r]

set out_id [open "SI Calculations Shallow Wells Output-thermov8.txt" w]

fconfigure $out_id -encoding unicode

 

 

# First line contains column headers; check for Unicode.

gets $in_id headers

if {![string is ascii $headers]} {

close $in_id

set in_id [open "SI Calculations Shallow Wells-thermov8.txt" r]

fconfigure $in_id -encoding unicode

gets $in_id headers

}

puts $out_id "$headers\tSiderite SI\tCalcite SI\tGibbsite SI\tJarosite-K SI\tJarosite-Na SI\tAlunite SI\tFe(OH)3(ppd) SI\tCarnotite SI"

 

# Loop through remaining lines.

gets $in_id aline

report set_digits 4

while {$aline != ""} {

set i 0

reset; balance on Cl-

data "thermo.com.v8.r6+.dat"

 

 

# Set basis constraints from input data.

foreach a [lrange $aline 1 end] {

incr i 1

if {[lindex $headers $i] == "pH"} {

pH = $a

} else {

$a = [lindex $headers $i] mg/kg

}

}

 

# Run SpecE8 calculation and write data + results.

data "thermo.com.v8.r6+.dat"

go

foreach a [lrange $aline 0 end] {

puts -nonewline $out_id "$a\t"

}

if {[report success]} {

puts $out_id \

"[report SI Siderite]\t[report SI Calcite]\t[report SI Gibbsite]\t[report SI Jarosite-K]\t[report SI Jarosite-Na]\t[report SI Alunite]\t[report SI Fe(OH)3(ppd)]\t[report SI Carnotite]"

} else {

puts $out_id "Did not converge"

}

 

# Next line of input.

gets $in_id aline

}

 

# Clean up.

close $out_id

close $in_id

quit

 

Hi Azra:

 

The Appendix on Control Scripts (right before the Multiple Analyses Appendix) gives an example of this. You can do this using the data command. The formal syntax (top of p. 263) is:

 

data {"C:\\Program Files\\Gwb\\Gtdata\\thermo.com.v8.r6+.dat"}

 

In the script given on p. 269, I'd place this right after the "reset; balance... " command, as follows:

 

script start

# Set up the input and output.
set in_id [open "scatter_data_aqqa_example2_wP3212.txt" r]
set out_id [open "Output.txt" w]
fconfigure $out_id -encoding unicode


# First line contains column headers; check for Unicode.
gets $in_id headers
if {![string is ascii $headers]} {
close $in_id
set in_id [open "scatter_data_aqqa_example2_wP3212.txt" r]
fconfigure $in_id -encoding unicode
gets $in_id headers
}
puts $out_id "$headers"


# Loop through remaining lines.
gets $in_id aline
report set_digits 4
while {$aline != ""} {
set i 0
reset; balance on SO4--
data {"C:\\Program Files\\Gwb\\Gtdata\\thermo.com.v8.r6+.dat"}

# Set basis constraints from input data.
foreach a [lrange $aline 1 end] {
	incr i 1
	if {[lindex $headers $i] == "pH"} {
		pH = $a
	} else {
		$a = [lindex $headers $i] mg/kg
	}
}


# Run SpecE8 calculation and write data + results.
go
foreach a [lrange $aline 0 end] {
	puts -nonewline $out_id "$a\t"
}
if {[report success]} {
	puts $out_id \
		"[report fugacity CO2(g)]\t[report SI Calcite]"
} else {
	puts $out_id "Did not converge"
}

puts $out_id \r	

# Next line of input.
gets $in_id aline
}


# Clean up.
close $out_id
close $in_id

quit

 

I had some trouble implementing the script using the exact syntax shown in the user's guide - GWB was unable to find the thermo data file in the place I'd specified. I'm not sure if that's a Windows Vista issue, differences in Tcl versions, or simply my lack of familiarity with Tcl. If you run into the same, the following worked for me:

 

  • place the extended thermo database in the same directory as your script
  • use the following syntax: data "thermo.com.v8.r6+.dat"

 

Please let me know if that addresses the issue.

 

Regards,

 

Tom

SI_Calculations_Shallow_Wells_thermov8.txt

Link to comment
Share on other sites

Hi Azra:

 

I can spot a couple of problems with your script:

 

Hi Tom,

You were rigth i needed to place the the script in the same directory as the input file. However the code will keep runnning and never quits. I tried to place the command in various places but wasn't able to solve the problem.

 

script start

# Set up the input and output.

set in_id [open "SI Calculations Shallow Wells_thermov8.txt" r]

set out_id [open "SI Calculations Shallow Wells Output-thermov8.txt" w]

fconfigure $out_id -encoding unicode

 

 

# First line contains column headers; check for Unicode.

gets $in_id headers

if {![string is ascii $headers]} {

close $in_id

set in_id [open "SI Calculations Shallow Wells-thermov8.txt" r]

fconfigure $in_id -encoding unicode

gets $in_id headers

}

 

In your second set in_id statement, the file name is slightly different (has a hyphen, not an underscore) from the initial set in_id statement.

 

puts $out_id "$headers\tSiderite SI\tCalcite SI\tGibbsite SI\tJarosite-K SI\tJarosite-Na SI\tAlunite SI\tFe(OH)3(ppd) SI\tCarnotite SI"

 

# Loop through remaining lines.

gets $in_id aline

report set_digits 4

while {$aline != ""} {

set i 0

reset; balance on Cl-

data "thermo.com.v8.r6+.dat"

 

 

# Set basis constraints from input data.

foreach a [lrange $aline 1 end] {

incr i 1

if {[lindex $headers $i] == "pH"} {

pH = $a

} else {

$a = [lindex $headers $i] mg/kg

}

}

 

# Run SpecE8 calculation and write data + results.

data "thermo.com.v8.r6+.dat"

go

foreach a [lrange $aline 0 end] {

puts -nonewline $out_id "$a\t"

}

if {[report success]} {

puts $out_id \

"[report SI Siderite]\t[report SI Calcite]\t[report SI Gibbsite]\t[report SI Jarosite-K]\t[report SI Jarosite-Na]\t[report SI Alunite]\t[report SI Fe(OH)3(ppd)]\t[report SI Carnotite]" } else {

puts $out_id "Did not converge"

}

 

# Next line of input.

gets $in_id aline

}

 

# Clean up.

close $out_id

close $in_id

quit

 

You've added a second output statement to your script. Is this what you intended?

 

Let me know if that cleans things up.

 

Regards,

 

Tom

Link to comment
Share on other sites

  • 5 months later...

Hi there,

 

I had success with the following script. Obviously, you will need to modify outputs relevant to your run, but I had the same problem originally and the loop at the end of script seemed to fix it and give each output a unique name.

 

Hope it helps a little.

 

________________________________________________________________________________

____________________________________

 

script start

 

# Set up the input and output.

set in_id [open "Input v1S.txt" r]

set out_id [open "Output v1S.txt" w]

fconfigure $out_id -encoding unicode

 

# First line contains column headers; check for Unicode.

gets $in_id headers

if {![string is ascii $headers]} {

close $in_id

set in_id [open "Input v1D.txt" r]

fconfigure $in_id -encoding unicode

gets $in_id headers

}

puts $out_id "$headers\tIS\tTDS\tH+\tSO4--\tNa+\tCa++\tCl-\tMg++\tK+\tHCO3-\tCO3--\tCaCO3\tFe++\tFe+++\tHgCl3-\tHgCl2\tHgCl+\tHg2++\tHg++\tQuicksilver SI\tHematite SI\tGoethite SI\tGypsum SI\tCalcite SI"

 

add HCO3-

add O2(aq)

 

# Loop through remaining lines.

gets $in_id aline

report set_digits 4

set x 0

while {$aline != ""} {

set i 0

 

# Set basis constraints from input data.

# Define constraints for basis

swap CaCO3 for HCO3-

swap e- for O2(aq)

 

foreach a [lrange $aline 1 end] {

incr i 1

if {[lindex $headers $i] == "pH"} {

pH = $a

} elseif {[lindex $headers $i] == "Eh"} {

Eh = $a

} elseif {[lindex $headers $i] == "T"} {

T = $a

} elseif {[lindex $headers $i] == "Hg++"} {

$a = [lindex $headers $i] ug/l

} else {

$a = [lindex $headers $i] mg/l

}

}

 

 

# Run SpecE8 calculation and write data + results.

incr x 1

suffix _S_run$x

go

foreach a [lrange $aline 0 end] {

puts -nonewline $out_id "$a\t"

}

if {[report success]} {

puts $out_id \

"[report IS]\t[report TDS]\t[report activity H+]\t[report activity SO4--]\t[report activity Na+]\t[report activity Ca++]\t[report activity Cl-]\t[report activity Mg++]\t[report activity K+]\t[report activity HCO3-]\t[report activity CO3--]\t[report activity CaCO3]\t[report activity Fe++]\t[report activity Fe+++]\t[report activity HgCl3-]\t[report activity HgCl2]\t[report activity HgCl+]\t[report activity Hg2++]\t[report activity Hg++]\t[report SI Quicksilver]\t[report SI Hematite]\t[report SI Goethite]\t[report SI Gypsum]\t[report SI Calcite]"

} else {

puts $out_id "Did not converge"

}

 

# Next line of input.

gets $in_id aline

}

 

# Clean up.

close $out_id

close $in_id

 

print species=long

show printout

script end

Link to comment
Share on other sites

Hi there,

 

I had success with the following script. Obviously, you will need to modify outputs relevant to your run, but I had the same problem originally and the loop at the end of script seemed to fix it and give each output a unique name.

 

Hope it helps a little.

 

Thank you for the valuable contribution!

 

Regards,

 

Tom Meuzelaar

RockWare, Inc.

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