IPhreeqcCOM Object

IPhreeqcCOM

Using the IPhreeqcCOM Object

The following example creates an IPhreeqcCOM object, loads the phreeqc.dat database and runs the ex1 example.

  JScript

var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
iphreeqc.LoadDatabase("phreeqc.dat");
iphreeqc.OutputFileOn = true;
if (iphreeqc.RunFile("ex1") == 0) {
    WScript.Echo("see " + iphreeqc.OutputFileName + ".");
}

  VBScript

Dim iphreeqc
Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
iphreeqc.LoadDatabase("phreeqc.dat")
iphreeqc.OutputFileOn = True
If (iphreeqc.RunFile("ex1") = 0) Then
    WScript.Echo("see " & iphreeqc.OutputFileName & ".")
End If

Remarks

Unlike the batch version of phreeqc, the output will be created in the file OutputFileName. If the OutputFileOn property were not set to True no output files would have been created.


AccumulateLine Method

Appends a line of text to the input buffer of the IPhreeqcCOM object.

expression.AccumulateLine( Line )

expression Required. An expression that returns an IPhreeqcCOM object.

Line Required String. The line of input to be added to the input buffer of the IPhreeqcCOM object.

Example

This example loads the phreeqc.dat database into the IPhreeqcCOM object. Next, Phreeqc input is accumulated and run by the IPhreeqcCOM object.

  JScript

var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
iphreeqc.LoadDatabase("phreeqc.dat");
iphreeqc.AccumulateLine("TITLE Example 2.--Temperature dependence of solubility");
iphreeqc.AccumulateLine("                  of gypsum and anhydrite");
iphreeqc.AccumulateLine("SOLUTION 1 Pure water");
iphreeqc.AccumulateLine("        pH      7.0");
iphreeqc.AccumulateLine("        temp    25.0");
iphreeqc.AccumulateLine("EQUILIBRIUM_PHASES 1");
iphreeqc.AccumulateLine("        Gypsum          0.0     1.0");
iphreeqc.AccumulateLine("        Anhydrite       0.0     1.0");
iphreeqc.AccumulateLine("REACTION_TEMPERATURE 1");
iphreeqc.AccumulateLine("        25.0 75.0 in 51 steps");
iphreeqc.AccumulateLine("SELECTED_OUTPUT");
iphreeqc.AccumulateLine("        -file   ex2.sel");
iphreeqc.AccumulateLine("        -temperature");
iphreeqc.AccumulateLine("        -si     anhydrite  gypsum");
iphreeqc.AccumulateLine("END");
iphreeqc.OutputFileOn = true;
if (iphreeqc.RunAccumulated() == 0) {
    WScript.Echo("see " + iphreeqc.OutputFileName + ".");
};

  VBScript

Dim iphreeqc
Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
iphreeqc.LoadDatabase("phreeqc.dat")
iphreeqc.AccumulateLine("TITLE Example 2.--Temperature dependence of solubility")
iphreeqc.AccumulateLine("                  of gypsum and anhydrite")
iphreeqc.AccumulateLine("SOLUTION 1 Pure water")
iphreeqc.AccumulateLine("        pH      7.0")
iphreeqc.AccumulateLine("        temp    25.0")
iphreeqc.AccumulateLine("EQUILIBRIUM_PHASES 1")
iphreeqc.AccumulateLine("        Gypsum          0.0     1.0")
iphreeqc.AccumulateLine("        Anhydrite       0.0     1.0")
iphreeqc.AccumulateLine("REACTION_TEMPERATURE 1")
iphreeqc.AccumulateLine("        25.0 75.0 in 51 steps")
iphreeqc.AccumulateLine("SELECTED_OUTPUT")
iphreeqc.AccumulateLine("        -file   ex2.sel")
iphreeqc.AccumulateLine("        -temperature")
iphreeqc.AccumulateLine("        -si     anhydrite  gypsum")
iphreeqc.AccumulateLine("END")
iphreeqc.OutputFileOn = True
If (iphreeqc.RunAccumulated() = 0) Then
    WScript.Echo("see " & iphreeqc.OutputFileName & ".")
End If


ClearAccumulatedLines Method

Clears the accumulated input buffer. The input buffer is accumulated from calls to the AccumulateLine method.

expression.ClearAccumulatedLines()

expression Required. An expression that returns an IPhreeqcCOM object.

Example

This example loads some keyword input, clears the input, and displays the results.

  JScript

var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
iphreeqc.AccumulateLine("SOLUTION 1");
iphreeqc.AccumulateLine("END");
WScript.Echo("The accumulated input is:\n" + iphreeqc.Lines);
iphreeqc.ClearAccumulatedLines();
WScript.Echo("The accumulated input now is:\n" + iphreeqc.Lines);

  VBScript

Dim iphreeqc
Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
iphreeqc.AccumulateLine("SOLUTION 1")
iphreeqc.AccumulateLine("END")
WScript.Echo("The accumulated input is:" & vbNewLine & iphreeqc.Lines)
iphreeqc.ClearAccumulatedLines()
WScript.Echo("The accumulated input is:" & vbNewLine & iphreeqc.Lines)


GetComponentList Method

Retrieves a list containing the current list of components.

expression.GetComponentList()

expression Required. An expression that returns an IPhreeqcCOM object.

Example

This example runs the ex2 input file and echos the list of components.

  JScript

var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
iphreeqc.LoadDatabase("phreeqc.dat");
iphreeqc.RunFile("ex2");
var str = "components:\n";
var comps = iphreeqc.GetComponentList().toArray();
for (var i in comps) {
    str += comps[i] + "\n";
}
WScript.Echo(str);

  VBScript

Dim iphreeqc, comp, comps, str
Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
iphreeqc.LoadDatabase("phreeqc.dat")
iphreeqc.RunFile("ex2")
str = "components:" & vbNewLine
comps = iphreeqc.GetComponentList()
For Each comp in comps
    str = str & comp & vbNewLine
Next
WScript.Echo(str)


GetDumpString Method

Retrieves the string buffer containing DUMP output.

expression.GetDumpString()

expression Required. An expression that returns an IPhreeqcCOM object.

Remarks

The GetDumpString method requires the DumpStringOn property be set to True before calling a Run method in order to return a dump string.

Example

This example equilibrates pure water with calcite and echos the dump string.

  JScript

var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
iphreeqc.LoadDatabase("phreeqc.dat");
iphreeqc.DumpStringOn = true;

var input = new String("");
input += "SOLUTION 1 Pure water     \n";
input += "EQUILIBRIUM_PHASES 1      \n";
input += "    Calcite 0 10          \n";
input += "SAVE solution 1           \n";
input += "SAVE equilibrium_phases 1 \n";
input += "DUMP                      \n";
input += "    -solution 1           \n";
input += "    -equilibrium_phases  1\n";

if (iphreeqc.RunString(input) != 0) {
    WScript.Echo(iphreeqc.GetErrorString());
}
var dump = iphreeqc.GetDumpString();
WScript.Echo(dump);

  VBScript

Dim iphreeqc, sInput, sDump

Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
iphreeqc.LoadDatabase("phreeqc.dat")
iphreeqc.DumpStringOn = True

sInput = ""
sInput = sInput & "SOLUTION 1 Pure water     " & vbNewLine
sInput = sInput & "EQUILIBRIUM_PHASES 1      " & vbNewLine
sInput = sInput & "    Calcite 0 10          " & vbNewLine
sInput = sInput & "SAVE solution 1           " & vbNewLine
sInput = sInput & "SAVE equilibrium_phases 1 " & vbNewLine
sInput = sInput & "DUMP                      " & vbNewLine
sInput = sInput & "    -solution 1           " & vbNewLine
sInput = sInput & "    -equilibrium_phases  1" & vbNewLine

If (iphreeqc.RunString(sInput) <> 0) Then
    WScript.Echo(iphreeqc.GetErrorString())
End If

sDump = "Dump:" & vbNewLine
sDump = sDump & iphreeqc.GetDumpString()
WScript.Echo(sDump)


GetErrorString Method

