mirror of
https://git.gfz-potsdam.de/naaice/iphreeqc.git
synced 2025-12-15 16:18:22 +01:00
Initial testing of SOLUTION_MODIFY and EQUILIBRIUM_PHASES_MODIFY.
git-svn-id: svn://136.177.114.72/svn_GW/phreeqcpp/trunk@3721 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
parent
2fd35ce463
commit
cbfb768381
@ -44,7 +44,9 @@ eltList(pp_assemblage_ptr->next_elt)
|
||||
for (i = 0; i < pp_assemblage_ptr->count_comps; i++)
|
||||
{
|
||||
cxxPPassemblageComp ppComp(&(pp_assemblage_ptr->pure_phases[i]));
|
||||
ppAssemblageComps.push_back(ppComp);
|
||||
//ppAssemblageComps.push_back(ppComp);
|
||||
std::string str(ppComp.get_name());
|
||||
this->ppAssemblageComps[str] = ppComp;
|
||||
}
|
||||
}
|
||||
cxxPPassemblage::cxxPPassemblage(const std::map < int,
|
||||
@ -90,8 +92,7 @@ cxxPPassemblage::cxxPPassemblage2pp_assemblage()
|
||||
pp_assemblage_ptr->pure_phases =
|
||||
(struct pure_phase *) free_check_null(pp_assemblage_ptr->pure_phases);
|
||||
pp_assemblage_ptr->pure_phases =
|
||||
cxxPPassemblageComp::cxxPPassemblageComp2pure_phase(this->
|
||||
ppAssemblageComps);
|
||||
cxxPPassemblageComp::cxxPPassemblageComp2pure_phase(this->ppAssemblageComps);
|
||||
pp_assemblage_ptr->next_elt = this->eltList.elt_list();
|
||||
return (pp_assemblage_ptr);
|
||||
}
|
||||
@ -120,10 +121,10 @@ cxxPPassemblage::dump_xml(std::ostream & s_oss, unsigned int indent) const
|
||||
// ppAssemblageComps
|
||||
s_oss << indent1;
|
||||
s_oss << "<pure_phases " << std::endl;
|
||||
for (std::list < cxxPPassemblageComp >::const_iterator it =
|
||||
for (std::map < std::string, cxxPPassemblageComp >::const_iterator it =
|
||||
ppAssemblageComps.begin(); it != ppAssemblageComps.end(); ++it)
|
||||
{
|
||||
it->dump_xml(s_oss, indent + 2);
|
||||
(*it).second.dump_xml(s_oss, indent + 2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -153,12 +154,12 @@ cxxPPassemblage::dump_raw(std::ostream & s_oss, unsigned int indent) const
|
||||
this->eltList.dump_raw(s_oss, indent + 2);
|
||||
|
||||
// ppAssemblagComps
|
||||
for (std::list < cxxPPassemblageComp >::const_iterator it =
|
||||
for (std::map < std::string, cxxPPassemblageComp >::const_iterator it =
|
||||
ppAssemblageComps.begin(); it != ppAssemblageComps.end(); ++it)
|
||||
{
|
||||
s_oss << indent1;
|
||||
s_oss << "-component" << std::endl;
|
||||
it->dump_raw(s_oss, indent + 2);
|
||||
(*it).second.dump_raw(s_oss, indent + 2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -229,9 +230,28 @@ cxxPPassemblage::read_raw(CParser & parser, bool check)
|
||||
|
||||
case 1: // component
|
||||
{
|
||||
std::istream::pos_type pos = parser.tellg();
|
||||
cxxPPassemblageComp ppComp;
|
||||
ppComp.read_raw(parser);
|
||||
this->ppAssemblageComps.push_back(ppComp);
|
||||
ppComp.read_raw(parser, false);
|
||||
|
||||
|
||||
if (this->ppAssemblageComps.find(ppComp.get_name()) != this->ppAssemblageComps.end())
|
||||
{
|
||||
cxxPPassemblageComp & comp = ppAssemblageComps.find(ppComp.get_name())->second;
|
||||
parser.seekg(pos).clear();
|
||||
parser.seekg(pos);
|
||||
comp.read_raw(parser, false);
|
||||
int i=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
parser.seekg(pos).clear();
|
||||
parser.seekg(pos);
|
||||
cxxPPassemblageComp ppComp1;
|
||||
ppComp1.read_raw(parser, false);
|
||||
std::string str(ppComp1.get_name());
|
||||
this->ppAssemblageComps[str] = ppComp1;
|
||||
}
|
||||
}
|
||||
useLastLine = true;
|
||||
break;
|
||||
@ -292,11 +312,11 @@ cxxPPassemblage::totalize()
|
||||
{
|
||||
this->totals.clear();
|
||||
// component structures
|
||||
for (std::list < cxxPPassemblageComp >::iterator it =
|
||||
for (std::map < std::string, cxxPPassemblageComp >::iterator it =
|
||||
ppAssemblageComps.begin(); it != ppAssemblageComps.end(); ++it)
|
||||
{
|
||||
it->totalize();
|
||||
this->totals.add_extensive(it->get_totals(), 1.0);
|
||||
(*it).second.totalize();
|
||||
this->totals.add_extensive((*it).second.get_totals(), 1.0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -310,27 +330,27 @@ cxxPPassemblage::add(const cxxPPassemblage & addee, double extensive)
|
||||
if (extensive == 0.0)
|
||||
return;
|
||||
//std::list<cxxPPassemblageComp> ppAssemblageComps;
|
||||
for (std::list < cxxPPassemblageComp >::const_iterator itadd =
|
||||
addee.ppAssemblageComps.begin();
|
||||
for (std::map < std::string, cxxPPassemblageComp >::const_iterator itadd = addee.ppAssemblageComps.begin();
|
||||
itadd != addee.ppAssemblageComps.end(); ++itadd)
|
||||
{
|
||||
bool found = false;
|
||||
for (std::list < cxxPPassemblageComp >::iterator it =
|
||||
for (std::map < std::string, cxxPPassemblageComp >::iterator it =
|
||||
this->ppAssemblageComps.begin();
|
||||
it != this->ppAssemblageComps.end(); ++it)
|
||||
{
|
||||
if (it->get_name() == itadd->get_name())
|
||||
if ((*it).second.get_name() == itadd->second.get_name())
|
||||
{
|
||||
it->add((*itadd), extensive);
|
||||
(*it).second.add((*itadd).second, extensive);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
cxxPPassemblageComp entity = *itadd;
|
||||
cxxPPassemblageComp entity = (*itadd).second;
|
||||
entity.multiply(extensive);
|
||||
this->ppAssemblageComps.push_back(entity);
|
||||
std::string str(entity.get_name());
|
||||
this->ppAssemblageComps[str] = entity;
|
||||
}
|
||||
}
|
||||
//cxxNameDouble eltList;
|
||||
|
||||
@ -59,7 +59,8 @@ class cxxPPassemblage:public cxxNumKeyword
|
||||
void dump_xml(std::ostream & os, unsigned int indent = 0) const;
|
||||
|
||||
protected:
|
||||
std::list < cxxPPassemblageComp > ppAssemblageComps;
|
||||
//std::list < cxxPPassemblageComp > ppAssemblageComps;
|
||||
std::map <std::string, cxxPPassemblageComp > ppAssemblageComps;
|
||||
cxxNameDouble eltList;
|
||||
cxxNameDouble totals;
|
||||
|
||||
|
||||
@ -64,8 +64,7 @@ cxxPPassemblageComp::get_phase()
|
||||
}
|
||||
|
||||
struct pure_phase *
|
||||
cxxPPassemblageComp::cxxPPassemblageComp2pure_phase(std::list <
|
||||
cxxPPassemblageComp > &el)
|
||||
cxxPPassemblageComp::cxxPPassemblageComp2pure_phase(std::map < std::string, cxxPPassemblageComp > &el)
|
||||
//
|
||||
// Builds pure_phase structure from of cxxPPassemblageComp
|
||||
//
|
||||
@ -77,19 +76,19 @@ cxxPPassemblageComp::cxxPPassemblageComp2pure_phase(std::list <
|
||||
malloc_error();
|
||||
|
||||
int i = 0;
|
||||
for (std::list < cxxPPassemblageComp >::iterator it = el.begin();
|
||||
for (std::map < std::string, cxxPPassemblageComp >::iterator it = el.begin();
|
||||
it != el.end(); ++it)
|
||||
{
|
||||
pure_phase_ptr[i].phase = it->get_phase();
|
||||
pure_phase_ptr[i].name = it->name;
|
||||
pure_phase_ptr[i].add_formula = it->add_formula;
|
||||
pure_phase_ptr[i].si = it->si;
|
||||
pure_phase_ptr[i].moles = it->moles;
|
||||
pure_phase_ptr[i].delta = it->delta;
|
||||
pure_phase_ptr[i].initial_moles = it->initial_moles;
|
||||
pure_phase_ptr[i].force_equality = (int) it->force_equality;
|
||||
pure_phase_ptr[i].dissolve_only = (int) it->dissolve_only;
|
||||
pure_phase_ptr[i].precipitate_only = (int) it->precipitate_only;
|
||||
pure_phase_ptr[i].phase = (*it).second.get_phase();
|
||||
pure_phase_ptr[i].name = (*it).second.name;
|
||||
pure_phase_ptr[i].add_formula = (*it).second.add_formula;
|
||||
pure_phase_ptr[i].si = (*it).second.si;
|
||||
pure_phase_ptr[i].moles = (*it).second.moles;
|
||||
pure_phase_ptr[i].delta = (*it).second.delta;
|
||||
pure_phase_ptr[i].initial_moles = (*it).second.initial_moles;
|
||||
pure_phase_ptr[i].force_equality = (int) (*it).second.force_equality;
|
||||
pure_phase_ptr[i].dissolve_only = (int) (*it).second.dissolve_only;
|
||||
pure_phase_ptr[i].precipitate_only = (int) (*it).second.precipitate_only;
|
||||
i++;
|
||||
}
|
||||
return (pure_phase_ptr);
|
||||
@ -148,23 +147,19 @@ cxxPPassemblageComp::dump_raw(std::ostream & s_oss, unsigned int indent) const
|
||||
s_oss << indent0 << "-name " << this->
|
||||
name << std::endl;
|
||||
if (this->add_formula != NULL)
|
||||
s_oss << indent0 << "-add_formula " << this->
|
||||
s_oss << indent1 << "-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;
|
||||
s_oss << indent0 << "-initial_moles " << this->
|
||||
initial_moles << std::endl;
|
||||
s_oss << indent0 << "-force_equality " << this->
|
||||
force_equality << std::endl;
|
||||
s_oss << indent0 << "-dissolve_only " << this->
|
||||
dissolve_only << std::endl;
|
||||
s_oss << indent0 << "-precipitate_only " << this->
|
||||
precipitate_only << std::endl;
|
||||
s_oss << indent1 << "-si " << this->si << 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;
|
||||
}
|
||||
|
||||
void
|
||||
cxxPPassemblageComp::read_raw(CParser & parser)
|
||||
cxxPPassemblageComp::read_raw(CParser & parser, bool check)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
@ -339,60 +334,63 @@ cxxPPassemblageComp::read_raw(CParser & parser)
|
||||
break;
|
||||
}
|
||||
// members that must be defined
|
||||
if (name_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Name not defined for PPassemblageComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
}
|
||||
if (si_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Si not defined for PPassemblageComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
}
|
||||
if (moles_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Moles not defined for PPassemblageComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
}
|
||||
if (delta_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Delta not defined for PPassemblageComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
}
|
||||
if (initial_moles_defined == false)
|
||||
if (check)
|
||||
{
|
||||
if (name_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Name not defined for PPassemblageComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
}
|
||||
if (si_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Si not defined for PPassemblageComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
}
|
||||
if (moles_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Moles not defined for PPassemblageComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
}
|
||||
if (delta_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Delta not defined for PPassemblageComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
}
|
||||
if (initial_moles_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.
|
||||
error_msg("Initial_moles not defined for PPassemblageComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
}
|
||||
if (dissolve_only_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.
|
||||
error_msg("Dissolve_only not defined for PPassemblageComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
}
|
||||
/* don't check to maintain backward compatibility
|
||||
if (precipitate_only_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.
|
||||
error_msg("Initial_moles not defined for PPassemblageComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
}
|
||||
if (dissolve_only_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.
|
||||
error_msg("Dissolve_only not defined for PPassemblageComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
}
|
||||
/* don't check to maintain backward compatibility
|
||||
if (precipitate_only_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.
|
||||
error_msg("Precipitate_only not defined for PPassemblageComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
}
|
||||
*/
|
||||
if (force_equality_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.
|
||||
error_msg
|
||||
("Force_equality not defined for PPassemblageComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
error_msg("Precipitate_only not defined for PPassemblageComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
}
|
||||
*/
|
||||
if (force_equality_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.
|
||||
error_msg
|
||||
("Force_equality not defined for PPassemblageComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -21,15 +21,13 @@ class cxxPPassemblageComp
|
||||
~cxxPPassemblageComp();
|
||||
|
||||
|
||||
static struct pure_phase *cxxPPassemblageComp2pure_phase(std::list <
|
||||
cxxPPassemblageComp
|
||||
> &el);
|
||||
static struct pure_phase *cxxPPassemblageComp2pure_phase(std::map < std::string, cxxPPassemblageComp > &el);
|
||||
|
||||
void dump_xml(std::ostream & os, unsigned int indent = 0) const;
|
||||
|
||||
void dump_raw(std::ostream & s_oss, unsigned int indent) const;
|
||||
|
||||
void read_raw(CParser & parser);
|
||||
void read_raw(CParser & parser, bool check = true);
|
||||
|
||||
char *get_name() const
|
||||
{
|
||||
|
||||
12
Parser.h
12
Parser.h
@ -169,6 +169,17 @@ class CParser
|
||||
return m_input_error;
|
||||
}
|
||||
|
||||
std::istream::pos_type tellg()
|
||||
{
|
||||
return m_input_stream.tellg();
|
||||
}
|
||||
std::istream& seekg(std::istream::pos_type p)
|
||||
{
|
||||
return m_input_stream.seekg(p);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Copies from begin to token until first space is encountered.
|
||||
@ -298,4 +309,5 @@ inline std::string trim(const std::string& source, const std::string& t = " \t")
|
||||
std::string str = source;
|
||||
return trim_left( trim_right( str , t) , t );
|
||||
}
|
||||
|
||||
#endif // PARSER_H_INCLUDED
|
||||
|
||||
@ -1252,6 +1252,7 @@ read_equilibrium_phases_modify(void)
|
||||
pp_assemblage_free(&(pp_assemblage[n]));
|
||||
pp_assemblage_copy(entity_ptr, &(pp_assemblage[n]), entity_ptr->n_user);
|
||||
pp_assemblage_free(entity_ptr);
|
||||
free_check_null(entity_ptr);
|
||||
|
||||
// Need to output the next keyword
|
||||
output_msg(OUTPUT_CHECKLINE, "\t%s\n", line);
|
||||
|
||||
73
Solution.cxx
73
Solution.cxx
@ -454,9 +454,49 @@ cxxSolution::dump_raw(std::ostream & s_oss, unsigned int indent) const
|
||||
s_oss << "SOLUTION_RAW " << this->n_user << " " << this->
|
||||
description << std::endl;
|
||||
|
||||
s_oss << "# Critical values" << std::endl;
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "-temp " << this->tc << std::endl;
|
||||
|
||||
// new identifier
|
||||
s_oss << indent1;
|
||||
s_oss << "-total_h " << this->total_h << std::endl;
|
||||
|
||||
// new identifier
|
||||
s_oss << indent1;
|
||||
s_oss << "-total_o " << this->total_o << std::endl;
|
||||
|
||||
// new identifier
|
||||
s_oss << indent1;
|
||||
s_oss << "-cb " << this->cb << std::endl;
|
||||
|
||||
// soln_total conc structures
|
||||
s_oss << indent1;
|
||||
s_oss << "-totals" << std::endl;
|
||||
this->totals.dump_raw(s_oss, indent + 2);
|
||||
|
||||
s_oss << "# Optional critical values" << std::endl;
|
||||
|
||||
// Isotopes
|
||||
s_oss << indent1;
|
||||
s_oss << "-Isotopes" << std::endl;
|
||||
{
|
||||
for (std::list < cxxSolutionIsotope >::const_iterator it =
|
||||
this->isotopes.begin(); it != isotopes.end(); ++it)
|
||||
{
|
||||
it->dump_raw(s_oss, indent + 2);
|
||||
}
|
||||
}
|
||||
/*
|
||||
for (std::map <char *, double, CHARSTAR_LESS>::const_iterator it = totals.begin(); it != totals.end(); ++it) {
|
||||
s_oss << indent2;
|
||||
s_oss << it->first << " " << it->second << std::endl;
|
||||
}
|
||||
*/
|
||||
|
||||
s_oss << "# Non-critical values" << std::endl;
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "-pH " << this->ph << std::endl;
|
||||
|
||||
@ -471,18 +511,6 @@ cxxSolution::dump_raw(std::ostream & s_oss, unsigned int indent) const
|
||||
s_oss << indent1;
|
||||
s_oss << "-ah2o " << this->ah2o << std::endl;
|
||||
|
||||
// new identifier
|
||||
s_oss << indent1;
|
||||
s_oss << "-total_h " << this->total_h << std::endl;
|
||||
|
||||
// new identifier
|
||||
s_oss << indent1;
|
||||
s_oss << "-total_o " << this->total_o << std::endl;
|
||||
|
||||
// new identifier
|
||||
s_oss << indent1;
|
||||
s_oss << "-cb " << this->cb << std::endl;
|
||||
|
||||
// new identifier
|
||||
s_oss << indent1;
|
||||
s_oss << "-mass_water " << this->mass_water << std::endl;
|
||||
@ -491,17 +519,6 @@ cxxSolution::dump_raw(std::ostream & s_oss, unsigned int indent) const
|
||||
s_oss << indent1;
|
||||
s_oss << "-total_alkalinity " << this->total_alkalinity << std::endl;
|
||||
|
||||
// soln_total conc structures
|
||||
s_oss << indent1;
|
||||
s_oss << "-totals" << std::endl;
|
||||
this->totals.dump_raw(s_oss, indent + 2);
|
||||
/*
|
||||
for (std::map <char *, double, CHARSTAR_LESS>::const_iterator it = totals.begin(); it != totals.end(); ++it) {
|
||||
s_oss << indent2;
|
||||
s_oss << it->first << " " << it->second << std::endl;
|
||||
}
|
||||
*/
|
||||
|
||||
// master_activity map
|
||||
s_oss << indent1;
|
||||
s_oss << "-activities" << std::endl;
|
||||
@ -528,16 +545,6 @@ cxxSolution::dump_raw(std::ostream & s_oss, unsigned int indent) const
|
||||
}
|
||||
}
|
||||
*/
|
||||
// Isotopes
|
||||
s_oss << indent1;
|
||||
s_oss << "-Isotopes" << std::endl;
|
||||
{
|
||||
for (std::list < cxxSolutionIsotope >::const_iterator it =
|
||||
this->isotopes.begin(); it != isotopes.end(); ++it)
|
||||
{
|
||||
it->dump_raw(s_oss, indent + 2);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user