IPhreeqc 2.18
Public Member Functions

IPhreeqc Class Reference

Provides an interface to PHREEQC (Version 2)--A Computer Program for Speciation, Batch-Reaction, One-Dimensional Transport, and Inverse Geochemical Calculations. More...

#include <IPhreeqc.hpp>

Public Member Functions

 IPhreeqc (void)
 ~IPhreeqc (void)
VRESULT AccumulateLine (const char *line)
size_t AddError (const char *error_msg)
size_t AddWarning (const char *warning_msg)
void ClearAccumulatedLines (void)
const std::string & GetAccumulatedLines (void)
const char * GetComponent (int n)
size_t GetComponentCount (void)
bool GetDumpFileOn (void) const
const char * GetDumpString (void)
const char * GetDumpStringLine (int n)
int GetDumpStringLineCount (void) const
bool GetDumpStringOn (void) const
bool GetErrorFileOn (void) const
const char * GetErrorString (void)
const char * GetErrorStringLine (int n)
int GetErrorStringLineCount (void) const
bool GetLogFileOn (void) const
bool GetOutputFileOn (void) const
int GetSelectedOutputColumnCount (void) const
bool GetSelectedOutputFileOn (void) const
int GetSelectedOutputRowCount (void) const
VRESULT GetSelectedOutputValue (int row, int col, VAR *pVAR)
const char * GetWarningString (void)
const char * GetWarningStringLine (int n)
int GetWarningStringLineCount (void) const
std::list< std::string > ListComponents (void)
int LoadDatabase (const char *filename)
int LoadDatabaseString (const char *input)
void OutputAccumulatedLines (void)
void OutputErrorString (void)
void OutputWarningString (void)
int RunAccumulated (void)
int RunFile (const char *filename)
int RunString (const char *input)
void SetDumpFileOn (bool bValue)
void SetDumpStringOn (bool bValue)
void SetErrorFileOn (bool bValue)
void SetLogFileOn (bool bValue)
void SetOutputFileOn (bool bValue)
void SetSelectedOutputFileOn (bool bValue)

Detailed Description

Provides an interface to PHREEQC (Version 2)--A Computer Program for Speciation, Batch-Reaction, One-Dimensional Transport, and Inverse Geochemical Calculations.


Constructor & Destructor Documentation

IPhreeqc::IPhreeqc ( void  )

Constructor.

Example:
#include <cstdlib>
#include <iostream>
#include <IPhreeqc.hpp>

int main(void)
{
  IPhreeqc iphreeqc;
  
  if (iphreeqc.LoadDatabase("phreeqc.dat") != 0) {
    std::cout << iphreeqc.GetErrorString() << std::endl;
    return EXIT_FAILURE;
  }
  
  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) {
    std::cout << iphreeqc.GetErrorString() << std::endl;
    return EXIT_FAILURE;
  }
  
  VAR v;
  ::VarInit(&v);
  
  std::cout << "selected-output:" << std::endl;
  for (int i = 0; i < iphreeqc.GetSelectedOutputRowCount(); ++i) {
    for (int j = 0; j < iphreeqc.GetSelectedOutputColumnCount(); ++j) {
      if (iphreeqc.GetSelectedOutputValue(i, j, &v) == VR_OK) {
        switch (v.type) {
        case TT_LONG:
          std::cout << v.lVal << " ";
          break;
        case TT_DOUBLE:
          std::cout << v.dVal << " ";
          break;
        case TT_STRING:
          std::cout << v.sVal << " ";
          break;
        }
      }
      ::VarClear(&v);
    }
    std::cout << std::endl;
  }
  return EXIT_SUCCESS;
}
IPhreeqc::~IPhreeqc ( void  )

Destructor


Member Function Documentation

VRESULT IPhreeqc::AccumulateLine ( const char *  line)

Accumlulate line(s) for input to phreeqc.

Parameters:
lineThe line(s) to add for input to phreeqc.
Return values:
VR_OKSuccess
VR_OUTOFMEMORYOut of memory
See also:
ClearAccumulatedLines, OutputAccumulatedLines, RunAccumulated
size_t IPhreeqc::AddError ( const char *  error_msg)

Appends the given error message and increments the error count. Internally used to create an error condition.