Returns a string containing any error messages that were generated during the last invocation of the following methods: AccumulateLine, GetSelectedOutputValue, LoadDatabase, LoadDatabaseString, RunAccumulated, RunFile, RunString.

expression.GetErrorString()

expression Required. An expression that returns an IPhreeqcCOM object.

Example

The example attempts to run the ex1 input file, fails, and displays the reason for failure (no database is loaded).

  JScript

try {
    var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
    iphreeqc.RunFile("ex1");
}
catch(e) {
    WScript.Echo(iphreeqc.GetErrorString());  // could also use e.message
}

  VBScript

Dim iphreeqc
On Error Resume Next
Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
If (iphreeqc.RunFile("ex1") <> 0) Then
    WScript.Echo(iphreeqc.GetErrorString())
End If


GetLogString Method

Retrieves the string buffer containing log output.

expression.GetLogString()

expression Required. An expression that returns an IPhreeqcCOM object.

Remarks

The GetLogString method requires the LogStringOn property be set to True before calling one of the Run methods.

Example

This example equilibrates pure water with calcite and displays the results.

  JScript

var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
iphreeqc.LoadDatabase("phreeqc.dat");
iphreeqc.LogStringOn = true;

var input = new String("");
input += "SOLUTION 1 Pure water     \n";
input += "EQUILIBRIUM_PHASES 1      \n";
input += "    Calcite 0 10          \n";
input += "KNOBS                     \n";
input += "    -logfile TRUE         \n";

if (iphreeqc.RunString(input) == 0) {
    WScript.Echo(iphreeqc.GetLogString());
}

  VBScript

Dim iphreeqc, sInput

Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
iphreeqc.LoadDatabase("phreeqc.dat")
iphreeqc.LogStringOn = True

sInput = ""
sInput = sInput & "SOLUTION 1 Pure water     " & vbNewLine
sInput = sInput & "EQUILIBRIUM_PHASES 1      " & vbNewLine
sInput = sInput & "    Calcite 0 10          " & vbNewLine
sInput = sInput & "KNOBS                     " & vbNewLine
sInput = sInput & "    -logfile TRUE         " & vbNewLine

If (iphreeqc.RunString(sInput) = 0) Then
    WScript.Echo(iphreeqc.GetLogString())
End If


GetNthSelectedOutputUserNumberList Method

Retrieves a list containing the current list of SELECTED_OUTPUT user numbers.

expression.GetNthSelectedOutputUserNumberList()

expression Required. An expression that returns an IPhreeqcCOM object.

Example

This example runs the multi_punch input file and echos the list of SELECTED_OUTPUT user numbers.

  JScript

var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
iphreeqc.LoadDatabase("phreeqc.dat");
iphreeqc.RunFile("multi_punch");
var str = "Defined selected-output numbers:\n";
var nums = iphreeqc.GetNthSelectedOutputUserNumberList().toArray();
for (var i in nums) {
    str += nums[i] + "\n";
}
WScript.Echo(str);

  VBScript

Dim iphreeqc, num, nums, str
Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
iphreeqc.LoadDatabase("phreeqc.dat")
iphreeqc.RunFile("multi_punch")
str = "Defined selected-output numbers:" & vbNewLine
nums = iphreeqc.GetNthSelectedOutputUserNumberList()
For Each num in nums
    str = str & num & vbNewLine
Next
WScript.Echo(str)


GetOutputString Method

Retrieves the string buffer containing phreeqc output.

expression.GetOutputString()

expression Required. An expression that returns an IPhreeqcCOM object.

Remarks

The GetOutputString method requires the OutputStringOn property be set to True before calling one of the Run methods.

Example

This example equilibrates pure water with calcite and displays the results.

  JScript

var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
iphreeqc.LoadDatabase("phreeqc.dat");
iphreeqc.OutputStringOn = true;

var input = new String("");
input += "SOLUTION 1 Pure water     \n";
input += "EQUILIBRIUM_PHASES 1      \n";
input += "    Calcite 0 10          \n";

if (iphreeqc.RunString(input) == 0) {
    WScript.Echo(iphreeqc.GetOutputString());
}

  VBScript

Dim iphreeqc, sInput

Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
iphreeqc.LoadDatabase("phreeqc.dat")
iphreeqc.OutputStringOn = True

sInput = ""
sInput = sInput & "SOLUTION 1 Pure water     " & vbNewLine
sInput = sInput & "EQUILIBRIUM_PHASES 1      " & vbNewLine
sInput = sInput & "    Calcite 0 10          " & vbNewLine

If (iphreeqc.RunString(sInput) = 0) Then
    WScript.Echo(iphreeqc.GetOutputString())
End If


GetSelectedOutputArray Method

Returns the contents of the selected output as an array of variants.

expression.GetSelectedOutputArray()

expression Required. An expression that returns an IPhreeqcCOM object.

Remarks

Accessing selected outputs having a user number other than 1 requires setting the CurrentSelectOutputUserNumber property appropriately.

Example

This example runs the ex2 input file and writes the selected-output array to stdout.

  JScript

var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
iphreeqc.LoadDatabase("phreeqc.dat");
iphreeqc.RunFile("ex2");

// Note: JScript doesn't support multi-dimensional arrays
var arr = iphreeqc.GetSelectedOutputArray().toArray();
var selout = "selected-output:\n";
for (var i = 0; i < iphreeqc.RowCount; ++i) {
    for (var j = 0; j < iphreeqc.ColumnCount; ++j) {
        selout += arr[i + j*iphreeqc.RowCount] + " ";
    }
    selout += "\n";
}
WScript.Echo(selout);

  VBScript

Dim iphreeqc, arr, selout, i, j
Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
iphreeqc.LoadDatabase("phreeqc.dat")
iphreeqc.RunFile("ex2")

arr = iphreeqc.GetSelectedOutputArray()
selout = "selected-output:" & vbNewLine
For i = LBound(arr, 1) To UBound(arr, 1)
    For j = LBound(arr, 2) To UBound(arr, 2)
        selout = selout & arr(i, j) & " "
    Next
    selout = selout & vbNewLine
Next
WScript.Echo(selout)


GetSelectedOutputString Method

Retrieves the string buffer containing selected-output.

expression.GetSelectedOutputString()

expression Required. An expression that returns an IPhreeqcCOM object.

Remarks

The GetSelectedOutputString method requires the SelectedOutputStringOn property be set to True before calling one of the Run methods.

Accessing selected outputs having a user number other than 1 requires setting the CurrentSelectOutputUserNumber property appropriately.

Example

This example runs the ex2 input file and displays the selected-output string.

  JScript

var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
iphreeqc.LoadDatabase("phreeqc.dat");
iphreeqc.SelectedOutputStringOn = true;
iphreeqc.RunFile("ex2");

if (iphreeqc.RunFile("ex2") == 0) {
    WScript.Echo(iphreeqc.GetSelectedOutputString());
}

  VBScript

Dim iphreeqc

Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
iphreeqc.LoadDatabase("phreeqc.dat")
iphreeqc.SelectedOutputStringOn = True

If (iphreeqc.RunFile("ex2") = 0) Then
    WScript.Echo(iphreeqc.GetSelectedOutputString())
End If


GetSelectedOutputValue Method

Returns the value associated with the specified row and column within SELECTED_OUTPUT and USER_PUNCH definitions. The first row (Row = 0) contains the heading for the given column.

expression.GetSelectedOutputValue( Row, Column )

expression Required. An expression that returns an IPhreeqcCOM object.

Row Required Long. Zero-based row index.

Column Required Long. Zero-based column index.

Remarks

The selected output may be retrieved after a successful call to any of the run methods: RunAccumulated, RunFile and RunString.

Accessing selected outputs having a user number other than 1 requires setting the CurrentSelectOutputUserNumber property appropriately.

The headings will contain a prefix and/or suffix in order to differentiate the columns. The following table shows the headings resulting from the given SELECTED_OUTPUT.

