mirror of
https://git.gfz-potsdam.de/naaice/iphreeqc.git
synced 2025-12-16 08:38:23 +01:00
vector llnl parameters, removed hash references
This commit is contained in:
parent
7c538b62a7
commit
d82d5d610f
@ -723,7 +723,7 @@ parse(char * l_inbuf, tokenrec ** l_buf)
|
|||||||
* Note: Modification of string length may translate incorrectly [146] */
|
* Note: Modification of string length may translate incorrectly [146] */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Search hash list
|
* Search list
|
||||||
*/
|
*/
|
||||||
PhreeqcPtr->str_tolower(token);
|
PhreeqcPtr->str_tolower(token);
|
||||||
std::map<const std::string, BASIC_TOKEN>::const_iterator item;
|
std::map<const std::string, BASIC_TOKEN>::const_iterator item;
|
||||||
@ -2267,7 +2267,7 @@ factor(struct LOC_exec * LINK)
|
|||||||
|
|
||||||
case tokdh_a:
|
case tokdh_a:
|
||||||
{
|
{
|
||||||
if (PhreeqcPtr->llnl_count_temp > 0)
|
if (PhreeqcPtr->llnl_temp.size() > 0)
|
||||||
{
|
{
|
||||||
n.UU.val = PhreeqcPtr->a_llnl;
|
n.UU.val = PhreeqcPtr->a_llnl;
|
||||||
}
|
}
|
||||||
@ -2293,7 +2293,7 @@ factor(struct LOC_exec * LINK)
|
|||||||
|
|
||||||
case tokdh_b:
|
case tokdh_b:
|
||||||
{
|
{
|
||||||
if (PhreeqcPtr->llnl_count_temp > 0)
|
if (PhreeqcPtr->llnl_temp.size() > 0)
|
||||||
{
|
{
|
||||||
n.UU.val = PhreeqcPtr->b_llnl;
|
n.UU.val = PhreeqcPtr->b_llnl;
|
||||||
}
|
}
|
||||||
|
|||||||
66
Phreeqc.cpp
66
Phreeqc.cpp
@ -889,16 +889,6 @@ void Phreeqc::init(void)
|
|||||||
count_total_steps = 0;
|
count_total_steps = 0;
|
||||||
phast = FALSE;
|
phast = FALSE;
|
||||||
output_newline = true;
|
output_newline = true;
|
||||||
llnl_temp = 0;
|
|
||||||
llnl_count_temp = 0;
|
|
||||||
llnl_adh = 0;
|
|
||||||
llnl_count_adh = 0;
|
|
||||||
llnl_bdh = 0;
|
|
||||||
llnl_count_bdh = 0;
|
|
||||||
llnl_bdot = 0;
|
|
||||||
llnl_count_bdot = 0;
|
|
||||||
llnl_co2_coefs = 0;
|
|
||||||
llnl_count_co2_coefs = 0;
|
|
||||||
//selected_output_file_name = NULL;
|
//selected_output_file_name = NULL;
|
||||||
dump_file_name = NULL;
|
dump_file_name = NULL;
|
||||||
remove_unstable_phases = FALSE;
|
remove_unstable_phases = FALSE;
|
||||||
@ -1985,46 +1975,11 @@ Phreeqc::InternalCopy(const Phreeqc *pSrc)
|
|||||||
llnl_co2_coefs = 0;
|
llnl_co2_coefs = 0;
|
||||||
llnl_count_co2_coefs = 0;
|
llnl_count_co2_coefs = 0;
|
||||||
*/
|
*/
|
||||||
llnl_count_temp = pSrc->llnl_count_temp;
|
llnl_temp = pSrc->llnl_temp;
|
||||||
if (llnl_count_temp > 0)
|
llnl_adh = pSrc->llnl_adh;
|
||||||
{
|
llnl_bdh = pSrc->llnl_bdh;
|
||||||
llnl_temp = (LDBLE *) free_check_null(llnl_temp);
|
llnl_bdot = pSrc->llnl_bdot;
|
||||||
llnl_temp = (LDBLE *) PHRQ_malloc((size_t) llnl_count_temp * sizeof(LDBLE));
|
llnl_co2_coefs = pSrc->llnl_co2_coefs;
|
||||||
if (llnl_temp == NULL) malloc_error();
|
|
||||||
memcpy(llnl_temp, pSrc->llnl_temp, (size_t) llnl_count_temp * sizeof(LDBLE));
|
|
||||||
}
|
|
||||||
llnl_count_adh = pSrc->llnl_count_adh;
|
|
||||||
if (llnl_count_adh > 0)
|
|
||||||
{
|
|
||||||
llnl_adh = (LDBLE *) free_check_null(llnl_adh);
|
|
||||||
llnl_adh = (LDBLE *) PHRQ_malloc((size_t) llnl_count_adh * sizeof(LDBLE));
|
|
||||||
if (llnl_adh == NULL) malloc_error();
|
|
||||||
memcpy(llnl_adh, pSrc->llnl_adh, (size_t) llnl_count_adh * sizeof(LDBLE));
|
|
||||||
}
|
|
||||||
llnl_count_bdh = pSrc->llnl_count_bdh;
|
|
||||||
if (llnl_count_bdh > 0)
|
|
||||||
{
|
|
||||||
llnl_bdh = (LDBLE *) free_check_null(llnl_bdh);
|
|
||||||
llnl_bdh = (LDBLE *) PHRQ_malloc((size_t) llnl_count_bdh * sizeof(LDBLE));
|
|
||||||
if (llnl_bdh == NULL) malloc_error();
|
|
||||||
memcpy(llnl_bdh, pSrc->llnl_bdh, (size_t) llnl_count_bdh * sizeof(LDBLE));
|
|
||||||
}
|
|
||||||
llnl_count_bdot = pSrc->llnl_count_bdot;
|
|
||||||
if (llnl_count_bdot > 0)
|
|
||||||
{
|
|
||||||
llnl_bdot = (LDBLE *) free_check_null(llnl_bdot);
|
|
||||||
llnl_bdot = (LDBLE *) PHRQ_malloc((size_t) llnl_count_bdot * sizeof(LDBLE));
|
|
||||||
if (llnl_bdot == NULL) malloc_error();
|
|
||||||
memcpy(llnl_bdot, pSrc->llnl_bdot, (size_t) llnl_count_bdot * sizeof(LDBLE));
|
|
||||||
}
|
|
||||||
llnl_count_co2_coefs = pSrc->llnl_count_co2_coefs;
|
|
||||||
if (llnl_count_co2_coefs > 0)
|
|
||||||
{
|
|
||||||
llnl_co2_coefs = (LDBLE *) free_check_null(llnl_co2_coefs);
|
|
||||||
llnl_co2_coefs = (LDBLE *) PHRQ_malloc((size_t) llnl_count_co2_coefs * sizeof(LDBLE));
|
|
||||||
if (llnl_co2_coefs == NULL) malloc_error();
|
|
||||||
memcpy(llnl_co2_coefs, pSrc->llnl_co2_coefs, (size_t) llnl_count_co2_coefs * sizeof(LDBLE));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Not implemented for now
|
// Not implemented for now
|
||||||
SelectedOutput_map = pSrc->SelectedOutput_map;
|
SelectedOutput_map = pSrc->SelectedOutput_map;
|
||||||
@ -2057,17 +2012,6 @@ Phreeqc::InternalCopy(const Phreeqc *pSrc)
|
|||||||
//remove_unstable_phases = FALSE;
|
//remove_unstable_phases = FALSE;
|
||||||
// auto screen_string;
|
// auto screen_string;
|
||||||
spread_length = 10;
|
spread_length = 10;
|
||||||
/* ---------------------------------------------------------------------- */
|
|
||||||
/*
|
|
||||||
* Hash definitions
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
elements_hash_table = NULL;
|
|
||||||
species_hash_table = NULL;
|
|
||||||
phases_hash_table = NULL;
|
|
||||||
logk_hash_table = NULL;
|
|
||||||
master_isotope_hash_table = NULL;
|
|
||||||
*/
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
* ISOTOPES
|
* ISOTOPES
|
||||||
* ---------------------------------------------------------------------- */
|
* ---------------------------------------------------------------------- */
|
||||||
|
|||||||
10
Phreeqc.h
10
Phreeqc.h
@ -721,11 +721,6 @@ public:
|
|||||||
int read_inv_isotopes(struct inverse *inverse_ptr, char *ptr);
|
int read_inv_isotopes(struct inverse *inverse_ptr, char *ptr);
|
||||||
int read_inv_phases(struct inverse *inverse_ptr, char *next_char);
|
int read_inv_phases(struct inverse *inverse_ptr, char *next_char);
|
||||||
int read_kinetics(void);
|
int read_kinetics(void);
|
||||||
int read_line_doubles(char *next_char, LDBLE ** d, int *count_d,
|
|
||||||
int *count_alloc);
|
|
||||||
int read_lines_doubles(char *next_char, LDBLE ** d, int *count_d,
|
|
||||||
int *count_alloc, const char **opt_list,
|
|
||||||
int count_opt_list, int *opt);
|
|
||||||
LDBLE *read_list_doubles(char **ptr, int *count_doubles);
|
LDBLE *read_list_doubles(char **ptr, int *count_doubles);
|
||||||
int *read_list_ints(char **ptr, int *count_ints, int positive);
|
int *read_list_ints(char **ptr, int *count_ints, int positive);
|
||||||
int *read_list_t_f(char **ptr, int *count_ints);
|
int *read_list_t_f(char **ptr, int *count_ints);
|
||||||
@ -1629,9 +1624,8 @@ protected:
|
|||||||
bool output_newline;
|
bool output_newline;
|
||||||
inline void Set_output_newline(bool tf) { this->output_newline = tf;}
|
inline void Set_output_newline(bool tf) { this->output_newline = tf;}
|
||||||
inline bool Get_output_newline() { return this->output_newline;}
|
inline bool Get_output_newline() { return this->output_newline;}
|
||||||
LDBLE *llnl_temp, *llnl_adh, *llnl_bdh, *llnl_bdot, *llnl_co2_coefs, a_llnl, b_llnl, bdot_llnl;
|
double a_llnl, b_llnl, bdot_llnl;
|
||||||
int llnl_count_temp, llnl_count_adh, llnl_count_bdh, llnl_count_bdot,
|
std::vector<double> llnl_temp, llnl_adh, llnl_bdh, llnl_bdot, llnl_co2_coefs;
|
||||||
llnl_count_co2_coefs;
|
|
||||||
|
|
||||||
//char *selected_output_file_name;
|
//char *selected_output_file_name;
|
||||||
std::map<int, SelectedOutput> SelectedOutput_map;
|
std::map<int, SelectedOutput> SelectedOutput_map;
|
||||||
|
|||||||
@ -722,7 +722,7 @@ dh_bdot(const char* name)
|
|||||||
char token[MAX_LENGTH];
|
char token[MAX_LENGTH];
|
||||||
struct species* s_ptr;
|
struct species* s_ptr;
|
||||||
double b = -999.99;
|
double b = -999.99;
|
||||||
if (llnl_count_temp > 0)
|
if (llnl_temp.size() > 0)
|
||||||
{
|
{
|
||||||
b = bdot_llnl;
|
b = bdot_llnl;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -149,16 +149,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#define REF_PRES_PASCAL 1.01325E5 /* Reference pressure: 1 atm */
|
#define REF_PRES_PASCAL 1.01325E5 /* Reference pressure: 1 atm */
|
||||||
#define MAX_P_NONLLNL 1500.0
|
#define MAX_P_NONLLNL 1500.0
|
||||||
/*
|
|
||||||
* Hash definitions
|
|
||||||
*/
|
|
||||||
# define SegmentSize 256
|
|
||||||
# define SegmentSizeShift 8 /* log2(SegmentSize) */
|
|
||||||
# define DirectorySize 256
|
|
||||||
# define DirectorySizeShift 8 /* log2(DirectorySize) */
|
|
||||||
# define Prime1 37
|
|
||||||
# define Prime2 1048583
|
|
||||||
# define DefaultMaxLoadFactor 5
|
|
||||||
//
|
//
|
||||||
// Typedefs and structure definitions
|
// Typedefs and structure definitions
|
||||||
//
|
//
|
||||||
|
|||||||
@ -1304,11 +1304,11 @@ master_isotope_store(const char *name, int replace_if_found)
|
|||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Function locates the string "name" in the hash table for master_isotope.
|
* Function locates the string "name" in the map for master_isotope.
|
||||||
*
|
*
|
||||||
* Pointer to a master_isotope structure is always returned.
|
* Pointer to a master_isotope structure is always returned.
|
||||||
*
|
*
|
||||||
* If the string is not found, a new entry is made in the hash table. Pointer to
|
* If the string is not found, a new entry is made in the map. Pointer to
|
||||||
* the new structure is returned.
|
* the new structure is returned.
|
||||||
* If "name" is found and replace is true, pointers in old master_isotope structure
|
* If "name" is found and replace is true, pointers in old master_isotope structure
|
||||||
* are freed and replaced with additional input.
|
* are freed and replaced with additional input.
|
||||||
@ -1607,7 +1607,7 @@ isotope_ratio_store(const char *name_in, int replace_if_found)
|
|||||||
*
|
*
|
||||||
* Pointer to a isotope_ratio structure is always returned.
|
* Pointer to a isotope_ratio structure is always returned.
|
||||||
*
|
*
|
||||||
* If the string is not found, a new entry is made in the hash table. Pointer to
|
* If the string is not found, a new entry is made in the map. Pointer to
|
||||||
* the new structure is returned.
|
* the new structure is returned.
|
||||||
* If "name" is found and replace is true, pointers in old isotope_ratio structure
|
* If "name" is found and replace is true, pointers in old isotope_ratio structure
|
||||||
* are freed and replaced with additional input.
|
* are freed and replaced with additional input.
|
||||||
|
|||||||
20
mainsubs.cpp
20
mainsubs.cpp
@ -71,26 +71,6 @@ initialize(void)
|
|||||||
Initialize llnl aqueous model parameters
|
Initialize llnl aqueous model parameters
|
||||||
*/
|
*/
|
||||||
a_llnl = b_llnl = 0.0;
|
a_llnl = b_llnl = 0.0;
|
||||||
llnl_temp = (LDBLE *) PHRQ_malloc(sizeof(LDBLE));
|
|
||||||
if (llnl_temp == NULL)
|
|
||||||
malloc_error();
|
|
||||||
llnl_count_temp = 0;
|
|
||||||
llnl_adh = (LDBLE *) PHRQ_malloc(sizeof(LDBLE));
|
|
||||||
if (llnl_adh == NULL)
|
|
||||||
malloc_error();
|
|
||||||
llnl_count_adh = 0;
|
|
||||||
llnl_bdh = (LDBLE *) PHRQ_malloc(sizeof(LDBLE));
|
|
||||||
if (llnl_bdh == NULL)
|
|
||||||
malloc_error();
|
|
||||||
llnl_count_bdh = 0;
|
|
||||||
llnl_bdot = (LDBLE *) PHRQ_malloc(sizeof(LDBLE));
|
|
||||||
if (llnl_bdot == NULL)
|
|
||||||
malloc_error();
|
|
||||||
llnl_count_bdot = 0;
|
|
||||||
llnl_co2_coefs = (LDBLE *) PHRQ_malloc(sizeof(LDBLE));
|
|
||||||
if (llnl_co2_coefs == NULL)
|
|
||||||
malloc_error();
|
|
||||||
llnl_count_co2_coefs = 0;
|
|
||||||
// new PBasic
|
// new PBasic
|
||||||
basic_interpreter = new PBasic(this, phrq_io);
|
basic_interpreter = new PBasic(this, phrq_io);
|
||||||
// allocate one change_surf
|
// allocate one change_surf
|
||||||
|
|||||||
22
model.cpp
22
model.cpp
@ -53,7 +53,7 @@ model(void)
|
|||||||
input_error++;
|
input_error++;
|
||||||
error_msg("Cannot use PITZER and SIT data blocks in same run (database + input file).", STOP);
|
error_msg("Cannot use PITZER and SIT data blocks in same run (database + input file).", STOP);
|
||||||
}
|
}
|
||||||
if ((pitzer_model == TRUE || sit_model == TRUE) && llnl_count_temp >0)
|
if ((pitzer_model == TRUE || sit_model == TRUE) && llnl_temp.size() > 0)
|
||||||
{
|
{
|
||||||
input_error++;
|
input_error++;
|
||||||
error_msg("Cannot use LLNL_AQUEOUS_MODEL_PARAMETERS with PITZER or SIT data blocks in same run (database + input file).", STOP);
|
error_msg("Cannot use LLNL_AQUEOUS_MODEL_PARAMETERS with PITZER or SIT data blocks in same run (database + input file).", STOP);
|
||||||
@ -570,17 +570,17 @@ gammas(LDBLE mu)
|
|||||||
/*
|
/*
|
||||||
* LLNL temperature dependence
|
* LLNL temperature dependence
|
||||||
*/
|
*/
|
||||||
if (llnl_count_temp > 0)
|
if (llnl_temp.size() > 0)
|
||||||
{
|
{
|
||||||
ifirst = 0;
|
ifirst = 0;
|
||||||
ilast = llnl_count_temp;
|
ilast = (int)llnl_temp.size();
|
||||||
if (tc_x < llnl_temp[0] || tc_x > llnl_temp[llnl_count_temp - 1])
|
if (tc_x < llnl_temp[0] || tc_x > llnl_temp[llnl_temp.size() - 1])
|
||||||
{
|
{
|
||||||
error_msg
|
error_msg
|
||||||
("Temperature out of range of LLNL_AQUEOUS_MODEL parameters",
|
("Temperature out of range of LLNL_AQUEOUS_MODEL parameters",
|
||||||
STOP);
|
STOP);
|
||||||
}
|
}
|
||||||
for (i = 0; i < llnl_count_temp; i++)
|
for (i = 0; i < (int)llnl_temp.size(); i++)
|
||||||
{
|
{
|
||||||
if (tc_x >= llnl_temp[i])
|
if (tc_x >= llnl_temp[i])
|
||||||
ifirst = i;
|
ifirst = i;
|
||||||
@ -629,7 +629,7 @@ gammas(LDBLE mu)
|
|||||||
(2 * muhalf * (muhalf + 1.0) * (muhalf + 1.0)) -
|
(2 * muhalf * (muhalf + 1.0) * (muhalf + 1.0)) -
|
||||||
0.3);
|
0.3);
|
||||||
c2 = -a / (2 * muhalf);
|
c2 = -a / (2 * muhalf);
|
||||||
if (llnl_count_temp > 0)
|
if (llnl_temp.size() > 0)
|
||||||
{
|
{
|
||||||
c2_llnl = -a_llnl / (2 * muhalf);
|
c2_llnl = -a_llnl / (2 * muhalf);
|
||||||
}
|
}
|
||||||
@ -725,7 +725,7 @@ gammas(LDBLE mu)
|
|||||||
}
|
}
|
||||||
else if (s_x[i]->exch_gflag == 7 && s_x[i]->alk > 0)
|
else if (s_x[i]->exch_gflag == 7 && s_x[i]->alk > 0)
|
||||||
{
|
{
|
||||||
if (llnl_count_temp > 0)
|
if (llnl_temp.size() > 0)
|
||||||
{
|
{
|
||||||
s_x[i]->lg =
|
s_x[i]->lg =
|
||||||
coef * (-a_llnl * muhalf * z * z /
|
coef * (-a_llnl * muhalf * z * z /
|
||||||
@ -805,7 +805,7 @@ gammas(LDBLE mu)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 7: /* LLNL */
|
case 7: /* LLNL */
|
||||||
if (llnl_count_temp > 0)
|
if (llnl_temp.size() > 0)
|
||||||
{
|
{
|
||||||
if (s_x[i]->z == 0)
|
if (s_x[i]->z == 0)
|
||||||
{
|
{
|
||||||
@ -834,7 +834,7 @@ gammas(LDBLE mu)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 8: /* LLNL CO2 */
|
case 8: /* LLNL CO2 */
|
||||||
if (llnl_count_temp > 0)
|
if (llnl_temp.size() > 0)
|
||||||
{
|
{
|
||||||
s_x[i]->lg = log_g_co2;
|
s_x[i]->lg = log_g_co2;
|
||||||
s_x[i]->dg = dln_g_co2 * s_x[i]->moles;
|
s_x[i]->dg = dln_g_co2 * s_x[i]->moles;
|
||||||
@ -2690,7 +2690,7 @@ calc_gas_pressures(void)
|
|||||||
* Fixed-volume gas phase reacting with a solution
|
* Fixed-volume gas phase reacting with a solution
|
||||||
* Change pressure used in logK to pressure of gas phase
|
* Change pressure used in logK to pressure of gas phase
|
||||||
*/
|
*/
|
||||||
if (gas_phase_ptr->Get_total_p() > MAX_P_NONLLNL && llnl_count_temp <= 0)
|
if (gas_phase_ptr->Get_total_p() > MAX_P_NONLLNL && llnl_temp.size() == 0)
|
||||||
{
|
{
|
||||||
gas_phase_ptr->Set_total_moles(0);
|
gas_phase_ptr->Set_total_moles(0);
|
||||||
for (size_t i = 0; i < gas_phase_ptr->Get_gas_comps().size(); i++)
|
for (size_t i = 0; i < gas_phase_ptr->Get_gas_comps().size(); i++)
|
||||||
@ -3686,7 +3686,7 @@ reset(void)
|
|||||||
//{
|
//{
|
||||||
// patm_x = ( 1 * patm_x + p_sat) / 2.0;
|
// patm_x = ( 1 * patm_x + p_sat) / 2.0;
|
||||||
//}
|
//}
|
||||||
if (llnl_count_temp <= 0)
|
if (llnl_temp.size() == 0)
|
||||||
{
|
{
|
||||||
if (patm_x > MAX_P_NONLLNL)
|
if (patm_x > MAX_P_NONLLNL)
|
||||||
patm_x = MAX_P_NONLLNL;
|
patm_x = MAX_P_NONLLNL;
|
||||||
|
|||||||
2
prep.cpp
2
prep.cpp
@ -5480,7 +5480,7 @@ calc_vm(LDBLE tc, LDBLE pa)
|
|||||||
* b4 = logk[vmi4], or
|
* b4 = logk[vmi4], or
|
||||||
* coef(tc) = millero[3] + millero[4] * tc + millero[5] * tc^2
|
* coef(tc) = millero[3] + millero[4] * tc + millero[5] * tc^2
|
||||||
*/
|
*/
|
||||||
if (llnl_count_temp > 0) return OK;
|
if (llnl_temp.size() > 0) return OK;
|
||||||
LDBLE pb_s = 2600. + pa * 1.01325, TK_s = tc + 45.15, sqrt_mu = sqrt(mu_x);
|
LDBLE pb_s = 2600. + pa * 1.01325, TK_s = tc + 45.15, sqrt_mu = sqrt(mu_x);
|
||||||
for (int i = 0; i < (int)this->s_x.size(); i++)
|
for (int i = 0; i < (int)this->s_x.size(); i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -597,7 +597,7 @@ print_gas_phase(void)
|
|||||||
print_centered("Gas phase");
|
print_centered("Gas phase");
|
||||||
output_msg(sformatf("Total pressure: %5.2f atmospheres",
|
output_msg(sformatf("Total pressure: %5.2f atmospheres",
|
||||||
(double) gas_phase_ptr->Get_total_p()));
|
(double) gas_phase_ptr->Get_total_p()));
|
||||||
if (gas_phase_ptr->Get_total_p() >= MAX_P_NONLLNL && llnl_count_temp <= 0)
|
if (gas_phase_ptr->Get_total_p() >= MAX_P_NONLLNL && llnl_temp.size() == 0)
|
||||||
output_msg(" WARNING: Program limit.\n");
|
output_msg(" WARNING: Program limit.\n");
|
||||||
else if (PR)
|
else if (PR)
|
||||||
output_msg(" (Peng-Robinson calculation)\n");
|
output_msg(" (Peng-Robinson calculation)\n");
|
||||||
|
|||||||
300
read.cpp
300
read.cpp
@ -9243,25 +9243,22 @@ int Phreeqc::
|
|||||||
read_llnl_aqueous_model_parameters(void)
|
read_llnl_aqueous_model_parameters(void)
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Reads aqueous model parameters
|
* Reads aqueous model parameters
|
||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
* none
|
* none
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* KEYWORD if keyword encountered, input_error may be incremented if
|
* KEYWORD if keyword encountered, input_error may be incremented if
|
||||||
* a keyword is encountered in an unexpected position
|
* a keyword is encountered in an unexpected position
|
||||||
* EOF if eof encountered while reading mass balance concentrations
|
* EOF if eof encountered while reading mass balance concentrations
|
||||||
* ERROR if error occurred reading data
|
* ERROR if error occurred reading data
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int i, count_alloc;
|
|
||||||
char token[MAX_LENGTH];
|
|
||||||
|
|
||||||
int return_value, opt;
|
int return_value, opt;
|
||||||
char *next_char;
|
char* next_char;
|
||||||
const char *opt_list[] = {
|
const char* opt_list[] = {
|
||||||
"temperatures", /* 0 */
|
"temperatures", /* 0 */
|
||||||
"temperature", /* 1 */
|
"temperature", /* 1 */
|
||||||
"temp", /* 2 */
|
"temp", /* 2 */
|
||||||
@ -9277,21 +9274,23 @@ read_llnl_aqueous_model_parameters(void)
|
|||||||
"co2_coefs" /* 12 */
|
"co2_coefs" /* 12 */
|
||||||
};
|
};
|
||||||
int count_opt_list = 13;
|
int count_opt_list = 13;
|
||||||
/*
|
/*
|
||||||
* Initialize
|
* Initialize
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* Read aqueous model parameters
|
* Read aqueous model parameters
|
||||||
*/
|
*/
|
||||||
return_value = UNKNOWN;
|
return_value = UNKNOWN;
|
||||||
opt = get_option(opt_list, count_opt_list, &next_char);
|
int opt_save = OPTION_DEFAULT;
|
||||||
|
opt_save = OPTION_DEFAULT;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
next_char = line;
|
opt = get_option(opt_list, count_opt_list, &next_char);
|
||||||
if (opt >= 0)
|
if (opt == OPTION_DEFAULT)
|
||||||
{
|
{
|
||||||
copy_token(token, &next_char, &i);
|
opt = opt_save;
|
||||||
}
|
}
|
||||||
|
opt_save = OPTION_DEFAULT;
|
||||||
switch (opt)
|
switch (opt)
|
||||||
{
|
{
|
||||||
case OPTION_EOF: /* end of file */
|
case OPTION_EOF: /* end of file */
|
||||||
@ -9304,112 +9303,98 @@ read_llnl_aqueous_model_parameters(void)
|
|||||||
case OPTION_ERROR:
|
case OPTION_ERROR:
|
||||||
input_error++;
|
input_error++;
|
||||||
error_msg
|
error_msg
|
||||||
("Unknown input in LLNL_AQUEOUS_MODEL_PARAMETERS keyword.",
|
("Unknown input in LLNL_AQUEOUS_MODEL_PARAMETERS keyword.",
|
||||||
CONTINUE);
|
CONTINUE);
|
||||||
error_msg(line_save, CONTINUE);
|
error_msg(line_save, CONTINUE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/*
|
|
||||||
* New component
|
|
||||||
*/
|
|
||||||
case 0: /* temperatures */
|
case 0: /* temperatures */
|
||||||
case 1: /* temperature */
|
case 1: /* temperature */
|
||||||
case 2: /* temp */
|
case 2: /* temp */
|
||||||
count_alloc = 1;
|
{
|
||||||
llnl_count_temp = 0;
|
std::istringstream iss(next_char);
|
||||||
i = read_lines_doubles(next_char, &(llnl_temp),
|
while (iss >> dummy)
|
||||||
&(llnl_count_temp), &(count_alloc),
|
{
|
||||||
opt_list, count_opt_list, &opt);
|
llnl_temp.push_back(dummy);
|
||||||
/*
|
}
|
||||||
ptr = next_char;
|
opt_save = 2;
|
||||||
llnl_temp = read_list_doubles(&ptr, &count);
|
}
|
||||||
llnl_count_temp = count;
|
break;
|
||||||
*/
|
|
||||||
break;
|
|
||||||
case 3: /* adh */
|
case 3: /* adh */
|
||||||
case 4: /* debye_huckel_a */
|
case 4: /* debye_huckel_a */
|
||||||
case 5: /* dh_a */
|
case 5: /* dh_a */
|
||||||
count_alloc = 1;
|
{
|
||||||
llnl_count_adh = 0;
|
std::istringstream iss(next_char);
|
||||||
i = read_lines_doubles(next_char, &(llnl_adh), &(llnl_count_adh),
|
while (iss >> dummy)
|
||||||
&(count_alloc), opt_list, count_opt_list,
|
{
|
||||||
&opt);
|
llnl_adh.push_back(dummy);
|
||||||
/*
|
}
|
||||||
ptr = next_char;
|
opt_save = 5;
|
||||||
llnl_adh = read_list_doubles(&ptr, &count);
|
}
|
||||||
llnl_count_adh = count;
|
break;
|
||||||
*/
|
|
||||||
break;
|
|
||||||
case 6: /* bdh */
|
case 6: /* bdh */
|
||||||
case 7: /* debye_huckel_b */
|
case 7: /* debye_huckel_b */
|
||||||
case 8: /* dh_b */
|
case 8: /* dh_b */
|
||||||
count_alloc = 1;
|
{
|
||||||
llnl_count_bdh = 0;
|
std::istringstream iss(next_char);
|
||||||
i = read_lines_doubles(next_char, &(llnl_bdh), &(llnl_count_bdh),
|
while (iss >> dummy)
|
||||||
&(count_alloc), opt_list, count_opt_list,
|
{
|
||||||
&opt);
|
llnl_bdh.push_back(dummy);
|
||||||
/*
|
}
|
||||||
ptr = next_char;
|
opt_save = 8;
|
||||||
llnl_bdh = read_list_doubles(&ptr, &count);
|
}
|
||||||
llnl_count_bdh = count;
|
break;
|
||||||
*/
|
|
||||||
break;
|
|
||||||
case 9: /* bdot */
|
case 9: /* bdot */
|
||||||
case 10: /* b_dot */
|
case 10: /* b_dot */
|
||||||
count_alloc = 1;
|
{
|
||||||
llnl_count_bdot = 0;
|
std::istringstream iss(next_char);
|
||||||
i = read_lines_doubles(next_char, &(llnl_bdot),
|
while (iss >> dummy)
|
||||||
&(llnl_count_bdot), &(count_alloc),
|
{
|
||||||
opt_list, count_opt_list, &opt);
|
llnl_bdot.push_back(dummy);
|
||||||
/*
|
}
|
||||||
ptr = next_char;
|
opt_save = 10;
|
||||||
llnl_bdot = read_list_doubles(&ptr, &count);
|
}
|
||||||
llnl_count_bdot = count;
|
break;
|
||||||
*/
|
|
||||||
break;
|
|
||||||
case 11: /* c_co2 */
|
case 11: /* c_co2 */
|
||||||
case 12: /* co2_coefs */
|
case 12: /* co2_coefs */
|
||||||
count_alloc = 1;
|
{
|
||||||
llnl_count_co2_coefs = 0;
|
std::istringstream iss(next_char);
|
||||||
i = read_lines_doubles(next_char, &(llnl_co2_coefs),
|
while (iss >> dummy)
|
||||||
&(llnl_count_co2_coefs), &(count_alloc),
|
{
|
||||||
opt_list, count_opt_list, &opt);
|
llnl_co2_coefs.push_back(dummy);
|
||||||
/*
|
}
|
||||||
ptr = next_char;
|
opt_save = 12;
|
||||||
llnl_co2_coefs = read_list_doubles(&ptr, &count);
|
}
|
||||||
llnl_count_co2_coefs = count;
|
break;
|
||||||
*/
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return_value = check_line_return;
|
return_value = check_line_return;
|
||||||
if (return_value == EOF || return_value == KEYWORD)
|
if (return_value == EOF || return_value == KEYWORD)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* check consistency */
|
/* check consistency */
|
||||||
if ((llnl_count_temp <= 0) ||
|
if ((llnl_temp.size() == 0) ||
|
||||||
(llnl_count_temp != llnl_count_adh) ||
|
(llnl_temp.size() != llnl_adh.size()) ||
|
||||||
(llnl_count_temp != llnl_count_bdh) ||
|
(llnl_temp.size() != llnl_bdh.size()) ||
|
||||||
(llnl_count_temp != llnl_count_bdot))
|
(llnl_temp.size() != llnl_bdot.size()))
|
||||||
{
|
{
|
||||||
error_msg
|
error_msg
|
||||||
("Must define equal number (>0) of temperatures, dh_a, dh_b, and bdot parameters\nin LLNL_AQUEOUS_MODEL",
|
("Must define equal number (>0) of temperatures, dh_a, dh_b, and bdot parameters\nin LLNL_AQUEOUS_MODEL",
|
||||||
CONTINUE);
|
CONTINUE);
|
||||||
input_error++;
|
input_error++;
|
||||||
}
|
}
|
||||||
if (llnl_count_co2_coefs != 5)
|
if (llnl_co2_coefs.size() != 5)
|
||||||
{
|
{
|
||||||
error_msg
|
error_msg
|
||||||
("Must define 5 CO2 activity coefficient parameters in LLNL_AQUEOUS_MODEL",
|
("Must define 5 CO2 activity coefficient parameters in LLNL_AQUEOUS_MODEL",
|
||||||
CONTINUE);
|
CONTINUE);
|
||||||
input_error++;
|
input_error++;
|
||||||
}
|
}
|
||||||
for (i = 1; i < llnl_count_temp; i++)
|
for (size_t i = 1; i < llnl_temp.size(); i++)
|
||||||
{
|
{
|
||||||
if (llnl_temp[i - 1] > llnl_temp[i])
|
if (llnl_temp[i - 1] > llnl_temp[i])
|
||||||
{
|
{
|
||||||
error_msg
|
error_msg
|
||||||
("Temperatures must be in ascending order in LLNL_AQUEOUS_MODEL",
|
("Temperatures must be in ascending order in LLNL_AQUEOUS_MODEL",
|
||||||
CONTINUE);
|
CONTINUE);
|
||||||
input_error++;
|
input_error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -9417,119 +9402,6 @@ read_llnl_aqueous_model_parameters(void)
|
|||||||
return (return_value);
|
return (return_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
|
||||||
int Phreeqc::
|
|
||||||
read_lines_doubles(char *next_char, LDBLE ** d, int *count_d,
|
|
||||||
int *count_alloc, const char **opt_list,
|
|
||||||
int count_opt_list, int *opt)
|
|
||||||
/* ---------------------------------------------------------------------- */
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Reads LDBLEs on line starting at next_char
|
|
||||||
* and on succeeding lines. Appends to d.
|
|
||||||
* Stops at KEYWORD, OPTION, and EOF
|
|
||||||
*
|
|
||||||
* Input Arguments:
|
|
||||||
* next_char points to line to read from
|
|
||||||
* d points to array of LDBLEs, must be malloced
|
|
||||||
* count_d number of elements in array
|
|
||||||
* count_alloc number of elements malloced
|
|
||||||
*
|
|
||||||
* Output Arguments:
|
|
||||||
* d points to array of LDBLEs, may have been
|
|
||||||
* realloced
|
|
||||||
* count_d updated number of elements in array
|
|
||||||
* count_alloc updated of elements malloced
|
|
||||||
*
|
|
||||||
* Returns:
|
|
||||||
* KEYWORD
|
|
||||||
* OPTION
|
|
||||||
* EOF
|
|
||||||
* ERROR if any errors reading LDBLEs
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (read_line_doubles(next_char, d, count_d, count_alloc) == ERROR)
|
|
||||||
{
|
|
||||||
return (ERROR);
|
|
||||||
}
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
*opt = get_option(opt_list, count_opt_list, &next_char);
|
|
||||||
if (*opt == OPTION_KEYWORD || *opt == OPTION_EOF
|
|
||||||
|| *opt == OPTION_ERROR)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (*opt >= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
next_char = line;
|
|
||||||
if (read_line_doubles(next_char, d, count_d, count_alloc) == ERROR)
|
|
||||||
{
|
|
||||||
return (ERROR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
|
||||||
int Phreeqc::
|
|
||||||
read_line_doubles(char *next_char, LDBLE ** d, int *count_d, int *count_alloc)
|
|
||||||
/* ---------------------------------------------------------------------- */
|
|
||||||
{
|
|
||||||
int i, j, l, n;
|
|
||||||
LDBLE value;
|
|
||||||
char token[MAX_LENGTH];
|
|
||||||
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
j = copy_token(token, &next_char, &l);
|
|
||||||
if (j == EMPTY)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (j != DIGIT)
|
|
||||||
{
|
|
||||||
return (ERROR);
|
|
||||||
}
|
|
||||||
if (replace("*", " ", token) == TRUE)
|
|
||||||
{
|
|
||||||
if (sscanf(token, "%d" SCANFORMAT, &n, &value) != 2)
|
|
||||||
{
|
|
||||||
return (ERROR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
(void)sscanf(token, SCANFORMAT, &value);
|
|
||||||
n = 1;
|
|
||||||
}
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
if ((*count_d) + n > (*count_alloc))
|
|
||||||
{
|
|
||||||
*count_alloc *= 2;
|
|
||||||
*d = (LDBLE *) PHRQ_realloc(*d,
|
|
||||||
(size_t) (*count_alloc) *
|
|
||||||
sizeof(LDBLE));
|
|
||||||
if (*d == NULL)
|
|
||||||
malloc_error();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (i = 0; i < n; i++)
|
|
||||||
{
|
|
||||||
(*d)[(*count_d) + i] = value;
|
|
||||||
}
|
|
||||||
*count_d += n;
|
|
||||||
}
|
|
||||||
return (OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
int Phreeqc::
|
int Phreeqc::
|
||||||
next_keyword_or_option(const char **opt_list, int count_opt_list)
|
next_keyword_or_option(const char **opt_list, int count_opt_list)
|
||||||
|
|||||||
@ -137,7 +137,7 @@ clean_up(void)
|
|||||||
rate_free(&rates[j]);
|
rate_free(&rates[j]);
|
||||||
}
|
}
|
||||||
rates.clear();
|
rates.clear();
|
||||||
/* logk hash table */
|
/* logk table */
|
||||||
for (j = 0; j < (int)logk.size(); j++)
|
for (j = 0; j < (int)logk.size(); j++)
|
||||||
{
|
{
|
||||||
logk[j]->add_logk.clear();
|
logk[j]->add_logk.clear();
|
||||||
@ -168,13 +168,13 @@ clean_up(void)
|
|||||||
rate_free(user_print);
|
rate_free(user_print);
|
||||||
user_print = (struct rate*)free_check_null(user_print);
|
user_print = (struct rate*)free_check_null(user_print);
|
||||||
/*
|
/*
|
||||||
Free llnl aqueous model parameters
|
Clear llnl aqueous model parameters
|
||||||
*/
|
*/
|
||||||
llnl_temp = (LDBLE*)free_check_null(llnl_temp);
|
llnl_temp.clear();
|
||||||
llnl_adh = (LDBLE*)free_check_null(llnl_adh);
|
llnl_adh.clear();
|
||||||
llnl_bdh = (LDBLE*)free_check_null(llnl_bdh);
|
llnl_bdh.clear();
|
||||||
llnl_bdot = (LDBLE*)free_check_null(llnl_bdot);
|
llnl_bdot.clear();
|
||||||
llnl_co2_coefs = (LDBLE*)free_check_null(llnl_co2_coefs);
|
llnl_co2_coefs.clear();
|
||||||
/*
|
/*
|
||||||
* Copier space
|
* Copier space
|
||||||
*/
|
*/
|
||||||
@ -226,7 +226,7 @@ clean_up(void)
|
|||||||
pitzer_clean_up();
|
pitzer_clean_up();
|
||||||
/* sit */
|
/* sit */
|
||||||
sit_clean_up();
|
sit_clean_up();
|
||||||
/* hash tables */
|
/* elements, species, phases*/
|
||||||
elements_map.clear();
|
elements_map.clear();
|
||||||
species_map.clear();
|
species_map.clear();
|
||||||
phases_map.clear();
|
phases_map.clear();
|
||||||
@ -253,12 +253,6 @@ clean_up(void)
|
|||||||
last_title_x.clear();
|
last_title_x.clear();
|
||||||
count_inverse = 0;
|
count_inverse = 0;
|
||||||
|
|
||||||
llnl_count_temp = 0;
|
|
||||||
llnl_count_adh = 0;
|
|
||||||
llnl_count_bdh = 0;
|
|
||||||
llnl_count_bdot = 0;
|
|
||||||
llnl_count_co2_coefs = 0;
|
|
||||||
|
|
||||||
default_data_base = (char *) free_check_null(default_data_base);
|
default_data_base = (char *) free_check_null(default_data_base);
|
||||||
sformatf_buffer = (char *) free_check_null(sformatf_buffer);
|
sformatf_buffer = (char *) free_check_null(sformatf_buffer);
|
||||||
return (OK);
|
return (OK);
|
||||||
@ -3145,7 +3139,7 @@ logk_search(const char *name_in)
|
|||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Function locates the string "name" in the hash table for logk.
|
* Function locates the string "name" in the map for logk.
|
||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
* name input, character string to be found in "logk".
|
* name input, character string to be found in "logk".
|
||||||
|
|||||||
@ -163,7 +163,7 @@ calc_rho_0(LDBLE tc, LDBLE pa)
|
|||||||
Wagner and Pruss, 2002, JPCRD 31, 387, eqn. 2.6, along the saturation pressure line +
|
Wagner and Pruss, 2002, JPCRD 31, 387, eqn. 2.6, along the saturation pressure line +
|
||||||
interpolation 0 - 300 oC, 0.006 - 1000 atm...
|
interpolation 0 - 300 oC, 0.006 - 1000 atm...
|
||||||
*/
|
*/
|
||||||
if (llnl_count_temp > 0) return OK;
|
if (llnl_temp.size() > 0) return OK;
|
||||||
if (tc > 350.)
|
if (tc > 350.)
|
||||||
{
|
{
|
||||||
if (need_temp_msg < 1)
|
if (need_temp_msg < 1)
|
||||||
@ -223,7 +223,7 @@ calc_dielectrics(LDBLE tc, LDBLE pa)
|
|||||||
and Fernandez et al., 1997, JPCRD 26, 1125, show its correctness)
|
and Fernandez et al., 1997, JPCRD 26, 1125, show its correctness)
|
||||||
+ d(eps)/d(P), Debye-Hueckel A and B, and Av (for Av, see Pitzer et al., 1984, JPCRD 13, p. 4)
|
+ d(eps)/d(P), Debye-Hueckel A and B, and Av (for Av, see Pitzer et al., 1984, JPCRD 13, p. 4)
|
||||||
*/
|
*/
|
||||||
if (llnl_count_temp > 0) return OK;
|
if (llnl_temp.size() > 0) return OK;
|
||||||
if (tc > 350.)
|
if (tc > 350.)
|
||||||
{
|
{
|
||||||
tc = 350.;
|
tc = 350.;
|
||||||
@ -1449,41 +1449,8 @@ status(int count, const char *str, bool rk_string)
|
|||||||
return (OK);
|
return (OK);
|
||||||
}
|
}
|
||||||
#endif /*PHREEQCI_GUI */
|
#endif /*PHREEQCI_GUI */
|
||||||
/*
|
|
||||||
** Dynamic hashing, after CACM April 1988 pp 446-457, by Per-Ake Larson.
|
|
||||||
** Coded into C, with minor code improvements, and with hsearch(3) interface,
|
|
||||||
** by ejp@ausmelb.oz, Jul 26, 1988: 13:16;
|
|
||||||
** also, hcreate/hdestroy routines added to simulate hsearch(3).
|
|
||||||
**
|
|
||||||
** These routines simulate hsearch(3) and family, with the important
|
|
||||||
** difference that the hash table is dynamic - can grow indefinitely
|
|
||||||
** beyond its original size (as supplied to hcreate()).
|
|
||||||
**
|
|
||||||
** Performance appears to be comparable to that of hsearch(3).
|
|
||||||
** The 'source-code' options referred to in hsearch(3)'s 'man' page
|
|
||||||
** are not implemented; otherwise functionality is identical.
|
|
||||||
**
|
|
||||||
** Compilation controls:
|
|
||||||
** DEBUG controls some informative traces, mainly for debugging.
|
|
||||||
** HASH_STATISTICS causes HashAccesses and HashCollisions to be maintained;
|
|
||||||
** when combined with DEBUG, these are displayed by hdestroy().
|
|
||||||
**
|
|
||||||
** Problems & fixes to ejp@ausmelb.oz. WARNING: relies on pre-processor
|
|
||||||
** concatenation property, in probably unnecessary code 'optimisation'.
|
|
||||||
** Esmond Pitt, Austec (Asia/Pacific) Ltd
|
|
||||||
** ...!uunet.UU.NET!munnari!ausmelb!ejp,ejp@ausmelb.oz
|
|
||||||
*/
|
|
||||||
|
|
||||||
# include <assert.h>
|
# include <assert.h>
|
||||||
|
|
||||||
/*
|
|
||||||
** Fast arithmetic, relying on powers of 2,
|
|
||||||
** and on pre-processor concatenation property
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* rewrote to remove MUL and DIV */
|
|
||||||
//# define MOD(x,y) ((x) & ((y)-1))
|
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
int Phreeqc::
|
int Phreeqc::
|
||||||
string_trim(char *str)
|
string_trim(char *str)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user