Parameters:
error_msgThe error message to display.
Returns:
The current error count.
See also:
GetErrorString, GetErrorStringLine, GetErrorStringLineCount, OutputErrorString
size_t IPhreeqc::AddWarning ( const char *  warning_msg)

Appends the given warning message and increments the warning count. Internally used to create a warning condition.

Parameters:
warning_msgThe warning message to display.
Returns:
The current warning count.
See also:
GetWarningString, GetWarningStringLine, GetWarningStringLineCount, OutputWarningString
void IPhreeqc::ClearAccumulatedLines ( void  )

Clears the accumulated input buffer. Input buffer is accumulated from calls to AccumulateLine.

See also:
AccumulateLine, GetAccumulatedLines, OutputAccumulatedLines, RunAccumulated
const std::string& IPhreeqc::GetAccumulatedLines ( void  )

Retrieve the accumulated input string. The accumulated input string can be run with RunAccumulated.

Returns:
The accumulated input string.
See also:
AccumulateLine, ClearAccumulatedLines, OutputAccumulatedLines, RunAccumulated
const char* IPhreeqc::GetComponent ( int  n)

Retrieves the given component.

Parameters:
nThe zero-based index of the component to retrieve.
Returns:
A null terminated string containing the given component. Returns an empty string if n is out of range.
See also:
GetComponentCount, ListComponents
size_t IPhreeqc::GetComponentCount ( void  )

Retrieves the number of components in the current list of components.

Returns:
The current count of components.
See also:
GetComponent, ListComponents
bool IPhreeqc::GetDumpFileOn ( void  ) const

Retrieves the current value of the dump file switch.

Return values:
trueOutput is written to the DUMP (dump.out if unspecified) file.
falseNo output is written.
See also:
GetDumpStringLine, GetDumpStringLineCount, GetDumpStringOn, GetDumpString, SetDumpFileOn, SetDumpStringOn
const char* IPhreeqc::GetDumpString ( void  )

Retrieves the string buffer containing DUMP output.

Returns:
A null terminated string containing DUMP output.
Precondition:
SetDumpStringOn must have been set to true in order to recieve DUMP output.
See also:
GetDumpStringLine, GetDumpFileOn, GetDumpStringLineCount, GetDumpStringOn, SetDumpFileOn, SetDumpStringOn
const char* IPhreeqc::GetDumpStringLine ( int  n)

Retrieves the given dump line.

Parameters:
nThe zero-based index of the line to retrieve.
Returns:
A null terminated string containing the given line. Returns an empty string if n is out of range.
Precondition:
SetDumpStringOn must have been set to true.
See also:
GetDumpFileOn, GetDumpString, GetDumpStringLineCount, GetDumpStringOn, SetDumpFileOn, SetDumpStringOn
int IPhreeqc::GetDumpStringLineCount ( void  ) const

Retrieves the number of lines in the current dump string buffer.

Returns:
The number of lines.
Precondition:
SetDumpStringOn must have been set to true.
See also:
GetDumpFileOn, GetDumpString, GetDumpStringLine, GetDumpStringOn, SetDumpFileOn, SetDumpStringOn
bool IPhreeqc::GetDumpStringOn ( void  ) const

Retrieves the current value of the dump string switch.

Return values:
trueOutput defined by the DUMP keyword is stored.
falseNo output is stored.
See also:
GetDumpFileOn, GetDumpString, GetDumpStringLine, GetDumpStringLineCount, SetDumpFileOn, SetDumpStringOn
bool IPhreeqc::GetErrorFileOn ( void  ) const

Retrieves the current value of the error file switch.

Return values:
trueErrors are written to the phreeqc.err file.
falseNo errors are written.
See also:
SetErrorFileOn
const char* IPhreeqc::GetErrorString ( void  )

Retrieves the error messages from the last call to RunAccumulated, RunFile, RunString, LoadDatabase, or LoadDatabaseString.

Returns:
A null terminated string containing error messages.
See also:
GetErrorStringLine, GetErrorStringLineCount, GetErrorFileOn, OutputErrorString, SetErrorFileOn
const char* IPhreeqc::GetErrorStringLine ( int  n)

Retrieves the given error line.

Returns:
A null terminated string containing the given line of the error string buffer.
Parameters:
nThe zero-based index of the line to retrieve.
See also:
GetErrorStringLineCount, OutputErrorString
int IPhreeqc::GetErrorStringLineCount ( void  ) const

