Merge commit '5688f837474cd7cda50564e379d291e9944a89fc'

This commit is contained in:
Darth Vader 2021-03-18 05:44:05 +00:00
commit 547b0e3462
49 changed files with 1060 additions and 7692 deletions

View File

@ -368,18 +368,6 @@ ChartObject::Read(CParser & parser)
this->chart_type = 1;
break;
case 10: /* grid_offset */
#ifdef PHREEQ98
/*
i = copy_token(token, &next_char, &l);
str_tolower(token);
if (i == DIGIT)
sscanf(token, "%d", &RowOffset);
i = copy_token(token, &next_char, &l);
str_tolower(token);
if (i == DIGIT)
sscanf(token, "%d", &ColumnOffset);
*/
#endif
break;
case 11: /* connect_simulations */
this->connect_simulations = parser.get_true_false(next_char, true);

View File

@ -31,68 +31,6 @@ cxxExchComp::cxxExchComp(PHRQ_io *io)
phase_proportion = 0.0;
formula_z = 0.0;
}
#ifdef SKIP
cxxExchComp::cxxExchComp(std::vector < cxxExchComp > &ec_vector,
std::vector < LDBLE >&f_vector)
//
// constructor for cxxExchComp from mixing
//
{
if (ec_vector.size() <= 0)
return;
//
// check consistency
//
std::vector < LDBLE >::iterator it_f;
std::vector < cxxExchComp >::iterator it_ec;
// set fixed variables
it_ec = ec_vector.begin();
this->formula = it_ec->formula;
this->formula_totals = it_ec->formula_totals;
this->formula_z = it_ec->formula_z;
this->phase_name = it_ec->phase_name;
this->rate_name = it_ec->rate_name;
it_ec++;
for (; it_ec != ec_vector.end(); it_ec++)
{
if (it_ec->formula != this->formula ||
it_ec->formula_z != this->formula_z ||
it_ec->phase_name != this->phase_name ||
this->rate_name != this->rate_name)
{
error_msg
("Mixing exchange components. Formula, z, phase_name, or rate_name did not match",
STOP);
}
}
// calculate sum of extensive factors
LDBLE sum_extensive = 0;
for (it_f = f_vector.begin(); it_f != f_vector.end(); it_f++)
{
sum_extensive += *it_f;
}
this->moles = 0;
this->la = 0;
this->charge_balance = 0;
this->phase_proportion = 0;
this->totals.clear();
this->totals.type = cxxNameDouble::ND_ELT_MOLES;
it_ec = ec_vector.begin();
it_f = f_vector.begin();
for (; it_ec != ec_vector.end();)
{
LDBLE extensive = *it_f;
LDBLE intensive = extensive / sum_extensive;
this->moles += it_ec->moles * extensive;
this->la += it_ec->la * intensive;
this->charge_balance += it_ec->charge_balance * extensive;
this->phase_proportion += it_ec->phase_proportion * intensive;
this->totals.add_extensive(it_ec->totals, extensive);
it_ec++;
it_f++;
}
}
#endif
cxxExchComp::~cxxExchComp()
{
}

View File

@ -118,40 +118,6 @@ cxxExchange::dump_xml(std::ostream & s_oss, unsigned int indent) const
return;
}
#ifdef SKIP
void
cxxExchange::dump_xml(std::ostream & s_oss, unsigned int indent) const
{
unsigned int i;
s_oss.precision(DBL_DIG - 1);
std::string indent0(""), indent1(""), indent2("");
for (i = 0; i < indent; ++i)
indent0.append(Utilities::INDENT);
for (i = 0; i < indent + 1; ++i)
indent1.append(Utilities::INDENT);
for (i = 0; i < indent + 2; ++i)
indent2.append(Utilities::INDENT);
// Exchange element and attributes
s_oss << indent0;
s_oss << "<exchange " << "\n";
s_oss << indent1;
s_oss << "pitzer_exchange_gammas=\"" << this->
pitzer_exchange_gammas << "\"" << "\n";
// components
s_oss << indent1;
s_oss << "<component " << "\n";
for (std::map < std::string, cxxExchComp >::const_iterator it = exchComps.begin();
it != exchComps.end(); ++it)
{
(*it).second.dump_xml(s_oss, indent + 2);
}
return;
}
#endif
void
cxxExchange::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out) const
{

View File

@ -36,88 +36,6 @@ cxxGasPhase::cxxGasPhase(PHRQ_io * io)
pr_in = false;
temperature = 298.15;
}
#ifdef SKIP
cxxGasPhase::cxxGasPhase(std::map < int, cxxGasPhase > &entity_map,
cxxMix & mx, int l_n_user, PHRQ_io * io)
: cxxNumKeyword(io)
{
this->n_user = this->n_user_end = l_n_user;
total_p = 0;
volume = 0;
v_m = 0;
pr_in = false;
bool first = true;
//
// Mix
//
// accumulate in map
std::map<std::string, cxxGasComp> comp_map;
std::map<std::string, cxxGasComp>::iterator comp_it;
const std::map < int, LDBLE > & mixcomps = mx.Get_mixComps();
std::map < int, LDBLE >::const_iterator it;
for (it = mixcomps.begin(); it != mixcomps.end(); it++)
{
const cxxGasPhase *entity_ptr = &(entity_map.find(it->first)->second);
if (first)
{
this->new_def = entity_ptr->new_def;
this->solution_equilibria = entity_ptr->solution_equilibria;
this->n_solution = entity_ptr->n_solution;
this->type = entity_ptr->type;
this->total_p = entity_ptr->total_p * it->second;
this->total_moles = entity_ptr->total_moles * it->second;
this->volume = entity_ptr->volume * it->second;
this->v_m = entity_ptr->v_m * it->second;
this->pr_in = entity_ptr->pr_in;
this->temperature = entity_ptr->temperature;
first = false;
}
else
{
if (this->type != entity_ptr->type)
{
std::ostringstream oss;
oss << "Cannot mix two gas_phases with differing types.";
error_msg(oss.str().c_str(), CONTINUE);
return;
}
this->total_p += entity_ptr->total_p * it->second;
this->volume += entity_ptr->volume * it->second;
this->v_m += entity_ptr->v_m * it->second;
}
cxxGasPhase *gas_phase_ptr = Utilities::Rxn_find(entity_map, it->first);
if (gas_phase_ptr)
{
std::vector<cxxGasComp> add_comps = gas_phase_ptr->Get_gas_comps();
for (size_t i = 0; i < add_comps.size(); i++)
{
comp_it = comp_map.find(add_comps[i].Get_phase_name());
if (comp_it != comp_map.end())
{
comp_it->second.add(add_comps[i], it->second);
}
else
{
cxxGasComp gc(add_comps[i]);
gc.multiply(it->second);
comp_map[add_comps[i].Get_phase_name()] = gc;
}
}
}
}
// put map into vector
this->gas_comps.clear();
std::vector<cxxGasComp> gc;
for (comp_it = comp_map.begin(); comp_it != comp_map.end(); comp_it++)
{
this->gas_comps.push_back(comp_it->second);
}
}
#endif
cxxGasPhase::cxxGasPhase(std::map < int, cxxGasPhase > &entity_map,
cxxMix & mx, int l_n_user, PHRQ_io * io)
: cxxNumKeyword(io)
@ -226,102 +144,10 @@ cxxGasPhase::cxxGasPhase(std::map < int, cxxGasPhase > &entity_map,
this->gas_comps.push_back(comp_it->second);
}
}
#ifdef SKIP
cxxGasPhase::cxxGasPhase(const std::map < int, cxxGasPhase > &entities,
cxxMix & mix, int l_n_user, PHRQ_io * io):
cxxNumKeyword(io)
{
this->n_user = this->n_user_end = l_n_user;
gasPhaseComps.type = cxxNameDouble::ND_NAME_COEF;
total_p = 0;
volume = 0;
v_m = 0;
pr_in = false;
bool first = true;
//
// Mix
//
//cxxNameDouble gasPhaseComps;
const std::map < int, LDBLE > & mixcomps = mix.Get_mixComps();
std::map < int, LDBLE >::const_iterator it;
for (it = mixcomps.begin(); it != mixcomps.end(); it++)
{
if (entities.find(it->first) != entities.end())
{
const cxxGasPhase *entity_ptr =
&(entities.find(it->first)->second);
this->gasPhaseComps.add_extensive(entity_ptr->gasPhaseComps,
it->second);
//GP_TYPE type;
//LDBLE total_p;
//LDBLE volume;
if (first)
{
this->type = entity_ptr->type;
this->total_p = entity_ptr->total_p * it->second;
this->volume = entity_ptr->volume * it->second;
this->v_m = entity_ptr->v_m * it->second;
this->pr_in = entity_ptr->pr_in;
first = false;
}
else
{
if (this->type != entity_ptr->type)
{
std::ostringstream oss;
oss << "Cannot mix two gas_phases with differing types.";
error_msg(oss.str().c_str(), CONTINUE);
//input_error++;
return;
}
this->total_p += entity_ptr->total_p * it->second;
this->volume += entity_ptr->volume * it->second;
this->v_m += entity_ptr->v_m * it->second;
}
}
}
}
#endif
cxxGasPhase::~cxxGasPhase()
{
}
#ifdef SKIP
void
cxxGasPhase::dump_xml(std::ostream & s_oss, unsigned int indent) const const
{
unsigned int i;
s_oss.precision(DBL_DIG - 1);
std::string indent0(""), indent1(""), indent2("");
for (i = 0; i < indent; ++i)
indent0.append(Utilities::INDENT);
for (i = 0; i < indent + 1; ++i)
indent1.append(Utilities::INDENT);
for (i = 0; i < indent + 2; ++i)
indent2.append(Utilities::INDENT);
// GasPhase element and attributes
s_oss << indent0;
s_oss << "<gas_phase " << "\n";
s_oss << indent1;
s_oss << "pitzer_gas_phase_gammas=\"" << this->
pitzer_gas_phase_gammas << "\"" << "\n";
// components
s_oss << indent1;
s_oss << "<component " << "\n";
for (std::list < cxxGasPhaseComp >::const_iterator it =
gas_phaseComps.begin(); it != gas_phaseComps.end(); ++it)
{
it->dump_xml(s_oss, indent + 2);
}
return;
}
#endif
void
cxxGasPhase::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out) const
{

View File

@ -31,179 +31,3 @@ units("mMol/kgw")
cxxISolution::~cxxISolution()
{
}
#ifdef SKIP_OR_MOVE_TO_STRUCTURES
void
cxxISolution::ConvertUnits(Phreeqc * phreeqc_ptr)
//
// Converts from input units to moles per kilogram water
//
{
LDBLE sum_solutes = 0;
// foreach conc
std::map < std::string, cxxISolutionComp >::iterator iter =
this->comps.begin();
for (; iter != this->comps.end(); ++iter)
{
struct master *master_ptr = phreeqc_ptr-> master_bsearch(iter->first.c_str());
if (master_ptr != NULL && (master_ptr->minor_isotope == TRUE))
continue;
//if (iter->second.Get_description() == "H(1)" || iter->second.Get_description() == "E") continue;
if (strcmp(iter->second.Get_description().c_str(), "H(1)") == 0
|| strcmp(iter->second.Get_description().c_str(), "E"))
continue;
if (iter->second.get_input_conc() <= 0.0)
continue;
/*
* Convert liters to kg solution
*/
LDBLE moles = iter->second.get_input_conc();
if (this->units.find("/l") != std::string::npos)
{
moles /= this->density;
}
/*
* Convert to moles
*/
//set gfw for element
iter->second.set_gfw(phreeqc_ptr);
// convert to moles
if (iter->second.get_units().find("g/") != std::string::npos)
{
if (iter->second.get_gfw() != 0)
{
moles /= iter->second.get_gfw();
}
else
{
std::ostringstream oss;
oss << "Could not find gfw, " << iter->second.
Get_description();
error_msg(oss.str().c_str(), CONTINUE);
}
}
/*
* Convert milli or micro
*/
char c = iter->second.get_units().c_str()[0];
if (c == 'm')
{
moles *= 1e-3;
}
else if (c == 'u')
{
moles *= 1e-6;
}
iter->second.set_moles(moles);
/*
* Sum grams of solute, convert from moles necessary
*/
sum_solutes += moles * (iter->second.get_gfw());
}
/*
* Convert /kgs to /kgw
*/
LDBLE l_mass_water;
if ((this->units.find("kgs") != std::string::npos) ||
(this->units.find("/l") != std::string::npos))
{
l_mass_water = 1.0 - 1e-3 * sum_solutes;
for (; iter != this->comps.end(); ++iter)
{
iter->second.set_moles(iter->second.get_moles() / l_mass_water);
}
}
/*
* Scale by mass of water in solution
*/
l_mass_water = this->mass_water;
for (; iter != this->comps.end(); ++iter)
{
iter->second.set_moles(iter->second.get_moles() * l_mass_water);
}
}
#endif
#ifdef SKIP
void
cxxISolution::dump_xml(std::ostream & os, unsigned int indent) const const
{
unsigned int i;
for (i = 0; i < indent; ++i)
os << Utilities::INDENT;
os << "<solution>\n";
cxxNumKeyword::dump_xml(os, indent);
for (i = 0; i < indent + 1; ++i)
os << Utilities::INDENT;
os << "<temp>" << this->get_tc() << "</temp>" << "\n";
for (i = 0; i < indent + 1; ++i)
os << Utilities::INDENT;
os << "<pH>" << this->get_ph() << "</pH>" << "\n";
for (i = 0; i < indent + 1; ++i)
os << Utilities::INDENT;
os << "<pe>" << this->get_solution_pe() << "</pe>" << "\n";
assert(this->pe.size() > 0);
assert(this->default_pe >= 0);
assert(this->pe.size() > (unsigned int) this->default_pe);
for (i = 0; i < indent + 1; ++i)
os << Utilities::INDENT;
os << "<units>" << this->get_units() << "</units>" << "\n";
for (i = 0; i < indent + 1; ++i)
os << Utilities::INDENT;
os << "<density>" << this->get_density() << "</density>" << "\n";
// foreach conc
if (!this->totals.empty())
{
for (i = 0; i < indent + 1; ++i)
os << Utilities::INDENT;
os << "<totals>\n";
std::vector < cxxISolutionComp >::const_iterator iter =
this->totals.begin();
for (; iter != this->totals.end(); ++iter)
{
(*iter).dump_xml(*this, os, indent + 2);
}
for (i = 0; i < indent + 1; ++i)
os << Utilities::INDENT;
os << "</totals>\n";
}
// foreach isotope
if (!this->isotopes.empty())
{
for (i = 0; i < indent + 1; ++i)
os << Utilities::INDENT;
os << "<isotopes>\n";
std::list < cxxIsotope >::const_iterator iter =
this->isotopes.begin();
for (; iter != this->isotopes.end(); ++iter)
{
(*iter).dump_xml(os, indent + 2);
}
for (i = 0; i < indent + 1; ++i)
os << Utilities::INDENT;
os << "</isotopes>\n";
}
for (i = 0; i < indent + 1; ++i)
os << Utilities::INDENT;
os << "<water>" << this->get_mass_water() << "</water>" << "\n";
for (i = 0; i < indent; ++i)
os << Utilities::INDENT;
os << "</solution>" << "\n";
}
#endif

View File

@ -21,259 +21,6 @@ cxxISolutionComp::~cxxISolutionComp(void)
{
}
#ifdef SKIP_OR_MOVE_TO_STRUCTURES
struct conc *
cxxISolutionComp::cxxISolutionComp2conc(Phreeqc * phreeqc_ptr, const std::map < std::string,
cxxISolutionComp > &totals)
// for ISolutions
// takes a std::vector cxxISolutionComp structures
// returns list of conc structures
{
struct conc *c;
c = (struct conc *)
phreeqc_ptr-> PHRQ_malloc((size_t) ((totals.size() + 1) * sizeof(struct conc)));
if (c == NULL)
phreeqc_ptr-> malloc_error();
int i = 0;
for (std::map < std::string, cxxISolutionComp >::const_iterator it = totals.begin();
it != totals.end(); ++it)
{
c[i].description = phreeqc_ptr-> string_duplicate(it->second.description.c_str());
c[i].moles = it->second.moles;
c[i].input_conc = it->second.input_conc;
if (it->second.units.size() == 0)
c[i].units = NULL;
else
c[i].units = phreeqc_ptr-> string_hsave(it->second.units.c_str());
if (it->second.equation_name.size() == 0)
c[i].equation_name = NULL;
else
c[i].equation_name = phreeqc_ptr-> string_hsave(it->second.equation_name.c_str());
c[i].phase_si = it->second.phase_si;
c[i].n_pe = it->second.n_pe;
c[i].as = phreeqc_ptr-> string_hsave(it->second.as.c_str());
c[i].gfw = it->second.gfw;
//c[i].skip = 0;
c[i].phase = NULL;
i++;
}
c[i].description = NULL;
return (c);
}
#endif
#ifdef SKIP_OR_MOVE_TO_STRUCTURES
void
cxxISolutionComp::set_gfw(Phreeqc * phreeqc_ptr)
{
// return gfw
if (this->gfw > 0.0)
return;
// calculate gfw from as or from master species gfw
if (this->as.size() != 0)
{
/* use given chemical formula to calculate gfw */
LDBLE l_gfw;
if (phreeqc_ptr-> compute_gfw(this->as.c_str(), &l_gfw) == ERROR)
{
std::ostringstream oss;
oss << "Could not compute gfw, " << this->as;
error_msg(oss.str().c_str(), CONTINUE);
return;
}
//if (this->description == "Alkalinity" && this->as == "CaCO3")
if (strcmp(this->description.c_str(), "Alkalinity") == 0
&& strcmp(this->as.c_str(), "CaCO3"))
{
l_gfw /= 2.;
}
this->gfw = l_gfw;
return;
}
/* use gfw of master species */
std::string str(this->description);
struct master *master_ptr = phreeqc_ptr-> master_bsearch(str.c_str());
if (master_ptr != NULL)
{
/* use gfw for element redox state */
this->gfw = master_ptr->gfw;
return;
}
std::ostringstream oss;
oss << "Could not find gfw, " << this->description;
error_msg(oss.str().c_str(), CONTINUE);
return;
}
#endif
#ifdef SKIP
cxxISolutionComp::STATUS_TYPE cxxISolutionComp::read(CParser & parser,
cxxISolution & solution)
{
// std::string& str = parser.line();
std::string str = parser.line();
// defaults set in ctor
// Remove space between "kg" and "solution" or "water" in units
Utilities::replace("Kg", "kg", str);
Utilities::replace("KG", "kg", str);
while (Utilities::replace("kg ", "kg", str));
std::istream::pos_type ptr = 0;
//
// Read master species list for mass balance equation
//
std::string token;
std::string token1;
int
count_redox_states = 0;
CParser::TOKEN_TYPE j;
while (((j = parser.copy_token(token, ptr)) == CParser::TT_UPPER) ||
(token[0] == '[') ||
(Utilities::strcmp_nocase_arg1(token.c_str(), "ph") == 0) ||
(Utilities::strcmp_nocase_arg1(token.c_str(), "pe") == 0))
{
++count_redox_states;
Utilities::replace("(+", "(", token);
if (count_redox_states > 1)
token1 += " ";
token1 += token;
}
if (count_redox_states == 0)
{
parser.incr_input_error();
parser.
error_msg
("No element or master species given for concentration input.",
PHRQ_io::OT_CONTINUE);
return cxxISolutionComp::ERROR;
}
description = token1;
// Determine if reading alkalinity, allow equivalents for units
Utilities::str_tolower(token1);
bool
alk = false;
if (token1.find("alk") == 0)
{
alk = true;
}
// Read concentration
if (!(std::istringstream(token) >> this->input_conc))
{
std::ostringstream err;
err << "Concentration data error for " << token1 <<
" in solution input.";
parser.error_msg(err, PHRQ_io::OT_CONTINUE);
return cxxISolutionComp::ERROR;
}
if ((j = parser.copy_token(token, ptr)) == CParser::TT_EMPTY)
return cxxISolutionComp::OK;
// Read optional data
token1 = token;
// Check for units info
if (parser.check_units(token1, alk, false, solution.get_units(), false) ==
CParser::OK)
{
if (parser.
check_units(token1, alk, false, solution.get_units(),
true) == CParser::OK)
{
this->units = token1;
if ((j = parser.copy_token(token, ptr)) == CParser::TT_EMPTY)
return cxxISolutionComp::OK;
}
else
{
return cxxISolutionComp::ERROR;
}
}
// Check for "as" followed by formula to be used for gfw
token1 = token;
Utilities::str_tolower(token1);
if (token1.compare("as") == 0)
{
parser.copy_token(token, ptr);
this->as = token;
if ((j = parser.copy_token(token, ptr)) == CParser::TT_EMPTY)
return cxxISolutionComp::OK;
}
// Check for "gfw" followed by gram formula weight
else if (token1.compare("gfw") == 0)
{
if (parser.copy_token(token, ptr) != CParser::TT_DIGIT)
{
parser.error_msg("Expecting gram formula weight.",
PHRQ_io::OT_CONTINUE);
return cxxISolutionComp::ERROR;
}
else
{
parser.get_iss() >> this->gfw;
if ((j = parser.copy_token(token, ptr)) == CParser::TT_EMPTY)
return cxxISolutionComp::OK;
}
}
// Check for redox couple for pe
if (Utilities::strcmp_nocase_arg1(token.c_str(), "pe") == 0)
{
this->n_pe = cxxPe_Data::store(solution.pe, token);
if ((j = parser.copy_token(token, ptr)) == CParser::TT_EMPTY)
return cxxISolutionComp::OK;
}
else if (token.find("/") != std::string::npos)
{
if (parser.parse_couple(token) == CParser::OK)
{
this->n_pe = cxxPe_Data::store(solution.pe, token);
if ((j = parser.copy_token(token, ptr)) == CParser::TT_EMPTY)
return cxxISolutionComp::OK;
}
else
{
return cxxISolutionComp::ERROR;
}
}
// Must have phase
this->equation_name = token;
if ((j = parser.copy_token(token, ptr)) == CParser::TT_EMPTY)
return cxxISolutionComp::OK;
// Check for saturation index
if (!(std::istringstream(token) >> this->phase_si))
{
parser.error_msg("Expected saturation index.", PHRQ_io::OT_CONTINUE);
return cxxISolutionComp::ERROR;
}
return cxxISolutionComp::OK;
}
#endif
#ifdef SKIP
void
cxxISolutionComp::dump_xml(std::ostream & s_oss, unsigned int indent) const const
{
unsigned int i;
std::string indent0("");
for (i = 0; i < indent; ++i)
indent0.append(Utilities::INDENT);
s_oss << indent0;
s_oss << "<soln_total";
s_oss << " conc_desc=\"" << this->description << "\"";
s_oss << " conc_moles=\"" << this->moles << "\"";
s_oss << "\">" << "\n";
}
#endif
/* ---------------------------------------------------------------------- */
CParser::STATUS_TYPE cxxISolutionComp::
read(const char *line_in, cxxSolution *solution_ptr)
@ -397,7 +144,7 @@ read(const char *line_in, cxxSolution *solution_ptr)
}
else
{
sscanf(token.c_str(), SCANFORMAT, &this->gfw);
(void)sscanf(token.c_str(), SCANFORMAT, &this->gfw);
if ((CParser::copy_token(token, b, e)) == CParser::TT_EMPTY)
return (CParser::PARSER_OK);
}

View File

@ -36,51 +36,6 @@ cxxKineticsComp::~cxxKineticsComp()
{
}
#ifdef SKIP
void
cxxKineticsComp::dump_xml(std::ostream & s_oss, unsigned int indent) const const
{
unsigned int i;
s_oss.precision(DBL_DIG - 1);
std::string indent0(""), indent1(""), indent2("");
for (i = 0; i < indent; ++i)
indent0.append(Utilities::INDENT);
for (i = 0; i < indent + 1; ++i)
indent1.append(Utilities::INDENT);
for (i = 0; i < indent + 2; ++i)
indent2.append(Utilities::INDENT);
// Kinetics_Comp element and attributes
s_oss << indent0 << "formula=\"" << this->formula << "\"" << "\n";
s_oss << indent0 << "moles=\"" << this->moles << "\"" << "\n";
s_oss << indent0 << "la=\"" << this->la << "\"" << "\n";
s_oss << indent0 << "charge_balance=\"" << this->
charge_balance << "\"" << "\n";
if (this->phase_name != NULL)
{
s_oss << indent0 << "phase_name=\"" << this->
phase_name << "\"" << "\n";
}
if (this->rate_name != NULL)
{
s_oss << indent0 << "rate_name=\"" << this->
rate_name << "\"" << "\n";
}
s_oss << indent0 << "phase_proportion=\"" << this->
phase_proportion << "\"" << "\n";
// totals
s_oss << indent0;
s_oss << "<totals " << "\n";
this->totals.dump_xml(s_oss, indent + 1);
// formula_totals
s_oss << indent0;
s_oss << "<formula_totals " << "\n";
this->formula_totals.dump_xml(s_oss, indent + 1);
}
#endif
void
cxxKineticsComp::dump_raw(std::ostream & s_oss, unsigned int indent) const
{
@ -233,7 +188,7 @@ cxxKineticsComp::read_raw(CParser & parser, bool check)
while (parser.copy_token(token, next_char) == CParser::TT_DIGIT)
{
double dd;
sscanf(token.c_str(), "%lf", &dd);
(void)sscanf(token.c_str(), "%lf", &dd);
temp_d_params.push_back((LDBLE) dd);
d_params_defined = true;
}

View File

@ -96,23 +96,6 @@ cxxNameDouble::cxxNameDouble(std::map < std::string, cxxISolutionComp > &comps)
}
this->type = ND_ELT_MOLES;
}
#ifdef SKIP
cxxNameDouble::cxxNameDouble(struct master_activity *ma, int count,
cxxNameDouble::ND_TYPE l_type)
//
// constructor for cxxNameDouble from list of elt_list
//
{
int i;
for (i = 0; i < count; i++)
{
if (ma[i].description == NULL)
continue;
(*this)[ma[i].description] = ma[i].la;
}
this->type = l_type;
}
#endif
cxxNameDouble::cxxNameDouble(struct name_coef *nc, int count)
//
// constructor for cxxNameDouble from list of elt_list
@ -379,38 +362,7 @@ cxxNameDouble::Simplify_redox(void) const
}
return new_totals;
}
#ifdef SKIP
cxxNameDouble
cxxNameDouble::Simplify_redox(void)
{
// remove individual redox states from totals
cxxNameDouble &nd = *this;
std::set<std::string> list_of_elements;
cxxNameDouble::const_iterator it;
for (it = nd.begin(); it != nd.end(); ++it)
{
std::string current_ename(it->first);
std::basic_string < char >::size_type indexCh;
indexCh = current_ename.find("(");
if (indexCh != std::string::npos)
{
current_ename = current_ename.substr(0, indexCh);
}
if (current_ename == "H" || current_ename == "O" || current_ename == "Charge")
continue;
list_of_elements.insert(current_ename);
}
cxxNameDouble new_totals;
new_totals.type = cxxNameDouble::ND_ELT_MOLES;
std::set<std::string>::iterator nt_it = list_of_elements.begin();
for( ; nt_it != list_of_elements.end(); nt_it++)
{
new_totals[(*nt_it).c_str()] = nd.Get_total_element((*nt_it).c_str());
}
return new_totals;
}
#endif
void
cxxNameDouble::Multiply_activities_redox(std::string str, LDBLE f)
{
@ -439,34 +391,6 @@ cxxNameDouble::Multiply_activities_redox(std::string str, LDBLE f)
if (str[0] < it->first[0]) break;
}
}
#ifdef SKIP
void
cxxNameDouble::Multiply_activities_redox(std::string str, LDBLE f)
{
// update original master_activities using just computed factors
cxxNameDouble::iterator it;
LDBLE lg_f = log10(f);
std::string redox_name = str;
redox_name.append("(");
for (it = this->begin(); it != this->end(); it++)
{
if (it->first == str)
{
// Found exact match
it->second += lg_f;
}
else
{
// no exact match, current is element name, need to find all valences
if (strstr(it->first.c_str(), redox_name.c_str()) == it->first.c_str())
{
it->second += lg_f;
}
}
}
}
#endif
LDBLE
cxxNameDouble::Get_total_element(const char *string) const
{

View File

@ -2786,8 +2786,9 @@ factor(struct LOC_exec * LINK)
if (parse_all)
{
PhreeqcPtr->sys_tot = 0;
PhreeqcPtr->count_sys = 1000;
int count_sys = PhreeqcPtr->count_sys;
//PhreeqcPtr->count_sys = 1000;
//int count_sys = PhreeqcPtr->count_sys;
size_t count_sys = 1000;
names_arg = (char**)PhreeqcPtr->PHRQ_calloc((size_t)(count_sys + 1), sizeof(char*));
if (names_arg == NULL)
{
@ -2916,8 +2917,9 @@ factor(struct LOC_exec * LINK)
if (parse_all)
{
PhreeqcPtr->sys_tot = 0;
PhreeqcPtr->count_sys = 1000;
int count_sys = PhreeqcPtr->count_sys;
//PhreeqcPtr->count_sys = 1000;
//int count_sys = PhreeqcPtr->count_sys;
int count_sys = 1000;
names_arg = (char **) PhreeqcPtr->PHRQ_calloc((size_t) (count_sys + 1), sizeof(char *));
if (names_arg == NULL)
{
@ -3482,35 +3484,6 @@ factor(struct LOC_exec * LINK)
break;
}
n.UU.val = PhreeqcPtr->solution_number();
#ifdef SKIP
if (PhreeqcPtr->state == TRANSPORT)
{
n.UU.val = PhreeqcPtr->cell_no;
}
else if (PhreeqcPtr->state == PHAST)
{
n.UU.val = PhreeqcPtr->cell_no;
}
else if (PhreeqcPtr->state == ADVECTION)
{
n.UU.val = PhreeqcPtr->cell_no;
}
else if (PhreeqcPtr->state < REACTION)
{
n.UU.val = PhreeqcPtr->use.Get_solution_ptr()->Get_n_user();
}
else
{
if (PhreeqcPtr->use.Get_mix_in())
{
n.UU.val = PhreeqcPtr->use.Get_n_mix_user();
}
else
{
n.UU.val = PhreeqcPtr->use.Get_n_solution_user();
}
}
#endif
break;
case toksim_no:
@ -4560,21 +4533,6 @@ findline(long n)
l = l->next;
return l;
}
#ifdef SKIP
linerec * PBasic::
mustfindline(long n)
{
linerec *l;
l = findline(n);
if (l == NULL)
{
char * error_string = PhreeqcPtr->sformatf( "Undefined line %ld", n);
errormsg(error_string);
}
return l;
}
#endif
linerec * PBasic::
mustfindline(long n)
{
@ -7316,27 +7274,6 @@ _Escape(int code)
throw PBasicStop();
// following not used
#ifdef SKIP
char l_buf[100];
char token[200], empty[2] = { "\0" };
if (code == 0)
/* exit(EXIT_SUCCESS); */
error_msg("Exit success in Basic", STOP);
if (code == -1)
{
error_msg("Fatal error in Basic interpreter.", CONTINUE);
sprintf(token, "%s",
_ShowEscape(l_buf, P_escapecode, P_ioresult, empty));
error_msg(token, STOP);
exit(EXIT_FAILURE);
}
/* fprintf(stderr, "%s\n", _ShowEscape(l_buf, P_escapecode, P_ioresult, "")); */
/* exit(EXIT_FAILURE); */
error_msg("Fatal error in Basic interpreter.", CONTINUE);
sprintf(token, "%s", _ShowEscape(l_buf, P_escapecode, P_ioresult, empty));
error_msg(token, STOP);
return (1);
#endif
}
int PBasic::

View File

@ -479,9 +479,6 @@ public:
int basic_compile(char *commands, void **lnbase, void **vbase, void **lpbase);
int basic_run(char *commands, void *lnbase, void *vbase, void *lpbase);
int basic_init(void);
#ifdef PHREEQ98
void GridChar(char *s, char *a);
#endif
int sget_logical_line(char **ptr, int *l, char *return_line);
long my_labs(long x);
void * my_memmove(void * d, Const void * s, size_t n);

View File

@ -300,29 +300,6 @@ cxxPPassemblage::add(const cxxPPassemblage & addee, LDBLE extensive)
//cxxNameDouble eltList;
this->eltList.add_extensive(addee.eltList, extensive);
}
#ifdef SKIP
cxxPPassemblageComp * cxxPPassemblage::
Find(const std::string name_in)
{
std::string name(name_in);
Utilities::str_tolower(name);
cxxPPassemblageComp * comp = NULL;
std::map<std::string, cxxPPassemblageComp>::iterator it;
it = this->pp_assemblage_comps.begin();
for ( ; it != this->pp_assemblage_comps.end(); it++)
{
std::string pname(it->first);
Utilities::str_tolower(pname);
if (name == pname)
{
comp = &it->second;
break;
}
}
return comp;
}
#endif
cxxPPassemblageComp * cxxPPassemblage::
Find(const std::string name_in)
{

View File

@ -473,52 +473,6 @@ void Phreeqc::init(void)
current_selected_output = NULL;
current_user_punch = NULL;
high_precision = false;
#ifdef SKIP
//struct punch punch;
/*
* Initialize punch
*/
punch.in = FALSE;
punch.count_totals = 0;
punch.totals = 0;
punch.count_molalities = 0;
punch.molalities = 0;
punch.count_activities = 0;
punch.activities = 0;
punch.count_pure_phases = 0;
punch.pure_phases = 0;
punch.count_si = 0;
punch.si = 0;
punch.count_gases = 0;
punch.gases = 0;
punch.count_s_s = 0;
punch.s_s = 0;
punch.count_kinetics = 0;
punch.kinetics = 0;
punch.count_isotopes = 0;
punch.isotopes = 0;
punch.count_calculate_values = 0;
punch.calculate_values = 0;
punch.inverse = TRUE;
punch.sim = TRUE;
punch.state = TRUE;
punch.soln = TRUE;
punch.dist = TRUE;
punch.time = TRUE;
punch.step = TRUE;
punch.rxn = FALSE;
punch.temp = FALSE;
punch.ph = TRUE;
punch.pe = TRUE;
punch.alk = FALSE;
punch.mu = FALSE;
punch.water = FALSE;
punch.high_precision = FALSE;
punch.user_punch = TRUE;
punch.charge_balance = FALSE;
punch.percent_error = FALSE;
#endif
MIN_LM = -30.0; /* minimum log molality allowed before molality set to zero */
LOG_ZERO_MOLALITY = -30; /* molalities <= LOG_ZERO_MOLALITY are considered equal to zero */
MIN_RELATED_LOG_ACTIVITY = -30;
@ -550,12 +504,8 @@ void Phreeqc::init(void)
/*----------------------------------------------------------------------
* Save
*---------------------------------------------------------------------- */
count_save_values = 0;
save_values = NULL;
save_init(-1); // set initial save values
// auto use
// copier structures
copy_solution.n_user = copy_solution.start = copy_solution.end = 0;
copy_solution.count = copy_solution.max = 0;
@ -582,7 +532,6 @@ void Phreeqc::init(void)
/*----------------------------------------------------------------------
* Inverse
*---------------------------------------------------------------------- */
inverse = NULL;
count_inverse = 0;
/*----------------------------------------------------------------------
* Mix
@ -616,30 +565,10 @@ void Phreeqc::init(void)
/*----------------------------------------------------------------------
* Species_list
*---------------------------------------------------------------------- */
count_species_list = 0;
max_species_list = 0;
species_list = NULL;
/*----------------------------------------------------------------------
* Jacobian and Mass balance lists
*---------------------------------------------------------------------- */
count_sum_jacob0 = 0;
max_sum_jacob0 = 0;
sum_jacob0 = NULL;
count_sum_mb1 = 0;
max_sum_mb1 = 0;
sum_mb1 = NULL;
count_sum_jacob1 = 0;
max_sum_jacob1 = 0;
sum_jacob1 = NULL;
count_sum_mb2 = 0;
max_sum_mb2 = 0;
sum_mb2 = NULL;
count_sum_jacob2 = 0;
max_sum_jacob2 = 0;
sum_jacob2 = NULL;
count_sum_delta = 0;
max_sum_delta = 0;
sum_delta = NULL;
/*----------------------------------------------------------------------
* Solution
*---------------------------------------------------------------------- */
@ -757,31 +686,16 @@ void Phreeqc::init(void)
/*----------------------------------------------------------------------
* Elements
*---------------------------------------------------------------------- */
elements = NULL;
count_elements = 0;
max_elements = MAX_ELEMENTS;
element_h_one = NULL;
/*----------------------------------------------------------------------
* Element List
*---------------------------------------------------------------------- */
elt_list = NULL;
count_elts = 0;
max_elts = MAX_ELTS;
/*----------------------------------------------------------------------
* Species
*---------------------------------------------------------------------- */
logk = NULL;
count_logk = 0;
max_logk = MAX_S;
moles_per_kilogram_string= NULL;
pe_string = NULL;
s = NULL;
count_s = 0;
max_s = MAX_S;
// auto s_diff_layer;
s_x = NULL;
count_s_x = 0;
max_s_x = 0;
s_h2o = NULL;
s_hplus = NULL;
s_h3oplus = NULL;
@ -792,20 +706,14 @@ void Phreeqc::init(void)
/*----------------------------------------------------------------------
* Phases
*---------------------------------------------------------------------- */
phases = NULL;
count_phases = 0;
max_phases = MAX_PHASES;
/*----------------------------------------------------------------------
* Master species
*---------------------------------------------------------------------- */
master = NULL;
dbg_master = NULL;
count_master = 0;
max_master = MAX_MASTER;
/*----------------------------------------------------------------------
* Unknowns
*---------------------------------------------------------------------- */
x = NULL;
count_unknowns = 0;
max_unknowns = 0;
ah2o_unknown = NULL;
@ -829,7 +737,6 @@ void Phreeqc::init(void)
* Reaction work space
*---------------------------------------------------------------------- */
// struct trxn;
trxn.token = 0;
for (int i = 0; i < MAX_LOG_K_INDICES; i++)
{
trxn.logk[i] = 0;
@ -839,11 +746,7 @@ void Phreeqc::init(void)
trxn.dz[i] = 0;
}
count_trxn = 0;
max_trxn = MAX_TRXN;
mb_unknowns = NULL;
count_mb_unknowns = 0;
max_mb_unknowns = MAX_TRXN;
/* ----------------------------------------------------------------------
* Print
* ---------------------------------------------------------------------- */
@ -891,8 +794,6 @@ void Phreeqc::init(void)
/* ----------------------------------------------------------------------
* RATES
* ---------------------------------------------------------------------- */
rates = NULL;
count_rates = 0;
rate_m = 0;
rate_m0 = 0;
rate_time = 0;
@ -908,11 +809,6 @@ void Phreeqc::init(void)
* USER PRINT COMMANDS
* ---------------------------------------------------------------------- */
user_print = NULL;
#ifdef SKIP
user_punch = NULL;
user_punch_headings = NULL;
user_punch_count_headings = 0;
#endif
n_user_punch_index = 0;
fpunchf_user_s_warning = 0;
fpunchf_user_buffer[0] = 0;
@ -939,9 +835,6 @@ void Phreeqc::init(void)
stop_program = FALSE;
incremental_reactions = FALSE;
count_strings = 0;
my_array = NULL;
delta = NULL;
residual = NULL;
input_error = 0;
next_keyword = Keywords::KEY_NONE;
parse_error = 0;
@ -1029,21 +922,9 @@ void Phreeqc::init(void)
/* ----------------------------------------------------------------------
* ISOTOPES
* ---------------------------------------------------------------------- */
count_master_isotope = 0;
master_isotope = NULL;
max_master_isotope = MAX_ELTS;
initial_solution_isotopes = FALSE;
count_calculate_value = 0;
calculate_value = NULL;
max_calculate_value = MAX_ELTS;
calculate_value_hash_table = NULL;
count_isotope_ratio = 0;
isotope_ratio = 0;
max_isotope_ratio = MAX_ELTS;
isotope_ratio_hash_table = 0;
count_isotope_alpha = 0;
isotope_alpha = 0;
max_isotope_alpha = MAX_ELTS;
isotope_alpha_hash_table = 0;
@ -1053,15 +934,10 @@ void Phreeqc::init(void)
//have_punch_name = FALSE;
print_density = 0;
print_viscosity = 0;
zeros = NULL;
zeros_max = 1;
cell_pore_volume = 0;
cell_volume = 0;
cell_porosity = 0;
cell_saturation = 0;
sys = NULL;
count_sys = 0;
max_sys = 0;
sys_tot = 0;
V_solutes = 0.0;
@ -1229,24 +1105,7 @@ void Phreeqc::init(void)
/* model.cpp ------------------------------- */
gas_in = FALSE;
min_value = 1e-10;
normal = NULL;
ineq_array = NULL;
res = NULL;
cu = NULL;
zero = NULL;
delta1 = NULL;
iu = NULL;
is = NULL;
back_eq = NULL;
normal_max = 0;
ineq_array_max = 0;
res_max = 0;
cu_max = 0;
zero_max = 0;
delta1_max = 0;
iu_max = 0;
is_max = 0;
back_eq_max = 0;
/* phrq_io_output.cpp ------------------------------- */
forward_output_to_log = 0;
/* phreeqc_files.cpp ------------------------------- */
@ -1254,11 +1113,6 @@ void Phreeqc::init(void)
default_data_base = string_duplicate("c:\\phreeqc\\database\\phreeqc.dat");
#else
default_data_base = string_duplicate("phreeqc.dat");
#endif
#ifdef PHREEQ98
int outputlinenr;
char *LogFileNameC;
char progress_str[512];
#endif
/* Pitzer */
pitzer_model = FALSE;
@ -1272,13 +1126,7 @@ void Phreeqc::init(void)
AW = 0;
VP = 0;
DW0 = 0;
pitz_params = NULL;
count_pitz_param = 0;
max_pitz_param = 100;
// auto pitz_param_map
theta_params = 0;
count_theta_param = 0;
max_theta_param = 100;
use_etheta = TRUE;
OTEMP = -100.;
OPRESS = -100.;
@ -1305,28 +1153,12 @@ void Phreeqc::init(void)
BK[i] = 0.0;
DK[i] = 0.0;
}
#ifdef PHREEQ98
int connect_simulations, graph_initial_solutions;
int shifts_as_points;
int chart_type;
int ShowChart;
int RowOffset, ColumnOffset;
#endif
dummy = 0;
/* print.cpp ------------------------------- */
sformatf_buffer = (char *) PHRQ_malloc(256 * sizeof(char));
if (sformatf_buffer == NULL)
malloc_error();
sformatf_buffer_size = 256;
#ifdef PHREEQ98
int colnr, rownr;
int graph_initial_solutions;
int prev_advection_step, prev_transport_step; /*, prev_reaction_step */
/* int shifts_as_points; */
int chart_type;
int AddSeries;
int FirstCallToUSER_GRAPH;
#endif
/* read.cpp */
prev_next_char = NULL;
#if defined PHREEQ98
@ -1340,10 +1172,7 @@ void Phreeqc::init(void)
/* readtr.cpp */
// auto dump_file_name_cpp;
/* sit.cpp ------------------------------- */
sit_params = NULL;
count_sit_param = 0;
max_sit_param = 100;
// auto sit_param_map
sit_A0 = 0;
sit_count_cations = 0;
sit_count_anions = 0;
@ -1390,13 +1219,6 @@ void Phreeqc::init(void)
heat_mix_f_m = 0;
warn_MCD_X = 0;
warn_fixed_Surf = 0;
#ifdef PHREEQ98
int AutoLoadOutputFile, CreateToC;
int ProcessMessages, ShowProgress, ShowProgressWindow, ShowChart;
int outputlinenr;
int stop_calculations;
char err_str98[80];
#endif
/* utilities.cpp ------------------------------- */
spinner = 0;
// keycount;
@ -1499,16 +1321,6 @@ Phreeqc::InternalCopy(const Phreeqc *pSrc)
/*----------------------------------------------------------------------
* Save
*---------------------------------------------------------------------- */
count_save_values = 0;
/*
save_values = NULL;
save_init(-1); // set initial save values
*/
// auto use
// copier structures
//-- skip copier, accept init
/*----------------------------------------------------------------------
* Inverse
@ -1754,32 +1566,20 @@ Phreeqc::InternalCopy(const Phreeqc *pSrc)
/*----------------------------------------------------------------------
* Elements
*---------------------------------------------------------------------- */
//max_elements = pSrc->max_elements;
//elements = (struct element **) free_check_null(elements);
//elements = (struct element **) PHRQ_malloc((size_t)max_elements * sizeof(struct element));
space((void **)((void *)&elements), pSrc->max_elements, &max_elements,
sizeof(struct element *));
count_elements = 0;
for (int i = 0; i < pSrc->count_elements; i++)
for (int i = 0; i < (int)pSrc->elements.size(); i++)
{
string_hsave(pSrc->elements[i]->name);
struct element *elt_ptr = element_store(pSrc->elements[i]->name);
const char * ptr = string_hsave(pSrc->elements[i]->name);
struct element *elt_ptr = element_store(ptr);
elt_ptr->gfw = pSrc->elements[i]->gfw;
}
element_h_one = element_store("H(1)");
/*
elements = NULL;
count_elements = 0;
max_elements = MAX_ELEMENTS;
element_h_one = NULL;
*/
/*----------------------------------------------------------------------
* Element List
*---------------------------------------------------------------------- */
/*
elt_list = NULL;
count_elts = 0;
max_elts = MAX_ELTS;
*/
/*----------------------------------------------------------------------
* Reaction
@ -1812,15 +1612,7 @@ Phreeqc::InternalCopy(const Phreeqc *pSrc)
*/
// logk
space((void **)((void *)&logk), pSrc->max_logk, &max_logk, sizeof(struct logk *));
//for (int i = 0; i < count_logk; i++)
//{
// logk[i] = (struct logk *) free_check_null(logk[i]);
//}
//logk = (struct logk **) free_check_null(logk);
//max_logk = pSrc->max_logk;
//logk = (struct logk **) PHRQ_malloc((size_t) max_logk * sizeof(struct logk *));
for (int i = 0; i < pSrc->count_logk; i++)
for (int i = 0; i < (int)pSrc->logk.size(); i++)
{
char * name = string_duplicate(pSrc->logk[i]->name);
struct logk *logk_ptr = logk_store(name, FALSE);
@ -1840,16 +1632,9 @@ Phreeqc::InternalCopy(const Phreeqc *pSrc)
}
}
}
count_logk = pSrc->count_logk;
// s, species
count_s = 0;
//max_s = pSrc->max_s;
//s = (struct species **) free_check_null(s);
//s = (struct species **) PHRQ_malloc(sizeof(struct species *)*size_t(max_s));
space((void **)((void *)&s), pSrc->max_s, &max_s, sizeof(struct species *));
for (int i = 0; i < pSrc->count_s; i++)
for (int i = 0; i < (int)pSrc->s.size(); i++)
{
struct species *s_ptr = s_store(pSrc->s[i]->name, pSrc->s[i]->z, FALSE);
memcpy(s_ptr, pSrc->s[i], sizeof(struct species));
@ -1933,17 +1718,7 @@ Phreeqc::InternalCopy(const Phreeqc *pSrc)
/*----------------------------------------------------------------------
* Phases
*---------------------------------------------------------------------- */
/*
phases = NULL;
count_phases = 0;
max_phases = MAX_PHASES;
*/
//max_phases = pSrc->max_phases;
//phases = (struct phase **) PHRQ_malloc((size_t)max_phases * sizeof(struct phase));
//space((void **)((void *)&phases), INIT, &max_phases,
// sizeof(struct phase *));
count_phases = 0;
for (int i = 0; i < pSrc->count_phases; i++)
for (int i = 0; i < (int)pSrc->phases.size(); i++)
{
struct phase *phase_ptr = phase_store(pSrc->phases[i]->name);
memcpy(phase_ptr, pSrc->phases[i], sizeof(struct phase));
@ -2007,16 +1782,10 @@ Phreeqc::InternalCopy(const Phreeqc *pSrc)
count_master = 0;
max_master = MAX_MASTER;
*/
count_master = pSrc->count_master;
//max_master = pSrc->max_master;
//master = (struct master **) free_check_null(master);
//master = (struct master **) PHRQ_malloc((size_t) max_master * sizeof(struct master *));
space((void **)((void *)&master), pSrc->max_master, &max_master,
sizeof(struct master *));
if (master == NULL) malloc_error();
dbg_master = master;
for (int i = 0; i < count_master; i++)
int count_master = (int)pSrc->master.size();
for (int i = 0; i < (int)master.size(); i++)
{
master.resize((size_t)i + 1);
master[i] = (struct master *) PHRQ_malloc( sizeof(struct master));
if (master[i] == NULL) malloc_error();
memcpy(master[i], pSrc->master[i], sizeof(struct master));
@ -2084,12 +1853,6 @@ Phreeqc::InternalCopy(const Phreeqc *pSrc)
trxn.dz[i] = 0;
}
count_trxn = 0;
max_trxn = MAX_TRXN;
*/
/*
mb_unknowns = NULL;
count_mb_unknowns = 0;
max_mb_unknowns = MAX_TRXN;
*/
/* ----------------------------------------------------------------------
* Print
@ -2155,21 +1918,16 @@ Phreeqc::InternalCopy(const Phreeqc *pSrc)
// auto rate_p
count_rate_p = 0;
*/
rates = (struct rate *) free_check_null(rates);
count_rates = pSrc->count_rates;
if (count_rates > 0)
for (int i = 0; i < (int)pSrc->rates.size(); i++)
{
rates = (struct rate *) PHRQ_malloc((size_t) count_rates * sizeof(struct rate));
if (rates == NULL) malloc_error();
for (int i = 0; i < count_rates; i++)
{
rates[i].name = string_hsave(pSrc->rates[i].name);
rates[i].commands = string_duplicate(pSrc->rates[i].commands);
rates[i].new_def = TRUE;
rates[i].linebase = NULL;
rates[i].varbase = NULL;
rates[i].loopbase = NULL;
}
size_t count_rates = rates.size();
rates.resize(count_rates + 1);
rates[i].name = string_hsave(pSrc->rates[i].name);
rates[i].commands = string_duplicate(pSrc->rates[i].commands);
rates[i].new_def = TRUE;
rates[i].linebase = NULL;
rates[i].varbase = NULL;
rates[i].loopbase = NULL;
}
/* ----------------------------------------------------------------------
* USER PRINT COMMANDS
@ -2192,38 +1950,6 @@ Phreeqc::InternalCopy(const Phreeqc *pSrc)
}
// For now, User Punch is not copied
#ifdef SKIP
/*
user_punch = NULL;
*/
{
user_punch->name = NULL;
user_punch->commands = NULL;
if (pSrc->user_punch->commands != NULL)
{
user_punch->commands = string_duplicate(pSrc->user_punch->commands);
}
user_punch->new_def = TRUE;
user_punch->linebase = NULL;
user_punch->varbase = NULL;
user_punch->loopbase = NULL;
}
/*
user_punch_headings = NULL;
user_punch_count_headings = 0;
*/
user_punch_count_headings = pSrc->user_punch_count_headings;
if (user_punch_count_headings > 0)
{
user_punch_headings = (const char **) free_check_null(user_punch_headings);
user_punch_headings = (const char **) PHRQ_malloc((size_t) user_punch_count_headings * sizeof(char *));
if (user_punch_headings == NULL) malloc_error();
for (int i = 0; i < user_punch_count_headings; i++)
{
user_punch_headings[i] = string_hsave(pSrc->user_punch_headings[i]);
}
}
#endif
n_user_punch_index = pSrc->n_user_punch_index;
fpunchf_user_s_warning = pSrc->fpunchf_user_s_warning;
//fpunchf_user_buffer[0] = 0;
@ -2408,13 +2134,7 @@ Phreeqc::InternalCopy(const Phreeqc *pSrc)
/* ----------------------------------------------------------------------
* ISOTOPES
* ---------------------------------------------------------------------- */
/*
count_master_isotope = 0;
master_isotope = NULL;
max_master_isotope = MAX_ELTS;
*/
for (int i = 0; i < pSrc->count_master_isotope; i++)
for (int i = 0; i < (int)pSrc->master_isotope.size(); i++)
{
struct master_isotope *master_isotope_ptr = master_isotope_store(pSrc->master_isotope[i]->name, FALSE);
memcpy(master_isotope_ptr, pSrc->master_isotope[i], sizeof(struct master_isotope));
@ -2443,35 +2163,18 @@ Phreeqc::InternalCopy(const Phreeqc *pSrc)
}
}
initial_solution_isotopes = pSrc->initial_solution_isotopes;
/*
count_calculate_value = 0;
calculate_value = NULL;
max_calculate_value = MAX_ELTS;
calculate_value_hash_table = NULL;
*/
for (int i = 0; i < pSrc->count_calculate_value; i++)
for (int i = 0; i < pSrc->calculate_value.size(); i++)
{
struct calculate_value *calculate_value_ptr = calculate_value_store(pSrc->calculate_value[i]->name, FALSE);
//memcpy(calculate_value_ptr, pSrc->calculate_value[i], sizeof(struct calculate_value));
struct calculate_value* calculate_value_ptr = calculate_value_store(pSrc->calculate_value[i]->name, FALSE);
calculate_value_ptr->value = pSrc->calculate_value[i]->value;
//calculate_value_ptr->commands = NULL;
if (pSrc->calculate_value[i]->commands)
{
calculate_value_ptr->commands = string_duplicate(pSrc->calculate_value[i]->commands);
}
//calculate_value_ptr->new_def = TRUE;
//calculate_value_ptr->calculated = FALSE;
//calculate_value_ptr->linebase = NULL;
//calculate_value_ptr->varbase = NULL;
//calculate_value_ptr->loopbase = NULL;
}
/*
count_isotope_ratio = 0;
isotope_ratio = 0;
max_isotope_ratio = MAX_ELTS;
isotope_ratio_hash_table = 0;
*/
for (int i = 0; i < pSrc->count_isotope_ratio; i++)
for (int i = 0; i < (int)pSrc->isotope_ratio.size(); i++)
{
struct isotope_ratio *isotope_ratio_ptr = isotope_ratio_store(pSrc->isotope_ratio[i]->name, FALSE);
isotope_ratio_ptr->name = string_hsave(pSrc->isotope_ratio[i]->name);
@ -2479,13 +2182,8 @@ Phreeqc::InternalCopy(const Phreeqc *pSrc)
isotope_ratio_ptr->ratio = pSrc->isotope_ratio[i]->ratio;
isotope_ratio_ptr->converted_ratio = pSrc->isotope_ratio[i]->converted_ratio;
}
/*
count_isotope_alpha = 0;
isotope_alpha = 0;
max_isotope_alpha = MAX_ELTS;
isotope_alpha_hash_table = 0;
*/
for (int i = 0; i < pSrc->count_isotope_alpha; i++)
for (int i = 0; i < (int)pSrc->isotope_alpha.size(); i++)
{
struct isotope_alpha *isotope_alpha_ptr = isotope_alpha_store(pSrc->isotope_alpha[i]->name, FALSE);
isotope_alpha_ptr->named_logk = string_hsave(pSrc->isotope_alpha[i]->named_logk);
@ -2498,145 +2196,9 @@ Phreeqc::InternalCopy(const Phreeqc *pSrc)
//have_punch_name = pSrc->have_punch_name;
print_density = pSrc->print_density;
print_viscosity = pSrc->print_viscosity;
#ifdef SKIP
LDBLE *zeros;
int zeros_max;
#endif
viscos = pSrc->viscos;
viscos_0 = pSrc->viscos_0;
viscos_0_25 = pSrc->viscos_0_25; // viscosity of the solution, of pure water, of pure water at 25 C
#ifdef SKIP
LDBLE cell_pore_volume;
LDBLE cell_porosity;
LDBLE cell_volume;
LDBLE cell_saturation;
struct system_species *sys;
int count_sys, max_sys;
LDBLE sys_tot;
LDBLE V_solutes, rho_0, rho_0_sat, kappa_0, p_sat/*, ah2o_x0*/;
LDBLE SC; // specific conductance mS/cm
LDBLE eps_r; // relative dielectric permittivity
LDBLE DH_A, DH_B, DH_Av; // Debye-Hueckel A, B and Av
LDBLE QBrn; // Born function d(ln(eps_r))/dP / eps_r * 41.84004, for supcrt calc'n of molal volume
LDBLE ZBrn; // Born function (-1/eps_r + 1) * 41.84004, for supcrt calc'n of molal volume
LDBLE dgdP; // dg / dP, pressure derivative of g-function, for supcrt calc'n of molal volume
int need_temp_msg;
LDBLE solution_mass, solution_volume;
/* phqalloc.cpp ------------------------------- */
PHRQMemHeader *s_pTail;
/* Basic */
PBasic * basic_interpreter;
double(*basic_callback_ptr) (double x1, double x2, const char *str, void *cookie);
void *basic_callback_cookie;
#ifdef IPHREEQC_NO_FORTRAN_MODULE
double(*basic_fortran_callback_ptr) (double *x1, double *x2, char *str, size_t l);
#else
double(*basic_fortran_callback_ptr) (double *x1, double *x2, const char *str, int l);
#endif
#if defined(SWIG) || defined(SWIG_IPHREEQC)
class BasicCallback *basicCallback;
void SetCallback(BasicCallback *cb) { basicCallback = cb; }
#endif
/* cl1.cpp ------------------------------- */
LDBLE *x_arg, *res_arg, *scratch;
int x_arg_max, res_arg_max, scratch_max;
#ifdef SKIP
/* dw.cpp ------------------------------- */
/* COMMON /QQQQ/ */
LDBLE Q0, Q5;
LDBLE GASCON, TZ, AA;
LDBLE Z, DZ, Y;
LDBLE G1, G2, GF;
LDBLE B1, B2, B1T, B2T, B1TT, B2TT;
#endif
/* gases.cpp ------------------------------- */
LDBLE a_aa_sum, b2, b_sum, R_TK;
/* input.cpp ------------------------------- */
int check_line_return;
int reading_db;
/* integrate.cpp ------------------------------- */
LDBLE midpoint_sv;
LDBLE z_global, xd_global, alpha_global;
/* inverse.cpp ------------------------------- */
int max_row_count, max_column_count;
int carbon;
const char **col_name, **row_name;
int count_rows, count_optimize;
int col_phases, col_redox, col_epsilon, col_ph, col_water,
col_isotopes, col_phase_isotopes;
int row_mb, row_fract, row_charge, row_carbon, row_isotopes,
row_epsilon, row_isotope_epsilon, row_water;
LDBLE *inv_zero, *array1, *inv_res, *inv_delta1, *delta2, *delta3, *inv_cu,
*delta_save;
LDBLE *min_delta, *max_delta;
int *inv_iu, *inv_is;
int klmd, nklmd, n2d, kode, iter;
LDBLE toler, error, max_pct, scaled_error;
struct master *master_alk;
int *row_back, *col_back;
unsigned long *good, *bad, *minimal;
int max_good, max_bad, max_minimal;
int count_good, count_bad, count_minimal, count_calls;
unsigned long soln_bits, phase_bits, current_bits, temp_bits;
FILE *netpath_file;
int count_inverse_models, count_pat_solutions;
int min_position[32], max_position[32], now[32];
std::vector <std::string> inverse_heading_names;
/* kinetics.cpp ------------------------------- */
public:
int count_pp, count_pg, count_ss;
void *cvode_kinetics_ptr;
int cvode_test;
int cvode_error;
int cvode_n_user;
int cvode_n_reactions;
realtype cvode_step_fraction;
realtype cvode_rate_sim_time;
realtype cvode_rate_sim_time_start;
realtype cvode_last_good_time;
realtype cvode_prev_good_time;
N_Vector cvode_last_good_y;
N_Vector cvode_prev_good_y;
M_Env kinetics_machEnv;
N_Vector kinetics_y, kinetics_abstol;
void *kinetics_cvode_mem;
cxxSSassemblage *cvode_ss_assemblage_save;
cxxPPassemblage *cvode_pp_assemblage_save;
protected:
LDBLE *m_original;
LDBLE *m_temp;
LDBLE *rk_moles;
int set_and_run_attempt;
LDBLE *x0_moles;
/* model.cpp ------------------------------- */
int gas_in;
LDBLE min_value;
LDBLE *normal, *ineq_array, *res, *cu, *zero, *delta1;
int *iu, *is, *back_eq;
int normal_max, ineq_array_max, res_max, cu_max, zero_max,
delta1_max, iu_max, is_max, back_eq_max;
/* phrq_io_output.cpp ------------------------------- */
int forward_output_to_log;
/* phreeqc_files.cpp ------------------------------- */
char *default_data_base;
#ifdef PHREEQ98
int outputlinenr;
char *LogFileNameC;
char progress_str[512];
#endif
#endif
/* Pitzer */
pitzer_model = pSrc->pitzer_model;
sit_model = pSrc->sit_model;
@ -2654,36 +2216,19 @@ protected:
always_full_pitzer = pSrc->always_full_pitzer;
ICON = pSrc->ICON;
IC = pSrc->IC;
/*
pitz_params = NULL;
count_pitz_param = 0;
max_pitz_param = 100;
*/
for (int i = 0; i < pSrc->count_pitz_param; i++)
for (int i = 0; i < (int)pSrc->pitz_params.size(); i++)
{
pitz_param_store(pSrc->pitz_params[i], true);
}
pitz_param_map = pSrc->pitz_param_map;
// auto pitz_param_map
/*
theta_params = 0;
count_theta_param = 0;
max_theta_param = 100;
use_etheta = TRUE;
*/
count_theta_param = pSrc->count_theta_param;
max_theta_param = count_theta_param;
space((void **)((void *)&theta_params), count_theta_param, &max_theta_param,
sizeof(struct theta_param *));
if (pSrc->theta_params != NULL)
for (int i = 0; i < (int)pSrc->theta_params.size(); i++)
{
//theta_params = (struct theta_param **) malloc((size_t)count_theta_param * sizeof(struct theta_param *));
for (int i = 0; i < count_theta_param; i++)
{
theta_params[i] = theta_param_alloc();
memcpy(theta_params[i], pSrc->theta_params[i], sizeof(struct theta_param));
}
size_t count_theta_params = theta_params.size();
theta_params.resize(count_theta_params + 1);
theta_params[count_theta_params] = theta_param_alloc();
memcpy(theta_params[count_theta_params], pSrc->theta_params[i], sizeof(struct theta_param));
}
use_etheta = pSrc->use_etheta;
/*
@ -2720,14 +2265,6 @@ protected:
DK[i] = 0.0;
}
*/
#ifdef PHREEQ98
int connect_simulations, graph_initial_solutions;
int shifts_as_points;
int chart_type;
int ShowChart;
int RowOffset, ColumnOffset;
#endif
dummy = 0;
/* print.cpp ------------------------------- */
/*
@ -2736,15 +2273,6 @@ protected:
malloc_error();
sformatf_buffer_size = 256;
*/
#ifdef PHREEQ98
int colnr, rownr;
int graph_initial_solutions;
int prev_advection_step, prev_transport_step; /*, prev_reaction_step */
/* int shifts_as_points; */
int chart_type;
int AddSeries;
int FirstCallToUSER_GRAPH;
#endif
/* read.cpp */
prev_next_char = NULL;
#if defined PHREEQ98
@ -2776,12 +2304,7 @@ protected:
sit_M = NULL;
sit_LGAMMA = NULL;
*/
count_sit_param = 0; //pSrc->count_sit_param;
max_sit_param = 1; // count_sit_param;
for (int i = 0; i < pSrc->count_sit_param; i++)
{
sit_param_store(pSrc->sit_params[i], true);
}
sit_params.clear();
sit_param_map = pSrc->sit_param_map;
/* tidy.cpp ------------------------------- */
//a0 = 0;
@ -2825,13 +2348,6 @@ protected:
current_A = pSrc->current_A;
fix_current = pSrc->fix_current;
#ifdef PHREEQ98
int AutoLoadOutputFile, CreateToC;
int ProcessMessages, ShowProgress, ShowProgressWindow, ShowChart;
int outputlinenr;
int stop_calculations;
char err_str98[80];
#endif
/* utilities.cpp ------------------------------- */
//spinner = 0;
//// keycount;

View File

@ -275,15 +275,6 @@ public:
void fpunchf_user(int user_index, const char *format, double d);
void fpunchf_user(int user_index, const char *format, char * d);
int fpunchf_end_row(const char *format);
#ifdef SKIP
// dw.cpp -------------------------------
int BB(LDBLE T);
LDBLE PS(LDBLE T);
LDBLE VLEST(LDBLE T);
int DFIND(LDBLE * DOUT, LDBLE P, LDBLE D, LDBLE T);
int QQ(LDBLE T, LDBLE D);
LDBLE BASE(LDBLE D);
#endif
// input.cpp -------------------------------
int reading_database(void);
void set_reading_database(int reading_database);
@ -552,10 +543,6 @@ public:
int set_pz(int initial);
int calc_pitz_param(struct pitz_param *pz_ptr, LDBLE TK, LDBLE TR);
int check_gammas_pz(void);
#ifdef SKIP
LDBLE DC(LDBLE T);
int DW(LDBLE T);
#endif
int ISPEC(const char *name);
LDBLE G(LDBLE Y);
LDBLE GP(LDBLE Y);
@ -1157,14 +1144,7 @@ protected:
int string_trim_right(char *str);
int string_trim_left(char *str);
static LDBLE under(LDBLE xval);
void zero_double(LDBLE * target, int n);
int get_input_errors(void);
#ifdef PHREEQ98
void AddToCEntry(char *a, int l, int i);
void ApplicationProcessMessages(void);
int copy_title(char *token_ptr, char **ptr, int *length);
extern int clean_up_null(void);
#endif
int isamong(char c, const char *s_l);
Address Hash_multi(HashTable * Table, const char *Key);
void ExpandTable_multi(HashTable * Table);
@ -1254,8 +1234,7 @@ protected:
/*----------------------------------------------------------------------
* Save
*---------------------------------------------------------------------- */
int count_save_values;
struct save_values *save_values;
std::vector<struct save_values> save_values;
struct save save;
/*----------------------------------------------------------------------
@ -1281,8 +1260,7 @@ protected:
/*----------------------------------------------------------------------
* Inverse
*---------------------------------------------------------------------- */
struct inverse *inverse;
std::vector<struct inverse> inverse;
int count_inverse;
/*----------------------------------------------------------------------
@ -1334,38 +1312,23 @@ protected:
/*----------------------------------------------------------------------
* Species_list
*---------------------------------------------------------------------- */
int count_species_list;
int max_species_list;
struct species_list *species_list;
std::vector<struct species_list> species_list;
/*----------------------------------------------------------------------
* Jacobian and Mass balance lists
*---------------------------------------------------------------------- */
std::vector<struct list0> sum_jacob0; /* array of pointers to targets and coefficients for array */
int count_sum_jacob0; /* number of elements in sum_jacob0 */
int max_sum_jacob0; /* calculated maximum number of elements in sum_jacob0 */
struct list0 *sum_jacob0; /* array of pointers to targets and coefficients for array */
int count_sum_mb1; /* number of elements in sum_mb1 */
int max_sum_mb1; /* calculated maximum number of elements in sum_mb1 */
struct list1 *sum_mb1; /* array of pointers to sources and targets for mass
balance summations with coef = 1.0 */
int count_sum_jacob1; /* number of elements in sum_jacob1 */
int max_sum_jacob1; /* calculated maximum number of elements in sum_jacob1 */
struct list1 *sum_jacob1; /* array of pointers to sources and targets for array
equations with coef = 1.0 */
int count_sum_mb2; /* number of elements in sum_mb2 */
int max_sum_mb2; /* calculated maximum number of elements in sum_mb2 */
struct list2 *sum_mb2; /* array of coefficients and pointers to sources and
targets for mass balance summations with coef != 1.0 */
int count_sum_jacob2; /* number of elements in sum_jacob2 */
int max_sum_jacob2; /* calculated maximum number of elements in sum_jacob2 */
struct list2 *sum_jacob2; /* array of coefficients and pointers to sources and
targets, coef != 1.0 */
int count_sum_delta; /* number of elements in sum_delta */
int max_sum_delta; /* calculated maximum number of elements in sum_delta */
struct list2 *sum_delta; /* array of pointers to sources, targets and coefficients for
summing deltas for mass balance equations */
std::vector<struct list1> sum_mb1; /* array of pointers to sources and targets for mass
balance summations with coef = 1.0 */
std::vector<struct list1> sum_jacob1; /* array of pointers to sources and targets for array
equations with coef = 1.0 */
std::vector<struct list2> sum_mb2; /* array of coefficients and pointers to sources and
targets for mass balance summations with coef != 1.0 */
std::vector<struct list2> sum_jacob2; /* array of coefficients and pointers to sources and
targets, coef != 1.0 */
std::vector<struct list2> sum_delta; /* array of pointers to sources, targets and coefficients for
summing deltas for mass balance equations */
/*----------------------------------------------------------------------
* Solution
*---------------------------------------------------------------------- */
@ -1477,20 +1440,14 @@ protected:
/*----------------------------------------------------------------------
* Elements
*---------------------------------------------------------------------- */
struct element **elements;
int count_elements;
int max_elements;
std::vector<struct element*> elements;
struct element *element_h_one;
/*----------------------------------------------------------------------
* Element List
*---------------------------------------------------------------------- */
struct elt_list *elt_list; /* structure array of working space while reading equations
names are in "strings", initially in input order */
std::vector<elt_list> elt_list;
int count_elts; /* number of elements in elt_list = position of next */
int max_elts;
/*----------------------------------------------------------------------
* Reaction
*---------------------------------------------------------------------- */
@ -1498,22 +1455,14 @@ protected:
/*----------------------------------------------------------------------
* Species
*---------------------------------------------------------------------- */
struct logk **logk;
int count_logk;
int max_logk;
std::vector<struct logk*> logk;
char *moles_per_kilogram_string;
char *pe_string;
struct species **s;
int count_s;
int max_s;
std::vector<struct species*> s;
std::vector< std::map < std::string, cxxSpeciesDL > > s_diff_layer;
struct species **s_x;
int count_s_x;
int max_s_x;
std::vector<struct species*> s_x;
struct species *s_h2o;
struct species *s_hplus;
@ -1526,23 +1475,17 @@ protected:
/*----------------------------------------------------------------------
* Phases
*---------------------------------------------------------------------- */
struct phase **phases;
int count_phases;
int max_phases;
std::vector<struct phase*> phases;
/*----------------------------------------------------------------------
* Master species
*---------------------------------------------------------------------- */
struct master **master; /* structure array of master species */
struct master **dbg_master;
int count_master;
int max_master;
std::vector<struct master*> master;
/*----------------------------------------------------------------------
* Unknowns
*---------------------------------------------------------------------- */
struct unknown **x;
std::vector<struct unknown*> x;
int count_unknowns;
int max_unknowns;
@ -1569,12 +1512,9 @@ protected:
*---------------------------------------------------------------------- */
struct reaction_temp trxn; /* structure array of working space while reading equations
species names are in "temp_strings" */
int count_trxn; /* number of reactants in trxn = position of next */
int max_trxn;
int count_trxn; /* number of reactants in trxn = position of next */
struct unknown_list *mb_unknowns;
int count_mb_unknowns;
int max_mb_unknowns;
std::vector<struct unknown_list> mb_unknowns;
/* ----------------------------------------------------------------------
* Print
@ -1589,8 +1529,7 @@ protected:
/* ----------------------------------------------------------------------
* RATES
* ---------------------------------------------------------------------- */
struct rate *rates;
int count_rates;
std::vector<struct rate> rates;
LDBLE rate_m, rate_m0, rate_time, rate_kin_time, rate_sim_time_start,
rate_sim_time_end, rate_sim_time, rate_moles, initial_total_time;
std::vector<LDBLE> rate_p;
@ -1650,9 +1589,7 @@ protected:
int count_strings;
int max_strings;
LDBLE *my_array;
LDBLE *delta;
LDBLE *residual;
std::vector<double> my_array, delta, residual;
int input_error;
@ -1745,23 +1682,13 @@ protected:
/* ----------------------------------------------------------------------
* ISOTOPES
* ---------------------------------------------------------------------- */
//struct name_coef match_tokens[50];
//int count_match_tokens;
int count_master_isotope;
struct master_isotope **master_isotope;
int max_master_isotope;
std::vector<master_isotope*> master_isotope;
int initial_solution_isotopes;
int count_calculate_value;
struct calculate_value **calculate_value;
int max_calculate_value;
std::vector<struct calculate_value*> calculate_value;
HashTable *calculate_value_hash_table;
int count_isotope_ratio;
struct isotope_ratio **isotope_ratio;
int max_isotope_ratio;
std::vector<struct isotope_ratio*> isotope_ratio;
HashTable *isotope_ratio_hash_table;
int count_isotope_alpha;
struct isotope_alpha **isotope_alpha;
int max_isotope_alpha;
std::vector<struct isotope_alpha*> isotope_alpha;
HashTable *isotope_alpha_hash_table;
int phreeqc_mpi_myself;
int first_read_input;
@ -1773,16 +1700,12 @@ protected:
/* VP: Density End */
int print_viscosity;
LDBLE *zeros;
int zeros_max;
LDBLE viscos, viscos_0, viscos_0_25; // viscosity of the solution, of pure water, of pure water at 25 C
LDBLE cell_pore_volume;
LDBLE cell_porosity;
LDBLE cell_volume;
LDBLE cell_saturation;
struct system_species *sys;
int count_sys, max_sys;
std::vector<struct system_species> sys;
LDBLE sys_tot;
LDBLE V_solutes, rho_0, rho_0_sat, kappa_0, p_sat/*, ah2o_x0*/;
@ -1815,16 +1738,8 @@ protected:
/* cl1.cpp ------------------------------- */
LDBLE *x_arg, *res_arg, *scratch;
std::vector<double> x_arg_v, res_arg_v, scratch_v;
int x_arg_max, res_arg_max, scratch_max;
#ifdef SKIP
/* dw.cpp ------------------------------- */
/* COMMON /QQQQ/ */
LDBLE Q0, Q5;
LDBLE GASCON, TZ, AA;
LDBLE Z, DZ, Y;
LDBLE G1, G2, GF;
LDBLE B1, B2, B1T, B2T, B1TT, B2TT;
#endif
/* gases.cpp ------------------------------- */
LDBLE a_aa_sum, b2, b_sum, R_TK;
@ -1892,33 +1807,23 @@ protected:
/* model.cpp ------------------------------- */
int gas_in;
LDBLE min_value;
LDBLE *normal, *ineq_array, *res, *cu, *zero, *delta1;
int *iu, *is, *back_eq;
int normal_max, ineq_array_max, res_max, cu_max, zero_max,
delta1_max, iu_max, is_max, back_eq_max;
std::vector<double> normal, ineq_array, res, cu, zero, delta1;
std::vector<int> iu, is, back_eq;
/* phrq_io_output.cpp ------------------------------- */
int forward_output_to_log;
/* phreeqc_files.cpp ------------------------------- */
char *default_data_base;
#ifdef PHREEQ98
int outputlinenr;
char *LogFileNameC;
char progress_str[512];
#endif
/* Pitzer */
int pitzer_model, sit_model, pitzer_pe;
int full_pitzer, always_full_pitzer, ICON, IC;
LDBLE COSMOT;
LDBLE AW;
LDBLE VP, DW0;
struct pitz_param **pitz_params;
int count_pitz_param, max_pitz_param;
std::vector<struct pitz_param*> pitz_params;
std::map< std::string, size_t > pitz_param_map;
struct theta_param **theta_params;
int count_theta_param, max_theta_param;
std::vector<struct theta_param*> theta_params;
int use_etheta;
LDBLE OTEMP, OPRESS;
LDBLE A0;
@ -1931,25 +1836,9 @@ protected:
LDBLE *M, *LGAMMA;
LDBLE BK[23], DK[23];
#ifdef PHREEQ98
int connect_simulations, graph_initial_solutions;
int shifts_as_points;
int chart_type;
int ShowChart;
int RowOffset, ColumnOffset;
#endif
LDBLE dummy;
/* print.cpp ------------------------------- */
#ifdef PHREEQ98
int colnr, rownr;
int graph_initial_solutions;
int prev_advection_step, prev_transport_step; /*, prev_reaction_step */
/* int shifts_as_points; */
int chart_type;
int AddSeries;
int FirstCallToUSER_GRAPH;
#endif
/* read.cpp */
char *prev_next_char;
@ -1968,8 +1857,7 @@ protected:
std::string dump_file_name_cpp;
/* sit.cpp ------------------------------- */
struct pitz_param **sit_params;
int count_sit_param, max_sit_param;
std::vector<struct pitz_param*> sit_params;
std::map< std::string, size_t > sit_param_map;
LDBLE sit_A0;
int sit_count_cations, sit_count_anions, sit_count_neutrals;
@ -2006,13 +1894,6 @@ protected:
int warn_MCD_X, warn_fixed_Surf;
LDBLE current_x, current_A, fix_current; // current: coulomb / s, Ampere, fixed current (Ampere)
#ifdef PHREEQ98
int AutoLoadOutputFile, CreateToC;
int ProcessMessages, ShowProgress, ShowProgressWindow, ShowChart;
int outputlinenr;
int stop_calculations;
char err_str98[80];
#endif
/* utilities.cpp ------------------------------- */
int spinner;
std::map<std::string, double> gfw_map;
@ -2194,39 +2075,6 @@ namespace Utilities
return phreeqc_cookie->cleanup_after_parser(parser);
}
#ifdef SKIP
template < typename T >
int Rxn_read_modify(std::map < int, T > &m, std::set < int > &s, Phreeqc * phreeqc_cookie)
{
typename std::map < int, T >::iterator it;
CParser parser(phreeqc_cookie->Get_phrq_io());
std::string key_name;
std::string::iterator b = parser.line().begin();
std::string::iterator e = parser.line().end();
CParser::copy_token(key_name, b, e);
cxxNumKeyword nk;
nk.read_number_description(parser);
T * entity_ptr = Utilities::Rxn_find(m, nk.Get_n_user());
if (!entity_ptr)
{
std::ostringstream errstr;
errstr << "Could not find " << key_name << " " << nk.Get_n_user() << " to modify.\n";
phreeqc_cookie->error_msg(errstr.str().c_str(), PHRQ_io::OT_STOP);
}
entity_ptr->read_raw(parser, false);
entity_ptr->Set_n_user(nk.Get_n_user());
entity_ptr->Set_n_user_end(nk.Get_n_user_end());
entity_ptr->Set_description(nk.Get_description());
s.insert(entity_ptr->Get_n_user());
return phreeqc_cookie->cleanup_after_parser(parser);
}
#endif
template < typename T >
int Rxn_read_modify(std::map < int, T > &m, std::set < int > &s, Phreeqc * phreeqc_cookie)
{

View File

@ -310,40 +310,6 @@ cxxPressure::read_raw(CParser & parser, bool check)
}
}
}
#ifdef SKIP
void
cxxPressure::dump_xml(std::ostream & s_oss, unsigned int indent) const const
{
unsigned int i;
s_oss.precision(DBL_DIG - 1);
std::string indent0(""), indent1(""), indent2("");
for (i = 0; i < indent; ++i)
indent0.append(Utilities::INDENT);
for (i = 0; i < indent + 1; ++i)
indent1.append(Utilities::INDENT);
for (i = 0; i < indent + 2; ++i)
indent2.append(Utilities::INDENT);
// Temperature element and attributes
s_oss << indent0;
s_oss << "<temperature " << "\n";
s_oss << indent1;
s_oss << "pitzer_temperature_gammas=\"" << this->
pitzer_temperature_gammas << "\"" << "\n";
// components
s_oss << indent1;
s_oss << "<component " << "\n";
for (std::list < cxxPressureComp >::const_iterator it =
temperatureComps.begin(); it != temperatureComps.end(); ++it)
{
it->dump_xml(s_oss, indent + 2);
}
return;
}
#endif
/* ---------------------------------------------------------------------- */
LDBLE cxxPressure::
Pressure_for_step(int step_number)

View File

@ -33,41 +33,6 @@ cxxReaction::~cxxReaction()
{
}
#ifdef SKIP
void
cxxReaction::dump_xml(std::ostream & s_oss, unsigned int indent) const const
{
unsigned int i;
s_oss.precision(DBL_DIG - 1);
std::string indent0(""), indent1(""), indent2("");
for (i = 0; i < indent; ++i)
indent0.append(Utilities::INDENT);
for (i = 0; i < indent + 1; ++i)
indent1.append(Utilities::INDENT);
for (i = 0; i < indent + 2; ++i)
indent2.append(Utilities::INDENT);
// Reaction element and attributes
s_oss << indent0;
s_oss << "<irrev " << "\n";
s_oss << indent1;
s_oss << "pitzer_irrev_gammas=\"" << this->
pitzer_irrev_gammas << "\"" << "\n";
// components
s_oss << indent1;
s_oss << "<component " << "\n";
for (std::list < cxxReactionComp >::const_iterator it =
irrevComps.begin(); it != irrevComps.end(); ++it)
{
it->dump_xml(s_oss, indent + 2);
}
return;
}
#endif
void
cxxReaction::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out) const
{

View File

@ -49,35 +49,6 @@ cxxSS::~cxxSS()
{
}
#ifdef SKIP
void
cxxSS::dump_xml(std::ostream & s_oss, unsigned int indent) const const
{
unsigned int i;
s_oss.precision(DBL_DIG - 1);
std::string indent0(""), indent1(""), indent2("");
for (i = 0; i < indent; ++i)
indent0.append(Utilities::INDENT);
for (i = 0; i < indent + 1; ++i)
indent1.append(Utilities::INDENT);
for (i = 0; i < indent + 2; ++i)
indent2.append(Utilities::INDENT);
// S_S element and attributes
s_oss << indent0 << "name=\"" << this->name << "\"" << "\n";
s_oss << indent0 << "add_formula=\"" << this->
add_formula << "\"" << "\n";
s_oss << indent0 << "si=\"" << this->si << "\"" << "\n";
s_oss << indent0 << "moles=\"" << this->moles << "\"" << "\n";
s_oss << indent0 << "delta=\"" << this->delta << "\"" << "\n";
s_oss << indent0 << "initial_moles=\"" << this->
initial_moles << "\"" << "\n";
s_oss << indent0 << "dissolve_only=\"" << this->
dissolve_only << "\"" << "\n";
}
#endif
void
cxxSS::dump_raw(std::ostream & s_oss, unsigned int indent) const
{

View File

@ -57,37 +57,6 @@ cxxSSassemblage::~cxxSSassemblage()
{
}
#ifdef SKIP
void
cxxSSassemblage::dump_xml(std::ostream & s_oss, unsigned int indent) const const
{
unsigned int i;
s_oss.precision(DBL_DIG - 1);
std::string indent0(""), indent1(""), indent2("");
for (i = 0; i < indent; ++i)
indent0.append(Utilities::INDENT);
for (i = 0; i < indent + 1; ++i)
indent1.append(Utilities::INDENT);
for (i = 0; i < indent + 2; ++i)
indent2.append(Utilities::INDENT);
// SSassemblage element and attributes
s_oss << indent0;
s_oss << "<EQUILIBRIUM_PHASES " << "\n";
// eltList
this->eltList.dump_xml(s_oss, indent + 1);
// SSs
s_oss << indent1;
s_oss << "<pure_phases " << "\n";
for (std::list < cxxSS >::const_iterator it =
SSs.begin(); it != SSs.end(); ++it)
{
it->dump_xml(s_oss, indent + 2);
}
}
#endif
void
cxxSSassemblage::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out) const
{

View File

@ -36,26 +36,6 @@ PHRQ_base(io)
dnc = 0;
dnb = 0;
}
#ifdef SKIP
cxxSScomp::cxxSScomp(struct pure_phase * pure_phase_ptr, PHRQ_io *io)
:
PHRQ_base(io)
//
// constructor for cxxSScomp from struct pure_phase
//
{
this->Set_name(pure_phase_ptr->name);
this->Set_add_formula(pure_phase_ptr->add_formula);
si = pure_phase_ptr->si;
si_org = pure_phase_ptr->si_org;
moles = pure_phase_ptr->moles;
delta = pure_phase_ptr->delta;
initial_moles = pure_phase_ptr->initial_moles;
force_equality = (pure_phase_ptr->force_equality == TRUE);
dissolve_only = (pure_phase_ptr->dissolve_only == TRUE);
precipitate_only = (pure_phase_ptr->precipitate_only == TRUE);
}
#endif
cxxSScomp::~cxxSScomp()
{
}
@ -248,29 +228,6 @@ cxxSScomp::read_raw(CParser & parser, bool check)
}
}
#ifdef SKIP
void
cxxSScomp::totalize(Phreeqc * phreeqc_ptr)
{
this->totals.clear();
// component structures
if (this->add_formula.size() != 0)
return;
struct phase *phase_ptr;
int l;
phase_ptr = phreeqc_ptr-> phase_bsearch(this->name.c_str(), &l, FALSE);
if (phase_ptr != NULL)
{
cxxNameDouble phase_formula(phase_ptr->next_elt);
this->totals.add_extensive(phase_formula, this->moles);
}
else
{
assert(false);
}
return;
}
#endif
void
cxxSScomp::multiply(LDBLE extensive)
{

View File

@ -1336,44 +1336,6 @@ cxxSolution::Update(const cxxNameDouble &const_nd)
// update totals
this->totals = simple_new;
}
#ifdef SKIP
void
cxxSolution::Update(const cxxNameDouble &const_nd)
{
// const_nd is updated totals
cxxNameDouble simple_original_totals = this->totals.Simplify_redox();
cxxNameDouble original_activities(this->master_activity);
this->master_activity.clear();
// Update activities
if (original_activities.size() > 0)
{
cxxNameDouble nd = const_nd;
cxxNameDouble simple_this_totals = nd.Simplify_redox();
cxxNameDouble::iterator it = simple_original_totals.begin();
for ( ; it != simple_original_totals.end(); it++)
{
cxxNameDouble::iterator jit = simple_this_totals.find(it->first);
if (jit != simple_this_totals.end())
{
if (it->second != 0)
{
LDBLE f = jit->second / it->second;
if (f != 1)
{
original_activities.Multiply_activities_redox(it->first, f);
}
}
}
}
original_activities.merge_redox(this->master_activity);
this->master_activity = original_activities;
}
return;
}
#endif
void
cxxSolution::zero()
{
@ -1501,31 +1463,6 @@ cxxSolution::Get_total(const char *string) const
return (it->second);
}
}
#ifdef SKIP
LDBLE
cxxSolution::Get_total_element(const char *string) const
{
cxxNameDouble::const_iterator it;
LDBLE d = 0.0;
for (it = this->totals.begin(); it != this->totals.end(); ++it)
{
// C++ way to do it
std::string ename(string);
std::string current_ename(it->first);
std::basic_string < char >::size_type indexCh;
indexCh = current_ename.find("(");
if (indexCh != std::string::npos)
{
current_ename = current_ename.substr(0, indexCh);
}
if (current_ename == ename)
{
d += it->second;
}
}
return (d);
}
#endif
void
cxxSolution::Set_total(char *string, LDBLE d)

View File

@ -802,41 +802,6 @@ cxxStorageBin::Get_Pressures()
{
return this->Pressures;
}
#ifdef SKIP
void
cxxStorageBin::dump_xml(std::ostream & s_oss, unsigned int indent) const const
{
unsigned int i;
s_oss.precision(DBL_DIG - 1);
std::string indent0(""), indent1(""), indent2("");
for (i = 0; i < indent; ++i)
indent0.append(Utilities::INDENT);
for (i = 0; i < indent + 1; ++i)
indent1.append(Utilities::INDENT);
for (i = 0; i < indent + 2; ++i)
indent2.append(Utilities::INDENT);
// StorageBin element and attributes
s_oss << indent0;
s_oss << "<mix " << "\n";
s_oss << indent1;
s_oss << "pitzer_mix_gammas=\"" << this->
pitzer_mix_gammas << "\"" << "\n";
// components
s_oss << indent1;
s_oss << "<component " << "\n";
for (std::list < cxxStorageBinComp >::const_iterator it =
mixComps.begin(); it != mixComps.end(); ++it)
{
it->dump_xml(s_oss, indent + 2);
}
return;
}
#endif
void
cxxStorageBin::dump_raw(std::ostream & s_oss, unsigned int indent) const
{
@ -1318,258 +1283,6 @@ cxxStorageBin::Clear(void)
// Pressure
this->Pressures.clear();
}
#ifdef SKIP
cxxSolution *
cxxStorageBin::mix_cxxSolutions(cxxMix & mixmap)
{
/*
* mixes solutions based on cxxMix structure, returns new solution
* return solution must be freed by calling method
*/
LDBLE intensive, extensive;
cxxSolution *cxxsoln_ptr, *cxxsoln_ptr1;
/*
* Zero out global solution data
*/
cxxsoln_ptr = new cxxSolution(0.0);
/*
* Determine sum of mixing fractions
*/
extensive = 0.0;
std::map < int, LDBLE >*mixcomps = mixmap.comps();
std::map < int, LDBLE >::const_iterator it;
for (it = mixcomps->begin(); it != mixcomps->end(); it++)
{
extensive += it->second;
}
/*
* Add solutions
*/
for (it = mixcomps->begin(); it != mixcomps->end(); it++)
{
cxxsoln_ptr1 = &((this->Solutions.find(it->first))->second);
if (cxxsoln_ptr1 == NULL)
{
error_string = sformatf(
"Solution %d not found in mix_cxxSolutions.", it->first);
error_msg(error_string, CONTINUE);
phreeqc_ptr-> input_error++;
return (NULL);
}
intensive = it->second / extensive;
cxxsoln_ptr->add(*cxxsoln_ptr1, intensive, it->second);
}
return (cxxsoln_ptr);
}
#endif
#ifdef SKIP_OR_MOVE_TO_STRUCTURES
struct system *
cxxStorageBin::cxxStorageBin2system(Phreeqc * phreeqc_ptr, int n)
//
// make a system from storagebin
//
{
struct system *system_ptr =
(struct system *) phreeqc_ptr-> PHRQ_malloc(sizeof(struct system));
if (system_ptr == NULL)
phreeqc_ptr-> malloc_error();
// Solutions
if (this->getSolution(n) != NULL)
{
//system_ptr->solution = (this->getSolution(n))->cxxSolution2solution(phreeqc_ptr);
system_ptr->solution = phreeqc_ptr-> cxxSolution2solution(this->getSolution(n));
}
else
{
system_ptr->solution = NULL;
}
// Exchangers
if (this->getExchange(n) != NULL)
{
//system_ptr->exchange = (this->getExchange(n))->cxxExchange2exchange(phreeqc_ptr);
system_ptr->exchange = phreeqc_ptr-> cxxExchange2exchange(this->getExchange(n));
}
else
{
system_ptr->exchange = NULL;
}
// GasPhases
if (this->getGasPhase(n) != NULL)
{
//system_ptr->gas_phase = (this->getGasPhase(n))->cxxGasPhase2gas_phase(phreeqc_ptr);
system_ptr->gas_phase = phreeqc_ptr-> cxxGasPhase2gas_phase(this->getGasPhase(n));
}
else
{
system_ptr->gas_phase = NULL;
}
// Kinetics
if (this->getKinetics(n) != NULL)
{
//system_ptr->kinetics = (this->getKinetics(n))->cxxKinetics2kinetics(phreeqc_ptr);
system_ptr->kinetics = phreeqc_ptr-> cxxKinetics2kinetics(this->getKinetics(n));
}
else
{
system_ptr->kinetics = NULL;
}
// PPassemblages
if (this->getPPassemblage(n) != NULL)
{
//system_ptr->pp_assemblage =
// (this->getPPassemblage(n))->cxxPPassemblage2pp_assemblage(phreeqc_ptr);
system_ptr->pp_assemblage =
phreeqc_ptr-> cxxPPassemblage2pp_assemblage(this->getPPassemblage(n));
}
else
{
system_ptr->pp_assemblage = NULL;
}
// SSassemblages
if (this->getSSassemblage(n) != NULL)
{
//system_ptr->ss_assemblage =
// (this->getSSassemblage(n))->cxxSSassemblage2ss_assemblage(phreeqc_ptr);
system_ptr->ss_assemblage =
phreeqc_ptr-> cxxSSassemblage2ss_assemblage((this->getSSassemblage(n)));
}
else
{
system_ptr->ss_assemblage = NULL;
}
// Surfaces
if (this->getSurface(n) != NULL)
{
//system_ptr->surface = (this->getSurface(n))->cxxSurface2surface(phreeqc_ptr);
system_ptr->surface = phreeqc_ptr-> cxxSurface2surface((this->getSurface(n)));
}
else
{
system_ptr->surface = NULL;
}
return system_ptr;
}
#endif
#ifdef SKIP
cxxExchange *
cxxStorageBin::mix_cxxExchange(cxxMix & mixmap)
{
/*
* mixes exchangers based on cxxMix structure, returns new exchanger
* return exchanger must be freed by calling method
*/
cxxExchange *new_exch_ptr, *old_exch_ptr;
/*
* Zero out global solution data
*/
new_exch_ptr = new cxxExchange();
std::map < int, LDBLE >::const_iterator it_mix;
std::map < int, LDBLE >*mixcomps = mixmap.comps();
// Pitzer_exchange_gammas
it_mix = mixcomps->begin();
old_exch_ptr = &((this->Exchangers.find(it_mix->first))->second);
if (old_exch_ptr == NULL)
{
error_string = sformatf( "Exchange %d not found in mix_cxxExchange.",
it_mix->first);
error_msg(error_string, CONTINUE);
phreeqc_ptr-> input_error++;
return (NULL);
}
new_exch_ptr->set_pitzer_exchange_gammas(old_exch_ptr->
get_pitzer_exchange_gammas());
/*
* Make list of ExchComps
*/
std::vector < cxxExchComp > ec_vector;
std::vector < LDBLE >f_vector;
//
// make list of all exchange components and their mix fractions
//
for (it_mix = mixcomps->begin(); it_mix != mixcomps->end(); it_mix++)
{
old_exch_ptr = &((this->Exchangers.find(it_mix->first))->second);
if (old_exch_ptr == NULL)
{
error_string = sformatf( "Exchange %d not found in mix_cxxExchange.",
it_mix->first);
error_msg(error_string, CONTINUE);
phreeqc_ptr-> input_error++;
return (NULL);
}
// Add exchange components to vector ec_vector
std::list < cxxExchComp >::const_iterator it_ec;
std::list < cxxExchComp > &eclist = old_exch_ptr->get_exchComps();
for (it_ec = eclist.begin(); it_ec != eclist.end(); it_ec++)
{
f_vector.push_back(it_mix->second);
//cxxExchComp ec = *it_ec;
//ec_vector.push_back(ec);
ec_vector.push_back(*it_ec);
}
}
//
// Process list to make mixture
//
char *current_formula = ec_vector.begin()->get_formula();
while (current_formula != NULL)
{
std::vector < cxxExchComp > ec_subvector;
std::vector < LDBLE >f_subvector;
std::vector < cxxExchComp >::iterator it_ec = ec_vector.begin();
std::vector < LDBLE >::iterator it_f = f_vector.begin();
current_formula = NULL;
for (; it_ec != ec_vector.end(); it_ec++)
{
if (*it_f != 0)
{
if (current_formula == NULL)
current_formula = it_ec->get_formula();
if (it_ec->get_formula() == current_formula)
{
ec_subvector.push_back(*it_ec);
f_subvector.push_back(*it_f);
*it_f = 0;
//ec_vector.erase(it_ec);
//f_vector.erase(it_f);
}
}
it_f++;
}
//
// mix ec_subvector to make
// one exchange component
//
if (current_formula != NULL)
{
cxxExchComp new_comp(ec_subvector, f_subvector);
new_exch_ptr->get_exchComps().push_back(new_comp);
}
}
/*
std::ostringstream oss;
new_exch_ptr->dump_raw(oss, 0);
std::cerr << oss.str();
*/
return (new_exch_ptr);
}
#endif
cxxSystem &
cxxStorageBin::Get_System(void)

View File

@ -96,74 +96,6 @@ cxxSurface::Get_related_rate() const
}
return (false);
}
#ifdef SKIP
void
cxxSurface::dump_xml(std::ostream & s_oss, unsigned int indent) const
{
unsigned int i;
s_oss.precision(DBL_DIG - 1);
std::string indent0(""), indent1(""), indent2("");
for (i = 0; i < indent; ++i)
indent0.append(Utilities::INDENT);
for (i = 0; i < indent + 1; ++i)
indent1.append(Utilities::INDENT);
for (i = 0; i < indent + 2; ++i)
indent2.append(Utilities::INDENT);
// Surface element and attributes
s_oss << indent0;
s_oss << "<surface " << "\n";
s_oss << indent1;
s_oss << "surface_type=\"" << this->type << "\"" << "\n";
s_oss << indent1;
s_oss << "dl_type=\"" << this->dl_type << "\"" << "\n";
s_oss << indent1;
s_oss << "sites_units=\"" << this->sites_units << "\"" << "\n";
s_oss << indent1;
s_oss << "only_counter_ions=\"" << this->
only_counter_ions << "\"" << "\n";
s_oss << indent1;
s_oss << "thickness=\"" << this->thickness << "\"" << "\n";
s_oss << indent1;
s_oss << "debye_lengths=\"" << this->debye_lengths << "\"" << "\n";
s_oss << indent1;
s_oss << "DDL_viscosity=\"" << this->DDL_viscosity << "\"" << "\n";
s_oss << indent1;
s_oss << "DDL_limit=\"" << this->DDL_limit << "\"" << "\n";
s_oss << indent1;
s_oss << "transport=\"" << this->transport << "\"" << "\n";
// surface component structures
s_oss << indent1;
s_oss << "<component " << "\n";
{
for (std::map < std::string, cxxSurfaceComp >::const_iterator it =
this->surfaceComps.begin(); it != this->surfaceComps.end(); ++it)
{
(*it).second.dump_xml(s_oss, indent + 2);
}
}
// surface charge structures
s_oss << indent1;
s_oss << "<charge_component " << "\n";
for (std::map < std::string, cxxSurfaceCharge >::const_iterator it =
surface_charges.begin(); it != surface_charges.end(); ++it)
{
(*it).second.dump_xml(s_oss, indent + 2);
}
return;
}
#endif
void
cxxSurface::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out) const
{

View File

@ -32,41 +32,6 @@ cxxTemperature::~cxxTemperature()
{
}
#ifdef SKIP
void
cxxTemperature::dump_xml(std::ostream & s_oss, unsigned int indent) const const
{
unsigned int i;
s_oss.precision(DBL_DIG - 1);
std::string indent0(""), indent1(""), indent2("");
for (i = 0; i < indent; ++i)
indent0.append(Utilities::INDENT);
for (i = 0; i < indent + 1; ++i)
indent1.append(Utilities::INDENT);
for (i = 0; i < indent + 2; ++i)
indent2.append(Utilities::INDENT);
// Temperature element and attributes
s_oss << indent0;
s_oss << "<temperature " << "\n";
s_oss << indent1;
s_oss << "pitzer_temperature_gammas=\"" << this->
pitzer_temperature_gammas << "\"" << "\n";
// components
s_oss << indent1;
s_oss << "<component " << "\n";
for (std::list < cxxTemperatureComp >::const_iterator it =
temperatureComps.begin(); it != temperatureComps.end(); ++it)
{
it->dump_xml(s_oss, indent + 2);
}
return;
}
#endif
int
cxxTemperature::read(CParser & parser)
{

File diff suppressed because it is too large Load Diff

View File

@ -188,12 +188,14 @@ cl1(int k, int l, int m, int n,
output_msg(sformatf( "Set up phase 1 costs\n"));
#endif
/* Zero first row of cu and iu */
memcpy((void *) &(l_cu[0]), (void *) &(scratch[0]),
(size_t) nklm * sizeof(LDBLE));
for (j = 0; j < nklm; ++j)
{
l_iu[j] = 0;
}
//memcpy((void *) &(l_cu[0]), (void *) &(scratch[0]),
// (size_t) nklm * sizeof(LDBLE));
memset(&l_cu[0], 0, (size_t)nklm * sizeof(LDBLE));
//for (j = 0; j < nklm; ++j)
//{
// l_iu[j] = 0;
//}
memset(&l_iu[0], 0, (size_t)nklm * sizeof(int));
/* L40: */
#ifdef DEBUG_CL1
output_msg(sformatf( "L40\n"));
@ -847,50 +849,24 @@ cl1(int k, int l, int m, int n,
void Phreeqc::
cl1_space(int check, int l_n2d, int klm, int l_nklmd)
{
if (check == 1)
if (l_n2d > x_arg_v.size())
{
if (x_arg == NULL)
{
x_arg = (LDBLE *) PHRQ_malloc((size_t) (l_n2d * sizeof(LDBLE)));
}
else if (l_n2d > x_arg_max)
{
x_arg =
(LDBLE *) PHRQ_realloc(x_arg, (size_t) (l_n2d * sizeof(LDBLE)));
x_arg_max = l_n2d;
}
if (x_arg == NULL)
malloc_error();
zero_double(x_arg, l_n2d);
x_arg_v.resize(l_n2d);
x_arg = &x_arg_v[0];
}
memset(x_arg_v.data(), 0, sizeof(double) * (size_t)l_n2d);
if (res_arg == NULL)
{
res_arg = (LDBLE *) PHRQ_malloc((size_t) ((klm) * sizeof(LDBLE)));
}
else if (klm > res_arg_max)
{
res_arg =
(LDBLE *) PHRQ_realloc(res_arg,
(size_t) ((klm) * sizeof(LDBLE)));
res_arg_max = klm;
}
if (res_arg == NULL)
malloc_error();
zero_double(res_arg, klm);
if (klm > res_arg_v.size())
{
res_arg_v.resize(klm);
res_arg = &res_arg_v[0];
}
memset(res_arg_v.data(), 0, sizeof(double) * (size_t)klm);
/* Make scratch space */
if (scratch == NULL)
if (l_nklmd > scratch_v.size())
{
scratch = (LDBLE *) PHRQ_malloc((size_t) l_nklmd * sizeof(LDBLE));
scratch_v.resize(l_nklmd);
scratch = &scratch_v[0];
}
else if (l_nklmd > scratch_max)
{
scratch =
(LDBLE *) PHRQ_realloc(scratch, (size_t) l_nklmd * sizeof(LDBLE));
scratch_max = l_nklmd;
}
if (scratch == NULL)
malloc_error();
zero_double(scratch, l_nklmd);
memset(scratch_v.data(), 0, sizeof(double) * (size_t)l_nklmd);
}

View File

@ -427,11 +427,7 @@ process_file_names(int argc, char *argv[], std::istream **db_cookie,
if (strcmp_nocase(token, "database") == 0)
{
user_database = (char *) free_check_null(user_database);
#ifdef PHREEQ98
user_database = string_duplicate(prefix_database_dir(ptr));
#else
user_database = string_duplicate(ptr);
#endif
if (string_trim(user_database) == EMPTY)
{
warning_msg("DATABASE file name is missing; default database will be used.");
@ -627,11 +623,7 @@ process_file_names(int argc, char *argv[], std::istream **db_cookie,
if (strcmp_nocase(token, "database") == 0)
{
user_database = (char *) free_check_null(user_database);
#ifdef PHREEQ98
user_database = string_duplicate(prefix_database_dir(ptr));
#else
user_database = string_duplicate(ptr);
#endif
if (string_trim(user_database) == EMPTY)
{
warning_msg("DATABASE file name is missing; default database will be used.");

View File

@ -69,41 +69,6 @@ cxxKinetics::~cxxKinetics()
{
}
#ifdef SKIP
void
cxxKinetics::dump_xml(std::ostream & s_oss, unsigned int indent) const const
{
unsigned int i;
s_oss.precision(DBL_DIG - 1);
std::string indent0(""), indent1(""), indent2("");
for (i = 0; i < indent; ++i)
indent0.append(Utilities::INDENT);
for (i = 0; i < indent + 1; ++i)
indent1.append(Utilities::INDENT);
for (i = 0; i < indent + 2; ++i)
indent2.append(Utilities::INDENT);
// Kinetics element and attributes
s_oss << indent0;
s_oss << "<kinetics " << "\n";
s_oss << indent1;
s_oss << "pitzer_kinetics_gammas=\"" << this->
pitzer_kinetics_gammas << "\"" << "\n";
// components
s_oss << indent1;
s_oss << "<component " << "\n";
for (std::list < cxxKineticsComp >::const_iterator it =
kineticsComps.begin(); it != kineticsComps.end(); ++it)
{
it->dump_xml(s_oss, indent + 2);
}
return;
}
#endif
void
cxxKinetics::dump_raw(std::ostream & s_oss, unsigned int indent, int * n_out) const
{

View File

@ -29,41 +29,6 @@ cxxMix::~cxxMix()
{
}
#ifdef SKIP
void
cxxMix::dump_xml(std::ostream & s_oss, unsigned int indent) const const
{
unsigned int i;
s_oss.precision(DBL_DIG - 1);
std::string indent0(""), indent1(""), indent2("");
for (i = 0; i < indent; ++i)
indent0.append(Utilities::INDENT);
for (i = 0; i < indent + 1; ++i)
indent1.append(Utilities::INDENT);
for (i = 0; i < indent + 2; ++i)
indent2.append(Utilities::INDENT);
// Mix element and attributes
s_oss << indent0;
s_oss << "<mix " << "\n";
s_oss << indent1;
s_oss << "pitzer_mix_gammas=\"" << this->
pitzer_mix_gammas << "\"" << "\n";
// components
s_oss << indent1;
s_oss << "<component " << "\n";
for (std::list < cxxMixComp >::const_iterator it = mixComps.begin();
it != mixComps.end(); ++it)
{
it->dump_xml(s_oss, indent + 2);
}
return;
}
#endif
void
cxxMix::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out) const
{

View File

@ -289,51 +289,7 @@ struct name_phase
const char *name;
struct phase *phase;
};
#ifdef SKIP
struct punch
{
int in;
int new_def;
struct name_master *totals;
int count_totals;
struct name_species *molalities;
int count_molalities;
struct name_species *activities;
int count_activities;
struct name_phase *pure_phases;
int count_pure_phases;
struct name_phase *si;
int count_si;
struct name_phase *gases;
int count_gases;
struct name_phase *s_s;
int count_s_s;
struct name_phase *kinetics;
int count_kinetics;
struct name_master *isotopes;
int count_isotopes;
struct name_master *calculate_values;
int count_calculate_values;
int inverse;
int sim;
int state;
int soln;
int dist;
int time;
int step;
int rxn;
int temp;
int ph;
int pe;
int alk;
int mu;
int water;
int high_precision;
int user_punch;
int charge_balance;
int percent_error;
};
#endif
struct Change_Surf
{
const char *comp_name;
@ -857,7 +813,7 @@ struct reaction_temp
{
LDBLE logk[MAX_LOG_K_INDICES];
LDBLE dz[3];
struct rxn_token_temp *token;
std::vector<struct rxn_token_temp> token;
};
struct rxn_token_temp
{ /* data for equations, aq. species or minerals */

View File

@ -53,7 +53,7 @@ calc_all_g(void)
/*
* calculate g for given surface for each species
*/
for (int i = 0; i < count_s_x; i++)
for (int i = 0; i < (int)this->s_x.size(); i++)
{
if (s_x[i]->type > HPLUS)
continue;
@ -252,7 +252,7 @@ g_function(LDBLE x_value)
{
it->second.Set_psi_to_z(exp(ln_x_value * it->first) - 1.0);
}
for (i = 0; i < count_s_x; i++)
for (i = 0; i < (int)this->s_x.size(); i++)
{
if (s_x[i]->type < H2O && s_x[i]->z != 0.0)
{
@ -265,7 +265,7 @@ g_function(LDBLE x_value)
sum1 = 0.0;
output_msg(sformatf(
"Species\tmoles\tX**z-1\tsum\tsum charge\n"));
for (i = 0; i < count_s_x; i++)
for (i = 0; i < (int)this->s_x.size(); i++)
{
if (s_x[i]->type < H2O && s_x[i]->z != 0.0)
{
@ -479,7 +479,7 @@ calc_init_g(void)
/*
* calculate g for given surface for each species
*/
for (int i = 0; i < count_s_x; i++)
for (int i = 0; i < (int)this->s_x.size(); i++)
{
if (s_x[i]->type > HPLUS)
continue;
@ -703,7 +703,7 @@ sum_diffuse_layer(cxxSurfaceCharge *charge_ptr)
count_elts = 0;
paren_count = 0;
mass_water_surface = charge_ptr->Get_mass_water();
for (int j = 0; j < count_s_x; j++)
for (int j = 0; j < (int)this->s_x.size(); j++)
{
if (s_x[j]->type > HPLUS)
continue;
@ -723,13 +723,7 @@ sum_diffuse_layer(cxxSurfaceCharge *charge_ptr)
add_elt_list(s_x[j]->next_elt, moles_surface);
}
add_elt_list(s_h2o->next_elt, mass_water_surface / gfw_water);
if (count_elts > 0)
{
qsort(elt_list, (size_t) count_elts,
(size_t) sizeof(struct elt_list), elt_list_compare);
elt_list_combine();
}
elt_list_combine();
return (OK);
}
/* ---------------------------------------------------------------------- */
@ -771,7 +765,7 @@ calc_all_donnan(void)
it->second = 0.0;
}
charge_group_map.clear();
for (int i = 0; i < count_s_x; i++)
for (int i = 0; i < (int)this->s_x.size(); i++)
{
if (s_x[i]->type > HPLUS)
continue;
@ -925,7 +919,7 @@ calc_init_donnan(void)
charge_group_map.clear();
charge_group_map[0.0] = 0.0;
for (int i = 0; i < count_s_x; i++)
for (int i = 0; i < (int)this->s_x.size(); i++)
{
if (s_x[i]->type > HPLUS)
continue;
@ -989,7 +983,7 @@ calc_init_donnan(void)
charge_ptr->Get_g_map()[z].Set_dg(-z);
}
/* save g for species */
for (int i = 0; i < count_s_x; i++)
for (int i = 0; i < (int)this->s_x.size(); i++)
{
int is = s_x[i]->number;
assert (is < (int) s_diff_layer.size());

View File

@ -266,15 +266,9 @@ setup_inverse(struct inverse *inv_ptr)
/*
* Malloc space for arrays
*/
my_array = (LDBLE *) free_check_null(my_array);
my_array =
(LDBLE *) PHRQ_malloc((size_t) max_column_count * max_row_count *
sizeof(LDBLE));
if (my_array == NULL)
malloc_error();
my_array.resize((size_t)max_column_count * (size_t)max_row_count);
array1 =
(LDBLE *) PHRQ_malloc((size_t) max_column_count * max_row_count *
array1 = (LDBLE *) PHRQ_malloc((size_t) max_column_count * max_row_count *
sizeof(LDBLE));
if (array1 == NULL)
malloc_error();
@ -288,10 +282,7 @@ setup_inverse(struct inverse *inv_ptr)
if (row_name == NULL)
malloc_error();
delta = (LDBLE *) free_check_null(delta);
delta = (LDBLE *) PHRQ_malloc((size_t) max_column_count * sizeof(LDBLE));
if (delta == NULL)
malloc_error();
delta.resize((size_t)max_column_count);
inv_delta1 = (LDBLE *) PHRQ_malloc((size_t) max_column_count * sizeof(LDBLE));
if (inv_delta1 == NULL)
@ -380,7 +371,7 @@ setup_inverse(struct inverse *inv_ptr)
*/
/* initialize master species */
for (i = 0; i < count_master; i++)
for (i = 0; i < (int)master.size(); i++)
{
master[i]->in = -1;
if (strstr(master[i]->elt->name, "Alk") == master[i]->elt->name)
@ -439,7 +430,7 @@ setup_inverse(struct inverse *inv_ptr)
column = i;
sprintf(token, "soln %d", i);
col_name[column] = string_hsave(token);
for (j = 0; j < count_master; j++)
for (j = 0; j < (int)master.size(); j++)
{
if (master[j]->in >= 0)
{
@ -453,7 +444,7 @@ setup_inverse(struct inverse *inv_ptr)
}
/* calculate charge balance for elements in model */
cb = 0;
for (j = 0; j < count_master; j++)
for (j = 0; j < (int)master.size(); j++)
{
if (master[j]->in >= 0)
{
@ -1332,8 +1323,8 @@ solve_inverse(struct inverse *inv_ptr)
output_msg(sformatf( "\tNumber of calls to cl1: %d\n",
count_calls));
}
my_array = (LDBLE *) free_check_null(my_array);
delta = (LDBLE *) free_check_null(delta);
my_array.clear();
delta.clear();
array1 = (LDBLE *) free_check_null(array1);
inv_zero = (LDBLE *) free_check_null(inv_zero);
inv_res = (LDBLE *) free_check_null(inv_res);
@ -1462,7 +1453,7 @@ solve_with_mask(struct inverse *inv_ptr, unsigned long cur_bits)
memcpy((void *) &(delta_save[0]), (void *) &(inv_zero[0]),
(size_t) max_column_count * sizeof(LDBLE));
shrink(inv_ptr, my_array, array1,
shrink(inv_ptr, my_array.data(), array1,
&k, &l, &m, &n, cur_bits, delta2, col_back, row_back);
/*
* Save delta constraints
@ -2068,7 +2059,7 @@ print_model(struct inverse *inv_ptr)
(double)d1, (double)d2, (double)d3, inv_ptr->phases[i - col_phases].phase->formula));
i1 = 0;
for (; i1 < count_phases; i1++)
for (; i1 < (int)phases.size(); i1++)
{
if (Utilities::strcmp_nocase(phases[i1]->name, col_name[i]))
continue;
@ -2223,100 +2214,6 @@ punch_model_heading(struct inverse *inv_ptr)
punch_flush();
return (OK);
}
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
punch_model_heading(struct inverse *inv_ptr)
/* ---------------------------------------------------------------------- */
{
/*
* Prints model headings to selected output file
*/
int i;
char token[MAX_LENGTH];
//if (/*punch.in == FALSE ||*/ pr.punch == FALSE || punch.inverse == FALSE)
// return (OK);
std::vector<std::string> heading_names;
std::map < int, SelectedOutput >::iterator so_it = SelectedOutput_map.begin();
for ( ; so_it != SelectedOutput_map.end(); so_it++)
{
// set punch file
current_selected_output = &(so_it->second);
if (pr.punch == FALSE ||
current_selected_output == NULL ||
current_selected_output->punch_ostream == NULL ||
!current_selected_output->Get_inverse() ||
!current_selected_output->Get_active())
continue;
phrq_io->Set_punch_ostream(current_selected_output->punch_ostream);
int l = (!current_selected_output->Get_high_precision()) ? 15 : 20;
heading_names.clear();
/*
* Print sum of residuals and maximum fractional error
*/
heading_names.push_back(sformatf("%*s\t", l, "Sum_resid"));
heading_names.push_back(sformatf("%*s\t", l, "Sum_Delta/U"));
heading_names.push_back(sformatf("%*s\t", l, "MaxFracErr"));
/*
* Print solution numbers
*/
for (i = 0; i < inv_ptr->count_solns; i++)
{
sprintf(token, "Soln_%d", inv_ptr->solns[i]);
std::string tok1(token);
tok1.append("_min");
std::string tok2(token);
tok2.append("_max");
heading_names.push_back(sformatf("%*s\t", l, token));
heading_names.push_back(sformatf("%*s\t", l, tok1.c_str()));
heading_names.push_back(sformatf("%*s\t", l, tok2.c_str()));
}
/*
* Print phase names
*/
for (i = col_phases; i < col_redox; i++)
{
std::string tok1(col_name[i]);
tok1.append("_max");
std::string tok2(col_name[i]);
tok2.append("_max");
heading_names.push_back(sformatf("%*s\t", l, col_name[i]));
heading_names.push_back(sformatf("%*s\t", l, tok1.c_str()));
heading_names.push_back(sformatf("%*s\t", l, tok2.c_str()));
}
size_t j;
// punch headings
//user_punch_count_headings = (int) heading_names.size();
//user_punch_headings = (const char **) PHRQ_realloc(user_punch_headings,
// (size_t) (user_punch_count_headings + 1) * sizeof(char *));
//if (user_punch_headings == NULL)
// malloc_error();
for (j = 0; j < heading_names.size(); j++)
{
fpunchf_heading(heading_names[j].c_str());
//user_punch_headings[j] = string_hsave(heading_names[j].c_str());
}
fpunchf_heading("\n");
}
current_selected_output = NULL;
phrq_io->Set_punch_ostream(NULL);
inverse_heading_names = heading_names;
/*
* Flush buffer after each model
*/
punch_flush();
return (OK);
}
#endif
/* ---------------------------------------------------------------------- */
int Phreeqc::
punch_model(struct inverse *inv_ptr)
@ -3708,7 +3605,7 @@ count_isotope_unknowns(struct inverse *inv_ptr,
{
/* find master */
for (k = 0; k < count_master; k++)
for (k = 0; k < (int)master.size(); k++)
{
if (master[k] == primary_ptr)
break;
@ -3716,7 +3613,7 @@ count_isotope_unknowns(struct inverse *inv_ptr,
/* sum all secondary for master */
k++;
for (; k < count_master; k++)
for (; k < (int)master.size(); k++)
{
if (master[k]->elt->primary != primary_ptr)
break;
@ -4512,7 +4409,7 @@ dump_netpath_pat(struct inverse *inv_ptr)
LDBLE d1, d2, d3;
char *ptr;
LDBLE sum, sum1, sum_iso, d;
LDBLE *array_save, *l_delta_save;
std::vector<double> array_save, l_delta_save;
int count_unknowns_save, max_row_count_save, max_column_count_save, temp,
count_current_solutions, temp_punch;
int solnmap[10][2];
@ -4534,8 +4431,6 @@ dump_netpath_pat(struct inverse *inv_ptr)
max_row_count_save = max_row_count;
max_column_count_save = max_column_count;
my_array = NULL;
delta = NULL;
count_unknowns = 0;
max_row_count = 0;
max_column_count = 0;
@ -4973,9 +4868,6 @@ dump_netpath_pat(struct inverse *inv_ptr)
fprintf(netpath_file, "%14d # Well number\n",
count_pat_solutions);
}
//free_model_allocs();
my_array = (LDBLE *) free_check_null(my_array);
delta = (LDBLE *) free_check_null(delta);
my_array = array_save;
delta = l_delta_save;
count_unknowns = count_unknowns_save;
@ -5016,7 +4908,7 @@ dump_netpath_pat(struct inverse *inv_ptr)
* Write elements
*/
xsolution_zero();
for (j = 0; j < count_master; j++)
for (j = 0; j < (int)master.size(); j++)
{
master[j]->in = FALSE;
}
@ -5036,7 +4928,7 @@ dump_netpath_pat(struct inverse *inv_ptr)
continue;
master_ptr->in = TRUE;
}
for (j = 0; j < count_master; j++)
for (j = 0; j < (int)master.size(); j++)
{
if (master[j]->in == TRUE)
{
@ -5204,7 +5096,7 @@ dump_netpath_pat(struct inverse *inv_ptr)
std::string::iterator e = string.end();
CParser::copy_token(token, b, e);
CParser::copy_token(string1, b, e);
sscanf(string1.c_str(), SCANFORMAT, &f);
(void)sscanf(string1.c_str(), SCANFORMAT, &f);
sum += f * rxn_ptr->coef;
}
}

View File

@ -106,7 +106,7 @@ read_isotopes(void)
input_error++;
break;
}
sscanf(token, SCANFORMAT, &(master_isotope_ptr->standard));
(void)sscanf(token, SCANFORMAT, &(master_isotope_ptr->standard));
opt_save = OPTION_DEFAULT;
break;
case 1: /* total_is_major_isotope */
@ -478,7 +478,7 @@ add_isotopes(cxxSolution &solution_ref)
/*
* zero out isotopes
*/
for (i = 0; i < count_master_isotope; i++)
for (i = 0; i < (int)master_isotope.size(); i++)
{
master_isotope[i]->moles = 0;
}
@ -513,7 +513,7 @@ add_isotopes(cxxSolution &solution_ref)
* Set isotopes flag
*/
initial_solution_isotopes = FALSE;
for (i = 0; i < count_master_isotope; i++)
for (i = 0; i < (int)master_isotope.size(); i++)
{
if (master_isotope[i]->minor_isotope == TRUE
&& master_isotope[i]->moles > 0)
@ -662,7 +662,7 @@ calculate_isotope_moles(struct element *elt_ptr,
/*
* Update master_isotope
*/
for (j = 0; j < count_master_isotope; j++)
for (j = 0; j < (int)master_isotope.size(); j++)
{
for (i = 0; i < count_isotopes; i++)
{
@ -770,12 +770,12 @@ print_initial_solution_isotopes(void)
print_centered("Isotopes");
output_msg(sformatf( "%10s\t%12s\t%12s\t%12s\t%12s\n\n", "Isotope",
"Molality", "Moles", "Ratio", "Units"));
for (i = 0; i < count_master_isotope; i++)
for (i = 0; i < (int)master_isotope.size(); i++)
{
if (master_isotope[i]->minor_isotope == FALSE)
{
print_isotope = FALSE;
for (j = 0; j < count_master_isotope; j++)
for (j = 0; j < (int)master_isotope.size(); j++)
{
if ((master_isotope[j]->elt == master_isotope[i]->elt) &&
(master_isotope[j]->minor_isotope == TRUE) &&
@ -794,7 +794,7 @@ print_initial_solution_isotopes(void)
master_isotope[i]->name,
(double) (master_isotope[i]->moles / mass_water_aq_x),
(double) master_isotope[i]->moles));
for (j = 0; j < count_master_isotope; j++)
for (j = 0; j < (int)master_isotope.size(); j++)
{
if (i == j)
continue;
@ -892,11 +892,7 @@ punch_calculate_values(void)
if (current_selected_output->Get_calculate_values().size() == 0)
return OK;
//if (punch.in == FALSE || punch.calculate_values == FALSE)
// return (OK);
//if (punch.count_calculate_values == 0)
// return (OK);
//for (i = 0; i < punch.count_calculate_values; i++)
for (size_t i = 0; i < current_selected_output->Get_calculate_values().size(); i++)
{
result = MISSING;
@ -995,7 +991,7 @@ print_isotope_ratios(void)
* Print heading
*/
print_isotope = FALSE;
for (i = 0; i < count_master_isotope; i++)
for (i = 0; i < (int)master_isotope.size(); i++)
{
if (master_isotope[i]->minor_isotope == FALSE)
continue;
@ -1015,7 +1011,7 @@ print_isotope_ratios(void)
output_msg(sformatf( "%25s\t%12s\t%15s\n\n", "Isotope Ratio",
"Ratio", "Input Units"));
for (j = 0; j < count_isotope_ratio; j++)
for (j = 0; j < (int)isotope_ratio.size(); j++)
{
if (isotope_ratio[j]->ratio == MISSING)
continue;
@ -1057,7 +1053,7 @@ print_isotope_alphas(void)
* Print heading
*/
print_isotope = FALSE;
for (i = 0; i < count_master_isotope; i++)
for (i = 0; i < (int)master_isotope.size(); i++)
{
if (master_isotope[i]->minor_isotope == FALSE)
continue;
@ -1080,7 +1076,7 @@ print_isotope_alphas(void)
" Isotope Ratio", "Solution alpha", "Solution",
(double) tc_x));
for (j = 0; j < count_isotope_alpha; j++)
for (j = 0; j < (int)isotope_alpha.size(); j++)
{
if (isotope_alpha[j]->value == MISSING)
continue;
@ -1132,54 +1128,14 @@ calculate_values(void)
/*
* initialize ratios as missing
*/
for (j = 0; j < count_calculate_value; j++)
for (j = 0; j < calculate_value.size(); j++)
{
calculate_value[j]->calculated = FALSE;
calculate_value[j]->value = MISSING;
}
#ifdef SKIP
for (j = 0; j < count_calculate_value; j++)
{
calculate_value_ptr = calculate_value[j];
rate_moles = NAN;
if (calculate_value_ptr->new_def == TRUE)
{
if (basic_compile
(calculate_value[j]->commands, &calculate_value[j]->linebase,
&calculate_value[j]->varbase,
&calculate_value[j]->loopbase) != 0)
{
error_string = sformatf(
"Fatal Basic error in CALCULATE_VALUES %s.",
calculate_value[j]->name);
error_msg(error_string, STOP);
}
calculate_value_ptr->new_def = FALSE;
}
if (basic_run
(l_command, calculate_value[j]->linebase,
calculate_value[j]->varbase, calculate_value[j]->loopbase) != 0)
{
error_string = sformatf( "Fatal Basic error in calculate_value %s.",
calculate_value[j]->name);
error_msg(error_string, STOP);
}
if (rate_moles == NAN)
{
error_string = sformatf( "Calculated value not SAVEed for %s.",
calculate_value[j]->name);
error_msg(error_string, STOP);
}
else
{
calculate_value[j]->calculated = TRUE;
calculate_value[j]->value = rate_moles;
}
}
#endif
if (pr.isotope_ratios == TRUE)
{
for (j = 0; j < count_isotope_ratio; j++)
for (j = 0; j < (int)isotope_ratio.size(); j++)
{
isotope_ratio_ptr = isotope_ratio[j];
master_isotope_ptr =
@ -1246,7 +1202,7 @@ calculate_values(void)
}
if (pr.isotope_alphas == TRUE)
{
for (j = 0; j < count_isotope_alpha; j++)
for (j = 0; j < (int)isotope_alpha.size(); j++)
{
isotope_alpha_ptr = isotope_alpha[j];
calculate_value_ptr = calculate_value_search(isotope_alpha_ptr->name);
@ -1306,107 +1262,6 @@ calculate_values(void)
}
return (OK);
}
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
calculate_values(void)
/* ---------------------------------------------------------------------- */
{
int j;
struct calculate_value *calculate_value_ptr;
struct isotope_ratio *isotope_ratio_ptr;
struct isotope_alpha *isotope_alpha_ptr;
struct master_isotope *master_isotope_ptr;
char l_command[] = "run";
/*
* initialize ratios as missing
*/
for (j = 0; j < count_calculate_value; j++)
{
calculate_value[j]->calculated = FALSE;
calculate_value[j]->value = MISSING;
}
for (j = 0; j < count_calculate_value; j++)
{
calculate_value_ptr = calculate_value[j];
rate_moles = NAN;
if (calculate_value_ptr->new_def == TRUE)
{
if (basic_compile
(calculate_value[j]->commands, &calculate_value[j]->linebase,
&calculate_value[j]->varbase,
&calculate_value[j]->loopbase) != 0)
{
error_string = sformatf(
"Fatal Basic error in CALCULATE_VALUES %s.",
calculate_value[j]->name);
error_msg(error_string, STOP);
}
calculate_value_ptr->new_def = FALSE;
}
if (basic_run
(l_command, calculate_value[j]->linebase,
calculate_value[j]->varbase, calculate_value[j]->loopbase) != 0)
{
error_string = sformatf( "Fatal Basic error in calculate_value %s.",
calculate_value[j]->name);
error_msg(error_string, STOP);
}
if (rate_moles == NAN)
{
error_string = sformatf( "Calculated value not SAVEed for %s.",
calculate_value[j]->name);
error_msg(error_string, STOP);
}
else
{
calculate_value[j]->calculated = TRUE;
calculate_value[j]->value = rate_moles;
}
}
for (j = 0; j < count_isotope_ratio; j++)
{
isotope_ratio_ptr = isotope_ratio[j];
master_isotope_ptr =
master_isotope_search(isotope_ratio_ptr->isotope_name);
calculate_value_ptr = calculate_value_search(isotope_ratio_ptr->name);
/*
* Calculate converted isotope ratio
*/
if (calculate_value_ptr->value == MISSING)
{
isotope_ratio_ptr->ratio = MISSING;
isotope_ratio_ptr->converted_ratio = MISSING;
}
else
{
isotope_ratio_ptr->ratio = calculate_value_ptr->value;
isotope_ratio_ptr->converted_ratio =
convert_isotope(master_isotope_ptr,
calculate_value_ptr->value);
}
}
for (j = 0; j < count_isotope_alpha; j++)
{
isotope_alpha_ptr = isotope_alpha[j];
calculate_value_ptr = calculate_value_search(isotope_alpha_ptr->name);
/*
* Calculate converted isotope ratio
*/
if (calculate_value_ptr->value == MISSING)
{
isotope_alpha_ptr->value = MISSING;
}
else
{
isotope_alpha_ptr->value = calculate_value_ptr->value;
}
}
return (OK);
}
#endif
/* ---------------------------------------------------------------------- */
LDBLE Phreeqc::
convert_isotope(struct master_isotope * master_isotope_ptr, LDBLE ratio)
@ -1495,13 +1350,8 @@ master_isotope_store(const char *name, int replace_if_found)
}
else
{
n = count_master_isotope++;
/* make sure there is space in s */
if (count_master_isotope >= max_master_isotope)
{
space((void **) ((void *) &master_isotope), count_master_isotope,
&max_master_isotope, sizeof(struct master_isotope *));
}
n = (int)master_isotope.size();
master_isotope.resize((size_t)n + 1);
/* Make new master_isotope structure */
master_isotope[n] = master_isotope_alloc();
master_isotope_ptr = master_isotope[n];
@ -1663,14 +1513,8 @@ calculate_value_store(const char *name, int replace_if_found)
}
else
{
n = count_calculate_value++;
/* make sure there is space in s */
if (count_calculate_value >= max_calculate_value)
{
space((void **) ((void *) &calculate_value),
count_calculate_value, &max_calculate_value,
sizeof(struct calculate_value *));
}
n = (int)calculate_value.size();
calculate_value.resize((size_t)n+1);
/* Make new calculate_value structure */
calculate_value[n] = calculate_value_alloc();
calculate_value_ptr = calculate_value[n];
@ -1855,13 +1699,8 @@ isotope_ratio_store(const char *name, int replace_if_found)
}
else
{
n = count_isotope_ratio++;
/* make sure there is space in s */
if (count_isotope_ratio >= max_isotope_ratio)
{
space((void **) ((void *) &isotope_ratio), count_isotope_ratio,
&max_isotope_ratio, sizeof(struct isotope_ratio *));
}
n = (int)isotope_ratio.size();
isotope_ratio.resize((size_t)n + 1);
/* Make new isotope_ratio structure */
isotope_ratio[n] = isotope_ratio_alloc();
isotope_ratio_ptr = isotope_ratio[n];
@ -2017,13 +1856,8 @@ isotope_alpha_store(const char *name, int replace_if_found)
}
else
{
n = count_isotope_alpha++;
/* make sure there is space in s */
if (count_isotope_alpha >= max_isotope_alpha)
{
space((void **) ((void *) &isotope_alpha), count_isotope_alpha,
&max_isotope_alpha, sizeof(struct isotope_alpha *));
}
n = (int)isotope_alpha.size();
isotope_alpha.resize((size_t)n + 1);
/* Make new isotope_alpha structure */
isotope_alpha[n] = isotope_alpha_alloc();
isotope_alpha_ptr = isotope_alpha[n];

View File

@ -288,121 +288,7 @@ RESTART: // if limiting rates, jump to here
}
return (OK);
}
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
calc_final_kinetic_reaction(cxxKinetics *kinetics_ptr)
/* ---------------------------------------------------------------------- */
{
/*
* Go through kinetic components to
* using extrapolated values, which were
* stored in moles in run_kinetics
*/
LDBLE coef;
struct phase *phase_ptr;
struct master *master_ptr;
/*
* Go through list and generate list of elements and
* coefficient of elements in reaction
*/
kinetics_ptr->Get_totals().clear();
count_elts = 0;
paren_count = 0;
for (size_t i = 0; i < kinetics_ptr->Get_kinetics_comps().size(); i++)
{
cxxKineticsComp * kinetics_comp_ptr = &(kinetics_ptr->Get_kinetics_comps()[i]);
if (kinetics_comp_ptr->Get_moles() > m_temp[i])
{
kinetics_comp_ptr->Set_moles(m_temp[i]);
kinetics_comp_ptr->Set_m(0);
}
coef = kinetics_comp_ptr->Get_moles();
if (coef == 0.0)
continue;
/*
* Reactant is a pure phase, copy formula into token
*/
cxxNameDouble::iterator it = kinetics_comp_ptr->Get_namecoef().begin();
for ( ; it != kinetics_comp_ptr->Get_namecoef().end(); it++)
{
std::string name = it->first;
LDBLE coef1 = it->second;
phase_ptr = NULL;
int k;
phase_ptr = phase_bsearch(name.c_str(), &k, FALSE);
if (phase_ptr != NULL)
{
add_elt_list(phase_ptr->next_elt,
coef *coef1);
}
else
{
char * temp_name = string_duplicate(name.c_str());
char * ptr = temp_name;
get_elts_in_species(&ptr, coef * coef1);
free_check_null(temp_name);
}
}
if (use.Get_exchange_ptr() != NULL
&& use.Get_exchange_ptr()->Get_related_rate())
{
cxxExchange * exchange_ptr = use.Get_exchange_ptr();
for(size_t j = 0; j < exchange_ptr->Get_exchange_comps().size(); j++)
{
std::string name(exchange_ptr->Get_exchange_comps()[j].Get_rate_name());
if (name.size() > 0)
{
if (strcmp_nocase
(kinetics_comp_ptr->Get_rate_name().c_str(),
name.c_str()) == 0)
{
/* found kinetics component */
char * formula = string_duplicate(exchange_ptr->Get_exchange_comps()[j].Get_formula().c_str());
char * ptr = formula;
get_elts_in_species(&ptr, -coef*exchange_ptr->Get_exchange_comps()[j].Get_phase_proportion());
free_check_null(formula);
}
}
}
}
if (use.Get_surface_ptr() != NULL && use.Get_surface_ptr()->Get_related_rate())
{
for (size_t j = 0; j < use.Get_surface_ptr()->Get_surface_comps().size(); j++)
{
cxxSurfaceComp *surface_comp_ptr = &(use.Get_surface_ptr()->Get_surface_comps()[j]);
if (surface_comp_ptr->Get_rate_name().size() > 0)
{
if (strcmp_nocase
(kinetics_comp_ptr->Get_rate_name().c_str(),
surface_comp_ptr->Get_rate_name().c_str()) == 0)
{
/* found kinetics component */
char * temp_formula = string_duplicate(surface_comp_ptr->Get_formula().c_str());
char *ptr = temp_formula;
/* Surface = 0 when m becomes low ...
*/
if (0.9 * surface_comp_ptr->Get_phase_proportion() *
(kinetics_comp_ptr->Get_m()) < MIN_RELATED_SURFACE)
{
master_ptr = master_bsearch(ptr);
master_ptr->total = 0.0;
}
else
{
get_elts_in_species(&ptr, -coef * surface_comp_ptr->Get_phase_proportion());
}
free_check_null(temp_formula);
}
}
}
}
}
kinetics_ptr->Set_totals(elt_list_NameDouble());
return (OK);
}
#endif
/* ---------------------------------------------------------------------- */
int Phreeqc::
rk_kinetics(int i, LDBLE kin_time, int use_mix, int nsaver,
@ -1189,21 +1075,6 @@ rk_kinetics(int i, LDBLE kin_time, int use_mix, int nsaver,
step_ok, (int) (100 * h_sum / kin_time));
status(0, str, true);
}
#ifdef SKIP
#if !defined(PHREEQCI_GUI)
#ifndef PHREEQ98
if (pr.status == TRUE && status_on == TRUE
&& (int) (1e3 / CLOCKS_PER_SEC * ((float) clock() - status_timer)) > status_interval)
{
char str[MAX_LENGTH];
backspace_screen(37);
sprintf(str, "RK-steps: Bad%4d. OK%5d. Time %3d%%", step_bad,
step_ok, (int) (100 * h_sum / kin_time));
screen_msg(sformatf("%-37s", str));
}
#endif
#endif
#endif
}
EQUAL_RATE_OUT:
@ -2094,398 +1965,6 @@ set_reaction(int i, int use_mix, int use_kinetics)
*/
return (OK);
}
//#define REVISED_CVODE
#ifdef REVISED_CVODE
/* ---------------------------------------------------------------------- */
int Phreeqc::
run_reactions(int i, LDBLE kin_time, int use_mix, LDBLE step_fraction)
/* ---------------------------------------------------------------------- */
{
/*
* Kinetics calculations
* Rates and moles of each reaction are calculated in calc_kinetic_reaction
* Total number of moles in reaction is stored in kinetics[i].totals
*/
int converge, m_iter;
int pr_all_save;
int nsaver;
cxxKinetics *kinetics_ptr;
cxxPPassemblage *pp_assemblage_ptr;
cxxSSassemblage *ss_assemblage_ptr;
cxxUse use_save;
int save_old, n_reactions /*, nok, nbad */ ;
/* CVODE definitions */
realtype ropt[OPT_SIZE], reltol, t, tout, tout1, sum_t;
long int iopt[OPT_SIZE];
int flag;
/*
* Set nsaver
*/
run_reactions_iterations = 0;
kin_time_x = kin_time;
rate_kin_time = kin_time;
nsaver = i;
if (state == TRANSPORT || state == PHAST)
{
if (use_mix == DISP)
{
nsaver = -2;
}
else if (use_mix == STAG)
{
nsaver = -2 - i;
}
}
if (state == ADVECTION)
{
nsaver = -2;
}
/*
* Check that reaction exists for this cell ..
*/
kinetics_ptr = Utilities::Rxn_find(Rxn_kinetics_map, i);
if (kin_time <= 0 ||
(state == REACTION && use.Get_kinetics_in() == FALSE) ||
(state == TRANSPORT && kinetics_ptr == NULL) ||
(state == PHAST && kinetics_ptr == NULL) ||
(state == ADVECTION && kinetics_ptr == NULL))
{
converge = set_and_run_wrapper(i, use_mix, FALSE, nsaver, step_fraction);
if (converge == MASS_BALANCE)
{
error_msg("Negative concentration in system. Stopping calculation.", STOP);
}
run_reactions_iterations += iterations;
}
else
{
/*
* Save moles of kinetic reactants for printout...
*/
size_t count_comps = kinetics_ptr->Get_kinetics_comps().size();
m_temp = (LDBLE *) PHRQ_malloc(count_comps * sizeof(LDBLE));
if (m_temp == NULL)
malloc_error();
m_original = (LDBLE *) PHRQ_malloc(count_comps * sizeof(LDBLE));
if (m_original == NULL)
malloc_error();
for (size_t j = 0; j < kinetics_ptr->Get_kinetics_comps().size(); j++)
{
cxxKineticsComp * kinetics_comp_ptr = &(kinetics_ptr->Get_kinetics_comps()[j]);
m_original[j] = kinetics_comp_ptr->Get_m();
m_temp[j] = kinetics_comp_ptr->Get_m();
}
/*
* Start the loop for timestepping ...
* Use either Runge-Kutta-Fehlberg, or final result extrapolation
*/
pr_all_save = pr.all;
pr.all = FALSE;
/*
* This condition makes output equal for incremental_reactions TRUE/FALSE...
* (if (incremental_reactions == FALSE || reaction_step == 1)
*/
store_get_equi_reactants(i, FALSE);
if (!kinetics_ptr->Get_use_cvode())
{
rk_kinetics(i, kin_time, use_mix, nsaver, step_fraction);
// finish up
rate_sim_time = rate_sim_time_start + kin_time;
store_get_equi_reactants(i, TRUE);
pr.all = pr_all_save;
kinetics_ptr = Utilities::Rxn_find(Rxn_kinetics_map, i);
for (size_t j = 0; j < kinetics_ptr->Get_kinetics_comps().size(); j++)
{
cxxKineticsComp * kinetics_comp_ptr = &(kinetics_ptr->Get_kinetics_comps()[j]);
kinetics_comp_ptr->Set_moles(m_original[j] - kinetics_comp_ptr->Get_m());
}
m_temp = (LDBLE *) free_check_null(m_temp);
m_original = (LDBLE *) free_check_null(m_original);
}
else
{
// save initial reactants
// cxxStorageBin save_bin(use); // if needed
save_old = -2 - (count_cells * (1 + stag_data->count_stag) + 2);
if (nsaver != i)
{
Utilities::Rxn_copy(Rxn_solution_map, i, save_old);
}
for (int j = 0; j < OPT_SIZE; j++)
{
iopt[j] = 0;
ropt[j] = 0;
}
/*
* Do mix first
*/
kinetics_ptr = Utilities::Rxn_find(Rxn_kinetics_map, i);
n_reactions = (int) kinetics_ptr->Get_kinetics_comps().size();
cvode_n_user = i;
cvode_kinetics_ptr = (void *) kinetics_ptr;
cvode_n_reactions = n_reactions;
cvode_rate_sim_time_start = rate_sim_time_start;
cvode_rate_sim_time = rate_sim_time;
if (multi_Dflag)
converge = set_and_run_wrapper(i, NOMIX, FALSE, i, 0.0);
else
converge = set_and_run_wrapper(i, use_mix, FALSE, i, 0.0);
if (converge == MASS_BALANCE)
error_msg
("Negative concentration in system. Stopping calculation.",
STOP);
saver();
pp_assemblage_ptr = Utilities::Rxn_find(Rxn_pp_assemblage_map, i);
ss_assemblage_ptr = Utilities::Rxn_find(Rxn_ss_assemblage_map, i);
if (pp_assemblage_ptr != NULL)
{
cvode_pp_assemblage_save = new cxxPPassemblage(*pp_assemblage_ptr);
}
if (ss_assemblage_ptr != NULL)
{
cvode_ss_assemblage_save = new cxxSSassemblage(*ss_assemblage_ptr);
}
/* allocate space for CVODE */
kinetics_machEnv = M_EnvInit_Serial(n_reactions);
kinetics_machEnv->phreeqc_ptr = this;
kinetics_y = N_VNew(n_reactions, kinetics_machEnv); /* Allocate y, abstol vectors */
if (kinetics_y == NULL)
malloc_error();
cvode_last_good_y = N_VNew(n_reactions, kinetics_machEnv); /* Allocate y, abstol vectors */
if (cvode_last_good_y == NULL)
malloc_error();
cvode_prev_good_y = N_VNew(n_reactions, kinetics_machEnv); /* Allocate y, abstol vectors */
if (cvode_prev_good_y == NULL)
malloc_error();
kinetics_abstol = N_VNew(n_reactions, kinetics_machEnv);
if (kinetics_abstol == NULL)
malloc_error();
for (int j = 0; j < n_reactions; j++)
{
Ith(cvode_last_good_y, j + 1) = 0.0;
Ith(cvode_prev_good_y, j + 1) = 0.0;
Ith(kinetics_abstol, j + 1) = 0.0;
}
/*
* Set y to 0.0
*/
for (size_t j = 0; j < kinetics_ptr->Get_kinetics_comps().size(); j++)
{
cxxKineticsComp * kinetics_comp_ptr = &(kinetics_ptr->Get_kinetics_comps()[j]);
kinetics_comp_ptr->Set_moles(0.0);
Ith(kinetics_y, j + 1) = 0.0;
Ith(kinetics_abstol, j + 1) = kinetics_comp_ptr->Get_tol();
}
reltol = 0.0;
/* Call CVodeMalloc to initialize CVODE:
NEQ is the problem size = number of equations
f is the user's right hand side function in y'=f(t,y)
T0 is the initial time
y is the initial dependent variable vector
BDF specifies the Backward Differentiation Formula
NEWTON specifies a Newton iteration
SV specifies scalar relative and vector absolute tolerances
&reltol is a pointer to the scalar relative tolerance
abstol is the absolute tolerance vector
FALSE indicates there are no optional inputs in iopt and ropt
iopt is an array used to communicate optional integer input and output
ropt is an array used to communicate optional real input and output
A pointer to CVODE problem memory is returned and stored in cvode_mem. */
/* Don`t know what this does */
/*
iopt[SLDET] = TRUE;
cvode_mem = CVodeMalloc(n_reactions, f, 0.0, y, BDF, NEWTON, SV, &reltol, abstol, NULL, NULL, TRUE, iopt, ropt, machEnv);
cvode_mem = CVodeMalloc(n_reactions, f, 0.0, y, ADAMS, FUNCTIONAL, SV, &reltol, abstol, NULL, NULL, FALSE, iopt, ropt, machEnv);
iopt[MXSTEP] is maximum number of steps that CVODE tries.
*/
iopt[MXSTEP] = kinetics_ptr->Get_cvode_steps();
iopt[MAXORD] = kinetics_ptr->Get_cvode_order();
kinetics_cvode_mem =
CVodeMalloc(n_reactions, f, 0.0, kinetics_y, BDF, NEWTON, SV,
&reltol, kinetics_abstol, this, NULL, TRUE, iopt,
ropt, kinetics_machEnv);
if (kinetics_cvode_mem == NULL)
malloc_error();
/* Call CVDense to specify the CVODE dense linear solver with the
user-supplied Jacobian routine Jac. */
flag = CVDense(kinetics_cvode_mem, Jac, this);
if (flag != SUCCESS)
{
error_msg("CVDense failed.", STOP);
}
t = 0;
tout = kin_time;
/*ropt[HMAX] = tout/10.; */
/*ropt[HMIN] = 1e-17; */
use_save = use;
flag = CVode(kinetics_cvode_mem, tout, kinetics_y, &t, NORMAL);
rate_sim_time = rate_sim_time_start + t;
/*
printf("At t = %0.4e y =%14.6e %14.6e %14.6e\n",
t, Ith(y,1), Ith(y,2), Ith(y,3));
*/
m_iter = 0;
sum_t = 0;
RESTART:
while (flag != SUCCESS)
{
sum_t += cvode_last_good_time;
error_string = sformatf(
"CVode incomplete at cvode_steps %d. Cell: %d\tTime: %e\tCvode calls: %d, continuing...\n",
(int) iopt[NST], cell_no, (double) sum_t, m_iter + 1);
warning_msg(error_string);
// run with last good y, update reactants
cvode_update_reactants(i, nsaver, true);
cvode_last_good_time = 0;
if (++m_iter >= kinetics_ptr->Get_bad_step_max())
{
m_temp = (LDBLE *) free_check_null(m_temp);
m_original = (LDBLE *) free_check_null(m_original);
error_msg("Repeated restart of integration.", STOP);
}
tout1 = tout - sum_t;
t = 0;
N_VScale(1.0, cvode_last_good_y, kinetics_y);
for (int j = 0; j < OPT_SIZE; j++)
{
iopt[j] = 0;
ropt[j] = 0;
}
CVodeFree(kinetics_cvode_mem); /* Free the CVODE problem memory */
iopt[MXSTEP] = kinetics_ptr->Get_cvode_steps();
iopt[MAXORD] = kinetics_ptr->Get_cvode_order();
kinetics_cvode_mem =
CVodeMalloc(n_reactions, f, 0.0, kinetics_y, BDF, NEWTON,
SV, &reltol, kinetics_abstol, this, NULL,
TRUE, iopt, ropt, kinetics_machEnv);
if (kinetics_cvode_mem == NULL)
malloc_error();
/* Call CVDense to specify the CVODE dense linear solver with the
user-supplied Jacobian routine Jac. */
flag = CVDense(kinetics_cvode_mem, Jac, this);
if (flag != SUCCESS)
{
error_msg("CVDense failed.", STOP);
}
flag = CVode(kinetics_cvode_mem, tout1, kinetics_y, &t, NORMAL);
}
// end cvode integration
// update
#ifdef SKIP
for (size_t j = 0; j < kinetics_ptr->Get_kinetics_comps().size(); j++)
{
cxxKineticsComp * kinetics_comp_ptr = &(kinetics_ptr->Get_kinetics_comps()[j]);
kinetics_comp_ptr->Set_moles(Ith(kinetics_y, j + 1));
kinetics_comp_ptr->Set_m(m_original[j] - kinetics_comp_ptr->Get_moles());
if (kinetics_comp_ptr->Get_m() < 0)
{
kinetics_comp_ptr->Set_moles(m_original[j]);
kinetics_comp_ptr->Set_m(0.0);
}
}
if (use.Get_pp_assemblage_ptr() != NULL)
{
Rxn_pp_assemblage_map[cvode_pp_assemblage_save->Get_n_user()] = *cvode_pp_assemblage_save;
use.Set_pp_assemblage_ptr(Utilities::Rxn_find(Rxn_pp_assemblage_map, cvode_pp_assemblage_save->Get_n_user()));
}
if (use.Get_ss_assemblage_ptr() != NULL)
{
Rxn_ss_assemblage_map[cvode_ss_assemblage_save->Get_n_user()] = *cvode_ss_assemblage_save;
use.Set_ss_assemblage_ptr(Utilities::Rxn_find(Rxn_ss_assemblage_map, cvode_ss_assemblage_save->Get_n_user()));
}
#endif
// put remaining kinetic reaction in last_good_y for update
N_VScale(1.0, kinetics_y, cvode_last_good_y);
if (!cvode_update_reactants(i, nsaver, false))
{
warning_msg("FAIL 2 after successful integration in CVode");
flag = -1;
goto RESTART;
}
#ifdef SKIP
calc_final_kinetic_reaction(kinetics_ptr);
if (set_and_run_wrapper(i, NOMIX, TRUE, nsaver, 1.0) == MASS_BALANCE)
{
warning_msg("FAIL 2 after successful integration in CVode");
flag = -1;
goto RESTART;
}
for (size_t j = 0; j < kinetics_ptr->Get_kinetics_comps().size(); j++)
{
cxxKineticsComp * kinetics_comp_ptr = &(kinetics_ptr->Get_kinetics_comps()[j]);
kinetics_comp_ptr->Set_m(m_original[j] - kinetics_comp_ptr->Get_moles());
}
#endif
/*
* Restore solution i, if necessary
*/
if (nsaver != i)
{
Utilities::Rxn_copy(Rxn_solution_map, save_old, i);
}
free_cvode();
use.Set_mix_in(use_save.Get_mix_in());
use.Set_mix_ptr(use_save.Get_mix_ptr());
// finish up
rate_sim_time = rate_sim_time_start + kin_time;
store_get_equi_reactants(i, TRUE);
pr.all = pr_all_save;
#ifdef SKIP
kinetics_ptr = Utilities::Rxn_find(Rxn_kinetics_map, i);
for (size_t j = 0; j < kinetics_ptr->Get_kinetics_comps().size(); j++)
{
cxxKineticsComp * kinetics_comp_ptr = &(kinetics_ptr->Get_kinetics_comps()[j]);
kinetics_comp_ptr->Set_moles(m_original[j] - kinetics_comp_ptr->Get_m());
}
#else
kinetics_ptr = Utilities::Rxn_find(Rxn_kinetics_map, i);
cxxKinetics *kinetics_original_ptr = Utilities::Rxn_find(Rxn_kinetics_map, use.Get_n_kinetics_user());
for (size_t j = 0; j < kinetics_ptr->Get_kinetics_comps().size(); j++)
{
cxxKineticsComp * kinetics_comp_ptr = &(kinetics_ptr->Get_kinetics_comps()[j]);
cxxKineticsComp * kinetics_original_comp_ptr = &(kinetics_original_ptr->Get_kinetics_comps()[j]);
kinetics_comp_ptr->Set_moles(kinetics_original_comp_ptr->Get_m() - kinetics_comp_ptr->Get_m());
}
#endif
m_temp = (LDBLE *) free_check_null(m_temp);
m_original = (LDBLE *) free_check_null(m_original);
} // end cvode
}
iterations = run_reactions_iterations;
if (cvode_pp_assemblage_save != NULL)
{
delete cvode_pp_assemblage_save;
cvode_pp_assemblage_save = NULL;
}
if (cvode_ss_assemblage_save != NULL)
{
delete cvode_ss_assemblage_save;
cvode_ss_assemblage_save = NULL;
}
return (OK);
}
#else
/* ---------------------------------------------------------------------- */
int Phreeqc::
run_reactions(int i, LDBLE kin_time, int use_mix, LDBLE step_fraction)
@ -2884,7 +2363,7 @@ run_reactions(int i, LDBLE kin_time, int use_mix, LDBLE step_fraction)
}
return (OK);
}
#endif
/* ---------------------------------------------------------------------- */
int Phreeqc::
free_cvode(void)

View File

@ -59,26 +59,11 @@ initialize(void)
cell_data[i].punch = FALSE;
cell_data[i].print = FALSE;
}
space((void **) ((void *) &elements), INIT, &max_elements,
sizeof(struct element *));
space((void **) ((void *) &elt_list), INIT, &max_elts,
sizeof(struct elt_list));
inverse = (struct inverse *) PHRQ_malloc((size_t) sizeof(struct inverse));
if (inverse == NULL) malloc_error();
count_inverse = 0;
space((void **) ((void *) &line), INIT, &max_line, sizeof(char));
space((void **) ((void *) &line_save), INIT, &max_line, sizeof(char));
space((void **) ((void *) &master), INIT, &max_master,
sizeof(struct master *));
space((void **) ((void *) &mb_unknowns), INIT, &max_mb_unknowns,
sizeof(struct unknown_list));
// one stag_data
stag_data = (struct stag_data *) PHRQ_calloc(1, sizeof(struct stag_data));
if (stag_data == NULL)
@ -87,113 +72,14 @@ initialize(void)
stag_data->exch_f = 0;
stag_data->th_m = 0;
stag_data->th_im = 0;
space((void **) ((void *) &phases), INIT, &max_phases,
sizeof(struct phase *));
space((void **) ((void *) &trxn.token), INIT, &max_trxn,
sizeof(struct rxn_token_temp));
space((void **) ((void *) &s), INIT, &max_s, sizeof(struct species *));
space((void **) ((void *) &logk), INIT, &max_logk, sizeof(struct logk *));
space((void **) ((void *) &master_isotope), INIT, &max_master_isotope,
sizeof(struct master_isotope *));
/*
* Create hash tables
*/
hcreate_multi((unsigned) max_logk, &logk_hash_table);
hcreate_multi((unsigned) max_master_isotope, &master_isotope_hash_table);
hcreate_multi((unsigned) max_elements, &elements_hash_table);
hcreate_multi((unsigned) max_s, &species_hash_table);
hcreate_multi((unsigned) max_phases, &phases_hash_table);
#ifdef SKIP_OLD_SELECTED_OUTPUT
/*
* Initialize punch
*/
punch.in = FALSE;
punch.new_def = FALSE;
// one punch.totals
punch.count_totals = 0;
punch.totals =
(struct name_master *) PHRQ_malloc(sizeof(struct name_master));
if (punch.totals == NULL)
malloc_error();
// one punch.molalities
punch.count_molalities = 0;
punch.molalities =
(struct name_species *) PHRQ_malloc(sizeof(struct name_species));
if (punch.molalities == NULL)
malloc_error();
// one punch.activities
punch.count_activities = 0;
punch.activities =
(struct name_species *) PHRQ_malloc(sizeof(struct name_species));
if (punch.activities == NULL)
malloc_error();
// one punch.pure_phases
punch.count_pure_phases = 0;
punch.pure_phases =
(struct name_phase *) PHRQ_malloc(sizeof(struct name_phase));
if (punch.pure_phases == NULL)
malloc_error();
// one punch.si
punch.count_si = 0;
punch.si = (struct name_phase *) PHRQ_malloc(sizeof(struct name_phase));
if (punch.si == NULL)
malloc_error();
// one punch.gases
punch.count_gases = 0;
punch.gases =
(struct name_phase *) PHRQ_malloc(sizeof(struct name_phase));
if (punch.gases == NULL)
malloc_error();
// one punch.s_s
punch.count_s_s = 0;
punch.s_s = (struct name_phase *) PHRQ_malloc(sizeof(struct name_phase));
if (punch.s_s == NULL)
malloc_error();
// one punch.kinetics
punch.count_kinetics = 0;
punch.kinetics =
(struct name_phase *) PHRQ_malloc(sizeof(struct name_phase));
if (punch.kinetics == NULL)
malloc_error();
// one punch.isotopes
punch.count_isotopes = 0;
punch.isotopes =
(struct name_master *) PHRQ_malloc(sizeof(struct name_master));
if (punch.isotopes == NULL)
malloc_error();
// one punch.calculate_values
punch.count_calculate_values = 0;
punch.calculate_values =
(struct name_master *) PHRQ_malloc(sizeof(struct name_master));
if (punch.calculate_values == NULL)
malloc_error();
#endif
// one save_values
save_values =
(struct save_values *) PHRQ_malloc(sizeof(struct save_values));
if (save_values == NULL)
malloc_error();
// one rate
rates = (struct rate *) PHRQ_malloc(sizeof(struct rate));
if (rates == NULL)
malloc_error();
hcreate_multi((unsigned) MAX_S, &logk_hash_table);
hcreate_multi((unsigned) MAX_ELTS, &master_isotope_hash_table);
hcreate_multi((unsigned) MAX_ELTS, &elements_hash_table);
hcreate_multi((unsigned) MAX_S, &species_hash_table);
hcreate_multi((unsigned) MAX_PHASES, &phases_hash_table);
// user_print
user_print = (struct rate *) PHRQ_malloc((size_t) sizeof(struct rate));
@ -203,37 +89,6 @@ initialize(void)
user_print->linebase = NULL;
user_print->varbase = NULL;
user_print->loopbase = NULL;
#ifdef SKIP
// user_punch
user_punch = (struct rate *) PHRQ_malloc((size_t) sizeof(struct rate));
if (user_punch == NULL)
malloc_error();
user_punch->commands = NULL;
user_punch->linebase = NULL;
user_punch->varbase = NULL;
user_punch->loopbase = NULL;
user_punch_headings = (const char **) PHRQ_malloc(sizeof(char *));
if (user_punch_headings == NULL)
malloc_error();
user_punch_count_headings = 0;
#endif
#if defined PHREEQ98
/*
* user_graph
*/
user_graph = (struct rate *) PHRQ_malloc((size_t) sizeof(struct rate));
if (user_graph == NULL)
malloc_error();
user_graph->commands = NULL;
user_graph->linebase = NULL;
user_graph->varbase = NULL;
user_graph->loopbase = NULL;
user_graph_headings = (char **) PHRQ_malloc(sizeof(char *));
if (user_graph_headings == NULL)
malloc_error();
user_graph_count_headings = 0;
#endif
/*
Initialize llnl aqueous model parameters
*/
@ -283,26 +138,14 @@ initialize(void)
#endif
/* calculate_value */
max_calculate_value = MAX_ELTS;
count_calculate_value = 0;
space((void **) ((void *) &calculate_value), INIT, &max_calculate_value,
sizeof(struct calculate_value *));
hcreate_multi((unsigned) max_calculate_value,
hcreate_multi((unsigned) MAX_ELTS,
&calculate_value_hash_table);
/* isotope_ratio */
max_isotope_ratio = MAX_ELTS;
count_isotope_ratio = 0;
space((void **) ((void *) &isotope_ratio), INIT, &max_isotope_ratio,
sizeof(struct isotope_ratio *));
hcreate_multi((unsigned) max_isotope_ratio, &isotope_ratio_hash_table);
hcreate_multi((unsigned) MAX_ELTS, &isotope_ratio_hash_table);
/* isotope_value */
max_isotope_alpha = MAX_ELTS;
count_isotope_alpha = 0;
space((void **) ((void *) &isotope_alpha), INIT, &max_isotope_alpha,
sizeof(struct isotope_alpha *));
hcreate_multi((unsigned) max_isotope_alpha, &isotope_alpha_hash_table);
/* isotope_alpha */
hcreate_multi((unsigned) MAX_ELTS, &isotope_alpha_hash_table);
/*
* define constant named log_k
@ -334,12 +177,6 @@ initialize(void)
// Allocate space for sit
sit_init();
// Allocate zeros
zeros = (LDBLE *) PHRQ_malloc(sizeof(LDBLE));
if (zeros == NULL)
malloc_error();
zeros[0] = 0.0;
zeros_max = 1;
use_kinetics_limiter = false;
return;
@ -710,26 +547,6 @@ initial_solutions(int print)
initial_solution_isotopes = FALSE;
return (OK);
}
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
solution_mix()
/* ---------------------------------------------------------------------- */
{
/*
* Go through list of solution_mix, mix, save solutions
*/
std::map<int, cxxMix>::iterator it;
for (it = Rxn_solution_mix_map.begin(); it != Rxn_solution_mix_map.end(); it++)
{
cxxSolution sol(Rxn_solution_map, it->second, it->second.Get_n_user(), this->phrq_io);
Rxn_solution_map[it->second.Get_n_user()] = sol;
Utilities::Rxn_copies(Rxn_solution_map, it->second.Get_n_user(), it->second.Get_n_user_end());
}
Rxn_solution_mix_map.clear();
return OK;
}
#endif
/* ---------------------------------------------------------------------- */
int Phreeqc::
initial_exchangers(int print)
@ -1310,7 +1127,7 @@ xexchange_save(int n_user)
count_elts = 0;
paren_count = 0;
charge = 0.0;
for (j = 0; j < count_species_list; j++)
for (j = 0; j < (int)species_list.size(); j++)
{
if (species_list[j].master_s == x[i]->master[0]->s)
{
@ -1531,7 +1348,7 @@ xsolution_save(int n_user)
*/
if (initial_solution_isotopes == TRUE)
{
for (int i = 0; i < count_master_isotope; i++)
for (int i = 0; i < (int)master_isotope.size(); i++)
{
if (master_isotope[i]->moles > 0)
{
@ -1572,7 +1389,7 @@ xsolution_save(int n_user)
/*
* Copy totals data
*/
for (int i = 0; i < count_master; i++)
for (int i = 0; i < (int)master.size(); i++)
{
if (master[i]->s->type == EX ||
master[i]->s->type == SURF || master[i]->s->type == SURF_PSI)
@ -1601,7 +1418,7 @@ xsolution_save(int n_user)
}
if (pitzer_model == TRUE || sit_model == TRUE)
{
for (int j = 0; j < count_s_x; j++)
for (int j = 0; j < (int)this->s_x.size(); j++)
{
if (s_x[j]->lg != 0.0)
{
@ -1636,42 +1453,11 @@ xsolution_save(int n_user)
warning_msg(error_string);
}
}
#ifdef SKIP
/*
* Bug-fix
* Create and initialize intial data (this object should always be present even if it is left empty)
*/
temp_solution.Create_initial_data();
cxxISolution* initialData = temp_solution.Get_initial_data();
initialData->Set_units( "Mol/kgw" );
// Copy totals to initialdata when present
if ( !temp_solution.Get_totals().empty() )
{
cxxNameDouble& totals = temp_solution.Get_totals();
for (cxxNameDouble::iterator jit = totals.begin(); jit != totals.end(); jit++)
{
std::string compName( jit->first );
double compConc = jit->second;
SolutionCompMap& comps = initialData->Get_comps();
cxxISolutionComp& tempComp = comps[ compName ];
tempComp.Set_description( compName.c_str() );
tempComp.Set_input_conc( compConc / temp_solution.Get_mass_water());
tempComp.Set_units( initialData->Get_units().c_str() );
}
}
#endif
if (this->save_species)
{
// saves mol/L
temp_solution.Get_species_map().clear();
for (int i = 0; i < this->count_s_x; i++)
for (int i = 0; i < (int)this->s_x.size(); i++)
{
if (s_x[i]->type <= H2O)
{
@ -1680,7 +1466,7 @@ xsolution_save(int n_user)
}
// saves gamma
temp_solution.Get_log_gamma_map().clear();
for (int i = 0; i < this->count_s_x; i++)
for (int i = 0; i < (int)this->s_x.size(); i++)
{
if (s_x[i]->type <= H2O)
{
@ -1689,7 +1475,7 @@ xsolution_save(int n_user)
}
// saves molalities
temp_solution.Get_log_molalities_map().clear();
for (int i = 0; i < this->count_s_x; i++)
for (int i = 0; i < (int)this->s_x.size(); i++)
{
if (s_x[i]->type <= H2O)
{
@ -1756,7 +1542,7 @@ xsurface_save(int n_user)
count_elts = 0;
paren_count = 0;
charge = 0.0;
for (int j = 0; j < count_species_list; j++)
for (int j = 0; j < (int)species_list.size(); j++)
{
if (species_list[j].master_s == x[i]->master[0]->s)
{
@ -1834,7 +1620,7 @@ xsurface_save(int n_user)
{
cxxSurfaceCharge & charge_ref = surface_ptr->Get_surface_charges()[i];
double mass_water_surface = charge_ref.Get_mass_water();
for (int j = 0; j < count_s_x; j++)
for (int j = 0; j < (int)this->s_x.size(); j++)
{
if (s_x[j]->type > H2O)
continue;
@ -1842,7 +1628,6 @@ xsurface_save(int n_user)
double moles_excess = mass_water_aq_x * molality * charge_ref.Get_g_map()[s_x[j]->z].Get_g();
double moles_surface = mass_water_surface * molality + moles_excess;
charge_ref.Get_dl_species_map()[s_x[j]->number] = moles_surface/mass_water_surface;
//#ifdef SKIP
double g = charge_ref.Get_g_map()[s_x[j]->z].Get_g();
//double moles_excess = mass_water_aq_x * molality * (g * s_x[j]->erm_ddl +
// mass_water_surface /
@ -1858,9 +1643,6 @@ xsurface_save(int n_user)
moles_excess = mass_water_aq_x * molality * g;
double c = (mass_water_surface * molality + moles_excess) / mass_water_surface;
charge_ref.Get_dl_species_map()[s_x[j]->number] = c;
//#endif
}
//charge_ref.Get_dl_species_map()[s_h2o->number] = 0.0;
charge_ref.Get_dl_species_map()[s_h2o->number] = 1.0/gfw_water;
@ -2041,7 +1823,7 @@ step_save_exch(int n_user)
}
// Set exchange total in one component
for (int i = 0; i < count_master; i++)
for (int i = 0; i < (int)master.size(); i++)
{
if (master[i]->s->type != EX)
continue;
@ -2086,7 +1868,7 @@ step_save_surf(int n_user)
return (OK);
Utilities::Rxn_copy(Rxn_surface_map, use.Get_surface_ptr()->Get_n_user(), n_user);
cxxSurface *surface_ptr = Utilities::Rxn_find(Rxn_surface_map, n_user);
for (int i = 0; i < count_master; i++)
for (int i = 0; i < (int)master.size(); i++)
{
if (master[i]->s->type != SURF)
continue;
@ -2459,12 +2241,10 @@ run_simulations(void)
/* ---------------------------------------------------------------------- */
{
char token[MAX_LENGTH];
//#ifdef SKIP_KEEP
#if defined(_MSC_VER) && (_MSC_VER < 1900) // removed in vs2015
unsigned int old_exponent_format;
old_exponent_format = _set_output_format(_TWO_DIGIT_EXPONENT);
#endif
//#endif
/*
* Prepare error handling
*/
@ -2529,11 +2309,6 @@ run_simulations(void)
output_msg(sformatf( "%s\n\n", title_x));
}
tidy_model();
#ifdef PHREEQ98
if (!phreeq98_debug)
{
#endif
/*
* Calculate distribution of species for initial solutions
*/
@ -2608,9 +2383,6 @@ run_simulations(void)
dup_print("End of simulation.", TRUE);
output_flush();
error_flush();
#ifdef PHREEQ98
} /* if (!phreeq98_debug) */
#endif
}
}
catch (const PhreeqcStop&)

View File

@ -259,26 +259,6 @@ model(void)
return (OK);
}
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
adjust_step_size(void)
/* ---------------------------------------------------------------------- */
{
/*
* Step sizes are cut down if overflow occurs in molalities
*/
pe_step_size_now -= (pe_step_size_now - 1.0) / 2.0;
step_size_now -= (step_size_now - 1.) / 2.0;
if (pe_step_size_now < 1.5)
pe_step_size_now = 1.5;
if (step_size_now < 1.5)
step_size_now = 1.5;
log_msg(sformatf( "\tNew step sizes: %f\t%f\t%d\n",
step_size_now, pe_step_size_now, iterations));
return (OK);
}
#endif
/* ---------------------------------------------------------------------- */
int Phreeqc::
check_residuals(void)
@ -657,7 +637,7 @@ gammas(LDBLE mu)
/*
* Calculate activity coefficients
*/
for (i = 0; i < count_s_x; i++)
for (i = 0; i < (int)this->s_x.size(); i++)
{
switch (s_x[i]->gflag)
{
@ -903,7 +883,7 @@ int Phreeqc::gammas_a_f(int i1)
}
}
for (i = 0; i < count_s_x; i++)
for (i = 0; i < (int)this->s_x.size(); i++)
{
if (s_x[i]->gflag != 4 || s_x[i]->primary)
continue;
@ -1045,12 +1025,8 @@ ineq(int in_kode)
/*
* Normalize column
*/
space((void **) ((void *) &normal), count_unknowns, &normal_max,
sizeof(LDBLE));
for (i = 0; i < count_unknowns; i++)
normal[i] = 1.0;
normal.resize((size_t)count_unknowns);
std::fill(normal.begin(), normal.end(), 1.0);
for (i = 0; i < count_unknowns; i++)
{
@ -1146,23 +1122,14 @@ ineq(int in_kode)
*/
max_row_count = 2 * count_unknowns + 2;
max_column_count = count_unknowns + 2;
space((void **) ((void *) &ineq_array), max_row_count * max_column_count,
&ineq_array_max, sizeof(LDBLE));
space((void **) ((void *) &back_eq), max_row_count, &back_eq_max,
sizeof(int));
space((void **) ((void *) &zero), max_row_count, &zero_max,
sizeof(LDBLE));
zero_double(zero, max_row_count);
space((void **) ((void *) &res), max_row_count, &res_max, sizeof(LDBLE));
zero_double(res, max_row_count);
space((void **) ((void *) &delta1), max_column_count, &delta1_max,
sizeof(LDBLE));
zero_double(delta1, max_column_count);
ineq_array.resize((size_t)max_row_count * (size_t)max_column_count);
back_eq.resize((size_t)max_row_count);
zero.resize((size_t)max_row_count);
memset(zero.data(), 0, (size_t)max_row_count * sizeof(double));
res.resize((size_t)max_row_count);
memset(res.data(), 0, (size_t)max_row_count * sizeof(double));
delta1.resize((size_t)max_column_count);
memset(delta1.data(), 0,(size_t)max_column_count * sizeof(double));
/*
* Copy equations to optimize into ineq_array
*/
@ -1411,10 +1378,11 @@ ineq(int in_kode)
{
/* Pure phase is present, force Mass transfer to be <= amount of mineral remaining */
memcpy((void *)
&(ineq_array[l_count_rows * max_column_count]),
(void *) &(zero[0]),
((size_t) count_unknowns + 1) * sizeof(LDBLE));
//memcpy((void *)
// &(ineq_array[l_count_rows * max_column_count]),
// (void *) &(zero[0]),
// ((size_t) count_unknowns + 1) * sizeof(LDBLE));
memset(&ineq_array[l_count_rows * max_column_count], 0, ((size_t) count_unknowns + 1) * sizeof(LDBLE));
ineq_array[l_count_rows * max_column_count + i] = 1.0;
ineq_array[l_count_rows * max_column_count +
count_unknowns] = x[i]->moles;
@ -1424,10 +1392,11 @@ ineq(int in_kode)
/* Pure phase is present and dissolve_only, force ppt to be <= amount of dissolved so far */
if (x[i]->dissolve_only == TRUE)
{
memcpy((void *)
&(ineq_array[l_count_rows * max_column_count]),
(void *) &(zero[0]),
((size_t) count_unknowns + 1) * sizeof(LDBLE));
//memcpy((void *)
// &(ineq_array[l_count_rows * max_column_count]),
// (void *) &(zero[0]),
// ((size_t) count_unknowns + 1) * sizeof(LDBLE));
memset(&(ineq_array[l_count_rows * max_column_count]), 0, ((size_t)count_unknowns + 1) * sizeof(LDBLE));
ineq_array[l_count_rows * max_column_count + i] = -1.0;
ineq_array[l_count_rows * max_column_count +
count_unknowns] =
@ -1609,9 +1578,14 @@ ineq(int in_kode)
{
if (x[i]->type == GAS_MOLES)
{
memcpy((void *) &(ineq_array[l_count_rows * max_column_count]),
(void *) &(zero[0]),
((size_t) count_unknowns + 1) * sizeof(LDBLE));
//memcpy((void *) &(ineq_array[l_count_rows * max_column_count]),
// (void *) &(zero[0]),
// ((size_t) count_unknowns + 1) * sizeof(LDBLE));
//std::fill(&(ineq_array[l_count_rows * max_column_count]),
// &(ineq_array[l_count_rows * max_column_count + count_unknowns]),
// 0.0e0);
memset(&(ineq_array[l_count_rows * max_column_count]), 0,
((size_t)count_unknowns + 1) * sizeof(LDBLE));
ineq_array[l_count_rows * max_column_count + i] = -1.0;
ineq_array[l_count_rows * max_column_count + count_unknowns] =
x[i]->moles;
@ -1647,9 +1621,11 @@ ineq(int in_kode)
break;
if (x[i]->phase->in == TRUE && x[i]->ss_in == TRUE)
{
memcpy((void *) &(ineq_array[l_count_rows * max_column_count]),
(void *) &(zero[0]),
((size_t) count_unknowns + 1) * sizeof(LDBLE));
//memcpy((void *) &(ineq_array[l_count_rows * max_column_count]),
// (void *) &(zero[0]),
// ((size_t) count_unknowns + 1) * sizeof(LDBLE));
memset(&(ineq_array[l_count_rows * max_column_count]), 0,
((size_t)count_unknowns + 1) * sizeof(LDBLE));
ineq_array[l_count_rows * max_column_count + i] = 1.0;
ineq_array[l_count_rows * max_column_count + count_unknowns] =
0.99 * x[i]->moles - MIN_TOTAL_SS;
@ -1719,7 +1695,7 @@ ineq(int in_kode)
if (debug_model == TRUE)
{
output_msg(sformatf( "\nA and B arrays:\n\n"));
array_print(ineq_array, l_count_rows, count_unknowns + 1,
array_print(ineq_array.data(), l_count_rows, count_unknowns + 1,
max_column_count);
}
/*
@ -1777,11 +1753,9 @@ ineq(int in_kode)
/*
* Allocate space for arrays
*/
space((void **) ((void *) &cu), 2 * l_nklmd, &cu_max, sizeof(LDBLE));
space((void **) ((void *) &iu), 2 * l_nklmd, &iu_max, sizeof(int));
space((void **) ((void *) &is), l_klmd, &is_max, sizeof(int));
cu.resize(2 * (size_t)l_nklmd);
iu.resize(2 * (size_t)l_nklmd);
is.resize(l_klmd);
#ifdef SLNQ
slnq_array =
@ -1807,9 +1781,9 @@ ineq(int in_kode)
/*
* Call CL1
*/
cl1(k, l, m, n,
l_nklmd, l_n2d, ineq_array,
&l_kode, ineq_tol, &l_iter, delta1, res, &l_error, cu, iu, is, FALSE);
cl1(k, l, m, n, l_nklmd, l_n2d, ineq_array.data(),
&l_kode, ineq_tol, &l_iter, delta1.data(), res.data(),
&l_error, cu.data(), iu.data(), is.data(), FALSE);
/* Set return_kode */
if (l_kode == 1)
{
@ -1874,8 +1848,10 @@ ineq(int in_kode)
#endif
/* Copy delta1 into delta and scale */
#ifdef SHRINK_ARRAY
memcpy((void *) &(delta[0]), (void *) &(zero[0]),
(size_t) count_unknowns * sizeof(LDBLE));
//memcpy((void *) &(delta[0]), (void *) &(zero[0]),
// (size_t) count_unknowns * sizeof(LDBLE));
memset(&(delta[0]), 0,
(size_t)count_unknowns * sizeof(LDBLE));
#endif
memcpy((void *) &(delta[0]), (void *) &(delta1[0]),
(size_t) n * sizeof(LDBLE));
@ -1977,21 +1953,21 @@ jacobian_sums(void)
/*
* Add constant terms
*/
for (k = 0; k < count_sum_jacob0; k++)
for (k = 0; k < (int)sum_jacob0.size(); k++)
{
*sum_jacob0[k].target += sum_jacob0[k].coef;
}
/*
* Add terms with coefficients of 1.0
*/
for (k = 0; k < count_sum_jacob1; k++)
for (k = 0; k < (int)sum_jacob1.size(); k++)
{
*sum_jacob1[k].target += *sum_jacob1[k].source;
}
/*
* Add terms with coefficients != 1.0
*/
for (k = 0; k < count_sum_jacob2; k++)
for (k = 0; k < (int)sum_jacob2.size(); k++)
{
*sum_jacob2[k].target += *sum_jacob2[k].source * sum_jacob2[k].coef;
}
@ -2158,18 +2134,16 @@ mb_sums(void)
/*
* Add terms with coefficients of 1.0
*/
for (k = 0; k < count_sum_mb1; k++)
for (k = 0; k < (int)sum_mb1.size(); k++)
{
*sum_mb1[k].target += *sum_mb1[k].source;
/* { k += 1; k -= 1;} */
}
/*
* Add terms with coefficients != 1.0
*/
for (k = 0; k < count_sum_mb2; k++)
for (k = 0; k < (int)sum_mb2.size(); k++)
{
*sum_mb2[k].target += *sum_mb2[k].source * sum_mb2[k].coef;
/* { k += 1; k -= 1;} */
}
return (OK);
}
@ -2382,7 +2356,7 @@ molalities(int allow_overflow)
/*
* la for master species
*/
for (i = 0; i < count_master; i++)
for (i = 0; i < (int)master.size(); i++)
{
if (master[i]->in == REWRITE)
{
@ -2400,7 +2374,7 @@ molalities(int allow_overflow)
s_h2o->tot_g_moles = s_h2o->moles;
s_h2o->tot_dh2o_moles = 0.0;
}
for (i = 0; i < count_s_x; i++)
for (i = 0; i < (int)this->s_x.size(); i++)
{
if (s_x[i]->type > HPLUS && s_x[i]->type != EX
&& s_x[i]->type != SURF)
@ -2460,7 +2434,7 @@ molalities(int allow_overflow)
}
struct species *s_ptr = NULL;
for (i = 0; i < count_s_x; i++)
for (i = 0; i < (int)this->s_x.size(); i++)
{
s_ptr = s_x[i];
if (s_ptr->type > HPLUS && s_ptr->type != EX && s_ptr->type != SURF)
@ -2575,217 +2549,7 @@ molalities(int allow_overflow)
return (OK);
}
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
molalities(int allow_overflow)
/* ---------------------------------------------------------------------- */
{
/*
* Calculates la for master species
* Calculates lm and moles from lk, lg, and la's of master species
* Adjusts lm of h2 and o2.
*/
int i, j;
LDBLE total_g;
struct rxn_token *rxn_ptr;
/*
* la for master species
*/
for (i = 0; i < count_master; i++)
{
if (master[i]->in == REWRITE)
{
master[i]->s->la = master[i]->s->lm + master[i]->s->lg;
}
}
if (dl_type_x != cxxSurface::NO_DL)
{
s_h2o->tot_g_moles = s_h2o->moles;
s_h2o->tot_dh2o_moles = 0.0;
}
for (i = 0; i < count_s_x; i++)
{
if (s_x[i]->type > HPLUS && s_x[i]->type != EX
&& s_x[i]->type != SURF)
continue;
/*
* lm and moles for all aqueous species
*/
s_x[i]->lm = s_x[i]->lk - s_x[i]->lg;
for (rxn_ptr = s_x[i]->rxn_x->token + 1; rxn_ptr->s != NULL;
rxn_ptr++)
{
s_x[i]->lm += rxn_ptr->s->la * rxn_ptr->coef;
/*
if (isnan(rxn_ptr->s->la))
{
fprintf(stderr,"molalities la %s %e\n", rxn_ptr->s->name, rxn_ptr->s->la);
}
*/
}
if (s_x[i]->type == EX)
{
s_x[i]->moles = Utilities::safe_exp(s_x[i]->lm * LOG_10);
}
else if (s_x[i]->type == SURF)
{
s_x[i]->moles = Utilities::safe_exp(s_x[i]->lm * LOG_10);
}
else
{
s_x[i]->moles = under(s_x[i]->lm) * mass_water_aq_x;
if (s_x[i]->moles / mass_water_aq_x > 100)
{
log_msg(sformatf( "Overflow: %s\t%e\t%e\t%d\n",
s_x[i]->name,
(double) (s_x[i]->moles / mass_water_aq_x),
(double) s_x[i]->lm, iterations));
if (iterations >= 0 && allow_overflow == FALSE)
{
return (ERROR);
}
}
}
}
/*
* other terms for diffuse layer model
*/
if (use.Get_surface_ptr() != NULL && use.Get_surface_ptr()->Get_type() == cxxSurface::CD_MUSIC
&& dl_type_x != cxxSurface::NO_DL)
calc_all_donnan();
for (i = 0; i < count_s_x; i++)
{
if (s_x[i]->type > HPLUS && s_x[i]->type != EX
&& s_x[i]->type != SURF)
continue;
if (use.Get_surface_ptr() != NULL && dl_type_x != cxxSurface::NO_DL
&& s_x[i]->type <= HPLUS)
{
total_g = 0.0;
s_x[i]->tot_dh2o_moles = 0.0;
for (j = 0; j < (int) use.Get_surface_ptr()->Get_surface_charges().size(); j++)
{
int is = s_x[i]->number;
cxxSurfaceCharge & charge_ref = use.Get_surface_ptr()->Get_surface_charges()[j];
/*
* partially corrected formulation assumes mass of water in diffuse layer
* is insignificant. Excess is calculated on the basis of moles_water_aq_x
* instead of moles_water_bulk.
*/
/* revised eq. 61 */
s_diff_layer[is][charge_ref.Get_name()].Set_g_moles(s_x[i]->moles * s_x[i]->erm_ddl *
(charge_ref.Get_g_map()[s_x[i]->z].Get_g() +
charge_ref.Get_mass_water() /
mass_water_aq_x));
if (s_x[i]->moles > 1e-30)
{
s_diff_layer[is][charge_ref.Get_name()].Set_dg_g_moles(s_x[i]->dg * s_diff_layer[is][charge_ref.Get_name()].Get_g_moles() /
s_x[i]->moles);
}
/*
* first term of 63 is summed for all surfaces in
* s_x[i]->tot_g_moles. This sum is then used in
* the jacobian for species i
*/
total_g +=
charge_ref.Get_g_map()[s_x[i]->z].Get_g() +
charge_ref.Get_mass_water() /
mass_water_aq_x;
/* revised eq. 63, second term */
/* g.dg is dg/dx(-2y**2) or dg/d(ln y) */
s_diff_layer[is][charge_ref.Get_name()].Set_dx_moles(
s_x[i]->moles * s_x[i]->erm_ddl *
charge_ref.Get_g_map()[s_x[i]->z].Get_dg());
/* revised eq. 63, third term */
s_diff_layer[is][charge_ref.Get_name()].Set_dh2o_moles(
-s_x[i]->moles * s_x[i]->erm_ddl *
charge_ref.Get_mass_water() /
mass_water_aq_x);
s_x[i]->tot_dh2o_moles += s_diff_layer[is][charge_ref.Get_name()].Get_dh2o_moles();
/* surface related to phase */
s_diff_layer[is][charge_ref.Get_name()].Set_drelated_moles(
s_x[i]->moles * s_x[i]->erm_ddl *
charge_ref.Get_specific_area() *
use.Get_surface_ptr()->Get_thickness() / mass_water_aq_x);
}
s_x[i]->tot_g_moles =
s_x[i]->moles * (1 + total_g /* s_x[i]->erm_ddl */ );
/* note that dg is for cb, act water, mu eqns */
/* dg_total_g for mole balance eqns */
/* dg_g_moles for surface cb */
if (s_x[i]->moles > 1e-30)
{
s_x[i]->dg_total_g =
s_x[i]->dg * s_x[i]->tot_g_moles / s_x[i]->moles;
}
else
{
s_x[i]->dg_total_g = 0.0;
}
if (debug_diffuse_layer == TRUE)
{
output_msg(sformatf( "%s\t%e\t%e\n", s_x[i]->name,
(double) s_x[i]->moles,
(double) s_x[i]->tot_g_moles));
output_msg(sformatf( "\tg\n"));
for (j = 0; j < (int) use.Get_surface_ptr()->Get_surface_charges().size(); j++)
{
cxxSurfaceCharge &charge_ref = use.Get_surface_ptr()->Get_surface_charges()[j];
output_msg(sformatf( "\t%e",
(double) charge_ref.Get_g_map()[s_x[i]->z].Get_g()));
}
output_msg(sformatf( "\n\tg_moles\n"));
for (j = 0; j < (int) use.Get_surface_ptr()->Get_surface_charges().size(); j++)
{
cxxSurfaceCharge &charge_ref = use.Get_surface_ptr()->Get_surface_charges()[j];
int is = s_x[i]->number;
output_msg(sformatf( "\t%e",
(double) s_diff_layer[is][charge_ref.Get_name()].Get_g_moles()));
}
output_msg(sformatf( "\n\tdg\n"));
for (j = 0; j < (int) use.Get_surface_ptr()->Get_surface_charges().size(); j++)
{
cxxSurfaceCharge &charge_ref = use.Get_surface_ptr()->Get_surface_charges()[j];
output_msg(sformatf( "\t%e",
(double) charge_ref.Get_g_map()[s_x[i]->z].Get_dg()));
}
output_msg(sformatf( "\n\tdx_moles\n"));
for (j = 0; j < (int) use.Get_surface_ptr()->Get_surface_charges().size(); j++)
{
int is = s_x[i]->number;
cxxSurfaceCharge &charge_ref = use.Get_surface_ptr()->Get_surface_charges()[j];
output_msg(sformatf( "\t%e",
(double) s_diff_layer[is][charge_ref.Get_name()].Get_dx_moles()));
}
output_msg(sformatf( "\n\tdh2o_moles\t%e\n",
(double) s_x[i]->tot_dh2o_moles));
for (j = 0; j < (int) use.Get_surface_ptr()->Get_surface_charges().size(); j++)
{
cxxSurfaceCharge &charge_ref = use.Get_surface_ptr()->Get_surface_charges()[j];
int is = s_x[i]->number;
output_msg(sformatf( "\t%e",
s_diff_layer[is][charge_ref.Get_name()].Get_dh2o_moles()));
}
output_msg(sformatf( "\n"));
}
}
}
calc_gas_pressures();
calc_ss_fractions();
return (OK);
}
#endif
/* ---------------------------------------------------------------------- */
int Phreeqc::
calc_gas_pressures(void)
@ -3391,7 +3155,7 @@ reset(void)
x[i]->delta = 0.0;
}
for (i = 0; i < count_sum_delta; i++)
for (i = 0; i < (int)sum_delta.size(); i++)
{
*sum_delta[i].target += *sum_delta[i].source * sum_delta[i].coef;
}
@ -4612,7 +4376,7 @@ residuals(void)
{
sum = 0;
sum1 = 0;
for (j = 0; j < count_s_x; j++)
for (j = 0; j < (int)this->s_x.size(); j++)
{
if (s_x[j]->type == SURF)
{
@ -4658,7 +4422,7 @@ residuals(void)
negfpsirt = master_ptr2->s->la * LOG_10;
sum = 0;
sum1 = 0;
for (j = 0; j < count_s_x; j++)
for (j = 0; j < (int)this->s_x.size(); j++)
{
if (s_x[j]->type < H2O)
{
@ -4813,7 +4577,7 @@ set(int initial)
return (set_sit(initial));
iterations = -1;
solution_ptr = use.Get_solution_ptr();
for (i = 0; i < count_s_x; i++)
for (i = 0; i < (int)this->s_x.size(); i++)
{
s_x[i]->lm = LOG_ZERO_MOLALITY;
s_x[i]->lg = 0.0;
@ -5032,10 +4796,7 @@ revise_guesses(void)
{
repeat = TRUE;
d = 0;
#ifdef SKIP
d = weight * log10(fabs(x[i]->moles / x[i]->sum));
double d1 = d;
#else
// avoid underflows and overflows
if (x[i]->moles > 1e101 || x[i]->moles < 1e-101 ||
x[i]->sum > 1e101 || x[i]->sum < 1e-101)
@ -5074,7 +4835,6 @@ revise_guesses(void)
{
x[i]->master[0]->s->la += 5.0;
}
#endif
}
if (debug_set == TRUE)
{
@ -5161,7 +4921,7 @@ sum_species(void)
total_ions_x = 0.0;
total_o_x = 0.0;
total_h_x = 0.0;
for (i = 0; i < count_s_x; i++)
for (i = 0; i < (int)this->s_x.size(); i++)
{
if (s_x[i]->type == EX)
continue;
@ -5189,12 +4949,12 @@ sum_species(void)
/*
* Sum valence states, put in master->total
*/
for (i = 0; i < count_master; i++)
for (i = 0; i < (int)master.size(); i++)
{
master[i]->total = 0.0;
master[i]->total_primary = 0.0;
}
for (i = 0; i < count_species_list; i++)
for (i = 0; i < (int)species_list.size(); i++)
{
if (species_list[i].master_s->secondary != NULL)
{
@ -5231,7 +4991,7 @@ sum_species(void)
/*
* Calculate total element concentrations
*/
for (i = 0; i < count_master; i++)
for (i = 0; i < (int)master.size(); i++)
{
master[i]->elt->primary->total_primary += master[i]->total;
}
@ -5268,7 +5028,7 @@ surface_model(void)
if (dl_type_x != cxxSurface::NO_DL && same_model == FALSE)
{
s_diff_layer.clear();
for (i = 0; i < count_s; i++)
for (i = 0; i < (int)s.size(); i++)
{
std::map < std::string, cxxSpeciesDL > dl;
s_diff_layer.push_back(dl);
@ -5405,32 +5165,23 @@ free_model_allocs(void)
* free space allocated in model
*/
int i;
if (x != NULL)
for (i = 0; i < (int)x.size(); i++)
{
for (i = 0; i < max_unknowns; i++)
{
unknown_free(x[i]);
}
unknown_free(x[i]);
}
x = (struct unknown **) free_check_null(x);
x.clear();
count_unknowns = 0;
max_unknowns = 0;
my_array = (LDBLE *) free_check_null(my_array);
delta = (LDBLE *) free_check_null(delta);
residual = (LDBLE *) free_check_null(residual);
s_x = (struct species **) free_check_null(s_x);
count_s_x = 0;
sum_mb1 = (struct list1 *) free_check_null(sum_mb1);
count_sum_mb1 = 0;
sum_mb2 = (struct list2 *) free_check_null(sum_mb2);
count_sum_mb2 = 0;
sum_jacob0 = (struct list0 *) free_check_null(sum_jacob0);
count_sum_jacob0 = 0;
sum_jacob1 = (struct list1 *) free_check_null(sum_jacob1);
count_sum_jacob1 = 0;
sum_jacob2 = (struct list2 *) free_check_null(sum_jacob2);
count_sum_jacob2 = 0;
sum_delta = (struct list2 *) free_check_null(sum_delta);
count_sum_delta = 0;
my_array.clear();
delta.clear();
residual.clear();
s_x.clear();
sum_mb1.clear();
sum_mb2.clear();
sum_jacob0.clear();
sum_jacob1.clear();
sum_jacob2.clear();
sum_delta.clear();
return (OK);
}
@ -5819,74 +5570,74 @@ void Phreeqc::
ineq_init(int l_max_row_count, int l_max_column_count)
/* ---------------------------------------------------------------------- */
{
if (normal == NULL)
{
normal =
(LDBLE *) PHRQ_malloc((size_t) count_unknowns * sizeof(LDBLE));
normal_max = count_unknowns;
if (normal == NULL)
malloc_error();
}
if (ineq_array == NULL)
{
ineq_array =
(LDBLE *) PHRQ_malloc((size_t) l_max_row_count * l_max_column_count *
sizeof(LDBLE));
if (ineq_array == NULL)
malloc_error();
ineq_array_max = l_max_row_count * l_max_column_count;
}
if (back_eq == NULL)
{
back_eq = (int *) PHRQ_malloc((size_t) l_max_row_count * sizeof(int));
if (back_eq == NULL)
malloc_error();
back_eq_max = l_max_row_count;
}
if (zero == NULL)
{
zero = (LDBLE *) PHRQ_malloc((size_t) l_max_row_count * sizeof(LDBLE));
if (zero == NULL)
malloc_error();
zero_max = l_max_row_count;
}
if (res == NULL)
{
res = (LDBLE *) PHRQ_malloc((size_t) l_max_row_count * sizeof(LDBLE));
if (res == NULL)
malloc_error();
res_max = l_max_row_count;
}
if (delta1 == NULL)
{
delta1 =
(LDBLE *) PHRQ_malloc((size_t) l_max_column_count * sizeof(LDBLE));
if (delta1 == NULL)
malloc_error();
delta1_max = l_max_column_count;
}
if (cu == NULL)
{
cu = (LDBLE *) PHRQ_malloc((size_t) 3 * l_max_row_count *
sizeof(LDBLE));
if (cu == NULL)
malloc_error();
cu_max = 3 * l_max_row_count;
}
if (iu == NULL)
{
iu = (int *) PHRQ_malloc((size_t) 3 * l_max_row_count * sizeof(int));
if (iu == NULL)
malloc_error();
iu_max = 3 * l_max_row_count;
}
if (is == NULL)
{
is = (int *) PHRQ_malloc((size_t) 3 * l_max_row_count * sizeof(int));
if (is == NULL)
malloc_error();
is_max = 3 * l_max_row_count;
}
//if (normal == NULL)
//{
// normal =
// (LDBLE *) PHRQ_malloc((size_t) count_unknowns * sizeof(LDBLE));
// normal_max = count_unknowns;
// if (normal == NULL)
// malloc_error();
//}
////if (ineq_array == NULL)
////{
//// ineq_array =
//// (LDBLE *) PHRQ_malloc((size_t) l_max_row_count * l_max_column_count *
//// sizeof(LDBLE));
//// if (ineq_array == NULL)
//// malloc_error();
//// ineq_array_max = l_max_row_count * l_max_column_count;
////}
//if (back_eq == NULL)
//{
// back_eq = (int *) PHRQ_malloc((size_t) l_max_row_count * sizeof(int));
// if (back_eq == NULL)
// malloc_error();
// back_eq_max = l_max_row_count;
//}
//if (zero == NULL)
//{
// zero = (LDBLE *) PHRQ_malloc((size_t) l_max_row_count * sizeof(LDBLE));
// if (zero == NULL)
// malloc_error();
// zero_max = l_max_row_count;
//}
//if (res == NULL)
//{
// res = (LDBLE *) PHRQ_malloc((size_t) l_max_row_count * sizeof(LDBLE));
// if (res == NULL)
// malloc_error();
// res_max = l_max_row_count;
//}
//if (delta1 == NULL)
//{
// delta1 =
// (LDBLE *) PHRQ_malloc((size_t) l_max_column_count * sizeof(LDBLE));
// if (delta1 == NULL)
// malloc_error();
// delta1_max = l_max_column_count;
//}
//if (cu == NULL)
//{
// cu = (LDBLE *) PHRQ_malloc((size_t) 3 * l_max_row_count *
// sizeof(LDBLE));
// if (cu == NULL)
// malloc_error();
// cu_max = 3 * l_max_row_count;
//}
//if (iu == NULL)
//{
// iu = (int *) PHRQ_malloc((size_t) 3 * l_max_row_count * sizeof(int));
// if (iu == NULL)
// malloc_error();
// iu_max = 3 * l_max_row_count;
//}
//if (is == NULL)
//{
// is = (int *) PHRQ_malloc((size_t) 3 * l_max_row_count * sizeof(int));
// if (is == NULL)
// malloc_error();
// is_max = 3 * l_max_row_count;
//}
}
/* ---------------------------------------------------------------------- */
void Phreeqc::

View File

@ -140,8 +140,8 @@ parse_eq(char *eqn, struct elt_list **elt_ptr, int association)
/*
* Sort elements in reaction and combine
*/
qsort(elt_list, (size_t) count_elts, (size_t) sizeof(struct elt_list),
elt_list_compare);
//qsort(elt_list.data(), (size_t) count_elts, sizeof(struct elt_list),
// elt_list_compare);
if (elt_list_combine() == ERROR)
return (ERROR);
/*
@ -228,8 +228,8 @@ check_eqn(int association)
/*
* Sort elements in reaction and combine
*/
qsort(elt_list, (size_t) count_elts, (size_t) sizeof(struct elt_list),
elt_list_compare);
//qsort(elt_list.data(), (size_t) count_elts, sizeof(struct elt_list),
// elt_list_compare);
if (elt_list_combine() == ERROR)
return (ERROR);
/*
@ -607,10 +607,9 @@ get_elts_in_species(char **t_ptr, LDBLE coef)
{
return (ERROR);
}
if (count_elts >= max_elts)
if (count_elts >= (int)elt_list.size())
{
space((void **) ((void *) &elt_list), count_elts, &max_elts,
sizeof(struct elt_list));
elt_list.resize((size_t)count_elts + 1);
}
elt_list[count_elts].elt = element_store(element);
if (get_num(t_ptr, &d) == ERROR)
@ -622,10 +621,9 @@ get_elts_in_species(char **t_ptr, LDBLE coef)
/*
* Expand working space for elements if necessary
*/
if (count_elts >= max_elts)
if (count_elts >= (int)elt_list.size())
{
space((void **) ((void *) &elt_list), count_elts, &max_elts,
sizeof(struct elt_list));
elt_list.resize((size_t)count_elts + 1);
}
continue;
}
@ -875,10 +873,9 @@ get_secondary_in_species(char **t_ptr, LDBLE coef)
/*
* Expand working space for elements if necessary
*/
if (count_elts >= max_elts)
if (count_elts >= (int)elt_list.size())
{
space((void **) ((void *) &elt_list), count_elts, &max_elts,
sizeof(struct elt_list));
elt_list.resize((size_t)count_elts + 1);
}
continue;
}
@ -1028,11 +1025,8 @@ get_species(char **ptr)
char string[MAX_LENGTH];
int l;
if (count_trxn + 1 >= max_trxn)
{
space((void **) ((void *) &(trxn.token)), count_trxn + 1, &max_trxn,
sizeof(struct rxn_token_temp));
}
if ((size_t) count_trxn + 1 > trxn.token.size())
trxn.token.resize((size_t)count_trxn + 1);
/* coefficient */
if (get_coef(&(trxn.token[count_trxn].coef), ptr) == ERROR)
{

View File

@ -15,16 +15,9 @@ pitzer_init(void)
* Initialization for pitzer
*/
pitzer_model = FALSE;
max_pitz_param = 100;
count_pitz_param = 0;
use_etheta = TRUE;
space((void **) ((void *) &pitz_params), INIT, &max_pitz_param,
sizeof(struct pitz_param *));
max_theta_param = 100;
count_theta_param = 0;
space((void **) ((void *) &theta_params), INIT, &max_theta_param,
sizeof(struct theta_param *));
pitz_params.clear();
theta_params.clear();
ICON = TRUE;
OTEMP = -100.;
@ -65,19 +58,18 @@ pitzer_tidy(void)
*/
if (spec != NULL)
spec = (struct species **) free_check_null(spec);
spec =
(struct species **)
PHRQ_malloc((size_t) (3 * count_s * sizeof(struct species *)));
spec = (struct species **)
PHRQ_malloc((size_t) (3 * s.size() * sizeof(struct species *)));
if (spec == NULL)
malloc_error();
for (i = 0; i < 3 * count_s; i++)
for (i = 0; i < 3 * (int)s.size(); i++)
spec[i] = NULL;
cations = spec;
neutrals = &(spec[count_s]);
anions = &(spec[2 * count_s]);
MAXCATIONS = count_s;
FIRSTANION = 2 * count_s;
MAXNEUTRAL = count_s;
neutrals = &(spec[s.size()]);
anions = &(spec[2 * s.size()]);
MAXCATIONS = (int)s.size();
FIRSTANION = 2 * (int)s.size();
MAXNEUTRAL = (int)s.size();
count_cations = 0;
count_anions = 0;
count_neutrals = 0;
@ -88,22 +80,22 @@ pitzer_tidy(void)
*/
if (IPRSNT != NULL)
IPRSNT = (int *) free_check_null(IPRSNT);
IPRSNT = (int *) PHRQ_malloc((size_t) (3 * count_s * sizeof(int)));
IPRSNT = (int *) PHRQ_malloc((size_t) (3 * s.size() * sizeof(int)));
if (IPRSNT == NULL)
malloc_error();
if (M != NULL)
M = (LDBLE *) free_check_null(M);
M = (LDBLE *) PHRQ_malloc((size_t) (3 * count_s * sizeof(LDBLE)));
M = (LDBLE *) PHRQ_malloc((size_t) (3 * s.size() * sizeof(LDBLE)));
if (M == NULL)
malloc_error();
if (LGAMMA != NULL)
LGAMMA = (LDBLE *) free_check_null(LGAMMA);
LGAMMA = (LDBLE *) PHRQ_malloc((size_t) (3 * count_s * sizeof(LDBLE)));
LGAMMA = (LDBLE *) PHRQ_malloc((size_t) (3 * s.size() * sizeof(LDBLE)));
if (LGAMMA == NULL)
malloc_error();
for (i = 0; i < count_s; i++)
for (i = 0; i < (int)s.size(); i++)
{
if (s[i] == s_eminus)
continue;
@ -129,20 +121,21 @@ pitzer_tidy(void)
* cation-cation or anion-anion pair
* Remove old TYPE_ETHETA definitions
*/
j = 0;
for (i = 0; i < count_pitz_param; i++)
std::vector<pitz_param*> pitz_params_temp = pitz_params;
pitz_params.clear();
for (i = 0; i < (int)pitz_params_temp.size(); i++)
{
if (pitz_params[i]->type == TYPE_ETHETA)
if (pitz_params_temp[i]->type == TYPE_ETHETA)
{
pitz_params[i] =
(struct pitz_param *) free_check_null(pitz_params[i]);
pitz_params_temp[i] = (struct pitz_param*)free_check_null(pitz_params_temp[i]);
}
else
{
pitz_params[j++] = pitz_params[i];
pitz_params.push_back(pitz_params_temp[i]);
}
}
count_pitz_param = j;
for (i = 0; i < count_cations - 1; i++)
{
for (j = i + 1; j < count_cations; j++)
@ -150,35 +143,27 @@ pitzer_tidy(void)
sprintf(line, "%s %s 1", spec[i]->name, spec[j]->name);
pzp_ptr = pitz_param_read(line, 2);
pzp_ptr->type = TYPE_ETHETA;
if (count_pitz_param >= max_pitz_param)
{
space((void **) ((void *) &pitz_params), count_pitz_param,
&max_pitz_param, sizeof(struct pitz_param *));
}
pitz_params[count_pitz_param++] = pzp_ptr;
size_t count_pitz_param = pitz_params.size();
pitz_params.resize(count_pitz_param + 1);
pitz_params[count_pitz_param] = pzp_ptr;
}
}
for (i = 2 * count_s; i < 2 * count_s + count_anions - 1; i++)
for (i = 2 * (int)s.size(); i < 2 * (int)s.size() + count_anions - 1; i++)
{
for (j = i + 1; j < 2 * count_s + count_anions; j++)
for (j = i + 1; j < 2 * (int)s.size() + count_anions; j++)
{
sprintf(line, "%s %s 1", spec[i]->name, spec[j]->name);
pzp_ptr = pitz_param_read(line, 2);
pzp_ptr->type = TYPE_ETHETA;
if (count_pitz_param >= max_pitz_param)
{
space((void **) ((void *) &pitz_params), count_pitz_param,
&max_pitz_param, sizeof(struct pitz_param *));
}
size_t count_pitz_param = pitz_params.size();
pitz_params.resize(count_pitz_param + 1);
pitz_params[count_pitz_param] = pzp_ptr;
count_pitz_param++;
}
}
/*
* put species numbers in pitz_params
*/
for (i = 0; i < count_pitz_param; i++)
for (i = 0; i < (int)pitz_params.size(); i++)
{
for (j = 0; j < 3; j++)
{
@ -206,7 +191,7 @@ pitzer_tidy(void)
string1 = string_hsave("K+");
string2 = string_hsave("Cl-");
IC = ISPEC(string2);
for (i = 0; i < count_pitz_param; i++)
for (i = 0; i < (int)pitz_params.size(); i++)
{
if ((pitz_params[i]->species[0] == string1 &&
pitz_params[i]->species[1] == string2) ||
@ -249,7 +234,7 @@ pitzer_tidy(void)
/*
* Set alpha values
*/
for (i = 0; i < count_pitz_param; i++)
for (i = 0; i < (int)pitz_params.size(); i++)
{
z0 = fabs(spec[pitz_params[i]->ispec[0]]->z);
z1 = fabs(spec[pitz_params[i]->ispec[1]]->z);
@ -297,11 +282,11 @@ pitzer_tidy(void)
/*
* Add specific alphas
*/
for (i = 0; i < count_pitz_param; i++)
for (i = 0; i < (int)pitz_params.size(); i++)
{
if (pitz_params[i]->type == TYPE_ALPHAS)
{
for (j = 0; j < count_pitz_param; j++)
for (j = 0; j < (int)pitz_params.size(); j++)
{
if (pitz_params[j]->type != TYPE_B1)
continue;
@ -312,7 +297,7 @@ pitzer_tidy(void)
pitz_params[j]->alpha = pitz_params[i]->a[0];
break;
}
for (j = 0; j < count_pitz_param; j++)
for (j = 0; j < (int)pitz_params.size(); j++)
{
if (pitz_params[j]->type != TYPE_B2)
continue;
@ -330,16 +315,12 @@ pitzer_tidy(void)
* Add thetas pointer to etheta pitzer parameters
*/
if (count_theta_param > 0)
for (i = 0; i < (int)theta_params.size(); i++)
{
for (i = 0; i < count_theta_param; i++)
{
theta_params[i] =
(struct theta_param *) free_check_null(theta_params[i]);
}
theta_params[i] = (struct theta_param *) free_check_null(theta_params[i]);
}
count_theta_param = 0;
for (i = 0; i < count_pitz_param; i++)
theta_params.clear();
for (i = 0; i < (int)pitz_params.size(); i++)
{
if (pitz_params[i]->type == TYPE_ETHETA)
{
@ -348,18 +329,13 @@ pitzer_tidy(void)
theta_param_ptr = theta_param_search(z0, z1);
if (theta_param_ptr == NULL)
{
if (count_theta_param >= max_theta_param)
{
space((void **) ((void *) &theta_params),
count_theta_param, &max_theta_param,
sizeof(struct theta_param *));
}
size_t count_theta_param = theta_params.size();
theta_params.resize(count_theta_param + 1);
theta_params[count_theta_param] = theta_param_alloc();
theta_param_init(theta_params[count_theta_param]);
theta_params[count_theta_param]->zj = z0;
theta_params[count_theta_param]->zk = z1;
theta_param_ptr = theta_params[count_theta_param];
count_theta_param++;
}
pitz_params[i]->thetas = theta_param_ptr;
}
@ -370,7 +346,7 @@ pitzer_tidy(void)
/* Coef for Osmotic coefficient for TYPE_MU */
for (i = 0; i < count_pitz_param; i++)
for (i = 0; i < (int)pitz_params.size(); i++)
{
if (pitz_params[i]->type == TYPE_MU)
{
@ -433,7 +409,7 @@ pitzer_tidy(void)
/* Coef for gammas for TYPE_MU */
for (i = 0; i < count_pitz_param; i++)
for (i = 0; i < (int)pitz_params.size(); i++)
{
if (pitz_params[i]->type == TYPE_MU)
{
@ -489,7 +465,7 @@ pitzer_tidy(void)
}
/* Debug TYPE_MU coefficients */
/*
for (i = 0; i < count_pitz_param; i++)
for (i = 0; i < (int)pitz_params.size(); i++)
{
if (pitz_params[i]->type == TYPE_MU)
{
@ -505,7 +481,7 @@ pitzer_tidy(void)
/* Coef for Osmotic coefficient for TYPE_LAMDA */
for (i = 0; i < count_pitz_param; i++)
for (i = 0; i < (int)pitz_params.size(); i++)
{
if (pitz_params[i]->type == TYPE_LAMDA)
{
@ -530,7 +506,7 @@ pitzer_tidy(void)
}
/* Debug TYPE_LAMDA coefficients */
/*
for (i = 0; i < count_pitz_param; i++)
for (i = 0; i < (int)pitz_params.size(); i++)
{
if (pitz_params[i]->type == TYPE_LAMDA)
{
@ -543,7 +519,7 @@ pitzer_tidy(void)
/* remake map */
{
pitz_param_map.clear();
for (int j = 0; j < count_pitz_param; j++)
for (int j = 0; j < (int)pitz_params.size(); j++)
{
std::set< std::string > header;
for (int i = 0; i < 3; i++)
@ -560,7 +536,7 @@ pitzer_tidy(void)
std::string key = key_str.str().c_str();
pitz_param_map[key] = j;
}
assert ((int) pitz_param_map.size() == count_pitz_param);
assert ((int) pitz_param_map.size() == (int)pitz_params.size());
}
return OK;
}
@ -574,7 +550,7 @@ ISPEC(const char *name)
*/
{
int i;
for (i = 0; i < 3 * count_s; i++)
for (i = 0; i < 3 * (int)s.size(); i++)
{
if (spec[i] == NULL)
continue;
@ -784,7 +760,7 @@ C
VP = patm_x;
#if !defined(PITZER_LISTS)
int i;
for (i = 0; i < count_pitz_param; i++)
for (i = 0; i < (int)pitz_params.size(); i++)
{
calc_pitz_param(pitz_params[i], TK, TR);
}
@ -923,7 +899,7 @@ pitzer(void)
C TRANSFER DATA FROM TO M
C
*/
for (i = 0; i < 3 * count_s; i++)
for (i = 0; i < 3 * (int)s.size(); i++)
{
IPRSNT[i] = FALSE;
M[i] = 0.0;
@ -954,7 +930,7 @@ pitzer(void)
C
*/
PTEMP(TK);
for (i = 0; i < 2 * count_s + count_anions; i++)
for (i = 0; i < 2 * (int)s.size() + count_anions; i++)
{
LGAMMA[i] = 0.0;
if (IPRSNT[i] == TRUE)
@ -1008,7 +984,7 @@ pitzer(void)
/*
* Calculate ethetas
*/
for (i = 0; i < count_theta_param; i++)
for (i = 0; i < (int)theta_params.size(); i++)
{
z0 = theta_params[i]->zj;
z1 = theta_params[i]->zk;
@ -1019,7 +995,7 @@ pitzer(void)
/*
* Sums for F, LGAMMA, and OSMOT
*/
for (i = 0; i < count_pitz_param; i++)
for (i = 0; i < (int)pitz_params.size(); i++)
{
i0 = pitz_params[i]->ispec[0];
i1 = pitz_params[i]->ispec[1];
@ -1155,7 +1131,7 @@ pitzer(void)
F_var = (z0 == 1 ? F1 : (z0 == 2.0 ? F2 : F));
LGAMMA[i] += z0 * z0 * F_var + z0 * CSUM;
}
for (i = 2 * count_s; i < 2 * count_s + count_anions; i++)
for (i = 2 * (int)s.size(); i < 2 * (int)s.size() + count_anions; i++)
{
if (!IPRSNT[i])
continue;
@ -1176,7 +1152,7 @@ pitzer(void)
C CORRECTED ERROR IN PHIMAC, NOVEMBER, 1989
C
*/
for (i = 0; i < 2 * count_s + count_anions; i++)
for (i = 0; i < 2 * (int)s.size() + count_anions; i++)
{
if (IPRSNT[i] == TRUE)
{
@ -1198,7 +1174,7 @@ pitzer(void)
*/
/*s_h2o->la=log10(AW); */
mu_x = I;
for (i = 0; i < 2 * count_s + count_anions; i++)
for (i = 0; i < 2 * (int)s.size() + count_anions; i++)
{
if (IPRSNT[i] == FALSE)
continue;
@ -1332,7 +1308,7 @@ pitzer(void)
*/
if (use_etheta == TRUE)
{
for (i = 0; i < count_theta_param; i++)
for (i = 0; i < (int)theta_params.size(); i++)
{
z0 = theta_params[i]->zj;
z1 = theta_params[i]->zk;
@ -1671,21 +1647,19 @@ pitzer_clean_up(void)
* Free all allocated memory, except strings
*/
int i;
for (i = 0; i < count_pitz_param; i++)
for (i = 0; i < (int)pitz_params.size(); i++)
{
pitz_params[i] =
(struct pitz_param *) free_check_null(pitz_params[i]);
}
count_pitz_param = 0;
pitz_param_map.clear();
pitz_params = (struct pitz_param **) free_check_null(pitz_params);
for (i = 0; i < count_theta_param; i++)
pitz_params.clear();
for (i = 0; i < (int)theta_params.size(); i++)
{
theta_params[i] =
(struct theta_param *) free_check_null(theta_params[i]);
}
count_theta_param = 0;
theta_params = (struct theta_param **) free_check_null(theta_params);
theta_params.clear();
LGAMMA = (LDBLE *) free_check_null(LGAMMA);
IPRSNT = (int *) free_check_null(IPRSNT);
spec = (struct species **) free_check_null(spec);
@ -1711,14 +1685,14 @@ set_pz(int initial)
*/
iterations = -1;
solution_ptr = use.Get_solution_ptr();
for (i = 0; i < count_s_x; i++)
for (i = 0; i < (int)this->s_x.size(); i++)
{
s_x[i]->lm = LOG_ZERO_MOLALITY;
s_x[i]->lg_pitzer = 0.0;
}
if (initial == TRUE || set_and_run_attempt > 0)
{
for (i = 0; i < count_s_x; i++)
for (i = 0; i < (int)this->s_x.size(); i++)
{
s_x[i]->lg = 0.0;
}
@ -2343,7 +2317,7 @@ model_pz(void)
{
count_basis_change++;
count_unknowns -= count_s_x;
count_unknowns -= (int)this->s_x.size();
reprep();
full_pitzer = false;
}
@ -2468,7 +2442,7 @@ gammas_pz(bool exch_a_f)
/*
* Calculate activity coefficients
*/
for (i = 0; i < count_s_x; i++)
for (i = 0; i < (int)this->s_x.size(); i++)
{
switch (s_x[i]->gflag)
{
@ -2540,7 +2514,7 @@ gammas_pz(bool exch_a_f)
if (use.Get_exchange_ptr() != NULL && exch_a_f) // appt for gammas_a_f
{
for (i = 0; i < count_s_x; i++)
for (i = 0; i < (int)this->s_x.size(); i++)
{
switch (s_x[i]->gflag)
{
@ -2627,12 +2601,12 @@ pitzer_make_lists(void)
max = count_cations;
break;
case 1:
min = count_s;
max = count_s + count_neutrals;
min = (int)s.size();
max = (int)s.size() + count_neutrals;
break;
case 2:
min = 2*count_s;
max = 2*count_s + count_anions;
min = 2* (int)s.size();
max = 2* (int)s.size() + count_anions;
break;
}
for (int i = min; i < max; i++)
@ -2647,19 +2621,19 @@ pitzer_make_lists(void)
continue;
IPRSNT[i] = TRUE;
s_list.push_back(i);
if (i < count_s)
if (i < (int)s.size())
{
cation_list.push_back(i);
}
if (i >= count_s && i < 2*count_s)
if (i >= (int)s.size() && i < 2* (int)s.size())
{
neutral_list.push_back(i);
}
if (i >= 2*count_s)
if (i >= 2* (int)s.size())
{
anion_list.push_back(i);
}
if (i < count_s || i >= 2*count_s)
if (i < (int)s.size() || i >= 2* (int)s.size())
{
ion_list.push_back(i);
}
@ -2674,7 +2648,7 @@ pitzer_make_lists(void)
{
IPRSNT[IC] = TRUE;
}
for (int i = 0; i < count_pitz_param; i++)
for (int i = 0; i < (int)pitz_params.size(); i++)
{
/*
TYPE_B0, TYPE_B1, TYPE_B2, TYPE_C0, TYPE_THETA, TYPE_LAMDA, TYPE_ZETA,

View File

@ -195,14 +195,10 @@ pitz_param_store(struct pitz_param *pzp_ptr, bool force_copy)
}
else
{
if (count_pitz_param >= max_pitz_param)
{
space((void **) ((void *) &pitz_params),
count_pitz_param, &max_pitz_param,
sizeof(struct pitz_param *));
}
if (force_copy)
{
size_t count_pitz_param = pitz_params.size();
pitz_params.resize(count_pitz_param + 1);
pitz_params[count_pitz_param] = pitz_param_duplicate(pzp_ptr);
// clean up pointers
// species
@ -215,13 +211,15 @@ pitz_param_store(struct pitz_param *pzp_ptr, bool force_copy)
}
// thetas
pitz_params[count_pitz_param]->thetas = NULL;
pitz_param_map[key] = count_pitz_param;
}
else
{
size_t count_pitz_param = pitz_params.size();
pitz_params.resize(count_pitz_param + 1);
pitz_params[count_pitz_param] = pzp_ptr;
pitz_param_map[key] = count_pitz_param;
}
pitz_param_map[key] = count_pitz_param;
count_pitz_param++;
}
}
@ -274,14 +272,10 @@ sit_param_store(struct pitz_param *pzp_ptr, bool force_copy)
}
else
{
if (count_sit_param >= max_sit_param)
{
space((void **) ((void *) &sit_params),
count_sit_param, &max_sit_param,
sizeof(struct pitz_param *));
}
if (force_copy)
{
size_t count_sit_param = sit_params.size();
sit_params.resize(count_sit_param + 1);
sit_params[count_sit_param] = pitz_param_duplicate(pzp_ptr);
// clean up pointers
// species
@ -294,13 +288,15 @@ sit_param_store(struct pitz_param *pzp_ptr, bool force_copy)
}
// thetas
sit_params[count_sit_param]->thetas = NULL;
sit_param_map[key] = count_sit_param;
}
else
{
size_t count_sit_param = sit_params.size();
sit_params.resize(count_sit_param + 1);
sit_params[count_sit_param] = pzp_ptr;
sit_param_map[key] = count_sit_param;
}
sit_param_map[key] = count_sit_param;
count_sit_param++;
}
}
@ -350,7 +346,7 @@ theta_param_search(LDBLE zj, LDBLE zk)
* Returns NULL if not found, index number in theta_params if found
*/
int i;
for (i = 0; i < count_theta_param; i++)
for (i = 0; i < (int)theta_params.size(); i++)
{
if ((theta_params[i]->zj == zj && theta_params[i]->zk == zk) ||
(theta_params[i]->zj == zk && theta_params[i]->zk == zj))

View File

@ -54,10 +54,7 @@ prep(void)
* Must allocate all necessary space before pointers to
* X are set.
*/
//if (!same_model && !switch_numerical)
// numerical_fixed_volume = false;
if (same_model == FALSE || !my_array/*|| switch_numerical*/)
if (same_model == FALSE || my_array.size() == 0)
{
clear();
setup_unknowns();
@ -81,26 +78,9 @@ prep(void)
/*
* Allocate space for array
*/
/*
array = (LDBLE *) PHRQ_malloc( (size_t) (count_unknowns+1) * count_unknowns * sizeof( LDBLE ));
if (array == NULL) malloc_error();
delta = (LDBLE *) PHRQ_malloc( (size_t) count_unknowns * sizeof( LDBLE ));
if (delta == NULL) malloc_error();
residual = (LDBLE *) PHRQ_malloc( (size_t) count_unknowns * sizeof( LDBLE ));
if (residual == NULL) malloc_error();
*/
my_array =
(LDBLE *) PHRQ_malloc((size_t) (max_unknowns + 1) *
max_unknowns * sizeof(LDBLE));
if (my_array == NULL)
malloc_error();
delta = (LDBLE *) PHRQ_malloc((size_t) max_unknowns * sizeof(LDBLE));
if (delta == NULL)
malloc_error();
residual =
(LDBLE *) PHRQ_malloc((size_t) max_unknowns * sizeof(LDBLE));
if (residual == NULL)
malloc_error();
my_array.resize(((size_t)max_unknowns + 1) * (size_t)max_unknowns);
delta.resize((size_t)max_unknowns);
residual.resize((size_t)max_unknowns);
for (int j = 0; j < max_unknowns; j++)
{
residual[j] = 0;
@ -155,7 +135,7 @@ quick_setup(void)
* Updates essential information for the model.
*/
int i;
for (i = 0; i < count_master; i++)
for (i = 0; i < (int)master.size(); i++)
{
if (master[i]->s->type == SURF_PSI)
continue;
@ -894,7 +874,7 @@ build_jacobian_sums(int k)
/*
* Calculate jacobian coefficients for each mass balance equation
*/
for (i = 0; i < count_mb_unknowns; i++)
for (i = 0; i < (int)mb_unknowns.size(); i++)
{
/*
* Store d(moles) for a mass balance equation
@ -1101,24 +1081,11 @@ build_mb_sums(void)
/*
* Make space for lists
*/
if (count_sum_mb1 + count_mb_unknowns >= max_sum_mb1)
{
space((void **) ((void *) &sum_mb1),
count_sum_mb1 + count_mb_unknowns, &max_sum_mb1,
sizeof(struct list1));
}
if (count_sum_mb2 + count_mb_unknowns >= max_sum_mb2)
{
space((void **) ((void *) &sum_mb2),
count_sum_mb2 + count_mb_unknowns, &max_sum_mb2,
sizeof(struct list2));
}
if (debug_prep == TRUE)
{
output_msg(sformatf( "\n\tMass balance summations.\n"));
}
for (i = 0; i < count_mb_unknowns; i++)
for (i = 0; i < (int)mb_unknowns.size(); i++)
{
target = &(mb_unknowns[i].unknown->f);
store_mb(mb_unknowns[i].source, target, mb_unknowns[i].coef);
@ -1152,60 +1119,24 @@ build_model(void)
/*
* Make space for lists of pointers to species in the model
*/
max_s_x = MAX_S;
// clear sum_species_map, which is built from s_x
sum_species_map_db.clear();
sum_species_map.clear();
space((void **) ((void *) &s_x), INIT, &max_s_x,
sizeof(struct species *));
max_sum_mb1 = MAX_SUM_MB;
count_sum_mb1 = 0;
space((void **) ((void *) &sum_mb1), INIT, &max_sum_mb1,
sizeof(struct list1));
max_sum_mb2 = MAX_SUM_MB;
count_sum_mb2 = 0;
space((void **) ((void *) &sum_mb2), INIT, &max_sum_mb2,
sizeof(struct list2));
max_sum_jacob0 = MAX_SUM_JACOB0;
count_sum_jacob0 = 0;
space((void **) ((void *) &sum_jacob0), INIT, &max_sum_jacob0,
sizeof(struct list0));
max_sum_jacob1 = MAX_SUM_JACOB1;
count_sum_jacob1 = 0;
space((void **) ((void *) &sum_jacob1), INIT, &max_sum_jacob1,
sizeof(struct list1));
max_sum_jacob2 = MAX_SUM_JACOB2;
count_sum_jacob2 = 0;
space((void **) ((void *) &sum_jacob2), INIT, &max_sum_jacob2,
sizeof(struct list2));
max_sum_delta = MAX_SUM_JACOB0;
count_sum_delta = 0;
space((void **) ((void *) &sum_delta), INIT, &max_sum_delta,
sizeof(struct list2));
max_species_list = 5 * MAX_S;
count_species_list = 0;
species_list = (struct species_list *) free_check_null(species_list);
space((void **) ((void *) &species_list), INIT, &max_species_list,
sizeof(struct species_list));
s_x.clear();
sum_mb1.clear();
sum_mb2.clear();
sum_jacob0.clear();
sum_jacob1.clear();
sum_jacob2.clear();
sum_delta.clear();
species_list.clear();
/*
* Pick species in the model, determine reaction for model, build jacobian
*/
count_s_x = 0;
s_x.clear();
compute_gfw("H2O", &gfw_water);
gfw_water *= 0.001;
for (i = 0; i < count_s; i++)
for (i = 0; i < (int)s.size(); i++)
{
if (s[i]->type > H2O && s[i]->type != EX && s[i]->type != SURF)
continue;
@ -1225,13 +1156,10 @@ build_model(void)
}
if (pitzer_model == FALSE && sit_model == FALSE)
s[i]->lg = 0.0;
if (count_s_x + 1 >= max_s_x)
{
space((void **) ((void *) &s_x), count_s_x + 1,
&max_s_x, sizeof(struct species *));
}
compute_gfw(s[i]->name, &s[i]->gfw);
s_x[count_s_x++] = s[i];
size_t count_s_x = s_x.size();
s_x.resize(count_s_x + 1);
s_x[count_s_x] = s[i];
/*
* Write mass action equation for current model
@ -1364,7 +1292,7 @@ build_model(void)
if (pitzer_model == TRUE || sit_model == TRUE)
{
j0 = count_unknowns;
j = count_unknowns + count_s_x;
j = count_unknowns + (int)this->s_x.size();
k = j0;
for (i = j0; i < j; i++)
{
@ -1383,7 +1311,7 @@ build_model(void)
/*
* Rewrite phases to current master species
*/
for (i = 0; i < count_phases; i++)
for (i = 0; i < (int)phases.size(); i++)
{
count_trxn = 0;
trxn_add_phase(phases[i]->rxn_s, 1.0, FALSE);
@ -1424,8 +1352,8 @@ build_model(void)
/*
* Sort species list, by master only
*/
qsort(&species_list[0], (size_t) count_species_list,
(size_t) sizeof(struct species_list), species_list_compare_master);
qsort(&species_list[0], (int)species_list.size(),
sizeof(struct species_list), species_list_compare_master);
/*
* Save model description
*/
@ -1706,24 +1634,16 @@ build_species_list(int n)
*/
int j;
struct master *master_ptr;
/*
* Check space and store reaction token name and pointer to species
*/
if (count_species_list + count_elts >= max_species_list)
{
space((void **) ((void *) &species_list),
count_species_list + count_elts, &max_species_list,
sizeof(struct species_list));
}
/*
* Treat species made only with H+, e-, and H2O specially
*/
if (is_special(s[n]) == TRUE)
{
size_t count_species_list = species_list.size();
species_list.resize(count_species_list + 1);
species_list[count_species_list].master_s = s_hplus;
species_list[count_species_list].s = s[n];
species_list[count_species_list].coef = 0.0;
count_species_list++;
return (OK);
}
/*
@ -1738,12 +1658,13 @@ build_species_list(int n)
if (elt_list[j].elt->master->s->type != EX)
continue;
master_ptr = elt_list[j].elt->master;
size_t count_species_list = species_list.size();
species_list.resize(count_species_list + 1);
species_list[count_species_list].master_s =
elt_list[j].elt->master->s;
species_list[count_species_list].s = s[n];
species_list[count_species_list].coef = master_ptr->coef *
elt_list[j].coef;
count_species_list++;
}
return (OK);
}
@ -1759,12 +1680,13 @@ build_species_list(int n)
if (elt_list[j].elt->master->s->type != SURF)
continue;
master_ptr = elt_list[j].elt->master;
size_t count_species_list = species_list.size();
species_list.resize(count_species_list + 1);
species_list[count_species_list].master_s =
elt_list[j].elt->master->s;
species_list[count_species_list].s = s[n];
species_list[count_species_list].coef = master_ptr->coef *
elt_list[j].coef;
count_species_list++;
}
return (OK);
}
@ -1783,6 +1705,8 @@ build_species_list(int n)
{
master_ptr = elt_list[j].elt->master->s->primary;
}
size_t count_species_list = species_list.size();
species_list.resize(count_species_list + 1);
species_list[count_species_list].master_s = master_ptr->s;
species_list[count_species_list].s = s[n];
/*
@ -1790,7 +1714,6 @@ build_species_list(int n)
*/
species_list[count_species_list].coef = master_ptr->coef *
elt_list[j].coef;
count_species_list++;
}
return (OK);
}
@ -1810,7 +1733,7 @@ clear(void)
*/
solution_ptr = use.Get_solution_ptr();
for (i = 0; i < count_s; i++)
for (i = 0; i < (int)s.size(); i++)
{
s[i]->in = FALSE;
}
@ -1835,7 +1758,7 @@ clear(void)
* Clear master species solution-dependent data
*/
const char * pe_str = string_hsave("pe");
for (i = 0; i < count_master; i++)
for (i = 0; i < (int)master.size(); i++)
{
master[i]->in = FALSE;
master[i]->unknown = NULL;
@ -1888,37 +1811,6 @@ clear(void)
* Free arrays used in model
*/
free_model_allocs();
#ifdef SKIP
// Bug-fix
// The standard implementation of clear() sets the unknown pointer of some of the
// masters to NULL. However, the function quick_setup presumes that a master pointer
// is valid when the masters total is larger than zero. This results in a crash
// when the unknown pointer is dereferenced. The same goes for the secondary master
// species.
//
// Perhaps this should be part of the 'Clear master species solution-dependent data'-loop above?!
for ( int i = 0; i < count_master; i++ )
{
if (master[i]->s->type == SURF_PSI)
continue;
if ( master[i]->s == s_eminus ||
master[i]->s == s_hplus ||
master[i]->s == s_h2o ||
master[i]->s == s_h2 ||
master[i]->s == s_o2 )
continue;
if (master[i]->total > 0 )
{
// Make sure masters total is set to zero when unknown pointer for master species is not set
if ( ( master[i]->s->secondary && !master[i]->s->secondary->unknown ) || !master[i]->unknown )
{
master[i]->total = 0.0;
}
}
}
#endif
return (OK);
}
/* ---------------------------------------------------------------------- */
@ -2122,7 +2014,7 @@ get_list_master_ptrs(char *ptr, struct master *master_ptr)
/*
* First in list is primary species
*/
for (j = 0; j < count_master; j++)
for (j = 0; j < (int)master.size(); j++)
{
if (master[j] == master_ptr0)
break;
@ -2131,7 +2023,7 @@ get_list_master_ptrs(char *ptr, struct master *master_ptr)
/*
* Element has only one valence
*/
if (j >= count_master || master[j]->elt->primary != master_ptr0)
if (j >= (int)master.size() || master[j]->elt->primary != master_ptr0)
{
master_ptr_list[count_list++] = master_ptr0;
/*
@ -2149,7 +2041,7 @@ get_list_master_ptrs(char *ptr, struct master *master_ptr)
input_error++;
}
master_ptr_list[count_list++] = master_ptr0->s->secondary;
while (j < count_master && master[j]->elt->primary == master_ptr0)
while (j < (int)master.size() && master[j]->elt->primary == master_ptr0)
{
if (master[j]->s->primary == NULL)
{
@ -2268,16 +2160,12 @@ store_mb_unknowns(struct unknown *unknown_ptr, LDBLE * LDBLE_ptr, LDBLE coef,
{
if (equal(coef, 0.0, TOL) == TRUE)
return (OK);
if ((count_mb_unknowns + 1) >= max_mb_unknowns)
{
space((void **) ((void *) &mb_unknowns), count_mb_unknowns + 1,
&max_mb_unknowns, sizeof(struct unknown_list));
}
size_t count_mb_unknowns = mb_unknowns.size();
mb_unknowns.resize(count_mb_unknowns + 1);
mb_unknowns[count_mb_unknowns].unknown = unknown_ptr;
mb_unknowns[count_mb_unknowns].source = LDBLE_ptr;
mb_unknowns[count_mb_unknowns].gamma_source = gamma_ptr;
mb_unknowns[count_mb_unknowns].coef = coef;
count_mb_unknowns++;
return (OK);
}
@ -2300,7 +2188,7 @@ mb_for_species_aq(int n)
struct master *master_ptr;
struct unknown *unknown_ptr;
count_mb_unknowns = 0;
mb_unknowns.clear();
/*
* e- does not appear in any mass balances
*/
@ -2463,7 +2351,8 @@ mb_for_species_ex(int n)
*/
int i;
struct master *master_ptr;
count_mb_unknowns = 0;
mb_unknowns.clear();
/*
* Master species for exchange do not appear in any mass balances
*/
@ -2553,7 +2442,7 @@ mb_for_species_surf(int n)
int i;
struct master *master_ptr;
count_mb_unknowns = 0;
mb_unknowns.clear();
/*
* Include in charge balance, if diffuse_layer_x == FALSE
*/
@ -2677,7 +2566,7 @@ reprep(void)
/*
* Initialize s, master, and unknown pointers
*/
for (i = 0; i < count_master; i++)
for (i = 0; i < (int)master.size(); i++)
{
if (master[i]->in == FALSE)
continue;
@ -2696,13 +2585,13 @@ reprep(void)
/*
* Free arrays built in build_model
*/
s_x = (struct species **) free_check_null(s_x);
sum_mb1 = (struct list1 *) free_check_null(sum_mb1);
sum_mb2 = (struct list2 *) free_check_null(sum_mb2);
sum_jacob0 = (struct list0 *) free_check_null(sum_jacob0);
sum_jacob1 = (struct list1 *) free_check_null(sum_jacob1);
sum_jacob2 = (struct list2 *) free_check_null(sum_jacob2);
sum_delta = (struct list2 *) free_check_null(sum_delta);
s_x.clear();
sum_mb1.clear();
sum_mb2.clear();
sum_jacob0.clear();
sum_jacob1.clear();
sum_jacob2.clear();
sum_delta.clear();
/*
* Build model again
*/
@ -2919,11 +2808,8 @@ add_potential_factor(void)
/*
* Make sure there is space
*/
if (count_trxn + 1 >= max_trxn)
{
space((void **) ((void *) &(trxn.token)), count_trxn + 1, &max_trxn,
sizeof(struct rxn_token_temp));
}
if ((size_t)count_trxn + 1 > trxn.token.size())
trxn.token.resize((size_t)count_trxn + 1);
/*
* Include psi in mass action equation
*/
@ -3016,11 +2902,8 @@ add_cd_music_factors(int n)
/*
* Make sure there is space
*/
if (count_trxn + 3 >= max_trxn)
{
space((void **) ((void *) &(trxn.token)), count_trxn + 3, &max_trxn,
sizeof(struct rxn_token_temp));
}
if ((size_t)count_trxn + 3 > trxn.token.size())
trxn.token.resize((size_t)count_trxn + 3);
/*
* Include psi in mass action equation
*/
@ -4863,15 +4746,13 @@ setup_unknowns(void)
max_unknowns++;
if (pitzer_model == TRUE || sit_model == TRUE)
{
max_unknowns += count_s;
max_unknowns += (int)s.size();
}
/*
* Allocate space for pointer array and structures
*/
space((void **) ((void *) &x), INIT, &max_unknowns,
sizeof(struct unknown *));
x.resize((size_t)max_unknowns);
for (i = 0; i < max_unknowns; i++)
{
x[i] = (struct unknown *) unknown_alloc();
@ -4976,34 +4857,26 @@ store_jacob(LDBLE * source, LDBLE * target, LDBLE coef)
*/
if (equal(coef, 1.0, TOL) == TRUE)
{
size_t count_sum_jacob1 = sum_jacob1.size();
sum_jacob1.resize(count_sum_jacob1 + 1);
if (debug_prep == TRUE)
{
output_msg(sformatf( "\tjacob1 %d\n", count_sum_jacob1));
output_msg(sformatf( "\tjacob1 %d\n", (int)count_sum_jacob1));
}
sum_jacob1[count_sum_jacob1].source = source;
sum_jacob1[count_sum_jacob1++].target = target;
/* Check space */
if (count_sum_jacob1 >= max_sum_jacob1)
{
space((void **) ((void *) &sum_jacob1), count_sum_jacob1,
&max_sum_jacob1, sizeof(struct list1));
}
sum_jacob1[count_sum_jacob1].target = target;
}
else
{
size_t count_sum_jacob2 = sum_jacob2.size();
sum_jacob2.resize(count_sum_jacob2 + 1);
if (debug_prep == TRUE)
{
output_msg(sformatf( "\tjacob2 %d\n", count_sum_jacob2));
output_msg(sformatf("\tjacob2 %d\n", count_sum_jacob2));
}
sum_jacob2[count_sum_jacob2].source = source;
sum_jacob2[count_sum_jacob2].target = target;
sum_jacob2[count_sum_jacob2++].coef = coef;
/* Check space */
if (count_sum_jacob2 >= max_sum_jacob2)
{
space((void **) ((void *) &sum_jacob2), count_sum_jacob2,
&max_sum_jacob2, sizeof(struct list2));
}
sum_jacob2[count_sum_jacob2].coef = coef;
}
return (OK);
}
@ -5016,15 +4889,11 @@ store_jacob0(int row, int column, LDBLE coef)
/*
* Stores in list a constant coef which will be added into jacobian array
*/
size_t count_sum_jacob0 = sum_jacob0.size();
sum_jacob0.resize(count_sum_jacob0 + 1);
sum_jacob0[count_sum_jacob0].target =
&(my_array[row * (count_unknowns + 1) + column]);
sum_jacob0[count_sum_jacob0++].coef = coef;
/* Check space */
if (count_sum_jacob0 >= max_sum_jacob0)
{
space((void **) ((void *) &sum_jacob0), count_sum_jacob0,
&max_sum_jacob0, sizeof(struct list0));
}
&(my_array[(size_t)row * ((size_t)count_unknowns + 1) + (size_t)column]);
sum_jacob0[count_sum_jacob0].coef = coef;
return (OK);
}
@ -5040,25 +4909,18 @@ store_mb(LDBLE * source, LDBLE * target, LDBLE coef)
*/
if (equal(coef, 1.0, TOL) == TRUE)
{
size_t count_sum_mb1 = sum_mb1.size();
sum_mb1.resize(count_sum_mb1 + 1);
sum_mb1[count_sum_mb1].source = source;
sum_mb1[count_sum_mb1++].target = target;
if (count_sum_mb1 >= max_sum_mb1)
{
space((void **) ((void *) &sum_mb1),
count_sum_mb1 + count_trxn + 4, &max_sum_mb1,
sizeof(struct list1));
}
sum_mb1[count_sum_mb1].target = target;
}
else
{
size_t count_sum_mb2 = sum_mb2.size();
sum_mb2.resize(count_sum_mb2 + 1);
sum_mb2[count_sum_mb2].source = source;
sum_mb2[count_sum_mb2].coef = coef;
sum_mb2[count_sum_mb2++].target = target;
if (count_sum_mb2 >= max_sum_mb2)
{
space((void **) ((void *) &sum_mb2), count_sum_mb2,
&max_sum_mb2, sizeof(struct list2));
}
sum_mb2[count_sum_mb2].target = target;
}
return (OK);
}
@ -5074,15 +4936,11 @@ store_sum_deltas(LDBLE * source, LDBLE * target, LDBLE coef)
* in x[i]->delta. These may be multiplied by a factor under some
* situations where the entire calculated step is not taken
*/
size_t count_sum_delta = sum_delta.size();
sum_delta.resize(count_sum_delta + 1);
sum_delta[count_sum_delta].source = source;
sum_delta[count_sum_delta].target = target;
sum_delta[count_sum_delta++].coef = coef;
/* Check space */
if (count_sum_delta >= max_sum_delta)
{
space((void **) ((void *) &sum_delta), count_sum_delta,
&max_sum_delta, sizeof(struct list2));
}
sum_delta[count_sum_delta].coef = coef;
return (OK);
}
@ -5159,13 +5017,13 @@ tidy_redox(void)
/*
* Keep valences of oxygen and hydrogen in model, if not already in
*/
for (int i = 0; i < count_master; i++)
for (int i = 0; i < (int)master.size(); i++)
{
if (master[i]->primary == TRUE &&
(master[i]->s == s_hplus || master[i]->s == s_h2o))
{
int j = i + 1;
while (j < count_master && master[j]->elt->primary == master[i])
while (j < (int)master.size() && master[j]->elt->primary == master[i])
{
if (master[j]->in == FALSE && master[j]->s != master[i]->s)
{
@ -5359,12 +5217,7 @@ write_mb_eqn_x(void)
free_check_null(temp_name);
}
}
if (count_elts > 0)
{
qsort(elt_list, (size_t) count_elts,
(size_t) sizeof(struct elt_list), elt_list_compare);
elt_list_combine();
}
elt_list_combine();
return (OK);
}
@ -5414,22 +5267,16 @@ write_mb_for_species_list(int n)
{
if (strcmp(elt_list[i].elt->name, "O(-2)") == 0)
{
if (count_elts >= max_elts)
if (count_elts >= (int)elt_list.size())
{
space((void **) ((void *) &elt_list), count_elts, &max_elts,
sizeof(struct elt_list));
elt_list.resize((size_t)count_elts + 1);
}
elt_list[count_elts].elt = element_h_one;
elt_list[count_elts].coef = elt_list[i].coef * 2;
count_elts++;
}
}
if (count_elts > 0)
{
qsort(elt_list, (size_t) count_elts,
(size_t) sizeof(struct elt_list), elt_list_compare);
elt_list_combine();
}
elt_list_combine();
s[n]->next_sys_total =
(struct elt_list *) free_check_null(s[n]->next_sys_total);
s[n]->next_sys_total = elt_list_save();
@ -5477,22 +5324,16 @@ write_phase_sys_total(int n)
{
if (strcmp(elt_list[i].elt->name, "O(-2)") == 0)
{
if (count_elts >= max_elts)
if (count_elts >= (int)elt_list.size())
{
space((void **) ((void *) &elt_list), count_elts, &max_elts,
sizeof(struct elt_list));
elt_list.resize((size_t)count_elts + 1);
}
elt_list[count_elts].elt = element_h_one;
elt_list[count_elts].coef = elt_list[i].coef * 2;
count_elts++;
}
}
if (count_elts > 0)
{
qsort(elt_list, (size_t) count_elts,
(size_t) sizeof(struct elt_list), elt_list_compare);
elt_list_combine();
}
elt_list_combine();
phases[n]->next_sys_total =
(struct elt_list *) free_check_null(phases[n]->next_sys_total);
phases[n]->next_sys_total = elt_list_save();
@ -5655,7 +5496,7 @@ calc_vm(LDBLE tc, LDBLE pa)
*/
if (llnl_count_temp > 0) return OK;
LDBLE pb_s = 2600. + pa * 1.01325, TK_s = tc + 45.15, sqrt_mu = sqrt(mu_x);
for (int i = 0; i < count_s_x; i++)
for (int i = 0; i < (int)this->s_x.size(); i++)
{
//if (!strcmp(s_x[i]->name, "H2O"))
if (s_x[i] == s_h2o)
@ -5750,7 +5591,7 @@ k_temp(LDBLE tc, LDBLE pa) /* pa - pressure in atm */
calc_vm(tc, pa);
mu_terms_in_logk = false;
for (i = 0; i < count_s_x; i++)
for (i = 0; i < (int)this->s_x.size(); i++)
{
//if (s_x[i]->rxn_x->logk[vm_tc])
/* calculate delta_v for the reaction... */
@ -5763,7 +5604,7 @@ k_temp(LDBLE tc, LDBLE pa) /* pa - pressure in atm */
/*
* Calculate log k for all pure phases
*/
for (i = 0; i < count_phases; i++)
for (i = 0; i < (int)phases.size(); i++)
{
if (phases[i]->in == TRUE)
{
@ -5849,7 +5690,7 @@ save_model(void)
/*
* mark master species
*/
for (i = 0; i < count_master; i++)
for (i = 0; i < (int)master.size(); i++)
{
master[i]->last_model = FALSE;
if (master[i]->total > 0)
@ -6040,7 +5881,7 @@ check_same_model(void)
/*
* Check master species
*/
for (i = 0; i < count_master; i++)
for (i = 0; i < (int)master.size(); i++)
{
/*
output_msg(sformatf("%s\t%e\t%d\n", master[i]->elt->name,
@ -6603,8 +6444,6 @@ change_hydrogen_in_elt_list(LDBLE charge)
found_o = -1;
coef_h = 0.0;
coef_o = 0.0;
qsort(elt_list, (size_t) count_elts,
(size_t) sizeof(struct elt_list), elt_list_compare);
elt_list_combine();
for (j = 0; j < count_elts; j++)
{
@ -6629,8 +6468,6 @@ change_hydrogen_in_elt_list(LDBLE charge)
elt_list[count_elts].elt = s_hplus->primary->elt;
elt_list[count_elts].coef = coef;
count_elts++;
qsort(elt_list, (size_t) count_elts,
(size_t) sizeof(struct elt_list), elt_list_compare);
elt_list_combine();
return (OK);
}

View File

@ -290,7 +290,7 @@ print_diffuse_layer(cxxSurfaceCharge *charge_ptr)
{
count_elts = 0;
paren_count = 0;
for (j = 0; j < count_s_x; j++)
for (j = 0; j < (int)this->s_x.size(); j++)
{
if (s_x[j]->type > HPLUS)
continue;
@ -316,12 +316,7 @@ print_diffuse_layer(cxxSurfaceCharge *charge_ptr)
ptr = &(token[0]);
get_elts_in_species (&ptr, mass_water_surface / gfw_water);
*/
if (count_elts > 0)
{
qsort(elt_list, (size_t)count_elts,
(size_t) sizeof(struct elt_list), elt_list_compare);
elt_list_combine();
}
elt_list_combine();
/*
* Print totals
*/
@ -371,7 +366,7 @@ print_eh(void)
tk_x = tc_x + 273.15;
first = TRUE;
for (i = 0; i < count_master; i++)
for (i = 0; i < (int)master.size(); i++)
{
if (master[i]->in != TRUE)
continue;
@ -381,7 +376,7 @@ print_eh(void)
* Secondary master species has mass balance equation
*/
master_ptr0 = master[i]->elt->primary;
for (k = i + 1; k < count_master; k++)
for (k = i + 1; k < (int)master.size(); k++)
{
if (master[k]->in != TRUE)
continue;
@ -460,7 +455,7 @@ print_exchange(void)
s_h2o->lm = s_h2o->la;
name = s_hplus->secondary->elt->name;
for (i = 0; i < count_species_list; i++)
for (i = 0; i < (int)species_list.size(); i++)
{
/*
* Get name of master species
@ -1074,7 +1069,7 @@ print_master_reactions(void)
int i;
struct rxn_token *next_token;
for (i = 0; i < count_master; i++)
for (i = 0; i < (int)master.size(); i++)
{
output_msg(sformatf("%s\t%s\n\tPrimary reaction\n",
master[i]->elt->name, master[i]->s->name));
@ -1253,7 +1248,7 @@ print_saturation_indices(void)
output_msg(sformatf(" %-15s%9s%8s%9s%3d%4s%3d%4s\n\n", "Phase", "SI**",
"log IAP", "log K(", int(tk_x), " K, ", int(floor(patm_x + 0.5)), " atm)"));
for (i = 0; i < count_phases; i++)
for (i = 0; i < (int)phases.size(); i++)
{
if (phases[i]->in == FALSE || phases[i]->type != SOLID)
continue;
@ -1491,7 +1486,7 @@ print_species(void)
*/
s_h2o->lm = s_h2o->la;
name = s_hplus->secondary->elt->name;
for (i = 0; i < count_species_list; i++)
for (i = 0; i < (int)species_list.size(); i++)
{
/*
* Get name of master species
@ -1779,7 +1774,7 @@ print_surface(void)
output_msg(sformatf("\t%-15s%12s%12s%12s%12s\n\n",
"Species", "Moles", "Fraction", "Molality",
"Molality"));
for (int i = 0; i < count_species_list; i++)
for (int i = 0; i < (int)species_list.size(); i++)
{
if (species_list[i].master_s != master_ptr->s)
continue;
@ -1821,7 +1816,7 @@ print_surface(void)
output_msg(sformatf("\t%-15s%12s%12s%12s%12s\n\n",
"Species", "Moles", "Fraction", "Molality",
"Molality"));
for (int i = 0; i < count_species_list; i++)
for (int i = 0; i < (int)species_list.size(); i++)
{
if (species_list[i].master_s != master_ptr->s)
continue;
@ -2077,7 +2072,7 @@ print_surface_cd_music(void)
output_msg(sformatf("\t%-20s%12s%12s%12s%12s\n\n",
"Species", "Moles", "Fraction", "Molality",
"Molality"));
for (int i = 0; i < count_species_list; i++)
for (int i = 0; i < (int)species_list.size(); i++)
{
if (species_list[i].master_s != master_ptr->s)
continue;
@ -2834,7 +2829,7 @@ punch_pp_assemblage(void)
{
for (int j = 0; j < count_unknowns; j++)
{
if (x == NULL || x[j]->type != PP)
if (x.size() == 0 || x[j]->type != PP)
continue;
//cxxPPassemblageComp * comp_ptr = pp_assemblage_ptr->Find(x[j]->pp_assemblage_comp_name);
cxxPPassemblageComp * comp_ptr = (cxxPPassemblageComp * ) x[j]->pp_assemblage_comp_ptr;
@ -3620,16 +3615,15 @@ print_alkalinity(void)
if (pr.alkalinity == FALSE || pr.all == FALSE)
return (OK);
print_centered("Distribution of alkalinity");
alk_list =
(struct species_list *)
PHRQ_malloc((size_t) (count_s_x * sizeof(struct species_list)));
alk_list = (struct species_list *)
PHRQ_malloc((s_x.size() * sizeof(struct species_list)));
if (alk_list == NULL)
{
malloc_error();
return (OK);
}
j = 0;
for (i = 0; i < count_s_x; i++)
for (i = 0; i < (int)this->s_x.size(); i++)
{
if (s_x[i]->alk == 0.0)
continue;

File diff suppressed because it is too large Load Diff

View File

@ -177,12 +177,12 @@ read_transport(void)
error_msg(line_save, CONTINUE);
break;
case 0: /* cells */
sscanf(next_char, "%d", &count_cells);
(void)sscanf(next_char, "%d", &count_cells);
opt_save = OPTION_DEFAULT;
break;
case 1: /* shifts */
if (copy_token(token, &next_char, &l) == DIGIT)
sscanf(token, "%d", &count_shifts);
(void)sscanf(token, "%d", &count_shifts);
else
{
warning_msg
@ -193,7 +193,7 @@ read_transport(void)
if (j != EMPTY)
{
if (j == DIGIT)
sscanf(token, "%d", &ishift);
(void)sscanf(token, "%d", &ishift);
else
{
input_error++;
@ -215,7 +215,7 @@ read_transport(void)
case 3: /* selected_output */
case 29: /* selected_output_frequency */
case 33: /* punch_frequency */
sscanf(next_char, "%d", &punch_modulus);
(void)sscanf(next_char, "%d", &punch_modulus);
opt_save = OPTION_DEFAULT;
if (punch_modulus <= 0)
{
@ -234,7 +234,7 @@ read_transport(void)
str_tolower(token);
if (i == DIGIT)
{
sscanf(token, "%d", &bcon_first);
(void)sscanf(token, "%d", &bcon_first);
if (bcon_first < 1 || bcon_first > 3)
{
input_error++;
@ -264,7 +264,7 @@ read_transport(void)
str_tolower(token);
if (i == DIGIT)
{
sscanf(token, "%d", &bcon_last);
(void)sscanf(token, "%d", &bcon_last);
if (bcon_last < 1 || bcon_last > 3)
{
input_error++;
@ -293,7 +293,7 @@ read_transport(void)
case 5: /* timest */
case 14: /* time_step */
if (copy_token(token, &next_char, &l) == DIGIT)
sscanf(token, SCANFORMAT, &timest);
(void)sscanf(token, SCANFORMAT, &timest);
{
std::string stdtoken;
j = copy_token(stdtoken, &next_char);
@ -304,7 +304,7 @@ read_transport(void)
}
if (j == DIGIT)
{
sscanf(stdtoken.c_str(), SCANFORMAT, &mcd_substeps);
(void)sscanf(stdtoken.c_str(), SCANFORMAT, &mcd_substeps);
}
}
//if (copy_token(token, &next_char, &l) == DIGIT)
@ -319,7 +319,7 @@ read_transport(void)
break;
case 6: /* diffc */
case 16: /* diffusion_coefficient */
sscanf(next_char, SCANFORMAT, &diffc);
(void)sscanf(next_char, SCANFORMAT, &diffc);
opt_save = OPTION_DEFAULT;
break;
case 7: /* tempr */
@ -327,7 +327,7 @@ read_transport(void)
case 19: /* temperature_retardation_factor */
case 39: /* thermal_diffusion */
if (copy_token(token, &next_char, &l) == DIGIT)
sscanf(token, SCANFORMAT, &tempr);
(void)sscanf(token, SCANFORMAT, &tempr);
if (tempr < 1)
{
tempr = 1;
@ -337,7 +337,7 @@ read_transport(void)
}
j = copy_token(token, &next_char, &l);
if (j == DIGIT)
sscanf(token, SCANFORMAT, &heat_diffc);
(void)sscanf(token, SCANFORMAT, &heat_diffc);
opt_save = OPTION_DEFAULT;
break;
case 8: /* length */
@ -456,7 +456,7 @@ read_transport(void)
case 27: /* output */
case 28: /* output_frequency */
case 34: /* print_frequency */
sscanf(next_char, "%d", &print_modulus);
(void)sscanf(next_char, "%d", &print_modulus);
opt_save = OPTION_DEFAULT;
if (print_modulus <= 0)
{
@ -469,7 +469,7 @@ read_transport(void)
case 31: /* dump_frequency */
dump_in = TRUE;
if (copy_token(token, &next_char, &l) == DIGIT)
sscanf(token, "%d", &dump_modulus);
(void)sscanf(token, "%d", &dump_modulus);
else
{
warning_msg("Expected integer value for dump_frequency.");
@ -480,7 +480,7 @@ read_transport(void)
case 32: /* dump_restart */
dump_in = TRUE;
if (copy_token(token, &next_char, &l) == DIGIT)
sscanf(token, "%d", &transport_start);
(void)sscanf(token, "%d", &transport_start);
else
{
warning_msg
@ -495,7 +495,7 @@ read_transport(void)
break;
case 36: /* initial_time */
if (copy_token(token, &next_char, &l) == DIGIT)
sscanf(token, SCANFORMAT, &initial_total_time);
(void)sscanf(token, SCANFORMAT, &initial_total_time);
{
std::string stdtoken;
j = copy_token(stdtoken, &next_char);
@ -678,7 +678,7 @@ read_transport(void)
case 45: /* current */
if (copy_token(token, &next_char, &l) == DIGIT)
{
sscanf(token, SCANFORMAT, &fix_current);
(void)sscanf(token, SCANFORMAT, &fix_current);
// fix_current = fabs(fix_current);
}
else
@ -704,7 +704,7 @@ read_transport(void)
}
if (copy_token(token, &next_char, &l) == DIGIT)
{
sscanf(token, SCANFORMAT, &max_mixf);
(void)sscanf(token, SCANFORMAT, &max_mixf);
}
else
{
@ -1171,7 +1171,7 @@ read_line_LDBLEs(char *next_char, LDBLE ** d, int *count_d, int *count_alloc)
}
else
{
sscanf(token, SCANFORMAT, &value);
(void)sscanf(token, SCANFORMAT, &value);
n = 1;
}
for (;;)

View File

@ -12,10 +12,7 @@ sit_init(void)
* Initialization for SIT
*/
sit_model = FALSE;
max_sit_param = 100;
count_sit_param = 0;
space((void **) ((void *) &sit_params), INIT, &max_sit_param,
sizeof(struct pitz_param *));
sit_params.clear();
OTEMP = -100.;
OPRESS = -100.;
return OK;
@ -39,16 +36,16 @@ sit_tidy(void)
* allocate pointers to species structures
*/
if (spec != NULL) spec = (struct species **) free_check_null(spec);
spec = (struct species **) PHRQ_malloc((size_t) (3 * count_s * sizeof(struct species *)));
spec = (struct species **) PHRQ_malloc((size_t) (3 * s.size() * sizeof(struct species *)));
if (spec == NULL) malloc_error();
for (i = 0; i < 3 * count_s; i++) spec[i] = NULL;
for (i = 0; i < 3 * (int)s.size(); i++) spec[i] = NULL;
cations = spec;
neutrals = &(spec[count_s]);
anions = &(spec[2 * count_s]);
sit_MAXCATIONS = count_s;
sit_FIRSTANION = 2 * count_s;
sit_MAXNEUTRAL = count_s;
neutrals = &(spec[s.size()]);
anions = &(spec[2 * s.size()]);
sit_MAXCATIONS = (int)s.size();
sit_FIRSTANION = 2 * (int)s.size();
sit_MAXNEUTRAL = (int)s.size();
sit_count_cations = 0;
sit_count_anions = 0;
sit_count_neutrals = 0;
@ -57,17 +54,17 @@ sit_tidy(void)
* allocate other arrays for SIT
*/
if (sit_IPRSNT != NULL) sit_IPRSNT = (int *) free_check_null(sit_IPRSNT);
sit_IPRSNT = (int *) PHRQ_malloc((size_t) (3 * count_s * sizeof(int)));
sit_IPRSNT = (int *) PHRQ_malloc((size_t) (3 * s.size() * sizeof(int)));
if (sit_IPRSNT == NULL) malloc_error();
if (sit_M != NULL) sit_M = (LDBLE *) free_check_null(sit_M);
sit_M = (LDBLE *) PHRQ_malloc((size_t) (3 * count_s * sizeof(LDBLE)));
sit_M = (LDBLE *) PHRQ_malloc((size_t) (3 * s.size() * sizeof(LDBLE)));
if (sit_M == NULL) malloc_error();
if (sit_LGAMMA != NULL) sit_LGAMMA = (LDBLE *) free_check_null(sit_LGAMMA);
sit_LGAMMA = (LDBLE *) PHRQ_malloc((size_t) (3 * count_s * sizeof(LDBLE)));
sit_LGAMMA = (LDBLE *) PHRQ_malloc((size_t) (3 * s.size() * sizeof(LDBLE)));
if (sit_LGAMMA == NULL) malloc_error();
for (i = 0; i < count_s; i++)
for (i = 0; i < (int)s.size(); i++)
{
if (s[i] == s_eminus)
continue;
@ -94,7 +91,7 @@ sit_tidy(void)
/*
* put species numbers in sit_params
*/
for (i = 0; i < count_sit_param; i++)
for (i = 0; i < (int)sit_params.size(); i++)
{
for (j = 0; j < 3; j++)
{
@ -117,7 +114,7 @@ sit_tidy(void)
} /* remake map */
{
sit_param_map.clear();
for (int j = 0; j < count_sit_param; j++)
for (int j = 0; j < (int)sit_params.size(); j++)
{
std::set< std::string > header;
for (int i = 0; i < 3; i++)
@ -134,7 +131,7 @@ sit_tidy(void)
std::string key = key_str.str().c_str();
sit_param_map[key] = j;
}
assert ((int) sit_param_map.size() == count_sit_param);
assert ((int) sit_param_map.size() == (int)sit_params.size());
}
if (get_input_errors() > 0) return (ERROR);
return OK;
@ -149,7 +146,7 @@ sit_ISPEC(const char *name)
*/
{
int i;
for (i = 0; i < 3 * count_s; i++)
for (i = 0; i < 3 * (int)s.size(); i++)
{
if (spec[i] == NULL)
continue;
@ -287,185 +284,6 @@ calc_sit_param(struct pitz_param *pz_ptr, LDBLE TK, LDBLE TR)
}
return OK;
}
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
sit(void)
/* ---------------------------------------------------------------------- */
{
int i, i0, i1;
LDBLE param, z0, z1;
LDBLE A, AGAMMA, T;
/*
LDBLE CONV, XI, XX, OSUM, BIGZ, DI, F, XXX, GAMCLM,
CSUM, PHIMAC, OSMOT, BMXP, ETHEAP, CMX, BMX, PHI,
BMXPHI, PHIPHI, AW, A, B;
*/
/*
LDBLE CONV, XI, XX, OSUM, BIGZ, DI, F, XXX, GAMCLM, CSUM, PHIMAC, OSMOT,
B;
*/
LDBLE XI, XX, OSUM, DI, F, OSMOT, B;
LDBLE I, TK;
/*
C
C INITIALIZE
C
*/
//CONV = 1.0 / LOG_10;
XI = 0.0e0;
XX = 0.0e0;
OSUM = 0.0e0;
/*n
I = *I_X;
TK = *TK_X;
*/
I = mu_x;
TK = tk_x;
/* DH_AB(TK, &A, &B); */
/*
C
C TRANSFER DATA FROM TO sit_M
C
*/
for (i = 0; i < 3 * count_s; i++)
{
sit_IPRSNT[i] = FALSE;
sit_M[i] = 0.0;
if (spec[i] != NULL && spec[i]->in == TRUE)
{
if (spec[i]->type == EX ||
spec[i]->type == SURF || spec[i]->type == SURF_PSI)
continue;
sit_M[i] = under(spec[i]->lm);
if (sit_M[i] > MIN_TOTAL)
sit_IPRSNT[i] = TRUE;
}
}
/*
C
C COMPUTE SIT COEFFICIENTS' TEMPERATURE DEPENDENCE
C
*/
PTEMP_SIT(TK);
for (i = 0; i < 2 * count_s + sit_count_anions; i++)
{
sit_LGAMMA[i] = 0.0;
if (sit_IPRSNT[i] == TRUE)
{
XX = XX + sit_M[i] * fabs(spec[i]->z);
XI = XI + sit_M[i] * spec[i]->z * spec[i]->z;
OSUM = OSUM + sit_M[i];
}
}
I = XI / 2.0e0;
I = mu_x; // Added equation for MU
DI = sqrt(I);
/*
C
C CALCULATE F & GAMCLM
C
*/
AGAMMA = 3*sit_A0; /* Grenthe p 379 */
A = AGAMMA / LOG_10;
/*
* F is now for log10 gamma
*/
B = 1.5;
F = -A * (DI / (1.0e0 + B * DI));
/*OSMOT = -(sit_A0) * pow(I, 1.5e0) / (1.0e0 + B * DI);*/
T = 1.0 + B*DI;
OSMOT = -2.0*A/(B*B*B)*(T - 2.0*log(T) - 1.0/T);
/*
* Sums for sit_LGAMMA, and OSMOT
* epsilons are tabulated for log10 gamma (not ln gamma)
*/
for (i = 0; i < count_sit_param; i++)
{
i0 = sit_params[i]->ispec[0];
i1 = sit_params[i]->ispec[1];
if (sit_IPRSNT[i0] == FALSE || sit_IPRSNT[i1] == FALSE) continue;
z0 = spec[i0]->z;
z1 = spec[i1]->z;
param = sit_params[i]->p;
switch (sit_params[i]->type)
{
case TYPE_SIT_EPSILON:
sit_LGAMMA[i0] += sit_M[i1] * param;
sit_LGAMMA[i1] += sit_M[i0] * param;
if (z0 == 0.0 && z1 == 0.0)
{
OSMOT += sit_M[i0] * sit_M[i1] * param / 2.0;
}
else
{
OSMOT += sit_M[i0] * sit_M[i1] * param;
}
break;
case TYPE_SIT_EPSILON_MU:
sit_LGAMMA[i0] += sit_M[i1] * I * param;
sit_LGAMMA[i1] += sit_M[i0] * I * param;
OSMOT += sit_M[i0] * sit_M[i1] * param;
if (z0 == 0.0 && z1 == 0.0)
{
OSMOT += sit_M[i0] * sit_M[i1] * param * I / 2.0;
}
else
{
OSMOT += sit_M[i0] * sit_M[i1] * param * I;
}
break;
default:
case TYPE_Other:
error_msg("TYPE_Other in pitz_param list.", STOP);
break;
}
}
/*
* Add F and CSUM terms to sit_LGAMMA
*/
for (i = 0; i < sit_count_cations; i++)
{
z0 = spec[i]->z;
sit_LGAMMA[i] += z0 * z0 * F;
}
for (i = 2 * count_s; i < 2 * count_s + sit_count_anions; i++)
{
z0 = spec[i]->z;
sit_LGAMMA[i] += z0 * z0 * F;
}
/*
C
C CONVERT TO MACINNES CONVENTION
C
*/
/*COSMOT = 1.0e0 + 2.0e0 * OSMOT / OSUM;*/
COSMOT = 1.0e0 + OSMOT*LOG_10 / OSUM;
/*
C
C CALCULATE THE ACTIVITY OF WATER
C
*/
AW = exp(-OSUM * COSMOT / 55.50837e0);
/*if (AW > 1.0) AW = 1.0;*/
/*s_h2o->la=log10(AW); */
mu_x = I;
for (i = 0; i < 2 * count_s + sit_count_anions; i++)
{
if (sit_IPRSNT[i] == FALSE) continue;
spec[i]->lg_pitzer = sit_LGAMMA[i];
/*
output_msg(sformatf( "%d %s:\t%e\t%e\t%e\t%e \n", i, spec[i]->name, sit_M[i], spec[i]->la, spec[i]->lg_pitzer, spec[i]->lg));
*/
}
return (OK);
}
#endif
/* ---------------------------------------------------------------------- */
int Phreeqc::
sit(void)
@ -519,7 +337,7 @@ sit(void)
sit_M[i] = 0.0;
}
}
//for (i = 0; i < 3 * count_s; i++)
//for (i = 0; i < 3 * (int)s.size(); i++)
//{
// sit_IPRSNT[i] = FALSE;
// sit_M[i] = 0.0;
@ -547,7 +365,7 @@ sit(void)
XI = XI + sit_M[i] * spec[i]->z * spec[i]->z;
OSUM = OSUM + sit_M[i];
}
//for (i = 0; i < 2 * count_s + sit_count_anions; i++)
//for (i = 0; i < 2 * (int)s.size() + sit_count_anions; i++)
//{
// sit_LGAMMA[i] = 0.0;
// if (sit_IPRSNT[i] == TRUE)
@ -582,8 +400,6 @@ sit(void)
* Sums for sit_LGAMMA, and OSMOT
* epsilons are tabulated for log10 gamma (not ln gamma)
*/
//for (i = 0; i < count_sit_param; i++)
//{
for (size_t j = 0; j < param_list.size(); j++)
{
int i = param_list[j];
@ -641,7 +457,7 @@ sit(void)
// z0 = spec[i]->z;
// sit_LGAMMA[i] += z0 * z0 * F;
//}
//for (i = 2 * count_s; i < 2 * count_s + sit_count_anions; i++)
//for (i = 2 * (int)s.size(); i < 2 * (int)s.size() + sit_count_anions; i++)
//{
// z0 = spec[i]->z;
// sit_LGAMMA[i] += z0 * z0 * F;
@ -667,7 +483,7 @@ sit(void)
int i = s_list[j];
spec[i]->lg_pitzer = sit_LGAMMA[i];
}
// for (i = 0; i < 2 * count_s + sit_count_anions; i++)
// for (i = 0; i < 2 * (int)s.size() + sit_count_anions; i++)
// {
// if (sit_IPRSNT[i] == FALSE) continue;
// spec[i]->lg_pitzer = sit_LGAMMA[i];
@ -687,12 +503,11 @@ sit_clean_up(void)
*/
int i;
for (i = 0; i < count_sit_param; i++)
for (i = 0; i < (int)sit_params.size(); i++)
{
sit_params[i] = (struct pitz_param *) free_check_null(sit_params[i]);
}
count_sit_param = 0;
sit_params = (struct pitz_param **) free_check_null(sit_params);
sit_params.clear();
sit_param_map.clear();
sit_LGAMMA = (LDBLE *) free_check_null(sit_LGAMMA);
sit_IPRSNT = (int *) free_check_null(sit_IPRSNT);
@ -719,14 +534,14 @@ set_sit(int initial)
*/
iterations = -1;
solution_ptr = use.Get_solution_ptr();
for (i = 0; i < count_s_x; i++)
for (i = 0; i < (int)this->s_x.size(); i++)
{
s_x[i]->lm = LOG_ZERO_MOLALITY;
s_x[i]->lg_pitzer = 0.0;
}
if (initial == TRUE || set_and_run_attempt > 0)
{
for (i = 0; i < count_s_x; i++)
for (i = 0; i < (int)this->s_x.size(); i++)
{
s_x[i]->lg = 0.0;
}
@ -1314,7 +1129,7 @@ model_sit(void)
{
count_basis_change++;
count_unknowns -= count_s_x;
count_unknowns -= (int)this->s_x.size();
reprep();
full_pitzer = false;
}
@ -1442,7 +1257,7 @@ gammas_sit()
/*
* Calculate activity coefficients
*/
for (i = 0; i < count_s_x; i++)
for (i = 0; i < (int)this->s_x.size(); i++)
{
switch (s_x[i]->gflag)
{
@ -1505,7 +1320,7 @@ gammas_sit()
if (use.Get_exchange_ptr() != NULL)
{
for (i = 0; i < count_s_x; i++)
for (i = 0; i < (int)this->s_x.size(); i++)
{
switch (s_x[i]->gflag)
{
@ -1573,37 +1388,6 @@ gammas_sit()
return (OK);
}
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
PTEMP_SIT(LDBLE TK)
/* ---------------------------------------------------------------------- */
{
/*
C
C SUBROUTINE TO CALUCLATE TEMPERATURE DEPENDENCE OF PITZER PARAMETER
C
*/
int i;
LDBLE TR = 298.15;
if (fabs(TK - OTEMP) < 0.001 && fabs(patm_x - OPRESS) < 0.1) return OK;
/*
C Set DW0
*/
DW0 = rho_0 = calc_rho_0(TK - 273.15, patm_x);
VP = patm_x;
for (i = 0; i < count_sit_param; i++)
{
calc_sit_param(sit_params[i], TK, TR);
}
calc_dielectrics(TK - 273.15, patm_x);
sit_A0 = A0;
OTEMP = TK;
OPRESS = patm_x;
return OK;
}
#endif
/* ---------------------------------------------------------------------- */
int Phreeqc::
PTEMP_SIT(LDBLE TK)
@ -1657,12 +1441,12 @@ sit_make_lists(void)
max = sit_count_cations;
break;
case 1:
min = count_s;
max = count_s + sit_count_neutrals;
min = (int)s.size();
max = (int)s.size() + sit_count_neutrals;
break;
case 2:
min = 2*count_s;
max = 2*count_s + sit_count_anions;
min = 2*(int)s.size();
max = 2*(int)s.size() + sit_count_anions;
break;
}
for (int i = min; i < max; i++)
@ -1676,19 +1460,19 @@ sit_make_lists(void)
continue;
sit_IPRSNT[i] = TRUE;
s_list.push_back(i);
if (i < count_s)
if (i < (int)s.size())
{
cation_list.push_back(i);
}
if (i >= count_s && i < 2*count_s)
if (i >= (int)s.size() && i < 2*(int)s.size())
{
neutral_list.push_back(i);
}
if (i >= 2*count_s)
if (i >= 2*(int)s.size())
{
anion_list.push_back(i);
}
if (i < count_s || i >= 2*count_s)
if (i < (int)s.size() || i >= 2*(int)s.size())
{
ion_list.push_back(i);
}
@ -1699,7 +1483,7 @@ sit_make_lists(void)
}
}
}
for (int i = 0; i < count_sit_param; i++)
for (int i = 0; i < (int)sit_params.size(); i++)
{
int i0 = sit_params[i]->ispec[0];
int i1 = sit_params[i]->ispec[1];

View File

@ -210,7 +210,7 @@ read_solution_spread(void)
break;
case 14: /* pressure */
case 15: /* press */
sscanf(next_char, SCANFORMAT, &(soln_defaults.pressure));
(void)sscanf(next_char, SCANFORMAT, &(soln_defaults.pressure));
break;
}
}
@ -269,7 +269,7 @@ read_solution_spread(void)
break;
case 0: /* temperature */
case 1:
sscanf(next_char, SCANFORMAT, &(soln_defaults.temp));
(void)sscanf(next_char, SCANFORMAT, &(soln_defaults.temp));
break;
case 2: /* density */
case 3:
@ -331,7 +331,7 @@ read_solution_spread(void)
break;
case 6: /* ph */
copy_token(token, &next_char);
sscanf(token.c_str(), SCANFORMAT, &(soln_defaults.ph));
(void)sscanf(token.c_str(), SCANFORMAT, &(soln_defaults.ph));
if (copy_token(token, &next_char) != EMPTY)
{
warning_msg
@ -340,7 +340,7 @@ read_solution_spread(void)
break;
case 7: /* pe */
copy_token(token, &next_char);
sscanf(token.c_str(), SCANFORMAT, &(soln_defaults.pe));
(void)sscanf(token.c_str(), SCANFORMAT, &(soln_defaults.pe));
if (copy_token(token, &next_char) != EMPTY)
{
warning_msg
@ -409,7 +409,7 @@ read_solution_spread(void)
}
else
{
sscanf(token.c_str(), SCANFORMAT,
(void)sscanf(token.c_str(), SCANFORMAT,
&(soln_defaults.iso[i].uncertainty));
}
}
@ -431,7 +431,7 @@ read_solution_spread(void)
}
else
{
sscanf(token.c_str(), SCANFORMAT, &(soln_defaults.water));
(void)sscanf(token.c_str(), SCANFORMAT, &(soln_defaults.water));
}
}
break;
@ -489,7 +489,7 @@ read_solution_spread(void)
error_msg(error_string, CONTINUE);
break;
}
sscanf(token.c_str(), SCANFORMAT, &(soln_defaults.iso[i].value));
(void)sscanf(token.c_str(), SCANFORMAT, &(soln_defaults.iso[i].value));
/* read and store isotope ratio uncertainty */
int j;
if ((j = copy_token(token, &next_char)) != EMPTY)
@ -504,14 +504,14 @@ read_solution_spread(void)
}
else
{
sscanf(token.c_str(), SCANFORMAT,
(void)sscanf(token.c_str(), SCANFORMAT,
&(soln_defaults.iso[i].uncertainty));
}
}
}
break;
case 14: /* pressure */
sscanf(next_char, SCANFORMAT, &(soln_defaults.pressure));
(void)sscanf(next_char, SCANFORMAT, &(soln_defaults.pressure));
break;
case 100: /* read headings */
heading = string_to_spread_row(line);
@ -720,14 +720,14 @@ spread_row_to_solution(struct spread_row *heading, struct spread_row *units,
break;
case 0: /* temperature */
case 1:
sscanf(next_char, SCANFORMAT, &dummy);
(void)sscanf(next_char, SCANFORMAT, &dummy);
temp_solution.Set_tc(dummy);
break;
case 2: /* density */
case 3:
{
int j = copy_token(token, &next_char);
sscanf(token.c_str(), SCANFORMAT, &dummy);
(void)sscanf(token.c_str(), SCANFORMAT, &dummy);
temp_solution.Set_density(dummy);
j = copy_token(token, &next_char);
if (j != EMPTY)
@ -915,7 +915,7 @@ spread_row_to_solution(struct spread_row *heading, struct spread_row *units,
free_check_null(char_string);
continue;
}
sscanf(token.c_str(), SCANFORMAT, &dummy);
(void)sscanf(token.c_str(), SCANFORMAT, &dummy);
temp_isotope.Set_ratio(dummy);
temp_isotope.Set_ratio_uncertainty(NAN);
@ -932,7 +932,7 @@ spread_row_to_solution(struct spread_row *heading, struct spread_row *units,
free_check_null(char_string);
continue;
}
sscanf(token.c_str(), SCANFORMAT, &dummy);
(void)sscanf(token.c_str(), SCANFORMAT, &dummy);
temp_isotope.Set_ratio_uncertainty(dummy);
}
temp_solution.Get_isotopes()[temp_isotope.Get_isotope_name()] = temp_isotope;
@ -956,7 +956,7 @@ spread_row_to_solution(struct spread_row *heading, struct spread_row *units,
}
else
{
sscanf(token.c_str(), SCANFORMAT, &dummy);
(void)sscanf(token.c_str(), SCANFORMAT, &dummy);
temp_solution.Set_mass_water(dummy);
}
}

View File

@ -318,7 +318,7 @@ xsolution_zero(void)
mass_water_aq_x = 0.0;
units_x = moles_per_kilogram_string;
for (i = 0; i < count_master; i++)
for (i = 0; i < (int)master.size(); i++)
{
master[i]->total = 0.0;
master[i]->total_primary = 0.0;
@ -326,7 +326,7 @@ xsolution_zero(void)
}
if (pitzer_model == TRUE || sit_model == TRUE)
{
for (i = 0; i < count_s; i++)
for (i = 0; i < (int)s.size(); i++)
{
s[i]->lg = 0.0;
}
@ -459,7 +459,7 @@ add_exchange(cxxExchange *exchange_ptr)
}
if (exchange_ptr->Get_new_def())
{
for (int i = 0; i < count_master; i++)
for (int i = 0; i < (int)master.size(); i++)
{
if (master[i]->type == EX && master[i]->total > 0)
{
@ -516,12 +516,6 @@ add_surface(cxxSurface *surface_ptr)
{
cb_x += comp_ptr->Get_charge_balance();
}
#ifdef SKIP_MUSIC
if (surface_ptr->type == CD_MUSIC)
{
cb_x += surface_ptr->comps[i].cb;
}
#endif
if (!surface_ptr->Get_new_def())
{
master_i_ptr->s->la = comp_ptr->Get_la();
@ -1032,12 +1026,7 @@ add_gas_phase(cxxGasPhase *gas_phase_ptr)
/*
* Sort elements in reaction and combine
*/
if (count_elts > 0)
{
qsort(elt_list, (size_t) count_elts,
(size_t) sizeof(struct elt_list), elt_list_compare);
elt_list_combine();
}
elt_list_combine();
/*
* Add gas elements to totals
*/
@ -1343,7 +1332,7 @@ pp_assemblage_check(cxxPPassemblage *pp_assemblage_ptr)
* Make la's of all master species for the element small, so SI will be small
* and no mass transfer will be calculated
*/
for (int k = 0; k < count_master; k++)
for (int k = 0; k < (int)master.size(); k++)
{
if (master[k]->elt->primary == master_ptr)
{
@ -1418,7 +1407,7 @@ ss_assemblage_check(cxxSSassemblage *ss_assemblage_ptr)
* so SI will be small
* and no mass transfer will be calculated
*/
for (k = 0; k < count_master; k++)
for (k = 0; k < (int)master.size(); k++)
{
if (master[k]->elt->primary == master_ptr)
{
@ -1445,7 +1434,7 @@ solution_check(void)
/*
* Check that all elements are in solution for phases with zero mass
*/
for (i = 0; i < count_master; i++)
for (i = 0; i < (int)master.size(); i++)
{
master_ptr = master[i];
if (master_ptr->total <= MIN_TOTAL && master_ptr->total >= -MIN_TOTAL)

File diff suppressed because it is too large Load Diff

View File

@ -82,11 +82,11 @@ get_all_components(void)
add_all_components_tally();
// add secondary master species
for (i = 0; i < count_master; i++)
for (i = 0; i < (int)master.size(); i++)
{
if (master[i]->total > 0.0 && master[i]->s->type == AQ && master[i]->primary == TRUE)
{
for (int j = i + 1; j < count_master; j++)
for (int j = i + 1; j < (int)master.size(); j++)
{
if (master[j]->elt->primary == master[i])
{
@ -105,7 +105,7 @@ get_all_components(void)
* Count components + Alkalinity + total_h + total_o
*/
tally_count_component = 3;
for (i = 0; i < count_master; i++)
for (i = 0; i < (int)master.size(); i++)
{
if (master[i]->total > 0.0 && master[i]->s->type == AQ)
{
@ -140,7 +140,7 @@ get_all_components(void)
compute_gfw("O", &(t_buffer[j].gfw));
j++;
for (i = 0; i < count_master; i++)
for (i = 0; i < (int)master.size(); i++)
{
if (master[i]->total > 0.0 && master[i]->s->type == AQ)
{
@ -157,63 +157,6 @@ get_all_components(void)
count_tally_table_rows = tally_count_component;
return (OK);
}
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
get_all_components(void)
/* ---------------------------------------------------------------------- */
{
/*
* Counts components in any defined solution, gas_phase, exchanger,
* surface, or pure_phase_assemblage
*
* Returns n_comp, which is total, including H, O, elements, and Charge
* names contains character strings with names of components
*/
int i, j;
/*
* Accumulate all aqueous components
*/
add_all_components_tally();
/*
* Count components, 2 for hydrogen, oxygen, + others,
*/
tally_count_component = 0;
for (i = 0; i < count_master; i++)
{
if (master[i]->total > 0.0 && master[i]->s->type == AQ)
{
tally_count_component++;
}
}
/*
* Put information in buffer.
* Buffer contains an entry for every primary master
* species that can be used in the transport problem.
* Each entry in buffer is sent to HST for transort.
*/
t_buffer =
(struct tally_buffer *) PHRQ_malloc((size_t) tally_count_component *
sizeof(struct tally_buffer));
j = 0;
for (i = 0; i < count_master; i++)
{
if (master[i]->total > 0.0 && master[i]->s->type == AQ)
{
t_buffer[j].name = master[i]->elt->name;
t_buffer[j].master = master[i];
t_buffer[j].gfw = master[i]->elt->gfw;
j++;
}
}
/*
* Return value
*/
/**n_comp = count_component;*/
count_tally_table_rows = tally_count_component;
return (OK);
}
#endif
/* ---------------------------------------------------------------------- */
int Phreeqc::
store_tally_table(LDBLE * l_array, int row_dim_in, int col_dim, LDBLE fill_factor)
@ -535,53 +478,6 @@ fill_tally_table(int *n_user, int index_conservative, int n_buffer)
tally_table[i].total[n_buffer][2].moles = solution_ptr->Get_total_o();
}
break;
#ifdef SKIP
case Solution:
/*
* fill solution
*/
if (n_user[Solution] < 0 || n_buffer == 0)
break;
{
cxxSolution *solution_ptr;
if (i == 0)
{
solution_ptr = Utilities::Rxn_find(Rxn_solution_map, index_conservative);
}
else if (i == 1)
{
solution_ptr = Utilities::Rxn_find(Rxn_solution_map, n_user[Solution]);
}
else
{
solution_ptr = NULL;
error_msg
("Solution is not in first two columns of tally_table",
STOP);
}
if (solution_ptr == NULL)
break;
xsolution_zero();
add_solution(solution_ptr, 1.0, 1.0);
count_elts = 0;
paren_count = 0;
for (int j = 0; j < count_master; j++)
{
if (master[j]->total > 0.0)
{
char * temp_name = string_duplicate(master[j]->elt->primary->elt->name);
ptr = temp_name;
get_elts_in_species(&ptr, master[j]->total);
free_check_null(temp_name);
}
}
qsort(elt_list, (size_t) count_elts,
(size_t) sizeof(struct elt_list), elt_list_compare);
elt_list_combine();
elt_list_to_tally_table(tally_table[i].total[n_buffer]);
}
break;
#endif
case Reaction:
/*
* fill reaction
@ -654,8 +550,6 @@ fill_tally_table(int *n_user, int index_conservative, int n_buffer)
{
add_elt_list(exchange_ptr->Get_exchange_comps()[j].Get_totals(), 1.0);
}
qsort(elt_list, (size_t) count_elts,
(size_t) sizeof(struct elt_list), elt_list_compare);
elt_list_combine();
elt_list_to_tally_table(tally_table[i].total[n_buffer]);
}
@ -676,8 +570,6 @@ fill_tally_table(int *n_user, int index_conservative, int n_buffer)
{
add_elt_list(surface_ptr->Get_surface_comps()[j].Get_totals(), 1.0);
}
qsort(elt_list, (size_t) count_elts,
(size_t) sizeof(struct elt_list), elt_list_compare);
elt_list_combine();
elt_list_to_tally_table(tally_table[i].total[n_buffer]);
}
@ -747,8 +639,6 @@ fill_tally_table(int *n_user, int index_conservative, int n_buffer)
add_elt_list(phase_ptr->next_elt, (*gc)[l].Get_moles());
}
qsort(elt_list, (size_t) count_elts,
(size_t) sizeof(struct elt_list), elt_list_compare);
elt_list_combine();
elt_list_to_tally_table(tally_table[i].total[n_buffer]);
break;
@ -860,7 +750,7 @@ master_to_tally_table(struct tally_buffer *buffer_ptr)
* copy element list amounts to buffer in tally table
* for column number
*/
for (j = 0; j < count_master; j++)
for (j = 0; j < (int)master.size(); j++)
{
if (master[j]->total <= 0)
continue;
@ -1025,8 +915,6 @@ build_tally_table(void)
strcpy(token, phase_ptr->formula);
add_elt_list(phase_ptr->next_elt, 1.0);
}
qsort(elt_list, (size_t) count_elts,
(size_t) sizeof(struct elt_list), elt_list_compare);
elt_list_combine();
tally_table[n].formula = elt_list_save();
}
@ -1077,8 +965,6 @@ build_tally_table(void)
paren_count = 0;
strcpy(token, phase_ptr->formula);
add_elt_list(phase_ptr->next_elt, 1.0);
qsort(elt_list, (size_t) count_elts,
(size_t) sizeof(struct elt_list), elt_list_compare);
elt_list_combine();
tally_table[n].formula = elt_list_save();
}
@ -1145,39 +1031,12 @@ build_tally_table(void)
free_check_null(temp_name);
}
}
qsort(elt_list, (size_t) count_elts,
(size_t) sizeof(struct elt_list), elt_list_compare);
elt_list_combine();
tally_table[n].formula = elt_list_save();
}
}
}
#ifdef SKIP
/*
* Debug print for table definition
*/
output_msg(sformatf( "List of rows for tally table\n"));
for (i = 0; i < count_tally_table_rows; i++)
{
output_msg(sformatf( "\t%-s\n", buffer[i].name));
}
output_msg(sformatf( "\nList of columns for tally table\n"));
for (i = 0; i < count_tally_table_columns; i++)
{
output_msg(sformatf( "\t%-20s\tType: %d\n",
tally_table[i].name, tally_table[i].type));
if (tally_table[i].formula != NULL)
{
for (j = 0; tally_table[i].formula[j].elt != NULL; j++)
{
output_msg(sformatf( "\t\t%-10s\t%f\n",
tally_table[i].formula[j].elt->name,
(double) tally_table[i].formula[j].coef));
}
}
}
#endif
pr.use = save_print_use;
return (OK);
}

View File

@ -150,15 +150,14 @@ tidy_model(void)
/* species */
if (new_model == TRUE)
{
qsort(s, (size_t) count_s, (size_t) sizeof(struct species *), s_compare);
qsort(s.data(), s.size(), sizeof(struct species *), s_compare);
/* master species */
qsort(master, (unsigned) count_master, sizeof(struct master *), master_compare);
qsort(master.data(), master.size(), sizeof(struct master *), master_compare);
/* elements */
qsort(elements, (size_t) count_elements, (size_t) sizeof(struct element *), element_compare);
qsort(elements.data(), elements.size(), sizeof(struct element *), element_compare);
/* phases */
qsort(phases, (size_t) count_phases, (size_t) sizeof(struct phase *), phase_compare);
qsort(phases.data(), phases.size(), sizeof(struct phase *), phase_compare);
}
@ -454,7 +453,7 @@ check_species_input(void)
int return_value;
return_value = OK;
for (i = 0; i < count_s; i++)
for (i = 0; i < (int)s.size(); i++)
{
if (s[i]->next_elt == NULL)
{
@ -534,12 +533,12 @@ tidy_logk(void)
*/
{
int i;
for (i = 0; i < count_logk; i++)
for (i = 0; i < (int)logk.size(); i++)
{
select_log_k_expression(logk[i]->log_k_original, logk[i]->log_k);
logk[i]->done = FALSE;
}
for (i = 0; i < count_logk; i++)
for (i = 0; i < (int)logk.size(); i++)
{
if (logk[i]->done == FALSE)
{
@ -1101,173 +1100,7 @@ tidy_gas_phase(void)
}
return (OK);
}
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
tidy_gas_phase(void)
/* ---------------------------------------------------------------------- */
{
int n_user, last;
LDBLE P, V_m;
bool PR;
/*
* Find all gases for each gas_phase in phase list
*/
for (std::set<int>::const_iterator nit = Rxn_new_gas_phase.begin(); nit != Rxn_new_gas_phase.end(); nit++)
{
std::map<int, cxxGasPhase>::iterator it = Rxn_gas_phase_map.find(*nit);
if (it == Rxn_gas_phase_map.end())
{
assert(false);
}
cxxGasPhase *gas_phase_ptr = &(it->second);
PR = false;
P = 0.0;
std::vector<cxxGasComp> gc = gas_phase_ptr->Get_gas_comps();
for (size_t j = 0; j < gc.size(); j++)
{
int k;
struct phase *phase_ptr = phase_bsearch(gc[j].Get_phase_name().c_str(), &k, FALSE);
if (phase_ptr == NULL)
{
input_error++;
error_string = sformatf(
"Gas not found in PHASES database, %s.",
gc[j].Get_phase_name().c_str());
error_msg(error_string, CONTINUE);
continue;
}
else
{
if (phase_ptr->t_c > 0 && phase_ptr->p_c > 0)
PR = true;
}
gas_phase_ptr->Set_pr_in(PR);
if (gas_phase_ptr->Get_new_def())
{
if (j == gc.size() - 1)
gas_phase_ptr->Set_new_def(false);
/*
* Fixed pressure
*/
if (gas_phase_ptr->Get_type() == cxxGasPhase::GP_PRESSURE)
{
if (gas_phase_ptr->Get_solution_equilibria())
{
input_error++;
error_string = sformatf(
"Gas phase %d: cannot use '-equilibrium' option with fixed pressure gas phase.",
gas_phase_ptr->Get_n_user());
error_msg(error_string, CONTINUE);
}
/* calculate moles */
if (gc[j].Get_p_read() != NAN)
{
P += gc[j].Get_p_read();
if (!PR)
gc[j].Set_moles(
gc[j].Get_p_read() * gas_phase_ptr->Get_volume() /
R_LITER_ATM / gas_phase_ptr->Get_temperature());
}
else
{
input_error++;
error_string = sformatf(
"Gas phase %d: partial pressure of gas component %s not defined.",
gas_phase_ptr->Get_n_user(), gc[j].Get_phase_name().c_str());
error_msg(error_string, CONTINUE);
}
}
else
{
/*
* Fixed volume
*/
if (!gas_phase_ptr->Get_solution_equilibria())
{
if (gc[j].Get_p_read() != NAN)
{
P += gc[j].Get_p_read();
if (!PR)
gc[j].Set_moles (
gc[j].Get_p_read() *
gas_phase_ptr->Get_volume() / R_LITER_ATM /
gas_phase_ptr->Get_temperature());
}
else
{
input_error++;
error_string = sformatf(
"Gas phase %d: moles of gas component %s not defined.",
gas_phase_ptr->Get_n_user(),
gc[j].Get_phase_name().c_str());
error_msg(error_string, CONTINUE);
}
}
}
gas_phase_ptr->Set_gas_comps(gc);
if (PR && P > 0 && j == gc.size() - 1)
{
std::vector<struct phase *> phase_ptrs;
size_t j_PR;
for (j_PR = 0; j_PR < gas_phase_ptr->Get_gas_comps().size(); j_PR++)
{
int k;
struct phase *phase_ptr = phase_bsearch(gas_phase_ptr->Get_gas_comps()[j_PR].Get_phase_name().c_str(), &k, FALSE);
if (gc[j_PR].Get_p_read() == 0)
continue;
phase_ptr->moles_x = gc[j_PR].Get_p_read() / P;
phase_ptrs.push_back(phase_ptr);
}
V_m = calc_PR(phase_ptrs, P, gas_phase_ptr->Get_temperature(), 0);
gas_phase_ptr->Set_v_m(V_m);
if (gas_phase_ptr->Get_type() == cxxGasPhase::GP_VOLUME)
{
gas_phase_ptr->Set_total_p(P);
}
std::vector<cxxGasComp> gc = gas_phase_ptr->Get_gas_comps();
for (j_PR = 0; j_PR < gas_phase_ptr->Get_gas_comps().size(); j_PR++)
{
int k;
struct phase *phase_ptr = phase_bsearch(gc[j_PR].Get_phase_name().c_str(), &k, FALSE);
if (gc[j_PR].Get_p_read() == 0)
{
gc[j_PR].Set_moles(0.0);
} else
{
gc[j_PR].Set_moles(phase_ptr->moles_x *
gas_phase_ptr->Get_volume() / V_m);
gas_phase_ptr->Set_total_moles(gas_phase_ptr->Get_total_moles() + gc[j_PR].Get_moles());
}
}
gas_phase_ptr->Set_gas_comps(gc);
}
/*
* Duplicate gas phase, only if not solution equilibria
*/
if (!gas_phase_ptr->Get_solution_equilibria())
{
n_user = gas_phase_ptr->Get_n_user();
last = gas_phase_ptr->Get_n_user_end();
gas_phase_ptr->Set_n_user_end(n_user);
for (int j1 = n_user + 1; j1 <= last; j1++)
{
Utilities::Rxn_copy(Rxn_gas_phase_map, n_user, j1);
}
}
else
{
gas_phase_ptr->Set_new_def(true);
}
}
}
}
return (OK);
}
#endif
/* ---------------------------------------------------------------------- */
int Phreeqc::
tidy_inverse(void)
@ -1474,16 +1307,11 @@ tidy_inverse(void)
/*
* Sort elements in reaction and combine
*/
if (count_elts > 0)
{
qsort(elt_list, (size_t) count_elts,
(size_t) sizeof(struct elt_list), elt_list_compare);
elt_list_combine();
}
elt_list_combine();
/*
* Mark master species list
*/
for (j = 0; j < count_master; j++)
for (j = 0; j < (int)master.size(); j++)
master[j]->in = FALSE;
for (j = 0; j < count_elts; j++)
{
@ -1511,13 +1339,13 @@ tidy_inverse(void)
*/
count_in = 0;
inverse[i].count_redox_rxns = 0;
for (j = 0; j < count_master; j++)
for (j = 0; j < (int)master.size(); j++)
{
/* skip all secondary master species in this loop */
if (master[j]->primary == FALSE || master[j]->in == FALSE)
continue;
count_in++;
if (j + 1 == count_master)
if (j + 1 == (int)master.size())
continue;
/* if next master species is secondary, mark all
secondary master species until a primary is found */
@ -1525,7 +1353,7 @@ tidy_inverse(void)
{
master[j]->in = FALSE;
count_in--;
for (k = j + 1; k < count_master; k++)
for (k = j + 1; k < (int)master.size(); k++)
{
if (master[k]->primary == FALSE)
{
@ -1552,7 +1380,7 @@ tidy_inverse(void)
if (inv_elts == NULL)
malloc_error();
count_in = 0;
for (j = 0; j < count_master; j++)
for (j = 0; j < (int)master.size(); j++)
{
/* skip H(1) and O(-2) */
if (master[j]->s == s_hplus || master[j]->s == s_h2o)
@ -1676,7 +1504,7 @@ tidy_phases(void)
/*
* Fix log Ks first, so they can possibly be added to other phase equations
*/
for (i = 0; i < count_phases; i++)
for (i = 0; i < (int)phases.size(); i++)
{
select_log_k_expression(phases[i]->logk, phases[i]->rxn->logk);
add_other_logk(phases[i]->rxn->logk, phases[i]->count_add_logk,
@ -1687,7 +1515,7 @@ tidy_phases(void)
/*
* Rewrite all phases to secondary species
*/
for (i = 0; i < count_phases; i++)
for (i = 0; i < (int)phases.size(); i++)
{
/*
* Rewrite equation
@ -2415,7 +2243,6 @@ tidy_punch(void)
/* calculate_values */
//for (i = 0; i < punch.count_calculate_values; i++)
for (size_t i = 0; i < current_selected_output->Get_calculate_values().size(); i++)
{
std::pair< std::string, void *> &pair_ref = current_selected_output->Get_calculate_values()[i];
@ -2475,312 +2302,7 @@ tidy_punch(void)
phrq_io->Set_punch_ostream(NULL);
return (OK);
}
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
tidy_punch(void)
/* ---------------------------------------------------------------------- */
{
int i, j, l;
int punch_save;
char token[MAX_LENGTH];
/*
* tidy punch information
*/
if (punch.high_precision == FALSE)
{
l = 12;
}
else
{
l = 20;
}
if (punch.in == TRUE)
{
/* totals */
for (i = 0; i < punch.count_totals; i++)
{
punch.totals[i].master = master_bsearch(punch.totals[i].name);
}
/* molalities */
for (i = 0; i < punch.count_molalities; i++)
{
punch.molalities[i].s = s_search(punch.molalities[i].name);
}
/* log activities */
for (i = 0; i < punch.count_activities; i++)
{
punch.activities[i].s = s_search(punch.activities[i].name);
}
/* equilibrium phases */
for (i = 0; i < punch.count_pure_phases; i++)
{
punch.pure_phases[i].phase =
phase_bsearch(punch.pure_phases[i].name, &j, FALSE);
}
/* saturation indices */
for (i = 0; i < punch.count_si; i++)
{
punch.si[i].phase = phase_bsearch(punch.si[i].name, &j, FALSE);
}
/* gases */
for (i = 0; i < punch.count_gases; i++)
{
punch.gases[i].phase =
phase_bsearch(punch.gases[i].name, &j, FALSE);
}
}
/*
* Always write new headings when SELECTED_OUTPUT is read
*/
if (punch.new_def == TRUE && punch.in == TRUE)
{
punch_save = pr.punch;
pr.punch = TRUE;
phrq_io->Set_punch_on(true);
/* constant stuff, sim, pH, etc. */
if (punch.sim == TRUE)
{
fpunchf_heading(sformatf("%*s\t", l, "sim"));
}
if (punch.state == TRUE)
{
fpunchf_heading(sformatf("%*s\t", l, "state"));
}
if (punch.soln == TRUE)
{
fpunchf_heading(sformatf("%*s\t", l, "soln"));
}
if (punch.dist == TRUE)
{
fpunchf_heading(sformatf("%*s\t", l, "dist_x"));
}
if (punch.time == TRUE)
{
fpunchf_heading(sformatf("%*s\t", l, "time"));
}
if (punch.step == TRUE)
{
fpunchf_heading(sformatf("%*s\t", l, "step"));
}
if (punch.ph == TRUE)
{
fpunchf_heading(sformatf("%*s\t", l, "pH"));
}
if (punch.pe == TRUE)
{
fpunchf_heading(sformatf("%*s\t", l, "pe"));
}
if (punch.rxn == TRUE)
{
fpunchf_heading(sformatf("%*s\t", l, "reaction"));
}
if (punch.temp == TRUE)
{
fpunchf_heading(sformatf("%*s\t", l, "temp"));
}
if (punch.alk == TRUE)
{
fpunchf_heading(sformatf("%*s\t", l, "Alk"));
}
if (punch.mu == TRUE)
{
fpunchf_heading(sformatf("%*s\t", l, "mu"));
}
if (punch.water == TRUE)
{
fpunchf_heading(sformatf("%*s\t", l, "mass_H2O"));
}
if (punch.charge_balance == TRUE)
{
fpunchf_heading(sformatf("%*s\t", l, "charge"));
}
if (punch.percent_error == TRUE)
{
fpunchf_heading(sformatf("%*s\t", l, "pct_err"));
}
/* totals */
for (i = 0; i < punch.count_totals; i++)
{
fpunchf_heading(sformatf("%*s\t", l, punch.totals[i].name));
if (punch.totals[i].master == NULL)
{
error_string = sformatf( "Did not find master species,"
" %s.", punch.totals[i].name);
warning_msg(error_string);
}
}
/* molalities */
for (i = 0; i < punch.count_molalities; i++)
{
strcpy(token, "m_");
strcat(token, punch.molalities[i].name);
fpunchf_heading(sformatf("%*s\t", l, token));
if (punch.molalities[i].s == NULL)
{
error_string = sformatf( "Did not find species,"
" %s.", punch.molalities[i].name);
warning_msg(error_string);
}
}
/* log activities */
for (i = 0; i < punch.count_activities; i++)
{
strcpy(token, "la_");
strcat(token, punch.activities[i].name);
fpunchf_heading(sformatf("%*s\t", l, token));
if (punch.activities[i].s == NULL)
{
error_string = sformatf( "Did not find species, "
"%s.", punch.activities[i].name);
warning_msg(error_string);
}
}
/* equilibrium phases */
for (i = 0; i < punch.count_pure_phases; i++)
{
strcpy(token, "d_");
strcat(token, punch.pure_phases[i].name);
fpunchf_heading(sformatf("%*s\t", l, punch.pure_phases[i].name));
fpunchf_heading(sformatf("%*s\t", l, token));
if (punch.pure_phases[i].phase == NULL)
{
error_string = sformatf( "Did not find phase, "
"%s.", punch.pure_phases[i].name);
warning_msg(error_string);
}
}
/* saturation indices */
for (i = 0; i < punch.count_si; i++)
{
strcpy(token, "si_");
strcat(token, punch.si[i].name);
fpunchf_heading(sformatf("%*s\t", l, token));
if (punch.si[i].phase == NULL)
{
error_string = sformatf( "Did not find phase, "
"%s.", punch.si[i].name);
warning_msg(error_string);
}
}
/* gases */
if (punch.count_gases > 0)
{
fpunchf_heading(sformatf("%*s\t", l, "pressure"));
fpunchf_heading(sformatf("%*s\t", l, "total mol"));
fpunchf_heading(sformatf("%*s\t", l, "volume"));
}
for (i = 0; i < punch.count_gases; i++)
{
strcpy(token, "g_");
strcat(token, punch.gases[i].name);
fpunchf_heading(sformatf("%*s\t", l, token));
if (punch.gases[i].phase == NULL)
{
error_string = sformatf( "Did not find phase, "
"%s.", punch.gases[i].name);
warning_msg(error_string);
}
}
/* kinetics */
for (i = 0; i < punch.count_kinetics; i++)
{
strcpy(token, "k_");
strcat(token, punch.kinetics[i].name);
fpunchf_heading(sformatf("%*s\t", l, token));
strcpy(token, "dk_");
strcat(token, punch.kinetics[i].name);
fpunchf_heading(sformatf("%*s\t", l, token));
}
/* solid solutions */
for (i = 0; i < punch.count_s_s; i++)
{
strcpy(token, "s_");
strcat(token, punch.s_s[i].name);
fpunchf_heading(sformatf("%*s\t", l, token));
}
/* isotopes */
for (i = 0; i < punch.count_isotopes; i++)
{
if (isotope_ratio_search(punch.isotopes[i].name) == NULL)
{
error_string = sformatf(
"Did not find isotope_ratio definition for "
"%s in -isotopes of SELECTED_OUTPUT.\n%s must be defined in ISOTOPE_RATIO data block.",
punch.isotopes[i].name, punch.isotopes[i].name);
warning_msg(error_string);
}
strcpy(token, "I_");
strcat(token, punch.isotopes[i].name);
fpunchf_heading(sformatf("%*s\t", l, token));
}
/* calculate_values */
for (i = 0; i < punch.count_calculate_values; i++)
{
if (calculate_value_search(punch.calculate_values[i].name) == NULL)
{
error_string = sformatf(
"Did not find calculate_values definition for "
"%s in -calculate_values of SELECTED_OUTPUT.\n%s must be defined in CALCULATE_VALUES data block.",
punch.calculate_values[i].name,
punch.calculate_values[i].name);
warning_msg(error_string);
}
strcpy(token, "V_");
strcat(token, punch.calculate_values[i].name);
fpunchf_heading(sformatf("%*s\t", l, token));
}
/* user_punch */
if (punch.user_punch == TRUE)
{
for (i = 0; i < user_punch_count_headings; i++)
{
fpunchf_heading(sformatf("%*s\t", l, user_punch_headings[i]));
}
}
fpunchf_heading("\n");
punch.new_def = FALSE;
pr.punch = punch_save;
phrq_io->Set_punch_on(pr.punch == TRUE);
}
punch_flush();
return (OK);
}
#endif
/* ---------------------------------------------------------------------- */
int Phreeqc::
tidy_species(void)
@ -2799,7 +2321,7 @@ tidy_species(void)
/*
* Set secondary and primary pointers in species structures
*/
for (i = 0; i < count_s; i++)
for (i = 0; i < (int)s.size(); i++)
{
s[i]->number = i;
s[i]->primary = NULL;
@ -2817,7 +2339,7 @@ tidy_species(void)
}
}
}
for (i = 0; i < count_master; i++)
for (i = 0; i < (int)master.size(); i++)
{
char * temp_name = string_duplicate(master[i]->elt->name);
ptr = temp_name;
@ -2870,7 +2392,7 @@ tidy_species(void)
* Write equations for all master species in terms of primary
* master species, set coefficient of element in master species
*/
for (i = 0; i < count_master; i++)
for (i = 0; i < (int)master.size(); i++)
{
count_trxn = 0;
if (master[i]->s->primary != NULL)
@ -2891,7 +2413,7 @@ tidy_species(void)
/*
* Rewrite all species to secondary species
*/
for (i = 0; i < count_s; i++)
for (i = 0; i < (int)s.size(); i++)
{
count_trxn = 0;
if (s[i]->primary != NULL || s[i]->secondary != NULL)
@ -2923,7 +2445,7 @@ tidy_species(void)
/*
* Set pointer in element to master species
*/
for (i = 0; i < count_elements; i++)
for (i = 0; i < (int)elements.size(); i++)
{
elements[i]->master = master_bsearch(elements[i]->name);
if (elements[i]->master == NULL)
@ -2946,7 +2468,7 @@ tidy_species(void)
* Make sure all primary master species for redox elements
* are also secondary master species
*/
for (i = 0; i < count_master; i++)
for (i = 0; i < (int)master.size(); i++)
{
if (master[i]->primary == FALSE)
{
@ -2982,7 +2504,7 @@ tidy_species(void)
/*
* Calculate H and O if alternate mass balance is given
*/
for (i = 0; i < count_s; i++)
for (i = 0; i < (int)s.size(); i++)
{
if (s[i]->next_secondary != NULL)
{
@ -3090,7 +2612,7 @@ tidy_species(void)
}
}
for (i = 0; i < count_master; i++)
for (i = 0; i < (int)master.size(); i++)
{
if (master[i]->gfw <= 0.0)
{
@ -3221,17 +2743,6 @@ tidy_surface(void)
}
break;
}
#ifdef SKIP_MUSIC
/*
* If charge of formula is non zero
*/
if (surface_ptr->type == CD_MUSIC)
{
surface_ptr->comps[i].cb =
surface_ptr->comps[i].formula_z *
surface_ptr->comps[i].moles;
}
#endif
}
/*
* Check that all surface comps have a corresponding master
@ -3384,11 +2895,8 @@ species_rxn_to_trxn(struct species *s_ptr)
trxn.token[i].unknown = NULL;
trxn.token[i].coef = s_ptr->rxn->token[i].coef;
count_trxn = i + 1;
if (count_trxn + 1 >= max_trxn)
{
space((void **) ((void *) &(trxn.token)), count_trxn + 1,
&max_trxn, sizeof(struct rxn_token_temp));
}
if ((size_t)count_trxn + 1 > trxn.token.size())
trxn.token.resize((size_t)count_trxn + 1);
}
return (OK);
}
@ -3427,11 +2935,8 @@ phase_rxn_to_trxn(struct phase *phase_ptr, struct reaction *rxn_ptr)
trxn.token[i].unknown = NULL;
trxn.token[i].coef = rxn_ptr->token[i].coef;
count_trxn = i + 1;
if (count_trxn + 1 >= max_trxn)
{
space((void **) ((void *) &(trxn.token)), count_trxn + 1,
&max_trxn, sizeof(struct rxn_token_temp));
}
if ((size_t)count_trxn + 1 > trxn.token.size())
trxn.token.resize((size_t)count_trxn + 1);
}
return (OK);
}
@ -3501,7 +3006,7 @@ tidy_isotopes(void)
/* find index number of master species, set flag to FALSE */
master_ptr = master_bsearch(kit->second.Get_elt_name().c_str());
isotope_number = kit->second.Get_isotope_number();
for (int k = 0; k < count_master; k++)
for (int k = 0; k < (int)master.size(); k++)
{
master[k]->isotope = FALSE;
}
@ -3532,7 +3037,7 @@ tidy_isotopes(void)
/* for primary, fill in ratio for all secondary species */
if (master_ptr->primary == TRUE && master_ptr->s->secondary != NULL)
{
for (int k = primary_number + 1; k < count_master; k++)
for (int k = primary_number + 1; k < (int)master.size(); k++)
{
if (master[k]->elt->primary != primary_ptr)
break;
@ -3566,7 +3071,7 @@ tidy_isotopes(void)
/*
* Write new isotope structure
*/
for (int k = 0; k < count_master; k++)
for (int k = 0; k < (int)master.size(); k++)
{
/* skip primary master species of redox elements */
if (master[k]->primary == TRUE && master[k]->s->secondary != NULL)
@ -4001,8 +3506,6 @@ tidy_min_exchange(void)
error_msg(error_string, CONTINUE);
continue;
}
qsort(elt_list, (size_t) count_elts,
(size_t) sizeof(struct elt_list), elt_list_compare);
elt_list_combine();
for (jj = 0; jj < count_elts; jj++)
{
@ -4181,8 +3684,6 @@ update_min_exchange(void)
error_msg(error_string, CONTINUE);
continue;
}
qsort(elt_list, (size_t)count_elts,
(size_t)sizeof(struct elt_list), elt_list_compare);
elt_list_combine();
for (jj = 0; jj < count_elts; jj++)
{
@ -4317,9 +3818,6 @@ tidy_min_surface(void)
surface_comp_ptr->Set_phase_name(phase_ptr->name);
/* make surface concentration proportional to mineral ... */
LDBLE conc = jit->second.Get_moles() * surface_comp_ptr->Get_phase_proportion();
#ifdef SKIP_MUSIC
comp_ptr->cb = conc * comp_ptr->formula_z;
#endif
/* if (conc < MIN_RELATED_SURFACE) conc = 0.0; */
{
char * temp_formula = string_duplicate(surface_comp_ptr->Get_formula().c_str());
@ -4409,8 +3907,6 @@ tidy_min_surface(void)
free_check_null(temp_formula);
}
}
qsort(elt_list, (size_t) count_elts,
(size_t) sizeof(struct elt_list), elt_list_compare);
elt_list_combine();
/* Makes no sense: sorbed species need not be in mineral structure... */
/* But elements that can desorb into solution must be in mineral */
@ -4782,8 +4278,6 @@ tidy_kin_surface(void)
/* save kinetics formula */
if (count_elts > 0)
{
qsort(elt_list, (size_t) count_elts,
(size_t) sizeof(struct elt_list), elt_list_compare);
elt_list_combine();
}
elt_list_kinetics = elt_list_save();
@ -4809,12 +4303,7 @@ tidy_kin_surface(void)
free_check_null(temp_formula);
}
}
if (count_elts > 0)
{
qsort(elt_list, (size_t) count_elts,
(size_t) sizeof(struct elt_list), elt_list_compare);
elt_list_combine();
}
elt_list_combine();
for (int j = 0; j < count_elts; j++)
{
if (elt_list[j].elt == NULL)
@ -6013,7 +5502,7 @@ tidy_master_isotope(void)
int i;
struct master *master_ptr;
for (i = 0; i < count_master_isotope; i++)
for (i = 0; i < (int)master_isotope.size(); i++)
{
/*
* Mark master species list as minor isotope
@ -6051,7 +5540,7 @@ tidy_isotope_ratios(void)
struct master_isotope *master_isotope_ptr;
struct calculate_value *calculate_value_ptr;
for (i = 0; i < count_isotope_ratio; i++)
for (i = 0; i < (int)isotope_ratio.size(); i++)
{
/*
* Mark master species list as minor isotope
@ -6097,7 +5586,7 @@ tidy_isotope_alphas(void)
struct calculate_value *calculate_value_ptr;
struct logk *logk_ptr;
for (i = 0; i < count_isotope_alpha; i++)
for (i = 0; i < (int)isotope_alpha.size(); i++)
{
/*
* Mark master species list as minor isotope

View File

@ -135,7 +135,7 @@ transport(void)
ct[i].m_s = NULL;
ct[i].v_m_size = ct[i].J_ij_size = ct[i].m_s_size = 0;
}
count_moles_added = count_elements;
count_moles_added = (int)elements.size();
moles_added = (struct MOLES_ADDED *) PHRQ_malloc((size_t) (count_moles_added)* sizeof(struct MOLES_ADDED));
if (moles_added == NULL)
malloc_error();
@ -1812,13 +1812,13 @@ fill_spec(int l_cell_no, int ref_cell)
//sol_D[l_cell_no].spec = (struct spec *) free_check_null(sol_D[l_cell_no].spec);
if (sol_D[l_cell_no].spec == NULL)
{
sol_D[l_cell_no].spec = (struct spec *) PHRQ_malloc((size_t)(count_species_list + size_xt) * sizeof(struct spec));
sol_D[l_cell_no].spec_size = count_species_list + size_xt;
sol_D[l_cell_no].spec = (struct spec *) PHRQ_malloc((species_list.size() + (size_t)size_xt) * sizeof(struct spec));
sol_D[l_cell_no].spec_size = (int)species_list.size() + size_xt;
}
else if (count_species_list + size_xt > sol_D[l_cell_no].spec_size)
else if ((int)species_list.size() + size_xt > sol_D[l_cell_no].spec_size)
{
sol_D[l_cell_no].spec = (struct spec *) PHRQ_realloc(sol_D[l_cell_no].spec, (size_t)(count_species_list + size_xt) * sizeof(struct spec));
sol_D[l_cell_no].spec_size = count_species_list + size_xt;
sol_D[l_cell_no].spec = (struct spec *) PHRQ_realloc(sol_D[l_cell_no].spec, (species_list.size() + (size_t)size_xt) * sizeof(struct spec));
sol_D[l_cell_no].spec_size = (int)species_list.size() + size_xt;
}
if (sol_D[l_cell_no].spec == NULL)
malloc_error();
@ -1878,11 +1878,13 @@ fill_spec(int l_cell_no, int ref_cell)
/*
* sort species by name...
*/
if (count_species_list > 0)
qsort(&species_list[0], (size_t) count_species_list,
(size_t) sizeof(struct species_list), sort_species_name);
if (species_list.size() > 1)
{
qsort(&species_list[0], species_list.size(),
sizeof(struct species_list), sort_species_name);
}
for (i = 0; i < count_species_list; i++)
for (i = 0; i < (int)species_list.size(); i++)
{
/*
* copy species data
@ -5891,7 +5893,7 @@ viscosity(void)
tc = (tc_x > 200) ? 200 : tc_x;
for (i = 0; i < count_s_x; i++)
for (i = 0; i < (int)this->s_x.size(); i++)
{
if (s_x[i]->type != AQ && s_x[i]->type > HPLUS)
continue;

View File

@ -19,10 +19,9 @@ add_elt_list(struct elt_list *elt_list_ptr, LDBLE coef)
for (elt_list_ptr1 = elt_list_ptr; elt_list_ptr1->elt != NULL;
elt_list_ptr1++)
{
if (count_elts >= max_elts)
if (count_elts >= (int)elt_list.size())
{
space((void **) ((void *) &elt_list), count_elts, &max_elts,
sizeof(struct elt_list));
elt_list.resize((size_t)count_elts + 1);
}
elt_list[count_elts].elt = elt_list_ptr1->elt;
elt_list[count_elts].coef = elt_list_ptr1->coef * coef;
@ -65,10 +64,9 @@ add_elt_list_multi_surf(struct elt_list *elt_list_ptr, LDBLE coef, struct elemen
for (elt_list_ptr1 = elt_list_ptr; elt_list_ptr1->elt != NULL;
elt_list_ptr1++)
{
if (count_elts >= max_elts)
if (count_elts >= (int)elt_list.size())
{
space((void **) ((void *) &elt_list), count_elts, &max_elts,
sizeof(struct elt_list));
elt_list.resize((size_t)count_elts + 1);
}
if (elt_list_ptr1->elt == surf_elt_ptr)
{
@ -93,10 +91,9 @@ add_elt_list_multi_surf(struct elt_list *elt_list_ptr, LDBLE coef, struct elemen
for (elt_list_ptr1 = elt_list_ptr; elt_list_ptr1->elt != NULL;
elt_list_ptr1++)
{
if (count_elts >= max_elts)
if (count_elts >= (int)elt_list.size())
{
space((void **) ((void *) &elt_list), count_elts, &max_elts,
sizeof(struct elt_list));
elt_list.resize((size_t)count_elts + 1);
}
if (elt_list_ptr1->elt == surf_elt_ptr)
{
@ -115,10 +112,9 @@ add_elt_list(const cxxNameDouble & nd, LDBLE coef)
cxxNameDouble::const_iterator cit = nd.begin();
for ( ; cit != nd.end(); cit++)
{
if (count_elts >= max_elts)
if (count_elts >= (int)elt_list.size())
{
space((void **) ((void *) &elt_list), count_elts, &max_elts,
sizeof(struct elt_list));
elt_list.resize((size_t)count_elts + 1);
}
elt_list[count_elts].elt = element_store(cit->first.c_str());
elt_list[count_elts].coef = cit->second * coef;
@ -407,15 +403,6 @@ copy_token(char *token_ptr, char **ptr, int *length)
}
token_ptr[i] = '\0';
*length = i;
#ifdef PHREEQ98
if ((return_value == DIGIT) && (strstr(token_ptr, ",") != NULL))
{
error_string = sformatf(
"Commas are not allowed as decimal separator: %s.",
token_ptr);
error_msg(error_string, CONTINUE);
}
#endif
return (return_value);
}
/* ---------------------------------------------------------------------- */
@ -484,15 +471,6 @@ copy_token(std::string &token, char **ptr)
token.append(c_char);
(*ptr)++;
}
#ifdef PHREEQ98
if ((return_value == DIGIT) && (strstr(token_ptr, ",") != NULL))
{
error_string = sformatf(
"Commas are not allowed as decimal separator: %s.",
token_ptr);
error_msg(error_string, CONTINUE);
}
#endif
return (return_value);
}
#if defined PHREEQ98
@ -599,17 +577,6 @@ dup_print(const char *ptr, int emphasis)
if (pr.headings == FALSE)
return (OK);
#ifdef PHREEQ98
if ((CreateToC == TRUE) && (AutoLoadOutputFile == TRUE))
{
if (strstr(ptr, "Reading") == ptr)
AddToCEntry((char *) ptr, 1, outputlinenr);
else if (strstr(ptr, "Beginning") == ptr)
AddToCEntry((char *) ptr, 2, outputlinenr);
else if ((strstr(ptr, "TITLE") != ptr) && (strstr(ptr, "End") != ptr))
AddToCEntry((char *) ptr, 3, outputlinenr);
}
#endif
std::string save_in(ptr);
l = (int) strlen(ptr);
dash = (char *) PHRQ_malloc((size_t) (l + 2) * sizeof(char));
@ -1001,10 +968,6 @@ print_centered(const char *string)
int i, l, l1, l2;
char token[MAX_LENGTH];
#ifdef PHREEQ98
if ((CreateToC == TRUE) && (AutoLoadOutputFile == TRUE))
AddToCEntry((char *) string, 4, outputlinenr);
#endif
l = (int) strlen(string);
l1 = (79 - l) / 2;
l2 = 79 - l - l1;
@ -1397,12 +1360,6 @@ status(int count, const char *str, bool rk_string)
char spin_str[2];
clock_t t2;
#ifdef PHREEQ98
if (ProcessMessages)
ApplicationProcessMessages();
if (stop_calculations == TRUE)
error_msg("Execution canceled by user.", STOP);
#endif
if (pr.status == FALSE || phast == TRUE)
return (OK);
@ -2030,29 +1987,6 @@ string_pad(const char *str, int i)
}
return (str_ptr);
}
/* ---------------------------------------------------------------------- */
void Phreeqc::
zero_double(LDBLE * target, int n)
/* ---------------------------------------------------------------------- */
{
int i;
if (n > zeros_max)
{
zeros = (LDBLE *) PHRQ_realloc(zeros, (size_t) (n * sizeof(LDBLE)));
if (zeros == NULL)
malloc_error();
for (i = zeros_max; i < n; i++)
{
zeros[i] = 0.0;
}
zeros_max = n;
}
memcpy((void *) target, (void *) zeros, (size_t) (n * sizeof(LDBLE)));
return;
}
/* ---------------------------------------------------------------------- */
int Phreeqc::
get_input_errors()