Input Headings
  SELECTED_OUTPUT
    -reset false
    -totals Ca Na

  Ca(mol/kgw)  Na(mol/kgw)

  SELECTED_OUTPUT
    -reset false
    -molalities Fe+2 Hfo_sOZn+

  m_Fe+2(mol/kgw)  m_Hfo_sOZn+(mol/kgw)

  SELECTED_OUTPUT
    -reset false
    -activities H+ Ca+2

  la_H+  la_Ca+2

  SELECTED_OUTPUT
    -reset false
    -equilibrium_phases Calcite Dolomite

  Calcite  d_Calcite  Dolomite  d_Dolomite

  SELECTED_OUTPUT
    -reset false
    -saturation_indices CO2(g) Siderite

  si_CO2(g)  si_Siderite

  SELECTED_OUTPUT
    -reset false
    -gases CO2(g) N2(g)

  pressure "total mol" volume g_CO2(g) g_N2(g)

  SELECTED_OUTPUT
    -reset false
    -kinetic_reactants CH2O Pyrite

  k_CH2O dk_CH2O k_Pyrite dk_Pyrite

  SELECTED_OUTPUT
    -reset false
    -solid_solutions CaSO4 SrSO4

  s_CaSO4 s_SrSO4

Example

This example runs the ex2 input file and echos the selected-output.

  JScript

var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
iphreeqc.LoadDatabase("phreeqc.dat");
iphreeqc.RunFile("ex2");

var selout = "selected-output:\n";
for (i = 0; i < iphreeqc.RowCount; ++i) {
    for (j = 0; j < iphreeqc.ColumnCount; ++j) {
        selout += iphreeqc.GetSelectedOutputValue(i, j) + " ";
    }
    selout += "\n"
}
WScript.Echo(selout);

  VBScript

Dim iphreeqc, i, j
Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
iphreeqc.LoadDatabase("phreeqc.dat")
iphreeqc.RunFile("ex2")

selout = "selected-output:" & vbNewLine
For i = 0 To iphreeqc.RowCount - 1
    For j = 0 To iphreeqc.ColumnCount - 1
        selout = selout & iphreeqc.GetSelectedOutputValue(i, j) & " "
    Next
    selout = selout & vbNewLine
Next
WScript.Echo(selout)


GetWarningString Method

Returns a string containing any warning messages that were generated during the last invocation of the following methods: LoadDatabase, LoadDatabaseString, RunAccumulated, RunFile, RunString.

expression.GetWarningString()

expression Required. An expression that returns an IPhreeqcCOM object.

Example

The example loads the phreeqc.dat database and attempts to use the DATABASE keyword to set the database to wateq4f.dat. A warning is displayed stating that the DATABASE keyword is ignored by IPhreeqcCOM.

  JScript

var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
iphreeqc.LoadDatabase("phreeqc.dat");
iphreeqc.AccumulateLine("DATABASE wateq4f.dat");
iphreeqc.AccumulateLine("SOLUTION 1");
iphreeqc.RunAccumulated();
if (iphreeqc.GetWarningString().length != 0) {
    WScript.Echo(iphreeqc.GetWarningString());
}

  VBScript

Dim iphreeqc
Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
iphreeqc.LoadDatabase("phreeqc.dat")
iphreeqc.AccumulateLine("DATABASE wateq4f.dat")
iphreeqc.AccumulateLine("SOLUTION 1")
iphreeqc.RunAccumulated()
If (Len(iphreeqc.GetWarningString()) <> 0) Then
    WScript.Echo(iphreeqc.GetWarningString())
End If


LoadDatabase Method

Loads a phreeqc database into the IPhreeqcCOM object. Returns the number of errors encountered while loading the database.

expression.LoadDatabase( FileName )

expression Required. An expression that returns an IPhreeqcCOM object.

FileName Required String. The file name of the phreeqc database to load.

Example

This example loads the phreeqc.dat database into the IPhreeqcCOM object.

  JScript

var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
if (iphreeqc.LoadDatabase("phreeqc.dat") == 0) {
    WScript.Echo("database ok");
} else {
    WScript.Echo("database contains errors");
}

  VBScript

Dim iphreeqc
Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
If (iphreeqc.LoadDatabase("phreeqc.dat") = 0) Then
    WScript.Echo("database ok")
Else
    WScript.Echo("database contains errors")
End If


LoadDatabaseString Method

Loads a phreeqc database into the IPhreeqcCOM object. Returns the number of errors encountered while loading the database.

expression.LoadDatabaseString( Input )

expression Required. An expression that returns an IPhreeqcCOM object.

Input Required String. The string containing phreeqc database.

Example

This example reads the phreeqc.dat database into a String and loads it into the IPhreeqcCOM object.

  JScript

var ForReading = 1

var fso = new ActiveXObject("Scripting.FileSystemObject");
var ts = fso.OpenTextFile("phreeqc.dat", ForReading);
var strDB = ts.ReadAll();

var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
if (iphreeqc.LoadDatabaseString(strDB) == 0) {
    WScript.Echo("database ok");
} else {
    WScript.Echo("database contains errors");
}

  VBScript

Const ForReading = 1

Dim fso, ts, strDB, Phreeqc

Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile("phreeqc.dat", ForReading)
strDB = ts.ReadAll()

Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
If (iphreeqc.LoadDatabaseString(strDB) = 0) Then
    WScript.Echo("database ok")
Else
    WScript.Echo("database contains errors")
End If


RunAccumulated Method

Runs IPhreeqcCOM using input that's been collected using the AccumulateLine method. Returns the number of errors encountered during the run.

expression.RunAccumulated()

expression Required. An expression that returns an IPhreeqcCOM object.

Remarks

The RunAccumulated method cannot be called until a database has been successfully loaded by one of the following methods: LoadDatabase or LoadDatabaseString.

Example

This example accumulates input and runs it with the IPhreeqcCOM object.

  JScript

var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
iphreeqc.OutputFileOn = true;
iphreeqc.LoadDatabase("phreeqc.dat");

iphreeqc.AccumulateLine("TITLE Example 2.--Temperature dependence of solubility");
iphreeqc.AccumulateLine("                  of gypsum and anhydrite");
iphreeqc.AccumulateLine("SOLUTION 1 Pure water");
iphreeqc.AccumulateLine("        pH      7.0");
iphreeqc.AccumulateLine("        temp    25.0");
iphreeqc.AccumulateLine("EQUILIBRIUM_PHASES 1");
iphreeqc.AccumulateLine("        Gypsum          0.0     1.0");
iphreeqc.AccumulateLine("        Anhydrite       0.0     1.0");
iphreeqc.AccumulateLine("REACTION_TEMPERATURE 1");
iphreeqc.AccumulateLine("        25.0 75.0 in 51 steps");
iphreeqc.AccumulateLine("SELECTED_OUTPUT");
iphreeqc.AccumulateLine("        -file   ex2.sel");
iphreeqc.AccumulateLine("        -temperature");
iphreeqc.AccumulateLine("        -si     anhydrite  gypsum");
iphreeqc.AccumulateLine("END");
if (iphreeqc.RunAccumulated() == 0) {
    WScript.Echo("see " + iphreeqc.OutputFileName + ".");
}

  VBScript

Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
iphreeqc.OutputFileOn = True
iphreeqc.LoadDatabase("phreeqc.dat")

iphreeqc.AccumulateLine("TITLE Example 2.--Temperature dependence of solubility")
iphreeqc.AccumulateLine("                  of gypsum and anhydrite")
iphreeqc.AccumulateLine("SOLUTION 1 Pure water")
iphreeqc.AccumulateLine("        pH      7.0")
iphreeqc.AccumulateLine("        temp    25.0")
iphreeqc.AccumulateLine("EQUILIBRIUM_PHASES 1")
iphreeqc.AccumulateLine("        Gypsum          0.0     1.0")
iphreeqc.AccumulateLine("        Anhydrite       0.0     1.0")
iphreeqc.AccumulateLine("REACTION_TEMPERATURE 1")
iphreeqc.AccumulateLine("        25.0 75.0 in 51 steps")
iphreeqc.AccumulateLine("SELECTED_OUTPUT")
iphreeqc.AccumulateLine("        -file   ex2.sel")
iphreeqc.AccumulateLine("        -temperature")
iphreeqc.AccumulateLine("        -si     anhydrite  gypsum")
iphreeqc.AccumulateLine("END")
If (iphreeqc.RunAccumulated() = 0) Then
    WScript.Echo("see " & iphreeqc.OutputFileName & ".")
End If


RunFile Method

Runs phreeqc using the given file as input. Returns the number of errors encountered during the run.

expression.RunFile( FileName )

expression Required. An expression that returns an IPhreeqcCOM object.

FileName Required String. The name of the phreeqc input file to run.

Remarks

The RunFile method cannot be called until a database has been successfully loaded by one of the following methods: LoadDatabase or LoadDatabaseString.

Example

This example runs the ex1 input file in the IPhreeqcCOM object.

  JScript

var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
iphreeqc.LoadDatabase("phreeqc.dat");
iphreeqc.OutputFileOn = true;
if (iphreeqc.RunFile("ex1") == 0) {
    WScript.Echo("see " + iphreeqc.OutputFileName + ".");
}

  VBScript

Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
iphreeqc.LoadDatabase("phreeqc.dat")
iphreeqc.OutputFileOn = True
If (iphreeqc.RunFile("ex1") = 0) Then
    WScript.Echo("see " & iphreeqc.OutputFileName & ".")
End If


RunString Method

Runs phreeqc using the given string as input. Returns the number of errors encountered during the run.

expression.RunString( Input )

expression Required. An expression that returns an IPhreeqcCOM object.

Input Required String. The string containing phreeqc input.

Remarks

The RunString method cannot be called until a database has been successfully loaded by one of the LoadDatabase methods: LoadDatabase or LoadDatabaseString.

Example

This example stores phreeqc input into a string and runs it with the IPhreeqcCOM object.

  JScript

var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
iphreeqc.LoadDatabase("phreeqc.dat");

var sInput = "SOLUTION 1\n";
sInput += "temp 25.0\n";
sInput += "pH   7.0\n";

iphreeqc.OutputFileOn = true;
iphreeqc.RunString(sInput);
WScript.Echo("see " + iphreeqc.OutputFileName + ".");

  VBScript

Dim iphreeqc, sInput
Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
iphreeqc.LoadDatabase("phreeqc.dat")

sInput = "SOLUTION 1" & vbNewLine
sInput = sInput & "temp 25.0" & vbNewLine
sInput = sInput & "pH   7.0" & vbNewLine

iphreeqc.OutputFileOn = True
iphreeqc.RunString(sInput)
WScript.Echo("see " & iphreeqc.OutputFileName & ".")


ColumnCount Property

Returns the number of columns in the selected output-array. Read-only Long.

Remarks

Accessing selected outputs having a user number other than 1 requires setting the CurrentSelectOutputUserNumber property appropriately.

Example

This example runs ex2 and displays the number of columns in the selected-output array.

  JScript

var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
iphreeqc.LoadDatabase("phreeqc.dat");
iphreeqc.RunFile("ex2");
WScript.Echo("The current selected-output array contains " +
    iphreeqc.ColumnCount + " columns.");

  VBScript

Dim iphreeqc
Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
iphreeqc.LoadDatabase("phreeqc.dat")
iphreeqc.RunFile("ex2")
WScript.Echo("The current selected-output array contains " & _
    iphreeqc.ColumnCount & " columns.")


CurrentSelectedOutputUserNumber Property

Returns or sets the current selected-output user number. Read/write Long.

Remarks

The CurrentSelectedOutputUserNumber property is subsequently used by the selected-output access methods and properties: (ColumnCount, GetSelectedOutputArray, GetSelectedOutputString, GetSelectedOutputValue, SelectedOutputFileName, SelectedOutputFileOn and RowCount).

Example

This example runs the multi_punch input file and writes the selected-output to multiple files.

  JScript

var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
iphreeqc.LoadDatabase("phreeqc.dat");
iphreeqc.RunFile("multi_punch");

var fso = new ActiveXObject("Scripting.FileSystemObject");

var nums = iphreeqc.GetNthSelectedOutputUserNumberList().toArray();
for (var i in nums) {
    var ts = fso.CreateTextFile("sel_out." + nums[i] + ".out", true);

    iphreeqc.CurrentSelectedOutputUserNumber = nums[i];
    var arr = iphreeqc.GetSelectedOutputArray().toArray();
    for (var i = 0; i < iphreeqc.RowCount; ++i) {
        for (var j = 0; j < iphreeqc.ColumnCount; ++j) {
            // Note: JScript doesn't support multi-dimensional arrays
            ts.Write(arr[i + j*iphreeqc.RowCount] + ",");
        }
        ts.WriteLine();
    }
    ts.Close()
}

  VBScript

Dim iphreeqc, fso, num, nums, arr

Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
iphreeqc.LoadDatabase("phreeqc.dat")
iphreeqc.RunFile("multi_punch")

Set fso = CreateObject("Scripting.FileSystemObject")

nums = iphreeqc.GetNthSelectedOutputUserNumberList()

For Each num in nums
    Set ts = fso.CreateTextFile("sel_out." & CStr(num) & ".out", True)

    iphreeqc.CurrentSelectedOutputUserNumber = num
    arr = iphreeqc.GetSelectedOutputArray()
    For i = LBound(arr, 1) To UBound(arr, 1)
        For j = LBound(arr, 2) To UBound(arr, 2)
            ts.Write(CStr(arr(i, j)) & ",")
        Next
        ts.WriteLine()
    Next
    ts.Close()
Next


DumpFileName Property

Returns or sets the name of the dump file. This will be the name of the dump file unless it was specified within the DUMP keyword data block. The initial setting is dump.id.out, where id is obtained from Id. Read/write String.

Remarks

The DumpFileOn property must be set to True before calling a Run method.

Example

This example equilibrates pure water with calcite and writes the dump results to DumpFileName.

  JScript

var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
iphreeqc.LoadDatabase("phreeqc.dat");
iphreeqc.DumpFileOn = true;

var input = new String("");
input += "SOLUTION 1 Pure water     \n";
input += "EQUILIBRIUM_PHASES 1      \n";
input += "    Calcite 0 10          \n";
input += "SAVE solution 1           \n";
input += "SAVE equilibrium_phases 1 \n";
input += "DUMP                      \n";
input += "    -solution 1           \n";
input += "    -equilibrium_phases  1\n";

if (iphreeqc.RunString(input) != 0) {
    WScript.Echo(iphreeqc.GetErrorString());
}
WScript.Echo("see " + iphreeqc.DumpFileName + ".");

  VBScript

Dim iphreeqc, sInput, sDump

Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
iphreeqc.LoadDatabase("phreeqc.dat")
iphreeqc.DumpFileOn = True

sInput = ""
sInput = sInput & "SOLUTION 1 Pure water     " & vbNewLine
sInput = sInput & "EQUILIBRIUM_PHASES 1      " & vbNewLine
sInput = sInput & "    Calcite 0 10          " & vbNewLine
sInput = sInput & "SAVE solution 1           " & vbNewLine
sInput = sInput & "SAVE equilibrium_phases 1 " & vbNewLine
sInput = sInput & "DUMP                      " & vbNewLine
sInput = sInput & "    -solution 1           " & vbNewLine
sInput = sInput & "    -equilibrium_phases  1" & vbNewLine

If (iphreeqc.RunString(sInput) <> 0) Then
    WScript.Echo(iphreeqc.GetErrorString())
End If
WScript.Echo("see " & iphreeqc.DumpFileName & ".")


DumpFileOn Property

True to turn on the dump file. The file will be named DumpFileName unless it was specified within the DUMP keyword data block. The initial setting is False. Read/write Boolean.

Remarks

The DumpFileOn property is used only by the Run methods: RunAccumulated, RunFile and RunString.

Example

This example equilibrates pure water with calcite and writes the dump results to DumpFileName.

  JScript

var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
iphreeqc.LoadDatabase("phreeqc.dat");
iphreeqc.DumpFileOn = true;

var input = new String("");
input += "SOLUTION 1 Pure water     \n";
input += "EQUILIBRIUM_PHASES 1      \n";
input += "    Calcite 0 10          \n";
input += "SAVE solution 1           \n";
input += "SAVE equilibrium_phases 1 \n";
input += "DUMP                      \n";
input += "    -solution 1           \n";
input += "    -equilibrium_phases  1\n";

if (iphreeqc.RunString(input) != 0) {
    WScript.Echo(iphreeqc.GetErrorString());
}
WScript.Echo("see " + iphreeqc.DumpFileName + ".");

  VBScript

Dim iphreeqc, sInput, sDump

Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
iphreeqc.LoadDatabase("phreeqc.dat")
iphreeqc.DumpFileOn = True

sInput = ""
sInput = sInput & "SOLUTION 1 Pure water     " & vbNewLine
sInput = sInput & "EQUILIBRIUM_PHASES 1      " & vbNewLine
sInput = sInput & "    Calcite 0 10          " & vbNewLine
sInput = sInput & "SAVE solution 1           " & vbNewLine
sInput = sInput & "SAVE equilibrium_phases 1 " & vbNewLine
sInput = sInput & "DUMP                      " & vbNewLine
sInput = sInput & "    -solution 1           " & vbNewLine
sInput = sInput & "    -equilibrium_phases  1" & vbNewLine

If (iphreeqc.RunString(sInput) <> 0) Then
    WScript.Echo(iphreeqc.GetErrorString())
End If
WScript.Echo("see " & iphreeqc.DumpFileName & ".")


DumpStringOn Property

True to store data normally sent to the dump file to a string buffer for retrieval. The initial setting is False. Read/write Boolean.

Remarks

The DumpStringOn property is used only by the Run methods: RunAccumulated, RunFile and RunString.

Example

This example equilibrates pure water with calcite and echos the dump string.

  JScript

var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
iphreeqc.LoadDatabase("phreeqc.dat");
iphreeqc.DumpStringOn = true;

var input = new String("");
input += "SOLUTION 1 Pure water     \n";
input += "EQUILIBRIUM_PHASES 1      \n";
input += "    Calcite 0 10          \n";
input += "SAVE solution 1           \n";
input += "SAVE equilibrium_phases 1 \n";
input += "DUMP                      \n";
input += "    -solution 1           \n";
input += "    -equilibrium_phases  1\n";

if (iphreeqc.RunString(input) != 0) {
    WScript.Echo(iphreeqc.GetErrorString());
}
var dump = iphreeqc.GetDumpString();
WScript.Echo(dump);

  VBScript

Dim iphreeqc, sInput, sDump

Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
iphreeqc.LoadDatabase("phreeqc.dat")
iphreeqc.DumpStringOn = True

sInput = ""
sInput = sInput & "SOLUTION 1 Pure water     " & vbNewLine
sInput = sInput & "EQUILIBRIUM_PHASES 1      " & vbNewLine
sInput = sInput & "    Calcite 0 10          " & vbNewLine
sInput = sInput & "SAVE solution 1           " & vbNewLine
sInput = sInput & "SAVE equilibrium_phases 1 " & vbNewLine
sInput = sInput & "DUMP                      " & vbNewLine
sInput = sInput & "    -solution 1           " & vbNewLine
sInput = sInput & "    -equilibrium_phases  1" & vbNewLine

If (iphreeqc.RunString(sInput) <> 0) Then
    WScript.Echo(iphreeqc.GetErrorString())
End If

sDump = "Dump:" & vbNewLine
sDump = sDump & iphreeqc.GetDumpString()
WScript.Echo(sDump)


ErrorFileName Property

Returns or sets the name of the error file. The initial setting is phreeqc.id.err, where id is obtained from Id. Read/write String.

Remarks

The ErrorFileOn property must be set to True before calling a Run method.

Example

The example attempts to run the ex1 input file, fails, and displays the name of the error file.

  JScript

try {
    var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
    iphreeqc.ErrorFileOn = true;
    iphreeqc.RunFile("ex1");
}
catch(e) {
    WScript.Echo("See " + iphreeqc.ErrorFileName + ".");
}

  VBScript

Dim iphreeqc
On Error Resume Next
Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
iphreeqc.ErrorFileOn = True
If (iphreeqc.RunFile("ex1") <> 0) Then
    WScript.Echo(("See " & iphreeqc.ErrorFileName & ".")
End If


ErrorFileOn Property

True to turn on output to the phreeqc error file ErrorFileName. The initial setting is False. Read/write Boolean.

Remarks

The ErrorFileOn property is used only by the Run methods: RunAccumulated, RunFile and RunString.

Example

The example attempts to run the ex1 input file, fails, and writes the error messages to the error file ErrorFileName (no database is loaded).

  JScript

try {
    var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
    iphreeqc.ErrorFileOn = true;
    iphreeqc.RunFile("ex1");
}
catch(e) {
    WScript.Echo("See " & iphreeqc.ErrorFileName & ".");
}

  VBScript

Dim iphreeqc
On Error Resume Next
Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
iphreeqc.ErrorFileOn = True
If (iphreeqc.RunFile("ex1") <> 0) Then
    WScript.Echo("See " & iphreeqc.ErrorFileName & ".")
End If


ErrorStringOn Property

True to store data normally sent to the error file to a string buffer for retrieval. The initial setting is True. Read/write Boolean.

Remarks

The ErrorStringOn property is used only by the Run methods: RunAccumulated, RunFile and RunString.

Example

The example attempts to run the ex1 input file, fails, and displays the error string.

  JScript

try {
    var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
    iphreeqc.ErrorStringOn = true;
    iphreeqc.RunFile("ex1");
}
catch (e) {
    WScript.Echo(iphreeqc.GetErrorString());
}

  VBScript

Dim iphreeqc
On Error Resume Next
Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
iphreeqc.ErrorStringOn = True
If (iphreeqc.RunFile("ex1") <> 0) Then
    WScript.Echo(iphreeqc.GetErrorString())
End If


Id Property

Returns the id of the IPhreeqcCOM object. Read-only Long.

Example

This example creates an IPhreeqcCOM object and displays the Id.

  JScript

var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
WScript.Echo("The id is " + iphreeqc.Id + ".");

  VBScript

Dim iphreeqc
Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
WScript.Echo("The id is " & iphreeqc.Id & ".")


Lines Property

Returns the accumulated text in the input buffer of the IPhreeqcCOM object. Read-only String.

Example

This example loads some keyword input into the IPhreeqcCOM object and displays the result.

  JScript

var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
iphreeqc.AccumulateLine("SOLUTION 1");
iphreeqc.AccumulateLine("END");
WScript.Echo("The accumulated input is:\n" + iphreeqc.Lines);

  VBScript

Dim iphreeqc
Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
iphreeqc.AccumulateLine("SOLUTION 1")
iphreeqc.AccumulateLine("END")
WScript.Echo("The accumulated input is:" & vbNewLine & iphreeqc.Lines)


LogFileName Property

Returns or sets the name of the log file. The initial setting is phreeqc.id.log, where id is obtained from Id. Read/write String.

Remarks

The LogFileOn property must be set to True before calling a Run method.

Example

This example equilibrates pure water with calcite and displays the name of the log file.

  JScript

var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
iphreeqc.LoadDatabase("phreeqc.dat");
iphreeqc.LogFileOn = true;

var input = new String("");
input += "SOLUTION 1 Pure water     \n";
input += "EQUILIBRIUM_PHASES 1      \n";
input += "    Calcite 0 10          \n";
input += "KNOBS                     \n";
input += "    -logfile TRUE         \n";

if (iphreeqc.RunString(input) == 0) {
    WScript.Echo("See " + iphreeqc.LogFileName + ".");
}

  VBScript

Dim iphreeqc, sInput

Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
iphreeqc.LoadDatabase("phreeqc.dat")
iphreeqc.LogFileOn = True

sInput = ""
sInput = sInput & "SOLUTION 1 Pure water     " & vbNewLine
sInput = sInput & "EQUILIBRIUM_PHASES 1      " & vbNewLine
sInput = sInput & "    Calcite 0 10          " & vbNewLine
sInput = sInput & "KNOBS                     " & vbNewLine
sInput = sInput & "    -logfile TRUE         " & vbNewLine

If (iphreeqc.RunString(sInput) = 0) Then
    WScript.Echo("See " & iphreeqc.LogFileName & ".")
End If


LogFileOn Property

True to turn on output to the phreeqc.log file. The initial setting is False. Read/write Boolean.

Remarks

The LogFileOn property is used only by the Run methods: RunAccumulated, RunFile and RunString. Logging must be enabled through the use of the KNOBS -logfile option in order to receive any log messages.

Example

This example runs ex2 with the phreeqc.log file turned on.

  JScript

var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
iphreeqc.LoadDatabase("phreeqc.dat");

// turn logging on
iphreeqc.AccumulateLine("KNOBS; -logfile true");
iphreeqc.RunAccumulated();

iphreeqc.LogFileOn = true;
iphreeqc.RunFile("ex2");
WScript.Echo("see phreeqc.log");

  VBScript

Dim iphreeqc
Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
iphreeqc.LoadDatabase("phreeqc.dat")

' turn logging on
iphreeqc.AccumulateLine("KNOBS; -logfile true")
iphreeqc.RunAccumulated()

iphreeqc.LogFileOn = True
iphreeqc.RunFile("ex2")
WScript.Echo("see phreeqc.log")


LogStringOn Property

True to store data normally sent to the log file to a string buffer for retrieval. The initial setting is False. Read/write Boolean.

Remarks

The LogStringOn property is used only by the Run methods: RunAccumulated, RunFile and RunString.

Example

This example equilibrates pure water with calcite and displays the log string.

  JScript

var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
iphreeqc.LoadDatabase("phreeqc.dat");
iphreeqc.LogStringOn = true;

var input = new String("");
input += "SOLUTION 1 Pure water     \n";
input += "EQUILIBRIUM_PHASES 1      \n";
input += "    Calcite 0 10          \n";
input += "KNOBS                     \n";
input += "    -logfile TRUE         \n";

if (iphreeqc.RunString(input) == 0) {
    WScript.Echo(iphreeqc.GetLogString());
}

  VBScript

Dim iphreeqc, sInput

Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
iphreeqc.LoadDatabase("phreeqc.dat")
iphreeqc.LogStringOn = True

sInput = ""
sInput = sInput & "SOLUTION 1 Pure water     " & vbNewLine
sInput = sInput & "EQUILIBRIUM_PHASES 1      " & vbNewLine
sInput = sInput & "    Calcite 0 10          " & vbNewLine
sInput = sInput & "KNOBS                     " & vbNewLine
sInput = sInput & "    -logfile TRUE         " & vbNewLine

If (iphreeqc.RunString(sInput) = 0) Then
    WScript.Echo(iphreeqc.GetLogString())
End If


OutputFileName Property

Returns or sets the name of the output file. The initial setting is phreeqc.id.out, where id is obtained from Id. Read/write String.

Remarks

The OutputFileOn property must be set to True before calling a Run method.

Example

This example equilibrates pure water with calcite and displays the name of the output file.

  JScript

var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
iphreeqc.LoadDatabase("phreeqc.dat");
iphreeqc.OutputFileOn = true;

var input = new String("");
input += "SOLUTION 1 Pure water     \n";
input += "EQUILIBRIUM_PHASES 1      \n";
input += "    Calcite 0 10          \n";

if (iphreeqc.RunString(input) == 0) {
    WScript.Echo("See " + iphreeqc.OutputFileName + ".");
}

  VBScript

Dim iphreeqc, sInput

Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
iphreeqc.LoadDatabase("phreeqc.dat")
iphreeqc.OutputFileOn = True

sInput = ""
sInput = sInput & "SOLUTION 1 Pure water     " & vbNewLine
sInput = sInput & "EQUILIBRIUM_PHASES 1      " & vbNewLine
sInput = sInput & "    Calcite 0 10          " & vbNewLine

If (iphreeqc.RunString(sInput) = 0) Then
    WScript.Echo("See " & iphreeqc.OutputFileName & ".")
End If


OutputFileOn Property

True to turn on output to the phreeqc.out file. The initial setting is False. Read/write Boolean.

Remarks

The OutputFileOn property is used only by the Run methods: RunAccumulated, RunFile and RunString.

Example

This example runs ex2 with the phreeqc.out file turned on.

  JScript

var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
iphreeqc.LoadDatabase("phreeqc.dat");
iphreeqc.OutputFileOn = true;
iphreeqc.RunFile("ex2");
WScript.Echo("see phreeqc.out");

  VBScript

Dim iphreeqc
Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
iphreeqc.LoadDatabase("phreeqc.dat")
iphreeqc.OutputFileOn = True
iphreeqc.RunFile("ex2")
WScript.Echo("see phreeqc.out")


OutputStringOn Property

True to store data normally sent to the output file to a string buffer for retrieval. The initial setting is False. Read/write Boolean.

Remarks

The OutputStringOn property is used only by the Run methods: RunAccumulated, RunFile and RunString.

Example

This example equilibrates pure water with calcite and displays the results.

  JScript

var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
iphreeqc.LoadDatabase("phreeqc.dat");
iphreeqc.OutputStringOn = true;

var input = new String("");
input += "SOLUTION 1 Pure water     \n";
input += "EQUILIBRIUM_PHASES 1      \n";
input += "    Calcite 0 10          \n";

if (iphreeqc.RunString(input) == 0) {
    WScript.Echo(iphreeqc.GetOutputString());
}

  VBScript

Dim iphreeqc, sInput

Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
iphreeqc.LoadDatabase("phreeqc.dat")
iphreeqc.OutputStringOn = True

sInput = ""
sInput = sInput & "SOLUTION 1 Pure water     " & vbNewLine
sInput = sInput & "EQUILIBRIUM_PHASES 1      " & vbNewLine
sInput = sInput & "    Calcite 0 10          " & vbNewLine

If (iphreeqc.RunString(sInput) = 0) Then
    WScript.Echo(iphreeqc.GetOutputString())
End If


RowCount Property

Returns the number of rows in the selected-output array. Read-only Long.

Remarks

Accessing selected outputs having a user number other than 1 requires setting the CurrentSelectOutputUserNumber property appropriately.

Example

This example runs ex2 and displays the number of rows in the selected-output array.

  JScript

var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
iphreeqc.LoadDatabase("phreeqc.dat");
iphreeqc.RunFile("ex2");
WScript.Echo("The current selected-output array contains " +
    iphreeqc.RowCount + " rows.");

  VBScript

Dim iphreeqc
Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
iphreeqc.LoadDatabase("phreeqc.dat")
iphreeqc.RunFile("ex2")
WScript.Echo("The current selected-output array contains " & _
    iphreeqc.RowCount & " rows.")


SelectedOutputFileName Property

Returns or sets the name of the selected-output file. The initial setting is selected.id.out, where id is obtained from Id. Read/write String.

Remarks

The SelectedOutputFileOn property must be set to True before calling a Run method.

Example

This example runs ex2 with the selected-output file turned on.

  JScript

var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
iphreeqc.LoadDatabase("phreeqc.dat");
iphreeqc.SelectedOutputFileOn = true;
if (iphreeqc.RunFile("ex2") == 0) {
    WScript.Echo("See " + iphreeqc.SelectedOutputFileName + ".");
}

  VBScript

Dim iphreeqc
Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
iphreeqc.LoadDatabase("phreeqc.dat")
iphreeqc.SelectedOutputFileOn = True
If (iphreeqc.RunFile("ex2") = 0) Then
    WScript.Echo("See " & iphreeqc.SelectedOutputFileName & ".")
End If


SelectedOutputFileOn Property

True to turn on the selected-output file. The file will be named selected.out unless a FileName was specified within the SELECTED_OUTPUT keyword data block. The initial setting is False. Read/write Boolean.

Remarks

The SelectedOutputFileOn property is used only by the Run methods: RunAccumulated, RunFile and RunString.

Example

This example runs ex2 with the selected-output file turned on.

  JScript

var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
iphreeqc.LoadDatabase("phreeqc.dat");
iphreeqc.SelectedOutputFileOn = true;
if (iphreeqc.RunFile("ex2") == 0) {
    WScript.Echo("See " + iphreeqc.SelectedOutputFileName + ".");
}

  VBScript

Dim iphreeqc
Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
iphreeqc.LoadDatabase("phreeqc.dat")
iphreeqc.SelectedOutputFileOn = True
If (iphreeqc.RunFile("ex2") = 0) Then
    WScript.Echo("See " & iphreeqc.SelectedOutputFileName & ".")
End If


SelectedOutputStringOn Property

True to store data normally sent to the selected-output file to a string buffer for retrieval. The initial setting is False. Read/write Boolean.

Remarks

The SelectedOutputStringOn property is used only by the Run methods: RunAccumulated, RunFile and RunString.

Example

This example runs ex2 and displays the selected-output string.

  JScript

var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
iphreeqc.LoadDatabase("phreeqc.dat");
iphreeqc.SelectedOutputStringOn = true;
if (iphreeqc.RunFile("ex2") == 0) {
    WScript.Echo(iphreeqc.GetSelectedOutputString());
}

  VBScript

Dim iphreeqc
Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
iphreeqc.LoadDatabase("phreeqc.dat")
iphreeqc.SelectedOutputStringOn = True
If (iphreeqc.RunFile("ex2") = 0) Then
    WScript.Echo(iphreeqc.GetSelectedOutputString())
End If


Version Property

Returns the version number of the IPhreeqcCOM object. Read-only String.

Example

This example creates an IPhreeqcCOM object and displays the Version.

  JScript

var iphreeqc = new ActiveXObject("IPhreeqcCOM.Object");
WScript.Echo(iphreeqc.Version);

  VBScript

Dim iphreeqc
Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
WScript.Echo iphreeqc.Version


Callback Event

Occurs when a call is made to CALLBACK from within a PHREEQC Basic program.

Sub object_Callback( x1, x2, str, value )

object An object of type IPhreeqcCOM declared with events.

x1 Required Double. The first argument given to the CALLBACK function.

x2 Required Double. The second argument given to the CALLBACK function.

str Required String. The third argument given to the CALLBACK function.

value Double. The value returned to the PHREEQC Basic function CALLBACK.

Remarks

Currently, the JScript example doesn't work correctly. The value returned to the PHREEQC Basic function CALLBACK is not updated.

Example

This example uses the CALLBACK functionality to set the year column of the selected output.

  JScript (*** BROKEN See Remarks. ***)

var iphreeqc = WScript.CreateObject("IPhreeqcCOM.Object");
WScript.ConnectObject(iphreeqc, "iphreeqc_");

var year = 2012

iphreeqc.LoadDatabase("phreeqc.dat");

iphreeqc.AccumulateLine("SOLUTION 1-2");
iphreeqc.AccumulateLine("END");
iphreeqc.AccumulateLine("EQUILIBRIUM_PHASES 1");
iphreeqc.AccumulateLine("   CO2(g) -1.5 10");
iphreeqc.AccumulateLine("EQUILIBRIUM_PHASES 2");
iphreeqc.AccumulateLine("   Calcite 0   10");
iphreeqc.AccumulateLine("SELECTED_OUTPUT 1");
iphreeqc.AccumulateLine("   -reset false");
iphreeqc.AccumulateLine("USER_PUNCH");
iphreeqc.AccumulateLine("   -Heading  pH  SR(calcite)  Year");
iphreeqc.AccumulateLine("   10 PUNCH -LA(\"H+\"), SR(\"calcite\")");
iphreeqc.AccumulateLine("   20 PUNCH CALLBACK(cell_no, -LA(\"H+\"), \"Year\")");
iphreeqc.AccumulateLine("END");
iphreeqc.AccumulateLine("RUN_CELLS");
iphreeqc.AccumulateLine("   -cells 1-2");
iphreeqc.AccumulateLine("END");

iphreeqc.SelectedOutputFileOn = true;

if (iphreeqc.RunAccumulated() == 0) {
    WScript.Echo("see " + iphreeqc.SelectedOutputFileName + ".");
}

WScript.DisconnectObject(iphreeqc);

iphreeqc = null

function iphreeqc_Callback(x1, x2, str, value) {
    var value = -1;
    if (str == "Year") {
        value = year;
        year = year + 1;
    }
}

  Python (with pywin32)

from win32com.client import DispatchWithEvents

def RunWithCallback():
    class IPhreeqcCOMEvents:
        def __init__(self):
           self.year = 2012

        def OnCallback(self, x1, x2, str, value):
            value = -1
            if str == "Year":
                value = self.year
                self.year += 1
            return value

    iphreeqc = DispatchWithEvents("IPhreeqcCOM.Object", IPhreeqcCOMEvents)

    iphreeqc.LoadDatabase("phreeqc.dat")

    iphreeqc.AccumulateLine("SOLUTION 1-2")
    iphreeqc.AccumulateLine("END")
    iphreeqc.AccumulateLine("EQUILIBRIUM_PHASES 1")
    iphreeqc.AccumulateLine("   CO2(g) -1.5 10")
    iphreeqc.AccumulateLine("EQUILIBRIUM_PHASES 2")
    iphreeqc.AccumulateLine("   Calcite 0   10")
    iphreeqc.AccumulateLine("SELECTED_OUTPUT 1")
    iphreeqc.AccumulateLine("   -reset false")
    iphreeqc.AccumulateLine("USER_PUNCH")
    iphreeqc.AccumulateLine("   -Heading  pH  SR(calcite)  Year")
    iphreeqc.AccumulateLine("   10 PUNCH -LA(\"H+\"), SR(\"calcite\")")
    iphreeqc.AccumulateLine("   20 PUNCH CALLBACK(cell_no, -LA(\"H+\"), \"Year\")")
    iphreeqc.AccumulateLine("END")
    iphreeqc.AccumulateLine("RUN_CELLS")
    iphreeqc.AccumulateLine("   -cells 1-2")
    iphreeqc.AccumulateLine("END")

    iphreeqc.SelectedOutputFileOn = True

    if iphreeqc.RunAccumulated() == 0:
        print "see " + iphreeqc.SelectedOutputFileName + "."

if __name__ == '__main__':
    RunWithCallback()

  VBScript

Dim iphreeqc, year

Set iphreeqc = CreateObject("IPhreeqcCOM.Object")
WScript.ConnectObject iphreeqc, "iphreeqc_"

year = 2012

iphreeqc.LoadDatabase("phreeqc.dat")

iphreeqc.AccumulateLine("SOLUTION 1-2")
iphreeqc.AccumulateLine("END")
iphreeqc.AccumulateLine("EQUILIBRIUM_PHASES 1")
iphreeqc.AccumulateLine("   CO2(g) -1.5 10")
iphreeqc.AccumulateLine("EQUILIBRIUM_PHASES 2")
iphreeqc.AccumulateLine("   Calcite 0   10")
iphreeqc.AccumulateLine("SELECTED_OUTPUT 1")
iphreeqc.AccumulateLine("   -reset false")
iphreeqc.AccumulateLine("USER_PUNCH")
iphreeqc.AccumulateLine("   -Heading  pH  SR(calcite)  Year")
iphreeqc.AccumulateLine("   10 PUNCH -LA(""H+""), SR(""calcite"")")
iphreeqc.AccumulateLine("   20 PUNCH CALLBACK(cell_no, -LA(""H+""), ""Year"")")
iphreeqc.AccumulateLine("END")
iphreeqc.AccumulateLine("RUN_CELLS")
iphreeqc.AccumulateLine("   -cells 1-2")
iphreeqc.AccumulateLine("END")

iphreeqc.SelectedOutputFileOn = True

If (iphreeqc.RunAccumulated() = 0) Then
    WScript.Echo("See " & iphreeqc.SelectedOutputFileName & ".")
End If

WScript.DisconnectObject iphreeqc

Set iphreeqc = Nothing

Sub iphreeqc_CallBack(x1, x2, str, value)
    value = -1
    If (str = "Year") Then
        value = year
        year = year + 1
    End If
End Sub


ex1

TITLE Example 1.--Add uranium and speciate seawater.
SOLUTION 1  SEAWATER FROM NORDSTROM ET AL. (1979)
        units   ppm
        pH      8.22
        pe      8.451
        density 1.023
        temp    25.0
        redox   O(0)/O(-2)
        Ca              412.3
        Mg              1291.8
        Na              10768.0
        K               399.1
        Fe              0.002
        Mn              0.0002  pe
        Si              4.28
        Cl              19353.0
        Alkalinity      141.682 as HCO3
        S(6)            2712.0
        N(5)            0.29    gfw   62.0
        N(-3)           0.03    as    NH4
        U               3.3     ppb   N(5)/N(-3)
        O(0)            1.0     O2(g) -0.7
SOLUTION_MASTER_SPECIES
        U       U+4     0.0     238.0290     238.0290
        U(4)    U+4     0.0     238.0290
        U(5)    UO2+    0.0     238.0290
        U(6)    UO2+2   0.0     238.0290
SOLUTION_SPECIES
        #primary master species for U
        #is also secondary master species for U(4)
        U+4 = U+4
                log_k          0.0
        U+4 + 4 H2O = U(OH)4 + 4 H+
                log_k          -8.538
                delta_h        24.760 kcal
        U+4 + 5 H2O = U(OH)5- + 5 H+
                log_k          -13.147
                delta_h        27.580 kcal
        #secondary master species for U(5)
        U+4 + 2 H2O = UO2+ + 4 H+ + e-
                log_k          -6.432
                delta_h        31.130 kcal
        #secondary master species for U(6)
        U+4 + 2 H2O = UO2+2 + 4 H+ + 2 e-
                log_k          -9.217
                delta_h        34.430 kcal
        UO2+2 + H2O = UO2OH+ + H+
                log_k          -5.782
                delta_h        11.015 kcal
        2UO2+2 + 2H2O = (UO2)2(OH)2+2 + 2H+
                log_k          -5.626
                delta_h        -36.04 kcal
        3UO2+2 + 5H2O = (UO2)3(OH)5+ + 5H+
                log_k          -15.641
                delta_h        -44.27 kcal
        UO2+2 + CO3-2 = UO2CO3
                log_k          10.064
                delta_h        0.84 kcal
        UO2+2 + 2CO3-2 = UO2(CO3)2-2
                log_k          16.977
                delta_h        3.48 kcal
        UO2+2 + 3CO3-2 = UO2(CO3)3-4
                log_k          21.397
                delta_h        -8.78 kcal
PHASES
        Uraninite
        UO2 + 4 H+ = U+4 + 2 H2O
        log_k          -3.490
        delta_h        -18.630 kcal
END


ex2

TITLE Example 2.--Temperature dependence of solubility
                  of gypsum and anhydrite
SOLUTION 1 Pure water
        pH      7.0
        temp    25.0
EQUILIBRIUM_PHASES 1
        Gypsum          0.0     1.0
        Anhydrite       0.0     1.0
REACTION_TEMPERATURE 1
        25.0 75.0 in 51 steps
SELECTED_OUTPUT
        -file   ex2.sel
        -temperature
        -si     anhydrite  gypsum
USER_GRAPH 1 Example 2
        -headings Temperature Gypsum Anhydrite
        -chart_title "Gypsum-Anhydrite Stability"
        -axis_scale x_axis 25 75 5 0
        -axis_scale y_axis auto 0.05 0.1
        -axis_titles "Temperature, in degrees celsius" "Saturation index"
        -initial_solutions false
  -start
  10 graph_x TC
  20 graph_y SI("Gypsum") SI("Anhydrite")
  -end
END


multi_punch

SOLUTION 1
    pH      7 charge
    Na	1
    Cl	1
    Ca	1
    C	  2
END
CALCULATE_VALUES
TOTAL_C
-start
10 save TOT("C")
-end
END
EQUILIBRIUM_PHASES 1
    CO2(g) -2
    Dolomite 0
END
REACTION 1
    HCl 1
    0.1 mmol
END
GAS_PHASE
    -fixed_volume
    N2(g)	1.2
END
KINETICS
    Calcite
        -tol    1e-8
        -m0	 3.e-3
        -m	3.e-3
        -parms	50	  0.6
END
SOLID_SOLUTION
Sulfate
    -comp 	Anhydrite	1.0
    -comp	Barite		1.0
END
RUN_CELLS
    -cell 1
SELECTED_OUTPUT
    -file multi_punch_1.sel
    -reset false
    -sim
    -state
    -solution
    -dist
    -time
    -step
    -pH
    -pe
    -reaction
    -temperature
    -alkalinity
    -ionic_strength
    -water
    -charge_balance
    -percent_error
    -totals			Na	Ca
    -molalities		Na+	HCO3-
    -activities		Ca+2	CO3-2
    -equilibrium_phases	CO2(g)	dolomite
    -saturation_indices	Halite
    -gases			N2(g)
    -kinetics		Calcite
    -solid_solutions	Anhydrite	Barite
    -calculate_values       TOTAL_C
    -inverse                false
SELECTED_OUTPUT 2
    -file multi_punch_2.sel
    -si Halite Calcite
USER_PUNCH 20
-heading Dummy
10 PUNCH "Dummy"
END
USER_PUNCH 2
-heading DUMMY_1 DUMMY_2
10 PUNCH "Dummy1", "Dummy2"
RUN_CELLS
    -cell 1
SELECTED_OUTPUT 1
    -active false
END
RUN_CELLS
    -cell 1
SELECTED_OUTPUT 1
    -active true
END
SOLUTION 2
    pH 7 charge
END
SOLUTION 3
    pH 7 charge
    Na	1
    Cl	1
END
INVERSE_MODELING
    -solution  2 3
    -phases
        Halite
SELECTED_OUTPUT 3
    -reset false
    -file multi_punch_3.sel
END
RUN_CELLS
    -cell 1


IPhreeqcCOM Object


IPhreeqcCOM Object

CurrentSelectedOutputUserNumber Method


IPhreeqcCOM Object

LoadDatabaseString Method


IPhreeqcCOM Object

LoadDatabase Method


Phreeqc Object


ColumnCount Property

CurrentSelectedOutputUserNumber Property

DumpFileName Property

DumpFileOn Property

DumpStringOn Property

ErrorFileName Property

ErrorFileOn Property

ErrorStringOn Property

Id Property

Lines Property

LogFileName Property

LogFileOn Property

LogStringOn Property

OutputFileName Property

OutputFileOn Property

OutputStringOn Property

RowCount Property

SelectedOutputFileName Property

SelectedOutputFileOn Property

SelectedOutputFileOn Property

SelectedOutputStringOn Property

Version Property

AccumulateLine Method

ClearAccumulatedLines Method

GetComponentList Method

GetDumpString Method

GetErrorString Method

GetLogString Method

GetNthSelectedOutputUserNumberList Met...

GetOutputString Method

GetSelectedOutputArray Method

GetSelectedOutputString Method

GetSelectedOutputValue Method

GetWarningString Method

LoadDatabase Method

LoadDatabaseString Method

RunAccumulated Method

RunFile Method

RunString Method

Callback Event

AddIns Object

Application Object

AutoCorrect Object

AutoRecover Object

CellFormat Object

Chart Object

DefaultWebOptions Object

Dialogs Object

ErrorCheckingOptions Object

Names Object

ODBCErrors Object

OLEDBErrors Object

Range Object

RecentFiles Object

RTD Object

Sheets Object

SmartTagRecognizers Object

Speech Object

SpellingOptions Object

UsedObjects Object

Watches Object

Window Object

Windows Object

Workbook Object

Workbooks Object

WorksheetFunction Object


INDEX~TEXT
seealso~"See&nbsp;Also"
appliesto~"Applies&nbsp;To"
elements~"Elements"
properties~"Properties"
methods~"Methods"
events~"Events"
example~"Example"
specifics~"Specifics"
show~"Show&nbsp;description"
hide~"Hide&nbsp;description"
parentelements~"Parents"
childelements~"Children"
attributeslinks~"Attributes"
section~"Section"
rows~"Rows"
cells~"Cells"


IPhreeqcCOM Object

GetNthSelectedOutputUserNumberList Method


IPhreeqcCOM Object

ColumnCount Property

CurrentSelectedOutputUserNumber Property

GetSelectedOutputArray Method

GetSelectedOutputValue Method

SelectedOutputFileOn Property