Retrieves the number of lines in the current error string buffer.

Returns:
The number of lines.
See also:
GetErrorStringLine, OutputErrorString
bool IPhreeqc::GetLogFileOn ( void  ) const

Retrieves the current value of the log file switch.

Return values:
trueLog messages are written to the phreeqc.log file.
falseNo log messages are written.
Remarks:
Logging must be enabled through the use of the KNOBS -logfile option in order to receive any log messages.
See also:
SetLogFileOn
bool IPhreeqc::GetOutputFileOn ( void  ) const

Retrieves the current value of the output file switch.

Return values:
trueOutput is written to the phreeqc.out file.
falseNo output is written.
See also:
SetOutputFileOn
int IPhreeqc::GetSelectedOutputColumnCount ( void  ) const

Retrieves the number of columns in the selected-output buffer.

Returns:
The number of columns.
See also:
GetSelectedOutputRowCount, GetSelectedOutputValue
bool IPhreeqc::GetSelectedOutputFileOn ( void  ) const

Retrieves the selected-output file switch.

Return values:
trueOutput is written to the selected-output (selected.out if unspecified) file.
falseNo output is written.
See also:
GetSelectedOutputValue, GetSelectedOutputColumnCount, GetSelectedOutputRowCount, SetSelectedOutputFileOn
int IPhreeqc::GetSelectedOutputRowCount ( void  ) const

Retrieves the number of rows in the selected-output buffer.

Returns:
The number of rows.
See also:
GetSelectedOutputColumnCount, GetSelectedOutputFileOn, GetSelectedOutputValue, SetSelectedOutputFileOn
VRESULT IPhreeqc::GetSelectedOutputValue ( int  row,
int  col,
VAR pVAR 
)

Returns the VAR associated with the specified row and column.

Parameters:
rowThe row index.
colThe column index.
pVARPointer to the VAR to recieve the requested data.
Return values:
VR_OKSuccess.
VR_INVALIDROWThe given row is out of range.
VR_INVALIDCOLThe given column is out of range.
VR_OUTOFMEMORYMemory could not be allocated.
VR_BADINSTANCEThe given id is invalid.
See also:
GetSelectedOutputColumnCount, GetSelectedOutputFileOn, GetSelectedOutputRowCount, SetSelectedOutputFileOn
Remarks:
Row 0 contains the column headings to the selected_ouput.
Examples:
The headings will include a suffix and/or prefix in order to differentiate the columns.

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
	
const char* IPhreeqc::GetWarningString ( void  )

Retrieves the warning messages from the last call to RunAccumulated, RunFile, RunString, LoadDatabase, or LoadDatabaseString.

Returns:
A null terminated string containing warning messages.
See also:
GetWarningStringLine, GetWarningStringLineCount, OutputWarningString
const char* IPhreeqc::GetWarningStringLine ( int  n)

Retrieves the given warning line.

Parameters:
nThe zero-based index of the line to retrieve.
Returns:
A null terminated string containing the given warning line message.
See also:
GetWarningStringLineCount, OutputWarningString
int IPhreeqc::GetWarningStringLineCount ( void  ) const

Retrieves the number of lines in the current warning string buffer.

Returns:
The number of lines.
See also:
GetWarningStringLine, GetWarningString, OutputWarningString
std::list< std::string > IPhreeqc::ListComponents ( void  )

Retrieves the current list of components.

Returns:
The current list of components.
See also:
GetComponent, GetComponentCount
int IPhreeqc::LoadDatabase ( const char *  filename)

Load the specified database file into phreeqc.

Parameters:
filenameThe name of the phreeqc database to load. The full path (or relative path with respect to the working directory) will be required if the file is not in the current working directory.
Returns:
The number of errors encountered.
See also:
LoadDatabaseString
Remarks:
All previous definitions are cleared.
int IPhreeqc::LoadDatabaseString ( const char *  input)

Load the specified string as a database into phreeqc.

Parameters:
inputString containing data to be used as the phreeqc database.
Returns:
The number of errors encountered.
See also:
LoadDatabaseString
Remarks:
All previous definitions are cleared.
void IPhreeqc::OutputAccumulatedLines ( void  )

Output the accumulated input buffer to stdout. The input buffer can be run with a call to RunAccumulated.

