mirror of
https://git.gfz-potsdam.de/naaice/iphreeqc.git
synced 2025-12-15 16:18:22 +01:00
Added TestRunString to cunit
git-svn-id: svn://136.177.114.72/svn_GW/IPhreeqc/branches/class@4211 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
parent
68534b0934
commit
e102b97e84
@ -2045,11 +2045,11 @@
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\IPhreeqc.hpp"
|
||||
RelativePath=".\include\IPhreeqc.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\IPhreeqc2.h"
|
||||
RelativePath=".\include\IPhreeqc2.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
|
||||
@ -24,58 +24,524 @@ class IPhreeqc2;
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Appends the given error message and increments the error count.
|
||||
* Internally used to create an error condition.
|
||||
* @internal
|
||||
*/
|
||||
int AddErrorM(int id, const char* error_msg);
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* @internal
|
||||
*/
|
||||
// TODO void ClearErrors(void);
|
||||
|
||||
|
||||
int CreateIPhreeqc(void);
|
||||
|
||||
IPL_RESULT DestroyIPhreeqc(int id);
|
||||
|
||||
/**
|
||||
* Load the specified database file into phreeqc.
|
||||
* @param filename The name of the phreeqc database to load.
|
||||
* The full path will be required if the file is not
|
||||
* in the current working directory.
|
||||
* @return The number of errors encountered.
|
||||
* @remarks
|
||||
* Any previous database definitions are cleared.
|
||||
* @par Fortran90 Interface:
|
||||
* @htmlonly
|
||||
* <CODE>
|
||||
* <PRE>
|
||||
* FUNCTION LoadDatabase(FILENAME)
|
||||
* CHARACTER(LEN=*), INTENT(IN) :: FILENAME
|
||||
* INTEGER :: LoadDatabase
|
||||
* END FUNCTION LoadDatabase
|
||||
* </PRE>
|
||||
* </CODE>
|
||||
* @endhtmlonly
|
||||
*/
|
||||
int LoadDatabaseM(int id, const char* filename);
|
||||
|
||||
/**
|
||||
* Load the specified string as a database into phreeqc.
|
||||
* @param input String containing data to be used as the phreeqc database.
|
||||
* @return The number of errors encountered.
|
||||
* @remarks
|
||||
* Any previous database definitions are cleared.
|
||||
* @par Fortran90 Interface:
|
||||
* @htmlonly
|
||||
* <CODE>
|
||||
* <PRE>
|
||||
* FUNCTION LoadDatabaseString(INPUT)
|
||||
* CHARACTER(LEN=*), INTENT(IN) :: INPUT
|
||||
* INTEGER :: LoadDatabaseString
|
||||
* END FUNCTION LoadDatabaseString
|
||||
* </PRE>
|
||||
* </CODE>
|
||||
* @endhtmlonly
|
||||
*/
|
||||
int LoadDatabaseStringM(int id, const char* input);
|
||||
|
||||
/**
|
||||
* Unload any database currently loaded into phreeqc.
|
||||
* @remarks
|
||||
* Any previous database definitions are cleared.
|
||||
*/
|
||||
int UnLoadDatabaseM(int id);
|
||||
|
||||
/**
|
||||
* Output the error messages normally stored in the phreeqc.err file to stdout.
|
||||
* @par Fortran90 Interface:
|
||||
* @htmlonly
|
||||
* <CODE>
|
||||
* <PRE>
|
||||
* SUBROUTINE OutputLastError
|
||||
* END SUBROUTINE OutputLastError
|
||||
* </PRE>
|
||||
* </CODE>
|
||||
* @endhtmlonly
|
||||
*/
|
||||
// TODO void OutputLastError(void);
|
||||
|
||||
const char* GetLastErrorStringM(int id);
|
||||
|
||||
// TODO const char* GetLastWarningString(void);
|
||||
|
||||
|
||||
const char* GetDumpStringM(int id);
|
||||
|
||||
int GetDumpLineCountM(int id);
|
||||
|
||||
const char* GetDumpLineM(int id, int n);
|
||||
|
||||
/**
|
||||
* Accumlulate lines for input to phreeqc.
|
||||
* @param line The line(s) to add for input to phreeqc.
|
||||
* @retval VR_OK Success
|
||||
* @retval VR_OUTOFMEMORY Out of memory
|
||||
* @par Fortran90 Interface:
|
||||
* @htmlonly
|
||||
* <CODE>
|
||||
* <PRE>
|
||||
* FUNCTION AccumulateLine(LINE)
|
||||
* CHARACTER(LEN=*), INTENT(IN) :: LINE
|
||||
* INTEGER :: AccumulateLine
|
||||
* END FUNCTION AccumulateLine
|
||||
* </PRE>
|
||||
* </CODE>
|
||||
* @endhtmlonly
|
||||
*/
|
||||
IPL_RESULT AccumulateLineM(int id, const char *line);
|
||||
|
||||
/**
|
||||
* Sets the selected_output flag on or off
|
||||
* @param selected_output_on If non-zero turns on output to the <B>SELECTED_OUTPUT</B> (<B>selected.out</B> if unspecified) file.
|
||||
* @par Fortran90 Interface:
|
||||
* @htmlonly
|
||||
* <CODE>
|
||||
* <PRE>
|
||||
* SUBROUTINE SetSelectedOutputOn(SELECTED_ON)
|
||||
* LOGICAL, INTENT(IN) :: SELECTED_ON
|
||||
* END SUBROUTINE SetSelectedOutputOn
|
||||
* </PRE>
|
||||
* </CODE>
|
||||
* @endhtmlonly
|
||||
*/
|
||||
int GetSelectedOutputOnM(int id);
|
||||
IPL_RESULT SetSelectedOutputOnM(int id, int value);
|
||||
|
||||
/**
|
||||
* Sets the output flag on or off
|
||||
* @param output_on If non-zero turns on output to the <B>phreeqc.out</B> file.
|
||||
* @par Fortran90 Interface:
|
||||
* @htmlonly
|
||||
* <CODE>
|
||||
* <PRE>
|
||||
* SUBROUTINE SetOutputOn(OUTPUT_ON)
|
||||
* LOGICAL, INTENT(IN) :: OUTPUT_ON
|
||||
* END SUBROUTINE SetOutputOn
|
||||
* </PRE>
|
||||
* </CODE>
|
||||
* @endhtmlonly
|
||||
*/
|
||||
int GetOutputOnM(int id);
|
||||
IPL_RESULT SetOutputOnM(int id, int value);
|
||||
|
||||
/**
|
||||
* Sets the error flag on or off
|
||||
* @param error_on If non-zero turns on output to the <B>phreeqc.err</B> file.
|
||||
* @par Fortran90 Interface:
|
||||
* @htmlonly
|
||||
* <CODE>
|
||||
* <PRE>
|
||||
* SUBROUTINE SetErrorOn(ERROR_ON)
|
||||
* LOGICAL, INTENT(IN) :: ERROR_ON
|
||||
* END SUBROUTINE SetOutputOn
|
||||
* </PRE>
|
||||
* </CODE>
|
||||
* @endhtmlonly
|
||||
*/
|
||||
int GetErrorOnM(int id);
|
||||
IPL_RESULT SetErrorOnM(int id, int value);
|
||||
|
||||
/**
|
||||
* Sets the log flag on or off
|
||||
* @param log_on If non-zero turns on output to the <B>phreeqc.log</B> file.
|
||||
* @par Fortran90 Interface:
|
||||
* @htmlonly
|
||||
* <CODE>
|
||||
* <PRE>
|
||||
* SUBROUTINE SetLogOn(LOG_ON)
|
||||
* LOGICAL, INTENT(IN) :: LOG_ON
|
||||
* END SUBROUTINE SetLogOn
|
||||
* </PRE>
|
||||
* </CODE>
|
||||
* @endhtmlonly
|
||||
*/
|
||||
int GetLogOnM(int id);
|
||||
IPL_RESULT SetLogOnM(int id, int value);
|
||||
|
||||
/**
|
||||
* Sets the dump flag on or off
|
||||
* @param dump_on If non-zero turns on output to the <B>DUMP</B> (<B>dump.out</B> if unspecified) file.
|
||||
* @par Fortran90 Interface:
|
||||
* @htmlonly
|
||||
* <CODE>
|
||||
* <PRE>
|
||||
* SUBROUTINE SetDumpOn(DUMP_ON)
|
||||
* LOGICAL, INTENT(IN) :: DUMP_ON
|
||||
* END SUBROUTINE SetDumpOn
|
||||
* </PRE>
|
||||
* </CODE>
|
||||
* @endhtmlonly
|
||||
*/
|
||||
int GetDumpOnM(int id);
|
||||
IPL_RESULT SetDumpOnM(int id, int value);
|
||||
|
||||
/**
|
||||
* Sets the dump string flag on or off
|
||||
* @param dump_string_on If non-zero captures as a string the output defined by the <B>DUMP</B> keyword.
|
||||
* @par Fortran90 Interface:
|
||||
* @htmlonly
|
||||
* <CODE>
|
||||
* <PRE>
|
||||
* SUBROUTINE SetDumpStringOn(DUMP_STRING_ON)
|
||||
* LOGICAL, INTENT(IN) :: DUMP_STRING_ON
|
||||
* END SUBROUTINE SetDumpStringOn
|
||||
* </PRE>
|
||||
* </CODE>
|
||||
* @endhtmlonly
|
||||
*/
|
||||
int GetDumpStringOnM(int id);
|
||||
IPL_RESULT SetDumpStringOnM(int id, int value);
|
||||
|
||||
/**
|
||||
* Runs the accumulated input sent to AccumulateLine.
|
||||
* @return The number of errors encountered.
|
||||
* @remarks
|
||||
* The accumulated input is cleared upon completion.
|
||||
* @pre LoadDatabase/LoadDatabaseString must have been called and returned 0 (zero) errors.
|
||||
* @par Fortran90 Interface:
|
||||
* @htmlonly
|
||||
* <CODE>
|
||||
* <PRE>
|
||||
* FUNCTION RunAccumulated()
|
||||
* INTEGER :: RunAccumulated
|
||||
* END FUNCTION RunAccumulated
|
||||
* </PRE>
|
||||
* </CODE>
|
||||
* @endhtmlonly
|
||||
*/
|
||||
int RunAccumulatedM(int id);
|
||||
|
||||
/**
|
||||
* Runs the specified phreeqc input file.
|
||||
* @param filename The name of the phreeqc input file to run.
|
||||
* @return The number of errors encountered during the run.
|
||||
* @pre LoadDatabase/LoadDatabaseString must have been called and returned 0 (zero) errors.
|
||||
* @par Fortran90 Interface:
|
||||
* @htmlonly
|
||||
* <CODE>
|
||||
* <PRE>
|
||||
* FUNCTION RunFile(FILENAME)
|
||||
* CHARACTER(LEN=*) :: FILENAME
|
||||
* INTEGER :: RunFile
|
||||
* END FUNCTION RunFile
|
||||
* </PRE>
|
||||
* </CODE>
|
||||
* @endhtmlonly
|
||||
*/
|
||||
int RunFileM(int id, const char* filename);
|
||||
|
||||
/**
|
||||
* Runs the specified string as input to phreeqc.
|
||||
* @param input String containing phreeqc input.
|
||||
* @return The number of errors encountered during the run.
|
||||
* @pre LoadDatabase/LoadDatabaseString must have been called and returned 0 (zero) errors.
|
||||
* @par Fortran90 Interface:
|
||||
* @htmlonly
|
||||
* <CODE>
|
||||
* <PRE>
|
||||
* FUNCTION RunString(INPUT)
|
||||
* CHARACTER(LEN=*) :: INPUT
|
||||
* INTEGER :: RunString
|
||||
* END FUNCTION RunString
|
||||
* </PRE>
|
||||
* </CODE>
|
||||
* @endhtmlonly
|
||||
*/
|
||||
int RunStringM(int id, const char* input);
|
||||
|
||||
/**
|
||||
* Returns the number of rows currently contained within selected_output.
|
||||
* @par Fortran90 Interface:
|
||||
* @htmlonly
|
||||
* <CODE>
|
||||
* <PRE>
|
||||
* FUNCTION GetSelectedOutputRowCount
|
||||
* INTEGER :: GetSelectedOutputRowCount
|
||||
* END FUNCTION GetSelectedOutputRowCount
|
||||
* </PRE>
|
||||
* </CODE>
|
||||
* @endhtmlonly
|
||||
*/
|
||||
int GetSelectedOutputRowCountM(int id);
|
||||
|
||||
/**
|
||||
* Returns the number of columns currently contained within selected_output.
|
||||
* @par Fortran90 Interface:
|
||||
* @htmlonly
|
||||
* <CODE>
|
||||
* <PRE>
|
||||
* FUNCTION GetSelectedOutputColumnCount
|
||||
* INTEGER :: GetSelectedOutputColumnCount
|
||||
* END FUNCTION GetSelectedOutputColumnCount
|
||||
* </PRE>
|
||||
* </CODE>
|
||||
* @endhtmlonly
|
||||
*/
|
||||
int GetSelectedOutputColumnCountM(int id);
|
||||
|
||||
/**
|
||||
* Returns the \c VAR associated with the specified row and column.
|
||||
* @param row The row index.
|
||||
* @param col The column index.
|
||||
* @param pVAR Pointer to the \c VAR to recieve the requested data.
|
||||
* @retval VR_OK Success
|
||||
* @retval VR_INVALIDROW The given row is out of range.
|
||||
* @retval VR_INVALIDCOL The given column is out of range.
|
||||
* @retval VR_OUTOFMEMORY Memory could not be allocated.
|
||||
* @remarks
|
||||
* Row 0 contains the column headings to the selected_ouput.
|
||||
* @par Examples:
|
||||
* The headings will include a suffix and/or prefix in order to differentiate the
|
||||
* columns.
|
||||
* @htmlonly
|
||||
<p>
|
||||
<table border=1>
|
||||
|
||||
<TR VALIGN="top">
|
||||
<TH width=65%>
|
||||
Input
|
||||
</TH>
|
||||
<TH width=35%>
|
||||
Headings
|
||||
</TH>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN="top">
|
||||
<TD width=65%>
|
||||
<CODE><PRE>
|
||||
SELECTED_OUTPUT
|
||||
-reset false
|
||||
-totals Ca Na
|
||||
</PRE></CODE>
|
||||
</TD>
|
||||
<TD width=35%>
|
||||
<CODE><PRE>
|
||||
Ca(mol/kgw) Na(mol/kgw)
|
||||
</PRE></CODE>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN="top">
|
||||
<TD width=65%>
|
||||
<CODE><PRE>
|
||||
SELECTED_OUTPUT
|
||||
-reset false
|
||||
-molalities Fe+2 Hfo_sOZn+
|
||||
</PRE></CODE>
|
||||
</TD>
|
||||
<TD width=35%>
|
||||
<CODE><PRE>
|
||||
m_Fe+2(mol/kgw) m_Hfo_sOZn+(mol/kgw)
|
||||
</PRE></CODE>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN="top">
|
||||
<TD width=65%>
|
||||
<CODE><PRE>
|
||||
SELECTED_OUTPUT
|
||||
-reset false
|
||||
-activities H+ Ca+2
|
||||
</PRE></CODE>
|
||||
</TD>
|
||||
<TD width=35%>
|
||||
<CODE><PRE>
|
||||
la_H+ la_Ca+2
|
||||
</PRE></CODE>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN="top">
|
||||
<TD width=65%>
|
||||
<CODE><PRE>
|
||||
SELECTED_OUTPUT
|
||||
-reset false
|
||||
-equilibrium_phases Calcite Dolomite
|
||||
</PRE></CODE>
|
||||
</TD>
|
||||
<TD width=35%>
|
||||
<CODE><PRE>
|
||||
Calcite d_Calcite Dolomite d_Dolomite
|
||||
</PRE></CODE>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN="top">
|
||||
<TD width=65%>
|
||||
<CODE><PRE>
|
||||
SELECTED_OUTPUT
|
||||
-reset false
|
||||
-saturation_indices CO2(g) Siderite
|
||||
</PRE></CODE>
|
||||
</TD>
|
||||
<TD width=35%>
|
||||
<CODE><PRE>
|
||||
si_CO2(g) si_Siderite
|
||||
</PRE></CODE>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN="top">
|
||||
<TD width=65%>
|
||||
<CODE><PRE>
|
||||
SELECTED_OUTPUT
|
||||
-reset false
|
||||
-gases CO2(g) N2(g)
|
||||
</PRE></CODE>
|
||||
</TD>
|
||||
<TD width=35%>
|
||||
<CODE><PRE>
|
||||
pressure "total mol" volume g_CO2(g) g_N2(g)
|
||||
</PRE></CODE>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN="top">
|
||||
<TD width=65%>
|
||||
<CODE><PRE>
|
||||
SELECTED_OUTPUT
|
||||
-reset false
|
||||
-kinetic_reactants CH2O Pyrite
|
||||
</PRE></CODE>
|
||||
</TD>
|
||||
<TD width=35%>
|
||||
<CODE><PRE>
|
||||
k_CH2O dk_CH2O k_Pyrite dk_Pyrite
|
||||
</PRE></CODE>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN="top">
|
||||
<TD width=65%>
|
||||
<CODE><PRE>
|
||||
SELECTED_OUTPUT
|
||||
-reset false
|
||||
-solid_solutions CaSO4 SrSO4
|
||||
</PRE></CODE>
|
||||
</TD>
|
||||
<TD width=35%>
|
||||
<CODE><PRE>
|
||||
s_CaSO4 s_SrSO4
|
||||
</PRE></CODE>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
</table>
|
||||
* @endhtmlonly
|
||||
* @par Fortran90 Interface:
|
||||
* @htmlonly
|
||||
* <CODE>
|
||||
* <PRE>
|
||||
* FUNCTION GetSelectedOutputValue(ROW,COL,VTYPE,DVALUE,SVALUE)
|
||||
* INTEGER, INTENT(IN) :: ROW
|
||||
* INTEGER, INTENT(IN) :: COL
|
||||
* INTEGER, INTENT(OUT) :: VTYPE
|
||||
* REAL*8, INTENT(OUT) :: DVALUE
|
||||
* CHARACTER(LEN=*), INTENT(OUT) :: SVALUE
|
||||
* INTEGER :: GetSelectedOutputValue
|
||||
* END FUNCTION GetSelectedOutputValue
|
||||
* </PRE>
|
||||
* </CODE>
|
||||
* @endhtmlonly
|
||||
*/
|
||||
IPL_RESULT GetSelectedOutputValueM(int id, int row, int col, VAR* pVAR);
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* @par Fortran90 Interface:
|
||||
* @htmlonly
|
||||
* <CODE>
|
||||
* <PRE>
|
||||
* FUNCTION GetErrorLineCount
|
||||
* INTEGER :: GetErrorLineCount
|
||||
* END FUNCTION GetErrorLineCount
|
||||
* </PRE>
|
||||
* </CODE>
|
||||
* @endhtmlonly
|
||||
*/
|
||||
int GetComponentCountM(int id);
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* @par Fortran90 Interface:
|
||||
* @htmlonly
|
||||
* <CODE>
|
||||
* <PRE>
|
||||
* FUNCTION GetErrorLineCount
|
||||
* INTEGER :: GetErrorLineCount
|
||||
* END FUNCTION GetErrorLineCount
|
||||
* </PRE>
|
||||
* </CODE>
|
||||
* @endhtmlonly
|
||||
*/
|
||||
const char* GetComponentM(int id, int n);
|
||||
|
||||
/**
|
||||
* Send the accumulated input to stdout.
|
||||
* This is the input that will be used for the next call to RunAccumulated.
|
||||
* @par Fortran90 Interface:
|
||||
* @htmlonly
|
||||
* <CODE>
|
||||
* <PRE>
|
||||
* SUBROUTINE OutputLines
|
||||
* END SUBROUTINE OutputLines
|
||||
* </PRE>
|
||||
* </CODE>
|
||||
* @endhtmlonly
|
||||
*/
|
||||
// TODO void OutputLines(void);
|
||||
|
||||
// TODO int RunWithCallback(PFN_PRERUN_CALLBACK pfn_pre, PFN_POSTRUN_CALLBACK pfn_post, void *cookie, int output_on, int error_on, int log_on, int selected_output_on);
|
||||
|
||||
// TODO int CatchErrors(PFN_CATCH_CALLBACK pfn, void *cookie);
|
||||
|
||||
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
||||
@ -10,15 +10,15 @@ CreateIPhreeqc(void)
|
||||
}
|
||||
|
||||
IPL_RESULT
|
||||
DestroyIPhreeqc(int n)
|
||||
DestroyIPhreeqc(int id)
|
||||
{
|
||||
return IPhreeqcLib::DestroyIPhreeqc(n);
|
||||
return IPhreeqcLib::DestroyIPhreeqc(id);
|
||||
}
|
||||
|
||||
int
|
||||
LoadDatabaseM(int n, const char* filename)
|
||||
LoadDatabaseM(int id, const char* filename)
|
||||
{
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(n);
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
|
||||
if (IPhreeqcPtr)
|
||||
{
|
||||
return IPhreeqcPtr->LoadDatabase(filename);
|
||||
@ -27,9 +27,9 @@ LoadDatabaseM(int n, const char* filename)
|
||||
}
|
||||
|
||||
int
|
||||
LoadDatabaseStringM(int n, const char* input)
|
||||
LoadDatabaseStringM(int id, const char* input)
|
||||
{
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(n);
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
|
||||
if (IPhreeqcPtr)
|
||||
{
|
||||
return IPhreeqcPtr->LoadDatabaseString(input);
|
||||
@ -38,9 +38,9 @@ LoadDatabaseStringM(int n, const char* input)
|
||||
}
|
||||
|
||||
int
|
||||
UnLoadDatabaseM(int n)
|
||||
UnLoadDatabaseM(int id)
|
||||
{
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(n);
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
|
||||
if (IPhreeqcPtr)
|
||||
{
|
||||
IPhreeqcPtr->UnLoadDatabase();
|
||||
@ -50,10 +50,10 @@ UnLoadDatabaseM(int n)
|
||||
}
|
||||
|
||||
const char*
|
||||
GetLastErrorStringM(int n)
|
||||
GetLastErrorStringM(int id)
|
||||
{
|
||||
static const char err_msg[] = "GetLastErrorString: Bad instance.\n";
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(n);
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
|
||||
if (IPhreeqcPtr)
|
||||
{
|
||||
return IPhreeqcPtr->GetLastErrorString();
|
||||
@ -62,10 +62,10 @@ GetLastErrorStringM(int n)
|
||||
}
|
||||
|
||||
const char*
|
||||
GetDumpStringM(int n)
|
||||
GetDumpStringM(int id)
|
||||
{
|
||||
static const char empty[] = "";
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(n);
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
|
||||
if (IPhreeqcPtr)
|
||||
{
|
||||
return IPhreeqcPtr->GetDumpString();
|
||||
@ -74,9 +74,9 @@ GetDumpStringM(int n)
|
||||
}
|
||||
|
||||
int
|
||||
GetDumpLineCountM(int n)
|
||||
GetDumpLineCountM(int id)
|
||||
{
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(n);
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
|
||||
if (IPhreeqcPtr)
|
||||
{
|
||||
return IPhreeqcPtr->GetDumpLineCount();
|
||||
@ -134,9 +134,9 @@ GetComponentM(int id, int n)
|
||||
}
|
||||
|
||||
IPL_RESULT
|
||||
AccumulateLineM(int n, const char *line)
|
||||
AccumulateLineM(int id, const char *line)
|
||||
{
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(n);
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
|
||||
if (IPhreeqcPtr)
|
||||
{
|
||||
switch (IPhreeqcPtr->AccumulateLine(line))
|
||||
@ -153,9 +153,9 @@ AccumulateLineM(int n, const char *line)
|
||||
}
|
||||
|
||||
int
|
||||
GetSelectedOutputOnM(int n)
|
||||
GetSelectedOutputOnM(int id)
|
||||
{
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(n);
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
|
||||
if (IPhreeqcPtr)
|
||||
{
|
||||
if (IPhreeqcPtr->GetSelectedOutputOn())
|
||||
@ -171,9 +171,9 @@ GetSelectedOutputOnM(int n)
|
||||
}
|
||||
|
||||
IPL_RESULT
|
||||
SetSelectedOutputOnM(int n, int value)
|
||||
SetSelectedOutputOnM(int id, int value)
|
||||
{
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(n);
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
|
||||
if (IPhreeqcPtr)
|
||||
{
|
||||
IPhreeqcPtr->SetSelectedOutputOn(value != 0);
|
||||
@ -183,9 +183,9 @@ SetSelectedOutputOnM(int n, int value)
|
||||
}
|
||||
|
||||
int
|
||||
GetOutputOnM(int n)
|
||||
GetOutputOnM(int id)
|
||||
{
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(n);
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
|
||||
if (IPhreeqcPtr)
|
||||
{
|
||||
if (IPhreeqcPtr->GetOutputOn())
|
||||
@ -201,9 +201,9 @@ GetOutputOnM(int n)
|
||||
}
|
||||
|
||||
IPL_RESULT
|
||||
SetOutputOnM(int n, int value)
|
||||
SetOutputOnM(int id, int value)
|
||||
{
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(n);
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
|
||||
if (IPhreeqcPtr)
|
||||
{
|
||||
IPhreeqcPtr->SetOutputOn(value != 0);
|
||||
@ -213,9 +213,9 @@ SetOutputOnM(int n, int value)
|
||||
}
|
||||
|
||||
int
|
||||
GetErrorOnM(int n)
|
||||
GetErrorOnM(int id)
|
||||
{
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(n);
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
|
||||
if (IPhreeqcPtr)
|
||||
{
|
||||
if (IPhreeqcPtr->GetErrorOn())
|
||||
@ -231,9 +231,9 @@ GetErrorOnM(int n)
|
||||
}
|
||||
|
||||
IPL_RESULT
|
||||
SetErrorOnM(int n, int value)
|
||||
SetErrorOnM(int id, int value)
|
||||
{
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(n);
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
|
||||
if (IPhreeqcPtr)
|
||||
{
|
||||
IPhreeqcPtr->SetErrorOn(value != 0);
|
||||
@ -243,9 +243,9 @@ SetErrorOnM(int n, int value)
|
||||
}
|
||||
|
||||
int
|
||||
GetLogOnM(int n)
|
||||
GetLogOnM(int id)
|
||||
{
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(n);
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
|
||||
if (IPhreeqcPtr)
|
||||
{
|
||||
if (IPhreeqcPtr->GetLogOn())
|
||||
@ -261,9 +261,9 @@ GetLogOnM(int n)
|
||||
}
|
||||
|
||||
IPL_RESULT
|
||||
SetLogOnM(int n, int value)
|
||||
SetLogOnM(int id, int value)
|
||||
{
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(n);
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
|
||||
if (IPhreeqcPtr)
|
||||
{
|
||||
IPhreeqcPtr->SetLogOn(value != 0);
|
||||
@ -274,9 +274,9 @@ SetLogOnM(int n, int value)
|
||||
|
||||
|
||||
int
|
||||
GetDumpOnM(int n)
|
||||
GetDumpOnM(int id)
|
||||
{
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(n);
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
|
||||
if (IPhreeqcPtr)
|
||||
{
|
||||
if (IPhreeqcPtr->GetDumpOn())
|
||||
@ -292,9 +292,9 @@ GetDumpOnM(int n)
|
||||
}
|
||||
|
||||
IPL_RESULT
|
||||
SetDumpOnM(int n, int value)
|
||||
SetDumpOnM(int id, int value)
|
||||
{
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(n);
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
|
||||
if (IPhreeqcPtr)
|
||||
{
|
||||
IPhreeqcPtr->SetDumpOn(value != 0);
|
||||
@ -304,9 +304,9 @@ SetDumpOnM(int n, int value)
|
||||
}
|
||||
|
||||
int
|
||||
GetDumpStringOnM(int n)
|
||||
GetDumpStringOnM(int id)
|
||||
{
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(n);
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
|
||||
if (IPhreeqcPtr)
|
||||
{
|
||||
if (IPhreeqcPtr->GetDumpStringOn())
|
||||
@ -322,9 +322,9 @@ GetDumpStringOnM(int n)
|
||||
}
|
||||
|
||||
IPL_RESULT
|
||||
SetDumpStringOnM(int n, int value)
|
||||
SetDumpStringOnM(int id, int value)
|
||||
{
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(n);
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
|
||||
if (IPhreeqcPtr)
|
||||
{
|
||||
IPhreeqcPtr->SetDumpStringOn(value != 0);
|
||||
@ -334,9 +334,9 @@ SetDumpStringOnM(int n, int value)
|
||||
}
|
||||
|
||||
int
|
||||
RunAccumulatedM(int n)
|
||||
RunAccumulatedM(int id)
|
||||
{
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(n);
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
|
||||
if (IPhreeqcPtr)
|
||||
{
|
||||
return IPhreeqcPtr->RunAccumulated();
|
||||
@ -345,9 +345,9 @@ RunAccumulatedM(int n)
|
||||
}
|
||||
|
||||
int
|
||||
RunFileM(int n, const char* filename)
|
||||
RunFileM(int id, const char* filename)
|
||||
{
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(n);
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
|
||||
if (IPhreeqcPtr)
|
||||
{
|
||||
return IPhreeqcPtr->RunFile(filename);
|
||||
@ -356,9 +356,20 @@ RunFileM(int n, const char* filename)
|
||||
}
|
||||
|
||||
int
|
||||
GetSelectedOutputRowCountM(int n)
|
||||
RunStringM(int id, const char* input)
|
||||
{
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(n);
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
|
||||
if (IPhreeqcPtr)
|
||||
{
|
||||
return IPhreeqcPtr->RunString(input);
|
||||
}
|
||||
return IPL_BADINSTANCE;
|
||||
}
|
||||
|
||||
int
|
||||
GetSelectedOutputRowCountM(int id)
|
||||
{
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
|
||||
if (IPhreeqcPtr)
|
||||
{
|
||||
return IPhreeqcPtr->GetSelectedOutputRowCount();
|
||||
@ -367,9 +378,9 @@ GetSelectedOutputRowCountM(int n)
|
||||
}
|
||||
|
||||
int
|
||||
GetSelectedOutputColumnCountM(int n)
|
||||
GetSelectedOutputColumnCountM(int id)
|
||||
{
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(n);
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
|
||||
if (IPhreeqcPtr)
|
||||
{
|
||||
return IPhreeqcPtr->GetSelectedOutputColumnCount();
|
||||
@ -379,9 +390,9 @@ GetSelectedOutputColumnCountM(int n)
|
||||
|
||||
|
||||
IPL_RESULT
|
||||
GetSelectedOutputValueM(int n, int row, int col, VAR* pVAR)
|
||||
GetSelectedOutputValueM(int id, int row, int col, VAR* pVAR)
|
||||
{
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(n);
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
|
||||
if (IPhreeqcPtr)
|
||||
{
|
||||
switch(IPhreeqcPtr->GetSelectedOutputValue(row, col, pVAR))
|
||||
@ -400,9 +411,9 @@ GetSelectedOutputValueM(int n, int row, int col, VAR* pVAR)
|
||||
}
|
||||
|
||||
int
|
||||
AddErrorM(int n, const char* error_msg)
|
||||
AddErrorM(int id, const char* error_msg)
|
||||
{
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(n);
|
||||
IPhreeqc2* IPhreeqcPtr = IPhreeqcLib::GetInstance(id);
|
||||
if (IPhreeqcPtr)
|
||||
{
|
||||
return (int)IPhreeqcPtr->AddError(error_msg);
|
||||
@ -439,12 +450,12 @@ IPhreeqcLib::CreateIPhreeqc(void)
|
||||
}
|
||||
|
||||
IPL_RESULT
|
||||
IPhreeqcLib::DestroyIPhreeqc(int n)
|
||||
IPhreeqcLib::DestroyIPhreeqc(int id)
|
||||
{
|
||||
IPL_RESULT retval = IPL_BADINSTANCE;
|
||||
if (n >= 0)
|
||||
if (id >= 0)
|
||||
{
|
||||
std::map<size_t, IPhreeqc2*>::iterator it = IPhreeqcLib::Instances.find(size_t(n));
|
||||
std::map<size_t, IPhreeqc2*>::iterator it = IPhreeqcLib::Instances.find(size_t(id));
|
||||
if (it != IPhreeqcLib::Instances.end())
|
||||
{
|
||||
delete (*it).second;
|
||||
@ -456,9 +467,9 @@ IPhreeqcLib::DestroyIPhreeqc(int n)
|
||||
}
|
||||
|
||||
IPhreeqc2*
|
||||
IPhreeqcLib::GetInstance(int n)
|
||||
IPhreeqcLib::GetInstance(int id)
|
||||
{
|
||||
std::map<size_t, IPhreeqc2*>::iterator it = IPhreeqcLib::Instances.find(size_t(n));
|
||||
std::map<size_t, IPhreeqc2*>::iterator it = IPhreeqcLib::Instances.find(size_t(id));
|
||||
if (it != IPhreeqcLib::Instances.end())
|
||||
{
|
||||
return (*it).second;
|
||||
|
||||
@ -275,6 +275,103 @@ void TestIPhreeqc::TestRunFile(void)
|
||||
CPPUNIT_ASSERT(::DeleteFile(dump_file));
|
||||
}
|
||||
|
||||
void TestIPhreeqc::TestRunString(void)
|
||||
{
|
||||
const char input[] =
|
||||
"TITLE Example 1.--Add uranium and speciate seawater.\n"
|
||||
"SOLUTION 1 SEAWATER FROM NORDSTROM ET AL. (1979)\n"
|
||||
" units ppm\n"
|
||||
" pH 8.22\n"
|
||||
" pe 8.451\n"
|
||||
" density 1.023\n"
|
||||
" temp 25.0\n"
|
||||
" redox O(0)/O(-2)\n"
|
||||
" Ca 412.3\n"
|
||||
" Mg 1291.8\n"
|
||||
" Na 10768.0\n"
|
||||
" K 399.1\n"
|
||||
" Fe 0.002\n"
|
||||
" Mn 0.0002 pe\n"
|
||||
" Si 4.28\n"
|
||||
" Cl 19353.0\n"
|
||||
" Alkalinity 141.682 as HCO3\n"
|
||||
" S(6) 2712.0\n"
|
||||
" N(5) 0.29 gfw 62.0\n"
|
||||
" N(-3) 0.03 as NH4\n"
|
||||
" U 3.3 ppb N(5)/N(-3)\n"
|
||||
" O(0) 1.0 O2(g) -0.7\n"
|
||||
"SOLUTION_MASTER_SPECIES\n"
|
||||
" U U+4 0.0 238.0290 238.0290\n"
|
||||
" U(4) U+4 0.0 238.0290\n"
|
||||
" U(5) UO2+ 0.0 238.0290\n"
|
||||
" U(6) UO2+2 0.0 238.0290\n"
|
||||
"SOLUTION_SPECIES\n"
|
||||
" #primary master species for U\n"
|
||||
" #is also secondary master species for U(4)\n"
|
||||
" U+4 = U+4\n"
|
||||
" log_k 0.0\n"
|
||||
" U+4 + 4 H2O = U(OH)4 + 4 H+\n"
|
||||
" log_k -8.538\n"
|
||||
" delta_h 24.760 kcal\n"
|
||||
" U+4 + 5 H2O = U(OH)5- + 5 H+\n"
|
||||
" log_k -13.147\n"
|
||||
" delta_h 27.580 kcal\n"
|
||||
" #secondary master species for U(5)\n"
|
||||
" U+4 + 2 H2O = UO2+ + 4 H+ + e-\n"
|
||||
" log_k -6.432\n"
|
||||
" delta_h 31.130 kcal\n"
|
||||
" #secondary master species for U(6)\n"
|
||||
" U+4 + 2 H2O = UO2+2 + 4 H+ + 2 e-\n"
|
||||
" log_k -9.217\n"
|
||||
" delta_h 34.430 kcal\n"
|
||||
" UO2+2 + H2O = UO2OH+ + H+\n"
|
||||
" log_k -5.782\n"
|
||||
" delta_h 11.015 kcal\n"
|
||||
" 2UO2+2 + 2H2O = (UO2)2(OH)2+2 + 2H+\n"
|
||||
" log_k -5.626\n"
|
||||
" delta_h -36.04 kcal\n"
|
||||
" 3UO2+2 + 5H2O = (UO2)3(OH)5+ + 5H+\n"
|
||||
" log_k -15.641\n"
|
||||
" delta_h -44.27 kcal\n"
|
||||
" UO2+2 + CO3-2 = UO2CO3\n"
|
||||
" log_k 10.064\n"
|
||||
" delta_h 0.84 kcal\n"
|
||||
" UO2+2 + 2CO3-2 = UO2(CO3)2-2\n"
|
||||
" log_k 16.977\n"
|
||||
" delta_h 3.48 kcal\n"
|
||||
" UO2+2 + 3CO3-2 = UO2(CO3)3-4\n"
|
||||
" log_k 21.397\n"
|
||||
" delta_h -8.78 kcal\n"
|
||||
"PHASES\n"
|
||||
" Uraninite\n"
|
||||
" UO2 + 4 H+ = U+4 + 2 H2O\n"
|
||||
" log_k -3.490\n"
|
||||
" delta_h -18.630 kcal\n"
|
||||
"END\n"
|
||||
"\n";
|
||||
|
||||
IPhreeqc2 obj;
|
||||
|
||||
if (::FileExists("phreeqc.out"))
|
||||
{
|
||||
CPPUNIT_ASSERT(::DeleteFile("phreeqc.out"));
|
||||
}
|
||||
CPPUNIT_ASSERT_EQUAL(false, ::FileExists("phreeqc.out"));
|
||||
CPPUNIT_ASSERT_EQUAL(0, obj.LoadDatabase("phreeqc.dat"));
|
||||
obj.SetOutputOn(1);
|
||||
obj.SetErrorOn(0);
|
||||
obj.SetLogOn(0);
|
||||
obj.SetSelectedOutputOn(0);
|
||||
obj.SetDumpOn(0);
|
||||
CPPUNIT_ASSERT_EQUAL(false, ::FileExists("phreeqc.out"));
|
||||
CPPUNIT_ASSERT_EQUAL(0, obj.RunString(input));
|
||||
CPPUNIT_ASSERT_EQUAL(true, ::FileExists("phreeqc.out"));
|
||||
if (::FileExists("phreeqc.out"))
|
||||
{
|
||||
CPPUNIT_ASSERT(::DeleteFile("phreeqc.out"));
|
||||
}
|
||||
}
|
||||
|
||||
void TestIPhreeqc::TestGetSelectedOutputRowCount(void)
|
||||
{
|
||||
IPhreeqc2 obj;
|
||||
|
||||
@ -14,6 +14,7 @@ class TestIPhreeqc : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST( TestRun );
|
||||
CPPUNIT_TEST( TestRunWithErrors );
|
||||
CPPUNIT_TEST( TestRunFile );
|
||||
CPPUNIT_TEST( TestRunString );
|
||||
CPPUNIT_TEST( TestGetSelectedOutputRowCount );
|
||||
CPPUNIT_TEST( TestGetSelectedOutputValue );
|
||||
CPPUNIT_TEST( TestGetSelectedOutputColumnCount );
|
||||
@ -54,6 +55,7 @@ public:
|
||||
void TestRun(void);
|
||||
void TestRunWithErrors(void);
|
||||
void TestRunFile(void);
|
||||
void TestRunString(void);
|
||||
void TestGetSelectedOutputRowCount(void);
|
||||
void TestGetSelectedOutputValue(void);
|
||||
void TestGetSelectedOutputColumnCount(void);
|
||||
|
||||
@ -344,6 +344,107 @@ void TestIPhreeqcLib::TestRunFile(void)
|
||||
CPPUNIT_ASSERT(::DeleteFile(dump_file));
|
||||
}
|
||||
|
||||
void TestIPhreeqcLib::TestRunString(void)
|
||||
{
|
||||
const char input[] =
|
||||
"TITLE Example 1.--Add uranium and speciate seawater.\n"
|
||||
"SOLUTION 1 SEAWATER FROM NORDSTROM ET AL. (1979)\n"
|
||||
" units ppm\n"
|
||||
" pH 8.22\n"
|
||||
" pe 8.451\n"
|
||||
" density 1.023\n"
|
||||
" temp 25.0\n"
|
||||
" redox O(0)/O(-2)\n"
|
||||
" Ca 412.3\n"
|
||||
" Mg 1291.8\n"
|
||||
" Na 10768.0\n"
|
||||
" K 399.1\n"
|
||||
" Fe 0.002\n"
|
||||
" Mn 0.0002 pe\n"
|
||||
" Si 4.28\n"
|
||||
" Cl 19353.0\n"
|
||||
" Alkalinity 141.682 as HCO3\n"
|
||||
" S(6) 2712.0\n"
|
||||
" N(5) 0.29 gfw 62.0\n"
|
||||
" N(-3) 0.03 as NH4\n"
|
||||
" U 3.3 ppb N(5)/N(-3)\n"
|
||||
" O(0) 1.0 O2(g) -0.7\n"
|
||||
"SOLUTION_MASTER_SPECIES\n"
|
||||
" U U+4 0.0 238.0290 238.0290\n"
|
||||
" U(4) U+4 0.0 238.0290\n"
|
||||
" U(5) UO2+ 0.0 238.0290\n"
|
||||
" U(6) UO2+2 0.0 238.0290\n"
|
||||
"SOLUTION_SPECIES\n"
|
||||
" #primary master species for U\n"
|
||||
" #is also secondary master species for U(4)\n"
|
||||
" U+4 = U+4\n"
|
||||
" log_k 0.0\n"
|
||||
" U+4 + 4 H2O = U(OH)4 + 4 H+\n"
|
||||
" log_k -8.538\n"
|
||||
" delta_h 24.760 kcal\n"
|
||||
" U+4 + 5 H2O = U(OH)5- + 5 H+\n"
|
||||
" log_k -13.147\n"
|
||||
" delta_h 27.580 kcal\n"
|
||||
" #secondary master species for U(5)\n"
|
||||
" U+4 + 2 H2O = UO2+ + 4 H+ + e-\n"
|
||||
" log_k -6.432\n"
|
||||
" delta_h 31.130 kcal\n"
|
||||
" #secondary master species for U(6)\n"
|
||||
" U+4 + 2 H2O = UO2+2 + 4 H+ + 2 e-\n"
|
||||
" log_k -9.217\n"
|
||||
" delta_h 34.430 kcal\n"
|
||||
" UO2+2 + H2O = UO2OH+ + H+\n"
|
||||
" log_k -5.782\n"
|
||||
" delta_h 11.015 kcal\n"
|
||||
" 2UO2+2 + 2H2O = (UO2)2(OH)2+2 + 2H+\n"
|
||||
" log_k -5.626\n"
|
||||
" delta_h -36.04 kcal\n"
|
||||
" 3UO2+2 + 5H2O = (UO2)3(OH)5+ + 5H+\n"
|
||||
" log_k -15.641\n"
|
||||
" delta_h -44.27 kcal\n"
|
||||
" UO2+2 + CO3-2 = UO2CO3\n"
|
||||
" log_k 10.064\n"
|
||||
" delta_h 0.84 kcal\n"
|
||||
" UO2+2 + 2CO3-2 = UO2(CO3)2-2\n"
|
||||
" log_k 16.977\n"
|
||||
" delta_h 3.48 kcal\n"
|
||||
" UO2+2 + 3CO3-2 = UO2(CO3)3-4\n"
|
||||
" log_k 21.397\n"
|
||||
" delta_h -8.78 kcal\n"
|
||||
"PHASES\n"
|
||||
" Uraninite\n"
|
||||
" UO2 + 4 H+ = U+4 + 2 H2O\n"
|
||||
" log_k -3.490\n"
|
||||
" delta_h -18.630 kcal\n"
|
||||
"END\n"
|
||||
"\n";
|
||||
|
||||
if (::FileExists("phreeqc.out"))
|
||||
{
|
||||
CPPUNIT_ASSERT(::DeleteFile("phreeqc.out"));
|
||||
}
|
||||
CPPUNIT_ASSERT_EQUAL(false, ::FileExists("phreeqc.out"));
|
||||
int n = ::CreateIPhreeqc();
|
||||
CPPUNIT_ASSERT(n >= 0);
|
||||
CPPUNIT_ASSERT_EQUAL(0, ::LoadDatabaseM(n, "phreeqc.dat"));
|
||||
::SetOutputOnM(n, 1);
|
||||
::SetErrorOnM(n, 0);
|
||||
::SetLogOnM(n, 0);
|
||||
::SetSelectedOutputOnM(n, 0);
|
||||
::SetDumpOnM(n, 0);
|
||||
CPPUNIT_ASSERT_EQUAL(false, ::FileExists("phreeqc.out"));
|
||||
CPPUNIT_ASSERT_EQUAL(0, ::RunStringM(n, input));
|
||||
CPPUNIT_ASSERT_EQUAL(true, ::FileExists("phreeqc.out"));
|
||||
if (n >= 0)
|
||||
{
|
||||
CPPUNIT_ASSERT_EQUAL(IPL_OK, ::DestroyIPhreeqc(n));
|
||||
}
|
||||
if (::FileExists("phreeqc.out"))
|
||||
{
|
||||
CPPUNIT_ASSERT(::DeleteFile("phreeqc.out"));
|
||||
}
|
||||
}
|
||||
|
||||
void TestIPhreeqcLib::TestGetSelectedOutputRowCount()
|
||||
{
|
||||
int n = ::CreateIPhreeqc();
|
||||
|
||||
@ -16,6 +16,7 @@ class TestIPhreeqcLib : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST( TestRunAccumulated );
|
||||
CPPUNIT_TEST( TestRunWithErrors );
|
||||
CPPUNIT_TEST( TestRunFile );
|
||||
CPPUNIT_TEST( TestRunString );
|
||||
CPPUNIT_TEST( TestGetSelectedOutputRowCount );
|
||||
CPPUNIT_TEST( TestGetSelectedOutputValue );
|
||||
CPPUNIT_TEST( TestGetSelectedOutputColumnCount );
|
||||
@ -56,6 +57,7 @@ public:
|
||||
void TestRunAccumulated(void);
|
||||
void TestRunWithErrors(void);
|
||||
void TestRunFile(void);
|
||||
void TestRunString(void);
|
||||
void TestGetSelectedOutputRowCount(void);
|
||||
void TestGetSelectedOutputValue(void);
|
||||
void TestGetSelectedOutputColumnCount(void);
|
||||
|
||||
@ -257,6 +257,101 @@ void TestInterface::TestRunFile()
|
||||
CPPUNIT_ASSERT(::DeleteFile(dump_file));
|
||||
}
|
||||
|
||||
void TestInterface::TestRunString(void)
|
||||
{
|
||||
const char input[] =
|
||||
"TITLE Example 1.--Add uranium and speciate seawater.\n"
|
||||
"SOLUTION 1 SEAWATER FROM NORDSTROM ET AL. (1979)\n"
|
||||
" units ppm\n"
|
||||
" pH 8.22\n"
|
||||
" pe 8.451\n"
|
||||
" density 1.023\n"
|
||||
" temp 25.0\n"
|
||||
" redox O(0)/O(-2)\n"
|
||||
" Ca 412.3\n"
|
||||
" Mg 1291.8\n"
|
||||
" Na 10768.0\n"
|
||||
" K 399.1\n"
|
||||
" Fe 0.002\n"
|
||||
" Mn 0.0002 pe\n"
|
||||
" Si 4.28\n"
|
||||
" Cl 19353.0\n"
|
||||
" Alkalinity 141.682 as HCO3\n"
|
||||
" S(6) 2712.0\n"
|
||||
" N(5) 0.29 gfw 62.0\n"
|
||||
" N(-3) 0.03 as NH4\n"
|
||||
" U 3.3 ppb N(5)/N(-3)\n"
|
||||
" O(0) 1.0 O2(g) -0.7\n"
|
||||
"SOLUTION_MASTER_SPECIES\n"
|
||||
" U U+4 0.0 238.0290 238.0290\n"
|
||||
" U(4) U+4 0.0 238.0290\n"
|
||||
" U(5) UO2+ 0.0 238.0290\n"
|
||||
" U(6) UO2+2 0.0 238.0290\n"
|
||||
"SOLUTION_SPECIES\n"
|
||||
" #primary master species for U\n"
|
||||
" #is also secondary master species for U(4)\n"
|
||||
" U+4 = U+4\n"
|
||||
" log_k 0.0\n"
|
||||
" U+4 + 4 H2O = U(OH)4 + 4 H+\n"
|
||||
" log_k -8.538\n"
|
||||
" delta_h 24.760 kcal\n"
|
||||
" U+4 + 5 H2O = U(OH)5- + 5 H+\n"
|
||||
" log_k -13.147\n"
|
||||
" delta_h 27.580 kcal\n"
|
||||
" #secondary master species for U(5)\n"
|
||||
" U+4 + 2 H2O = UO2+ + 4 H+ + e-\n"
|
||||
" log_k -6.432\n"
|
||||
" delta_h 31.130 kcal\n"
|
||||
" #secondary master species for U(6)\n"
|
||||
" U+4 + 2 H2O = UO2+2 + 4 H+ + 2 e-\n"
|
||||
" log_k -9.217\n"
|
||||
" delta_h 34.430 kcal\n"
|
||||
" UO2+2 + H2O = UO2OH+ + H+\n"
|
||||
" log_k -5.782\n"
|
||||
" delta_h 11.015 kcal\n"
|
||||
" 2UO2+2 + 2H2O = (UO2)2(OH)2+2 + 2H+\n"
|
||||
" log_k -5.626\n"
|
||||
" delta_h -36.04 kcal\n"
|
||||
" 3UO2+2 + 5H2O = (UO2)3(OH)5+ + 5H+\n"
|
||||
" log_k -15.641\n"
|
||||
" delta_h -44.27 kcal\n"
|
||||
" UO2+2 + CO3-2 = UO2CO3\n"
|
||||
" log_k 10.064\n"
|
||||
" delta_h 0.84 kcal\n"
|
||||
" UO2+2 + 2CO3-2 = UO2(CO3)2-2\n"
|
||||
" log_k 16.977\n"
|
||||
" delta_h 3.48 kcal\n"
|
||||
" UO2+2 + 3CO3-2 = UO2(CO3)3-4\n"
|
||||
" log_k 21.397\n"
|
||||
" delta_h -8.78 kcal\n"
|
||||
"PHASES\n"
|
||||
" Uraninite\n"
|
||||
" UO2 + 4 H+ = U+4 + 2 H2O\n"
|
||||
" log_k -3.490\n"
|
||||
" delta_h -18.630 kcal\n"
|
||||
"END\n"
|
||||
"\n";
|
||||
|
||||
if (::FileExists("phreeqc.out"))
|
||||
{
|
||||
CPPUNIT_ASSERT(::DeleteFile("phreeqc.out"));
|
||||
}
|
||||
CPPUNIT_ASSERT_EQUAL(false, ::FileExists("phreeqc.out"));
|
||||
CPPUNIT_ASSERT_EQUAL(0, ::LoadDatabase("phreeqc.dat"));
|
||||
::SetOutputOn(1);
|
||||
::SetErrorOn(0);
|
||||
::SetLogOn(0);
|
||||
::SetSelectedOutputOn(0);
|
||||
::SetDumpOn(0);
|
||||
CPPUNIT_ASSERT_EQUAL(false, ::FileExists("phreeqc.out"));
|
||||
CPPUNIT_ASSERT_EQUAL(0, ::RunString(input));
|
||||
CPPUNIT_ASSERT_EQUAL(true, ::FileExists("phreeqc.out"));
|
||||
if (::FileExists("phreeqc.out"))
|
||||
{
|
||||
CPPUNIT_ASSERT(::DeleteFile("phreeqc.out"));
|
||||
}
|
||||
}
|
||||
|
||||
void TestInterface::TestGetSelectedOutputRowCount()
|
||||
{
|
||||
CPPUNIT_ASSERT_EQUAL(0, ::LoadDatabase("llnl.dat"));
|
||||
|
||||
@ -16,6 +16,7 @@ class TestInterface :
|
||||
CPPUNIT_TEST( TestRun );
|
||||
CPPUNIT_TEST( TestRunWithErrors );
|
||||
CPPUNIT_TEST( TestRunFile );
|
||||
CPPUNIT_TEST( TestRunString );
|
||||
CPPUNIT_TEST( TestGetSelectedOutputRowCount );
|
||||
CPPUNIT_TEST( TestGetSelectedOutputValue );
|
||||
CPPUNIT_TEST( TestGetSelectedOutputColumnCount );
|
||||
@ -55,6 +56,7 @@ public:
|
||||
void TestRun(void);
|
||||
void TestRunWithErrors(void);
|
||||
void TestRunFile(void);
|
||||
void TestRunString(void);
|
||||
void TestGetSelectedOutputRowCount(void);
|
||||
void TestGetSelectedOutputValue(void);
|
||||
void TestGetSelectedOutputColumnCount(void);
|
||||
|
||||
@ -324,35 +324,8 @@
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="TestInterface.cpp"
|
||||
RelativePath=".\TestInterface.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="MemDebug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""
|
||||
PreprocessorDefinitions=""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\TestIPhreeqc.cpp"
|
||||
@ -2224,7 +2197,7 @@
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="TestInterface.h"
|
||||
RelativePath=".\TestInterface.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user