mirror of
https://git.gfz-potsdam.de/naaice/iphreeqc.git
synced 2025-12-16 16:44:49 +01:00
gas_phase and irrev removed.
get_line moved to PHRQ_io. Still debugging some. git-svn-id: svn://136.177.114.72/svn_GW/phreeqcpp/branches/ErrorHandling@5967 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
parent
ddafdd170f
commit
acf62c7881
@ -125,7 +125,7 @@ ChartHandler::End_timer()
|
||||
// size_t i;
|
||||
// for (i = 0; i < it->second->Get_Curves().size(); i ++)
|
||||
// {
|
||||
// std::cerr << "Curve " << i << ", number of points " << it->second->Get_Curves()[i]->Get_x().size() << std::endl;
|
||||
// std::cerr << "Curve " << i << ", number of points " << it->second->Get_Curves()[i]->Get_x().size() << "\n";
|
||||
// }
|
||||
//}
|
||||
size_t i = 0;
|
||||
|
||||
@ -142,7 +142,7 @@ ChartObject::Set_axis_scale(CParser & parser)
|
||||
}
|
||||
if (string_vector.size() == 0)
|
||||
{
|
||||
error_msg("No axis defined for scales", CParser::OT_CONTINUE);
|
||||
error_msg("No axis defined for scales", PHRQ_io::OT_CONTINUE);
|
||||
return false;
|
||||
}
|
||||
std::string str = string_vector[0];
|
||||
@ -168,8 +168,8 @@ ChartObject::Set_axis_scale(CParser & parser)
|
||||
std::ostringstream estream;
|
||||
estream << "Found " << str;
|
||||
estream << ", but expect axis type \'x\', \'y\', \'y2\'or \'sy\'.";
|
||||
estream << std::endl;
|
||||
error_msg(estream.str().c_str(), CParser::OT_CONTINUE);
|
||||
estream << "\n";
|
||||
error_msg(estream.str().c_str(), PHRQ_io::OT_CONTINUE);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -189,7 +189,7 @@ ChartObject::Set_axis_scale(CParser & parser)
|
||||
std::ostringstream estream;
|
||||
estream << "Found " << s;
|
||||
estream << ", but expect number or 'a(uto)'.";
|
||||
estream << std::endl;
|
||||
estream << "\n";
|
||||
error_msg(estream.str().c_str(), CONTINUE);
|
||||
return false;
|
||||
}
|
||||
@ -205,7 +205,7 @@ ChartObject::Set_axis_scale(CParser & parser)
|
||||
{
|
||||
std::ostringstream estream;
|
||||
estream << "MIN and MAX must be > 0 for log " << type << "-scale.";
|
||||
estream << std::endl;
|
||||
estream << "\n";
|
||||
error_msg(estream.str().c_str(), CONTINUE);
|
||||
return false;
|
||||
}
|
||||
@ -217,8 +217,8 @@ ChartObject::Set_axis_scale(CParser & parser)
|
||||
if (scale_ptr[0] > scale_ptr[1])
|
||||
{
|
||||
std::ostringstream estream;
|
||||
estream << "Maximum must be larger than minimum of axis_scale " << type << "-scale." << std::endl;
|
||||
estream << "Switching values for MIN and MAX. " << std::endl;
|
||||
estream << "Maximum must be larger than minimum of axis_scale " << type << "-scale." << "\n";
|
||||
estream << "Switching values for MIN and MAX. " << "\n";
|
||||
warning_msg(estream.str().c_str());
|
||||
double t;
|
||||
t = scale_ptr[0];
|
||||
@ -468,9 +468,10 @@ ChartObject::OpenCSVFile(std::string file_name)
|
||||
return false;
|
||||
}
|
||||
|
||||
std::ostringstream oss_out;
|
||||
std::ostringstream oss_err;
|
||||
CParser parser(f_csv, oss_out, oss_err, this->Get_io());
|
||||
//std::ostringstream oss_out;
|
||||
//std::ostringstream oss_err;
|
||||
//CParser parser(f_csv, oss_out, oss_err, this->Get_io());
|
||||
CParser parser(f_csv, this->Get_io());
|
||||
parser.set_echo_file(CParser::EO_NONE);
|
||||
|
||||
/* Get lines */
|
||||
@ -481,7 +482,7 @@ ChartObject::OpenCSVFile(std::string file_name)
|
||||
std::vector<CurveObject *> csv_curves;
|
||||
|
||||
// Read file line by line into temporary curves
|
||||
while (parser.check_line("cvs file", false, true, true, false) != CParser::LT_EOF)
|
||||
while (parser.check_line("cvs file", false, true, true, false) != PHRQ_io::LT_EOF)
|
||||
{
|
||||
// Headings line
|
||||
if (linenr == 0)
|
||||
@ -743,7 +744,7 @@ ChartObject::ExtractCurveInfo(std::string & cmd_line)
|
||||
|
||||
// Add to list of new plotxy curves
|
||||
this->new_plotxy_curves.push_back(new_curve);
|
||||
//std::cerr << revised_line << std::endl;
|
||||
//std::cerr << revised_line << "\n";
|
||||
cmd_line = revised_line;
|
||||
}
|
||||
void
|
||||
@ -755,7 +756,7 @@ ChartObject::Set_rate_struct(void)
|
||||
std::ostringstream oss;
|
||||
for (; it != rate_command_list.end(); it++)
|
||||
{
|
||||
oss << *it << std::endl;
|
||||
oss << *it << "\n";
|
||||
}
|
||||
this->Rate_free();
|
||||
this->user_graph->commands = (char *) P_INSTANCE_POINTER PHRQ_malloc((oss.str().size()) + 100 * sizeof(char));
|
||||
@ -930,7 +931,7 @@ ChartObject::SaveCurvesToFile(std::string &file_name)
|
||||
if ((*it)->Get_x().size() > max_points)
|
||||
max_points = (*it)->Get_x().size();
|
||||
}
|
||||
f_out << std::endl;
|
||||
f_out << "\n";
|
||||
|
||||
// write data
|
||||
size_t i2 = 0;
|
||||
@ -955,7 +956,7 @@ ChartObject::SaveCurvesToFile(std::string &file_name)
|
||||
f_out << "\t";
|
||||
}
|
||||
}
|
||||
f_out << std::endl;
|
||||
f_out << "\n";
|
||||
i2++;
|
||||
}
|
||||
f_out.close();
|
||||
@ -1101,10 +1102,10 @@ ChartObject::dump(std::ostream & oss, unsigned int indent)
|
||||
indent0.append(Utilities::INDENT);
|
||||
for (i = 0; i < indent + 1; ++i)
|
||||
indent1.append(Utilities::INDENT);
|
||||
oss << indent0 << "USER_GRAPH " << this->n_user << " " << this->description << std::endl;
|
||||
oss << indent0 << "USER_GRAPH " << this->n_user << " " << this->description << "\n";
|
||||
|
||||
// chart title
|
||||
oss << indent1 << "-chart_title \"" << this->chart_title << "\"" << std::endl;
|
||||
oss << indent1 << "-chart_title \"" << this->chart_title << "\"" << "\n";
|
||||
|
||||
// axis titles
|
||||
if (this->axis_titles.size() > 0)
|
||||
@ -1115,7 +1116,7 @@ ChartObject::dump(std::ostream & oss, unsigned int indent)
|
||||
{
|
||||
oss << "\"" << axis_titles[i] << "\" ";
|
||||
}
|
||||
oss << std::endl;
|
||||
oss << "\n";
|
||||
}
|
||||
|
||||
// axis_scale_x
|
||||
@ -1137,7 +1138,7 @@ ChartObject::dump(std::ostream & oss, unsigned int indent)
|
||||
{
|
||||
oss << " log";
|
||||
}
|
||||
oss << std::endl;
|
||||
oss << "\n";
|
||||
}
|
||||
// axis_scale_y
|
||||
scale_ptr = this->axis_scale_y;
|
||||
@ -1158,7 +1159,7 @@ ChartObject::dump(std::ostream & oss, unsigned int indent)
|
||||
{
|
||||
oss << " log";
|
||||
}
|
||||
oss << std::endl;
|
||||
oss << "\n";
|
||||
}
|
||||
// axis_scale_sy
|
||||
scale_ptr = this->axis_scale_y2;
|
||||
@ -1179,39 +1180,39 @@ ChartObject::dump(std::ostream & oss, unsigned int indent)
|
||||
{
|
||||
oss << " log";
|
||||
}
|
||||
oss << std::endl;
|
||||
oss << "\n";
|
||||
}
|
||||
// chart type
|
||||
if (this->chart_type == 0)
|
||||
{
|
||||
oss << indent1 << "-plot_concentration_vs x" << std::endl;
|
||||
oss << indent1 << "-plot_concentration_vs x" << "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
oss << indent1 << "-plot_concentration_vs t" << std::endl;
|
||||
oss << indent1 << "-plot_concentration_vs t" << "\n";
|
||||
}
|
||||
// graph_initial_solutions
|
||||
if (this->graph_initial_solutions)
|
||||
{
|
||||
oss << indent1 << "-initial_solutions true" << std::endl;
|
||||
oss << indent1 << "-initial_solutions true" << "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
oss << indent1 << "-initial_solutions false" << std::endl;
|
||||
oss << indent1 << "-initial_solutions false" << "\n";
|
||||
}
|
||||
// connect_simulations
|
||||
if (this->connect_simulations)
|
||||
{
|
||||
oss << indent1 << "-connect_simulations true" << std::endl;
|
||||
oss << indent1 << "-connect_simulations true" << "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
oss << indent1 << "-connect_simulations false" << std::endl;
|
||||
oss << indent1 << "-connect_simulations false" << "\n";
|
||||
}
|
||||
// csv files
|
||||
for (i = 0; i < this->csv_file_names.size(); i++)
|
||||
{
|
||||
oss << indent1 << "-plot_csv_file " << this->csv_file_names[i] << std::endl;
|
||||
oss << indent1 << "-plot_csv_file " << this->csv_file_names[i] << "\n";
|
||||
}
|
||||
|
||||
// headings
|
||||
@ -1222,17 +1223,17 @@ ChartObject::dump(std::ostream & oss, unsigned int indent)
|
||||
{
|
||||
oss << this->headings_original[i] << " ";
|
||||
}
|
||||
oss << std::endl;
|
||||
oss << "\n";
|
||||
}
|
||||
|
||||
// commands
|
||||
oss << indent1 << "-start" << std::endl;
|
||||
oss << indent1 << "-start" << "\n";
|
||||
std::list<std::string>::iterator it = rate_command_list_original.begin();
|
||||
for (; it != rate_command_list_original.end(); it++)
|
||||
{
|
||||
oss << *it << std::endl;
|
||||
oss << *it << "\n";
|
||||
}
|
||||
oss << indent1 << "-end" << std::endl;
|
||||
oss << indent1 << "-end" << "\n";
|
||||
|
||||
/*
|
||||
struct rate *user_graph;
|
||||
|
||||
78
ExchComp.cxx
78
ExchComp.cxx
@ -140,33 +140,33 @@ cxxExchComp::dump_xml(std::ostream & s_oss, unsigned int indent) const
|
||||
|
||||
// Exch_Comp element and attributes
|
||||
|
||||
s_oss << indent0 << "formula=\"" << this->formula << "\"" << std::endl;
|
||||
s_oss << indent0 << "formula=\"" << this->formula << "\"" << "\n";
|
||||
s_oss << indent0 << "formula_z=\"" << this->
|
||||
formula_z << "\"" << std::endl;
|
||||
s_oss << indent0 << "moles=\"" << this->moles << "\"" << std::endl;
|
||||
s_oss << indent0 << "la=\"" << this->la << "\"" << std::endl;
|
||||
formula_z << "\"" << "\n";
|
||||
s_oss << indent0 << "moles=\"" << this->moles << "\"" << "\n";
|
||||
s_oss << indent0 << "la=\"" << this->la << "\"" << "\n";
|
||||
s_oss << indent0 << "charge_balance=\"" << this->
|
||||
charge_balance << "\"" << std::endl;
|
||||
charge_balance << "\"" << "\n";
|
||||
if (this->phase_name.size() != 0)
|
||||
{
|
||||
s_oss << indent0 << "phase_name=\"" << this->phase_name << "\"" << std::endl;
|
||||
s_oss << indent0 << "phase_name=\"" << this->phase_name << "\"" << "\n";
|
||||
}
|
||||
if (this->rate_name.size() != 0)
|
||||
{
|
||||
s_oss << indent0 << "rate_name=\"" << this->
|
||||
rate_name << "\"" << std::endl;
|
||||
rate_name << "\"" << "\n";
|
||||
}
|
||||
s_oss << indent0 << "phase_proportion=\"" << this->
|
||||
phase_proportion << "\"" << std::endl;
|
||||
phase_proportion << "\"" << "\n";
|
||||
|
||||
// totals
|
||||
s_oss << indent0;
|
||||
s_oss << "<totals " << std::endl;
|
||||
s_oss << "<totals " << "\n";
|
||||
this->totals.dump_xml(s_oss, indent + 1);
|
||||
|
||||
// formula_totals
|
||||
s_oss << indent0;
|
||||
s_oss << "<formula_totals " << std::endl;
|
||||
s_oss << "<formula_totals " << "\n";
|
||||
this->formula_totals.dump_xml(s_oss, indent + 1);
|
||||
}
|
||||
|
||||
@ -186,35 +186,35 @@ cxxExchComp::dump_raw(std::ostream & s_oss, unsigned int indent) const
|
||||
|
||||
// Exch_Comp element and attributes
|
||||
|
||||
s_oss << indent0 << "-formula " << this->formula << std::endl;
|
||||
s_oss << indent0 << "-formula " << this->formula << "\n";
|
||||
|
||||
//s_oss << indent1 << "# critical values" << std::endl;
|
||||
//s_oss << indent1 << "# critical values" << "\n";
|
||||
|
||||
// totals
|
||||
s_oss << indent1;
|
||||
s_oss << "-totals" << std::endl;
|
||||
s_oss << "-totals" << "\n";
|
||||
this->totals.dump_raw(s_oss, indent + 2);
|
||||
|
||||
s_oss << indent1 << "-charge_balance " << this->charge_balance << std::endl;
|
||||
s_oss << indent1 << "-charge_balance " << this->charge_balance << "\n";
|
||||
|
||||
//s_oss << indent1 << "# Noncritical values" << std::endl;
|
||||
s_oss << indent1 << "-moles " << this->moles << std::endl;
|
||||
s_oss << indent1 << "-la " << this->la << std::endl;
|
||||
//s_oss << indent1 << "# Noncritical values" << "\n";
|
||||
s_oss << indent1 << "-moles " << this->moles << "\n";
|
||||
s_oss << indent1 << "-la " << this->la << "\n";
|
||||
|
||||
if (this->phase_name.size() != 0)
|
||||
{
|
||||
s_oss << indent1 << "-phase_name " << this->phase_name << std::endl;
|
||||
s_oss << indent1 << "-phase_name " << this->phase_name << "\n";
|
||||
}
|
||||
if (this->rate_name.size() != 0)
|
||||
{
|
||||
s_oss << indent1 << "-rate_name " << this->rate_name << std::endl;
|
||||
s_oss << indent1 << "-rate_name " << this->rate_name << "\n";
|
||||
}
|
||||
s_oss << indent1 << "-phase_proportion " << this->phase_proportion << std::endl;
|
||||
s_oss << indent1 << "-formula_z " << this->formula_z << std::endl;
|
||||
s_oss << indent1 << "-phase_proportion " << this->phase_proportion << "\n";
|
||||
s_oss << indent1 << "-formula_z " << this->formula_z << "\n";
|
||||
|
||||
// formula_totals
|
||||
s_oss << indent1;
|
||||
s_oss << "-formula_totals" << std::endl;
|
||||
s_oss << "-formula_totals" << "\n";
|
||||
this->formula_totals.dump_raw(s_oss, indent + 2);
|
||||
|
||||
}
|
||||
@ -270,8 +270,8 @@ cxxExchComp::read_raw(CParser & parser, bool check)
|
||||
case CParser::OPT_ERROR:
|
||||
opt = CParser::OPT_KEYWORD;
|
||||
// Allow return to Exchange for more processing
|
||||
//parser.error_msg("Unknown input in EXCH_COMP read.", CParser::OT_CONTINUE);
|
||||
//parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE);
|
||||
//parser.error_msg("Unknown input in EXCH_COMP read.", PHRQ_io::OT_CONTINUE);
|
||||
//parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
|
||||
break;
|
||||
|
||||
case 0: // formula
|
||||
@ -280,7 +280,7 @@ cxxExchComp::read_raw(CParser & parser, bool check)
|
||||
this->formula.clear();
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected string value for formula.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -295,7 +295,7 @@ cxxExchComp::read_raw(CParser & parser, bool check)
|
||||
this->moles = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for moles.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
moles_defined = true;
|
||||
break;
|
||||
@ -306,7 +306,7 @@ cxxExchComp::read_raw(CParser & parser, bool check)
|
||||
this->la = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for la.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
la_defined = true;
|
||||
break;
|
||||
@ -317,7 +317,7 @@ cxxExchComp::read_raw(CParser & parser, bool check)
|
||||
this->charge_balance = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for charge_balance.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
charge_balance_defined = true;
|
||||
break;
|
||||
@ -328,7 +328,7 @@ cxxExchComp::read_raw(CParser & parser, bool check)
|
||||
this->phase_name.clear();
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected string value for phase_name.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -342,7 +342,7 @@ cxxExchComp::read_raw(CParser & parser, bool check)
|
||||
this->rate_name.clear();
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected string value for rate_name.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -356,7 +356,7 @@ cxxExchComp::read_raw(CParser & parser, bool check)
|
||||
this->formula_z = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for formula_z.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
formula_z_defined = true;
|
||||
break;
|
||||
@ -368,7 +368,7 @@ cxxExchComp::read_raw(CParser & parser, bool check)
|
||||
parser.incr_input_error();
|
||||
parser.
|
||||
error_msg("Expected numeric value for phase_proportion.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -380,7 +380,7 @@ cxxExchComp::read_raw(CParser & parser, bool check)
|
||||
parser.
|
||||
error_msg
|
||||
("Expected element name and molality for ExchComp totals.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
opt_save = 8;
|
||||
break;
|
||||
@ -393,7 +393,7 @@ cxxExchComp::read_raw(CParser & parser, bool check)
|
||||
parser.
|
||||
error_msg
|
||||
("Expected element name and molality for ExchComp formula totals.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
opt_save = 9;
|
||||
break;
|
||||
@ -408,31 +408,31 @@ cxxExchComp::read_raw(CParser & parser, bool check)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Formula not defined for ExchComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (moles_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Moles not defined for ExchComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (la_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("La not defined for ExchComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (charge_balance_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Charge_balance not defined for ExchComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (formula_z_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Formula_z not defined for ExchComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,8 +121,8 @@ class cxxExchComp: public PHRQ_base
|
||||
this->formula_totals = nd;
|
||||
}
|
||||
|
||||
cxxNameDouble & Get_totals() {return (this->totals);};
|
||||
cxxNameDouble & Get_formula_totals(void) {return this->formula_totals;};
|
||||
cxxNameDouble & Get_totals() {return (this->totals);}
|
||||
cxxNameDouble & Get_formula_totals(void) {return this->formula_totals;}
|
||||
|
||||
|
||||
void add(const cxxExchComp & comp, double extensive);
|
||||
|
||||
32
Exchange.cxx
32
Exchange.cxx
@ -127,15 +127,15 @@ cxxExchange::dump_xml(std::ostream & s_oss, unsigned int indent) const
|
||||
|
||||
// Exchange element and attributes
|
||||
s_oss << indent0;
|
||||
s_oss << "<exchange " << std::endl;
|
||||
s_oss << "<exchange " << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "pitzer_exchange_gammas=\"" << this->
|
||||
pitzer_exchange_gammas << "\"" << std::endl;
|
||||
pitzer_exchange_gammas << "\"" << "\n";
|
||||
|
||||
// components
|
||||
s_oss << indent1;
|
||||
s_oss << "<component " << std::endl;
|
||||
s_oss << "<component " << "\n";
|
||||
for (std::map < std::string, cxxExchComp >::const_iterator it = exchComps.begin();
|
||||
it != exchComps.end(); ++it)
|
||||
{
|
||||
@ -162,26 +162,26 @@ cxxExchange::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out) con
|
||||
// Exchange element and attributes
|
||||
s_oss << indent0;
|
||||
int n_user_local = (n_out != NULL) ? *n_out : this->n_user;
|
||||
s_oss << "EXCHANGE_RAW " << n_user_local << " " << this->description << std::endl;
|
||||
s_oss << "EXCHANGE_RAW " << n_user_local << " " << this->description << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "-new_def " << this->new_def << std::endl;
|
||||
s_oss << "-new_def " << this->new_def << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "-exchange_gammas " << this->pitzer_exchange_gammas << std::endl;
|
||||
s_oss << "-exchange_gammas " << this->pitzer_exchange_gammas << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "-solution_equilibria " << this->solution_equilibria << std::endl;
|
||||
s_oss << "-solution_equilibria " << this->solution_equilibria << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "-n_solution " << this->n_solution << std::endl;
|
||||
s_oss << "-n_solution " << this->n_solution << "\n";
|
||||
|
||||
// exchComps structures
|
||||
for (std::map < std::string, cxxExchComp >::const_iterator it = exchComps.begin();
|
||||
it != exchComps.end(); ++it)
|
||||
{
|
||||
s_oss << indent1;
|
||||
s_oss << "-component" << std::endl;
|
||||
s_oss << "-component" << "\n";
|
||||
(*it).second.dump_raw(s_oss, indent + 2);
|
||||
}
|
||||
|
||||
@ -236,8 +236,8 @@ cxxExchange::read_raw(CParser & parser, bool check)
|
||||
case CParser::OPT_ERROR:
|
||||
opt = CParser::OPT_EOF;
|
||||
parser.error_msg("Unknown input in EXCH_COMP_RAW keyword.",
|
||||
CParser::OT_CONTINUE);
|
||||
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
|
||||
useLastLine = false;
|
||||
break;
|
||||
|
||||
@ -250,7 +250,7 @@ cxxExchange::read_raw(CParser & parser, bool check)
|
||||
parser.
|
||||
error_msg
|
||||
("Expected boolean value for pitzer_exchange_gammas.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
pitzer_exchange_gammas_defined = true;
|
||||
useLastLine = false;
|
||||
@ -290,7 +290,7 @@ cxxExchange::read_raw(CParser & parser, bool check)
|
||||
parser.
|
||||
error_msg
|
||||
("Expected boolean value for new_def.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
useLastLine = false;
|
||||
break;
|
||||
@ -302,7 +302,7 @@ cxxExchange::read_raw(CParser & parser, bool check)
|
||||
parser.
|
||||
error_msg
|
||||
("Expected boolean value for solution_equilibria.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
useLastLine = false;
|
||||
break;
|
||||
@ -314,7 +314,7 @@ cxxExchange::read_raw(CParser & parser, bool check)
|
||||
parser.
|
||||
error_msg
|
||||
("Expected integer value for n_solution.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
useLastLine = false;
|
||||
break;
|
||||
@ -331,7 +331,7 @@ cxxExchange::read_raw(CParser & parser, bool check)
|
||||
parser.
|
||||
error_msg
|
||||
("Pitzer_exchange_gammsa not defined for EXCHANGE_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
13
Exchange.h
13
Exchange.h
@ -32,15 +32,16 @@ public:
|
||||
bool Get_pitzer_exchange_gammas() const;
|
||||
void Set_pitzer_exchange_gammas(bool b);
|
||||
|
||||
bool Get_new_def(void) const {return this->new_def;};
|
||||
void Set_new_def(bool tf) {this->new_def = tf;};
|
||||
bool Get_solution_equilibria(void) const {return this->solution_equilibria;};
|
||||
void Set_solution_equilibria(bool tf) {this->solution_equilibria = tf;};
|
||||
int Get_n_solution(void) const {return this->n_solution;};
|
||||
void Set_n_solution(int i) {this->n_solution = i;};
|
||||
bool Get_new_def(void) const {return this->new_def;}
|
||||
void Set_new_def(bool tf) {this->new_def = tf;}
|
||||
bool Get_solution_equilibria(void) const {return this->solution_equilibria;}
|
||||
void Set_solution_equilibria(bool tf) {this->solution_equilibria = tf;}
|
||||
int Get_n_solution(void) const {return this->n_solution;}
|
||||
void Set_n_solution(int i) {this->n_solution = i;}
|
||||
cxxExchComp *ExchComp_find(std::string s);
|
||||
|
||||
std::map < std::string, cxxExchComp > &Get_exchComps(void);
|
||||
|
||||
void totalize();
|
||||
|
||||
const cxxNameDouble & Get_totals() const;
|
||||
|
||||
283
GasPhase.cxx
283
GasPhase.cxx
@ -25,47 +25,98 @@ cxxGasPhase::cxxGasPhase(PHRQ_io * io)
|
||||
//
|
||||
: cxxNumKeyword(io)
|
||||
{
|
||||
new_def = true;
|
||||
solution_equilibria = false;
|
||||
n_solution = -999;
|
||||
type = cxxGasPhase::GP_PRESSURE;
|
||||
total_p = 1.0;
|
||||
volume = 1.0;
|
||||
v_m = 0;
|
||||
pr_in = false;
|
||||
temperature = 298.15;
|
||||
}
|
||||
|
||||
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;
|
||||
gasPhaseComps.type = cxxNameDouble::ND_NAME_COEF;
|
||||
}
|
||||
|
||||
cxxGasPhase::cxxGasPhase(struct gas_phase *gas_phase_ptr, PHRQ_io * io)
|
||||
bool first = true;
|
||||
//
|
||||
// constructor for cxxGasPhase from struct gas_phase
|
||||
// Mix
|
||||
//
|
||||
:
|
||||
cxxNumKeyword(io)
|
||||
{
|
||||
int i;
|
||||
// accumulate in map
|
||||
std::map<std::string, cxxGasComp> comp_map;
|
||||
std::map<std::string, cxxGasComp>::iterator comp_it;
|
||||
|
||||
this->Set_description(gas_phase_ptr->description);
|
||||
n_user = gas_phase_ptr->n_user;
|
||||
n_user_end = gas_phase_ptr->n_user_end;
|
||||
if (gas_phase_ptr->type == PRESSURE)
|
||||
const std::map < int, double > & mixcomps = mx.Get_mixComps();
|
||||
std::map < int, double >::const_iterator it;
|
||||
for (it = mixcomps.begin(); it != mixcomps.end(); it++)
|
||||
{
|
||||
type = cxxGasPhase::GP_PRESSURE;
|
||||
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
|
||||
{
|
||||
type = cxxGasPhase::GP_VOLUME;
|
||||
}
|
||||
total_p = gas_phase_ptr->total_p;
|
||||
volume = gas_phase_ptr->volume;
|
||||
v_m = gas_phase_ptr->v_m;
|
||||
pr_in = gas_phase_ptr->pr_in;
|
||||
|
||||
// gas_phase components
|
||||
for (i = 0; i < gas_phase_ptr->count_comps; i++)
|
||||
if (this->type != entity_ptr->type)
|
||||
{
|
||||
if (gas_phase_ptr->comps[i].name == NULL)
|
||||
continue;
|
||||
gasPhaseComps[gas_phase_ptr->comps[i].name] =
|
||||
gas_phase_ptr->comps[i].moles;
|
||||
std::ostringstream oss;
|
||||
oss << "Can not 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);
|
||||
}
|
||||
}
|
||||
#ifdef SKIP
|
||||
cxxGasPhase::cxxGasPhase(const std::map < int, cxxGasPhase > &entities,
|
||||
cxxMix & mix, int l_n_user, PHRQ_io * io):
|
||||
cxxNumKeyword(io)
|
||||
@ -121,7 +172,7 @@ cxxNumKeyword(io)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
cxxGasPhase::~cxxGasPhase()
|
||||
{
|
||||
}
|
||||
@ -143,15 +194,15 @@ cxxGasPhase::dump_xml(std::ostream & s_oss, unsigned int indent) const const
|
||||
|
||||
// GasPhase element and attributes
|
||||
s_oss << indent0;
|
||||
s_oss << "<gas_phase " << std::endl;
|
||||
s_oss << "<gas_phase " << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "pitzer_gas_phase_gammas=\"" << this->
|
||||
pitzer_gas_phase_gammas << "\"" << std::endl;
|
||||
pitzer_gas_phase_gammas << "\"" << "\n";
|
||||
|
||||
// components
|
||||
s_oss << indent1;
|
||||
s_oss << "<component " << std::endl;
|
||||
s_oss << "<component " << "\n";
|
||||
for (std::list < cxxGasPhaseComp >::const_iterator it =
|
||||
gas_phaseComps.begin(); it != gas_phaseComps.end(); ++it)
|
||||
{
|
||||
@ -179,27 +230,36 @@ cxxGasPhase::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out) con
|
||||
// GasPhase element and attributes
|
||||
s_oss << indent0;
|
||||
int n_user_local = (n_out != NULL) ? *n_out : this->n_user;
|
||||
s_oss << "GAS_PHASE_RAW " << n_user_local << " " << this->description << std::endl;
|
||||
s_oss << "GAS_PHASE_RAW " << n_user_local << " " << this->description << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "-type " << this->type << std::endl;
|
||||
|
||||
s_oss << "-new_def " << this->new_def << "\n";
|
||||
s_oss << indent1;
|
||||
s_oss << "-total_p " << this->total_p << std::endl;
|
||||
|
||||
s_oss << "-solution_equilibria " << this->solution_equilibria << "\n";
|
||||
s_oss << indent1;
|
||||
s_oss << "-volume " << this->volume << std::endl;
|
||||
|
||||
s_oss << "-n_solution " << this->n_solution << "\n";
|
||||
s_oss << indent1;
|
||||
s_oss << "-v_m " << this->v_m << std::endl;
|
||||
|
||||
s_oss << "-type " << this->type << "\n";
|
||||
s_oss << indent1;
|
||||
s_oss << "-pr_in " << (this->pr_in ? 1 : 0) << std::endl;
|
||||
s_oss << "-total_p " << this->total_p << "\n";
|
||||
s_oss << indent1;
|
||||
s_oss << "-total_moles " << this->total_moles << "\n";
|
||||
s_oss << indent1;
|
||||
s_oss << "-volume " << this->volume << "\n";
|
||||
s_oss << indent1;
|
||||
s_oss << "-v_m " << this->v_m << "\n";
|
||||
s_oss << indent1;
|
||||
s_oss << "-pr_in " << (this->pr_in ? 1 : 0) << "\n";
|
||||
s_oss << indent1;
|
||||
s_oss << "-temperature " << this->temperature << "\n";
|
||||
|
||||
// gasPhaseComps
|
||||
for (size_t i = 0 ; i < this->gas_comps.size(); i++)
|
||||
{
|
||||
s_oss << indent1;
|
||||
s_oss << "-component" << std::endl;
|
||||
this->gasPhaseComps.dump_raw(s_oss, indent + 2);
|
||||
s_oss << "-component" << "\n";
|
||||
this->gas_comps[i].dump_raw(s_oss, indent + 2);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -218,6 +278,11 @@ cxxGasPhase::read_raw(CParser & parser, bool check)
|
||||
vopts.push_back("component"); //4
|
||||
vopts.push_back("pressure"); //5
|
||||
vopts.push_back("pr_in"); //6
|
||||
vopts.push_back("new_def"); //7
|
||||
vopts.push_back("solution_equilibria"); //8
|
||||
vopts.push_back("n_solution"); //9
|
||||
vopts.push_back("total_moles"); //10
|
||||
vopts.push_back("temperature"); //11
|
||||
}
|
||||
|
||||
std::istream::pos_type ptr;
|
||||
@ -261,8 +326,8 @@ cxxGasPhase::read_raw(CParser & parser, bool check)
|
||||
case CParser::OPT_ERROR:
|
||||
opt = CParser::OPT_EOF;
|
||||
parser.error_msg("Unknown input in GAS_PHASE_COMP_RAW keyword.",
|
||||
CParser::OT_CONTINUE);
|
||||
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
|
||||
useLastLine = false;
|
||||
break;
|
||||
|
||||
@ -273,7 +338,7 @@ cxxGasPhase::read_raw(CParser & parser, bool check)
|
||||
this->type = cxxGasPhase::GP_PRESSURE;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected enum for type.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -290,7 +355,7 @@ cxxGasPhase::read_raw(CParser & parser, bool check)
|
||||
this->total_p = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for total_p.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
total_p_defined = true;
|
||||
useLastLine = false;
|
||||
@ -302,7 +367,7 @@ cxxGasPhase::read_raw(CParser & parser, bool check)
|
||||
this->volume = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for volume.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
volume_defined = true;
|
||||
useLastLine = false;
|
||||
@ -314,30 +379,37 @@ cxxGasPhase::read_raw(CParser & parser, bool check)
|
||||
this->v_m = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for v_m.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
v_m_defined = true;
|
||||
useLastLine = false;
|
||||
break;
|
||||
|
||||
case 4: // component
|
||||
if (this->gasPhaseComps.read_raw(parser, next_char) !=
|
||||
CParser::PARSER_OK)
|
||||
{
|
||||
cxxGasComp gc;
|
||||
//bool tf = gc.read_raw(parser, next_char);
|
||||
//if (!tf
|
||||
if (!gc.read_raw(parser, next_char))
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.
|
||||
error_msg
|
||||
("Expected gas component name and moles for gasPhaseComps.",
|
||||
CParser::OT_CONTINUE);
|
||||
parser.error_msg
|
||||
("Expected gas component information.",
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->gas_comps.push_back(gc);
|
||||
}
|
||||
//opt_save = 4;
|
||||
useLastLine = true;
|
||||
}
|
||||
opt_save = 4;
|
||||
useLastLine = false;
|
||||
break;
|
||||
case 6: // pr_in
|
||||
if (!(parser.get_iss() >> i))
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected 0/1 for pr_in.", CParser::OT_CONTINUE);
|
||||
parser.error_msg("Expected 0/1 for pr_in.", PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -346,6 +418,58 @@ cxxGasPhase::read_raw(CParser & parser, bool check)
|
||||
pr_in_defined = true;
|
||||
useLastLine = false;
|
||||
break;
|
||||
case 7: // new_def
|
||||
if (!(parser.get_iss() >> i))
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected 0/1 for new_def.", PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->new_def = (i == 0) ? false : true;
|
||||
}
|
||||
useLastLine = false;
|
||||
break;
|
||||
case 8: // solution_equilibria
|
||||
if (!(parser.get_iss() >> i))
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected 0/1 for solution_equilibria.", PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->solution_equilibria = (i == 0) ? false : true;
|
||||
}
|
||||
useLastLine = false;
|
||||
break;
|
||||
case 9: // n_solution
|
||||
if (!(parser.get_iss() >> this->n_solution))
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected integer for n_solution.", PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
useLastLine = false;
|
||||
break;
|
||||
case 10: // total_moles
|
||||
if (!(parser.get_iss() >> this->total_moles))
|
||||
{
|
||||
this->total_moles = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for total_moles.",
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
useLastLine = false;
|
||||
break;
|
||||
case 11: // temperature
|
||||
if (!(parser.get_iss() >> this->temperature))
|
||||
{
|
||||
this->temperature = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for temperature.",
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
useLastLine = false;
|
||||
break;
|
||||
}
|
||||
if (opt == CParser::OPT_EOF || opt == CParser::OPT_KEYWORD)
|
||||
break;
|
||||
@ -357,31 +481,31 @@ cxxGasPhase::read_raw(CParser & parser, bool check)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Type not defined for GAS_PHASE_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (total_p_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Total_p not defined for GAS_PHASE_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (volume_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Volume not defined for GAS_PHASE_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (v_m_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("V_m not defined for GAS_PHASE_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (pr_in_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Pr_in not defined for GAS_PHASE_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -436,6 +560,29 @@ cxxGasPhase::mpi_unpack(int *ints, int *ii, double *doubles, int *dd)
|
||||
#endif
|
||||
void
|
||||
cxxGasPhase::totalize(PHREEQC_PTR_ARG)
|
||||
{
|
||||
this->totals.clear();
|
||||
// component structures
|
||||
for (size_t i = 0; i < this->gas_comps.size(); i++)
|
||||
{
|
||||
struct phase *phase_ptr;
|
||||
int l;
|
||||
phase_ptr = P_INSTANCE_POINTER phase_bsearch(this->gas_comps[i].Get_phase_name().c_str(), &l, FALSE);
|
||||
if (phase_ptr != NULL)
|
||||
{
|
||||
cxxNameDouble phase_formula(phase_ptr->next_elt);
|
||||
this->totals.add_extensive(phase_formula, this->gas_comps[i].Get_moles());
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
#ifdef SKIP
|
||||
void
|
||||
cxxGasPhase::totalize(PHREEQC_PTR_ARG)
|
||||
{
|
||||
this->totals.clear();
|
||||
// component structures
|
||||
@ -457,3 +604,13 @@ cxxGasPhase::totalize(PHREEQC_PTR_ARG)
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
LDBLE cxxGasPhase::Calc_total_moles(void)
|
||||
{
|
||||
LDBLE tot = 0.0;
|
||||
for (size_t i = 0; i < this->gas_comps.size(); i++)
|
||||
{
|
||||
tot += gas_comps[i].Get_moles();
|
||||
}
|
||||
return tot;
|
||||
}
|
||||
|
||||
42
GasPhase.h
42
GasPhase.h
@ -6,10 +6,11 @@
|
||||
#include <string> // std::string
|
||||
#include <list> // std::list
|
||||
#include <vector> // std::vector
|
||||
|
||||
#include "phrqtype.h"
|
||||
#include "NumKeyword.h"
|
||||
#include "NameDouble.h"
|
||||
#include "Phreeqc_class.h"
|
||||
#include "GasComp.h"
|
||||
class cxxMix;
|
||||
|
||||
class cxxGasPhase:public cxxNumKeyword
|
||||
@ -17,8 +18,7 @@ class cxxGasPhase:public cxxNumKeyword
|
||||
|
||||
public:
|
||||
cxxGasPhase(PHRQ_io * io=NULL);
|
||||
cxxGasPhase(struct gas_phase *, PHRQ_io * io=NULL);
|
||||
cxxGasPhase(const std::map < int, cxxGasPhase > &entity_map,
|
||||
cxxGasPhase(std::map < int, cxxGasPhase > &entity_map,
|
||||
cxxMix & mx, int n_user, PHRQ_io * io=NULL);
|
||||
~cxxGasPhase();
|
||||
|
||||
@ -45,26 +45,50 @@ class cxxGasPhase:public cxxNumKeyword
|
||||
{
|
||||
return this->totals;
|
||||
};
|
||||
const cxxNameDouble & Get_gasPhaseComps(void) const {return gasPhaseComps;};
|
||||
std::vector<cxxGasComp> & Get_gas_comps(void) {return gas_comps;};
|
||||
void Set_gas_comps(const std::vector<cxxGasComp> v) {gas_comps = v;};
|
||||
|
||||
GP_TYPE Get_type(void) const {return type;};
|
||||
void Set_type(GP_TYPE t) {type = t;};
|
||||
double Get_total_p(void) const {return total_p;};
|
||||
double Get_volume(void) const {return volume;};
|
||||
void Set_volume(LDBLE v) {volume = v;};
|
||||
double Get_v_m(void) const {return v_m;};
|
||||
void Set_v_m(LDBLE v) {v_m = v;};
|
||||
bool Get_pr_in(void) const {return pr_in;};
|
||||
void Set_pr_in(bool tf) {pr_in = tf;};
|
||||
cxxNameDouble & Get_totals(void) {return totals;};
|
||||
|
||||
bool Get_new_def(void) const {return this->new_def;};
|
||||
void Set_new_def(bool tf) {this->new_def = tf;};
|
||||
bool Get_solution_equilibria(void) const {return this->solution_equilibria;};
|
||||
void Set_solution_equilibria(bool tf) {this->solution_equilibria = tf;};
|
||||
int Get_n_solution(void) const {return this->n_solution;};
|
||||
void Set_n_solution(int i) {this->n_solution = i;};
|
||||
LDBLE Get_total_moles(void) {return (LDBLE) total_moles;};
|
||||
void Set_total_moles(LDBLE t) {total_moles = t;};
|
||||
LDBLE Get_total_p(void) {return (LDBLE) total_p;};
|
||||
void Set_total_p(LDBLE t) {total_p = t;};
|
||||
LDBLE Get_temperature(void) {return (LDBLE) temperature;};
|
||||
void Set_temperature(LDBLE t) {temperature = t;};
|
||||
LDBLE Calc_total_moles(void);
|
||||
|
||||
protected:
|
||||
void add(const cxxGasPhase & addee, double extensive);
|
||||
|
||||
protected:
|
||||
cxxNameDouble gasPhaseComps;
|
||||
bool new_def;
|
||||
bool solution_equilibria;
|
||||
int n_solution;
|
||||
GP_TYPE type;
|
||||
double total_p;
|
||||
double volume;
|
||||
double v_m;
|
||||
LDBLE total_p;
|
||||
LDBLE total_moles;
|
||||
LDBLE volume;
|
||||
LDBLE v_m;
|
||||
bool pr_in;
|
||||
LDBLE temperature;
|
||||
std::vector<cxxGasComp> gas_comps;
|
||||
cxxNameDouble totals;
|
||||
|
||||
};
|
||||
|
||||
#endif // !defined(GASPHASE_H_INCLUDED)
|
||||
|
||||
@ -193,8 +193,8 @@ cxxISolution & cxxISolution::read(CParser & parser)
|
||||
case CParser::OPTION_ERROR:
|
||||
opt = CParser::OPTION_EOF;
|
||||
CParser::error_msg("Unknown input in SOLUTION keyword.",
|
||||
CParser::OT_CONTINUE);
|
||||
CParser::error_msg(parser.line().c_str(), CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
CParser::error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
|
||||
break;
|
||||
|
||||
case 0: // temp
|
||||
@ -299,7 +299,7 @@ cxxISolution & cxxISolution::read(CParser & parser)
|
||||
parser.
|
||||
error_msg
|
||||
("Expected numeric value for mass of water in solution.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -169,7 +169,7 @@ cxxISolutionComp::STATUS_TYPE cxxISolutionComp::read(CParser & parser,
|
||||
parser.
|
||||
error_msg
|
||||
("No element or master species given for concentration input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
return cxxISolutionComp::ERROR;
|
||||
}
|
||||
description = token1;
|
||||
@ -189,7 +189,7 @@ cxxISolutionComp::STATUS_TYPE cxxISolutionComp::read(CParser & parser,
|
||||
std::ostringstream err;
|
||||
err << "Concentration data error for " << token1 <<
|
||||
" in solution input.";
|
||||
parser.error_msg(err, CParser::OT_CONTINUE);
|
||||
parser.error_msg(err, PHRQ_io::OT_CONTINUE);
|
||||
return cxxISolutionComp::ERROR;
|
||||
}
|
||||
if ((j = parser.copy_token(token, ptr)) == CParser::TT_EMPTY)
|
||||
@ -232,7 +232,7 @@ cxxISolutionComp::STATUS_TYPE cxxISolutionComp::read(CParser & parser,
|
||||
if (parser.copy_token(token, ptr) != CParser::TT_DIGIT)
|
||||
{
|
||||
parser.error_msg("Expecting gram formula weight.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
return cxxISolutionComp::ERROR;
|
||||
}
|
||||
else
|
||||
@ -272,7 +272,7 @@ cxxISolutionComp::STATUS_TYPE cxxISolutionComp::read(CParser & parser,
|
||||
// Check for saturation index
|
||||
if (!(std::istringstream(token) >> this->phase_si))
|
||||
{
|
||||
parser.error_msg("Expected saturation index.", CParser::OT_CONTINUE);
|
||||
parser.error_msg("Expected saturation index.", PHRQ_io::OT_CONTINUE);
|
||||
return cxxISolutionComp::ERROR;
|
||||
}
|
||||
return cxxISolutionComp::OK;
|
||||
@ -295,6 +295,6 @@ cxxISolutionComp::dump_xml(std::ostream & s_oss, unsigned int indent) const cons
|
||||
|
||||
s_oss << " conc_moles=\"" << this->moles << "\"";
|
||||
|
||||
s_oss << "\">" << std::endl;
|
||||
s_oss << "\">" << "\n";
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -73,32 +73,32 @@ cxxKineticsComp::dump_xml(std::ostream & s_oss, unsigned int indent) const const
|
||||
|
||||
// Kinetics_Comp element and attributes
|
||||
|
||||
s_oss << indent0 << "formula=\"" << this->formula << "\"" << std::endl;
|
||||
s_oss << indent0 << "moles=\"" << this->moles << "\"" << std::endl;
|
||||
s_oss << indent0 << "la=\"" << this->la << "\"" << std::endl;
|
||||
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 << "\"" << std::endl;
|
||||
charge_balance << "\"" << "\n";
|
||||
if (this->phase_name != NULL)
|
||||
{
|
||||
s_oss << indent0 << "phase_name=\"" << this->
|
||||
phase_name << "\"" << std::endl;
|
||||
phase_name << "\"" << "\n";
|
||||
}
|
||||
if (this->rate_name != NULL)
|
||||
{
|
||||
s_oss << indent0 << "rate_name=\"" << this->
|
||||
rate_name << "\"" << std::endl;
|
||||
rate_name << "\"" << "\n";
|
||||
}
|
||||
s_oss << indent0 << "phase_proportion=\"" << this->
|
||||
phase_proportion << "\"" << std::endl;
|
||||
phase_proportion << "\"" << "\n";
|
||||
|
||||
// totals
|
||||
s_oss << indent0;
|
||||
s_oss << "<totals " << std::endl;
|
||||
s_oss << "<totals " << "\n";
|
||||
this->totals.dump_xml(s_oss, indent + 1);
|
||||
|
||||
// formula_totals
|
||||
s_oss << indent0;
|
||||
s_oss << "<formula_totals " << std::endl;
|
||||
s_oss << "<formula_totals " << "\n";
|
||||
this->formula_totals.dump_xml(s_oss, indent + 1);
|
||||
}
|
||||
#endif
|
||||
@ -119,20 +119,20 @@ cxxKineticsComp::dump_raw(std::ostream & s_oss, unsigned int indent) const
|
||||
// Kinetics_Comp element and attributes
|
||||
|
||||
s_oss << indent0 << "-rate_name " << this->
|
||||
rate_name << std::endl;
|
||||
s_oss << indent1 << "-tol " << this->tol << std::endl;
|
||||
s_oss << indent1 << "-m " << this->m << std::endl;
|
||||
s_oss << indent1 << "-m0 " << this->m0 << std::endl;
|
||||
s_oss << indent1 << "-moles " << this->moles << std::endl;
|
||||
rate_name << "\n";
|
||||
s_oss << indent1 << "-tol " << this->tol << "\n";
|
||||
s_oss << indent1 << "-m " << this->m << "\n";
|
||||
s_oss << indent1 << "-m0 " << this->m0 << "\n";
|
||||
s_oss << indent1 << "-moles " << this->moles << "\n";
|
||||
|
||||
// namecoef
|
||||
s_oss << indent1;
|
||||
s_oss << "-namecoef" << std::endl;
|
||||
s_oss << "-namecoef" << "\n";
|
||||
this->namecoef.dump_raw(s_oss, indent + 2);
|
||||
|
||||
// d_params
|
||||
s_oss << indent1;
|
||||
s_oss << "-d_params" << std::endl;
|
||||
s_oss << "-d_params" << "\n";
|
||||
{
|
||||
int i = 0;
|
||||
s_oss << indent2;
|
||||
@ -141,13 +141,13 @@ cxxKineticsComp::dump_raw(std::ostream & s_oss, unsigned int indent) const
|
||||
{
|
||||
if (i++ == 5)
|
||||
{
|
||||
s_oss << std::endl;
|
||||
s_oss << "\n";
|
||||
s_oss << indent2;
|
||||
i = 0;
|
||||
}
|
||||
s_oss << *it << " ";
|
||||
}
|
||||
s_oss << std::endl;
|
||||
s_oss << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
@ -202,8 +202,8 @@ cxxKineticsComp::read_raw(CParser & parser, bool check)
|
||||
case CParser::OPT_ERROR:
|
||||
opt = CParser::OPT_KEYWORD;
|
||||
// Allow return to Kinetics for more processing
|
||||
//parser.error_msg("Unknown input in KINETICS_COMP read.", CParser::OT_CONTINUE);
|
||||
//parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE);
|
||||
//parser.error_msg("Unknown input in KINETICS_COMP read.", PHRQ_io::OT_CONTINUE);
|
||||
//parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
|
||||
break;
|
||||
|
||||
case 0: // rate_name
|
||||
@ -212,7 +212,7 @@ cxxKineticsComp::read_raw(CParser & parser, bool check)
|
||||
this->rate_name.clear();
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected string value for rate_name.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -227,7 +227,7 @@ cxxKineticsComp::read_raw(CParser & parser, bool check)
|
||||
this->tol = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for tol.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
tol_defined = true;
|
||||
break;
|
||||
@ -238,7 +238,7 @@ cxxKineticsComp::read_raw(CParser & parser, bool check)
|
||||
this->m = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for m.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
m_defined = true;
|
||||
break;
|
||||
@ -249,7 +249,7 @@ cxxKineticsComp::read_raw(CParser & parser, bool check)
|
||||
this->m0 = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for m0.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
m0_defined = true;
|
||||
break;
|
||||
@ -261,7 +261,7 @@ cxxKineticsComp::read_raw(CParser & parser, bool check)
|
||||
this->moles = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for moles.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
moles_defined = true;
|
||||
break;
|
||||
@ -275,7 +275,7 @@ cxxKineticsComp::read_raw(CParser & parser, bool check)
|
||||
parser.
|
||||
error_msg
|
||||
("Expected element name and molality for namecoef.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
opt_save = 5;
|
||||
break;
|
||||
@ -304,31 +304,31 @@ cxxKineticsComp::read_raw(CParser & parser, bool check)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Rate_name not defined for KineticsComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (tol_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Tol not defined for KineticsComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (m_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("M not defined for KineticsComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (m0_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("M0 not defined for KineticsComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (moles_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Moles not defined for KineticsComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -193,7 +193,7 @@ cxxNameDouble::dump_xml(std::ostream & s_oss, unsigned int indent) const
|
||||
{
|
||||
s_oss << indent0;
|
||||
s_oss << xmlElement << xmlAtt1 << it->first << xmlAtt2 << it->
|
||||
second << "/>" << std::endl;
|
||||
second << "/>" << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
@ -210,7 +210,7 @@ cxxNameDouble::dump_raw(std::ostream & s_oss, unsigned int indent) const
|
||||
for (const_iterator it = (*this).begin(); it != (*this).end(); it++)
|
||||
{
|
||||
s_oss << indent0;
|
||||
s_oss << it->first << " " << it->second << std::endl;
|
||||
s_oss << it->first << " " << it->second << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
@ -448,7 +448,7 @@ cxxNameDouble::mpi_pack(int *ints, int *ii, LDBLE *doubles, int *dd)
|
||||
int n = dictionary.string2int(it->first);
|
||||
if (n < 0)
|
||||
{
|
||||
std::cerr << it->first << std::endl;
|
||||
std::cerr << it->first << "\n";
|
||||
error_msg("Name in NameDouble was not defined in dictionary?\n",
|
||||
STOP);
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ error_msg(const std::string & stdstr, int stop)
|
||||
{
|
||||
this->base_error_count++;
|
||||
std::ostringstream msg;
|
||||
msg << "ERROR: " << stdstr << std::endl;
|
||||
msg << "ERROR: " << stdstr << "\n";
|
||||
if (this->io)
|
||||
{
|
||||
this->io->output_msg(msg.str().c_str());
|
||||
@ -53,8 +53,8 @@ warning_msg(const std::string & stdstr)
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << stdstr << std::endl;
|
||||
std::cout << stdstr << std::endl;
|
||||
std::cerr << stdstr << "\n";
|
||||
std::cout << stdstr << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ output_msg(const std::string & stdstr)
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << stdstr << std::endl;
|
||||
std::cout << stdstr << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ screen_msg(const std::string & stdstr)
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << stdstr << std::endl;
|
||||
std::cerr << stdstr << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,6 +93,6 @@ echo_msg(const std::string & stdstr)
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << stdstr << std::endl;
|
||||
std::cout << stdstr << "\n";
|
||||
}
|
||||
}
|
||||
269
PHRQ_io.cpp
269
PHRQ_io.cpp
@ -1,5 +1,7 @@
|
||||
#include <assert.h>
|
||||
#include "Utils.h"
|
||||
#include "PHRQ_io.h"
|
||||
#include "Parser.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
@ -358,11 +360,11 @@ warning_msg(const char *err_str)
|
||||
{
|
||||
if (error_ostream != NULL && error_on)
|
||||
{
|
||||
(*error_ostream) << err_str << std::endl;
|
||||
(*error_ostream) << err_str << "\n";
|
||||
error_ostream->flush();
|
||||
}
|
||||
std::ostringstream warn_str;
|
||||
warn_str << err_str << std::endl;
|
||||
warn_str << err_str << "\n";
|
||||
log_msg(warn_str.str().c_str());
|
||||
log_flush();
|
||||
output_msg(warn_str.str().c_str());
|
||||
@ -517,3 +519,266 @@ pop_istream()
|
||||
delete_istream_list.pop_front();
|
||||
}
|
||||
}
|
||||
/* ---------------------------------------------------------------------- */
|
||||
PHRQ_io::LINE_TYPE PHRQ_io::
|
||||
get_line(void)
|
||||
/* ---------------------------------------------------------------------- */
|
||||
{
|
||||
/*
|
||||
* Read a line from input file put in "line".
|
||||
* Copy of input line is stored in "line_save".
|
||||
* Characters after # are discarded in line but retained in "line_save"
|
||||
*
|
||||
* Arguments:
|
||||
* fp is file name
|
||||
* Returns:
|
||||
* EMPTY,
|
||||
* EOF,
|
||||
* KEYWORD,
|
||||
* OK,
|
||||
* OPTION
|
||||
*/
|
||||
int i;
|
||||
bool empty;
|
||||
std::string stdtoken;
|
||||
void *cookie;
|
||||
bool continue_loop = true;;
|
||||
|
||||
PHRQ_io::LINE_TYPE return_value;
|
||||
// loop for include files
|
||||
for (;;)
|
||||
{
|
||||
cookie = this->get_istream();
|
||||
if (cookie == NULL)
|
||||
{
|
||||
break;
|
||||
}
|
||||
return_value = LT_EMPTY;
|
||||
while (return_value == LT_EMPTY)
|
||||
{
|
||||
/*
|
||||
* Eliminate all characters after # sign as a comment
|
||||
*/
|
||||
i = -1;
|
||||
empty = true;
|
||||
/*
|
||||
* Get line, check for eof
|
||||
*/
|
||||
continue_loop = false;
|
||||
|
||||
|
||||
//if (!m_input_stream.eof())
|
||||
////{
|
||||
//// error_msg("Reading input file.", OT_CONTINUE);
|
||||
//// error_msg("istream::get() returned an error.", OT_STOP);
|
||||
////}
|
||||
////else
|
||||
//{
|
||||
// //{{MOD
|
||||
// m_line.erase(m_line.begin(), m_line.end()); // m_line.clear();
|
||||
// //}}MOD
|
||||
// m_next_keyword = Keywords::KEY_END;
|
||||
// return LT_EOF;
|
||||
//}
|
||||
if (get_logical_line(cookie) == LT_EOF)
|
||||
{
|
||||
//if (!m_input_stream.eof())
|
||||
//{
|
||||
// error_msg("Reading input file.", OT_CONTINUE);
|
||||
// error_msg("istream::get() returned an error.", OT_STOP);
|
||||
//}
|
||||
//pop next file
|
||||
this->pop_istream();
|
||||
continue_loop = true;
|
||||
break;
|
||||
}
|
||||
/*
|
||||
* Get long lines
|
||||
*/
|
||||
bool empty = true;
|
||||
m_line = m_line_save.substr(0, m_line_save.find_first_of('#'));
|
||||
for (unsigned int i = 0; i < m_line.size(); ++i)
|
||||
{
|
||||
if (!::isspace(m_line[i]))
|
||||
{
|
||||
empty = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (this->accumulate)
|
||||
{
|
||||
this->accumulated.append(m_line_save);
|
||||
this->accumulated.append("\n");
|
||||
}
|
||||
//
|
||||
// New line character encountered
|
||||
//
|
||||
return_value = (empty ? LT_EMPTY : LT_OK);
|
||||
|
||||
}
|
||||
if (continue_loop) continue;
|
||||
//
|
||||
// Determine return_value
|
||||
//
|
||||
if (return_value == LT_OK)
|
||||
{
|
||||
if (check_key(m_line.begin(), m_line.end()))
|
||||
{
|
||||
return_value = LT_KEYWORD;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string::iterator beg = m_line.begin();
|
||||
std::string::iterator end = m_line.end();
|
||||
std::string token;
|
||||
CParser::copy_token(token, beg, end);
|
||||
|
||||
if (token.size() > 1 && token[0] == '-' &&::isalpha(token[1]))
|
||||
{
|
||||
return_value = LT_OPTION;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add new include file to stack
|
||||
//ptr = line;
|
||||
//copy_token(stdtoken, &ptr);
|
||||
|
||||
std::string::iterator beg = m_line.begin();
|
||||
std::string::iterator end = m_line.end();
|
||||
CParser::copy_token(stdtoken, beg, end);
|
||||
Utilities::str_tolower(stdtoken);
|
||||
if ((strstr(stdtoken.c_str(),"include$") == stdtoken.c_str()) ||
|
||||
(strstr(stdtoken.c_str(),"include_file") == stdtoken.c_str()))
|
||||
{
|
||||
std::string file_name;
|
||||
file_name.assign(beg, end);
|
||||
file_name = trim(file_name);
|
||||
|
||||
if (file_name.size() > 0)
|
||||
{
|
||||
std::ifstream *next_stream = new std::ifstream(file_name.c_str(), std::ios_base::in);
|
||||
if (!next_stream->is_open())
|
||||
{
|
||||
// error opening file
|
||||
// error_string = sformatf( "Could not open include file %s", file_name);
|
||||
std::ostringstream errstr;
|
||||
errstr << "Could not open include file " << file_name;
|
||||
error_msg(errstr.str().c_str(), OT_STOP);
|
||||
}
|
||||
this->push_istream(next_stream);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return return_value;
|
||||
}
|
||||
m_next_keyword = Keywords::KEY_END;
|
||||
return LT_EOF;
|
||||
}
|
||||
|
||||
/**
|
||||
Reads input stream until end of line, ";", or eof
|
||||
stores characters in line_save
|
||||
|
||||
returns:
|
||||
EOF on empty line on end of file or
|
||||
OK otherwise
|
||||
*/
|
||||
PHRQ_io::LINE_TYPE PHRQ_io::
|
||||
get_logical_line(void * cookie)
|
||||
{
|
||||
int
|
||||
j;
|
||||
unsigned int
|
||||
pos;
|
||||
char
|
||||
c;
|
||||
if (!cookie)
|
||||
return LT_EOF;
|
||||
m_line_save.erase(m_line_save.begin(), m_line_save.end()); // m_line_save.clear();
|
||||
|
||||
//while ((j = m_input_stream.get()) != std::char_traits < char >::eof())
|
||||
while ((j = istream_getc(cookie)) != EOF)
|
||||
{
|
||||
c = (char) j;
|
||||
if (c == '#')
|
||||
{
|
||||
// ignore all chars after # until newline
|
||||
do
|
||||
{
|
||||
c = (char) j;
|
||||
if (c == '\n')
|
||||
{
|
||||
break;
|
||||
}
|
||||
m_line_save += c;
|
||||
}
|
||||
while ((j = istream_getc(cookie)) != EOF);
|
||||
//while ((j =
|
||||
// m_input_stream.get()) != std::char_traits <
|
||||
// char >::eof());
|
||||
}
|
||||
if (c == ';')
|
||||
break;
|
||||
if (c == '\n')
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (c == '\\')
|
||||
{
|
||||
pos = (int) m_line_save.size();
|
||||
m_line_save += c;
|
||||
//while ((j = m_input_stream.get()) != std::char_traits < char >::eof())
|
||||
while ((j = PHRQ_io::istream_getc(cookie)) != EOF)
|
||||
{
|
||||
c = (char) j;
|
||||
if (c == '\\')
|
||||
{
|
||||
pos = (int) m_line_save.size();
|
||||
m_line_save += c;
|
||||
continue;
|
||||
}
|
||||
if (c == '\n')
|
||||
{
|
||||
// remove '\\'
|
||||
for (; pos < m_line_save.size(); pos++)
|
||||
{
|
||||
m_line_save[pos] = m_line_save[pos + 1];
|
||||
}
|
||||
m_line_save.erase(m_line_save.size() - 1, 1);
|
||||
break;
|
||||
}
|
||||
m_line_save += c;
|
||||
if (!::isspace(j))
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_line_save += c;
|
||||
}
|
||||
}
|
||||
if (j == std::char_traits < char >::eof() && m_line_save.size() == 0)
|
||||
{
|
||||
return (LT_EOF);
|
||||
}
|
||||
return (LT_OK);
|
||||
}
|
||||
|
||||
bool PHRQ_io::
|
||||
check_key(std::string::iterator begin, std::string::iterator end)
|
||||
{
|
||||
std::string lowercase;
|
||||
CParser::copy_token(lowercase, begin, end);
|
||||
std::transform(lowercase.begin(), lowercase.end(), lowercase.begin(),
|
||||
tolower);
|
||||
|
||||
m_next_keyword = Keywords::Keyword_search(lowercase);
|
||||
if (m_next_keyword == Keywords::KEY_NONE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
42
PHRQ_io.h
42
PHRQ_io.h
@ -10,6 +10,7 @@
|
||||
#include <iostream>
|
||||
#include <exception>
|
||||
#include <list>
|
||||
#include "Keywords.h"
|
||||
|
||||
class PhreeqcStop : std::exception
|
||||
{
|
||||
@ -18,6 +19,20 @@ class PhreeqcStop : std::exception
|
||||
class IPQ_DLL_EXPORT PHRQ_io
|
||||
{
|
||||
public:
|
||||
enum LINE_TYPE
|
||||
{
|
||||
LT_EOF = -1,
|
||||
LT_OK = 1,
|
||||
LT_EMPTY = 2,
|
||||
LT_KEYWORD = 3,
|
||||
LT_OPTION = 8
|
||||
};
|
||||
|
||||
enum ONERROR_TYPE
|
||||
{
|
||||
OT_CONTINUE = 0,
|
||||
OT_STOP = 1
|
||||
};
|
||||
// constructor/destructor
|
||||
PHRQ_io(void);
|
||||
virtual ~ PHRQ_io();
|
||||
@ -103,6 +118,24 @@ public:
|
||||
void Set_screen_on(bool tf) {this->screen_on = tf;};
|
||||
bool Get_screen_on(void) {return this->screen_on;};
|
||||
|
||||
// input methods
|
||||
LINE_TYPE get_line(void);
|
||||
LINE_TYPE get_logical_line(void * cookie);
|
||||
bool check_key(std::string::iterator begin, std::string::iterator end);
|
||||
std::string & Get_m_line() {return m_line;}
|
||||
std::string & Get_m_line_save() {return m_line_save;}
|
||||
std::string & Get_accumulated() {return accumulated;}
|
||||
LINE_TYPE Get_m_line_type() {return m_line_type;};
|
||||
void Set_accumulate(bool tf)
|
||||
{
|
||||
if (tf)
|
||||
{
|
||||
accumulated.clear();
|
||||
}
|
||||
this->accumulate = tf;
|
||||
}
|
||||
Keywords::KEYWORDS Get_m_next_keyword() const {return m_next_keyword;}
|
||||
|
||||
// echo
|
||||
enum ECHO_OPTION
|
||||
{
|
||||
@ -136,5 +169,14 @@ protected:
|
||||
|
||||
std::list <std::istream *> istream_list;
|
||||
std::list <bool> delete_istream_list;
|
||||
|
||||
// input data members
|
||||
Keywords::KEYWORDS m_next_keyword;
|
||||
std::string m_line;
|
||||
std::string m_line_save;
|
||||
std::string accumulated;
|
||||
bool accumulate;
|
||||
LINE_TYPE m_line_type;
|
||||
};
|
||||
|
||||
#endif /* _PHRQIO_H */
|
||||
|
||||
@ -92,14 +92,14 @@ cxxPPassemblage::dump_xml(std::ostream & s_oss, unsigned int indent) const
|
||||
|
||||
// PPassemblage element and attributes
|
||||
s_oss << indent0;
|
||||
s_oss << "<EQUILIBRIUM_PHASES " << std::endl;
|
||||
s_oss << "<EQUILIBRIUM_PHASES " << "\n";
|
||||
|
||||
// eltList
|
||||
this->eltList.dump_xml(s_oss, indent + 1);
|
||||
|
||||
// ppAssemblageComps
|
||||
s_oss << indent1;
|
||||
s_oss << "<pure_phases " << std::endl;
|
||||
s_oss << "<pure_phases " << "\n";
|
||||
for (std::map < std::string, cxxPPassemblageComp >::const_iterator it =
|
||||
ppAssemblageComps.begin(); it != ppAssemblageComps.end(); ++it)
|
||||
{
|
||||
@ -125,12 +125,12 @@ cxxPPassemblage::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out)
|
||||
s_oss << indent0;
|
||||
int n_user_local = (n_out != NULL) ? *n_out : this->n_user;
|
||||
s_oss << "EQUILIBRIUM_PHASES_RAW " << n_user_local << " " << this->
|
||||
description << std::endl;
|
||||
description << "\n";
|
||||
|
||||
// eltList
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "-eltList " << std::endl;
|
||||
s_oss << "-eltList " << "\n";
|
||||
this->eltList.dump_raw(s_oss, indent + 2);
|
||||
|
||||
// ppAssemblagComps
|
||||
@ -138,7 +138,7 @@ cxxPPassemblage::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out)
|
||||
ppAssemblageComps.begin(); it != ppAssemblageComps.end(); ++it)
|
||||
{
|
||||
s_oss << indent1;
|
||||
s_oss << "-component" << std::endl;
|
||||
s_oss << "-component" << "\n";
|
||||
(*it).second.dump_raw(s_oss, indent + 2);
|
||||
}
|
||||
}
|
||||
@ -191,8 +191,8 @@ cxxPPassemblage::read_raw(CParser & parser, bool check)
|
||||
opt = CParser::OPT_EOF;
|
||||
parser.
|
||||
error_msg("Unknown input in EQUILIBRIUM_PHASES_RAW keyword.",
|
||||
CParser::OT_CONTINUE);
|
||||
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
|
||||
useLastLine = false;
|
||||
break;
|
||||
|
||||
@ -203,7 +203,7 @@ cxxPPassemblage::read_raw(CParser & parser, bool check)
|
||||
parser.incr_input_error();
|
||||
parser.
|
||||
error_msg("Expected element name and moles for totals.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
opt_save = 0;
|
||||
break;
|
||||
|
||||
@ -73,21 +73,21 @@ cxxPPassemblageComp::dump_xml(std::ostream & s_oss, unsigned int indent) const
|
||||
|
||||
// Pure_Phase element and attributes
|
||||
|
||||
s_oss << indent0 << "name=\"" << this->name << "\"" << std::endl;
|
||||
s_oss << indent0 << "name=\"" << this->name << "\"" << "\n";
|
||||
s_oss << indent0 << "add_formula=\"" << this->
|
||||
add_formula << "\"" << std::endl;
|
||||
s_oss << indent0 << "si=\"" << this->si << "\"" << std::endl;
|
||||
s_oss << indent0 << "si_org=\"" << this->si_org << "\"" << std::endl;
|
||||
s_oss << indent0 << "moles=\"" << this->moles << "\"" << std::endl;
|
||||
s_oss << indent0 << "delta=\"" << this->delta << "\"" << std::endl;
|
||||
add_formula << "\"" << "\n";
|
||||
s_oss << indent0 << "si=\"" << this->si << "\"" << "\n";
|
||||
s_oss << indent0 << "si_org=\"" << this->si_org << "\"" << "\n";
|
||||
s_oss << indent0 << "moles=\"" << this->moles << "\"" << "\n";
|
||||
s_oss << indent0 << "delta=\"" << this->delta << "\"" << "\n";
|
||||
s_oss << indent0 << "initial_moles=\"" << this->
|
||||
initial_moles << "\"" << std::endl;
|
||||
initial_moles << "\"" << "\n";
|
||||
s_oss << indent0 << "force_equality=\"" << this->
|
||||
force_equality << "\"" << std::endl;
|
||||
force_equality << "\"" << "\n";
|
||||
s_oss << indent0 << "dissolve_only=\"" << this->
|
||||
dissolve_only << "\"" << std::endl;
|
||||
dissolve_only << "\"" << "\n";
|
||||
s_oss << indent0 << "precipitate_only=\"" << this->
|
||||
precipitate_only << "\"" << std::endl;
|
||||
precipitate_only << "\"" << "\n";
|
||||
|
||||
}
|
||||
|
||||
@ -108,17 +108,17 @@ cxxPPassemblageComp::dump_raw(std::ostream & s_oss, unsigned int indent) const
|
||||
// Pure_Phase element and attributes
|
||||
|
||||
if (this->name.size() != 0)
|
||||
s_oss << indent0 << "-name " << this->name << std::endl;
|
||||
s_oss << indent0 << "-name " << this->name << "\n";
|
||||
if (this->add_formula.size() != 0)
|
||||
s_oss << indent1 << "-add_formula " << this->add_formula << std::endl;
|
||||
s_oss << indent1 << "-si " << this->si << std::endl;
|
||||
s_oss << indent1 << "-si_org " << this->si_org << std::endl;
|
||||
s_oss << indent1 << "-moles " << this->moles << std::endl;
|
||||
s_oss << indent1 << "-delta " << this->delta << std::endl;
|
||||
s_oss << indent1 << "-initial_moles " << this->initial_moles << std::endl;
|
||||
s_oss << indent1 << "-force_equality " << this->force_equality << std::endl;
|
||||
s_oss << indent1 << "-dissolve_only " << this->dissolve_only << std::endl;
|
||||
s_oss << indent1 << "-precipitate_only " << this->precipitate_only << std::endl;
|
||||
s_oss << indent1 << "-add_formula " << this->add_formula << "\n";
|
||||
s_oss << indent1 << "-si " << this->si << "\n";
|
||||
s_oss << indent1 << "-si_org " << this->si_org << "\n";
|
||||
s_oss << indent1 << "-moles " << this->moles << "\n";
|
||||
s_oss << indent1 << "-delta " << this->delta << "\n";
|
||||
s_oss << indent1 << "-initial_moles " << this->initial_moles << "\n";
|
||||
s_oss << indent1 << "-force_equality " << this->force_equality << "\n";
|
||||
s_oss << indent1 << "-dissolve_only " << this->dissolve_only << "\n";
|
||||
s_oss << indent1 << "-precipitate_only " << this->precipitate_only << "\n";
|
||||
}
|
||||
|
||||
void
|
||||
@ -176,8 +176,8 @@ cxxPPassemblageComp::read_raw(CParser & parser, bool check)
|
||||
case CParser::OPT_ERROR:
|
||||
opt = CParser::OPT_KEYWORD;
|
||||
// Allow return to Exchange for more processing
|
||||
//parser.error_msg("Unknown input in PURE_PHASE read.", CParser::OT_CONTINUE);
|
||||
//parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE);
|
||||
//parser.error_msg("Unknown input in PURE_PHASE read.", PHRQ_io::OT_CONTINUE);
|
||||
//parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
|
||||
break;
|
||||
|
||||
case 0: // name
|
||||
@ -186,7 +186,7 @@ cxxPPassemblageComp::read_raw(CParser & parser, bool check)
|
||||
this->name.clear();
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected string value for name.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -201,7 +201,7 @@ cxxPPassemblageComp::read_raw(CParser & parser, bool check)
|
||||
this->add_formula.clear();
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected string value for add_formula.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -215,7 +215,7 @@ cxxPPassemblageComp::read_raw(CParser & parser, bool check)
|
||||
this->si = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for si.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
si_defined = true;
|
||||
break;
|
||||
@ -226,7 +226,7 @@ cxxPPassemblageComp::read_raw(CParser & parser, bool check)
|
||||
this->moles = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for moles.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
moles_defined = true;
|
||||
break;
|
||||
@ -237,7 +237,7 @@ cxxPPassemblageComp::read_raw(CParser & parser, bool check)
|
||||
this->delta = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for delta.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
delta_defined = true;
|
||||
break;
|
||||
@ -248,7 +248,7 @@ cxxPPassemblageComp::read_raw(CParser & parser, bool check)
|
||||
this->initial_moles = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for initial_moles.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
initial_moles_defined = true;
|
||||
break;
|
||||
@ -260,7 +260,7 @@ cxxPPassemblageComp::read_raw(CParser & parser, bool check)
|
||||
this->dissolve_only = false;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected boolean value for dissolve_only.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
dissolve_only_defined = true;
|
||||
if (this->dissolve_only)
|
||||
@ -275,7 +275,7 @@ cxxPPassemblageComp::read_raw(CParser & parser, bool check)
|
||||
this->force_equality = false;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected boolean value for force_equality.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
force_equality_defined = true;
|
||||
break;
|
||||
@ -286,7 +286,7 @@ cxxPPassemblageComp::read_raw(CParser & parser, bool check)
|
||||
this->precipitate_only = false;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected boolean value for precipitate_only.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
precipitate_only_defined = true;
|
||||
if (this->precipitate_only)
|
||||
@ -300,7 +300,7 @@ cxxPPassemblageComp::read_raw(CParser & parser, bool check)
|
||||
this->si_org = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for si_org.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
si_org_defined = true;
|
||||
break;
|
||||
@ -315,37 +315,37 @@ cxxPPassemblageComp::read_raw(CParser & parser, bool check)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Name not defined for PPassemblageComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (si_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Si not defined for PPassemblageComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (moles_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Moles not defined for PPassemblageComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (delta_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Delta not defined for PPassemblageComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (initial_moles_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Initial_moles not defined for PPassemblageComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (dissolve_only_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Dissolve_only not defined for PPassemblageComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
/* don't check to maintain backward compatibility
|
||||
if (precipitate_only_defined == false)
|
||||
@ -353,7 +353,7 @@ cxxPPassemblageComp::read_raw(CParser & parser, bool check)
|
||||
parser.incr_input_error();
|
||||
parser.
|
||||
error_msg("Precipitate_only not defined for PPassemblageComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
*/
|
||||
if (force_equality_defined == false)
|
||||
@ -361,13 +361,13 @@ cxxPPassemblageComp::read_raw(CParser & parser, bool check)
|
||||
parser.incr_input_error();
|
||||
parser.error_msg
|
||||
("Force_equality not defined for PPassemblageComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (si_org_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Si_org not defined for PPassemblageComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
217
Parser.cxx
217
Parser.cxx
@ -19,12 +19,36 @@
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
CParser::CParser(PHRQ_io *io):
|
||||
PHRQ_base(io),
|
||||
m_input_stream(std::cin),
|
||||
//m_output_stream(std::cout),
|
||||
//m_error_stream(std::cerr),
|
||||
m_input_error(0),
|
||||
m_next_keyword(Keywords::KEY_NONE)
|
||||
{
|
||||
if (!io)
|
||||
{
|
||||
error_msg("This parser constructor requires non-null phrq_io", PHRQ_io::OT_STOP);
|
||||
}
|
||||
m_line_save = io->Get_m_line();
|
||||
m_line = io->Get_m_line();
|
||||
m_line_type = io->Get_m_line_type();
|
||||
m_line_iss.str(m_line);
|
||||
m_line_iss.seekg(0, std::ios_base::beg);
|
||||
m_line_iss.clear();
|
||||
echo_file = EO_ALL;
|
||||
echo_stream = EO_NONE;
|
||||
accumulate = false;
|
||||
phrq_io_only = true;
|
||||
|
||||
}
|
||||
|
||||
CParser::CParser(std::istream & input, PHRQ_io *io):
|
||||
PHRQ_base(io),
|
||||
m_input_stream(input),
|
||||
m_output_stream(std::cout),
|
||||
m_error_stream(std::cerr),
|
||||
//m_output_stream(std::cout),
|
||||
//m_error_stream(std::cerr),
|
||||
m_input_error(0),
|
||||
m_next_keyword(Keywords::KEY_NONE)
|
||||
{
|
||||
@ -33,8 +57,10 @@ m_next_keyword(Keywords::KEY_NONE)
|
||||
echo_file = EO_ALL;
|
||||
echo_stream = EO_NONE;
|
||||
accumulate = false;
|
||||
phrq_io_only = false;
|
||||
}
|
||||
|
||||
#ifdef SKIP
|
||||
CParser::CParser(std::istream & input, std::ostream & output, PHRQ_io *io)
|
||||
:
|
||||
PHRQ_base(io),
|
||||
@ -66,16 +92,16 @@ m_next_keyword(Keywords::KEY_NONE)
|
||||
echo_stream = EO_NONE;
|
||||
accumulate = false;
|
||||
}
|
||||
|
||||
#endif
|
||||
CParser::~CParser()
|
||||
{
|
||||
}
|
||||
|
||||
CParser::LINE_TYPE CParser::check_line(const std::string & str,
|
||||
PHRQ_io::LINE_TYPE CParser::check_line(const std::string & str,
|
||||
bool allow_empty, bool allow_eof,
|
||||
bool allow_keyword, bool print)
|
||||
{
|
||||
LINE_TYPE
|
||||
PHRQ_io::LINE_TYPE
|
||||
i;
|
||||
|
||||
// Get line
|
||||
@ -93,27 +119,30 @@ CParser::LINE_TYPE CParser::check_line(const std::string & str,
|
||||
case EO_NONE:
|
||||
break;
|
||||
case EO_ALL:
|
||||
if (i != LT_EOF)
|
||||
if (i != PHRQ_io::LT_EOF)
|
||||
{
|
||||
std::ostringstream msg;
|
||||
msg << "\t" << m_line_save << "\n";
|
||||
get_output() << msg;
|
||||
//get_output() << msg;
|
||||
io->output_msg(msg.str().c_str());
|
||||
}
|
||||
break;
|
||||
case EO_KEYWORDS:
|
||||
if (i == LT_KEYWORD)
|
||||
if (i == PHRQ_io::LT_KEYWORD)
|
||||
{
|
||||
std::ostringstream msg;
|
||||
msg << "\t" << m_line_save << "\n";
|
||||
get_output() << msg;
|
||||
//get_output() << msg;
|
||||
io->output_msg(msg.str().c_str());
|
||||
}
|
||||
break;
|
||||
case EO_NOKEYWORDS:
|
||||
if (i != LT_KEYWORD && i != LT_EOF)
|
||||
if (i != PHRQ_io::LT_KEYWORD && i != PHRQ_io::LT_EOF)
|
||||
{
|
||||
std::ostringstream msg;
|
||||
msg << "\t" << m_line_save << "\n";
|
||||
get_output() << msg;
|
||||
//get_output() << msg;
|
||||
io->output_msg(msg.str().c_str());
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -123,7 +152,7 @@ CParser::LINE_TYPE CParser::check_line(const std::string & str,
|
||||
case EO_NONE:
|
||||
break;
|
||||
case EO_ALL:
|
||||
if (i != LT_EOF)
|
||||
if (i != PHRQ_io::LT_EOF)
|
||||
{
|
||||
std::ostringstream msg;
|
||||
msg << "\t" << m_line_save << "\n";
|
||||
@ -131,7 +160,7 @@ CParser::LINE_TYPE CParser::check_line(const std::string & str,
|
||||
}
|
||||
break;
|
||||
case EO_KEYWORDS:
|
||||
if (i == LT_KEYWORD)
|
||||
if (i == PHRQ_io::LT_KEYWORD)
|
||||
{
|
||||
std::ostringstream msg;
|
||||
msg << "\t" << m_line_save << "\n";
|
||||
@ -140,7 +169,7 @@ CParser::LINE_TYPE CParser::check_line(const std::string & str,
|
||||
break;
|
||||
|
||||
case EO_NOKEYWORDS:
|
||||
if (i != LT_KEYWORD && i != LT_EOF)
|
||||
if (i != PHRQ_io::LT_KEYWORD && i != PHRQ_io::LT_EOF)
|
||||
{
|
||||
std::ostringstream msg;
|
||||
msg << "\t" << m_line_save << "\n";
|
||||
@ -149,34 +178,51 @@ CParser::LINE_TYPE CParser::check_line(const std::string & str,
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (i == LT_EMPTY && allow_empty == false);
|
||||
while (i == PHRQ_io::LT_EMPTY && allow_empty == false);
|
||||
|
||||
// Check eof
|
||||
if (i == LT_EOF && allow_eof == false)
|
||||
if (i == PHRQ_io::LT_EOF && allow_eof == false)
|
||||
{
|
||||
std::ostringstream msg;
|
||||
msg << "Unexpected eof while reading " << str <<
|
||||
"\nExecution terminated.\n";
|
||||
error_msg(msg.str().c_str(), OT_STOP);
|
||||
error_msg(msg.str().c_str(), PHRQ_io::OT_STOP);
|
||||
}
|
||||
|
||||
// Check keyword
|
||||
if (i == LT_KEYWORD && allow_keyword == false)
|
||||
if (i == PHRQ_io::LT_KEYWORD && allow_keyword == false)
|
||||
{
|
||||
std::ostringstream msg;
|
||||
msg << "Expected data for " << str <<
|
||||
", but got a keyword ending data block.";
|
||||
error_msg(msg.str().c_str(), OT_CONTINUE);
|
||||
error_msg(msg.str().c_str(), PHRQ_io::OT_CONTINUE);
|
||||
incr_input_error();
|
||||
}
|
||||
m_line_type = i;
|
||||
return i;
|
||||
}
|
||||
|
||||
CParser::LINE_TYPE CParser::get_line()
|
||||
PHRQ_io::LINE_TYPE CParser::get_line_phrq_io()
|
||||
{
|
||||
CParser::LINE_TYPE return_value = LT_EMPTY;
|
||||
while (return_value == LT_EMPTY)
|
||||
m_line_type = io->get_line();
|
||||
m_line_save = io->Get_m_line_save();
|
||||
m_line = io->Get_m_line();
|
||||
m_next_keyword = io->Get_m_next_keyword();
|
||||
if (accumulate)
|
||||
{
|
||||
this->accumulated.append(m_line_save);
|
||||
this->accumulated.append("\n");
|
||||
}
|
||||
return m_line_type;
|
||||
}
|
||||
|
||||
PHRQ_io::LINE_TYPE CParser::get_line()
|
||||
{
|
||||
if (this->phrq_io_only)
|
||||
{
|
||||
return get_line_phrq_io();
|
||||
}
|
||||
PHRQ_io::LINE_TYPE return_value = PHRQ_io::LT_EMPTY;
|
||||
while (return_value == PHRQ_io::LT_EMPTY)
|
||||
{
|
||||
//
|
||||
// Eliminate all characters after # sign as a comment
|
||||
@ -185,12 +231,12 @@ CParser::LINE_TYPE CParser::get_line()
|
||||
//
|
||||
// Get line, check for eof
|
||||
//
|
||||
if (get_logical_line() == LT_EOF)
|
||||
if (get_logical_line() == PHRQ_io::LT_EOF)
|
||||
{
|
||||
if (!m_input_stream.eof())
|
||||
{
|
||||
error_msg("Reading input file.", OT_CONTINUE);
|
||||
error_msg("istream::get() returned an error.", OT_STOP);
|
||||
error_msg("Reading input file.", PHRQ_io::OT_CONTINUE);
|
||||
error_msg("istream::get() returned an error.", PHRQ_io::OT_STOP);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -198,7 +244,7 @@ CParser::LINE_TYPE CParser::get_line()
|
||||
m_line.erase(m_line.begin(), m_line.end()); // m_line.clear();
|
||||
//}}MOD
|
||||
m_next_keyword = Keywords::KEY_END;
|
||||
return LT_EOF;
|
||||
return PHRQ_io::LT_EOF;
|
||||
}
|
||||
}
|
||||
|
||||
@ -225,17 +271,17 @@ CParser::LINE_TYPE CParser::get_line()
|
||||
//
|
||||
// New line character encountered
|
||||
//
|
||||
return_value = (empty ? LT_EMPTY : LT_OK);
|
||||
return_value = (empty ? PHRQ_io::LT_EMPTY : PHRQ_io::LT_OK);
|
||||
}
|
||||
|
||||
//
|
||||
// Determine return_value
|
||||
//
|
||||
if (return_value == LT_OK)
|
||||
if (return_value == PHRQ_io::LT_OK)
|
||||
{
|
||||
if (check_key(m_line.begin(), m_line.end()))
|
||||
{
|
||||
return_value = LT_KEYWORD;
|
||||
return_value = PHRQ_io::LT_KEYWORD;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -246,7 +292,7 @@ CParser::LINE_TYPE CParser::get_line()
|
||||
|
||||
if (token.size() > 1 && token[0] == '-' &&::isalpha(token[1]))
|
||||
{
|
||||
return_value = LT_OPTION;
|
||||
return_value = PHRQ_io::LT_OPTION;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -261,7 +307,7 @@ CParser::LINE_TYPE CParser::get_line()
|
||||
EOF on empty line on end of file or
|
||||
OK otherwise
|
||||
*/
|
||||
CParser::LINE_TYPE CParser::get_logical_line()
|
||||
PHRQ_io::LINE_TYPE CParser::get_logical_line()
|
||||
{
|
||||
int
|
||||
j;
|
||||
@ -333,9 +379,9 @@ CParser::LINE_TYPE CParser::get_logical_line()
|
||||
}
|
||||
if (j == std::char_traits < char >::eof() && m_line_save.size() == 0)
|
||||
{
|
||||
return (LT_EOF);
|
||||
return (PHRQ_io::LT_EOF);
|
||||
}
|
||||
return (LT_OK);
|
||||
return (PHRQ_io::LT_OK);
|
||||
}
|
||||
|
||||
bool
|
||||
@ -396,7 +442,7 @@ CParser::check_key(std::string::iterator begin, std::string::iterator end)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef SKIP
|
||||
CParser::STATUS_TYPE CParser::check_units(std::string & tot_units,
|
||||
bool alkalinity,
|
||||
bool check_compatibility,
|
||||
@ -503,7 +549,7 @@ CParser::STATUS_TYPE CParser::check_units(std::string & tot_units,
|
||||
{
|
||||
std::ostringstream err;
|
||||
err << "Unknown unit, " << tot_units;
|
||||
error_msg(err.str().c_str(), OT_CONTINUE);
|
||||
error_msg(err.str().c_str(), PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
return PARSER_ERROR;
|
||||
}
|
||||
@ -531,7 +577,7 @@ CParser::STATUS_TYPE CParser::check_units(std::string & tot_units,
|
||||
if (print)
|
||||
{
|
||||
error_msg("Only alkalinity can be entered in equivalents.",
|
||||
OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
return PARSER_ERROR;
|
||||
}
|
||||
@ -564,11 +610,11 @@ CParser::STATUS_TYPE CParser::check_units(std::string & tot_units,
|
||||
std::ostringstream err;
|
||||
err << "Units for master species, " << tot_units <<
|
||||
", are not compatible with default units, " << str << ".";
|
||||
error_msg(err.str().c_str(), OT_CONTINUE);
|
||||
error_msg(err.str().c_str(), PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
return PARSER_ERROR;
|
||||
}
|
||||
|
||||
#endif
|
||||
CParser::TOKEN_TYPE CParser::token_type(const std::string & token)
|
||||
{
|
||||
if (!token.empty())
|
||||
@ -696,16 +742,16 @@ CParser::get_option(const std::vector < std::string > &opt_list,
|
||||
//
|
||||
// Read line
|
||||
//
|
||||
LINE_TYPE lt = check_line("get_option", false, true, true, true);
|
||||
if (lt == LT_EOF)
|
||||
PHRQ_io::LINE_TYPE lt = check_line("get_option", false, true, true, true);
|
||||
if (lt == PHRQ_io::LT_EOF)
|
||||
{
|
||||
j = OPT_EOF;
|
||||
}
|
||||
else if (lt == LT_KEYWORD)
|
||||
else if (lt == PHRQ_io::LT_KEYWORD)
|
||||
{
|
||||
j = OPT_KEYWORD;
|
||||
}
|
||||
else if (lt == LT_OPTION)
|
||||
else if (lt == PHRQ_io::LT_OPTION)
|
||||
{
|
||||
opt_ptr = m_line.begin();
|
||||
std::string::iterator end = m_line.end();
|
||||
@ -724,7 +770,10 @@ CParser::get_option(const std::vector < std::string > &opt_list,
|
||||
{
|
||||
if (true) // database_file == NULL
|
||||
{
|
||||
get_output() << "\t" << m_line_save << "\n";
|
||||
//get_output() << "\t" << m_line_save << "\n";
|
||||
std::ostringstream msg;
|
||||
msg << "\t" << m_line_save << "\n";
|
||||
io->output_msg(msg.str().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -732,7 +781,10 @@ CParser::get_option(const std::vector < std::string > &opt_list,
|
||||
{
|
||||
if (true) // (database_file == NULL)
|
||||
{
|
||||
get_output() << "\t" << m_line_save << "\n";
|
||||
//get_output() << "\t" << m_line_save << "\n";
|
||||
std::ostringstream msg;
|
||||
msg << "\t" << m_line_save << "\n";
|
||||
io->output_msg(msg.str().c_str());
|
||||
}
|
||||
|
||||
std::ostringstream err;
|
||||
@ -785,16 +837,16 @@ CParser::get_option(const std::vector < std::string > &opt_list,
|
||||
//
|
||||
// Read line
|
||||
//
|
||||
LINE_TYPE lt = check_line("get_option", false, true, true, true);
|
||||
if (lt == LT_EOF)
|
||||
PHRQ_io::LINE_TYPE lt = check_line("get_option", false, true, true, true);
|
||||
if (lt == PHRQ_io::LT_EOF)
|
||||
{
|
||||
j = OPT_EOF;
|
||||
}
|
||||
else if (lt == LT_KEYWORD)
|
||||
else if (lt == PHRQ_io::LT_KEYWORD)
|
||||
{
|
||||
j = OPT_KEYWORD;
|
||||
}
|
||||
else if (lt == LT_OPTION)
|
||||
else if (lt == PHRQ_io::LT_OPTION)
|
||||
{
|
||||
std::string::iterator opt_ptr = m_line.begin();
|
||||
std::string::iterator end = m_line.end();
|
||||
@ -850,7 +902,7 @@ CParser::STATUS_TYPE CParser::get_elt(std::string::iterator & begin,
|
||||
if (begin == end)
|
||||
{
|
||||
error_msg("Empty string in get_elt. Expected an element name.",
|
||||
OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
return PARSER_ERROR;
|
||||
}
|
||||
|
||||
@ -876,7 +928,7 @@ CParser::STATUS_TYPE CParser::get_elt(std::string::iterator & begin,
|
||||
else if (begin == end)
|
||||
{
|
||||
error_msg("No ending bracket (]) for element name",
|
||||
OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
incr_input_error();
|
||||
return PARSER_ERROR;
|
||||
}
|
||||
@ -925,7 +977,7 @@ CParser::STATUS_TYPE CParser::parse_couple(std::string & token)
|
||||
std::ostringstream err_msg;
|
||||
err_msg << "Element name must be followed by " <<
|
||||
"parentheses in redox couple, " << token << ".";
|
||||
error_msg(err_msg.str().c_str(), OT_CONTINUE);
|
||||
error_msg(err_msg.str().c_str(), PHRQ_io::OT_CONTINUE);
|
||||
incr_input_error();
|
||||
return PARSER_ERROR;
|
||||
}
|
||||
@ -941,7 +993,7 @@ CParser::STATUS_TYPE CParser::parse_couple(std::string & token)
|
||||
std::ostringstream err_msg;
|
||||
err_msg << "End of line or " "/"
|
||||
" encountered before end of parentheses, " << token << ".";
|
||||
error_msg(err_msg.str().c_str(), OT_CONTINUE);
|
||||
error_msg(err_msg.str().c_str(), PHRQ_io::OT_CONTINUE);
|
||||
return PARSER_ERROR;
|
||||
}
|
||||
paren1.insert(paren1.end(), *ptr); // element.push_back(c);
|
||||
@ -959,7 +1011,7 @@ CParser::STATUS_TYPE CParser::parse_couple(std::string & token)
|
||||
std::ostringstream err_msg;
|
||||
err_msg << " " "/" " must follow parentheses " <<
|
||||
"ending first half of redox couple, " << token << ".";
|
||||
error_msg(err_msg.str().c_str(), OT_CONTINUE);
|
||||
error_msg(err_msg.str().c_str(), PHRQ_io::OT_CONTINUE);
|
||||
return PARSER_ERROR;
|
||||
}
|
||||
++ptr;
|
||||
@ -970,7 +1022,7 @@ CParser::STATUS_TYPE CParser::parse_couple(std::string & token)
|
||||
std::ostringstream err_msg;
|
||||
err_msg << "Redox couple must be two redox states " <<
|
||||
"of the same element, " << token << ".";
|
||||
error_msg(err_msg.str().c_str(), OT_CONTINUE);
|
||||
error_msg(err_msg.str().c_str(), PHRQ_io::OT_CONTINUE);
|
||||
return PARSER_ERROR;
|
||||
}
|
||||
if (*ptr != '(')
|
||||
@ -978,7 +1030,7 @@ CParser::STATUS_TYPE CParser::parse_couple(std::string & token)
|
||||
std::ostringstream err_msg;
|
||||
err_msg << "Element name must be followed by "
|
||||
"parentheses in redox couple, " << token << ".";
|
||||
error_msg(err_msg.str().c_str(), OT_CONTINUE);
|
||||
error_msg(err_msg.str().c_str(), PHRQ_io::OT_CONTINUE);
|
||||
incr_input_error();
|
||||
return PARSER_ERROR;
|
||||
}
|
||||
@ -993,7 +1045,7 @@ CParser::STATUS_TYPE CParser::parse_couple(std::string & token)
|
||||
std::ostringstream err_msg;
|
||||
err_msg << "End of line or " "/"
|
||||
" encountered before end of parentheses, " << token << ".";
|
||||
error_msg(err_msg.str().c_str(), OT_CONTINUE);
|
||||
error_msg(err_msg.str().c_str(), PHRQ_io::OT_CONTINUE);
|
||||
return PARSER_ERROR;
|
||||
}
|
||||
paren2.insert(paren2.end(), *ptr); // element.push_back(c);
|
||||
@ -1017,7 +1069,7 @@ CParser::STATUS_TYPE CParser::parse_couple(std::string & token)
|
||||
std::ostringstream err_msg;
|
||||
err_msg << "Both parts of redox couple are the same, " <<
|
||||
token << ".";
|
||||
error_msg(err_msg.str().c_str(), OT_CONTINUE);
|
||||
error_msg(err_msg.str().c_str(), PHRQ_io::OT_CONTINUE);
|
||||
return PARSER_ERROR;
|
||||
}
|
||||
return PARSER_OK;
|
||||
@ -1036,7 +1088,7 @@ CParser::STATUS_TYPE CParser::addPair(std::map < std::string, double >&totals,
|
||||
|
||||
j = copy_token(token, pos);
|
||||
|
||||
if (j == TT_EMPTY)
|
||||
if (j == CParser::TT_EMPTY)
|
||||
return PARSER_OK;
|
||||
|
||||
if (!(m_line_iss >> d))
|
||||
@ -1067,16 +1119,16 @@ CParser::getOptionFromLastLine(const std::vector < std::string > &opt_list,
|
||||
//
|
||||
// Read line
|
||||
//
|
||||
LINE_TYPE lt = m_line_type;
|
||||
if (lt == LT_EOF)
|
||||
PHRQ_io::LINE_TYPE lt = m_line_type;
|
||||
if (lt == PHRQ_io::LT_EOF)
|
||||
{
|
||||
j = OPT_EOF;
|
||||
}
|
||||
else if (lt == LT_KEYWORD)
|
||||
else if (lt == PHRQ_io::LT_KEYWORD)
|
||||
{
|
||||
j = OPT_KEYWORD;
|
||||
}
|
||||
else if (lt == LT_OPTION)
|
||||
else if (lt == PHRQ_io::LT_OPTION)
|
||||
{
|
||||
opt_ptr = m_line.begin();
|
||||
std::string::iterator end = m_line.end();
|
||||
@ -1095,7 +1147,10 @@ CParser::getOptionFromLastLine(const std::vector < std::string > &opt_list,
|
||||
{
|
||||
if (true) // database_file == NULL
|
||||
{
|
||||
get_output() << "\t" << m_line_save << "\n";
|
||||
//get_output() << "\t" << m_line_save << "\n";
|
||||
std::ostringstream msg;
|
||||
msg << "\t" << m_line_save << "\n";
|
||||
io->output_msg(msg.str().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1103,7 +1158,10 @@ CParser::getOptionFromLastLine(const std::vector < std::string > &opt_list,
|
||||
{
|
||||
if (true) // (database_file == NULL)
|
||||
{
|
||||
get_output() << "\t" << m_line_save << "\n";
|
||||
//get_output() << "\t" << m_line_save << "\n";
|
||||
std::ostringstream msg;
|
||||
msg << "\t" << m_line_save << "\n";
|
||||
io->output_msg(msg.str().c_str());
|
||||
}
|
||||
//std::cerr << "Unknown option." << "\n";
|
||||
//std::cerr << m_line_save << "\n";
|
||||
@ -1157,16 +1215,16 @@ CParser::getOptionFromLastLine(const std::vector < std::string > &opt_list,
|
||||
//
|
||||
// Read line
|
||||
//
|
||||
LINE_TYPE lt = m_line_type;
|
||||
if (lt == LT_EOF)
|
||||
PHRQ_io::LINE_TYPE lt = m_line_type;
|
||||
if (lt == PHRQ_io::LT_EOF)
|
||||
{
|
||||
j = OPT_EOF;
|
||||
}
|
||||
else if (lt == LT_KEYWORD)
|
||||
else if (lt == PHRQ_io::LT_KEYWORD)
|
||||
{
|
||||
j = OPT_KEYWORD;
|
||||
}
|
||||
else if (lt == LT_OPTION)
|
||||
else if (lt == PHRQ_io::LT_OPTION)
|
||||
{
|
||||
std::string::iterator opt_ptr = m_line.begin();
|
||||
std::string::iterator end = m_line.end();
|
||||
@ -1191,7 +1249,10 @@ CParser::getOptionFromLastLine(const std::vector < std::string > &opt_list,
|
||||
{
|
||||
if (true) // database_file == NULL
|
||||
{
|
||||
get_output() << "\t" << m_line_save << "\n";
|
||||
//get_output() << "\t" << m_line_save << "\n";
|
||||
std::ostringstream msg;
|
||||
msg << "\t" << m_line_save << "\n";
|
||||
io->output_msg(msg.str().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1199,10 +1260,13 @@ CParser::getOptionFromLastLine(const std::vector < std::string > &opt_list,
|
||||
{
|
||||
if (true) // (database_file == NULL)
|
||||
{
|
||||
get_output() << "\t" << m_line_save << "\n";
|
||||
//get_output() << "\t" << m_line_save << "\n";
|
||||
std::ostringstream msg;
|
||||
msg << "\t" << m_line_save << "\n";
|
||||
io->output_msg(msg.str().c_str());
|
||||
}
|
||||
error_msg("Unknown option.", OT_CONTINUE);
|
||||
error_msg(m_line_save.c_str(), OT_CONTINUE);
|
||||
error_msg("Unknown option.", PHRQ_io::OT_CONTINUE);
|
||||
error_msg(m_line_save.c_str(), PHRQ_io::OT_CONTINUE);
|
||||
incr_input_error();
|
||||
j = OPT_ERROR;
|
||||
next_pos = pos_ptr;
|
||||
@ -1226,7 +1290,10 @@ CParser::getOptionFromLastLine(const std::vector < std::string > &opt_list,
|
||||
{
|
||||
if (true) // database_file == NULL
|
||||
{
|
||||
get_output() << "\t" << m_line_save << "\n";
|
||||
//get_output() << "\t" << m_line_save << "\n";
|
||||
std::ostringstream msg;
|
||||
msg << "\t" << m_line_save << "\n";
|
||||
io->output_msg(msg.str().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1304,7 +1371,7 @@ bool CParser::get_true_false(std::istream::pos_type & pos, bool def)
|
||||
CParser::TOKEN_TYPE CParser::get_rest_of_line(std::string &token)
|
||||
{
|
||||
token.clear();
|
||||
std::istringstream::pos_type pos = m_line_iss.tellg();
|
||||
//std::istringstream::pos_type pos = m_line_iss.tellg();
|
||||
int j;
|
||||
while ((j = m_line_iss.get()) != std::char_traits < char >::eof())
|
||||
{
|
||||
|
||||
80
Parser.h
80
Parser.h
@ -12,18 +12,21 @@
|
||||
#include <istream> // std::istream
|
||||
#include "PHRQ_base.h"
|
||||
#include "Keywords.h"
|
||||
#include "PHRQ_io.h"
|
||||
|
||||
|
||||
|
||||
class CParser: public PHRQ_base
|
||||
{
|
||||
public:
|
||||
CParser(PHRQ_io *io=NULL);
|
||||
CParser(std::istream & input, PHRQ_io *io=NULL);
|
||||
CParser(std::istream & input, std::ostream & output, PHRQ_io *io=NULL);
|
||||
CParser(std::istream & input, std::ostream & output,
|
||||
std::ostream & error, PHRQ_io *io=NULL);
|
||||
//CParser(std::istream & input, std::ostream & output, PHRQ_io *io=NULL);
|
||||
//CParser(std::istream & input, std::ostream & output,
|
||||
// std::ostream & error, PHRQ_io *io=NULL);
|
||||
|
||||
virtual ~ CParser();
|
||||
|
||||
#ifdef SKIP
|
||||
enum LINE_TYPE
|
||||
{
|
||||
LT_EOF = -1,
|
||||
@ -32,7 +35,7 @@ class CParser: public PHRQ_base
|
||||
LT_KEYWORD = 3,
|
||||
LT_OPTION = 8
|
||||
};
|
||||
|
||||
#endif
|
||||
enum TOKEN_TYPE
|
||||
{
|
||||
TT_EMPTY = 2,
|
||||
@ -48,26 +51,6 @@ class CParser: public PHRQ_base
|
||||
FT_ERROR = 1
|
||||
};
|
||||
|
||||
// enum KEY_TYPE
|
||||
// {
|
||||
// KT_NONE = -1,
|
||||
// KT_END = 0,
|
||||
// KT_EOF = 1,
|
||||
// KT_SOLUTION_RAW = 5,
|
||||
// KT_EXCHANGE_RAW = 6,
|
||||
// KT_GASPHASE_RAW = 7,
|
||||
// KT_KINETICS_RAW = 8,
|
||||
// KT_PPASSEMBLAGE_RAW = 9,
|
||||
// KT_SSASSEMBLAGE_RAW = 10,
|
||||
// KT_SURFACE_RAW = 11,
|
||||
// KT_TEMPERATURE_RAW = 12,
|
||||
// KT_REACTION_RAW = 13,
|
||||
// KT_MIX_RAW = 14
|
||||
//#if defined MULTICHART
|
||||
// , KT_USER_GRAPH = 15
|
||||
//#endif
|
||||
// };
|
||||
|
||||
enum OPT_TYPE
|
||||
{
|
||||
OPT_DEFAULT = -4,
|
||||
@ -75,13 +58,13 @@ class CParser: public PHRQ_base
|
||||
OPT_KEYWORD = -2,
|
||||
OPT_EOF = -1
|
||||
};
|
||||
|
||||
#ifdef SKIP
|
||||
enum ONERROR_TYPE
|
||||
{
|
||||
OT_CONTINUE = 0,
|
||||
OT_STOP = 1
|
||||
};
|
||||
|
||||
#endif
|
||||
enum ECHO_OPTION
|
||||
{
|
||||
EO_NONE = 0,
|
||||
@ -116,7 +99,7 @@ class CParser: public PHRQ_base
|
||||
|
||||
Terminates if EOF and allow_eof == false.
|
||||
*/
|
||||
LINE_TYPE check_line(const std::string & str, bool allow_empty,
|
||||
PHRQ_io::LINE_TYPE check_line(const std::string & str, bool allow_empty,
|
||||
bool allow_eof, bool allow_keyword, bool print);
|
||||
|
||||
/**
|
||||
@ -133,14 +116,15 @@ class CParser: public PHRQ_base
|
||||
LT_OK,
|
||||
LT_OPTION
|
||||
*/
|
||||
LINE_TYPE get_line();
|
||||
PHRQ_io::LINE_TYPE get_line();
|
||||
PHRQ_io::LINE_TYPE get_line_phrq_io();
|
||||
|
||||
// bool check_key(const std::string::iterator ptr);
|
||||
bool check_key(std::string::iterator begin, std::string::iterator end);
|
||||
|
||||
STATUS_TYPE check_units(std::string & tot_units, bool alkalinity,
|
||||
bool check_compatibility,
|
||||
const std::string & default_units, bool print);
|
||||
//STATUS_TYPE check_units(std::string & tot_units, bool alkalinity,
|
||||
// bool check_compatibility,
|
||||
// const std::string & default_units, bool print);
|
||||
|
||||
|
||||
//KEY_TYPE next_keyword() const
|
||||
@ -183,15 +167,15 @@ class CParser: public PHRQ_base
|
||||
return m_line_iss;
|
||||
}
|
||||
int incr_input_error();
|
||||
std::ostream & get_output()
|
||||
{
|
||||
return m_output_stream;
|
||||
}
|
||||
//std::ostream & get_output()
|
||||
//{
|
||||
// return m_output_stream;
|
||||
//}
|
||||
int get_input_error()
|
||||
{
|
||||
return m_input_error;
|
||||
}
|
||||
|
||||
#ifdef SKIP
|
||||
std::istream::pos_type tellg()
|
||||
{
|
||||
return m_input_stream.tellg();
|
||||
@ -200,6 +184,7 @@ class CParser: public PHRQ_base
|
||||
{
|
||||
return m_input_stream.seekg(p);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@ -219,18 +204,18 @@ class CParser: public PHRQ_base
|
||||
TT_DIGIT
|
||||
TT_UNKNOWN
|
||||
*/
|
||||
static TOKEN_TYPE copy_token(std::string & token,
|
||||
static CParser::TOKEN_TYPE copy_token(std::string & token,
|
||||
std::string::iterator & begin,
|
||||
std::string::iterator & end);
|
||||
static CParser::TOKEN_TYPE copy_title(std::string & token,
|
||||
std::string::iterator & begin,
|
||||
std::string::iterator & end);
|
||||
static TOKEN_TYPE token_type(const std::string & token);
|
||||
static TOKEN_TYPE copy_token(std::string & token, std::istream & is);
|
||||
TOKEN_TYPE copy_token(std::string & token, std::istream::pos_type & pos);
|
||||
static CParser::TOKEN_TYPE token_type(const std::string & token);
|
||||
static CParser::TOKEN_TYPE copy_token(std::string & token, std::istream & is);
|
||||
CParser::TOKEN_TYPE copy_token(std::string & token, std::istream::pos_type & pos);
|
||||
bool get_true_false(std::istream::pos_type & pos, bool def);
|
||||
TOKEN_TYPE get_rest_of_line(std::string &token);
|
||||
static TOKEN_TYPE parse_delimited(std::string & source, std::string & result, const std::string& t);
|
||||
CParser::TOKEN_TYPE get_rest_of_line(std::string &token);
|
||||
static CParser::TOKEN_TYPE parse_delimited(std::string & source, std::string & result, const std::string& t);
|
||||
CParser::TOKEN_TYPE peek_token();
|
||||
|
||||
/**
|
||||
@ -294,23 +279,24 @@ class CParser: public PHRQ_base
|
||||
std::istream::pos_type & pos);
|
||||
|
||||
protected:
|
||||
LINE_TYPE get_logical_line();
|
||||
PHRQ_io::LINE_TYPE get_logical_line();
|
||||
|
||||
protected:
|
||||
std::istream & m_input_stream;
|
||||
std::ostream & m_output_stream;
|
||||
std::ostream & m_error_stream;
|
||||
//std::ostream & m_output_stream;
|
||||
//std::ostream & m_error_stream;
|
||||
int m_input_error;
|
||||
//KEY_TYPE m_next_keyword;
|
||||
Keywords::KEYWORDS m_next_keyword;
|
||||
std::string m_line;
|
||||
std::string m_line_save;
|
||||
std::istringstream m_line_iss;
|
||||
LINE_TYPE m_line_type;
|
||||
PHRQ_io::LINE_TYPE m_line_type;
|
||||
ECHO_OPTION echo_stream;
|
||||
ECHO_OPTION echo_file;
|
||||
std::string accumulated;
|
||||
bool accumulate;
|
||||
bool phrq_io_only;
|
||||
|
||||
};
|
||||
|
||||
|
||||
58
Phreeqc.cpp
58
Phreeqc.cpp
@ -186,13 +186,25 @@ size_t Phreeqc::list_components(std::list<std::string> &list_c)
|
||||
}
|
||||
|
||||
// irreversible reactions
|
||||
{
|
||||
std::map<int, cxxReaction>::const_iterator cit = Rxn_reaction_map.begin();
|
||||
for (; cit != Rxn_reaction_map.end(); cit++)
|
||||
{
|
||||
cxxReaction r_ptr(cit->second);
|
||||
reaction_calc(&r_ptr);
|
||||
accumulator.add_extensive(r_ptr.Get_elementList(), 1.0);
|
||||
}
|
||||
}
|
||||
#ifdef SKIP
|
||||
{
|
||||
for (i = 0; i < count_irrev; i++)
|
||||
{
|
||||
reaction_calc(&irrev[i]);
|
||||
cxxReaction entity(&irrev[i]);
|
||||
accumulator.add_extensive(entity.Get_elementList(), 1.0);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
// pure phases
|
||||
for (i = 0; i < count_pp_assemblage; i++)
|
||||
{
|
||||
@ -202,12 +214,15 @@ size_t Phreeqc::list_components(std::list<std::string> &list_c)
|
||||
}
|
||||
|
||||
// exchangers
|
||||
//for (i = 0; i < count_exchange; i++)
|
||||
//{
|
||||
// cxxExchange entity(&exchange[i], phrq_io);
|
||||
// entity.totalize();
|
||||
// accumulator.add_extensive(entity.Get_totals(), 1.0);
|
||||
//}
|
||||
#ifdef SKIP
|
||||
for (i = 0; i < count_exchange; i++)
|
||||
{
|
||||
cxxExchange entity(&exchange[i], phrq_io);
|
||||
entity.totalize();
|
||||
accumulator.add_extensive(entity.Get_totals(), 1.0);
|
||||
}
|
||||
#endif
|
||||
{
|
||||
std::map<int, cxxExchange>::const_iterator cit = Rxn_exchange_map.begin();
|
||||
for (; cit != Rxn_exchange_map.end(); cit++)
|
||||
{
|
||||
@ -215,6 +230,7 @@ size_t Phreeqc::list_components(std::list<std::string> &list_c)
|
||||
entity.totalize();
|
||||
accumulator.add_extensive(entity.Get_totals(), 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
// surfaces
|
||||
for (i = 0; i < count_surface; i++)
|
||||
@ -225,13 +241,23 @@ size_t Phreeqc::list_components(std::list<std::string> &list_c)
|
||||
}
|
||||
|
||||
// gas phases
|
||||
{
|
||||
std::map<int, cxxGasPhase>::const_iterator cit = Rxn_gas_phase_map.begin();
|
||||
for (; cit != Rxn_gas_phase_map.end(); cit++)
|
||||
{
|
||||
cxxGasPhase entity = cit->second;
|
||||
entity.totalize(this);
|
||||
accumulator.add_extensive(entity.Get_totals(), 1.0);
|
||||
}
|
||||
}
|
||||
#ifdef SKIP
|
||||
for (i = 0; i < count_gas_phase; i++)
|
||||
{
|
||||
cxxGasPhase entity(&gas_phase[i], phrq_io);
|
||||
entity.totalize(this);
|
||||
accumulator.add_extensive(entity.Get_totals(), 1.0);
|
||||
}
|
||||
|
||||
#endif
|
||||
// solid-solutions
|
||||
for (i = 0; i < count_s_s_assemblage; i++)
|
||||
{
|
||||
@ -320,7 +346,7 @@ void Phreeqc::init(void)
|
||||
max_pp_assemblage = MAX_PP_ASSEMBLAGE;
|
||||
//max_exchange = MAX_PP_ASSEMBLAGE;
|
||||
max_surface = MAX_PP_ASSEMBLAGE;
|
||||
max_gas_phase = MAX_PP_ASSEMBLAGE;
|
||||
//max_gas_phase = MAX_PP_ASSEMBLAGE;
|
||||
max_kinetics = MAX_PP_ASSEMBLAGE;
|
||||
max_s_s_assemblage = MAX_PP_ASSEMBLAGE;
|
||||
|
||||
@ -340,12 +366,12 @@ void Phreeqc::init(void)
|
||||
count_pp_assemblage = 0;
|
||||
//count_exchange = 0;
|
||||
count_surface = 0;
|
||||
count_gas_phase = 0;
|
||||
//count_gas_phase = 0;
|
||||
count_kinetics = 0;
|
||||
count_s_s_assemblage = 0;
|
||||
|
||||
count_elements = 0;
|
||||
count_irrev = 0;
|
||||
//count_irrev = 0;
|
||||
count_master = 0;
|
||||
//count_mix = 0;
|
||||
count_phases = 0;
|
||||
@ -392,7 +418,7 @@ void Phreeqc::init(void)
|
||||
pp_assemblage = 0;
|
||||
//exchange = 0;
|
||||
surface = 0;
|
||||
gas_phase = 0;
|
||||
//gas_phase = 0;
|
||||
kinetics = 0;
|
||||
s_s_assemblage = 0;
|
||||
cell_data = 0;
|
||||
@ -403,7 +429,7 @@ void Phreeqc::init(void)
|
||||
inverse = 0;
|
||||
count_inverse = 0;
|
||||
|
||||
irrev = 0;
|
||||
//irrev = 0;
|
||||
|
||||
line = 0;
|
||||
line_save = 0;
|
||||
@ -470,7 +496,7 @@ void Phreeqc::init(void)
|
||||
use.solution_in = FALSE;
|
||||
use.pp_assemblage_in = FALSE;
|
||||
use.mix_in = FALSE;
|
||||
use.irrev_in = FALSE;
|
||||
use.reaction_in = FALSE;
|
||||
/*
|
||||
* Initialize punch
|
||||
*/
|
||||
@ -661,7 +687,7 @@ void Phreeqc::init(void)
|
||||
copy_gas_phase.n_user = copy_gas_phase.start = copy_gas_phase.end = 0;
|
||||
copy_kinetics.n_user = copy_kinetics.start = copy_kinetics.end = 0;
|
||||
copy_mix.n_user = copy_mix.start = copy_mix.end = 0;
|
||||
copy_irrev.n_user = copy_irrev.start = copy_irrev.end = 0;
|
||||
copy_reaction.n_user = copy_reaction.start = copy_reaction.end = 0;
|
||||
copy_temperature.n_user = copy_temperature.start = copy_temperature.end = 0;
|
||||
copy_pressure.n_user = copy_pressure.start = copy_pressure.end = 0;
|
||||
|
||||
@ -712,7 +738,7 @@ void Phreeqc::init(void)
|
||||
dbg_surface = surface;
|
||||
dbg_pp_assemblage = pp_assemblage;
|
||||
dbg_kinetics = kinetics;
|
||||
dbg_irrev = irrev;
|
||||
//dbg_irrev = irrev;
|
||||
//dbg_mix = mix;
|
||||
dbg_master = master;
|
||||
calculating_deriv = FALSE;
|
||||
|
||||
93
Phreeqc.h
93
Phreeqc.h
@ -131,7 +131,7 @@ public:
|
||||
//int system_total_solids(struct exchange *exchange_ptr,
|
||||
int system_total_solids(cxxExchange *exchange_ptr,
|
||||
struct pp_assemblage *pp_assemblage_ptr,
|
||||
struct gas_phase *gas_phase_ptr,
|
||||
cxxGasPhase *gas_phase_ptr,
|
||||
struct s_s_assemblage *s_s_assemblage_ptr,
|
||||
struct surface *surface_ptr);
|
||||
|
||||
@ -570,7 +570,8 @@ public:
|
||||
int setup_slack(void);
|
||||
int setup_master_rxn(struct master **master_ptr_list,
|
||||
struct reaction **pe_rxn);
|
||||
LDBLE calc_PR(struct phase **phase_ptrs, int n_g, LDBLE P, LDBLE TK, LDBLE V_m);
|
||||
//LDBLE calc_PR(struct phase **phase_ptrs, int n_g, LDBLE P, LDBLE TK, LDBLE V_m);
|
||||
LDBLE calc_PR(std::vector<struct phase *> phase_ptrs, LDBLE P, LDBLE TK, LDBLE V_m);
|
||||
LDBLE calc_PR();
|
||||
int setup_pure_phases(void);
|
||||
int adjust_setup_pure_phases(void);
|
||||
@ -620,7 +621,7 @@ public:
|
||||
int print_alkalinity(void);
|
||||
int print_diffuse_layer(struct surface_charge *surface_charge_ptr);
|
||||
int print_eh(void);
|
||||
int print_irrev(void);
|
||||
int print_reaction(void);
|
||||
int print_kinetics(void);
|
||||
int print_mix(void);
|
||||
int print_pp_assemblage(void);
|
||||
@ -653,7 +654,6 @@ public:
|
||||
int read_t_c_only(char *ptr, LDBLE *t_c);
|
||||
int read_p_c_only(char *ptr, LDBLE * p_c);
|
||||
int read_omega_only(char *ptr, LDBLE *omega);
|
||||
//int read_delta_v_only(char *ptr, LDBLE * delta_v);
|
||||
int read_number_description(char *ptr, int *n_user, int *n_user_end,
|
||||
char **description, int allow_negative=FALSE);
|
||||
int check_key(const char *str);
|
||||
@ -703,8 +703,10 @@ public:
|
||||
int read_pure_phases(void);
|
||||
int read_rates(void);
|
||||
int read_reaction(void);
|
||||
int read_reaction_reactants(struct irrev *irrev_ptr);
|
||||
int read_reaction_steps(struct irrev *irrev_ptr);
|
||||
//int read_reaction_reactants(struct irrev *irrev_ptr);
|
||||
int read_reaction_reactants(cxxReaction *reaction_ptr);
|
||||
//int read_reaction_steps(struct irrev *irrev_ptr);
|
||||
int read_reaction_steps(cxxReaction *reaction_ptr);
|
||||
int read_solid_solutions(void);
|
||||
int read_temperature(void);
|
||||
int read_reaction_temps(struct temperature *temperature_ptr);
|
||||
@ -731,26 +733,26 @@ public:
|
||||
int cleanup_after_parser(CParser &parser);
|
||||
|
||||
// ReadClass.cxx
|
||||
|
||||
int read_generic(Keywords::KEYWORDS key);
|
||||
int read_solution_raw(void);
|
||||
int read_exchange_raw(void);
|
||||
//int read_exchange_raw(void);
|
||||
int read_surface_raw(void);
|
||||
int read_equilibrium_phases_raw(void);
|
||||
int read_kinetics_raw(void);
|
||||
int read_solid_solutions_raw(void);
|
||||
int read_gas_phase_raw(void);
|
||||
int read_reaction_raw(void);
|
||||
int read_mix_raw(void);
|
||||
int read_temperature_raw(void);
|
||||
//int read_gas_phase_raw(void);
|
||||
//int read_reaction_raw(void);
|
||||
//int read_mix_raw(void);
|
||||
//int read_temperature_raw(void);
|
||||
int read_dump(void);
|
||||
int read_solution_modify(void);
|
||||
int read_equilibrium_phases_modify(void);
|
||||
int read_exchange_modify(void);
|
||||
//int read_exchange_modify(void);
|
||||
int read_surface_modify(void);
|
||||
int read_solid_solutions_modify(void);
|
||||
int read_gas_phase_modify(void);
|
||||
//int read_gas_phase_modify(void);
|
||||
int read_kinetics_modify(void);
|
||||
int read_reaction_modify(void);
|
||||
//int read_reaction_modify(void);
|
||||
//int read_reaction_temperature_modify(void);
|
||||
int read_delete(void);
|
||||
int read_run_cells(void);
|
||||
@ -818,21 +820,24 @@ public:
|
||||
int xsolution_zero(void);
|
||||
//int add_exchange(struct exchange *exchange_ptr);
|
||||
int add_exchange(cxxExchange *exchange_ptr);
|
||||
int add_gas_phase(struct gas_phase *gas_phase_ptr);
|
||||
int add_gas_phase(cxxGasPhase *gas_phase_ptr);
|
||||
int add_kinetics(struct kinetics *kinetics_ptr);
|
||||
//int add_mix(struct mix *mix_ptr);
|
||||
int add_mix(cxxMix * mix_ptr);
|
||||
int add_pp_assemblage(struct pp_assemblage *pp_assemblage_ptr);
|
||||
int add_reaction(struct irrev *irrev_ptr, int step_number,
|
||||
//int add_reaction(struct irrev *irrev_ptr, int step_number,
|
||||
// LDBLE step_fraction);
|
||||
int add_reaction(cxxReaction *reaction_ptr, int step_number,
|
||||
LDBLE step_fraction);
|
||||
int add_s_s_assemblage(struct s_s_assemblage *s_s_assemblage_ptr);
|
||||
int add_solution(struct solution *solution_ptr, LDBLE extensive,
|
||||
LDBLE intensive);
|
||||
int add_surface(struct surface *surface_ptr);
|
||||
int check_pp_assemblage(struct pp_assemblage *pp_assemblage_ptr);
|
||||
int gas_phase_check(struct gas_phase *gas_phase_ptr);
|
||||
int gas_phase_check(cxxGasPhase *gas_phase_ptr);
|
||||
int pp_assemblage_check(struct pp_assemblage *pp_assemblage_ptr);
|
||||
int reaction_calc(struct irrev *irrev_ptr);
|
||||
//int reaction_calc(struct irrev *irrev_ptr);
|
||||
int reaction_calc(cxxReaction *reaction_ptr);
|
||||
int solution_check(void);
|
||||
int s_s_assemblage_check(struct s_s_assemblage *s_s_assemblage_ptr);
|
||||
|
||||
@ -878,8 +883,9 @@ protected:
|
||||
struct exchange *exchange_search(int n_user, int *n, int print);
|
||||
int exchange_sort(void);
|
||||
#endif
|
||||
static int gas_comp_compare(const void *ptr1, const void *ptr2);
|
||||
//static int gas_comp_compare(const void *ptr1, const void *ptr2);
|
||||
public:
|
||||
#ifdef SKIP
|
||||
struct gas_phase *gas_phase_alloc(void);
|
||||
struct gas_phase *gas_phase_bsearch(int k, int *n);
|
||||
protected:
|
||||
@ -901,12 +907,14 @@ public:
|
||||
int n_user_new);
|
||||
struct gas_phase *gas_phase_search(int n_user, int *n);
|
||||
int gas_phase_sort(void);
|
||||
#endif
|
||||
enum entity_type get_entity_enum(char *name);
|
||||
struct inverse *inverse_alloc(void);
|
||||
int inverse_delete(int i);
|
||||
static int inverse_isotope_compare(const void *ptr1, const void *ptr2);
|
||||
struct inverse *inverse_search(int n_user, int *n);
|
||||
int inverse_sort(void);
|
||||
#ifdef SKIP
|
||||
struct irrev *irrev_bsearch(int k, int *n);
|
||||
int irrev_copy(struct irrev *irrev_old_ptr, struct irrev *irrev_new_ptr,
|
||||
int n_user_new);
|
||||
@ -916,6 +924,7 @@ public:
|
||||
struct irrev *irrev_search(int n_user, int *n);
|
||||
int irrev_ptr_to_user(struct irrev *irrev_ptr_old, int n_user_new);
|
||||
int irrev_sort(void);
|
||||
#endif
|
||||
public:
|
||||
struct kinetics *kinetics_alloc(void);
|
||||
struct kinetics *kinetics_bsearch(int k, int *n);
|
||||
@ -1105,18 +1114,18 @@ public:
|
||||
int unknown_free(struct unknown *unknown_ptr);
|
||||
int entity_exists(char *name, int n_user);
|
||||
|
||||
static int exchange_compare_int(const void *ptr1, const void *ptr2);
|
||||
static int gas_phase_compare_int(const void *ptr1, const void *ptr2);
|
||||
//static int exchange_compare_int(const void *ptr1, const void *ptr2);
|
||||
//static int gas_phase_compare_int(const void *ptr1, const void *ptr2);
|
||||
static int inverse_compare(const void *ptr1, const void *ptr2);
|
||||
int inverse_free(struct inverse *inverse_ptr);
|
||||
static int irrev_compare(const void *ptr1, const void *ptr2);
|
||||
static int irrev_compare_int(const void *ptr1, const void *ptr2);
|
||||
//static int irrev_compare(const void *ptr1, const void *ptr2);
|
||||
//static int irrev_compare_int(const void *ptr1, const void *ptr2);
|
||||
static int kinetics_compare_int(const void *ptr1, const void *ptr2);
|
||||
int logk_init(struct logk *logk_ptr);
|
||||
static int master_compare_string(const void *ptr1, const void *ptr2);
|
||||
int master_free(struct master *master_ptr);
|
||||
static int mix_compare(const void *ptr1, const void *ptr2);
|
||||
static int mix_compare_int(const void *ptr1, const void *ptr2);
|
||||
//static int mix_compare(const void *ptr1, const void *ptr2);
|
||||
//static int mix_compare_int(const void *ptr1, const void *ptr2);
|
||||
struct phase *phase_alloc(void);
|
||||
static int phase_compare_string(const void *ptr1, const void *ptr2);
|
||||
int phase_free(struct phase *phase_ptr);
|
||||
@ -1132,8 +1141,8 @@ public:
|
||||
static int solution_compare_int(const void *ptr1, const void *ptr2);
|
||||
static int species_list_compare(const void *ptr1, const void *ptr2);
|
||||
static int surface_compare_int(const void *ptr1, const void *ptr2);
|
||||
static int temperature_compare(const void *ptr1, const void *ptr2);
|
||||
static int temperature_compare_int(const void *ptr1, const void *ptr2);
|
||||
//static int temperature_compare(const void *ptr1, const void *ptr2);
|
||||
//static int temperature_compare_int(const void *ptr1, const void *ptr2);
|
||||
static int rxn_token_temp_compare(const void *ptr1, const void *ptr2);
|
||||
int trxn_multiply(LDBLE coef);
|
||||
#ifdef PHREEQCI_GUI
|
||||
@ -1144,18 +1153,18 @@ public:
|
||||
#endif
|
||||
|
||||
// convert class to struct (structures.cpp)
|
||||
struct mix * cxxMix2mix(const cxxMix *mx);
|
||||
//struct mix * cxxMix2mix(const cxxMix *mx);
|
||||
struct kinetics *cxxKinetics2kinetics(const cxxKinetics * kin);
|
||||
struct kinetics_comp * cxxKineticsComp2kinetics_comp(const std::list < cxxKineticsComp > * el);
|
||||
//struct exchange * cxxExchange2exchange(const cxxExchange * ex);
|
||||
//struct exch_comp * cxxExchComp2exch_comp(const std::map < std::string, cxxExchComp > * el);
|
||||
struct master * Get_exch_master(const cxxExchComp * ec);
|
||||
struct gas_phase * cxxGasPhase2gas_phase(const cxxGasPhase * gp);
|
||||
struct gas_comp * cxxGasPhaseComp2gas_comp(const cxxGasPhase * gp);
|
||||
struct temperature * cxxTemperature2temperature(const cxxTemperature *temp);
|
||||
//struct master * Get_exch_master(const cxxExchComp * ec);
|
||||
//struct gas_phase * cxxGasPhase2gas_phase(const cxxGasPhase * gp);
|
||||
//struct gas_comp * cxxGasPhaseComp2gas_comp(const cxxGasPhase * gp);
|
||||
//struct temperature * cxxTemperature2temperature(const cxxTemperature *temp);
|
||||
struct pp_assemblage * cxxPPassemblage2pp_assemblage(const cxxPPassemblage * pp);
|
||||
struct pure_phase * cxxPPassemblageComp2pure_phase(const std::map < std::string, cxxPPassemblageComp > * ppc);
|
||||
struct irrev * cxxReaction2irrev(const cxxReaction * rxn);
|
||||
//struct irrev * cxxReaction2irrev(const cxxReaction * rxn);
|
||||
struct solution * cxxSolution2solution(const cxxSolution * sol);
|
||||
struct isotope * cxxSolutionIsotopeList2isotope(const cxxSolutionIsotopeList * il);
|
||||
struct s_s_assemblage * cxxSSassemblage2s_s_assemblage(const cxxSSassemblage * ss);
|
||||
@ -1331,10 +1340,10 @@ protected:
|
||||
Address Hash_multi(HashTable * Table, const char *Key);
|
||||
void ExpandTable_multi(HashTable * Table);
|
||||
public:
|
||||
//bool recursive_include(std::ifstream & input_stream, std::iostream & accumulated_stream);
|
||||
int main_method(int argc, char *argv[]);
|
||||
void set_phast(int);
|
||||
size_t list_components(std::list<std::string> &list_c);
|
||||
PHRQ_io * Get_phrq_io(void) {return this->phrq_io;}
|
||||
protected:
|
||||
void init(void);
|
||||
|
||||
@ -1426,7 +1435,7 @@ protected:
|
||||
struct copier copy_gas_phase;
|
||||
struct copier copy_kinetics;
|
||||
struct copier copy_mix;
|
||||
struct copier copy_irrev;
|
||||
struct copier copy_reaction;
|
||||
struct copier copy_temperature;
|
||||
struct copier copy_pressure;
|
||||
|
||||
@ -1450,17 +1459,21 @@ protected:
|
||||
/*----------------------------------------------------------------------
|
||||
* Irreversible reaction
|
||||
*---------------------------------------------------------------------- */
|
||||
|
||||
std::map<int, cxxReaction> Rxn_reaction_map;
|
||||
#ifdef SKIP
|
||||
struct irrev *irrev;
|
||||
struct irrev *dbg_irrev;
|
||||
int count_irrev;
|
||||
#endif
|
||||
/*----------------------------------------------------------------------
|
||||
* Gas phase
|
||||
*---------------------------------------------------------------------- */
|
||||
|
||||
std::map<int, cxxGasPhase> Rxn_gas_phase_map;
|
||||
#ifdef SKIP
|
||||
int count_gas_phase;
|
||||
int max_gas_phase;
|
||||
struct gas_phase *gas_phase;
|
||||
#endif
|
||||
/*----------------------------------------------------------------------
|
||||
* Solid solution
|
||||
*---------------------------------------------------------------------- */
|
||||
@ -2102,7 +2115,8 @@ public:
|
||||
std::vector<int> keycount; // used to mark keywords that have been read
|
||||
|
||||
#endif /* _INC_PHREEQC_H */
|
||||
|
||||
#ifndef _INC_ISFINITE_H
|
||||
#define _INC_ISFINITE_H
|
||||
/*********************************
|
||||
isfinite handling
|
||||
(Note: Should NOT be guarded)
|
||||
@ -2128,3 +2142,4 @@ public:
|
||||
#endif
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
49
Pressure.cxx
49
Pressure.cxx
@ -48,7 +48,7 @@ cxxPressure::read(CParser & parser)
|
||||
*/
|
||||
// Number and description set in read_reaction_pressure
|
||||
|
||||
CParser::LINE_TYPE lt;
|
||||
PHRQ_io::LINE_TYPE lt;
|
||||
bool done = false;
|
||||
for (;;)
|
||||
{
|
||||
@ -60,21 +60,21 @@ cxxPressure::read(CParser & parser)
|
||||
std::string token, str;
|
||||
lt = parser.check_line(str, false, true, true, true);
|
||||
|
||||
if (lt == CParser::LT_EMPTY ||
|
||||
lt == CParser::LT_KEYWORD ||
|
||||
lt == CParser::LT_EOF)
|
||||
if (lt == PHRQ_io::LT_EMPTY ||
|
||||
lt == PHRQ_io::LT_KEYWORD ||
|
||||
lt == PHRQ_io::LT_EOF)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (lt == CParser::LT_OPTION)
|
||||
if (lt == PHRQ_io::LT_OPTION)
|
||||
{
|
||||
this->error_msg("Expected numeric value for pressures.", CParser::OT_CONTINUE);
|
||||
this->error_msg("Expected numeric value for pressures.", PHRQ_io::OT_CONTINUE);
|
||||
break;
|
||||
}
|
||||
|
||||
if (done)
|
||||
{
|
||||
this->error_msg("Unknown input following equal increment definition.", CParser::OT_CONTINUE);
|
||||
this->error_msg("Unknown input following equal increment definition.", PHRQ_io::OT_CONTINUE);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@ cxxPressure::read(CParser & parser)
|
||||
if (!(iss >> d))
|
||||
{
|
||||
this->error_msg("Expected numeric value for pressures.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -165,18 +165,18 @@ cxxPressure::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out) con
|
||||
|
||||
s_oss << indent0;
|
||||
int n_user_local = (n_out != NULL) ? *n_out : this->n_user;
|
||||
s_oss << "REACTION_PRESSURE_RAW " << n_user_local << " " << this->description << std::endl;
|
||||
s_oss << "REACTION_PRESSURE_RAW " << n_user_local << " " << this->description << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "-count " << this->count << std::endl;
|
||||
s_oss << "-count " << this->count << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "-equal_increments " << this->equalIncrements << std::endl;
|
||||
s_oss << "-equal_increments " << this->equalIncrements << "\n";
|
||||
|
||||
// Temperature element and attributes
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "-pressures " << std::endl;
|
||||
s_oss << "-pressures " << "\n";
|
||||
{
|
||||
int i = 0;
|
||||
s_oss << indent2;
|
||||
@ -185,13 +185,13 @@ cxxPressure::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out) con
|
||||
{
|
||||
if (i++ == 5)
|
||||
{
|
||||
s_oss << std::endl;
|
||||
s_oss << "\n";
|
||||
s_oss << indent2;
|
||||
i = 0;
|
||||
}
|
||||
s_oss << *it << " ";
|
||||
}
|
||||
s_oss << std::endl;
|
||||
s_oss << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
@ -218,6 +218,7 @@ cxxPressure::read_raw(CParser & parser)
|
||||
bool useLastLine(false);
|
||||
|
||||
// Number and description set in read_reaction_pressure_raw
|
||||
this->read_number_description(parser);
|
||||
|
||||
opt_save = CParser::OPT_ERROR;
|
||||
bool equalIncrements_defined(false);
|
||||
@ -248,8 +249,8 @@ cxxPressure::read_raw(CParser & parser)
|
||||
case CParser::OPT_ERROR:
|
||||
opt = CParser::OPT_EOF;
|
||||
parser.error_msg("Unknown input in REACTION_PRESSURE_RAW keyword.",
|
||||
CParser::OT_CONTINUE);
|
||||
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
|
||||
useLastLine = false;
|
||||
break;
|
||||
|
||||
@ -266,7 +267,7 @@ cxxPressure::read_raw(CParser & parser)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for pressures.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -282,7 +283,7 @@ cxxPressure::read_raw(CParser & parser)
|
||||
{
|
||||
this->equalIncrements = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected boolean value for equalIncrements.", CParser::OT_CONTINUE);
|
||||
parser.error_msg("Expected boolean value for equalIncrements.", PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
opt_save = CParser::OPT_DEFAULT;
|
||||
useLastLine = false;
|
||||
@ -294,7 +295,7 @@ cxxPressure::read_raw(CParser & parser)
|
||||
{
|
||||
this->count = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected integer value for count.", CParser::OT_CONTINUE);
|
||||
parser.error_msg("Expected integer value for count.", PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
opt_save = CParser::OPT_DEFAULT;
|
||||
useLastLine = false;
|
||||
@ -309,13 +310,13 @@ cxxPressure::read_raw(CParser & parser)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Equal_increments not defined for REACTION_PRESSURE_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (count_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Count_temps not defined for REACTION_PRESSURE_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
}
|
||||
#ifdef SKIP
|
||||
@ -335,15 +336,15 @@ cxxPressure::dump_xml(std::ostream & s_oss, unsigned int indent) const const
|
||||
|
||||
// Temperature element and attributes
|
||||
s_oss << indent0;
|
||||
s_oss << "<temperature " << std::endl;
|
||||
s_oss << "<temperature " << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "pitzer_temperature_gammas=\"" << this->
|
||||
pitzer_temperature_gammas << "\"" << std::endl;
|
||||
pitzer_temperature_gammas << "\"" << "\n";
|
||||
|
||||
// components
|
||||
s_oss << indent1;
|
||||
s_oss << "<component " << std::endl;
|
||||
s_oss << "<component " << "\n";
|
||||
for (std::list < cxxPressureComp >::const_iterator it =
|
||||
temperatureComps.begin(); it != temperatureComps.end(); ++it)
|
||||
{
|
||||
|
||||
@ -23,11 +23,11 @@ class cxxPressure:public cxxNumKeyword
|
||||
int read(CParser & parser);
|
||||
void read_raw(CParser & parser);
|
||||
LDBLE Pressure_for_step(int step_number);
|
||||
std::vector<double> & Get_pressures(void) {return pressures;};
|
||||
std::vector<double> & Get_pressures(void) {return pressures;}
|
||||
int Get_count(void) const;
|
||||
void Set_count(int i) {count = i;};
|
||||
bool Get_equalIncrements(void) const {return equalIncrements;};
|
||||
void Set_equalIncrements(bool tf) {equalIncrements = tf;};
|
||||
void Set_count(int i) {count = i;}
|
||||
bool Get_equalIncrements(void) const {return equalIncrements;}
|
||||
void Set_equalIncrements(bool tf) {equalIncrements = tf;}
|
||||
|
||||
protected:
|
||||
std::vector < double >pressures;
|
||||
|
||||
56
Reaction.cxx
56
Reaction.cxx
@ -29,6 +29,7 @@ cxxReaction::cxxReaction(PHRQ_io *io)
|
||||
reactantList.type = cxxNameDouble::ND_NAME_COEF;
|
||||
elementList.type = cxxNameDouble::ND_ELT_MOLES;
|
||||
}
|
||||
#ifdef SKIP
|
||||
cxxReaction::cxxReaction(struct irrev *irrev_ptr, PHRQ_io *io)
|
||||
//
|
||||
// constructor for cxxReaction from struct irrev
|
||||
@ -64,7 +65,7 @@ elementList(irrev_ptr->elts)
|
||||
this->equalIncrements = false;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
cxxReaction::~cxxReaction()
|
||||
{
|
||||
}
|
||||
@ -86,15 +87,15 @@ cxxReaction::dump_xml(std::ostream & s_oss, unsigned int indent) const const
|
||||
|
||||
// Reaction element and attributes
|
||||
s_oss << indent0;
|
||||
s_oss << "<irrev " << std::endl;
|
||||
s_oss << "<irrev " << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "pitzer_irrev_gammas=\"" << this->
|
||||
pitzer_irrev_gammas << "\"" << std::endl;
|
||||
pitzer_irrev_gammas << "\"" << "\n";
|
||||
|
||||
// components
|
||||
s_oss << indent1;
|
||||
s_oss << "<component " << std::endl;
|
||||
s_oss << "<component " << "\n";
|
||||
for (std::list < cxxReactionComp >::const_iterator it =
|
||||
irrevComps.begin(); it != irrevComps.end(); ++it)
|
||||
{
|
||||
@ -122,21 +123,21 @@ cxxReaction::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out) con
|
||||
// Reaction element and attributes
|
||||
s_oss << indent0;
|
||||
int n_user_local = (n_out != NULL) ? *n_out : this->n_user;
|
||||
s_oss << "REACTION_RAW " << n_user_local << " " << this->description << std::endl;
|
||||
s_oss << "REACTION_RAW " << n_user_local << " " << this->description << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "-units " << this->units << std::endl;
|
||||
s_oss << "-units " << this->units << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "-reactant_list " << std::endl;
|
||||
s_oss << "-reactant_list " << "\n";
|
||||
this->reactantList.dump_raw(s_oss, indent + 2);
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "-element_list " << std::endl;
|
||||
s_oss << "-element_list " << "\n";
|
||||
this->elementList.dump_raw(s_oss, indent + 2);
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "-steps " << std::endl;
|
||||
s_oss << "-steps " << "\n";
|
||||
{
|
||||
int i = 0;
|
||||
s_oss << indent2;
|
||||
@ -145,20 +146,20 @@ cxxReaction::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out) con
|
||||
{
|
||||
if (i++ == 5)
|
||||
{
|
||||
s_oss << std::endl;
|
||||
s_oss << "\n";
|
||||
s_oss << indent2;
|
||||
i = 0;
|
||||
}
|
||||
s_oss << *it << " ";
|
||||
}
|
||||
s_oss << std::endl;
|
||||
s_oss << "\n";
|
||||
}
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "-equal_increments " << this->equalIncrements << std::endl;
|
||||
s_oss << "-equal_increments " << this->equalIncrements << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "-count_steps " << this->countSteps << std::endl;
|
||||
s_oss << "-count_steps " << this->countSteps << "\n";
|
||||
|
||||
|
||||
}
|
||||
@ -224,8 +225,8 @@ cxxReaction::read_raw(CParser & parser, const bool check)
|
||||
case CParser::OPT_ERROR:
|
||||
opt = CParser::OPT_EOF;
|
||||
parser.error_msg("Unknown input in IRREV_COMP_RAW keyword.",
|
||||
CParser::OT_CONTINUE);
|
||||
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
|
||||
useLastLine = false;
|
||||
break;
|
||||
|
||||
@ -245,7 +246,7 @@ cxxReaction::read_raw(CParser & parser, const bool check)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected reactant formula and coefficient.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
opt_save = 1;
|
||||
useLastLine = false;
|
||||
@ -257,7 +258,7 @@ cxxReaction::read_raw(CParser & parser, const bool check)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected element formula and coefficient.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
opt_save = 2;
|
||||
useLastLine = false;
|
||||
@ -277,7 +278,7 @@ cxxReaction::read_raw(CParser & parser, const bool check)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for steps.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -295,7 +296,7 @@ cxxReaction::read_raw(CParser & parser, const bool check)
|
||||
parser.incr_input_error();
|
||||
parser.
|
||||
error_msg("Expected boolean value for equalIncrements.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
opt_save = CParser::OPT_DEFAULT;
|
||||
useLastLine = false;
|
||||
@ -308,7 +309,7 @@ cxxReaction::read_raw(CParser & parser, const bool check)
|
||||
this->countSteps = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected integer value for countSteps.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
opt_save = CParser::OPT_DEFAULT;
|
||||
useLastLine = false;
|
||||
@ -325,20 +326,29 @@ cxxReaction::read_raw(CParser & parser, const bool check)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Units not defined for REACTION_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (equalIncrements_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.
|
||||
error_msg("Equal_increments not defined for REACTION_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (countSteps_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Count_steps not defined for REACTION_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
int cxxReaction::
|
||||
Get_actualSteps(void) const
|
||||
{
|
||||
if (equalIncrements)
|
||||
{
|
||||
return this->countSteps;
|
||||
}
|
||||
return (int) this->steps.size();
|
||||
}
|
||||
21
Reaction.h
21
Reaction.h
@ -15,20 +15,25 @@ class cxxReaction:public cxxNumKeyword
|
||||
|
||||
public:
|
||||
cxxReaction(PHRQ_io *io = NULL);
|
||||
cxxReaction(struct irrev *, PHRQ_io *io = NULL);
|
||||
//cxxReaction(struct irrev *, PHRQ_io *io = NULL);
|
||||
~cxxReaction();
|
||||
|
||||
//void dump_xml(std::ostream& os, unsigned int indent = 0)const;
|
||||
|
||||
void dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out=NULL) const;
|
||||
|
||||
void read_raw(CParser & parser, bool check);
|
||||
const cxxNameDouble &Get_elementList(void) const {return this->elementList;};
|
||||
const cxxNameDouble &Get_reactantList(void) const {return this->reactantList;};
|
||||
const std::vector < double > &Get_steps(void) const {return this->steps;};
|
||||
int Get_countSteps(void) const {return this->countSteps;};
|
||||
bool Get_equalIncrements(void) const {return this->equalIncrements;};
|
||||
const std::string &Get_units(void) const {return this->units;};
|
||||
void read_raw(CParser & parser, bool check=true);
|
||||
const cxxNameDouble &Get_elementList(void) const {return this->elementList;}
|
||||
void Set_elementList(cxxNameDouble nd) {this->elementList = nd;}
|
||||
cxxNameDouble &Get_reactantList(void) {return this->reactantList;}
|
||||
std::vector < double > &Get_steps(void) {return this->steps;}
|
||||
void Set_steps(std::vector<LDBLE> &v) {steps = v;}
|
||||
int Get_actualSteps(void) const;
|
||||
int Get_countSteps(void) const {return this->countSteps;}
|
||||
void Set_countSteps(int i) {countSteps = i;}
|
||||
bool Get_equalIncrements(void) const {return this->equalIncrements;}
|
||||
void Set_equalIncrements(bool tf) {equalIncrements = tf;}
|
||||
const std::string &Get_units(void) const {return this->units;}
|
||||
|
||||
void Set_units(const char * s)
|
||||
{
|
||||
|
||||
422
ReadClass.cxx
422
ReadClass.cxx
@ -69,10 +69,7 @@ read_solution_raw(void)
|
||||
pr.echo_input = save_echo_input;
|
||||
|
||||
std::istringstream iss_in(keywordLines);
|
||||
std::ostringstream oss_out;
|
||||
std::ostringstream oss_err;
|
||||
|
||||
CParser parser(iss_in, oss_out, oss_err, phrq_io);
|
||||
CParser parser(iss_in, phrq_io);
|
||||
assert(!reading_database());
|
||||
if (pr.echo_input == FALSE)
|
||||
{
|
||||
@ -119,7 +116,7 @@ read_solution_raw(void)
|
||||
if (return_value == KEYWORD) echo_msg(sformatf( "\t%s\n", line));
|
||||
return (return_value);
|
||||
}
|
||||
|
||||
#ifdef SKIP
|
||||
/* ---------------------------------------------------------------------- */
|
||||
int Phreeqc::
|
||||
read_exchange_raw(void)
|
||||
@ -163,10 +160,7 @@ read_exchange_raw(void)
|
||||
pr.echo_input = save_echo_input;
|
||||
|
||||
std::istringstream iss_in(keywordLines);
|
||||
std::ostringstream oss_out;
|
||||
std::ostringstream oss_err;
|
||||
|
||||
CParser parser(iss_in, oss_out, oss_err, phrq_io);
|
||||
CParser parser(iss_in, phrq_io);
|
||||
assert(!reading_database());
|
||||
if (pr.echo_input == FALSE)
|
||||
{
|
||||
@ -194,6 +188,7 @@ read_exchange_raw(void)
|
||||
Utilities::Rxn_copy(Rxn_exchange_map, n_user, i);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SKIP
|
||||
//struct exchange *exchange_ptr = ex.cxxExchange2exchange(PHREEQC_THIS);
|
||||
struct exchange *exchange_ptr = cxxExchange2exchange(&ex);
|
||||
@ -227,7 +222,7 @@ read_exchange_raw(void)
|
||||
if (return_value == KEYWORD) echo_msg(sformatf( "\t%s\n", line));
|
||||
return (return_value);
|
||||
}
|
||||
|
||||
#endif
|
||||
/* ---------------------------------------------------------------------- */
|
||||
int Phreeqc::
|
||||
read_surface_raw(void)
|
||||
@ -271,10 +266,7 @@ read_surface_raw(void)
|
||||
pr.echo_input = save_echo_input;
|
||||
|
||||
std::istringstream iss_in(keywordLines);
|
||||
std::ostringstream oss_out;
|
||||
std::ostringstream oss_err;
|
||||
|
||||
CParser parser(iss_in, oss_out, oss_err, phrq_io);
|
||||
CParser parser(iss_in, phrq_io);
|
||||
assert(!reading_database());
|
||||
if (pr.echo_input == FALSE)
|
||||
{
|
||||
@ -367,10 +359,7 @@ read_equilibrium_phases_raw(void)
|
||||
pr.echo_input = save_echo_input;
|
||||
|
||||
std::istringstream iss_in(keywordLines);
|
||||
std::ostringstream oss_out;
|
||||
std::ostringstream oss_err;
|
||||
|
||||
CParser parser(iss_in, oss_out, oss_err, phrq_io);
|
||||
CParser parser(iss_in, phrq_io);
|
||||
assert(!reading_database());
|
||||
if (pr.echo_input == FALSE)
|
||||
{
|
||||
@ -464,10 +453,7 @@ read_kinetics_raw(void)
|
||||
pr.echo_input = save_echo_input;
|
||||
|
||||
std::istringstream iss_in(keywordLines);
|
||||
std::ostringstream oss_out;
|
||||
std::ostringstream oss_err;
|
||||
|
||||
CParser parser(iss_in, oss_out, oss_err, phrq_io);
|
||||
CParser parser(iss_in, phrq_io);
|
||||
assert(!reading_database());
|
||||
if (pr.echo_input == FALSE)
|
||||
{
|
||||
@ -560,10 +546,7 @@ read_solid_solutions_raw(void)
|
||||
pr.echo_input = save_echo_input;
|
||||
|
||||
std::istringstream iss_in(keywordLines);
|
||||
std::ostringstream oss_out;
|
||||
std::ostringstream oss_err;
|
||||
|
||||
CParser parser(iss_in, oss_out, oss_err, phrq_io);
|
||||
CParser parser(iss_in, phrq_io);
|
||||
assert(!reading_database());
|
||||
if (pr.echo_input == FALSE)
|
||||
{
|
||||
@ -614,7 +597,76 @@ read_solid_solutions_raw(void)
|
||||
if (return_value == KEYWORD) echo_msg(sformatf( "\t%s\n", line));
|
||||
return (return_value);
|
||||
}
|
||||
#ifdef SKIP
|
||||
/* ---------------------------------------------------------------------- */
|
||||
int Phreeqc::
|
||||
read_gas_phase_raw(void)
|
||||
/* ---------------------------------------------------------------------- */
|
||||
{
|
||||
/*
|
||||
* Reads GAS_PHASE_RAW data block
|
||||
*
|
||||
* Arguments:
|
||||
* none
|
||||
*
|
||||
* Returns:
|
||||
* KEYWORD if keyword encountered, input_error may be incremented if
|
||||
* a keyword is encountered in an unexpected position
|
||||
* EOF if eof encountered while reading mass balance concentrations
|
||||
* ERROR if error occurred reading data
|
||||
*
|
||||
*/
|
||||
int return_value;
|
||||
/*
|
||||
* Accumulate lines in std string
|
||||
*/
|
||||
std::string keywordLines("");
|
||||
|
||||
keywordLines.append(line);
|
||||
keywordLines.append("\n");
|
||||
/*
|
||||
* Read additonal lines
|
||||
*/
|
||||
int save_echo_input = pr.echo_input;
|
||||
pr.echo_input = FALSE;
|
||||
for (;;)
|
||||
{
|
||||
return_value = check_line("gas_phase_raw", TRUE, TRUE, TRUE, FALSE);
|
||||
/* empty, eof, keyword, print */
|
||||
if (return_value == EOF || return_value == KEYWORD)
|
||||
break;
|
||||
keywordLines.append(line);
|
||||
keywordLines.append("\n");
|
||||
}
|
||||
pr.echo_input = save_echo_input;
|
||||
|
||||
std::istringstream iss_in(keywordLines);
|
||||
CParser parser(iss_in, phrq_io);
|
||||
assert(!reading_database());
|
||||
if (pr.echo_input == FALSE)
|
||||
{
|
||||
parser.set_echo_file(CParser::EO_NONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
parser.set_echo_file(CParser::EO_NOKEYWORDS);
|
||||
}
|
||||
//For testing, need to read line to get started
|
||||
std::vector < std::string > vopts;
|
||||
std::istream::pos_type next_char;
|
||||
parser.get_option(vopts, next_char);
|
||||
|
||||
cxxGasPhase entity(phrq_io);
|
||||
entity.read_raw(parser);
|
||||
|
||||
Rxn_gas_phase_map[entity.Get_n_user()] = entity;
|
||||
|
||||
// Need to output the next keyword
|
||||
if (return_value == KEYWORD) echo_msg(sformatf( "\t%s\n", line));
|
||||
return (return_value);
|
||||
}
|
||||
#endif
|
||||
#ifdef SKIP
|
||||
/* ---------------------------------------------------------------------- */
|
||||
int Phreeqc::
|
||||
read_gas_phase_raw(void)
|
||||
@ -709,7 +761,8 @@ read_gas_phase_raw(void)
|
||||
if (return_value == KEYWORD) echo_msg(sformatf( "\t%s\n", line));
|
||||
return (return_value);
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef SKIP
|
||||
/* ---------------------------------------------------------------------- */
|
||||
int Phreeqc::
|
||||
read_reaction_raw(void)
|
||||
@ -753,10 +806,8 @@ read_reaction_raw(void)
|
||||
pr.echo_input = save_echo_input;
|
||||
|
||||
std::istringstream iss_in(keywordLines);
|
||||
std::ostringstream oss_out;
|
||||
std::ostringstream oss_err;
|
||||
|
||||
CParser parser(iss_in, oss_out, oss_err, phrq_io);
|
||||
CParser parser(iss_in, phrq_io);
|
||||
assert(!reading_database());
|
||||
if (pr.echo_input == FALSE)
|
||||
{
|
||||
@ -805,6 +856,7 @@ read_reaction_raw(void)
|
||||
if (return_value == KEYWORD) echo_msg(sformatf( "\t%s\n", line));
|
||||
return (return_value);
|
||||
}
|
||||
#endif
|
||||
#ifdef SKIP
|
||||
/* ---------------------------------------------------------------------- */
|
||||
int Phreeqc::
|
||||
@ -926,9 +978,7 @@ read_dump(void)
|
||||
*/
|
||||
std::istringstream iss_in;
|
||||
return_value = streamify_to_next_keyword(iss_in);
|
||||
std::ostringstream oss_out;
|
||||
std::ostringstream oss_err;
|
||||
CParser parser(iss_in, oss_out, oss_err, phrq_io);
|
||||
CParser parser(iss_in, phrq_io);
|
||||
assert(!reading_database());
|
||||
|
||||
//For testing, need to read line to get started
|
||||
@ -976,9 +1026,7 @@ read_delete(void)
|
||||
*/
|
||||
std::istringstream iss_in;
|
||||
return_value = streamify_to_next_keyword(iss_in);
|
||||
std::ostringstream oss_out;
|
||||
std::ostringstream oss_err;
|
||||
CParser parser(iss_in, oss_out, oss_err, phrq_io);
|
||||
CParser parser(iss_in, phrq_io);
|
||||
assert(!reading_database());
|
||||
|
||||
//For testing, need to read line to get started
|
||||
@ -1028,9 +1076,7 @@ read_run_cells(void)
|
||||
*/
|
||||
std::istringstream iss_in;
|
||||
return_value = streamify_to_next_keyword(iss_in);
|
||||
std::ostringstream oss_out;
|
||||
std::ostringstream oss_err;
|
||||
CParser parser(iss_in, oss_out, oss_err, phrq_io);
|
||||
CParser parser(iss_in, phrq_io);
|
||||
assert(!reading_database());
|
||||
|
||||
//For testing, need to read line to get started
|
||||
@ -1100,9 +1146,7 @@ read_solution_modify(void)
|
||||
*/
|
||||
std::istringstream iss_in;
|
||||
return_value = streamify_to_next_keyword(iss_in);
|
||||
std::ostringstream oss_out;
|
||||
std::ostringstream oss_err;
|
||||
CParser parser(iss_in, oss_out, oss_err, phrq_io);
|
||||
CParser parser(iss_in, phrq_io);
|
||||
assert(!reading_database());
|
||||
|
||||
//For testing, need to read line to get started
|
||||
@ -1199,9 +1243,7 @@ read_equilibrium_phases_modify(void)
|
||||
*/
|
||||
std::istringstream iss_in;
|
||||
return_value = streamify_to_next_keyword(iss_in);
|
||||
std::ostringstream oss_out;
|
||||
std::ostringstream oss_err;
|
||||
CParser parser(iss_in, oss_out, oss_err, phrq_io);
|
||||
CParser parser(iss_in, phrq_io);
|
||||
assert(!reading_database());
|
||||
|
||||
//For testing, need to read line to get started
|
||||
@ -1248,6 +1290,7 @@ read_equilibrium_phases_modify(void)
|
||||
if (return_value == OPTION_KEYWORD) echo_msg(sformatf( "\t%s\n", line));
|
||||
return (return_value);
|
||||
}
|
||||
#ifdef SKIP
|
||||
/* ---------------------------------------------------------------------- */
|
||||
int Phreeqc::
|
||||
read_exchange_modify(void)
|
||||
@ -1293,9 +1336,7 @@ read_exchange_modify(void)
|
||||
*/
|
||||
std::istringstream iss_in;
|
||||
return_value = streamify_to_next_keyword(iss_in);
|
||||
std::ostringstream oss_out;
|
||||
std::ostringstream oss_err;
|
||||
CParser parser(iss_in, oss_out, oss_err, phrq_io);
|
||||
CParser parser(iss_in, phrq_io);
|
||||
assert(!reading_database());
|
||||
|
||||
//For testing, need to read line to get started
|
||||
@ -1392,6 +1433,7 @@ read_exchange_modify(void)
|
||||
if (return_value == OPTION_KEYWORD) echo_msg(sformatf( "\t%s\n", line));
|
||||
return (return_value);
|
||||
}
|
||||
#endif
|
||||
/* ---------------------------------------------------------------------- */
|
||||
int Phreeqc::
|
||||
read_surface_modify(void)
|
||||
@ -1436,9 +1478,7 @@ read_surface_modify(void)
|
||||
*/
|
||||
std::istringstream iss_in;
|
||||
return_value = streamify_to_next_keyword(iss_in);
|
||||
std::ostringstream oss_out;
|
||||
std::ostringstream oss_err;
|
||||
CParser parser(iss_in, oss_out, oss_err, phrq_io);
|
||||
CParser parser(iss_in, phrq_io);
|
||||
assert(!reading_database());
|
||||
|
||||
//For testing, need to read line to get started
|
||||
@ -1526,9 +1566,7 @@ read_solid_solutions_modify(void)
|
||||
*/
|
||||
std::istringstream iss_in;
|
||||
return_value = streamify_to_next_keyword(iss_in);
|
||||
std::ostringstream oss_out;
|
||||
std::ostringstream oss_err;
|
||||
CParser parser(iss_in, oss_out, oss_err, phrq_io);
|
||||
CParser parser(iss_in, phrq_io);
|
||||
assert(!reading_database());
|
||||
|
||||
//For testing, need to read line to get started
|
||||
@ -1572,6 +1610,86 @@ read_solid_solutions_modify(void)
|
||||
if (return_value == OPTION_KEYWORD) echo_msg(sformatf( "\t%s\n", line));
|
||||
return (return_value);
|
||||
}
|
||||
#ifdef SKIP
|
||||
/* ---------------------------------------------------------------------- */
|
||||
int Phreeqc::
|
||||
read_gas_phase_modify(void)
|
||||
/* ---------------------------------------------------------------------- */
|
||||
{
|
||||
/*
|
||||
* Reads GAS_PHASE_MODIFY data block
|
||||
*
|
||||
* Arguments:
|
||||
* none
|
||||
*
|
||||
* Returns:
|
||||
* KEYWORD if keyword encountered, input_error may be incremented if
|
||||
* a keyword is encountered in an unexpected position
|
||||
* EOF if eof encountered while reading mass balance concentrations
|
||||
* ERROR if error occurred reading data
|
||||
*
|
||||
*/
|
||||
int return_value;
|
||||
// find gas_phase number
|
||||
char token[MAX_LENGTH];
|
||||
char *next;
|
||||
int l, n_user;
|
||||
next = line;
|
||||
copy_token(token, &next, &l);
|
||||
if (copy_token(token, &next, &l) != DIGIT)
|
||||
{
|
||||
input_error++;
|
||||
error_string = sformatf( "Expected gas_phase number following GAS_PHASE_MODIFY.\n%s\n", line_save);
|
||||
error_msg(error_string, CONTINUE);
|
||||
std::istringstream iss_in;
|
||||
return_value = streamify_to_next_keyword(iss_in);
|
||||
return (ERROR);
|
||||
}
|
||||
else
|
||||
{
|
||||
sscanf(token,"%d", &n_user);
|
||||
}
|
||||
/*
|
||||
* Make parser
|
||||
*/
|
||||
std::istringstream iss_in;
|
||||
return_value = streamify_to_next_keyword(iss_in);
|
||||
CParser parser(iss_in, phrq_io);
|
||||
assert(!reading_database());
|
||||
|
||||
//For testing, need to read line to get started
|
||||
parser.set_echo_file(CParser::EO_NONE);
|
||||
std::vector < std::string > vopts;
|
||||
std::istream::pos_type next_char;
|
||||
parser.get_option(vopts, next_char);
|
||||
|
||||
if (pr.echo_input == FALSE)
|
||||
{
|
||||
parser.set_echo_file(CParser::EO_NONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
parser.set_echo_file(CParser::EO_NOKEYWORDS);
|
||||
}
|
||||
|
||||
cxxGasPhase *gas_phase_ptr = Utilities::Rxn_find(Rxn_gas_phase_map, n_user);
|
||||
if (gas_phase_ptr == NULL)
|
||||
{
|
||||
input_error++;
|
||||
error_string = sformatf( "Gas_phase %d not found for GAS_PHASE_MODIFY.\n", n_user);
|
||||
error_msg(error_string, CONTINUE);
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
// read entity
|
||||
gas_phase_ptr->read_raw(parser, false);
|
||||
|
||||
// Need to output the next keyword
|
||||
if (return_value == OPTION_KEYWORD) echo_msg(sformatf( "\t%s\n", line));
|
||||
return (return_value);
|
||||
}
|
||||
#endif
|
||||
#ifdef SKIP
|
||||
/* ---------------------------------------------------------------------- */
|
||||
int Phreeqc::
|
||||
read_gas_phase_modify(void)
|
||||
@ -1660,6 +1778,7 @@ read_gas_phase_modify(void)
|
||||
if (return_value == OPTION_KEYWORD) echo_msg(sformatf( "\t%s\n", line));
|
||||
return (return_value);
|
||||
}
|
||||
#endif
|
||||
/* ---------------------------------------------------------------------- */
|
||||
int Phreeqc::
|
||||
read_kinetics_modify(void)
|
||||
@ -1704,9 +1823,7 @@ read_kinetics_modify(void)
|
||||
*/
|
||||
std::istringstream iss_in;
|
||||
return_value = streamify_to_next_keyword(iss_in);
|
||||
std::ostringstream oss_out; // ??
|
||||
std::ostringstream oss_err; // ??
|
||||
CParser parser(iss_in, oss_out, oss_err, phrq_io);
|
||||
CParser parser(iss_in, phrq_io);
|
||||
assert(!reading_database());
|
||||
|
||||
//For testing, need to read line to get started
|
||||
@ -1750,6 +1867,7 @@ read_kinetics_modify(void)
|
||||
if (return_value == OPTION_KEYWORD) echo_msg(sformatf( "\t%s\n", line));
|
||||
return (return_value);
|
||||
}
|
||||
#ifdef SKIP
|
||||
/* ---------------------------------------------------------------------- */
|
||||
int Phreeqc::
|
||||
read_reaction_modify(void)
|
||||
@ -1793,9 +1911,7 @@ read_reaction_modify(void)
|
||||
*/
|
||||
std::istringstream iss_in;
|
||||
return_value = streamify_to_next_keyword(iss_in);
|
||||
std::ostringstream oss_out;
|
||||
std::ostringstream oss_err;
|
||||
CParser parser(iss_in, oss_out, oss_err, phrq_io);
|
||||
CParser parser(iss_in, phrq_io);
|
||||
assert(!reading_database());
|
||||
|
||||
//For testing, need to read line to get started
|
||||
@ -1838,6 +1954,7 @@ read_reaction_modify(void)
|
||||
if (return_value == OPTION_KEYWORD) echo_msg(sformatf( "\t%s\n", line));
|
||||
return (return_value);
|
||||
}
|
||||
#endif
|
||||
/* ---------------------------------------------------------------------- */
|
||||
int Phreeqc::
|
||||
streamify_to_next_keyword(std::istringstream & lines)
|
||||
@ -2075,6 +2192,22 @@ delete_entities(void)
|
||||
}
|
||||
|
||||
// gas_phases
|
||||
if (delete_info.Get_gas_phase().Get_defined())
|
||||
{
|
||||
if (delete_info.Get_gas_phase().Get_numbers().size() == 0)
|
||||
{
|
||||
Rxn_gas_phase_map.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::set < int >::iterator it;
|
||||
for (it = delete_info.Get_gas_phase().Get_numbers().begin(); it != delete_info.Get_gas_phase().Get_numbers().end(); it++)
|
||||
{
|
||||
Rxn_gas_phase_map.erase(*it);
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef SKIP
|
||||
if (delete_info.Get_gas_phase().Get_defined())
|
||||
{
|
||||
if (delete_info.Get_gas_phase().Get_numbers().size() == 0)
|
||||
@ -2096,7 +2229,7 @@ delete_entities(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
// kineticss
|
||||
if (delete_info.Get_kinetics().Get_defined())
|
||||
{
|
||||
@ -2159,6 +2292,22 @@ delete_entities(void)
|
||||
}
|
||||
#endif
|
||||
// reactions
|
||||
if (delete_info.Get_reaction().Get_defined())
|
||||
{
|
||||
if (delete_info.Get_reaction().Get_numbers().size() == 0)
|
||||
{
|
||||
Rxn_reaction_map.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::set < int >::iterator it;
|
||||
for (it = delete_info.Get_reaction().Get_numbers().begin(); it != delete_info.Get_reaction().Get_numbers().end(); it++)
|
||||
{
|
||||
Rxn_reaction_map.erase(*it);
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef SKIP
|
||||
if (delete_info.Get_reaction().Get_defined())
|
||||
{
|
||||
if (delete_info.Get_reaction().Get_numbers().size() == 0)
|
||||
@ -2180,6 +2329,7 @@ delete_entities(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// temperatures
|
||||
if (delete_info.Get_temperature().Get_defined())
|
||||
{
|
||||
@ -2261,10 +2411,11 @@ run_as_cells(void)
|
||||
*/
|
||||
dup_print("Beginning of batch-reaction calculations.", TRUE);
|
||||
count_steps = 1;
|
||||
if (use.irrev_in == TRUE && use.irrev_ptr != NULL)
|
||||
if (use.reaction_in == TRUE && use.reaction_ptr != NULL)
|
||||
{
|
||||
if (abs(use.irrev_ptr->count_steps) > count_steps)
|
||||
count_steps = abs(use.irrev_ptr->count_steps);
|
||||
int count = ((cxxReaction *) use.reaction_ptr)->Get_actualSteps();
|
||||
if (count > count_steps)
|
||||
count_steps = count;
|
||||
}
|
||||
if (use.kinetics_in == TRUE && use.kinetics_ptr != NULL)
|
||||
{
|
||||
@ -2593,6 +2744,27 @@ dump_ostream(std::ostream& os)
|
||||
}
|
||||
|
||||
// gas_phases
|
||||
if (dump_info.Get_bool_gas_phase())
|
||||
{
|
||||
if (dump_info.Get_gas_phase().size() == 0)
|
||||
{
|
||||
Utilities::Rxn_dump_raw(Rxn_gas_phase_map, os, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::set < int >::iterator it;
|
||||
for (it = dump_info.Get_gas_phase().begin(); it != dump_info.Get_gas_phase().end(); it++)
|
||||
{
|
||||
cxxGasPhase *p = Utilities::Rxn_find(Rxn_gas_phase_map, *it);
|
||||
|
||||
if (p != NULL)
|
||||
{
|
||||
p->dump_raw(os, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef SKIP
|
||||
if (dump_info.Get_bool_gas_phase())
|
||||
{
|
||||
if (dump_info.Get_gas_phase().size() == 0)
|
||||
@ -2617,7 +2789,7 @@ dump_ostream(std::ostream& os)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
// kinetics
|
||||
if (dump_info.Get_bool_kinetics())
|
||||
{
|
||||
@ -2692,6 +2864,27 @@ dump_ostream(std::ostream& os)
|
||||
}
|
||||
#endif
|
||||
// reaction
|
||||
if (dump_info.Get_bool_reaction())
|
||||
{
|
||||
if (dump_info.Get_reaction().size() == 0)
|
||||
{
|
||||
Utilities::Rxn_dump_raw(Rxn_reaction_map, os, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::set < int >::iterator it;
|
||||
for (it = dump_info.Get_reaction().begin(); it != dump_info.Get_reaction().end(); it++)
|
||||
{
|
||||
cxxReaction *p = Utilities::Rxn_find(Rxn_reaction_map, *it);
|
||||
|
||||
if (p != NULL)
|
||||
{
|
||||
p->dump_raw(os, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef SKIP
|
||||
if (dump_info.Get_bool_reaction())
|
||||
{
|
||||
if (dump_info.Get_reaction().size() == 0)
|
||||
@ -2716,7 +2909,7 @@ dump_ostream(std::ostream& os)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
// temperature
|
||||
if (dump_info.Get_bool_temperature())
|
||||
{
|
||||
@ -2760,10 +2953,10 @@ dump_ostream(std::ostream& os)
|
||||
}
|
||||
}
|
||||
// Turn off any reaction calculation
|
||||
os << "USE mix none" << std::endl;
|
||||
os << "USE reaction none" << std::endl;
|
||||
os << "USE reaction_temperature none" << std::endl;
|
||||
os << "USE reaction_pressure none" << std::endl;
|
||||
os << "USE mix none" << "\n";
|
||||
os << "USE reaction none" << "\n";
|
||||
os << "USE reaction_temperature none" << "\n";
|
||||
os << "USE reaction_pressure none" << "\n";
|
||||
|
||||
// Turn off dump until next read
|
||||
dump_info.SetAll(false);
|
||||
@ -2794,9 +2987,10 @@ read_user_graph_handler(void)
|
||||
*/
|
||||
std::istringstream iss_in;
|
||||
return_value = streamify_to_next_keyword(iss_in);
|
||||
std::ostringstream oss_out;
|
||||
std::ostringstream oss_err;
|
||||
CParser parser(iss_in, oss_out, oss_err, phrq_io);
|
||||
//std::ostringstream oss_out;
|
||||
//std::ostringstream oss_err;
|
||||
//CParser parser(iss_in, oss_out, oss_err, phrq_io);
|
||||
CParser parser(iss_in, phrq_io);
|
||||
|
||||
//For testing, need to read line to get started
|
||||
std::vector < std::string > vopts;
|
||||
@ -2821,3 +3015,85 @@ read_user_graph_handler(void)
|
||||
return (return_value);
|
||||
}
|
||||
#endif
|
||||
#ifdef SKIP
|
||||
/* ---------------------------------------------------------------------- */
|
||||
int Phreeqc::
|
||||
read_generic(Keywords::KEYWORDS key)
|
||||
/* ---------------------------------------------------------------------- */
|
||||
{
|
||||
/*
|
||||
* Reads _raw and _modify data blocks
|
||||
*
|
||||
* Arguments:
|
||||
* none
|
||||
*
|
||||
* Returns:
|
||||
* KEYWORD if keyword encountered, input_error may be incremented if
|
||||
* a keyword is encountered in an unexpected position
|
||||
* EOF if eof encountered while reading mass balance concentrations
|
||||
* ERROR if error occurred reading data
|
||||
*
|
||||
*/
|
||||
int return_value;
|
||||
|
||||
std::string token;
|
||||
char *next;
|
||||
int n_user;
|
||||
next = line;
|
||||
copy_token(token, &next);
|
||||
if (copy_token(token, &next) != DIGIT)
|
||||
{
|
||||
input_error++;
|
||||
error_string = sformatf( "Expected reactant number following keyword.\n%s\n", line_save);
|
||||
error_msg(error_string, CONTINUE);
|
||||
std::istringstream iss_in;
|
||||
return_value = streamify_to_next_keyword(iss_in);
|
||||
return (ERROR);
|
||||
}
|
||||
else
|
||||
{
|
||||
sscanf(token.c_str(),"%d", &n_user);
|
||||
}
|
||||
/*
|
||||
* Make parser
|
||||
*/
|
||||
std::istringstream iss_in;
|
||||
return_value = streamify_to_next_keyword(iss_in);
|
||||
CParser parser(iss_in, phrq_io);
|
||||
assert(!reading_database());
|
||||
|
||||
//For testing, need to read line to get started
|
||||
parser.set_echo_file(CParser::EO_NONE);
|
||||
std::vector < std::string > vopts;
|
||||
std::istream::pos_type next_char;
|
||||
parser.get_option(vopts, next_char);
|
||||
|
||||
if (pr.echo_input == FALSE)
|
||||
{
|
||||
parser.set_echo_file(CParser::EO_NONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
parser.set_echo_file(CParser::EO_NOKEYWORDS);
|
||||
}
|
||||
switch (key)
|
||||
{
|
||||
case Keywords::KEY_REACTION_PRESSURE_RAW:
|
||||
{
|
||||
cxxPressure entity(this->phrq_io);
|
||||
entity.read_raw(parser);
|
||||
if (entity.Get_base_error_count() == 0)
|
||||
{
|
||||
Rxn_pressure_map[n_user] = entity;
|
||||
}
|
||||
// Make copies if necessary
|
||||
Utilities::Rxn_copies(Rxn_pressure_map, entity.Get_n_user(), entity.Get_n_user_end());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Need to output the next keyword
|
||||
if (return_value == OPTION_KEYWORD) echo_msg(sformatf( "\t%s\n", line));
|
||||
return (return_value);
|
||||
}
|
||||
#endif
|
||||
@ -90,14 +90,14 @@ cxxSSassemblage::dump_xml(std::ostream & s_oss, unsigned int indent) const const
|
||||
|
||||
// SSassemblage element and attributes
|
||||
s_oss << indent0;
|
||||
s_oss << "<EQUILIBRIUM_PHASES " << std::endl;
|
||||
s_oss << "<EQUILIBRIUM_PHASES " << "\n";
|
||||
|
||||
// eltList
|
||||
this->eltList.dump_xml(s_oss, indent + 1);
|
||||
|
||||
// ssAssemblageSSs
|
||||
s_oss << indent1;
|
||||
s_oss << "<pure_phases " << std::endl;
|
||||
s_oss << "<pure_phases " << "\n";
|
||||
for (std::list < cxxSSassemblageSS >::const_iterator it =
|
||||
ssAssemblageSSs.begin(); it != ssAssemblageSSs.end(); ++it)
|
||||
{
|
||||
@ -122,14 +122,14 @@ cxxSSassemblage::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out)
|
||||
// SSassemblage element and attributes
|
||||
s_oss << indent0;
|
||||
int n_user_local = (n_out != NULL) ? *n_out : this->n_user;
|
||||
s_oss << "SOLID_SOLUTIONS_RAW " << n_user_local << " " << this->description << std::endl;
|
||||
s_oss << "SOLID_SOLUTIONS_RAW " << n_user_local << " " << this->description << "\n";
|
||||
|
||||
// ssAssemblageSSs
|
||||
for (std::map < std::string, cxxSSassemblageSS >::const_iterator it =
|
||||
ssAssemblageSSs.begin(); it != ssAssemblageSSs.end(); ++it)
|
||||
{
|
||||
s_oss << indent1;
|
||||
s_oss << "-solid_solution" << std::endl;
|
||||
s_oss << "-solid_solution" << "\n";
|
||||
(*it).second.dump_raw(s_oss, indent + 2);
|
||||
}
|
||||
}
|
||||
@ -181,8 +181,8 @@ cxxSSassemblage::read_raw(CParser & parser, bool check)
|
||||
opt = CParser::OPT_EOF;
|
||||
parser.
|
||||
error_msg("Unknown input in SOLID_SOLUTIONS_RAW or SOLID_SOLUTIONS_MODIFY keyword.",
|
||||
CParser::OT_CONTINUE);
|
||||
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
|
||||
useLastLine = false;
|
||||
break;
|
||||
|
||||
|
||||
@ -8,7 +8,6 @@
|
||||
#include <algorithm> // std::sort
|
||||
|
||||
#include "Utils.h" // define first
|
||||
#include "Phreeqc.h"
|
||||
#include "SSassemblageSS.h"
|
||||
//#include "Dictionary.h"
|
||||
#include "phqalloc.h"
|
||||
@ -91,16 +90,16 @@ cxxSSassemblageSS::dump_xml(std::ostream & s_oss, unsigned int indent) const con
|
||||
|
||||
// S_S element and attributes
|
||||
|
||||
s_oss << indent0 << "name=\"" << this->name << "\"" << std::endl;
|
||||
s_oss << indent0 << "name=\"" << this->name << "\"" << "\n";
|
||||
s_oss << indent0 << "add_formula=\"" << this->
|
||||
add_formula << "\"" << std::endl;
|
||||
s_oss << indent0 << "si=\"" << this->si << "\"" << std::endl;
|
||||
s_oss << indent0 << "moles=\"" << this->moles << "\"" << std::endl;
|
||||
s_oss << indent0 << "delta=\"" << this->delta << "\"" << std::endl;
|
||||
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 << "\"" << std::endl;
|
||||
initial_moles << "\"" << "\n";
|
||||
s_oss << indent0 << "dissolve_only=\"" << this->
|
||||
dissolve_only << "\"" << std::endl;
|
||||
dissolve_only << "\"" << "\n";
|
||||
|
||||
}
|
||||
#endif
|
||||
@ -117,18 +116,18 @@ cxxSSassemblageSS::dump_raw(std::ostream & s_oss, unsigned int indent) const
|
||||
indent1.append(Utilities::INDENT);
|
||||
// S_S element and attributes
|
||||
|
||||
s_oss << indent0 << "-name " << this->name << std::endl;
|
||||
//s_oss << indent0 << "-total_moles " << this->total_moles << std::endl;
|
||||
s_oss << indent1 << "-a0 " << this->a0 << std::endl;
|
||||
s_oss << indent1 << "-a1 " << this->a1 << std::endl;
|
||||
s_oss << indent1 << "-ag0 " << this->ag0 << std::endl;
|
||||
s_oss << indent1 << "-ag1 " << this->ag1 << std::endl;
|
||||
s_oss << indent1 << "-miscibility " << this->miscibility << std::endl;
|
||||
//s_oss << indent0 << "-spinodal " << this->spinodal << std::endl;
|
||||
//s_oss << indent0 << "-tk " << this->tk << std::endl;
|
||||
s_oss << indent1 << "-xb1 " << this->xb1 << std::endl;
|
||||
s_oss << indent1 << "-xb2 " << this->xb2 << std::endl;
|
||||
s_oss << indent1 << "-components " << std::endl;
|
||||
s_oss << indent0 << "-name " << this->name << "\n";
|
||||
//s_oss << indent0 << "-total_moles " << this->total_moles << "\n";
|
||||
s_oss << indent1 << "-a0 " << this->a0 << "\n";
|
||||
s_oss << indent1 << "-a1 " << this->a1 << "\n";
|
||||
s_oss << indent1 << "-ag0 " << this->ag0 << "\n";
|
||||
s_oss << indent1 << "-ag1 " << this->ag1 << "\n";
|
||||
s_oss << indent1 << "-miscibility " << this->miscibility << "\n";
|
||||
//s_oss << indent0 << "-spinodal " << this->spinodal << "\n";
|
||||
//s_oss << indent0 << "-tk " << this->tk << "\n";
|
||||
s_oss << indent1 << "-xb1 " << this->xb1 << "\n";
|
||||
s_oss << indent1 << "-xb2 " << this->xb2 << "\n";
|
||||
s_oss << indent1 << "-components " << "\n";
|
||||
this->comps.dump_raw(s_oss, indent + 2);
|
||||
}
|
||||
|
||||
@ -191,8 +190,8 @@ cxxSSassemblageSS::read_raw(CParser & parser, bool check)
|
||||
case CParser::OPT_ERROR:
|
||||
opt = CParser::OPT_KEYWORD;
|
||||
// Allow return to Exchange for more processing
|
||||
//parser.error_msg("Unknown input in S_S read.", CParser::OT_CONTINUE);
|
||||
//parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE);
|
||||
//parser.error_msg("Unknown input in S_S read.", PHRQ_io::OT_CONTINUE);
|
||||
//parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
|
||||
break;
|
||||
|
||||
case 0: // name
|
||||
@ -201,7 +200,7 @@ cxxSSassemblageSS::read_raw(CParser & parser, bool check)
|
||||
this->name.clear();
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected string value for name.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -217,7 +216,7 @@ cxxSSassemblageSS::read_raw(CParser & parser, bool check)
|
||||
{
|
||||
this->total_moles = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for total_moles.", CParser::OT_CONTINUE);
|
||||
parser.error_msg("Expected numeric value for total_moles.", PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
total_moles_defined = true;
|
||||
*/
|
||||
@ -230,7 +229,7 @@ cxxSSassemblageSS::read_raw(CParser & parser, bool check)
|
||||
this->a0 = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for a0.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
a0_defined = true;
|
||||
opt_save = CParser::OPT_DEFAULT;
|
||||
@ -242,7 +241,7 @@ cxxSSassemblageSS::read_raw(CParser & parser, bool check)
|
||||
this->a1 = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for a1.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
a1_defined = true;
|
||||
opt_save = CParser::OPT_DEFAULT;
|
||||
@ -253,7 +252,7 @@ cxxSSassemblageSS::read_raw(CParser & parser, bool check)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected phase name and moles for comps.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
opt_save = 4;
|
||||
break;
|
||||
@ -264,7 +263,7 @@ cxxSSassemblageSS::read_raw(CParser & parser, bool check)
|
||||
this->miscibility = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected boolean value for miscibility.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
miscibility_defined = true;
|
||||
opt_save = CParser::OPT_DEFAULT;
|
||||
@ -276,7 +275,7 @@ cxxSSassemblageSS::read_raw(CParser & parser, bool check)
|
||||
{
|
||||
this->spinodal = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected boolean value for spinodal.", CParser::OT_CONTINUE);
|
||||
parser.error_msg("Expected boolean value for spinodal.", PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
spinodal_defined = true;
|
||||
*/
|
||||
@ -289,7 +288,7 @@ cxxSSassemblageSS::read_raw(CParser & parser, bool check)
|
||||
{
|
||||
this->tk = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for tk.", CParser::OT_CONTINUE);
|
||||
parser.error_msg("Expected numeric value for tk.", PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
tk_defined = true;
|
||||
*/
|
||||
@ -302,7 +301,7 @@ cxxSSassemblageSS::read_raw(CParser & parser, bool check)
|
||||
this->xb1 = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for xb1.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
xb1_defined = true;
|
||||
opt_save = CParser::OPT_DEFAULT;
|
||||
@ -314,7 +313,7 @@ cxxSSassemblageSS::read_raw(CParser & parser, bool check)
|
||||
this->xb2 = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for xb2.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
xb2_defined = true;
|
||||
opt_save = CParser::OPT_DEFAULT;
|
||||
@ -326,7 +325,7 @@ cxxSSassemblageSS::read_raw(CParser & parser, bool check)
|
||||
this->ag0 = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for ag0.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
ag0_defined = true;
|
||||
opt_save = CParser::OPT_DEFAULT;
|
||||
@ -338,7 +337,7 @@ cxxSSassemblageSS::read_raw(CParser & parser, bool check)
|
||||
this->ag1 = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for ag1.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
ag1_defined = true;
|
||||
opt_save = CParser::OPT_DEFAULT;
|
||||
@ -356,65 +355,65 @@ cxxSSassemblageSS::read_raw(CParser & parser, bool check)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Name not defined for SSassemblageSS input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
/*
|
||||
if (total_moles_defined == false) {
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Total_moles not defined for SSassemblageSS input.", CParser::OT_CONTINUE);
|
||||
parser.error_msg("Total_moles not defined for SSassemblageSS input.", PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
*/
|
||||
if (a0_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("A0 not defined for SSassemblageSS input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (a1_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("A1 not defined for SSassemblageSS input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (ag0_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Ag0 not defined for SSassemblageSS input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (ag1_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Ag1 not defined for SSassemblageSS input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (miscibility_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Miscibility not defined for SSassemblageSS input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
/*
|
||||
if (spinodal_defined == false) {
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Spinodal not defined for SSassemblageSS input.", CParser::OT_CONTINUE);
|
||||
parser.error_msg("Spinodal not defined for SSassemblageSS input.", PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (tk_defined == false) {
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Tk not defined for SSassemblageSS input.", CParser::OT_CONTINUE);
|
||||
parser.error_msg("Tk not defined for SSassemblageSS input.", PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
*/
|
||||
if (xb1_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Xb1 not defined for SSassemblageSS input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (xb2_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Xb2 not defined for SSassemblageSS input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
152
Solution.cxx
152
Solution.cxx
@ -144,50 +144,50 @@ cxxSolution::dump_xml(std::ostream & s_oss, unsigned int indent) const
|
||||
|
||||
// Solution element and attributes
|
||||
s_oss << indent0;
|
||||
s_oss << "<solution " << std::endl;
|
||||
s_oss << "<solution " << "\n";
|
||||
|
||||
//s_oss << indent1;
|
||||
//s_oss << "soln_new_def=\"" << this->new_def << "\"" << std::endl;
|
||||
//s_oss << "soln_new_def=\"" << this->new_def << "\"" << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "soln_n_user=\"" << this->n_user << "\" " << std::endl;
|
||||
s_oss << "soln_n_user=\"" << this->n_user << "\" " << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "soln_description=\"" << this->description << "\"" << std::endl;
|
||||
s_oss << "soln_description=\"" << this->description << "\"" << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "soln_tc=\"" << this->tc << "\"" << std::endl;
|
||||
s_oss << "soln_tc=\"" << this->tc << "\"" << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "soln_ph=\"" << this->ph << "\"" << std::endl;
|
||||
s_oss << "soln_ph=\"" << this->ph << "\"" << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "soln_solution_pe=\"" << this->pe << "\"" << std::endl;
|
||||
s_oss << "soln_solution_pe=\"" << this->pe << "\"" << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "soln_mu=\"" << this->mu << "\"" << std::endl;
|
||||
s_oss << "soln_mu=\"" << this->mu << "\"" << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "soln_ah2o=\"" << this->ah2o << "\"" << std::endl;
|
||||
s_oss << "soln_ah2o=\"" << this->ah2o << "\"" << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "soln_total_h=\"" << this->total_h << "\"" << std::endl;
|
||||
s_oss << "soln_total_h=\"" << this->total_h << "\"" << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "soln_total_o=\"" << this->total_o << "\"" << std::endl;
|
||||
s_oss << "soln_total_o=\"" << this->total_o << "\"" << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "soln_cb=\"" << this->cb << "\"" << std::endl;
|
||||
s_oss << "soln_cb=\"" << this->cb << "\"" << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "soln_mass_water=\"" << this->mass_water << "\"" << std::endl;
|
||||
s_oss << "soln_mass_water=\"" << this->mass_water << "\"" << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "soln_total_alkalinity=\"" << this->
|
||||
total_alkalinity << "\"" << std::endl;
|
||||
total_alkalinity << "\"" << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "\">" << std::endl;
|
||||
s_oss << "\">" << "\n";
|
||||
|
||||
// soln_total conc structures
|
||||
this->totals.dump_xml(s_oss, indent + 1);
|
||||
@ -201,7 +201,7 @@ cxxSolution::dump_xml(std::ostream & s_oss, unsigned int indent) const
|
||||
s_oss << "<soln_m_a";
|
||||
s_oss << " m_a_desc=\"" << it->first << "\"" ;
|
||||
s_oss << " m_a_la=\"" << it->second << "\"" ;
|
||||
s_oss << "\">" << std::endl;
|
||||
s_oss << "\">" << "\n";
|
||||
}
|
||||
}
|
||||
*/
|
||||
@ -214,7 +214,7 @@ cxxSolution::dump_xml(std::ostream & s_oss, unsigned int indent) const
|
||||
s_oss << "<soln_s_g";
|
||||
s_oss << " m_a_desc=\"" << it->first << "\"" ;
|
||||
s_oss << " m_a_la=\"" << it->second << "\"" ;
|
||||
s_oss << "\">" << std::endl;
|
||||
s_oss << "\">" << "\n";
|
||||
}
|
||||
}
|
||||
*/
|
||||
@ -227,7 +227,7 @@ cxxSolution::dump_xml(std::ostream & s_oss, unsigned int indent) const
|
||||
|
||||
// End of solution
|
||||
s_oss << indent0;
|
||||
s_oss << "</solution>" << std::endl;
|
||||
s_oss << "</solution>" << "\n";
|
||||
|
||||
return;
|
||||
}
|
||||
@ -249,35 +249,35 @@ cxxSolution::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out) con
|
||||
// Solution element and attributes
|
||||
s_oss << indent0;
|
||||
int n_user_local = (n_out != NULL) ? *n_out : this->n_user;
|
||||
s_oss << "SOLUTION_RAW " << n_user_local << " " << this->description << std::endl;
|
||||
s_oss << "SOLUTION_RAW " << n_user_local << " " << this->description << "\n";
|
||||
|
||||
//s_oss << "# Critical values" << std::endl;
|
||||
//s_oss << "# Critical values" << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "-temp " << this->tc << std::endl;
|
||||
s_oss << "-temp " << this->tc << "\n";
|
||||
|
||||
// new identifier
|
||||
s_oss << indent1;
|
||||
s_oss << "-total_h " << this->total_h << std::endl;
|
||||
s_oss << "-total_h " << this->total_h << "\n";
|
||||
|
||||
// new identifier
|
||||
s_oss << indent1;
|
||||
s_oss << "-total_o " << this->total_o << std::endl;
|
||||
s_oss << "-total_o " << this->total_o << "\n";
|
||||
|
||||
// new identifier
|
||||
s_oss << indent1;
|
||||
s_oss << "-cb " << this->cb << std::endl;
|
||||
s_oss << "-cb " << this->cb << "\n";
|
||||
|
||||
// soln_total conc structures
|
||||
s_oss << indent1;
|
||||
s_oss << "-totals" << std::endl;
|
||||
s_oss << "-totals" << "\n";
|
||||
this->totals.dump_raw(s_oss, indent + 2);
|
||||
|
||||
//s_oss << "# Optional critical values" << std::endl;
|
||||
//s_oss << "# Optional critical values" << "\n";
|
||||
|
||||
// Isotopes
|
||||
s_oss << indent1;
|
||||
s_oss << "-Isotopes" << std::endl;
|
||||
s_oss << "-Isotopes" << "\n";
|
||||
{
|
||||
for (std::list < cxxSolutionIsotope >::const_iterator it =
|
||||
this->isotopes.begin(); it != isotopes.end(); ++it)
|
||||
@ -287,49 +287,49 @@ cxxSolution::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out) con
|
||||
}
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "-pH " << this->ph << std::endl;
|
||||
s_oss << "-pH " << this->ph << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "-pe " << this->pe << std::endl;
|
||||
s_oss << "-pe " << this->pe << "\n";
|
||||
|
||||
// new identifier
|
||||
s_oss << indent1;
|
||||
s_oss << "-mu " << this->mu << std::endl;
|
||||
s_oss << "-mu " << this->mu << "\n";
|
||||
|
||||
// new identifier
|
||||
s_oss << indent1;
|
||||
s_oss << "-ah2o " << this->ah2o << std::endl;
|
||||
s_oss << "-ah2o " << this->ah2o << "\n";
|
||||
|
||||
// new identifier
|
||||
s_oss << indent1;
|
||||
s_oss << "-mass_water " << this->mass_water << std::endl;
|
||||
s_oss << "-mass_water " << this->mass_water << "\n";
|
||||
|
||||
// new identifier
|
||||
s_oss << indent1;
|
||||
s_oss << "-total_alkalinity " << this->total_alkalinity << std::endl;
|
||||
s_oss << "-total_alkalinity " << this->total_alkalinity << "\n";
|
||||
|
||||
// master_activity map
|
||||
s_oss << indent1;
|
||||
s_oss << "-activities" << std::endl;
|
||||
s_oss << "-activities" << "\n";
|
||||
this->master_activity.dump_raw(s_oss, indent + 2);
|
||||
/*
|
||||
{
|
||||
for (std::map <char *, double>::const_iterator it = master_activity.begin(); it != master_activity.end(); ++it) {
|
||||
s_oss << indent2;
|
||||
s_oss << it->first << " " << it->second << std::endl;
|
||||
s_oss << it->first << " " << it->second << "\n";
|
||||
}
|
||||
}
|
||||
*/
|
||||
// species_gamma map
|
||||
s_oss << indent1;
|
||||
s_oss << "-gammas" << std::endl;
|
||||
s_oss << "-gammas" << "\n";
|
||||
this->species_gamma.dump_raw(s_oss, indent + 2);
|
||||
/*
|
||||
{
|
||||
{
|
||||
for (std::map <char *, double>::const_iterator it = species_gamma.begin(); it != species_gamma.end(); ++it) {
|
||||
s_oss << indent2;
|
||||
s_oss << it->first << " " << it->second << std::endl;
|
||||
s_oss << it->first << " " << it->second << "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -406,8 +406,8 @@ cxxSolution::read_raw(CParser & parser, bool check)
|
||||
case CParser::OPT_ERROR:
|
||||
opt = CParser::OPT_EOF;
|
||||
parser.error_msg("Unknown input in SOLUTION_RAW keyword.",
|
||||
CParser::OT_CONTINUE);
|
||||
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
|
||||
continue;
|
||||
|
||||
case 0: // totals
|
||||
@ -417,7 +417,7 @@ cxxSolution::read_raw(CParser & parser, bool check)
|
||||
// parser.incr_input_error();
|
||||
// parser.
|
||||
// error_msg("Expected element name and moles for totals.",
|
||||
// CParser::OT_CONTINUE);
|
||||
// PHRQ_io::OT_CONTINUE);
|
||||
//}
|
||||
{
|
||||
cxxNameDouble temp_totals;
|
||||
@ -426,7 +426,7 @@ cxxSolution::read_raw(CParser & parser, bool check)
|
||||
parser.incr_input_error();
|
||||
parser.
|
||||
error_msg("Expected element name and moles for totals.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -444,7 +444,7 @@ cxxSolution::read_raw(CParser & parser, bool check)
|
||||
parser.
|
||||
error_msg
|
||||
("Expected species name and log activity for activities.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
opt_save = 1;
|
||||
break;
|
||||
@ -457,7 +457,7 @@ cxxSolution::read_raw(CParser & parser, bool check)
|
||||
parser.
|
||||
error_msg
|
||||
("Expected species name and activity coefficient for gammas.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
opt_save = 2;
|
||||
break;
|
||||
@ -469,7 +469,7 @@ cxxSolution::read_raw(CParser & parser, bool check)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected data for isotopes.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -490,7 +490,7 @@ cxxSolution::read_raw(CParser & parser, bool check)
|
||||
this->tc = 25.0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for temperature.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
tc_defined = true;
|
||||
opt_save = CParser::OPT_DEFAULT;
|
||||
@ -502,7 +502,7 @@ cxxSolution::read_raw(CParser & parser, bool check)
|
||||
this->ph = 7.0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for pH.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
ph_defined = true;
|
||||
opt_save = CParser::OPT_DEFAULT;
|
||||
@ -514,7 +514,7 @@ cxxSolution::read_raw(CParser & parser, bool check)
|
||||
this->pe = 4.0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for pe.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
pe_defined = true;
|
||||
opt_save = CParser::OPT_DEFAULT;
|
||||
@ -527,7 +527,7 @@ cxxSolution::read_raw(CParser & parser, bool check)
|
||||
this->mu = 1e-7;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for ionic strength.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
mu_defined = true;
|
||||
opt_save = CParser::OPT_DEFAULT;
|
||||
@ -541,7 +541,7 @@ cxxSolution::read_raw(CParser & parser, bool check)
|
||||
parser.incr_input_error();
|
||||
parser.
|
||||
error_msg("Expected numeric value for activity of water.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
ah2o_defined = true;
|
||||
opt_save = CParser::OPT_DEFAULT;
|
||||
@ -553,7 +553,7 @@ cxxSolution::read_raw(CParser & parser, bool check)
|
||||
this->total_h = 111.1;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for total hydrogen.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
total_h_defined = true;
|
||||
opt_save = CParser::OPT_DEFAULT;
|
||||
@ -565,7 +565,7 @@ cxxSolution::read_raw(CParser & parser, bool check)
|
||||
this->total_o = 55.55;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for total oxygen.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
total_o_defined = true;
|
||||
opt_save = CParser::OPT_DEFAULT;
|
||||
@ -578,7 +578,7 @@ cxxSolution::read_raw(CParser & parser, bool check)
|
||||
this->mass_water = 1.0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for mass of water.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
mass_water_defined = true;
|
||||
opt_save = CParser::OPT_DEFAULT;
|
||||
@ -592,7 +592,7 @@ cxxSolution::read_raw(CParser & parser, bool check)
|
||||
parser.incr_input_error();
|
||||
parser.
|
||||
error_msg("Expected numeric value for total_alkalinity.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
total_alkalinity_defined = true;
|
||||
opt_save = CParser::OPT_DEFAULT;
|
||||
@ -605,7 +605,7 @@ cxxSolution::read_raw(CParser & parser, bool check)
|
||||
this->cb = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for charge balance.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
cb_defined = true;
|
||||
opt_save = CParser::OPT_DEFAULT;
|
||||
@ -623,63 +623,63 @@ cxxSolution::read_raw(CParser & parser, bool check)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Temp not defined for SOLUTION_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (ph_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("pH not defined for SOLUTION_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (pe_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("pe not defined for SOLUTION_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (mu_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Ionic strength not defined for SOLUTION_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (ah2o_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.
|
||||
error_msg("Activity of water not defined for SOLUTION_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (total_h_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Total hydrogen not defined for SOLUTION_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (total_o_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Total oxygen not defined for SOLUTION_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (cb_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Charge balance not defined for SOLUTION_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (mass_water_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Temp not defined for SOLUTION_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (total_alkalinity_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.
|
||||
error_msg("Total alkalinity not defined for SOLUTION_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
}
|
||||
return;
|
||||
@ -1469,13 +1469,13 @@ cxxSolution::Update(const cxxNameDouble &nd)
|
||||
// */
|
||||
// std::ostringstream msg;
|
||||
// status_on = FALSE;
|
||||
// std::cout << std::endl << "TEST CLASSES" << std::endl;
|
||||
// std::cout << "\n" << "TEST CLASSES" << "\n";
|
||||
// for (i = 0; i < count_solution; i++)
|
||||
// {
|
||||
// if (solution[i]->new_def == TRUE)
|
||||
// {
|
||||
// std::cout << "Solution new_def " << solution[i]->
|
||||
// n_user << std::endl;
|
||||
// n_user << "\n";
|
||||
// cxxISolution sol(solution[i]);
|
||||
// solution_free(solution[i]);
|
||||
// solution[i] = NULL;
|
||||
@ -1486,7 +1486,7 @@ cxxSolution::Update(const cxxNameDouble &nd)
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// std::cout << "Solution " << solution[i]->n_user << std::endl;
|
||||
// std::cout << "Solution " << solution[i]->n_user << "\n";
|
||||
// std::ostringstream oss;
|
||||
// cxxSolution sol(solution[i]);
|
||||
// solution_free(solution[i]);
|
||||
@ -1515,7 +1515,7 @@ cxxSolution::Update(const cxxNameDouble &nd)
|
||||
// {
|
||||
// if (exchange[i].new_def != TRUE)
|
||||
// {
|
||||
// std::cout << "Exchange " << exchange[i].n_user << std::endl;
|
||||
// std::cout << "Exchange " << exchange[i].n_user << "\n";
|
||||
// std::ostringstream oss;
|
||||
// cxxExchange ex(&(exchange[i]));
|
||||
// ex.dump_raw(oss, 0);
|
||||
@ -1544,7 +1544,7 @@ cxxSolution::Update(const cxxNameDouble &nd)
|
||||
// {
|
||||
// if (surface[i].new_def != TRUE)
|
||||
// {
|
||||
// std::cout << "Surface " << surface[i].n_user << std::endl;
|
||||
// std::cout << "Surface " << surface[i].n_user << "\n";
|
||||
// std::ostringstream oss;
|
||||
// cxxSurface ex(&(surface[i]));
|
||||
// ex.dump_raw(oss, 0);
|
||||
@ -1577,7 +1577,7 @@ cxxSolution::Update(const cxxNameDouble &nd)
|
||||
// if (pp_assemblage[i].new_def != TRUE)
|
||||
// {
|
||||
// std::cout << "PPassemblage " << pp_assemblage[i].
|
||||
// n_user << std::endl;
|
||||
// n_user << "\n";
|
||||
// std::ostringstream oss;
|
||||
// cxxPPassemblage ex(&(pp_assemblage[i]));
|
||||
// ex.dump_raw(oss, 0);
|
||||
@ -1609,7 +1609,7 @@ cxxSolution::Update(const cxxNameDouble &nd)
|
||||
// }
|
||||
// for (i = 0; i < count_kinetics; i++)
|
||||
// {
|
||||
// std::cout << "Kinetics " << kinetics[i].n_user << std::endl;
|
||||
// std::cout << "Kinetics " << kinetics[i].n_user << "\n";
|
||||
// std::ostringstream oss;
|
||||
// cxxKinetics ex(&(kinetics[i]));
|
||||
// ex.dump_raw(oss, 0);
|
||||
@ -1640,7 +1640,7 @@ cxxSolution::Update(const cxxNameDouble &nd)
|
||||
// if (s_s_assemblage[i].new_def != TRUE)
|
||||
// {
|
||||
// std::cout << "Solid solution " << s_s_assemblage[i].
|
||||
// n_user << std::endl;
|
||||
// n_user << "\n";
|
||||
// std::ostringstream oss;
|
||||
// cxxSSassemblage ex(&(s_s_assemblage[i]));
|
||||
// ex.dump_raw(oss, 0);
|
||||
@ -1674,7 +1674,7 @@ cxxSolution::Update(const cxxNameDouble &nd)
|
||||
// {
|
||||
// if (gas_phase[i].new_def != TRUE)
|
||||
// {
|
||||
// std::cout << "Gas phase " << gas_phase[i].n_user << std::endl;
|
||||
// std::cout << "Gas phase " << gas_phase[i].n_user << "\n";
|
||||
// std::ostringstream oss;
|
||||
// cxxGasPhase ex(&(gas_phase[i]));
|
||||
// ex.dump_raw(oss, 0);
|
||||
@ -1705,7 +1705,7 @@ cxxSolution::Update(const cxxNameDouble &nd)
|
||||
// }
|
||||
// for (i = 0; i < count_irrev; i++)
|
||||
// {
|
||||
// std::cout << "Reaction " << irrev[i].n_user << std::endl;
|
||||
// std::cout << "Reaction " << irrev[i].n_user << "\n";
|
||||
// std::ostringstream oss;
|
||||
// cxxReaction ex(&(irrev[i]));
|
||||
// ex.dump_raw(oss, 0);
|
||||
@ -1734,7 +1734,7 @@ cxxSolution::Update(const cxxNameDouble &nd)
|
||||
// }
|
||||
// for (i = 0; i < count_mix; i++)
|
||||
// {
|
||||
// std::cout << "Mix " << mix[i].n_user << std::endl;
|
||||
// std::cout << "Mix " << mix[i].n_user << "\n";
|
||||
// std::ostringstream oss;
|
||||
// cxxMix ex(&(mix[i]));
|
||||
// ex.dump_raw(oss, 0);
|
||||
@ -1763,7 +1763,7 @@ cxxSolution::Update(const cxxNameDouble &nd)
|
||||
// }
|
||||
// for (i = 0; i < count_temperature; i++)
|
||||
// {
|
||||
// std::cout << "Temperature " << temperature[i].n_user << std::endl;
|
||||
// std::cout << "Temperature " << temperature[i].n_user << "\n";
|
||||
// std::ostringstream oss;
|
||||
// cxxTemperature ex(&(temperature[i]));
|
||||
// ex.dump_raw(oss, 0);
|
||||
|
||||
@ -91,32 +91,32 @@ cxxSolutionIsotope::dump_xml(std::ostream & s_oss, unsigned int indent) const
|
||||
indent1.append(Utilities::INDENT);
|
||||
|
||||
s_oss << indent0;
|
||||
s_oss << "<soln_isotope=\"" << std::endl;
|
||||
s_oss << "<soln_isotope=\"" << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "iso_isotope_number=\"" << this->
|
||||
isotope_number << "\"" << std::endl;
|
||||
isotope_number << "\"" << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "iso_elt_name=\"" << this->elt_name << "\"" << std::endl;
|
||||
s_oss << "iso_elt_name=\"" << this->elt_name << "\"" << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "iso_isotope_name=\"" << this->isotope_name << "\"" << std::endl;
|
||||
s_oss << "iso_isotope_name=\"" << this->isotope_name << "\"" << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "iso_total=\"" << this->total << "\"" << std::endl;
|
||||
s_oss << "iso_total=\"" << this->total << "\"" << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "iso_ratio=\"" << this->ratio << "\"" << std::endl;
|
||||
s_oss << "iso_ratio=\"" << this->ratio << "\"" << "\n";
|
||||
|
||||
if (this->ratio_uncertainty != NAN)
|
||||
{
|
||||
s_oss << indent1;
|
||||
s_oss << "iso_ratio_uncertainty=\"" << this->
|
||||
ratio_uncertainty << "\"" << std::endl;
|
||||
ratio_uncertainty << "\"" << "\n";
|
||||
}
|
||||
s_oss << indent0;
|
||||
s_oss << "\">" << std::endl;
|
||||
s_oss << "\">" << "\n";
|
||||
}
|
||||
|
||||
void
|
||||
@ -138,7 +138,7 @@ cxxSolutionIsotope::dump_raw(std::ostream & s_oss, unsigned int indent) const
|
||||
{
|
||||
s_oss << this->ratio_uncertainty << " ";
|
||||
}
|
||||
s_oss << std::endl;
|
||||
s_oss << "\n";
|
||||
}
|
||||
|
||||
CParser::STATUS_TYPE cxxSolutionIsotope::read_raw(CParser & parser, std::istream::pos_type next_char )
|
||||
@ -192,7 +192,7 @@ CParser::STATUS_TYPE cxxSolutionIsotope::read_raw(CParser & parser, std::istream
|
||||
parser.incr_input_error();
|
||||
parser.
|
||||
error_msg("Expected numeric value for mass of water in solution.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -243,7 +243,7 @@ cxxSolutionIsotope::STATUS cxxSolutionIsotope::read(CParser & parser)
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected isotope name to"
|
||||
" begin with an isotopic number.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
return ERROR;
|
||||
}
|
||||
assert(parser.get_iss().good() || parser.get_iss().eof());
|
||||
@ -252,8 +252,8 @@ cxxSolutionIsotope::STATUS cxxSolutionIsotope::read(CParser & parser)
|
||||
std::istringstream::int_type c = parser.get_iss().peek();
|
||||
if (c == std::char_traits < char >::eof() || !(::isupper(c)))
|
||||
{
|
||||
parser.error_msg("Expecting element name.", CParser::OT_CONTINUE);
|
||||
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE);
|
||||
parser.error_msg("Expecting element name.", PHRQ_io::OT_CONTINUE);
|
||||
parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
|
||||
parser.incr_input_error();
|
||||
return ERROR;
|
||||
}
|
||||
@ -272,7 +272,7 @@ cxxSolutionIsotope::STATUS cxxSolutionIsotope::read(CParser & parser)
|
||||
assert(parser.get_iss().fail());
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for isotope ratio.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
return ERROR;
|
||||
}
|
||||
assert(parser.get_iss().good() || parser.get_iss().eof());
|
||||
@ -287,7 +287,7 @@ cxxSolutionIsotope::STATUS cxxSolutionIsotope::read(CParser & parser)
|
||||
parser.
|
||||
error_msg
|
||||
("Expected numeric value for uncertainty in isotope ratio.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
@ -375,15 +375,15 @@ cxxStorageBin::dump_xml(std::ostream & s_oss, unsigned int indent) const const
|
||||
|
||||
// StorageBin element and attributes
|
||||
s_oss << indent0;
|
||||
s_oss << "<mix " << std::endl;
|
||||
s_oss << "<mix " << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "pitzer_mix_gammas=\"" << this->
|
||||
pitzer_mix_gammas << "\"" << std::endl;
|
||||
pitzer_mix_gammas << "\"" << "\n";
|
||||
|
||||
// components
|
||||
s_oss << indent1;
|
||||
s_oss << "<component " << std::endl;
|
||||
s_oss << "<component " << "\n";
|
||||
for (std::list < cxxStorageBinComp >::const_iterator it =
|
||||
mixComps.begin(); it != mixComps.end(); ++it)
|
||||
{
|
||||
@ -505,13 +505,13 @@ cxxStorageBin::dump_raw(std::ostream & s_oss, int n, unsigned int indent, int *n
|
||||
void
|
||||
cxxStorageBin::read_raw(CParser & parser)
|
||||
{
|
||||
CParser::LINE_TYPE i;
|
||||
PHRQ_io::LINE_TYPE i;
|
||||
while ((i =
|
||||
parser.check_line("StorageBin read_raw", false, true, true,
|
||||
true)) != CParser::LT_KEYWORD)
|
||||
true)) != PHRQ_io::LT_KEYWORD)
|
||||
{
|
||||
if (i == CParser::LT_EOF)
|
||||
return; // CParser::LT_EOF;
|
||||
if (i == PHRQ_io::LT_EOF)
|
||||
return; // PHRQ_io::LT_EOF;
|
||||
}
|
||||
|
||||
for (;;)
|
||||
@ -624,13 +624,13 @@ cxxStorageBin::read_raw(CParser & parser)
|
||||
}
|
||||
|
||||
END_OF_SIMULATION_INPUT:
|
||||
return; //CParser::LT_OK;
|
||||
return; //PHRQ_io::LT_OK;
|
||||
}
|
||||
|
||||
int
|
||||
cxxStorageBin::read_raw_keyword(CParser & parser)
|
||||
{
|
||||
CParser::LINE_TYPE i;
|
||||
PHRQ_io::LINE_TYPE i;
|
||||
int entity_number = -999;
|
||||
|
||||
switch (parser.next_keyword())
|
||||
@ -641,10 +641,10 @@ cxxStorageBin::read_raw_keyword(CParser & parser)
|
||||
case Keywords::KEY_END:
|
||||
while ((i =
|
||||
parser.check_line("StorageBin read_raw_keyword", false, true,
|
||||
true, true)) != CParser::LT_KEYWORD)
|
||||
true, true)) != PHRQ_io::LT_KEYWORD)
|
||||
{
|
||||
if (i == CParser::LT_EOF)
|
||||
break; // CParser::LT_EOF;
|
||||
if (i == PHRQ_io::LT_EOF)
|
||||
break; // PHRQ_io::LT_EOF;
|
||||
}
|
||||
break;
|
||||
/*case CParser::KT_EOF:
|
||||
@ -753,7 +753,7 @@ cxxStorageBin::read_raw_keyword(CParser & parser)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return (entity_number); //CParser::LT_OK;
|
||||
return (entity_number); //PHRQ_io::LT_OK;
|
||||
}
|
||||
|
||||
//void
|
||||
@ -1060,7 +1060,7 @@ cxxStorageBin::mpi_send(int n, int task_number)
|
||||
{
|
||||
ints.push_back(0);
|
||||
}
|
||||
//std::cerr << "Packed Solution" << std::endl;
|
||||
//std::cerr << "Packed Solution" << "\n";
|
||||
|
||||
// Exchanger
|
||||
if (this->getExchange(n) != NULL)
|
||||
@ -1072,7 +1072,7 @@ cxxStorageBin::mpi_send(int n, int task_number)
|
||||
{
|
||||
ints.push_back(0);
|
||||
}
|
||||
//std::cerr << "Packed Exchange" << std::endl;
|
||||
//std::cerr << "Packed Exchange" << "\n";
|
||||
|
||||
// GasPhase
|
||||
if (this->getGasPhase(n) != NULL)
|
||||
@ -1084,7 +1084,7 @@ cxxStorageBin::mpi_send(int n, int task_number)
|
||||
{
|
||||
ints.push_back(0);
|
||||
}
|
||||
//std::cerr << "Packed GasPhase" << std::endl;
|
||||
//std::cerr << "Packed GasPhase" << "\n";
|
||||
|
||||
// Kinetics
|
||||
if (this->getKinetics(n) != NULL)
|
||||
@ -1096,7 +1096,7 @@ cxxStorageBin::mpi_send(int n, int task_number)
|
||||
{
|
||||
ints.push_back(0);
|
||||
}
|
||||
//std::cerr << "Packed Kinetics" << std::endl;
|
||||
//std::cerr << "Packed Kinetics" << "\n";
|
||||
|
||||
// PPassemblages
|
||||
if (this->getPPassemblage(n) != NULL)
|
||||
@ -1108,7 +1108,7 @@ cxxStorageBin::mpi_send(int n, int task_number)
|
||||
{
|
||||
ints.push_back(0);
|
||||
}
|
||||
//std::cerr << "Packed PPassemblage" << std::endl;
|
||||
//std::cerr << "Packed PPassemblage" << "\n";
|
||||
|
||||
// SSassemblages
|
||||
if (this->getSSassemblage(n) != NULL)
|
||||
@ -1120,7 +1120,7 @@ cxxStorageBin::mpi_send(int n, int task_number)
|
||||
{
|
||||
ints.push_back(0);
|
||||
}
|
||||
//std::cerr << "Packed SSassemblage" << std::endl;
|
||||
//std::cerr << "Packed SSassemblage" << "\n";
|
||||
|
||||
// Surfaces
|
||||
if (this->getSurface(n) != NULL)
|
||||
@ -1132,7 +1132,7 @@ cxxStorageBin::mpi_send(int n, int task_number)
|
||||
{
|
||||
ints.push_back(0);
|
||||
}
|
||||
//std::cerr << "Packed Surface" << std::endl;
|
||||
//std::cerr << "Packed Surface" << "\n";
|
||||
|
||||
// Pack data
|
||||
int max_size = 0;
|
||||
@ -1155,11 +1155,11 @@ cxxStorageBin::mpi_send(int n, int task_number)
|
||||
/*
|
||||
for (int j = 0; j < i; j++) {
|
||||
int_array[j] = ints[j];
|
||||
//std::cerr << "Sending ints " << j << " value " << ints[j] << std::endl;
|
||||
//std::cerr << "Sending ints " << j << " value " << ints[j] << "\n";
|
||||
}
|
||||
for (int j = 0; j < d; j++) {
|
||||
double_array[j] = doubles[j];
|
||||
//std::cerr << "Sending doubles " << j << " value " << doubles[j] << std::endl;
|
||||
//std::cerr << "Sending doubles " << j << " value " << doubles[j] << "\n";
|
||||
}
|
||||
*/
|
||||
/*
|
||||
@ -1243,7 +1243,7 @@ cxxStorageBin::mpi_recv(int task_number)
|
||||
entity.mpi_unpack(ints, &i, doubles, &d);
|
||||
this->setSolution(entity.Get_n_user(), &entity);
|
||||
}
|
||||
//std::cerr << "Unpacked Solution" << std::endl;
|
||||
//std::cerr << "Unpacked Solution" << "\n";
|
||||
|
||||
// Exchanger
|
||||
if (ints[i++] != 0)
|
||||
@ -1252,7 +1252,7 @@ cxxStorageBin::mpi_recv(int task_number)
|
||||
entity.mpi_unpack(ints, &i, doubles, &d);
|
||||
this->setExchange(entity.Get_n_user(), &entity);
|
||||
}
|
||||
//std::cerr << "Unpacked Exchange" << std::endl;
|
||||
//std::cerr << "Unpacked Exchange" << "\n";
|
||||
|
||||
// GasPhase
|
||||
if (ints[i++] != 0)
|
||||
@ -1261,7 +1261,7 @@ cxxStorageBin::mpi_recv(int task_number)
|
||||
entity.mpi_unpack(ints, &i, doubles, &d);
|
||||
this->setGasPhase(entity.Get_n_user(), &entity);
|
||||
}
|
||||
//std::cerr << "Unpacked GasPhase" << std::endl;
|
||||
//std::cerr << "Unpacked GasPhase" << "\n";
|
||||
|
||||
// Kinetics
|
||||
if (ints[i++] != 0)
|
||||
@ -1270,7 +1270,7 @@ cxxStorageBin::mpi_recv(int task_number)
|
||||
entity.mpi_unpack(ints, &i, doubles, &d);
|
||||
this->setKinetics(entity.Get_n_user(), &entity);
|
||||
}
|
||||
//std::cerr << "Unpacked Kinetics" << std::endl;
|
||||
//std::cerr << "Unpacked Kinetics" << "\n";
|
||||
|
||||
// PPassemblage
|
||||
if (ints[i++] != 0)
|
||||
@ -1279,7 +1279,7 @@ cxxStorageBin::mpi_recv(int task_number)
|
||||
entity.mpi_unpack(ints, &i, doubles, &d);
|
||||
this->setPPassemblage(entity.Get_n_user(), &entity);
|
||||
}
|
||||
//std::cerr << "Unpacked PPassemblage" << std::endl;
|
||||
//std::cerr << "Unpacked PPassemblage" << "\n";
|
||||
|
||||
// SSassemblage
|
||||
if (ints[i++] != 0)
|
||||
@ -1288,7 +1288,7 @@ cxxStorageBin::mpi_recv(int task_number)
|
||||
entity.mpi_unpack(ints, &i, doubles, &d);
|
||||
this->setSSassemblage(entity.Get_n_user(), &entity);
|
||||
}
|
||||
//std::cerr << "Unpacked SSassemblage" << std::endl;
|
||||
//std::cerr << "Unpacked SSassemblage" << "\n";
|
||||
|
||||
// Surfaces
|
||||
if (ints[i++] != 0)
|
||||
@ -1297,7 +1297,7 @@ cxxStorageBin::mpi_recv(int task_number)
|
||||
entity.mpi_unpack(ints, &i, doubles, &d);
|
||||
this->setSurface(entity.Get_n_user(), &entity);
|
||||
}
|
||||
//std::cerr << "Unpacked Surface" << std::endl;
|
||||
//std::cerr << "Unpacked Surface" << "\n";
|
||||
|
||||
delete[]ints;
|
||||
delete[]doubles;
|
||||
@ -1503,10 +1503,10 @@ cxxStorageBin::Set_System(struct Use *use_ptr)
|
||||
}
|
||||
}
|
||||
// reaction
|
||||
if (use_ptr->irrev_ptr != NULL)
|
||||
if (use_ptr->reaction_ptr != NULL)
|
||||
{
|
||||
std::map < int, cxxReaction >::iterator it =
|
||||
this->Reactions.find(use_ptr->n_irrev_user);
|
||||
this->Reactions.find(use_ptr->n_reaction_user);
|
||||
if (it != this->Reactions.end())
|
||||
{
|
||||
this->system.Set_Reaction(&(it->second));
|
||||
|
||||
@ -17,9 +17,9 @@ StorageBinListItem::StorageBinListItem(CParser & parser)
|
||||
for (;;)
|
||||
{
|
||||
//read lines
|
||||
CParser::LINE_TYPE l = parser.check_line("read StorageBinListLtem", false, true, true, true);
|
||||
PHRQ_io::LINE_TYPE l = parser.check_line("read StorageBinListLtem", false, true, true, true);
|
||||
std::istream::pos_type next_char = 0;
|
||||
if (l == CParser::LT_EOF) break;
|
||||
if (l == PHRQ_io::LT_EOF) break;
|
||||
for (;;)
|
||||
{
|
||||
std::string token;
|
||||
@ -36,7 +36,7 @@ StorageBinListItem::StorageBinListItem(CParser & parser)
|
||||
{
|
||||
// ignore characters like RUN
|
||||
//parser.error_msg("Expected single number or range of numbers.",
|
||||
// CParser::OT_CONTINUE);
|
||||
// PHRQ_io::OT_CONTINUE);
|
||||
//break;
|
||||
}
|
||||
}
|
||||
@ -259,7 +259,7 @@ bool StorageBinList::Read(CParser & parser)
|
||||
else
|
||||
{
|
||||
parser.error_msg("Expected single number or range of numbers.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -302,8 +302,8 @@ bool StorageBinList::Read(CParser & parser)
|
||||
case CParser::OPT_ERROR:
|
||||
opt = CParser::OPT_EOF;
|
||||
parser.error_msg("Unknown input reading DELETE definition.",
|
||||
CParser::OT_CONTINUE);
|
||||
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
|
||||
useLastLine = false;
|
||||
return_value = false;
|
||||
break;
|
||||
|
||||
118
Surface.cxx
118
Surface.cxx
@ -154,44 +154,44 @@ cxxSurface::dump_xml(std::ostream & s_oss, unsigned int indent) const
|
||||
|
||||
// Surface element and attributes
|
||||
s_oss << indent0;
|
||||
s_oss << "<surface " << std::endl;
|
||||
s_oss << "<surface " << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
//s_oss << "diffuse_layer=\"" << this->diffuse_layer << "\"" << std::endl;
|
||||
s_oss << "surface_type=\"" << this->type << "\"" << std::endl;
|
||||
//s_oss << "diffuse_layer=\"" << this->diffuse_layer << "\"" << "\n";
|
||||
s_oss << "surface_type=\"" << this->type << "\"" << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
//s_oss << "edl=\"" << this->edl << "\"" << std::endl;
|
||||
s_oss << "dl_type=\"" << this->dl_type << "\"" << std::endl;
|
||||
//s_oss << "edl=\"" << this->edl << "\"" << "\n";
|
||||
s_oss << "dl_type=\"" << this->dl_type << "\"" << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "sites_units=\"" << this->sites_units << "\"" << std::endl;
|
||||
s_oss << "sites_units=\"" << this->sites_units << "\"" << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "only_counter_ions=\"" << this->
|
||||
only_counter_ions << "\"" << std::endl;
|
||||
only_counter_ions << "\"" << "\n";
|
||||
|
||||
//s_oss << indent1;
|
||||
//s_oss << "donnan=\"" << this->donnan << "\"" << std::endl;
|
||||
//s_oss << "donnan=\"" << this->donnan << "\"" << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "thickness=\"" << this->thickness << "\"" << std::endl;
|
||||
s_oss << "thickness=\"" << this->thickness << "\"" << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "debye_lengths=\"" << this->debye_lengths << "\"" << std::endl;
|
||||
s_oss << "debye_lengths=\"" << this->debye_lengths << "\"" << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "DDL_viscosity=\"" << this->DDL_viscosity << "\"" << std::endl;
|
||||
s_oss << "DDL_viscosity=\"" << this->DDL_viscosity << "\"" << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "DDL_limit=\"" << this->DDL_limit << "\"" << std::endl;
|
||||
s_oss << "DDL_limit=\"" << this->DDL_limit << "\"" << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "transport=\"" << this->transport << "\"" << std::endl;
|
||||
s_oss << "transport=\"" << this->transport << "\"" << "\n";
|
||||
|
||||
// surface component structures
|
||||
s_oss << indent1;
|
||||
s_oss << "<component " << std::endl;
|
||||
s_oss << "<component " << "\n";
|
||||
{
|
||||
for (std::map < std::string, cxxSurfaceComp >::const_iterator it =
|
||||
this->surfaceComps.begin(); it != this->surfaceComps.end(); ++it)
|
||||
@ -201,7 +201,7 @@ cxxSurface::dump_xml(std::ostream & s_oss, unsigned int indent) const
|
||||
}
|
||||
// surface charge structures
|
||||
s_oss << indent1;
|
||||
s_oss << "<charge_component " << std::endl;
|
||||
s_oss << "<charge_component " << "\n";
|
||||
for (std::map < std::string, cxxSurfaceCharge >::const_iterator it =
|
||||
surfaceCharges.begin(); it != surfaceCharges.end(); ++it)
|
||||
{
|
||||
@ -228,46 +228,46 @@ cxxSurface::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out) cons
|
||||
// Surface element and attributes
|
||||
s_oss << indent0;
|
||||
int n_user_local = (n_out != NULL) ? *n_out : this->n_user;
|
||||
s_oss << "SURFACE_RAW " << n_user_local << " " << this->description << std::endl;
|
||||
s_oss << "SURFACE_RAW " << n_user_local << " " << this->description << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
//s_oss << "-diffuse_layer " << this->diffuse_layer << std::endl;
|
||||
s_oss << "-type " << this->type << std::endl;
|
||||
//s_oss << "-diffuse_layer " << this->diffuse_layer << "\n";
|
||||
s_oss << "-type " << this->type << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
//s_oss << "-edl " << this->edl << std::endl;
|
||||
s_oss << "-dl_type " << this->dl_type << std::endl;
|
||||
//s_oss << "-edl " << this->edl << "\n";
|
||||
s_oss << "-dl_type " << this->dl_type << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "-sites_units " << this->sites_units << std::endl;
|
||||
s_oss << "-sites_units " << this->sites_units << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "-only_counter_ions " << this->only_counter_ions << std::endl;
|
||||
s_oss << "-only_counter_ions " << this->only_counter_ions << "\n";
|
||||
|
||||
//s_oss << indent1;
|
||||
//s_oss << "-donnan " << this->donnan << std::endl;
|
||||
//s_oss << "-donnan " << this->donnan << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "-thickness " << this->thickness << std::endl;
|
||||
s_oss << "-thickness " << this->thickness << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "-debye_lengths " << this->debye_lengths << std::endl;
|
||||
s_oss << "-debye_lengths " << this->debye_lengths << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "-DDL_viscosity " << this->DDL_viscosity << std::endl;
|
||||
s_oss << "-DDL_viscosity " << this->DDL_viscosity << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "-DDL_limit " << this->DDL_limit << std::endl;
|
||||
s_oss << "-DDL_limit " << this->DDL_limit << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "-transport " << this->transport << std::endl;
|
||||
s_oss << "-transport " << this->transport << "\n";
|
||||
|
||||
// surfaceComps structures
|
||||
for (std::map < std::string, cxxSurfaceComp >::const_iterator it =
|
||||
surfaceComps.begin(); it != surfaceComps.end(); ++it)
|
||||
{
|
||||
s_oss << indent1;
|
||||
s_oss << "-component" << std::endl;
|
||||
s_oss << "-component" << "\n";
|
||||
(*it).second.dump_raw(s_oss, indent + 2);
|
||||
}
|
||||
// surface charge structures
|
||||
@ -276,7 +276,7 @@ cxxSurface::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out) cons
|
||||
surfaceCharges.begin(); it != surfaceCharges.end(); ++it)
|
||||
{
|
||||
s_oss << indent1;
|
||||
s_oss << "-charge_component " << std::endl;
|
||||
s_oss << "-charge_component " << "\n";
|
||||
(*it).second.dump_raw(s_oss, indent + 2);
|
||||
}
|
||||
}
|
||||
@ -352,21 +352,21 @@ cxxSurface::read_raw(CParser & parser, bool check)
|
||||
case CParser::OPT_ERROR:
|
||||
opt = CParser::OPT_EOF;
|
||||
parser.error_msg("Unknown input in SURFACE keyword.",
|
||||
CParser::OT_CONTINUE);
|
||||
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
|
||||
useLastLine = false;
|
||||
break;
|
||||
|
||||
case 0: // diffuse_layer
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Diffuse layer is obsolete, use -type.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
/*
|
||||
if (!(parser.get_iss() >> this->diffuse_layer))
|
||||
{
|
||||
this->diffuse_layer = false;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected boolean value for diffuse_layer.", CParser::OT_CONTINUE);
|
||||
parser.error_msg("Expected boolean value for diffuse_layer.", PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
diffuse_layer_defined = true;
|
||||
*/
|
||||
@ -376,13 +376,13 @@ cxxSurface::read_raw(CParser & parser, bool check)
|
||||
case 1: // edl
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("-edl is obsolete, use -type.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
/*
|
||||
if (!(parser.get_iss() >> this->edl))
|
||||
{
|
||||
this->edl = false;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected boolean value for edl.", CParser::OT_CONTINUE);
|
||||
parser.error_msg("Expected boolean value for edl.", PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
edl_defined = true;
|
||||
*/
|
||||
@ -396,7 +396,7 @@ cxxSurface::read_raw(CParser & parser, bool check)
|
||||
parser.incr_input_error();
|
||||
parser.
|
||||
error_msg("Expected boolean value for only_counter_ions.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
only_counter_ions_defined = true;
|
||||
useLastLine = false;
|
||||
@ -405,13 +405,13 @@ cxxSurface::read_raw(CParser & parser, bool check)
|
||||
case 3: // donnan
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("-Donnan is obsolete, use -dl_type.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
/*
|
||||
if (!(parser.get_iss() >> this->donnan))
|
||||
{
|
||||
this->donnan = false;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected boolean value for donnan.", CParser::OT_CONTINUE);
|
||||
parser.error_msg("Expected boolean value for donnan.", PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
donnan_defined = true;
|
||||
*/
|
||||
@ -424,7 +424,7 @@ cxxSurface::read_raw(CParser & parser, bool check)
|
||||
this->thickness = 0.0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for thickness.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
thickness_defined = true;
|
||||
useLastLine = false;
|
||||
@ -492,7 +492,7 @@ cxxSurface::read_raw(CParser & parser, bool check)
|
||||
this->type = NO_EDL;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for type.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
this->type = (SURFACE_TYPE) i;
|
||||
type_defined = true;
|
||||
@ -505,7 +505,7 @@ cxxSurface::read_raw(CParser & parser, bool check)
|
||||
this->dl_type = NO_DL;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for dl_type.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
this->dl_type = (DIFFUSE_LAYER_TYPE) i;
|
||||
dl_type_defined = true;
|
||||
@ -518,7 +518,7 @@ cxxSurface::read_raw(CParser & parser, bool check)
|
||||
this->sites_units = SITES_ABSOLUTE;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for sites_units.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
this->sites_units = (SITES_UNITS) i;
|
||||
sites_units_defined = true;
|
||||
@ -531,7 +531,7 @@ cxxSurface::read_raw(CParser & parser, bool check)
|
||||
this->debye_lengths = 0.0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for debye_lengths.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
debye_lengths_defined = true;
|
||||
useLastLine = false;
|
||||
@ -543,7 +543,7 @@ cxxSurface::read_raw(CParser & parser, bool check)
|
||||
this->DDL_viscosity = 0.0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for DDL_viscosity.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
DDL_viscosity_defined = true;
|
||||
useLastLine = false;
|
||||
@ -555,7 +555,7 @@ cxxSurface::read_raw(CParser & parser, bool check)
|
||||
this->DDL_limit = 0.0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for DDL_limit.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
DDL_limit_defined = true;
|
||||
useLastLine = false;
|
||||
@ -567,7 +567,7 @@ cxxSurface::read_raw(CParser & parser, bool check)
|
||||
this->transport = false;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected boolean value for transport.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
transport_defined = true;
|
||||
useLastLine = false;
|
||||
@ -583,11 +583,11 @@ cxxSurface::read_raw(CParser & parser, bool check)
|
||||
/*
|
||||
if (diffuse_layer_defined == false) {
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Diffuse_layer not defined for SURFACE_RAW input.", CParser::OT_CONTINUE);
|
||||
parser.error_msg("Diffuse_layer not defined for SURFACE_RAW input.", PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (edl_defined == false) {
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Edl not defined for SURFACE_RAW input.", CParser::OT_CONTINUE);
|
||||
parser.error_msg("Edl not defined for SURFACE_RAW input.", PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
*/
|
||||
if (only_counter_ions_defined == false)
|
||||
@ -595,61 +595,61 @@ cxxSurface::read_raw(CParser & parser, bool check)
|
||||
parser.incr_input_error();
|
||||
parser.
|
||||
error_msg("Only_counter_ions not defined for SURFACE_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
/*
|
||||
if (donnan_defined == false) {
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Donnan not defined for SURFACE_RAW input.", CParser::OT_CONTINUE);
|
||||
parser.error_msg("Donnan not defined for SURFACE_RAW input.", PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
*/
|
||||
if (thickness_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Thickness not defined for SURFACE_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (type_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Surface type not defined for SURFACE_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (dl_type_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Dl_type not defined for SURFACE_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (sites_units_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Sites_units not defined for SURFACE_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (debye_lengths_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Debye_lengths not defined for SURFACE_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (DDL_viscosity_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("DDL_viscosity not defined for SURFACE_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (DDL_limit_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("DDL_limit not defined for SURFACE_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (transport_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Transport not defined for SURFACE_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ cxxSurfaceCharge::~cxxSurfaceCharge()
|
||||
// {
|
||||
// std::ostringstream error_oss;
|
||||
// error_oss << "Surface charge psi_master not found." << this->
|
||||
// name << std::endl;
|
||||
// name << "\n";
|
||||
// //Utilities::error_msg(error_oss.str(), CONTINUE);
|
||||
// error_msg(error_oss.str().c_str(), CONTINUE);
|
||||
// }
|
||||
@ -96,23 +96,23 @@ cxxSurfaceCharge::dump_xml(std::ostream & s_oss, unsigned int indent) const
|
||||
|
||||
// Surf_Charge element and attributes
|
||||
|
||||
s_oss << indent0 << "name=\"" << this->name << "\"" << std::endl;
|
||||
s_oss << indent0 << "name=\"" << this->name << "\"" << "\n";
|
||||
s_oss << indent0 << "specific_area=\"" << this->
|
||||
specific_area << "\"" << std::endl;
|
||||
s_oss << indent0 << "grams=\"" << this->grams << "\"" << std::endl;
|
||||
specific_area << "\"" << "\n";
|
||||
s_oss << indent0 << "grams=\"" << this->grams << "\"" << "\n";
|
||||
s_oss << indent0 << "charge_balance=\"" << this->
|
||||
charge_balance << "\"" << std::endl;
|
||||
charge_balance << "\"" << "\n";
|
||||
s_oss << indent0 << "mass_water=\"" << this->
|
||||
mass_water << "\"" << std::endl;
|
||||
s_oss << indent0 << "la_psi=\"" << this->la_psi << "\"" << std::endl;
|
||||
s_oss << indent0 << "la_psi1=\"" << this->la_psi1 << "\"" << std::endl;
|
||||
s_oss << indent0 << "la_psi2=\"" << this->la_psi2 << "\"" << std::endl;
|
||||
mass_water << "\"" << "\n";
|
||||
s_oss << indent0 << "la_psi=\"" << this->la_psi << "\"" << "\n";
|
||||
s_oss << indent0 << "la_psi1=\"" << this->la_psi1 << "\"" << "\n";
|
||||
s_oss << indent0 << "la_psi2=\"" << this->la_psi2 << "\"" << "\n";
|
||||
s_oss << indent0 << "capacitance=\"" << this->
|
||||
capacitance[0] << " " << this->capacitance[0] << "\"" << std::endl;
|
||||
capacitance[0] << " " << this->capacitance[0] << "\"" << "\n";
|
||||
|
||||
// totals
|
||||
s_oss << indent0;
|
||||
s_oss << "<diffuse_layer_totals " << std::endl;
|
||||
s_oss << "<diffuse_layer_totals " << "\n";
|
||||
this->diffuse_layer_totals.dump_xml(s_oss, indent + 1);
|
||||
|
||||
}
|
||||
@ -133,28 +133,28 @@ cxxSurfaceCharge::dump_raw(std::ostream & s_oss, unsigned int indent) const
|
||||
|
||||
// Surf_Charge element and attributes
|
||||
|
||||
s_oss << indent0 << "-name " << this->name << std::endl;
|
||||
s_oss << indent0 << "-name " << this->name << "\n";
|
||||
s_oss << indent1 << "-specific_area " << this->
|
||||
specific_area << std::endl;
|
||||
s_oss << indent1 << "-grams " << this->grams << std::endl;
|
||||
specific_area << "\n";
|
||||
s_oss << indent1 << "-grams " << this->grams << "\n";
|
||||
s_oss << indent1 << "-charge_balance " << this->
|
||||
charge_balance << std::endl;
|
||||
charge_balance << "\n";
|
||||
s_oss << indent1 << "-mass_water " << this->
|
||||
mass_water << std::endl;
|
||||
mass_water << "\n";
|
||||
s_oss << indent1 << "-la_psi " << this->
|
||||
la_psi << std::endl;
|
||||
la_psi << "\n";
|
||||
s_oss << indent1 << "-la_psi1 " << this->
|
||||
la_psi1 << std::endl;
|
||||
la_psi1 << "\n";
|
||||
s_oss << indent1 << "-la_psi2 " << this->
|
||||
la_psi2 << std::endl;
|
||||
la_psi2 << "\n";
|
||||
s_oss << indent1 << "-capacitance0 " << this->
|
||||
capacitance[0] << std::endl;
|
||||
capacitance[0] << "\n";
|
||||
s_oss << indent1 << "-capacitance1 " << this->
|
||||
capacitance[1] << std::endl;
|
||||
capacitance[1] << "\n";
|
||||
|
||||
// totals
|
||||
s_oss << indent1;
|
||||
s_oss << "-diffuse_layer_totals" << std::endl;
|
||||
s_oss << "-diffuse_layer_totals" << "\n";
|
||||
this->diffuse_layer_totals.dump_raw(s_oss, indent + 2);
|
||||
|
||||
}
|
||||
@ -216,8 +216,8 @@ cxxSurfaceCharge::read_raw(CParser & parser, bool check)
|
||||
case CParser::OPT_ERROR:
|
||||
opt = CParser::OPT_KEYWORD;
|
||||
// Allow return to Surface for more processing
|
||||
//parser.error_msg("Unknown input in SURF_CHARGE read.", CParser::OT_CONTINUE);
|
||||
//parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE);
|
||||
//parser.error_msg("Unknown input in SURF_CHARGE read.", PHRQ_io::OT_CONTINUE);
|
||||
//parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
|
||||
break;
|
||||
|
||||
case 0: // name
|
||||
@ -226,7 +226,7 @@ cxxSurfaceCharge::read_raw(CParser & parser, bool check)
|
||||
this->name.clear();
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected string value for name.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -241,7 +241,7 @@ cxxSurfaceCharge::read_raw(CParser & parser, bool check)
|
||||
this->specific_area = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for specific_area.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
specific_area_defined = true;
|
||||
break;
|
||||
@ -252,7 +252,7 @@ cxxSurfaceCharge::read_raw(CParser & parser, bool check)
|
||||
this->grams = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for grams.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
grams_defined = true;
|
||||
break;
|
||||
@ -264,7 +264,7 @@ cxxSurfaceCharge::read_raw(CParser & parser, bool check)
|
||||
this->charge_balance = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for charge_balance.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
charge_balance_defined = true;
|
||||
break;
|
||||
@ -275,7 +275,7 @@ cxxSurfaceCharge::read_raw(CParser & parser, bool check)
|
||||
this->mass_water = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for mass_water.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
mass_water_defined = true;
|
||||
break;
|
||||
@ -287,7 +287,7 @@ cxxSurfaceCharge::read_raw(CParser & parser, bool check)
|
||||
this->la_psi = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for la_psi.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
la_psi_defined = true;
|
||||
break;
|
||||
@ -301,7 +301,7 @@ cxxSurfaceCharge::read_raw(CParser & parser, bool check)
|
||||
parser.
|
||||
error_msg
|
||||
("Expected element name and molality for SurfaceCharge diffuse_layer_totals.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
opt_save = 6;
|
||||
break;
|
||||
@ -312,7 +312,7 @@ cxxSurfaceCharge::read_raw(CParser & parser, bool check)
|
||||
this->la_psi1 = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for la_psi1.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
la_psi1_defined = true;
|
||||
break;
|
||||
@ -323,7 +323,7 @@ cxxSurfaceCharge::read_raw(CParser & parser, bool check)
|
||||
this->la_psi2 = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for la_psi.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
la_psi2_defined = true;
|
||||
break;
|
||||
@ -334,7 +334,7 @@ cxxSurfaceCharge::read_raw(CParser & parser, bool check)
|
||||
this->capacitance[0] = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for capacitance0.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
capacitance0_defined = true;
|
||||
break;
|
||||
@ -345,7 +345,7 @@ cxxSurfaceCharge::read_raw(CParser & parser, bool check)
|
||||
this->capacitance[1] = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for capacitance1.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
capacitance1_defined = true;
|
||||
break;
|
||||
@ -361,62 +361,62 @@ cxxSurfaceCharge::read_raw(CParser & parser, bool check)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Name not defined for SurfaceCharge input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (specific_area_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Specific_area not defined for SurfaceCharge input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (grams_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Grams not defined for SurfaceCharge input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (charge_balance_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.
|
||||
error_msg("Charge_balance not defined for SurfaceCharge input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (mass_water_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Mass_water not defined for SurfaceCharge input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (la_psi_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("La_psi not defined for SurfaceCharge input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (la_psi1_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("La_psi1 not defined for SurfaceCharge input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (la_psi2_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("La_psi2 not defined for SurfaceCharge input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (capacitance0_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Capacitance0 not defined for SurfaceCharge input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (capacitance1_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Capacitance1 not defined for SurfaceCharge input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,36 +77,36 @@ cxxSurfaceComp::dump_xml(std::ostream & s_oss, unsigned int indent) const
|
||||
|
||||
// Surf_Comp element and attributes
|
||||
|
||||
s_oss << indent0 << "formula=\"" << this->formula << "\"" << std::endl;
|
||||
s_oss << indent0 << "formula=\"" << this->formula << "\"" << "\n";
|
||||
s_oss << indent0 << "formula_z=\"" << this->
|
||||
formula_z << "\"" << std::endl;
|
||||
s_oss << indent0 << "moles=\"" << this->moles << "\"" << std::endl;
|
||||
s_oss << indent0 << "la=\"" << this->la << "\"" << std::endl;
|
||||
//s_oss << indent0 << "charge_number=\"" << this->charge_number << "\"" << std::endl;
|
||||
formula_z << "\"" << "\n";
|
||||
s_oss << indent0 << "moles=\"" << this->moles << "\"" << "\n";
|
||||
s_oss << indent0 << "la=\"" << this->la << "\"" << "\n";
|
||||
//s_oss << indent0 << "charge_number=\"" << this->charge_number << "\"" << "\n";
|
||||
s_oss << indent0 << "charge_balance=\"" << this->
|
||||
charge_balance << "\"" << std::endl;
|
||||
charge_balance << "\"" << "\n";
|
||||
if (this->phase_name.size() != 0)
|
||||
{
|
||||
s_oss << indent0 << "phase_name=\"" << this->
|
||||
phase_name << "\"" << std::endl;
|
||||
phase_name << "\"" << "\n";
|
||||
}
|
||||
if (this->rate_name.size() != 0)
|
||||
{
|
||||
s_oss << indent0 << "rate_name=\"" << this->
|
||||
rate_name << "\"" << std::endl;
|
||||
rate_name << "\"" << "\n";
|
||||
}
|
||||
s_oss << indent0 << "phase_proportion=\"" << this->
|
||||
phase_proportion << "\"" << std::endl;
|
||||
s_oss << indent0 << "Dw=\"" << this->Dw << "\"" << std::endl;
|
||||
phase_proportion << "\"" << "\n";
|
||||
s_oss << indent0 << "Dw=\"" << this->Dw << "\"" << "\n";
|
||||
|
||||
// formula_totals
|
||||
s_oss << indent0;
|
||||
s_oss << "<formula_totals " << std::endl;
|
||||
s_oss << "<formula_totals " << "\n";
|
||||
this->formula_totals.dump_xml(s_oss, indent + 1);
|
||||
|
||||
// totals
|
||||
s_oss << indent0;
|
||||
s_oss << "<totals " << std::endl;
|
||||
s_oss << "<totals " << "\n";
|
||||
this->totals.dump_xml(s_oss, indent + 1);
|
||||
|
||||
}
|
||||
@ -128,36 +128,36 @@ cxxSurfaceComp::dump_raw(std::ostream & s_oss, unsigned int indent) const
|
||||
// Surf_Comp element and attributes
|
||||
|
||||
s_oss << indent0 << "-formula " << this->
|
||||
formula << std::endl;
|
||||
formula << "\n";
|
||||
s_oss << indent1 << "-formula_z " << this->
|
||||
formula_z << std::endl;
|
||||
s_oss << indent1 << "-moles " << this->moles << std::endl;
|
||||
s_oss << indent1 << "-la " << this->la << std::endl;
|
||||
//s_oss << indent1 << "-charge_number " << this->charge_number << std::endl;
|
||||
formula_z << "\n";
|
||||
s_oss << indent1 << "-moles " << this->moles << "\n";
|
||||
s_oss << indent1 << "-la " << this->la << "\n";
|
||||
//s_oss << indent1 << "-charge_number " << this->charge_number << "\n";
|
||||
s_oss << indent1 << "-charge_balance " << this->
|
||||
charge_balance << std::endl;
|
||||
charge_balance << "\n";
|
||||
if (this->phase_name.size() != 0)
|
||||
{
|
||||
s_oss << indent1 << "-phase_name " << this->
|
||||
phase_name << std::endl;
|
||||
phase_name << "\n";
|
||||
}
|
||||
if (this->rate_name.size() != 0)
|
||||
{
|
||||
s_oss << indent1 << "-rate_name " << this->
|
||||
rate_name << std::endl;
|
||||
rate_name << "\n";
|
||||
}
|
||||
s_oss << indent1 << "-phase_proportion " << this->
|
||||
phase_proportion << std::endl;
|
||||
s_oss << indent1 << "-Dw " << this->Dw << std::endl;
|
||||
phase_proportion << "\n";
|
||||
s_oss << indent1 << "-Dw " << this->Dw << "\n";
|
||||
|
||||
// formula_totals
|
||||
s_oss << indent1;
|
||||
s_oss << "-formula_totals" << std::endl;
|
||||
s_oss << "-formula_totals" << "\n";
|
||||
this->formula_totals.dump_raw(s_oss, indent + 2);
|
||||
|
||||
// totals
|
||||
s_oss << indent1;
|
||||
s_oss << "-totals" << std::endl;
|
||||
s_oss << "-totals" << "\n";
|
||||
this->totals.dump_raw(s_oss, indent + 2);
|
||||
|
||||
}
|
||||
@ -217,8 +217,8 @@ cxxSurfaceComp::read_raw(CParser & parser, bool check)
|
||||
case CParser::OPT_ERROR:
|
||||
opt = CParser::OPT_KEYWORD;
|
||||
// Allow return to Surface for more processing
|
||||
//parser.error_msg("Unknown input in SURF_COMP read.", CParser::OT_CONTINUE);
|
||||
//parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE);
|
||||
//parser.error_msg("Unknown input in SURF_COMP read.", PHRQ_io::OT_CONTINUE);
|
||||
//parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
|
||||
break;
|
||||
|
||||
case 0: // formula
|
||||
@ -227,7 +227,7 @@ cxxSurfaceComp::read_raw(CParser & parser, bool check)
|
||||
this->formula.clear();
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected string value for formula.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -242,7 +242,7 @@ cxxSurfaceComp::read_raw(CParser & parser, bool check)
|
||||
this->moles = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for moles.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
moles_defined = true;
|
||||
break;
|
||||
@ -253,7 +253,7 @@ cxxSurfaceComp::read_raw(CParser & parser, bool check)
|
||||
this->la = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for la.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
la_defined = true;
|
||||
break;
|
||||
@ -264,7 +264,7 @@ cxxSurfaceComp::read_raw(CParser & parser, bool check)
|
||||
this->charge_number = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected integer value for charge_number.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
charge_number_defined = true;
|
||||
break;
|
||||
@ -275,7 +275,7 @@ cxxSurfaceComp::read_raw(CParser & parser, bool check)
|
||||
this->charge_balance = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for charge_balance.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
charge_balance_defined = true;
|
||||
break;
|
||||
@ -286,7 +286,7 @@ cxxSurfaceComp::read_raw(CParser & parser, bool check)
|
||||
this->phase_name.clear();
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected string value for phase_name.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -300,7 +300,7 @@ cxxSurfaceComp::read_raw(CParser & parser, bool check)
|
||||
this->rate_name.clear();
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected string value for rate_name.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -315,7 +315,7 @@ cxxSurfaceComp::read_raw(CParser & parser, bool check)
|
||||
parser.incr_input_error();
|
||||
parser.
|
||||
error_msg("Expected numeric value for phase_proportion.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -327,7 +327,7 @@ cxxSurfaceComp::read_raw(CParser & parser, bool check)
|
||||
parser.
|
||||
error_msg
|
||||
("Expected element name and molality for SurfaceComp totals.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
opt_save = 8;
|
||||
break;
|
||||
@ -338,7 +338,7 @@ cxxSurfaceComp::read_raw(CParser & parser, bool check)
|
||||
this->formula_z = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for formula_z.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
formula_z_defined = true;
|
||||
break;
|
||||
@ -351,7 +351,7 @@ cxxSurfaceComp::read_raw(CParser & parser, bool check)
|
||||
parser.
|
||||
error_msg
|
||||
("Expected element name and molality for SurfaceComp formula totals.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
opt_save = 10;
|
||||
break;
|
||||
@ -362,7 +362,7 @@ cxxSurfaceComp::read_raw(CParser & parser, bool check)
|
||||
this->Dw = 0.0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for Dw.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
Dw_defined = true;
|
||||
break;
|
||||
@ -377,45 +377,45 @@ cxxSurfaceComp::read_raw(CParser & parser, bool check)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Formula not defined for SurfaceComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (formula_z_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Formula_z not defined for ExchComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (moles_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Moles not defined for SurfaceComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (la_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("La not defined for SurfaceComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
#ifdef SKIP
|
||||
if (charge_number_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Charge_number not defined for SurfaceComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
#endif
|
||||
if (charge_balance_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Charge_balance not defined for SurfaceComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (Dw_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Dw not defined for SurfaceComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,15 +49,15 @@ cxxTemperature::dump_xml(std::ostream & s_oss, unsigned int indent) const const
|
||||
|
||||
// Temperature element and attributes
|
||||
s_oss << indent0;
|
||||
s_oss << "<temperature " << std::endl;
|
||||
s_oss << "<temperature " << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "pitzer_temperature_gammas=\"" << this->
|
||||
pitzer_temperature_gammas << "\"" << std::endl;
|
||||
pitzer_temperature_gammas << "\"" << "\n";
|
||||
|
||||
// components
|
||||
s_oss << indent1;
|
||||
s_oss << "<component " << std::endl;
|
||||
s_oss << "<component " << "\n";
|
||||
for (std::list < cxxTemperatureComp >::const_iterator it =
|
||||
temperatureComps.begin(); it != temperatureComps.end(); ++it)
|
||||
{
|
||||
@ -86,7 +86,7 @@ cxxTemperature::read(CParser & parser)
|
||||
*/
|
||||
// Number and description set in read_reaction_temperature
|
||||
|
||||
CParser::LINE_TYPE lt;
|
||||
PHRQ_io::LINE_TYPE lt;
|
||||
bool done = false;
|
||||
for (;;)
|
||||
{
|
||||
@ -95,21 +95,21 @@ cxxTemperature::read(CParser & parser)
|
||||
std::string token, str;
|
||||
lt = parser.check_line(str, false, true, true, true);
|
||||
|
||||
if (lt == CParser::LT_EMPTY ||
|
||||
lt == CParser::LT_KEYWORD ||
|
||||
lt == CParser::LT_EOF)
|
||||
if (lt == PHRQ_io::LT_EMPTY ||
|
||||
lt == PHRQ_io::LT_KEYWORD ||
|
||||
lt == PHRQ_io::LT_EOF)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (lt == CParser::LT_OPTION)
|
||||
if (lt == PHRQ_io::LT_OPTION)
|
||||
{
|
||||
this->error_msg("Expected numeric value for temperatures.", CParser::OT_CONTINUE);
|
||||
this->error_msg("Expected numeric value for temperatures.", PHRQ_io::OT_CONTINUE);
|
||||
break;
|
||||
}
|
||||
|
||||
if (done)
|
||||
{
|
||||
this->error_msg("Unknown input following equal increment definition.", CParser::OT_CONTINUE);
|
||||
this->error_msg("Unknown input following equal increment definition.", PHRQ_io::OT_CONTINUE);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -136,7 +136,7 @@ cxxTemperature::read(CParser & parser)
|
||||
if (!(iss >> d))
|
||||
{
|
||||
this->error_msg("Expected numeric value for temperatures.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -200,18 +200,18 @@ cxxTemperature::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out)
|
||||
|
||||
s_oss << indent0;
|
||||
int n_user_local = (n_out != NULL) ? *n_out : this->n_user;
|
||||
s_oss << "REACTION_TEMPERATURE_RAW " << n_user_local << " " << this->description << std::endl;
|
||||
s_oss << "REACTION_TEMPERATURE_RAW " << n_user_local << " " << this->description << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "-count_temps " << this->Get_countTemps() << std::endl;
|
||||
s_oss << "-count_temps " << this->Get_countTemps() << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "-equal_increments " << this->equalIncrements << std::endl;
|
||||
s_oss << "-equal_increments " << this->equalIncrements << "\n";
|
||||
|
||||
// Temperature element and attributes
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "-temps " << std::endl;
|
||||
s_oss << "-temps " << "\n";
|
||||
{
|
||||
int i = 0;
|
||||
s_oss << indent2;
|
||||
@ -220,13 +220,13 @@ cxxTemperature::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out)
|
||||
{
|
||||
if (i++ == 5)
|
||||
{
|
||||
s_oss << std::endl;
|
||||
s_oss << "\n";
|
||||
s_oss << indent2;
|
||||
i = 0;
|
||||
}
|
||||
s_oss << *it << " ";
|
||||
}
|
||||
s_oss << std::endl;
|
||||
s_oss << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
@ -285,8 +285,8 @@ cxxTemperature::read_raw(CParser & parser)
|
||||
case CParser::OPT_ERROR:
|
||||
opt = CParser::OPT_EOF;
|
||||
parser.error_msg("Unknown input in TEMPERATURE_COMP_RAW keyword.",
|
||||
CParser::OT_CONTINUE);
|
||||
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
|
||||
useLastLine = false;
|
||||
break;
|
||||
|
||||
@ -304,7 +304,7 @@ cxxTemperature::read_raw(CParser & parser)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for temps.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -322,7 +322,7 @@ cxxTemperature::read_raw(CParser & parser)
|
||||
parser.incr_input_error();
|
||||
parser.
|
||||
error_msg("Expected boolean value for equalIncrements.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
opt_save = CParser::OPT_DEFAULT;
|
||||
useLastLine = false;
|
||||
@ -335,7 +335,7 @@ cxxTemperature::read_raw(CParser & parser)
|
||||
this->countTemps = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected integer value for countTemps.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
opt_save = CParser::OPT_DEFAULT;
|
||||
useLastLine = false;
|
||||
@ -352,7 +352,7 @@ cxxTemperature::read_raw(CParser & parser)
|
||||
parser.
|
||||
error_msg
|
||||
("Equal_increments not defined for REACTION_TEMPERATURE_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (countTemps_defined == false)
|
||||
{
|
||||
@ -360,7 +360,7 @@ cxxTemperature::read_raw(CParser & parser)
|
||||
parser.
|
||||
error_msg
|
||||
("Count_temps not defined for REACTION_TEMPERATURE_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
}
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -23,11 +23,11 @@ class cxxTemperature:public cxxNumKeyword
|
||||
void read_raw(CParser & parser);
|
||||
int read(CParser & parser);
|
||||
LDBLE Temperature_for_step(int step_number);
|
||||
std::vector<double> & Get_temps(void) {return temps;};
|
||||
std::vector<double> & Get_temps(void) {return temps;}
|
||||
int Get_countTemps(void) const;
|
||||
void Set_countTemps(int i) {countTemps = i;};
|
||||
bool Get_equalIncrements(void) const {return equalIncrements;};
|
||||
void Set_equalIncrements(bool tf) {equalIncrements = tf;};
|
||||
void Set_countTemps(int i) {countTemps = i;}
|
||||
bool Get_equalIncrements(void) const {return equalIncrements;}
|
||||
void Set_equalIncrements(bool tf) {equalIncrements = tf;}
|
||||
|
||||
protected:
|
||||
std::vector < double >temps;
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
|
||||
#include "Utils.h"
|
||||
#include "Parser.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
int
|
||||
Utilities::strcmp_nocase_arg1(const char *str1, const char *str2)
|
||||
|
||||
84
Utils.h
84
Utils.h
@ -1,6 +1,6 @@
|
||||
#if !defined(UTILITIES_H_INCLUDED)
|
||||
#define UTILITIES_H_INCLUDED
|
||||
|
||||
#include "Phreeqc.h"
|
||||
#include <string>
|
||||
#include <sstream> // std::istringstream std::ostringstream
|
||||
#include <ostream> // std::ostream
|
||||
@ -11,14 +11,14 @@ namespace Utilities
|
||||
{
|
||||
|
||||
const char INDENT[] = " ";
|
||||
|
||||
#ifdef SKIP
|
||||
enum STATUS_TYPE
|
||||
{
|
||||
OK = 0,
|
||||
ERROR = 1
|
||||
ST_OK = 0,
|
||||
ST_ERROR = 1
|
||||
};
|
||||
|
||||
STATUS_TYPE parse_couple(std::string & token);
|
||||
#endif
|
||||
//STATUS_TYPE parse_couple(std::string & token);
|
||||
|
||||
int strcmp_nocase(const char *str1, const char *str2);
|
||||
|
||||
@ -89,6 +89,78 @@ namespace Utilities
|
||||
return (b.find(i) != b.end());}
|
||||
*/
|
||||
|
||||
template < typename T >
|
||||
void Rxn_copies(std::map < int, T > &b, int n_user, int n_user_end)
|
||||
{
|
||||
if (n_user_end <= n_user) return;
|
||||
typename std::map < int, T >::iterator it;
|
||||
it = b.find(n_user);
|
||||
if (it != b.end())
|
||||
{
|
||||
for (int j = n_user + 1; j <= n_user_end; j++)
|
||||
{
|
||||
b[j] = it->second;
|
||||
it = b.find(j);
|
||||
it->second.Set_n_user(j);
|
||||
it->second.Set_n_user_end(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
template < typename T >
|
||||
int Rxn_read_raw(std::map < int, T > &m, Phreeqc * phreeqc_cookie)
|
||||
{
|
||||
typename std::map < int, T >::iterator it;
|
||||
assert(!phreeqc_cookie->reading_database());
|
||||
|
||||
T entity(phreeqc_cookie->Get_phrq_io());
|
||||
|
||||
CParser parser(phreeqc_cookie->Get_phrq_io());
|
||||
//if (phreeqc_cookie->pr.echo_input == FALSE) parser.set_echo_file(CParser::EO_NONE);
|
||||
entity.read_raw(parser);
|
||||
|
||||
// Store
|
||||
if (entity.Get_base_error_count() == 0)
|
||||
{
|
||||
m[entity.Get_n_user()] = entity;
|
||||
}
|
||||
|
||||
// Make copies if necessary
|
||||
Utilities::Rxn_copies(m, entity.Get_n_user(), entity.Get_n_user_end());
|
||||
return phreeqc_cookie->cleanup_after_parser(parser);
|
||||
}
|
||||
|
||||
template < typename T >
|
||||
int Rxn_read_modify(std::map < int, T > &m, 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);
|
||||
|
||||
return phreeqc_cookie->cleanup_after_parser(parser);
|
||||
}
|
||||
|
||||
/*
|
||||
template<class T>
|
||||
bool exists (std::map<int, T> b, int i){
|
||||
return (b.find(i) != b.end());}
|
||||
*/
|
||||
|
||||
}
|
||||
#endif // UTILITIES_H_INCLUDED
|
||||
|
||||
@ -129,15 +129,15 @@ cxxKinetics::dump_xml(std::ostream & s_oss, unsigned int indent) const const
|
||||
|
||||
// Kinetics element and attributes
|
||||
s_oss << indent0;
|
||||
s_oss << "<kinetics " << std::endl;
|
||||
s_oss << "<kinetics " << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "pitzer_kinetics_gammas=\"" << this->
|
||||
pitzer_kinetics_gammas << "\"" << std::endl;
|
||||
pitzer_kinetics_gammas << "\"" << "\n";
|
||||
|
||||
// components
|
||||
s_oss << indent1;
|
||||
s_oss << "<component " << std::endl;
|
||||
s_oss << "<component " << "\n";
|
||||
for (std::list < cxxKineticsComp >::const_iterator it =
|
||||
kineticsComps.begin(); it != kineticsComps.end(); ++it)
|
||||
{
|
||||
@ -165,47 +165,47 @@ cxxKinetics::dump_raw(std::ostream & s_oss, unsigned int indent, int * n_out) co
|
||||
// Kinetics element and attributes
|
||||
s_oss << indent0;
|
||||
int n_user_local = (n_out != NULL) ? *n_out : this->n_user;
|
||||
s_oss << "KINETICS_RAW " << n_user_local << " " << this->description << std::endl;
|
||||
s_oss << "KINETICS_RAW " << n_user_local << " " << this->description << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "-step_divide " << this->step_divide << std::endl;
|
||||
s_oss << "-step_divide " << this->step_divide << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "-rk " << this->rk << std::endl;
|
||||
s_oss << "-rk " << this->rk << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "-bad_step_max " << this->bad_step_max << std::endl;
|
||||
s_oss << "-bad_step_max " << this->bad_step_max << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "-use_cvode " << this->use_cvode << std::endl;
|
||||
s_oss << "-use_cvode " << this->use_cvode << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "-cvode_steps " << this->cvode_steps << std::endl;
|
||||
s_oss << "-cvode_steps " << this->cvode_steps << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "-cvode_order " << this->cvode_order << std::endl;
|
||||
s_oss << "-cvode_order " << this->cvode_order << "\n";
|
||||
|
||||
// kineticsComps structures
|
||||
for (std::list < cxxKineticsComp >::const_iterator it =
|
||||
kineticsComps.begin(); it != kineticsComps.end(); ++it)
|
||||
{
|
||||
s_oss << indent1;
|
||||
s_oss << "-component" << std::endl;
|
||||
s_oss << "-component" << "\n";
|
||||
(*it).dump_raw(s_oss, indent + 2);
|
||||
}
|
||||
|
||||
// totals
|
||||
s_oss << indent1;
|
||||
s_oss << "-totals " << std::endl;
|
||||
s_oss << "-totals " << "\n";
|
||||
this->totals.dump_raw(s_oss, indent + 2);
|
||||
|
||||
// equal_steps
|
||||
s_oss << indent1;
|
||||
s_oss << "-equal_steps " << this->equal_steps << std::endl;
|
||||
s_oss << "-equal_steps " << this->equal_steps << "\n";
|
||||
|
||||
// steps
|
||||
s_oss << indent1;
|
||||
s_oss << "-steps " << std::endl;
|
||||
s_oss << "-steps " << "\n";
|
||||
{
|
||||
int i = 0;
|
||||
s_oss << indent2;
|
||||
@ -214,13 +214,13 @@ cxxKinetics::dump_raw(std::ostream & s_oss, unsigned int indent, int * n_out) co
|
||||
{
|
||||
if (i++ == 5)
|
||||
{
|
||||
s_oss << std::endl;
|
||||
s_oss << "\n";
|
||||
s_oss << indent2;
|
||||
i = 0;
|
||||
}
|
||||
s_oss << *it << " ";
|
||||
}
|
||||
s_oss << std::endl;
|
||||
s_oss << "\n";
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -291,8 +291,8 @@ cxxKinetics::read_raw(CParser & parser, bool check)
|
||||
case CParser::OPT_ERROR:
|
||||
opt = CParser::OPT_EOF;
|
||||
parser.error_msg("Unknown input in KINETICS_COMP_RAW keyword.",
|
||||
CParser::OT_CONTINUE);
|
||||
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
|
||||
useLastLine = false;
|
||||
break;
|
||||
|
||||
@ -302,7 +302,7 @@ cxxKinetics::read_raw(CParser & parser, bool check)
|
||||
this->step_divide = 1.0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for step_divide.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
step_divide_defined = true;
|
||||
useLastLine = false;
|
||||
@ -314,7 +314,7 @@ cxxKinetics::read_raw(CParser & parser, bool check)
|
||||
this->rk = 3;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected integer value for rk.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
rk_defined = true;
|
||||
useLastLine = false;
|
||||
@ -326,7 +326,7 @@ cxxKinetics::read_raw(CParser & parser, bool check)
|
||||
this->bad_step_max = 500;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected integer value for bad_step_max.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
bad_step_max_defined = true;
|
||||
useLastLine = false;
|
||||
@ -338,7 +338,7 @@ cxxKinetics::read_raw(CParser & parser, bool check)
|
||||
this->use_cvode = false;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected boolean value for use_cvode.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
use_cvode_defined = true;
|
||||
useLastLine = false;
|
||||
@ -404,7 +404,7 @@ cxxKinetics::read_raw(CParser & parser, bool check)
|
||||
parser.
|
||||
error_msg
|
||||
("Expected element name and molality for KineticsComp totals.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
opt_save = 5;
|
||||
useLastLine = false;
|
||||
@ -420,7 +420,7 @@ cxxKinetics::read_raw(CParser & parser, bool check)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for steps.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -438,7 +438,7 @@ cxxKinetics::read_raw(CParser & parser, bool check)
|
||||
this->cvode_steps = 100;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected integer value for cvode_steps.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
cvode_steps_defined = true;
|
||||
useLastLine = false;
|
||||
@ -450,7 +450,7 @@ cxxKinetics::read_raw(CParser & parser, bool check)
|
||||
this->cvode_order = 5;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected integer value for cvode_order.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
cvode_order_defined = true;
|
||||
useLastLine = false;
|
||||
@ -461,7 +461,7 @@ cxxKinetics::read_raw(CParser & parser, bool check)
|
||||
this->equal_steps = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected integer value for equal_steps.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
equal_steps_defined = true;
|
||||
useLastLine = false;
|
||||
@ -482,44 +482,44 @@ cxxKinetics::read_raw(CParser & parser, bool check)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Step_divide not defined for KINETICS_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (rk_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Rk not defined for KINETICS_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (bad_step_max_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Bad_step_max not defined for KINETICS_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (use_cvode_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Use_cvode not defined for KINETICS_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (cvode_steps_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Cvode_steps not defined for KINETICS_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
if (cvode_order_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Cvode_order not defined for KINETICS_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
// disable to remain backward compatible with PHAST restart files?
|
||||
//if (equal_steps_defined == false)
|
||||
//{
|
||||
// parser.incr_input_error();
|
||||
// parser.error_msg("Equal_steps not defined for KINETICS_RAW input.",
|
||||
// CParser::OT_CONTINUE);
|
||||
// PHRQ_io::OT_CONTINUE);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
18
cxxMix.cxx
18
cxxMix.cxx
@ -71,15 +71,15 @@ cxxMix::dump_xml(std::ostream & s_oss, unsigned int indent) const const
|
||||
|
||||
// Mix element and attributes
|
||||
s_oss << indent0;
|
||||
s_oss << "<mix " << std::endl;
|
||||
s_oss << "<mix " << "\n";
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "pitzer_mix_gammas=\"" << this->
|
||||
pitzer_mix_gammas << "\"" << std::endl;
|
||||
pitzer_mix_gammas << "\"" << "\n";
|
||||
|
||||
// components
|
||||
s_oss << indent1;
|
||||
s_oss << "<component " << std::endl;
|
||||
s_oss << "<component " << "\n";
|
||||
for (std::list < cxxMixComp >::const_iterator it = mixComps.begin();
|
||||
it != mixComps.end(); ++it)
|
||||
{
|
||||
@ -107,12 +107,12 @@ cxxMix::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out) const
|
||||
// Mix element and attributes
|
||||
s_oss << indent0;
|
||||
int n_user_local = (n_out != NULL) ? *n_out : this->n_user;
|
||||
s_oss << "MIX " << n_user_local << " " << this->description << std::endl;
|
||||
s_oss << "MIX " << n_user_local << " " << this->description << "\n";
|
||||
|
||||
for (std::map < int, double >::const_iterator it = this->mixComps.begin();
|
||||
it != this->mixComps.end(); it++)
|
||||
{
|
||||
s_oss << indent1 << it->first << " " << it->second << std::endl;
|
||||
s_oss << indent1 << it->first << " " << it->second << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
@ -163,8 +163,8 @@ cxxMix::read_raw(CParser & parser)
|
||||
case CParser::OPT_ERROR:
|
||||
opt = CParser::OPT_EOF;
|
||||
parser.error_msg("Unknown input in MIX_COMP_RAW keyword.",
|
||||
CParser::OT_CONTINUE);
|
||||
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
|
||||
useLastLine = false;
|
||||
break;
|
||||
|
||||
@ -178,7 +178,7 @@ cxxMix::read_raw(CParser & parser)
|
||||
parser.
|
||||
error_msg
|
||||
("Expected integer value for solution number.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
break;
|
||||
}
|
||||
if (!(parser.get_iss() >> d))
|
||||
@ -187,7 +187,7 @@ cxxMix::read_raw(CParser & parser)
|
||||
parser.
|
||||
error_msg
|
||||
("Expected numeric value for solution fraction.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
break;
|
||||
}
|
||||
this->mixComps[i] = d;
|
||||
|
||||
4
cxxMix.h
4
cxxMix.h
@ -34,7 +34,7 @@ class cxxMix:public cxxNumKeyword
|
||||
{
|
||||
mixComps[n] = f;
|
||||
}
|
||||
};
|
||||
}
|
||||
void Multiply(LDBLE f)
|
||||
{
|
||||
for (std::map < int, LDBLE >::iterator it = this->mixComps.begin();
|
||||
@ -42,7 +42,7 @@ class cxxMix:public cxxNumKeyword
|
||||
{
|
||||
it->second *= f;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const std::map < int, LDBLE > & Get_mixComps() const
|
||||
{
|
||||
|
||||
13
dumper.cpp
13
dumper.cpp
@ -2,6 +2,7 @@
|
||||
|
||||
#include "dumper.h"
|
||||
#include "Parser.h"
|
||||
#include "PHRQ_io.h"
|
||||
|
||||
dumper::dumper(PHRQ_io *io)
|
||||
:
|
||||
@ -170,7 +171,7 @@ bool dumper::Read(CParser & parser)
|
||||
else
|
||||
{
|
||||
parser.error_msg("Expected single number or range of numbers.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -241,8 +242,8 @@ bool dumper::Read(CParser & parser)
|
||||
case CParser::OPT_ERROR:
|
||||
opt = CParser::OPT_EOF;
|
||||
parser.error_msg("Unknown input reading DUMP definition.",
|
||||
CParser::OT_CONTINUE);
|
||||
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
|
||||
useLastLine = false;
|
||||
return_value = false;
|
||||
break;
|
||||
@ -393,7 +394,7 @@ bool dumper::Read(CParser & parser)
|
||||
else
|
||||
{
|
||||
parser.error_msg("Expected single number or range of numbers.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -465,8 +466,8 @@ bool dumper::Read(CParser & parser)
|
||||
case CParser::OPT_ERROR:
|
||||
opt = CParser::OPT_EOF;
|
||||
parser.error_msg("Unknown input reading DUMP definition.",
|
||||
CParser::OT_CONTINUE);
|
||||
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
|
||||
useLastLine = false;
|
||||
return_value = false;
|
||||
break;
|
||||
|
||||
14
runner.cpp
14
runner.cpp
@ -95,7 +95,7 @@ bool runner::Read(CParser & parser)
|
||||
else
|
||||
{
|
||||
parser.error_msg("Expected single number or range of numbers.",
|
||||
CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -103,8 +103,8 @@ bool runner::Read(CParser & parser)
|
||||
if (!(parser.get_iss() >> this->start_time))
|
||||
{
|
||||
parser.error_msg("Expected start_time for RUN_CELLS.",
|
||||
CParser::OT_CONTINUE);
|
||||
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
break;
|
||||
case 3: //time_step
|
||||
@ -114,8 +114,8 @@ bool runner::Read(CParser & parser)
|
||||
if (!(parser.get_iss() >> this->time_step))
|
||||
{
|
||||
parser.error_msg("Expected time_step for RUN_CELLS.",
|
||||
CParser::OT_CONTINUE);
|
||||
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -123,8 +123,8 @@ bool runner::Read(CParser & parser)
|
||||
case CParser::OPT_ERROR:
|
||||
opt = CParser::OPT_EOF;
|
||||
parser.error_msg("Unknown input reading RUN_CELLS definition.",
|
||||
CParser::OT_CONTINUE);
|
||||
parser.error_msg(parser.line().c_str(), CParser::OT_CONTINUE);
|
||||
PHRQ_io::OT_CONTINUE);
|
||||
parser.error_msg(parser.line().c_str(), PHRQ_io::OT_CONTINUE);
|
||||
useLastLine = false;
|
||||
return_value = false;
|
||||
break;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user