See also:
AccumulateLine, ClearAccumulatedLines, RunAccumulated
void IPhreeqc::OutputErrorString ( void  )

Output the error messages normally stored in the phreeqc.err file to stdout.

See also:
GetErrorStringLine, GetErrorStringLineCount, GetErrorFileOn, SetErrorFileOn
void IPhreeqc::OutputWarningString ( void  )

Output the warning messages to stdout.

See also:
GetWarningStringLine, GetWarningStringLineCount, GetWarningString
int IPhreeqc::RunAccumulated ( void  )

Runs the input buffer as defined by calls to AccumulateLine.

Returns:
The number of errors encountered.
See also:
AccumulateLine, ClearAccumulatedLines, OutputAccumulatedLines, RunFile, RunString
Remarks:
The accumulated input is cleared at the next call to AccumulateLine.
Precondition:
LoadDatabase/LoadDatabaseString must have been called and returned 0 (zero) errors.
int IPhreeqc::RunFile ( const char *  filename)

Runs the specified phreeqc input file.

Parameters:
filenameThe name of the phreeqc input file to run.
Returns:
The number of errors encountered during the run.
See also:
RunAccumulated, RunString
Precondition:
LoadDatabase/LoadDatabaseString must have been called and returned 0 (zero) errors.
int IPhreeqc::RunString ( const char *  input)

Runs the specified string as input to phreeqc.

Parameters:
inputString containing phreeqc input.
Returns:
The number of errors encountered during the run.
See also:
RunAccumulated, RunFile
Precondition:
LoadDatabase/LoadDatabaseString must have been called and returned 0 (zero) errors.
void IPhreeqc::SetDumpFileOn ( bool  bValue)

Sets the dump file switch on or off. This switch controls whether or not phreeqc writes to the DUMP (dump.out if unspecified) file. The initial setting is false.

Parameters:
bValueIf true, turns on output to the DUMP file; if false, turns off output to the DUMP file.
See also:
GetDumpFileOn, GetDumpString, GetDumpStringOn, GetDumpStringLine, GetDumpStringLineCount, SetDumpStringOn
void IPhreeqc::SetDumpStringOn ( bool  bValue)

Sets the dump string switch on or off. This switch controls whether or not the data normally sent to the dump file are stored in a buffer for retrieval. The initial setting is false.

Parameters:
bValueIf true, captures the output defined by the DUMP keyword into a string buffer; if false, output defined by the DUMP keyword is not captured to a string buffer.
See also:
GetDumpFileOn, GetDumpString, GetDumpStringOn, GetDumpStringLine, GetDumpStringLineCount, SetDumpFileOn
void IPhreeqc::SetErrorFileOn ( bool  bValue)

Sets the error file switch on or off. This switch controls whether or not error messages are written to the phreeqc.err file. The initial setting is false.

Parameters:
bValueIf true, writes errors to the error file; if false, no errors are written to the error file.
See also:
GetErrorStringLine, GetErrorStringLineCount, GetErrorFileOn, OutputErrorString
void IPhreeqc::SetLogFileOn ( bool  bValue)

Sets the log file switch on or off. This switch controls whether or not phreeqc writes log messages to the phreeqc.log file. The initial setting is false.

Parameters:
bValueIf true, turns on output to the log file; if false, no log messages are written to the log file.
Remarks:
Logging must be enabled through the use of the KNOBS -logfile option in order to receive any log messages.
See also:
GetLogFileOn
void IPhreeqc::SetOutputFileOn ( bool  bValue)

Sets the output file switch on or off. This switch controls whether or not phreeqc writes to the phreeqc.out file. This is the output that is normally generated when phreeqc is run. The initial setting is false.

Parameters:
bValueIf true, writes output to the output file; if false, no output is written to the output file.
See also:
GetOutputFileOn
void IPhreeqc::SetSelectedOutputFileOn ( bool  bValue)

Sets the selected-output file switch on or off. This switch controls whether or not phreeqc writes output to the SELECTED_OUTPUT (selected.out if unspecified) file. The initial setting is false.

Parameters:
bValueIf true, writes output to the selected-output file; if false, no output is written to the selected-output file.
See also:
GetSelectedOutputColumnCount, GetSelectedOutputFileOn, GetSelectedOutputRowCount, GetSelectedOutputValue

The documentation for this class was generated from the following file: