mirror of
https://git.gfz-potsdam.de/naaice/iphreeqc.git
synced 2025-12-16 08:38:23 +01:00
Removed MOVE_TO_STRUCTURES ifdefs.
Removed most SKIP ifdefs ran test cases OK. git-svn-id: svn://136.177.114.72/svn_GW/phreeqcpp/branches/ErrorHandling@5657 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
parent
9efcd6ecb8
commit
4d728afcbe
110
ExchComp.cxx
110
ExchComp.cxx
@ -129,116 +129,6 @@ cxxExchComp::cxxExchComp(std::vector < cxxExchComp > &ec_vector,
|
||||
cxxExchComp::~cxxExchComp()
|
||||
{
|
||||
}
|
||||
#ifdef MOVE_TO_STRUCTURES
|
||||
struct master *
|
||||
cxxExchComp::get_master(PHREEQC_PTR_ARG)
|
||||
{
|
||||
struct master *master_ptr = NULL;
|
||||
for (std::map < std::string, double >::iterator it =
|
||||
totals.begin(); it != totals.end(); it++)
|
||||
{
|
||||
|
||||
/* Find master species */
|
||||
char *eltName = P_INSTANCE_POINTER string_hsave(it->first.c_str());
|
||||
assert(it->first.size() != 0);
|
||||
struct element *elt_ptr = P_INSTANCE_POINTER element_store(eltName);
|
||||
if (elt_ptr->master == NULL)
|
||||
{
|
||||
std::ostringstream error_oss;
|
||||
error_oss << "Master species not in data base for " << elt_ptr->
|
||||
name << std::endl;
|
||||
//Utilities::error_msg(error_oss.str(), STOP);
|
||||
error_msg(error_oss.str().c_str(), CONTINUE);
|
||||
return (NULL);
|
||||
}
|
||||
if (elt_ptr->master->type != EX)
|
||||
continue;
|
||||
master_ptr = elt_ptr->master;
|
||||
break;
|
||||
}
|
||||
if (master_ptr == NULL)
|
||||
{
|
||||
for (std::map < std::string, double >::iterator it =
|
||||
this->formula_totals.begin(); it != formula_totals.end(); it++)
|
||||
{
|
||||
|
||||
/* Find master species */
|
||||
char *eltName = P_INSTANCE_POINTER string_hsave(it->first.c_str());
|
||||
assert(it->first.size() != 0);
|
||||
struct element *elt_ptr = P_INSTANCE_POINTER element_store(eltName);
|
||||
if (elt_ptr->master == NULL)
|
||||
{
|
||||
std::ostringstream error_oss;
|
||||
error_oss << "Master species not in data base for " <<
|
||||
elt_ptr->name << std::endl;
|
||||
//Utilities::error_msg(error_oss.str(), STOP);
|
||||
error_msg(error_oss.str().c_str(), CONTINUE);
|
||||
return (NULL);
|
||||
}
|
||||
if (elt_ptr->master->type != EX)
|
||||
continue;
|
||||
master_ptr = elt_ptr->master;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (master_ptr == NULL)
|
||||
{
|
||||
std::ostringstream error_oss;
|
||||
error_oss <<
|
||||
"Exchange formula does not contain an exchange master species, "
|
||||
<< this->formula << std::endl;
|
||||
//Utilities::error_msg(error_oss.str(), CONTINUE);
|
||||
error_msg(error_oss.str().c_str(), CONTINUE);
|
||||
|
||||
std::ostringstream oss;
|
||||
this->dump_raw(oss, 0);
|
||||
std::cerr << oss.str();
|
||||
|
||||
}
|
||||
return (master_ptr);
|
||||
}
|
||||
|
||||
struct exch_comp *
|
||||
cxxExchComp::cxxExchComp2exch_comp(PHREEQC_PTR_ARG_COMMA std::map < std::string, cxxExchComp > &el)
|
||||
//
|
||||
// Builds exch_comp structure from of cxxExchComp
|
||||
//
|
||||
{
|
||||
struct exch_comp *exch_comp_ptr =
|
||||
(struct exch_comp *)
|
||||
P_INSTANCE_POINTER PHRQ_malloc((size_t) (el.size() * sizeof(struct exch_comp)));
|
||||
if (exch_comp_ptr == NULL)
|
||||
P_INSTANCE_POINTER malloc_error();
|
||||
|
||||
int i = 0;
|
||||
for (std::map < std::string, cxxExchComp >::iterator it = el.begin(); it != el.end();
|
||||
++it)
|
||||
{
|
||||
if ((*it).second.formula.size() == 0)
|
||||
exch_comp_ptr[i].formula = NULL;
|
||||
else
|
||||
exch_comp_ptr[i].formula = P_INSTANCE_POINTER string_hsave((*it).second.formula.c_str());
|
||||
exch_comp_ptr[i].formula_z = (*it).second.formula_z;
|
||||
exch_comp_ptr[i].totals = (*it).second.totals.elt_list(P_INSTANCE);
|
||||
exch_comp_ptr[i].moles = (*it).second.moles;
|
||||
exch_comp_ptr[i].formula_totals = (*it).second.formula_totals.elt_list(P_INSTANCE);
|
||||
exch_comp_ptr[i].la = (*it).second.la;
|
||||
exch_comp_ptr[i].charge_balance = (*it).second.charge_balance;
|
||||
if ((*it).second.phase_name.size() == 0)
|
||||
exch_comp_ptr[i].phase_name = NULL;
|
||||
else
|
||||
exch_comp_ptr[i].phase_name = P_INSTANCE_POINTER string_hsave((*it).second.phase_name.c_str());
|
||||
exch_comp_ptr[i].phase_proportion = (*it).second.phase_proportion;
|
||||
if ((*it).second.rate_name.size() == 0)
|
||||
exch_comp_ptr[i].rate_name = NULL;
|
||||
else
|
||||
exch_comp_ptr[i].rate_name = P_INSTANCE_POINTER string_hsave((*it).second.rate_name.c_str());
|
||||
exch_comp_ptr[i].master = (*it).second.get_master(P_INSTANCE);
|
||||
i++;
|
||||
}
|
||||
return (exch_comp_ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
cxxExchComp::dump_xml(std::ostream & s_oss, unsigned int indent) const
|
||||
|
||||
113
Exchange.cxx
113
Exchange.cxx
@ -78,17 +78,6 @@ cxxNumKeyword(io)
|
||||
this->add(*entity_ptr, it->second);
|
||||
this->pitzer_exchange_gammas = entity_ptr->pitzer_exchange_gammas;
|
||||
}
|
||||
#ifdef SKIP
|
||||
if (entity_ptr == NULL)
|
||||
{
|
||||
sprintf(error_string, "Exchange %d not found while mixing.",
|
||||
it->first);
|
||||
error_msg(error_string, CONTINUE);
|
||||
input_error++;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -203,31 +192,6 @@ cxxExchange::get_related_rate()
|
||||
return (false);
|
||||
}
|
||||
|
||||
#ifdef MOVE_TO_STRUCTURES
|
||||
struct exchange *
|
||||
cxxExchange::cxxExchange2exchange(PHREEQC_PTR_ARG)
|
||||
//
|
||||
// Builds a exchange structure from instance of cxxExchange
|
||||
//
|
||||
{
|
||||
struct exchange *exchange_ptr = P_INSTANCE_POINTER exchange_alloc();
|
||||
|
||||
exchange_ptr->description = P_INSTANCE_POINTER string_duplicate (this->get_description().c_str());
|
||||
exchange_ptr->n_user = this->n_user;
|
||||
exchange_ptr->n_user_end = this->n_user_end;
|
||||
exchange_ptr->new_def = FALSE;
|
||||
exchange_ptr->solution_equilibria = FALSE;
|
||||
exchange_ptr->n_solution = -2;
|
||||
exchange_ptr->related_phases = (int) this->get_related_phases();
|
||||
exchange_ptr->related_rate = (int) this->get_related_rate();
|
||||
exchange_ptr->pitzer_exchange_gammas = (int) this->pitzer_exchange_gammas;
|
||||
exchange_ptr->count_comps = (int) this->exchComps.size();
|
||||
exchange_ptr->comps = (struct exch_comp *) P_INSTANCE_POINTER free_check_null(exchange_ptr->comps);
|
||||
exchange_ptr->comps = cxxExchComp::cxxExchComp2exch_comp(P_INSTANCE_COMMA this->exchComps);
|
||||
return (exchange_ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
cxxExchange::dump_xml(std::ostream & s_oss, unsigned int indent) const
|
||||
{
|
||||
@ -366,32 +330,6 @@ cxxExchange::read_raw(CParser & parser, bool check)
|
||||
cxxExchComp ec(this->Get_io());
|
||||
|
||||
// preliminary read
|
||||
#ifdef SKIP
|
||||
std::istream::pos_type pos = parser.tellg();
|
||||
CParser::ECHO_OPTION eo = parser.get_echo_file();
|
||||
parser.set_echo_file(CParser::EO_NONE);
|
||||
CParser::ECHO_OPTION eo_s = parser.get_echo_stream();
|
||||
parser.set_echo_stream(CParser::EO_NONE);
|
||||
ec.read_raw(parser, false);
|
||||
parser.set_echo_file(eo);
|
||||
parser.set_echo_stream(eo_s);
|
||||
parser.seekg(pos).clear();
|
||||
parser.seekg(pos);
|
||||
|
||||
if (this->exchComps.find(ec.get_formula()) != this->exchComps.end())
|
||||
{
|
||||
cxxExchComp & comp = this->exchComps.find(ec.get_formula())->second;
|
||||
|
||||
comp.read_raw(parser, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
cxxExchComp ec1;
|
||||
ec1.read_raw(parser, false);
|
||||
std::string str(ec1.get_formula());
|
||||
this->exchComps[str] = ec1;
|
||||
}
|
||||
#endif
|
||||
parser.set_accumulate(true);
|
||||
ec.read_raw(parser, false);
|
||||
parser.set_accumulate(false);
|
||||
@ -431,43 +369,6 @@ cxxExchange::read_raw(CParser & parser, bool check)
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef SKIP
|
||||
void
|
||||
cxxExchange::add(const cxxExchange & addee, double extensive)
|
||||
//
|
||||
// Add existing exchange to "this" exchange
|
||||
//
|
||||
{
|
||||
//std::list<cxxExchComp> exchComps;
|
||||
// exchComps
|
||||
if (extensive == 0.0)
|
||||
return;
|
||||
for (std::list < cxxExchComp >::const_iterator itadd =
|
||||
addee.exchComps.begin(); itadd != addee.exchComps.end(); ++itadd)
|
||||
{
|
||||
bool found = false;
|
||||
for (std::list < cxxExchComp >::iterator it = this->exchComps.begin();
|
||||
it != this->exchComps.end(); ++it)
|
||||
{
|
||||
if (it->get_formula() == itadd->get_formula())
|
||||
{
|
||||
it->add((*itadd), extensive);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
cxxExchComp exc = *itadd;
|
||||
exc.multiply(extensive);
|
||||
//exc.add(*itadd, extensive);
|
||||
this->exchComps.push_back(exc);
|
||||
}
|
||||
}
|
||||
//bool pitzer_exchange_gammas;
|
||||
this->pitzer_exchange_gammas = addee.pitzer_exchange_gammas;
|
||||
}
|
||||
#endif
|
||||
void
|
||||
cxxExchange::add(const cxxExchange & addee, double extensive)
|
||||
//
|
||||
@ -484,19 +385,6 @@ cxxExchange::add(const cxxExchange & addee, double extensive)
|
||||
if (it != this->exchComps.end())
|
||||
{
|
||||
(*it).second.add((*itadd).second, extensive);
|
||||
//bool found = false;
|
||||
//for (std::list < cxxExchComp >::iterator it = this->exchComps.begin();
|
||||
// it != this->exchComps.end(); ++it)
|
||||
//{
|
||||
// if (it->get_formula() == itadd->get_formula())
|
||||
// {
|
||||
// it->add((*itadd), extensive);
|
||||
// found = true;
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
/*if (!found)*/
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -506,7 +394,6 @@ cxxExchange::add(const cxxExchange & addee, double extensive)
|
||||
this->exchComps[(*itadd).first] = exc;
|
||||
}
|
||||
}
|
||||
//bool pitzer_exchange_gammas;
|
||||
this->pitzer_exchange_gammas = addee.pitzer_exchange_gammas;
|
||||
}
|
||||
#ifdef USE_MPI
|
||||
|
||||
69
GasPhase.cxx
69
GasPhase.cxx
@ -123,75 +123,6 @@ cxxNumKeyword(io)
|
||||
cxxGasPhase::~cxxGasPhase()
|
||||
{
|
||||
}
|
||||
#ifdef MOVE_TO_STRUCTURES
|
||||
struct gas_comp *
|
||||
cxxGasPhase::cxxGasPhaseComp2gas_comp(PHREEQC_PTR_ARG)
|
||||
{
|
||||
//struct gas_comp *gas_comp_ptr(NULL);
|
||||
struct gas_comp *gas_comp_ptr = NULL;
|
||||
if (this->gasPhaseComps.size() > 0)
|
||||
{
|
||||
int i = 0;
|
||||
int n;
|
||||
gas_comp_ptr =
|
||||
(struct gas_comp *)
|
||||
P_INSTANCE_POINTER PHRQ_malloc((size_t)
|
||||
(this->gasPhaseComps.size() *
|
||||
sizeof(struct gas_comp)));
|
||||
if (gas_comp_ptr == NULL)
|
||||
P_INSTANCE_POINTER malloc_error();
|
||||
for (cxxNameDouble::iterator it = this->gasPhaseComps.begin();
|
||||
it != this->gasPhaseComps.end(); it++)
|
||||
{
|
||||
gas_comp_ptr[i].name = P_INSTANCE_POINTER string_hsave(it->first.c_str());
|
||||
assert(it->first.size() != 0);
|
||||
gas_comp_ptr[i].phase = P_INSTANCE_POINTER phase_bsearch(it->first.c_str(), &n, TRUE);
|
||||
gas_comp_ptr[i].p_read = 0;
|
||||
gas_comp_ptr[i].moles = it->second;
|
||||
gas_comp_ptr[i].initial_moles = 0;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return (gas_comp_ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MOVE_TO_STRUCTURES
|
||||
struct gas_phase *
|
||||
cxxGasPhase::cxxGasPhase2gas_phase(PHREEQC_PTR_ARG)
|
||||
//
|
||||
// Builds a gas_phase structure from instance of cxxGasPhase
|
||||
//
|
||||
{
|
||||
struct gas_phase *gas_phase_ptr = P_INSTANCE_POINTER gas_phase_alloc();
|
||||
|
||||
gas_phase_ptr->description = P_INSTANCE_POINTER string_duplicate (this->get_description().c_str());
|
||||
gas_phase_ptr->n_user = this->n_user;
|
||||
gas_phase_ptr->n_user_end = this->n_user_end;
|
||||
gas_phase_ptr->new_def = FALSE;
|
||||
gas_phase_ptr->solution_equilibria = FALSE;
|
||||
gas_phase_ptr->n_solution = -2;
|
||||
if (this->type == cxxGasPhase::GP_PRESSURE)
|
||||
{
|
||||
gas_phase_ptr->type = PRESSURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
gas_phase_ptr->type = VOLUME;
|
||||
}
|
||||
gas_phase_ptr->total_p = this->total_p;
|
||||
gas_phase_ptr->volume = this->volume;
|
||||
gas_phase_ptr->temperature = 273.15;
|
||||
|
||||
// comps
|
||||
gas_phase_ptr->count_comps = (int) this->gasPhaseComps.size();
|
||||
gas_phase_ptr->comps =
|
||||
(struct gas_comp *) P_INSTANCE_POINTER free_check_null(gas_phase_ptr->comps);
|
||||
gas_phase_ptr->comps = this->cxxGasPhaseComp2gas_comp(P_INSTANCE);
|
||||
|
||||
return (gas_phase_ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SKIP
|
||||
void
|
||||
|
||||
@ -40,57 +40,11 @@ units("mMol/kgw")
|
||||
pes = NULL;
|
||||
}
|
||||
|
||||
#ifdef SKIP_OR_MOVE_TO_STRUCTURES
|
||||
cxxISolution::cxxISolution(PHREEQC_PTR_ARG_COMMA struct solution *solution_ptr, PHRQ_io *io)
|
||||
:
|
||||
cxxSolution(solution_ptr, io)
|
||||
//, pe(cxxPe_Data::alloc())
|
||||
{
|
||||
density = solution_ptr->density;
|
||||
this->set_units(solution_ptr->units);
|
||||
// totals
|
||||
for (int i = 0; solution_ptr->totals[i].description != NULL; i++)
|
||||
{
|
||||
cxxISolutionComp c(&(solution_ptr->totals[i]), this->Get_io());
|
||||
//comps.insert(solution_ptr->totals[i].description, c);
|
||||
comps[solution_ptr->totals[i].description] = c;
|
||||
}
|
||||
default_pe = solution_ptr->default_pe;
|
||||
// pe_data
|
||||
pes = P_INSTANCE_POINTER pe_data_dup(solution_ptr->pe);
|
||||
}
|
||||
#endif
|
||||
|
||||
cxxISolution::~cxxISolution()
|
||||
{
|
||||
//// ToDo //pe_data_free(this->pes);
|
||||
}
|
||||
|
||||
#ifdef SKIP_OR_MOVE_TO_STRUCTURES
|
||||
struct solution *
|
||||
cxxISolution::cxxISolution2solution(PHREEQC_PTR_ARG)
|
||||
//
|
||||
// Builds a solution structure from instance of cxxISolution
|
||||
//
|
||||
{
|
||||
struct solution *soln_ptr = this->cxxSolution2solution(P_INSTANCE);
|
||||
soln_ptr->new_def = TRUE;
|
||||
soln_ptr->density = this->density;
|
||||
if (this->units.size() == 0)
|
||||
soln_ptr->units = NULL;
|
||||
else
|
||||
soln_ptr->units = P_INSTANCE_POINTER string_hsave(this->units.c_str());
|
||||
soln_ptr->default_pe = this->default_pe;
|
||||
// pe
|
||||
soln_ptr->pe = (struct pe_data *) P_INSTANCE_POINTER pe_data_free(soln_ptr->pe);
|
||||
soln_ptr->pe = P_INSTANCE_POINTER pe_data_dup(this->pes);
|
||||
// totals
|
||||
soln_ptr->totals = (struct conc *) P_INSTANCE_POINTER free_check_null(soln_ptr->totals);
|
||||
soln_ptr->totals = cxxISolutionComp::cxxISolutionComp2conc(P_INSTANCE_COMMA this->comps);
|
||||
return (soln_ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SKIP_OR_MOVE_TO_STRUCTURES
|
||||
void
|
||||
cxxISolution::ConvertUnits(PHREEQC_PTR_ARG)
|
||||
@ -382,13 +336,6 @@ cxxISolution & cxxISolution::read(CParser & parser)
|
||||
if (opt == CParser::OPTION_EOF || opt == CParser::OPTION_KEYWORD)
|
||||
break;
|
||||
}
|
||||
#ifdef SKIP
|
||||
//
|
||||
// Sort totals by description
|
||||
//
|
||||
std::sort(sol.totals.begin(), sol.totals.end());
|
||||
#endif
|
||||
|
||||
//
|
||||
// fix up default units and default pe
|
||||
//
|
||||
|
||||
@ -61,59 +61,6 @@ cxxKineticsComp::~cxxKineticsComp()
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef MOVE_TO_STRUCTURES
|
||||
struct kinetics_comp *
|
||||
cxxKineticsComp::cxxKineticsComp2kinetics_comp(PHREEQC_PTR_ARG_COMMA std::list < cxxKineticsComp >
|
||||
&el)
|
||||
//
|
||||
// Builds kinetics_comp structure from of cxxKineticsComp
|
||||
//
|
||||
{
|
||||
struct kinetics_comp *kinetics_comp_ptr =
|
||||
(struct kinetics_comp *)
|
||||
P_INSTANCE_POINTER PHRQ_malloc((size_t) (el.size() * sizeof(struct kinetics_comp)));
|
||||
if (kinetics_comp_ptr == NULL)
|
||||
P_INSTANCE_POINTER malloc_error();
|
||||
|
||||
int i = 0;
|
||||
for (std::list < cxxKineticsComp >::iterator it = el.begin();
|
||||
it != el.end(); ++it)
|
||||
{
|
||||
if ((*it).rate_name.size() == 0)
|
||||
kinetics_comp_ptr[i].rate_name = NULL;
|
||||
else
|
||||
kinetics_comp_ptr[i].rate_name = P_INSTANCE_POINTER string_hsave((*it).rate_name.c_str());
|
||||
kinetics_comp_ptr[i].list = (*it).namecoef.name_coef(P_INSTANCE);
|
||||
kinetics_comp_ptr[i].count_list = (int) (*it).namecoef.size();
|
||||
kinetics_comp_ptr[i].tol = (*it).tol;
|
||||
kinetics_comp_ptr[i].m = (*it).m;
|
||||
kinetics_comp_ptr[i].initial_moles = 0.;
|
||||
kinetics_comp_ptr[i].m0 = (*it).m0;
|
||||
kinetics_comp_ptr[i].moles = (*it).moles;
|
||||
kinetics_comp_ptr[i].count_c_params = 0;
|
||||
kinetics_comp_ptr[i].c_params = NULL;
|
||||
/*
|
||||
kinetics_comp_ptr[i].count_d_params = 0;
|
||||
kinetics_comp_ptr[i].d_params = NULL;
|
||||
*/
|
||||
|
||||
kinetics_comp_ptr[i].count_d_params = (int) (*it).d_params.size();
|
||||
kinetics_comp_ptr[i].d_params = NULL;
|
||||
if ((*it).d_params.size() > 0)
|
||||
{
|
||||
kinetics_comp_ptr[i].d_params = (LDBLE *)
|
||||
P_INSTANCE_POINTER PHRQ_malloc((size_t) ((*it).d_params.size() * sizeof(double)));
|
||||
if (kinetics_comp_ptr[i].d_params == NULL)
|
||||
P_INSTANCE_POINTER malloc_error();
|
||||
std::copy((*it).d_params.begin(), (*it).d_params.end(),
|
||||
kinetics_comp_ptr[i].d_params);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return (kinetics_comp_ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SKIP
|
||||
void
|
||||
cxxKineticsComp::dump_xml(std::ostream & s_oss, unsigned int indent) const const
|
||||
|
||||
139
NameDouble.cxx
139
NameDouble.cxx
@ -158,145 +158,6 @@ cxxNameDouble::~cxxNameDouble()
|
||||
{
|
||||
}
|
||||
|
||||
struct elt_list *
|
||||
cxxNameDouble::elt_list(PHREEQC_PTR_ARG)
|
||||
//
|
||||
// Builds a exch_comp structure from instance of cxxNameDouble
|
||||
//
|
||||
{
|
||||
assert(this->type == cxxNameDouble::ND_ELT_MOLES);
|
||||
struct elt_list *elt_list_ptr =
|
||||
(struct elt_list *)
|
||||
P_INSTANCE_POINTER PHRQ_malloc((size_t) ((this->size() + 1) * sizeof(struct elt_list)));
|
||||
if (elt_list_ptr == NULL)
|
||||
P_INSTANCE_POINTER malloc_error();
|
||||
int i = 0;
|
||||
for (iterator it = this->begin(); it != this->end(); ++it)
|
||||
{
|
||||
elt_list_ptr[i].elt = P_INSTANCE_POINTER element_store(it->first.c_str());
|
||||
elt_list_ptr[i].coef = it->second;
|
||||
i++;
|
||||
}
|
||||
elt_list_ptr[i].elt = NULL;
|
||||
elt_list_ptr[i].coef = 0;
|
||||
return (elt_list_ptr);
|
||||
}
|
||||
|
||||
#ifdef MOVE_TO_STRUCTURES
|
||||
struct master_activity *
|
||||
cxxNameDouble::master_activity(PHREEQC_PTR_ARG) const
|
||||
//
|
||||
// Builds a list of master_activity structures from instance of cxxNameDouble
|
||||
//
|
||||
{
|
||||
int i = 0;
|
||||
assert(this->type == cxxNameDouble::ND_SPECIES_LA
|
||||
|| this->type == cxxNameDouble::ND_SPECIES_GAMMA);
|
||||
struct master_activity *master_activity_ptr = NULL;
|
||||
switch ((*this).type)
|
||||
{
|
||||
case cxxNameDouble::ND_SPECIES_LA:
|
||||
{
|
||||
master_activity_ptr =
|
||||
(struct master_activity *)
|
||||
P_INSTANCE_POINTER PHRQ_malloc((size_t)
|
||||
(((*this).size() +
|
||||
1) * sizeof(struct master_activity)));
|
||||
if (master_activity_ptr == NULL)
|
||||
P_INSTANCE_POINTER malloc_error();
|
||||
for (const_iterator it = (*this).begin(); it != (*this).end();
|
||||
it++)
|
||||
{
|
||||
master_activity_ptr[i].description = P_INSTANCE_POINTER string_hsave(it->first.c_str());
|
||||
master_activity_ptr[i].la = it->second;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
master_activity_ptr[i].description = NULL;
|
||||
break;
|
||||
case cxxNameDouble::ND_SPECIES_GAMMA:
|
||||
{
|
||||
if ((*this).size() > 0)
|
||||
{
|
||||
master_activity_ptr =
|
||||
(struct master_activity *)
|
||||
P_INSTANCE_POINTER PHRQ_malloc((size_t)
|
||||
(((*this).size()) *
|
||||
sizeof(struct master_activity)));
|
||||
if (master_activity_ptr == NULL)
|
||||
P_INSTANCE_POINTER malloc_error();
|
||||
for (const_iterator it = (*this).begin(); it != (*this).end();
|
||||
it++)
|
||||
{
|
||||
master_activity_ptr[i].description = P_INSTANCE_POINTER string_hsave(it->first.c_str());
|
||||
master_activity_ptr[i].la = it->second;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case cxxNameDouble::ND_ELT_MOLES:
|
||||
case cxxNameDouble::ND_NAME_COEF:
|
||||
break;
|
||||
}
|
||||
return (master_activity_ptr);
|
||||
}
|
||||
|
||||
struct conc *
|
||||
cxxNameDouble::conc(PHREEQC_PTR_ARG) const
|
||||
// for Solutions, not ISolutions
|
||||
// takes a map of (elt name, moles)
|
||||
// returns list of conc structures
|
||||
{
|
||||
struct conc *c;
|
||||
assert(this->type == cxxNameDouble::ND_ELT_MOLES);
|
||||
c = (struct conc *)
|
||||
P_INSTANCE_POINTER PHRQ_malloc((size_t) (((*this).size() + 1) * sizeof(struct conc)));
|
||||
if (c == NULL)
|
||||
P_INSTANCE_POINTER malloc_error();
|
||||
int i = 0;
|
||||
for (const_iterator it = (*this).begin(); it != (*this).end(); ++it)
|
||||
{
|
||||
c[i].description = P_INSTANCE_POINTER string_hsave(it->first.c_str());
|
||||
c[i].moles = it->second;
|
||||
c[i].input_conc = it->second;
|
||||
c[i].units = NULL;
|
||||
c[i].equation_name = NULL;
|
||||
c[i].phase_si = 0.0;
|
||||
c[i].n_pe = 0;
|
||||
c[i].as = NULL;
|
||||
c[i].gfw = 0.0;
|
||||
//c[i].skip = 0;
|
||||
c[i].phase = NULL;
|
||||
i++;
|
||||
}
|
||||
c[i].description = NULL;
|
||||
return (c);
|
||||
}
|
||||
|
||||
struct name_coef *
|
||||
cxxNameDouble::name_coef(PHREEQC_PTR_ARG) const
|
||||
//
|
||||
// Builds a name_coef structure from instance of cxxNameDouble
|
||||
//
|
||||
{
|
||||
assert(this->type == cxxNameDouble::ND_NAME_COEF);
|
||||
struct name_coef *name_coef_ptr =
|
||||
(struct name_coef *)
|
||||
P_INSTANCE_POINTER PHRQ_malloc((size_t) ((this->size()) * sizeof(struct name_coef)));
|
||||
if (name_coef_ptr == NULL)
|
||||
P_INSTANCE_POINTER malloc_error();
|
||||
int i = 0;
|
||||
for (const_iterator it = (*this).begin(); it != (*this).end(); ++it)
|
||||
{
|
||||
name_coef_ptr[i].name = P_INSTANCE_POINTER string_hsave(it->first.c_str());
|
||||
name_coef_ptr[i].coef = it->second;
|
||||
i++;
|
||||
}
|
||||
return (name_coef_ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
cxxNameDouble::dump_xml(std::ostream & s_oss, unsigned int indent) const
|
||||
{
|
||||
|
||||
14
NameDouble.h
14
NameDouble.h
@ -34,23 +34,12 @@ class cxxNameDouble:public
|
||||
~
|
||||
cxxNameDouble();
|
||||
|
||||
struct elt_list * elt_list(PHREEQC_PTR_ARG);
|
||||
|
||||
//struct master_activity * master_activity(PHREEQC_PTR_ARG) const;
|
||||
|
||||
//struct conc * conc(PHREEQC_PTR_ARG) const;
|
||||
|
||||
//struct name_coef * name_coef(PHREEQC_PTR_ARG) const;
|
||||
|
||||
void
|
||||
dump_xml(std::ostream & s_oss, unsigned int indent) const;
|
||||
|
||||
void
|
||||
dump_raw(std::ostream & s_oss, unsigned int indent) const;
|
||||
|
||||
CParser::STATUS_TYPE
|
||||
read_raw(CParser & parser, std::istream::pos_type & pos);
|
||||
|
||||
void
|
||||
add_extensive(const cxxNameDouble & old, double factor);
|
||||
void
|
||||
@ -61,7 +50,6 @@ class cxxNameDouble:public
|
||||
add(const char *key, double total);
|
||||
void
|
||||
multiply(double factor);
|
||||
|
||||
void
|
||||
merge_redox(const cxxNameDouble & source);
|
||||
|
||||
@ -75,7 +63,7 @@ class cxxNameDouble:public
|
||||
}
|
||||
|
||||
void
|
||||
mpi_pack(PHREEQC_PTR_ARG_COMMA std::vector < int >&ints, std::vector < double >&doubles);
|
||||
mpi_pack(std::vector < int >&ints, std::vector < double >&doubles);
|
||||
void
|
||||
mpi_pack(int *ints, int *ii, double *doubles, int *dd);
|
||||
|
||||
|
||||
@ -81,28 +81,6 @@ cxxPPassemblage::~cxxPPassemblage()
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef MOVE_TO_STRUCTURES
|
||||
struct pp_assemblage *
|
||||
cxxPPassemblage::cxxPPassemblage2pp_assemblage(PHREEQC_PTR_ARG)
|
||||
//
|
||||
// Builds a pp_assemblage structure from instance of cxxPPassemblage
|
||||
//
|
||||
{
|
||||
struct pp_assemblage *pp_assemblage_ptr = P_INSTANCE_POINTER pp_assemblage_alloc();
|
||||
|
||||
pp_assemblage_ptr->description = P_INSTANCE_POINTER string_duplicate (this->get_description().c_str());
|
||||
pp_assemblage_ptr->n_user = this->n_user;
|
||||
pp_assemblage_ptr->n_user_end = this->n_user_end;
|
||||
pp_assemblage_ptr->new_def = FALSE;
|
||||
pp_assemblage_ptr->count_comps = (int) this->ppAssemblageComps.size();
|
||||
pp_assemblage_ptr->pure_phases =
|
||||
(struct pure_phase *) P_INSTANCE_POINTER free_check_null(pp_assemblage_ptr->pure_phases);
|
||||
pp_assemblage_ptr->pure_phases =
|
||||
cxxPPassemblageComp::cxxPPassemblageComp2pure_phase(P_INSTANCE_COMMA this->ppAssemblageComps);
|
||||
pp_assemblage_ptr->next_elt = this->eltList.elt_list(P_INSTANCE);
|
||||
return (pp_assemblage_ptr);
|
||||
}
|
||||
#endif
|
||||
void
|
||||
cxxPPassemblage::dump_xml(std::ostream & s_oss, unsigned int indent) const
|
||||
{
|
||||
@ -239,33 +217,6 @@ cxxPPassemblage::read_raw(CParser & parser, bool check)
|
||||
cxxPPassemblageComp ec(this->Get_io());
|
||||
|
||||
// preliminary read
|
||||
#ifdef SKIP
|
||||
std::istream::pos_type pos = parser.tellg();
|
||||
CParser::ECHO_OPTION eo = parser.get_echo_file();
|
||||
parser.set_echo_file(CParser::EO_NONE);
|
||||
CParser::ECHO_OPTION eo_s = parser.get_echo_stream();
|
||||
parser.set_echo_stream(CParser::EO_NONE);
|
||||
ppComp.read_raw(parser, false);
|
||||
parser.set_echo_file(eo);
|
||||
parser.set_echo_stream(eo_s);
|
||||
|
||||
if (this->ppAssemblageComps.find(ppComp.get_name()) != this->ppAssemblageComps.end())
|
||||
{
|
||||
cxxPPassemblageComp & comp = this->ppAssemblageComps.find(ppComp.get_name())->second;
|
||||
parser.seekg(pos).clear();
|
||||
parser.seekg(pos);
|
||||
comp.read_raw(parser, false);
|
||||
}
|
||||
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;
|
||||
}
|
||||
#endif
|
||||
parser.set_accumulate(true);
|
||||
ec.read_raw(parser, false);
|
||||
parser.set_accumulate(false);
|
||||
|
||||
@ -63,44 +63,6 @@ cxxPPassemblageComp::~cxxPPassemblageComp()
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef MOVE_TO_STRUCTURES
|
||||
struct pure_phase *
|
||||
cxxPPassemblageComp::cxxPPassemblageComp2pure_phase(PHREEQC_PTR_ARG_COMMA std::map < std::string, cxxPPassemblageComp > &el)
|
||||
//
|
||||
// Builds pure_phase structure from of cxxPPassemblageComp
|
||||
//
|
||||
{
|
||||
struct pure_phase *pure_phase_ptr =
|
||||
(struct pure_phase *)
|
||||
P_INSTANCE_POINTER PHRQ_malloc((size_t) (el.size() * sizeof(struct pure_phase)));
|
||||
if (pure_phase_ptr == NULL)
|
||||
P_INSTANCE_POINTER malloc_error();
|
||||
|
||||
int i = 0;
|
||||
for (std::map < std::string, cxxPPassemblageComp >::iterator it = el.begin();
|
||||
it != el.end(); ++it)
|
||||
{
|
||||
pure_phase_ptr[i].phase = (*it).second.get_phase(P_INSTANCE);
|
||||
if ((*it).second.name.size() == 0)
|
||||
pure_phase_ptr[i].name = NULL;
|
||||
else
|
||||
pure_phase_ptr[i].name = P_INSTANCE_POINTER string_hsave((*it).second.name.c_str());
|
||||
if ((*it).second.add_formula.size() == 0)
|
||||
pure_phase_ptr[i].add_formula = NULL;
|
||||
else
|
||||
pure_phase_ptr[i].add_formula = P_INSTANCE_POINTER string_hsave((*it).second.add_formula.c_str());
|
||||
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);
|
||||
}
|
||||
#endif
|
||||
void
|
||||
cxxPPassemblageComp::dump_xml(std::ostream & s_oss, unsigned int indent) const
|
||||
{
|
||||
|
||||
54
Reaction.cxx
54
Reaction.cxx
@ -74,60 +74,6 @@ cxxReaction::~cxxReaction()
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef MOVE_TO_STRUCTURES
|
||||
struct irrev *
|
||||
cxxReaction::cxxReaction2irrev(PHREEQC_PTR_ARG)
|
||||
//
|
||||
// Builds a irrev structure from instance of cxxReaction
|
||||
//
|
||||
{
|
||||
struct irrev *irrev_ptr;
|
||||
irrev_ptr = (struct irrev *) P_INSTANCE_POINTER PHRQ_malloc(sizeof(struct irrev));
|
||||
if (irrev_ptr == NULL)
|
||||
P_INSTANCE_POINTER malloc_error();
|
||||
|
||||
irrev_ptr->description = P_INSTANCE_POINTER string_duplicate (this->get_description().c_str());
|
||||
irrev_ptr->n_user = this->n_user;
|
||||
irrev_ptr->n_user_end = this->n_user_end;
|
||||
|
||||
irrev_ptr->list = this->reactantList.name_coef(P_INSTANCE);
|
||||
irrev_ptr->count_list = (int) this->reactantList.size();
|
||||
if (this->elementList.size() > 0)
|
||||
{
|
||||
irrev_ptr->elts = this->elementList.elt_list(P_INSTANCE);
|
||||
}
|
||||
else
|
||||
{
|
||||
// NULL value causes reaction stoichiometry to be calculated
|
||||
irrev_ptr->elts = NULL;
|
||||
}
|
||||
// steps
|
||||
irrev_ptr->steps = NULL;
|
||||
if (this->steps.size() > 0)
|
||||
{
|
||||
irrev_ptr->steps =
|
||||
(LDBLE *)
|
||||
P_INSTANCE_POINTER PHRQ_malloc((size_t) (this->steps.size() * sizeof(double)));
|
||||
if (irrev_ptr->steps == NULL)
|
||||
P_INSTANCE_POINTER malloc_error();
|
||||
std::copy(this->steps.begin(), this->steps.end(), irrev_ptr->steps);
|
||||
}
|
||||
if (this->equalIncrements)
|
||||
{
|
||||
irrev_ptr->count_steps = -this->countSteps;
|
||||
}
|
||||
else
|
||||
{
|
||||
irrev_ptr->count_steps = (int) this->steps.size();
|
||||
}
|
||||
if (this->units.size() == 0)
|
||||
irrev_ptr->units = NULL;
|
||||
else
|
||||
irrev_ptr->units = P_INSTANCE_POINTER string_hsave(this->units.c_str());
|
||||
return (irrev_ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SKIP
|
||||
void
|
||||
cxxReaction::dump_xml(std::ostream & s_oss, unsigned int indent) const const
|
||||
|
||||
232
ReadClass.cxx
232
ReadClass.cxx
@ -1165,97 +1165,6 @@ read_run_cells(void)
|
||||
if (return_value == OPTION_KEYWORD) output_msg(OUTPUT_CHECKLINE, "\t%s\n", line);
|
||||
return (return_value);
|
||||
}
|
||||
#ifdef SKIP
|
||||
/* ---------------------------------------------------------------------- */
|
||||
int CLASS_QUALIFIER
|
||||
read_solution_modify(void)
|
||||
/* ---------------------------------------------------------------------- */
|
||||
{
|
||||
/*
|
||||
* Reads solution_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 solution number
|
||||
char token[MAX_LENGTH];
|
||||
char *next;
|
||||
int l, n_user, n;
|
||||
next = line;
|
||||
copy_token(token, &next, &l);
|
||||
if (copy_token(token, &next, &l) != DIGIT)
|
||||
{
|
||||
input_error++;
|
||||
sprintf(error_string, "Expected solution number following SOLUTION_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);
|
||||
std::ostringstream oss_out;
|
||||
std::ostringstream oss_err;
|
||||
CParser parser(PHREEQC_THIS_COMMA iss_in, oss_out, oss_err);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
if (solution_bsearch(n_user, &n, FALSE) == NULL)
|
||||
{
|
||||
input_error++;
|
||||
sprintf(error_string, "Solution %d not found for SOLUTION_MODIFY.\n", n_user);
|
||||
error_msg(error_string, CONTINUE);
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
cxxSolution sol(solution[n]);
|
||||
sol.read_raw(parser, false);
|
||||
|
||||
struct solution *soln_ptr = sol.cxxSolution2solution(PHREEQC_THIS);
|
||||
|
||||
/*
|
||||
* This is not quite right, may not produce sort order, forced sort
|
||||
*/
|
||||
|
||||
solution_free(solution[n]);
|
||||
solution[n] = soln_ptr;
|
||||
|
||||
// Need to output the next keyword
|
||||
if (return_value == OPTION_KEYWORD) output_msg(OUTPUT_CHECKLINE, "\t%s\n", line);
|
||||
return (return_value);
|
||||
}
|
||||
#endif
|
||||
/* ---------------------------------------------------------------------- */
|
||||
int CLASS_QUALIFIER
|
||||
read_solution_modify(void)
|
||||
@ -2335,147 +2244,6 @@ delete_entities(void)
|
||||
delete_info.SetAll(false);
|
||||
return (OK);
|
||||
}
|
||||
#ifdef SKIP
|
||||
/* ---------------------------------------------------------------------- */
|
||||
int
|
||||
run_as_cells(void)
|
||||
/* ---------------------------------------------------------------------- */
|
||||
{
|
||||
int i, n;
|
||||
LDBLE kin_time;
|
||||
/*
|
||||
* Calculate advection
|
||||
*/
|
||||
state = ADVECTION;
|
||||
/* mass_water_switch = TRUE; */
|
||||
/*
|
||||
* Check existence of all solutions
|
||||
*/
|
||||
if (run_info.Get_cells().Get_numbers().size() == 0 ||
|
||||
!(run_info.Get_cells().Get_defined())) return(OK);
|
||||
|
||||
dup_print("Beginning of run as cells.", TRUE);
|
||||
|
||||
std::set < int >::iterator it = run_info.Get_cells().Get_numbers().begin();
|
||||
last_model.force_prep = TRUE;
|
||||
initial_total_time = run_info.Get_start_time();
|
||||
rate_sim_time_start = 0;
|
||||
kin_time = run_info.Get_time_step();
|
||||
double advection_kin_time_save = advection_kin_time;
|
||||
advection_kin_time = kin_time;
|
||||
|
||||
for ( ; it != run_info.Get_cells().Get_numbers().end(); it++)
|
||||
{
|
||||
i = *it;
|
||||
if (i < 0) continue;
|
||||
//if (solution_bsearch(i, &n, TRUE) == NULL)
|
||||
//{
|
||||
// sprintf(error_string,
|
||||
// "Solution %d is needed for RUN, but is not defined.", i);
|
||||
// warning_msg(error_string);
|
||||
// continue;
|
||||
//}
|
||||
/*
|
||||
* Equilibrate and (or) mix
|
||||
*/
|
||||
set_initial_moles(i);
|
||||
cell_no = i;
|
||||
set_advection(i, TRUE, TRUE, i);
|
||||
reactions();
|
||||
|
||||
//run_reactions(i, kin_time, TRUE, 1.0);
|
||||
////rate_sim_time = rate_sim_time_start + kin_time;
|
||||
|
||||
//punch_all();
|
||||
//print_all();
|
||||
//save.n_solution_user = i;
|
||||
//save.n_solution_user_end = i;
|
||||
//struct save save_dbg = save;
|
||||
saver();
|
||||
}
|
||||
double advection_kin_time = advection_kin_time_save;
|
||||
initial_total_time += rate_sim_time_start;
|
||||
/* free_model_allocs(); */
|
||||
mass_water_switch = FALSE;
|
||||
run_info.Get_cells().Set_defined(false);
|
||||
return (OK);
|
||||
}
|
||||
#endif
|
||||
#ifdef SKIP2
|
||||
/* ---------------------------------------------------------------------- */
|
||||
int CLASS_QUALIFIER
|
||||
run_as_cells(void)
|
||||
/* ---------------------------------------------------------------------- */
|
||||
{
|
||||
struct save save_data;
|
||||
LDBLE kin_time;
|
||||
|
||||
state = REACTION;
|
||||
if (run_info.Get_cells().Get_numbers().size() == 0 ||
|
||||
!(run_info.Get_cells().Get_defined())) return(OK);
|
||||
|
||||
dup_print("Beginning of run as cells.", TRUE);
|
||||
|
||||
std::set < int >::iterator it = run_info.Get_cells().Get_numbers().begin();
|
||||
last_model.force_prep = TRUE;
|
||||
initial_total_time = run_info.Get_start_time();
|
||||
rate_sim_time_start = 0;
|
||||
kin_time = run_info.Get_time_step();
|
||||
|
||||
for ( ; it != run_info.Get_cells().Get_numbers().end(); it++)
|
||||
{
|
||||
int i = *it;
|
||||
if (i < 0) continue;
|
||||
|
||||
set_advection(i, TRUE, TRUE, i);
|
||||
|
||||
save_data = save;
|
||||
|
||||
/* last_model.force_prep = TRUE; */
|
||||
//if (set_use() == FALSE)
|
||||
// return (OK);
|
||||
|
||||
/*
|
||||
* save data for saving solutions
|
||||
*/
|
||||
//memcpy(&save_data, &save, sizeof(struct save));
|
||||
/*
|
||||
*Copy everything to -2
|
||||
*/
|
||||
copy_use(-2);
|
||||
rate_sim_time_start = 0;
|
||||
rate_sim_time = 0;
|
||||
|
||||
set_initial_moles(-2);
|
||||
|
||||
/*
|
||||
* Run reaction step
|
||||
*/
|
||||
run_reactions(-2, kin_time, TRUE, 1.0);
|
||||
rate_sim_time = kin_time;
|
||||
|
||||
punch_all();
|
||||
print_all();
|
||||
|
||||
/* saves back into -2 */
|
||||
save = save_data;
|
||||
saver();
|
||||
}
|
||||
/*
|
||||
* save end of reaction
|
||||
*/
|
||||
//memcpy(&save, &save_data, sizeof(struct save));
|
||||
//if (use.kinetics_in == TRUE)
|
||||
//{
|
||||
// kinetics_duplicate(-2, use.n_kinetics_user);
|
||||
//}
|
||||
//saver();
|
||||
run_info.Get_cells().Set_defined(false);
|
||||
/* free_model_allocs(); */
|
||||
/* last_model.force_prep = TRUE; */
|
||||
return (OK);
|
||||
}
|
||||
#endif
|
||||
/* ---------------------------------------------------------------------- */
|
||||
int CLASS_QUALIFIER
|
||||
run_as_cells(void)
|
||||
|
||||
@ -78,26 +78,6 @@ cxxSSassemblage::~cxxSSassemblage()
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef MOVE_TO_STRUCTURES
|
||||
struct s_s_assemblage *
|
||||
cxxSSassemblage::cxxSSassemblage2s_s_assemblage(PHREEQC_PTR_ARG)
|
||||
//
|
||||
// Builds a s_s_assemblage structure from instance of cxxSSassemblage
|
||||
//
|
||||
{
|
||||
struct s_s_assemblage *s_s_assemblage_ptr = P_INSTANCE_POINTER s_s_assemblage_alloc();
|
||||
|
||||
s_s_assemblage_ptr->description = P_INSTANCE_POINTER string_duplicate (this->get_description().c_str());
|
||||
s_s_assemblage_ptr->n_user = this->n_user;
|
||||
s_s_assemblage_ptr->n_user_end = this->n_user_end;
|
||||
s_s_assemblage_ptr->new_def = FALSE;
|
||||
s_s_assemblage_ptr->count_s_s = (int) this->ssAssemblageSSs.size();
|
||||
s_s_assemblage_ptr->s_s =
|
||||
cxxSSassemblageSS::cxxSSassemblageSS2s_s(P_INSTANCE_COMMA this->ssAssemblageSSs);
|
||||
return (s_s_assemblage_ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SKIP
|
||||
void
|
||||
cxxSSassemblage::dump_xml(std::ostream & s_oss, unsigned int indent) const const
|
||||
@ -216,31 +196,6 @@ cxxSSassemblage::read_raw(CParser & parser, bool check)
|
||||
cxxSSassemblageSS ec(this->Get_io());
|
||||
|
||||
// preliminary read
|
||||
#ifdef SKIP
|
||||
std::istream::pos_type pos = parser.tellg();
|
||||
CParser::ECHO_OPTION eo = parser.get_echo_file();
|
||||
parser.set_echo_file(CParser::EO_NONE);
|
||||
CParser::ECHO_OPTION eo_s = parser.get_echo_stream();
|
||||
parser.set_echo_stream(CParser::EO_NONE);
|
||||
ec.read_raw(parser, false);
|
||||
parser.set_echo_file(eo);
|
||||
parser.set_echo_stream(eo_s);
|
||||
parser.seekg(pos).clear();
|
||||
parser.seekg(pos);
|
||||
|
||||
if (this->ssAssemblageSSs.find(ec.get_name()) != this->ssAssemblageSSs.end())
|
||||
{
|
||||
cxxSSassemblageSS & ec1 = this->ssAssemblageSSs.find(ec.get_name())->second;
|
||||
ec1.read_raw(parser, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
cxxSSassemblageSS ec1;
|
||||
ec1.read_raw(parser, false);
|
||||
std::string str(ec1.get_name());
|
||||
this->ssAssemblageSSs[str] = ec1;
|
||||
}
|
||||
#endif
|
||||
parser.set_accumulate(true);
|
||||
ec.read_raw(parser, false);
|
||||
parser.set_accumulate(false);
|
||||
@ -326,41 +281,6 @@ cxxSSassemblage::totalize(PHREEQC_PTR_ARG)
|
||||
}
|
||||
return;
|
||||
}
|
||||
#ifdef SKIP
|
||||
void
|
||||
cxxSSassemblage::add(const cxxSSassemblage & addee, double extensive)
|
||||
//
|
||||
// Add to existing ssassemblage to "this" ssassemblage
|
||||
//
|
||||
{
|
||||
if (extensive == 0.0)
|
||||
return;
|
||||
|
||||
for (std::list < cxxSSassemblageSS >::const_iterator itadd =
|
||||
addee.ssAssemblageSSs.begin(); itadd != addee.ssAssemblageSSs.end();
|
||||
++itadd)
|
||||
{
|
||||
bool found = false;
|
||||
for (std::list < cxxSSassemblageSS >::iterator it =
|
||||
this->ssAssemblageSSs.begin(); it != this->ssAssemblageSSs.end();
|
||||
++it)
|
||||
{
|
||||
if (it->get_name() == itadd->get_name())
|
||||
{
|
||||
it->add((*itadd), extensive);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
cxxSSassemblageSS entity = *itadd;
|
||||
entity.multiply(extensive);
|
||||
this->ssAssemblageSSs.push_back(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
void
|
||||
cxxSSassemblage::add(const cxxSSassemblage & addee, double extensive)
|
||||
//
|
||||
|
||||
@ -25,10 +25,6 @@ public:
|
||||
cxxMix & mx, int n_user, PHRQ_io * io = NULL);
|
||||
~cxxSSassemblage();
|
||||
|
||||
//struct s_s_assemblage *cxxSSassemblage2s_s_assemblage(PHREEQC_PTR_ARG);
|
||||
|
||||
//struct s_s *cxxSSassemblageComp2s_s();
|
||||
|
||||
//void dump_xml(std::ostream& os, unsigned int indent = 0)const;
|
||||
|
||||
void dump_raw(std::ostream & s_oss, unsigned int indent) const;
|
||||
|
||||
@ -80,99 +80,6 @@ cxxSSassemblageSS::~cxxSSassemblageSS()
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef MOVE_TO_STRUCTURES
|
||||
struct s_s *
|
||||
cxxSSassemblageSS::cxxSSassemblageSS2s_s(PHREEQC_PTR_ARG_COMMA std::map < std::string, cxxSSassemblageSS > &el)
|
||||
//
|
||||
// Builds s_s structure from of cxxSSassemblageSS
|
||||
//
|
||||
{
|
||||
|
||||
//
|
||||
// generate s_s structures
|
||||
//
|
||||
struct s_s *s_s_ptr =
|
||||
(struct s_s *) P_INSTANCE_POINTER PHRQ_malloc((size_t) (el.size() * sizeof(struct s_s)));
|
||||
if (s_s_ptr == NULL)
|
||||
P_INSTANCE_POINTER malloc_error();
|
||||
int j = 0;
|
||||
for (std::map < std::string, cxxSSassemblageSS >::iterator it = el.begin();
|
||||
it != el.end(); ++it)
|
||||
{
|
||||
s_s_ptr[j].name = P_INSTANCE_POINTER string_hsave((*it).second.name.c_str());
|
||||
if ((*it).second.name.size() <= 0)
|
||||
{
|
||||
#ifdef PHREEQC_CLASS
|
||||
P_INSTANCE_POINTER error_msg("Name of a solid solution not defined in solid-solution assemblage. Error in _MODIFY definition?\n", STOP);
|
||||
#else
|
||||
::error_msg("Name of a solid solution not defined in solid-solution assemblage. Error in _MODIFY definition?\n", STOP);
|
||||
#endif
|
||||
|
||||
}
|
||||
assert((*it).second.name.size() > 0);
|
||||
//s_s_ptr[j].total_moles = it->total_moles;
|
||||
s_s_ptr[j].total_moles = 0;
|
||||
s_s_ptr[j].dn = 0;
|
||||
s_s_ptr[j].a0 = (*it).second.a0;
|
||||
s_s_ptr[j].a1 = (*it).second.a1;
|
||||
s_s_ptr[j].ag0 = (*it).second.ag0;
|
||||
s_s_ptr[j].ag1 = (*it).second.ag1;
|
||||
//s_s_ptr[j].ag0 = 0;
|
||||
//s_s_ptr[j].ag1 = 0;
|
||||
s_s_ptr[j].s_s_in = TRUE;
|
||||
s_s_ptr[j].miscibility = (*it).second.miscibility;
|
||||
//s_s_ptr[j].spinodal = it->spinodal;
|
||||
s_s_ptr[j].spinodal = FALSE;
|
||||
//s_s_ptr[j].tk = it->tk;
|
||||
s_s_ptr[j].tk = 273.15;
|
||||
s_s_ptr[j].xb1 = (*it).second.xb1;
|
||||
s_s_ptr[j].xb2 = (*it).second.xb2;
|
||||
s_s_ptr[j].input_case = 0;
|
||||
s_s_ptr[j].p[0] = 0;
|
||||
s_s_ptr[j].p[1] = 0;
|
||||
s_s_ptr[j].p[2] = 0;
|
||||
s_s_ptr[j].p[3] = 0;
|
||||
//
|
||||
// generate s_s_comp structures
|
||||
//
|
||||
s_s_ptr[j].count_comps = (int) (*it).second.comps.size();
|
||||
s_s_ptr[j].comps = NULL;
|
||||
if ((*it).second.comps.size() > 0)
|
||||
{
|
||||
int i = 0;
|
||||
int n;
|
||||
struct s_s_comp *s_s_comp_ptr =
|
||||
(struct s_s_comp *)
|
||||
P_INSTANCE_POINTER PHRQ_malloc((size_t)
|
||||
((*it).second.comps.size() * sizeof(struct s_s_comp)));
|
||||
if (s_s_comp_ptr == NULL)
|
||||
P_INSTANCE_POINTER malloc_error();
|
||||
for (cxxNameDouble::iterator itc = (*it).second.comps.begin();
|
||||
itc != (*it).second.comps.end(); ++itc)
|
||||
{
|
||||
s_s_comp_ptr[i].name = P_INSTANCE_POINTER string_hsave(itc->first.c_str());
|
||||
assert(itc->first.size() > 0);
|
||||
s_s_comp_ptr[i].phase = P_INSTANCE_POINTER phase_bsearch(itc->first.c_str(), &n, TRUE);
|
||||
s_s_comp_ptr[i].initial_moles = 0;
|
||||
s_s_comp_ptr[i].moles = itc->second;
|
||||
s_s_comp_ptr[i].init_moles = 0;
|
||||
s_s_comp_ptr[i].delta = 0;
|
||||
s_s_comp_ptr[i].fraction_x = 0;
|
||||
s_s_comp_ptr[i].log10_lambda = 0;
|
||||
s_s_comp_ptr[i].log10_fraction_x = 0;
|
||||
s_s_comp_ptr[i].dn = 0;
|
||||
s_s_comp_ptr[i].dnc = 0;
|
||||
s_s_comp_ptr[i].dnb = 0;
|
||||
i++;
|
||||
}
|
||||
s_s_ptr[j].comps = s_s_comp_ptr;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
return (s_s_ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SKIP
|
||||
void
|
||||
cxxSSassemblageSS::dump_xml(std::ostream & s_oss, unsigned int indent) const const
|
||||
|
||||
@ -31,9 +31,6 @@ class cxxSSassemblageSS: public PHRQ_base
|
||||
SS_PARM_MARGULES = 9
|
||||
};
|
||||
|
||||
//static struct s_s *cxxSSassemblageSS2s_s(PHREEQC_PTR_ARG_COMMA std::map < std::string, cxxSSassemblageSS >
|
||||
// &el);
|
||||
|
||||
void dump_xml(std::ostream & os, unsigned int indent = 0) const;
|
||||
|
||||
void dump_raw(std::ostream & s_oss, unsigned int indent) const;
|
||||
|
||||
57
Solution.cxx
57
Solution.cxx
@ -283,63 +283,6 @@ cxxSolution::~cxxSolution()
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef MOVE_TO_STRUCTURES
|
||||
struct solution *
|
||||
cxxSolution::cxxSolution2solution(PHREEQC_PTR_ARG)
|
||||
//
|
||||
// Builds a solution structure from instance of cxxSolution
|
||||
//
|
||||
{
|
||||
|
||||
struct solution *solution_ptr = P_INSTANCE_POINTER solution_alloc();
|
||||
|
||||
solution_ptr->description = P_INSTANCE_POINTER string_duplicate (this->get_description().c_str());
|
||||
solution_ptr->n_user = this->n_user;
|
||||
solution_ptr->n_user_end = this->n_user_end;
|
||||
solution_ptr->new_def = FALSE;
|
||||
solution_ptr->tc = this->tc;
|
||||
solution_ptr->ph = this->ph;
|
||||
solution_ptr->solution_pe = this->pe;
|
||||
solution_ptr->mu = this->mu;
|
||||
solution_ptr->ah2o = this->ah2o;
|
||||
solution_ptr->total_h = this->total_h;
|
||||
solution_ptr->total_o = this->total_o;
|
||||
solution_ptr->cb = this->cb;
|
||||
solution_ptr->mass_water = this->mass_water;
|
||||
solution_ptr->total_alkalinity = this->total_alkalinity;
|
||||
solution_ptr->density = 1.0;
|
||||
solution_ptr->units = P_INSTANCE_POINTER moles_per_kilogram_string;
|
||||
solution_ptr->default_pe = 0;
|
||||
// pe_data
|
||||
|
||||
// totals
|
||||
solution_ptr->totals =
|
||||
(struct conc *) P_INSTANCE_POINTER free_check_null(solution_ptr->totals);
|
||||
solution_ptr->totals = this->totals.conc(P_INSTANCE);
|
||||
|
||||
// master_activity
|
||||
solution_ptr->master_activity =
|
||||
(struct master_activity *) P_INSTANCE_POINTER free_check_null(solution_ptr->
|
||||
master_activity);
|
||||
solution_ptr->master_activity = this->master_activity.master_activity(P_INSTANCE);
|
||||
solution_ptr->count_master_activity =
|
||||
(int) this->master_activity.size() + 1;
|
||||
|
||||
// species_gamma
|
||||
solution_ptr->species_gamma = this->species_gamma.master_activity(P_INSTANCE);
|
||||
solution_ptr->count_species_gamma = (int) this->species_gamma.size();
|
||||
|
||||
// isotopes
|
||||
solution_ptr->isotopes =
|
||||
(struct isotope *) P_INSTANCE_POINTER free_check_null(solution_ptr->isotopes);
|
||||
//solution_ptr->isotopes = cxxSolutionIsotope::list2isotope(this->isotopes);
|
||||
solution_ptr->isotopes = this->isotopes.cxxSolutionIsotopeList2isotope(P_INSTANCE);
|
||||
solution_ptr->count_isotopes = (int) this->isotopes.size();
|
||||
|
||||
return (solution_ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
cxxSolution::dump_xml(std::ostream & s_oss, unsigned int indent) const
|
||||
{
|
||||
|
||||
@ -19,13 +19,10 @@ class cxxSolution:public cxxNumKeyword
|
||||
public:
|
||||
cxxSolution(PHRQ_io *io=NULL);
|
||||
cxxSolution(struct solution *, PHRQ_io *io=NULL);
|
||||
//cxxSolution(PHREEQC_PTR_ARG_COMMA int n_user, PHRQ_io *io=NULL);
|
||||
cxxSolution( const std::map < int, cxxSolution > &solution_map,
|
||||
cxxMix & mx, int n_user, PHRQ_io *io=NULL);
|
||||
~cxxSolution();
|
||||
|
||||
//static cxxSolution& read(CParser& parser);
|
||||
|
||||
double Get_tc() const
|
||||
{
|
||||
return this->tc;
|
||||
@ -149,9 +146,6 @@ class cxxSolution:public cxxNumKeyword
|
||||
double Get_master_activity(char *string) const;
|
||||
void Set_master_activity(char *string, double value);
|
||||
const cxxSolutionIsotopeList & Get_isotopes(void) const {return isotopes;};
|
||||
|
||||
//struct solution *cxxSolution2solution(PHREEQC_PTR_ARG);
|
||||
|
||||
void dump_raw(std::ostream & s_oss, unsigned int indent) const;
|
||||
|
||||
void read_raw(CParser & parser, bool check = true);
|
||||
|
||||
@ -84,16 +84,6 @@ cxxSolutionIsotope::list2isotope(PHREEQC_PTR_ARG_COMMA std::list < cxxSolutionIs
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SKIP
|
||||
std::string cxxSolutionIsotope::get_name() constconst
|
||||
{
|
||||
std::ostringstream oss;
|
||||
//std::ostrstream oss;
|
||||
oss << this->isotope_number << this->elt_name;
|
||||
return oss.str();
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
cxxSolutionIsotope::dump_xml(std::ostream & s_oss, unsigned int indent) const
|
||||
{
|
||||
@ -226,21 +216,7 @@ cxxSolutionIsotope::operator<(const cxxSolutionIsotope & isotope) const
|
||||
return (i < 0);
|
||||
return (this->isotope_number < isotope.isotope_number);
|
||||
}
|
||||
#ifdef SKIP_OR_MOVE_TO_STRUCTURES
|
||||
struct master *
|
||||
cxxSolutionIsotope::master(PHREEQC_PTR_ARG)
|
||||
{
|
||||
return (P_INSTANCE_POINTER master_bsearch(this->elt_name.c_str()));
|
||||
}
|
||||
#endif
|
||||
#ifdef SKIP_OR_MOVE_TO_STRUCTURES
|
||||
struct master *
|
||||
cxxSolutionIsotope::primary(PHREEQC_PTR_ARG)
|
||||
{
|
||||
char * str = P_INSTANCE_POINTER string_hsave(this->elt_name.c_str());
|
||||
return (P_INSTANCE_POINTER master_bsearch_primary(str));
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
cxxSolutionIsotope::add(const cxxSolutionIsotope & isotope_ptr,
|
||||
double intensive, double extensive)
|
||||
|
||||
@ -13,15 +13,6 @@ class cxxSolutionIsotope: public PHRQ_base
|
||||
cxxSolutionIsotope(struct isotope *isotope_ptr, PHRQ_io *io=NULL);
|
||||
~cxxSolutionIsotope(void);
|
||||
|
||||
/*
|
||||
enum STATUS {
|
||||
ERROR = 0,
|
||||
OK = 1
|
||||
};
|
||||
*/
|
||||
//cxxSolutionIsotope::STATUS read(CParser& parser);
|
||||
//static struct isotope *list2isotope(PHREEQC_PTR_ARG_COMMA std::list < cxxSolutionIsotope > &t);
|
||||
|
||||
void dump_xml(std::ostream & os, unsigned int indent) const;
|
||||
void dump_raw(std::ostream & os, unsigned int indent) const;
|
||||
|
||||
@ -82,10 +73,6 @@ class cxxSolutionIsotope: public PHRQ_base
|
||||
}
|
||||
|
||||
bool operator<(const cxxSolutionIsotope & conc) const;
|
||||
|
||||
//struct master *master(PHREEQC_PTR_ARG);
|
||||
//struct master *primary(PHREEQC_PTR_ARG);
|
||||
|
||||
void add(const cxxSolutionIsotope & isotope_ptr, double intensive,
|
||||
double extensive);
|
||||
void multiply(double extensive);
|
||||
|
||||
@ -88,36 +88,4 @@ cxxSolutionIsotopeList::multiply(double extensive)
|
||||
it->total *= extensive;
|
||||
}
|
||||
}
|
||||
#ifdef MOVE_TO_STRUCTURES
|
||||
struct isotope *
|
||||
cxxSolutionIsotopeList::cxxSolutionIsotopeList2isotope(PHREEQC_PTR_ARG)
|
||||
{
|
||||
struct isotope *iso;
|
||||
if (this->size() <= 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
iso =
|
||||
(struct isotope *)
|
||||
P_INSTANCE_POINTER PHRQ_malloc((size_t) ((this->size()) * sizeof(struct isotope)));
|
||||
if (iso == NULL)
|
||||
P_INSTANCE_POINTER malloc_error();
|
||||
int i = 0;
|
||||
for (cxxSolutionIsotopeList::iterator it = this->begin();
|
||||
it != this->end(); ++it)
|
||||
{
|
||||
iso[i].isotope_number = it->isotope_number;
|
||||
iso[i].elt_name = P_INSTANCE_POINTER string_hsave(it->elt_name.c_str());
|
||||
iso[i].total = it->total;
|
||||
iso[i].ratio = it->ratio;
|
||||
iso[i].ratio_uncertainty = it->ratio_uncertainty;
|
||||
iso[i].master = it->master(P_INSTANCE);
|
||||
iso[i].primary = it->primary(P_INSTANCE);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return (iso);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@ -18,7 +18,6 @@ public:
|
||||
|
||||
~cxxSolutionIsotopeList();
|
||||
|
||||
//struct isotope * cxxSolutionIsotopeList2isotope(PHREEQC_PTR_ARG);
|
||||
void add(cxxSolutionIsotopeList oldlist, double intensive, double extensive);
|
||||
void multiply(double extensive);
|
||||
|
||||
|
||||
@ -48,75 +48,7 @@ PHRQ_base(io)
|
||||
// default constructor for cxxStorageBin
|
||||
this->system.Set_io(io);
|
||||
}
|
||||
#ifdef SKIP
|
||||
cxxStorageBin::cxxStorageBin(struct Use *use_ptr)
|
||||
{
|
||||
//Construct from use pointer
|
||||
|
||||
// Solution
|
||||
if (use_ptr->solution_ptr != NULL)
|
||||
{
|
||||
cxxSolution entity(use_ptr->solution_ptr);
|
||||
this->setSolution(use_ptr->n_solution_user, &entity);
|
||||
}
|
||||
// Exchange
|
||||
if (use_ptr->exchange_ptr != NULL)
|
||||
{
|
||||
cxxExchange entity(use_ptr->exchange_ptr);
|
||||
this->setExchange(use_ptr->n_exchange_user, &entity);
|
||||
}
|
||||
// gas_phase
|
||||
if (use_ptr->gas_phase_ptr != NULL)
|
||||
{
|
||||
cxxGasPhase entity(use_ptr->gas_phase_ptr);
|
||||
this->setGasPhase(use_ptr->n_gas_phase_user, &entity);
|
||||
}
|
||||
// kinetics
|
||||
if (use_ptr->kinetics_ptr != NULL)
|
||||
{
|
||||
cxxKinetics entity(use_ptr->kinetics_ptr);
|
||||
this->setKinetics(use_ptr->n_kinetics_user, &entity);
|
||||
}
|
||||
// pp_assemblage
|
||||
if (use_ptr->pp_assemblage_ptr != NULL)
|
||||
{
|
||||
cxxPPassemblage entity(use_ptr->pp_assemblage_ptr);
|
||||
this->setPPassemblage(use_ptr->n_pp_assemblage_user, &entity);
|
||||
}
|
||||
// s_s_assemblage
|
||||
if (use_ptr->s_s_assemblage_ptr != NULL)
|
||||
{
|
||||
cxxSSassemblage entity(use_ptr->s_s_assemblage_ptr);
|
||||
this->setSSassemblage(use_ptr->n_s_s_assemblage_user, &entity);
|
||||
}
|
||||
// surface
|
||||
if (use_ptr->surface_ptr != NULL)
|
||||
{
|
||||
cxxSurface entity(use_ptr->surface_ptr);
|
||||
this->setSurface(use_ptr->n_surface_user, &entity);
|
||||
}
|
||||
// mix
|
||||
if (use_ptr->mix_ptr != NULL)
|
||||
{
|
||||
cxxMix entity(use_ptr->mix_ptr);
|
||||
this->setMix(use_ptr->n_mix_user, &entity);
|
||||
}
|
||||
// reaction
|
||||
if (use_ptr->irrev_ptr != NULL)
|
||||
{
|
||||
cxxReaction entity(use_ptr->irrev_ptr);
|
||||
this->setReaction(use_ptr->n_irrev_user, &entity);
|
||||
}
|
||||
// reaction temperature
|
||||
if (use_ptr->temperature_ptr != NULL)
|
||||
{
|
||||
cxxTemperature entity(use_ptr->temperature_ptr);
|
||||
this->setTemperature(use_ptr->n_temperature_user, &entity);
|
||||
}
|
||||
// set system
|
||||
this->setSystem(use_ptr);
|
||||
}
|
||||
#endif
|
||||
cxxStorageBin::cxxStorageBin(PHREEQC_PTR_ARG_COMMA struct Use *use_ptr, PHRQ_io * io)
|
||||
:
|
||||
PHRQ_base(io)
|
||||
@ -1530,19 +1462,6 @@ cxxStorageBin::mpi_recv(int task_number)
|
||||
MPI_DOUBLE, MPI_COMM_WORLD);
|
||||
}
|
||||
buffer = free_check_null(buffer);
|
||||
#ifdef SKIP
|
||||
for (int j = 0; j < count_ints; j++)
|
||||
{
|
||||
std::cerr << "Recving ints " << j << " value " << ints[j] << std::
|
||||
endl;
|
||||
}
|
||||
for (int j = 0; j < count_doubles; j++)
|
||||
{
|
||||
std::
|
||||
cerr << "Recving doubles " << j << " value " << doubles[j] <<
|
||||
std::endl;
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* Make list of list of ints and doubles from solution structure
|
||||
* This list is not the complete structure, but only enough
|
||||
|
||||
219
Surface.cxx
219
Surface.cxx
@ -143,82 +143,6 @@ cxxSurface::Get_related_rate()
|
||||
return (false);
|
||||
}
|
||||
|
||||
#ifdef MOVE_TO_STRUCTURES
|
||||
struct surface *
|
||||
cxxSurface::cxxSurface2surface(PHREEQC_PTR_ARG)
|
||||
//
|
||||
// Builds a surface structure from instance of cxxSurface
|
||||
//
|
||||
{
|
||||
struct surface *surface_ptr = P_INSTANCE_POINTER surface_alloc();
|
||||
|
||||
surface_ptr->description = P_INSTANCE_POINTER string_duplicate (this->get_description().c_str());
|
||||
surface_ptr->n_user = this->n_user;
|
||||
surface_ptr->n_user_end = this->n_user_end;
|
||||
surface_ptr->new_def = FALSE;
|
||||
surface_ptr->type = this->type;
|
||||
surface_ptr->dl_type = this->dl_type;
|
||||
surface_ptr->sites_units = this->sites_units;
|
||||
//surface_ptr->diffuse_layer = this->diffuse_layer;
|
||||
//surface_ptr->edl = this->edl;
|
||||
surface_ptr->only_counter_ions = this->only_counter_ions;
|
||||
//surface_ptr->donnan = this->donnan;
|
||||
surface_ptr->thickness = this->thickness;
|
||||
surface_ptr->debye_lengths = 1.0;
|
||||
surface_ptr->solution_equilibria = FALSE;
|
||||
surface_ptr->n_solution = -2;
|
||||
surface_ptr->related_phases = (int) this->get_related_phases();
|
||||
surface_ptr->related_rate = (int) this->get_related_rate();
|
||||
surface_ptr->transport = this->transport;
|
||||
surface_ptr->debye_lengths = this->debye_lengths;
|
||||
surface_ptr->DDL_viscosity = this->DDL_viscosity;
|
||||
surface_ptr->DDL_limit = this->DDL_limit;
|
||||
|
||||
// Surface comps
|
||||
surface_ptr->count_comps = (int) this->surfaceComps.size();
|
||||
surface_ptr->comps =
|
||||
(struct surface_comp *) P_INSTANCE_POINTER free_check_null(surface_ptr->comps);
|
||||
surface_ptr->comps =
|
||||
cxxSurfaceComp::cxxSurfaceComp2surface_comp(P_INSTANCE_COMMA this->surfaceComps);
|
||||
|
||||
// Surface charge
|
||||
surface_ptr->charge =
|
||||
(struct surface_charge *) P_INSTANCE_POINTER free_check_null(surface_ptr->charge);
|
||||
//if (surface_ptr->edl == TRUE) {
|
||||
if (surface_ptr->type == DDL || surface_ptr->type == CD_MUSIC)
|
||||
{
|
||||
surface_ptr->count_charge = (int) this->surfaceCharges.size();
|
||||
surface_ptr->charge =
|
||||
cxxSurfaceCharge::cxxSurfaceCharge2surface_charge(P_INSTANCE_COMMA this->surfaceCharges);
|
||||
}
|
||||
else
|
||||
{
|
||||
surface_ptr->count_charge = 0;
|
||||
}
|
||||
// Need to fill in charge (number) in comps list
|
||||
if (surface_ptr->type != NO_EDL)
|
||||
{
|
||||
int i, j;
|
||||
for (i = 0; i < surface_ptr->count_comps; i++)
|
||||
{
|
||||
char *charge_name = P_INSTANCE_POINTER string_hsave(
|
||||
cxxSurfaceComp::get_charge_name(P_INSTANCE_COMMA surface_ptr->comps[i].formula).c_str());
|
||||
for (j = 0; j < surface_ptr->count_charge; j++)
|
||||
{
|
||||
if (charge_name == surface_ptr->charge[j].name)
|
||||
{
|
||||
surface_ptr->comps[i].charge = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert(j < surface_ptr->count_charge);
|
||||
}
|
||||
}
|
||||
|
||||
return (surface_ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
cxxSurface::dump_xml(std::ostream & s_oss, unsigned int indent) const
|
||||
{
|
||||
@ -516,31 +440,6 @@ cxxSurface::read_raw(CParser & parser, bool check)
|
||||
cxxSurfaceComp ec(this->Get_io());
|
||||
|
||||
// preliminary read
|
||||
#ifdef SKIP
|
||||
std::istream::pos_type pos = parser.tellg();
|
||||
CParser::ECHO_OPTION eo = parser.get_echo_file();
|
||||
parser.set_echo_file(CParser::EO_NONE);
|
||||
CParser::ECHO_OPTION eo_s = parser.get_echo_stream();
|
||||
parser.set_echo_stream(CParser::EO_NONE);
|
||||
ec.read_raw(parser, false);
|
||||
parser.set_echo_file(eo);
|
||||
parser.set_echo_stream(eo_s);
|
||||
parser.seekg(pos).clear();
|
||||
parser.seekg(pos);
|
||||
|
||||
if (this->surfaceComps.find(ec.get_formula()) != this->surfaceComps.end())
|
||||
{
|
||||
cxxSurfaceComp & comp = this->surfaceComps.find(ec.get_formula())->second;
|
||||
comp.read_raw(parser, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
cxxSurfaceComp ec1;
|
||||
ec1.read_raw(parser, false);
|
||||
std::string str(ec1.get_formula());
|
||||
this->surfaceComps[str] = ec1;
|
||||
}
|
||||
#endif
|
||||
parser.set_accumulate(true);
|
||||
ec.read_raw(parser, false);
|
||||
parser.set_accumulate(false);
|
||||
@ -569,31 +468,6 @@ cxxSurface::read_raw(CParser & parser, bool check)
|
||||
cxxSurfaceCharge ec(this->Get_io());
|
||||
|
||||
// preliminary read
|
||||
#ifdef SKIP
|
||||
std::istream::pos_type pos = parser.tellg();
|
||||
CParser::ECHO_OPTION eo = parser.get_echo_file();
|
||||
parser.set_echo_file(CParser::EO_NONE);
|
||||
CParser::ECHO_OPTION eo_s = parser.get_echo_stream();
|
||||
parser.set_echo_stream(CParser::EO_NONE);
|
||||
ec.read_raw(parser, false);
|
||||
parser.set_echo_file(eo);
|
||||
parser.set_echo_stream(eo_s);
|
||||
parser.seekg(pos).clear();
|
||||
parser.seekg(pos);
|
||||
|
||||
if (this->surfaceCharges.find(ec.get_name()) != this->surfaceCharges.end())
|
||||
{
|
||||
cxxSurfaceCharge & comp = this->surfaceCharges.find(ec.get_name())->second;
|
||||
comp.read_raw(parser, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
cxxSurfaceCharge ec1;
|
||||
ec1.read_raw(parser, false);
|
||||
std::string str(ec1.get_name());
|
||||
this->surfaceCharges[str] = ec1;
|
||||
}
|
||||
#endif
|
||||
parser.set_accumulate(true);
|
||||
ec.read_raw(parser, false);
|
||||
parser.set_accumulate(false);
|
||||
@ -880,100 +754,7 @@ cxxSurface::totalize()
|
||||
}
|
||||
return;
|
||||
}
|
||||
#ifdef SKIP
|
||||
void
|
||||
cxxSurface::add(const cxxSurface & addee, double extensive)
|
||||
//
|
||||
// Add surface to "this" exchange
|
||||
//
|
||||
{
|
||||
//std::list<cxxSurfaceComp> surfaceComps;
|
||||
//std::list<cxxSurfaceCharge> surfaceCharges;
|
||||
//enum SURFACE_TYPE type;
|
||||
//enum DIFFUSE_LAYER_TYPE dl_type;
|
||||
//enum SITES_UNITS sites_units;
|
||||
//bool only_counter_ions;
|
||||
//double thickness;
|
||||
//double debye_lengths;
|
||||
//double DDL_viscosity;
|
||||
//double DDL_limit;
|
||||
//bool transport;
|
||||
if (extensive == 0.0)
|
||||
return;
|
||||
if (this->surfaceComps.size() == 0)
|
||||
{
|
||||
//enum SURFACE_TYPE type;
|
||||
this->type = addee.type;
|
||||
//enum DIFFUSE_LAYER_TYPE dl_type;
|
||||
this->dl_type = addee.dl_type;
|
||||
//enum SITES_UNITS sites_units;
|
||||
this->sites_units = addee.sites_units;
|
||||
//bool only_counter_ions;
|
||||
this->only_counter_ions = addee.only_counter_ions;
|
||||
//double thickness;
|
||||
this->thickness = addee.thickness;
|
||||
//double debye_lengths;
|
||||
this->debye_lengths = addee.debye_lengths;
|
||||
//double DDL_viscosity;
|
||||
this->DDL_viscosity = addee.DDL_viscosity;
|
||||
//double DDL_limit;
|
||||
this->DDL_limit = addee.DDL_limit;
|
||||
//bool transport;
|
||||
this->transport = addee.transport;
|
||||
}
|
||||
//std::list<cxxSurfaceComp> surfaceComps;
|
||||
|
||||
for (std::list < cxxSurfaceComp >::const_iterator itadd =
|
||||
addee.surfaceComps.begin(); itadd != addee.surfaceComps.end();
|
||||
++itadd)
|
||||
{
|
||||
bool found = false;
|
||||
for (std::list < cxxSurfaceComp >::iterator it =
|
||||
this->surfaceComps.begin(); it != this->surfaceComps.end(); ++it)
|
||||
{
|
||||
if (it->get_formula() == itadd->get_formula())
|
||||
{
|
||||
it->add((*itadd), extensive);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
cxxSurfaceComp entity = *itadd;
|
||||
entity.multiply(extensive);
|
||||
//exc.add(*itadd, extensive);
|
||||
this->surfaceComps.push_back(entity);
|
||||
}
|
||||
}
|
||||
//std::list<cxxSurfaceCharge> surfaceCharges;
|
||||
for (std::list < cxxSurfaceCharge >::const_iterator itadd =
|
||||
addee.surfaceCharges.begin(); itadd != addee.surfaceCharges.end();
|
||||
++itadd)
|
||||
{
|
||||
bool found = false;
|
||||
for (std::list < cxxSurfaceCharge >::iterator it =
|
||||
this->surfaceCharges.begin(); it != this->surfaceCharges.end();
|
||||
++it)
|
||||
{
|
||||
if (it->get_name() == itadd->get_name())
|
||||
{
|
||||
it->add((*itadd), extensive);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
cxxSurfaceCharge entity = *itadd;
|
||||
entity.multiply(extensive);
|
||||
//exc.add(*itadd, extensive);
|
||||
this->surfaceCharges.push_back(entity);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
void
|
||||
cxxSurface::add(const cxxSurface & addee, double extensive)
|
||||
//
|
||||
|
||||
@ -22,14 +22,6 @@ class cxxSurface:public cxxNumKeyword
|
||||
int n_user, PHRQ_io *io=NULL);
|
||||
~cxxSurface();
|
||||
|
||||
//enum SURFACE_STYPE { UNKNOWN_DL, NO_EDL, DDL, CD_MUSIC };
|
||||
//enum SURFACE_DL_TYPE { NO_DL, BORKOVEC_DL, DONNAN_DL } ;
|
||||
//enum SURFACE_SITES_UNITS { SITES_ABSOLUTE, SITES_DENSITY } ;
|
||||
|
||||
//struct surface *cxxSurface2surface(PHREEQC_PTR_ARG);
|
||||
|
||||
//struct surf_comp *cxxSurfaceComp2surf_comp(PHREEQC_PTR_ARG);
|
||||
|
||||
void dump_xml(std::ostream & os, unsigned int indent = 0) const;
|
||||
|
||||
void dump_raw(std::ostream & s_oss, unsigned int indent) const;
|
||||
|
||||
@ -86,48 +86,6 @@ cxxSurfaceCharge::~cxxSurfaceCharge()
|
||||
// return (master_ptr);
|
||||
//}
|
||||
|
||||
#ifdef MOVE_TO_STRUCTURES
|
||||
struct surface_charge *
|
||||
cxxSurfaceCharge::cxxSurfaceCharge2surface_charge(PHREEQC_PTR_ARG_COMMA std::map < std::string, cxxSurfaceCharge > &el)
|
||||
//
|
||||
// Builds surface_charge structure from of cxxSurfaceCharge
|
||||
//
|
||||
{
|
||||
struct surface_charge *surf_charge_ptr =
|
||||
(struct surface_charge *)
|
||||
P_INSTANCE_POINTER PHRQ_malloc((size_t) (el.size() * sizeof(struct surface_charge)));
|
||||
if (surf_charge_ptr == NULL)
|
||||
P_INSTANCE_POINTER malloc_error();
|
||||
|
||||
int i = 0;
|
||||
for (std::map < std::string, cxxSurfaceCharge >::iterator it = el.begin();
|
||||
it != el.end(); ++it)
|
||||
{
|
||||
surf_charge_ptr[i].name = P_INSTANCE_POINTER string_hsave((*it).second.name.c_str());
|
||||
assert((*it).second.name.size() > 0);
|
||||
surf_charge_ptr[i].specific_area = (*it).second.specific_area;
|
||||
surf_charge_ptr[i].grams = (*it).second.grams;
|
||||
surf_charge_ptr[i].charge_balance = (*it).second.charge_balance;
|
||||
surf_charge_ptr[i].mass_water = (*it).second.mass_water;
|
||||
surf_charge_ptr[i].la_psi = (*it).second.la_psi;
|
||||
surf_charge_ptr[i].la_psi1 = (*it).second.la_psi1;
|
||||
surf_charge_ptr[i].la_psi2 = (*it).second.la_psi2;
|
||||
surf_charge_ptr[i].capacitance[0] = (*it).second.capacitance[0];
|
||||
surf_charge_ptr[i].capacitance[1] = (*it).second.capacitance[1];
|
||||
surf_charge_ptr[i].sigma0 = 0;
|
||||
surf_charge_ptr[i].sigma1 = 0;
|
||||
surf_charge_ptr[i].sigma2 = 0;
|
||||
surf_charge_ptr[i].sigmaddl = 0;
|
||||
surf_charge_ptr[i].diffuse_layer_totals = (*it).second.diffuse_layer_totals.elt_list(P_INSTANCE);
|
||||
//surf_charge_ptr[i].psi_master = it->get_psi_master();
|
||||
surf_charge_ptr[i].count_g = 0;
|
||||
surf_charge_ptr[i].g = NULL;
|
||||
i++;
|
||||
}
|
||||
return (surf_charge_ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
cxxSurfaceCharge::dump_xml(std::ostream & s_oss, unsigned int indent) const
|
||||
{
|
||||
|
||||
@ -22,9 +22,7 @@ public:
|
||||
|
||||
|
||||
struct master *get_psi_master();
|
||||
|
||||
//static struct surface_charge *cxxSurfaceCharge2surface_charge(PHREEQC_PTR_ARG_COMMA std::map < std::string, cxxSurfaceCharge > &el);
|
||||
|
||||
|
||||
void dump_xml(std::ostream & os, unsigned int indent = 0) const;
|
||||
|
||||
void dump_raw(std::ostream & s_oss, unsigned int indent) const;
|
||||
|
||||
105
SurfaceComp.cxx
105
SurfaceComp.cxx
@ -66,89 +66,6 @@ totals(surf_comp_ptr->totals)
|
||||
cxxSurfaceComp::~cxxSurfaceComp()
|
||||
{
|
||||
}
|
||||
#ifdef MOVE_TO_STRUCTURES
|
||||
struct master *
|
||||
cxxSurfaceComp::get_master(PHREEQC_PTR_ARG)
|
||||
{
|
||||
struct master *master_ptr = NULL;
|
||||
//for (std::map <char *, double, CHARSTAR_LESS>::iterator it = totals.begin(); it != totals.end(); it++) {
|
||||
for (cxxNameDouble::iterator it = this->totals.begin();
|
||||
it != this->totals.end(); it++)
|
||||
{
|
||||
/* Find master species */
|
||||
char *eltName = P_INSTANCE_POINTER string_hsave(it->first.c_str());
|
||||
assert(it->first.size() > 0);
|
||||
struct element *elt_ptr = P_INSTANCE_POINTER element_store(eltName);
|
||||
if (elt_ptr->master == NULL)
|
||||
{
|
||||
std::ostringstream error_oss;
|
||||
error_oss << "Master species not in data base for " << elt_ptr->
|
||||
name << std::endl;
|
||||
//Utilities::error_msg(error_oss.str(), CONTINUE);
|
||||
error_msg(error_oss.str().c_str(), CONTINUE);
|
||||
return (NULL);
|
||||
}
|
||||
if (elt_ptr->master->type != SURF)
|
||||
continue;
|
||||
master_ptr = elt_ptr->master;
|
||||
break;
|
||||
}
|
||||
if (master_ptr == NULL)
|
||||
{
|
||||
std::ostringstream error_oss;
|
||||
error_oss <<
|
||||
"Surface formula does not contain an surface master species, " <<
|
||||
this->formula << std::endl;
|
||||
//Utilities::error_msg(error_oss.str(), CONTINUE);
|
||||
error_msg(error_oss.str().c_str(), CONTINUE);
|
||||
}
|
||||
return (master_ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MOVE_TO_STRUCTURES
|
||||
struct surface_comp *
|
||||
cxxSurfaceComp::cxxSurfaceComp2surface_comp(PHREEQC_PTR_ARG_COMMA std::map < std::string, cxxSurfaceComp > &el)
|
||||
//
|
||||
// Builds surface_comp structure from of cxxSurfaceComp
|
||||
//
|
||||
{
|
||||
struct surface_comp *surf_comp_ptr =
|
||||
(struct surface_comp *)
|
||||
P_INSTANCE_POINTER PHRQ_malloc((size_t) (el.size() * sizeof(struct surface_comp)));
|
||||
if (surf_comp_ptr == NULL)
|
||||
P_INSTANCE_POINTER malloc_error();
|
||||
|
||||
int i = 0;
|
||||
for (std::map < std::string, cxxSurfaceComp >::iterator it = el.begin();
|
||||
it != el.end(); ++it)
|
||||
{
|
||||
surf_comp_ptr[i].formula = P_INSTANCE_POINTER string_hsave((*it).second.formula.c_str());
|
||||
assert((*it).second.formula.size() > 0);
|
||||
surf_comp_ptr[i].formula_totals = (*it).second.formula_totals.elt_list(P_INSTANCE);
|
||||
surf_comp_ptr[i].formula_z = (*it).second.formula_z;
|
||||
surf_comp_ptr[i].moles = (*it).second.moles;
|
||||
surf_comp_ptr[i].master = (*it).second.get_master(P_INSTANCE);
|
||||
surf_comp_ptr[i].totals = (*it).second.totals.elt_list(P_INSTANCE);
|
||||
surf_comp_ptr[i].la = (*it).second.la;
|
||||
//surf_comp_ptr[i].charge = it->charge_number;
|
||||
surf_comp_ptr[i].cb = (*it).second.charge_balance;
|
||||
if ((*it).second.phase_name.size() == 0)
|
||||
surf_comp_ptr[i].phase_name = NULL;
|
||||
else
|
||||
surf_comp_ptr[i].phase_name = P_INSTANCE_POINTER string_hsave((*it).second.phase_name.c_str());
|
||||
surf_comp_ptr[i].phase_proportion = (*it).second.phase_proportion;
|
||||
if ((*it).second.rate_name.size() == 0)
|
||||
surf_comp_ptr[i].rate_name = NULL;
|
||||
else
|
||||
surf_comp_ptr[i].rate_name = P_INSTANCE_POINTER string_hsave((*it).second.rate_name.c_str());
|
||||
surf_comp_ptr[i].Dw = (*it).second.Dw;
|
||||
surf_comp_ptr[i].master = (*it).second.get_master(P_INSTANCE);
|
||||
i++;
|
||||
}
|
||||
return (surf_comp_ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
cxxSurfaceComp::dump_xml(std::ostream & s_oss, unsigned int indent) const
|
||||
@ -727,25 +644,3 @@ cxxSurfaceComp::Get_formula_totals() const
|
||||
{
|
||||
return (this->formula_totals);
|
||||
}
|
||||
#ifdef MOVE_TO_STRUCTURES
|
||||
std::string
|
||||
cxxSurfaceComp::charge_name(PHREEQC_PTR_ARG)
|
||||
{
|
||||
char * str = P_INSTANCE_POINTER string_hsave(this->formula.c_str());
|
||||
return (get_charge_name(P_INSTANCE_COMMA str));
|
||||
}
|
||||
std::string
|
||||
cxxSurfaceComp::get_charge_name(PHREEQC_PTR_ARG_COMMA char *token)
|
||||
{
|
||||
char name[100];
|
||||
int l;
|
||||
char *ptr1 = token;
|
||||
P_INSTANCE_POINTER get_elt(&ptr1, name, &l);
|
||||
ptr1 = strchr(name, '_');
|
||||
if (ptr1 != NULL)
|
||||
{
|
||||
ptr1[0] = '\0';
|
||||
}
|
||||
return (std::string(name));
|
||||
}
|
||||
#endif
|
||||
@ -18,7 +18,6 @@ public:
|
||||
cxxSurfaceComp(struct surface_comp *, PHRQ_io *io=NULL);
|
||||
~cxxSurfaceComp();
|
||||
|
||||
//struct master *get_master(PHREEQC_PTR_ARG);
|
||||
const std::string &Get_phase_name() const;
|
||||
void Set_phase_name(char * f);
|
||||
const std::string &Get_rate_name() const;
|
||||
@ -27,7 +26,6 @@ public:
|
||||
void Set_formula(char * f);
|
||||
double Get_charge_balance() const;
|
||||
void Set_charge_balance(double d);
|
||||
//static struct surface_comp *cxxSurfaceComp2surface_comp(PHREEQC_PTR_ARG_COMMA std::map < std::string, cxxSurfaceComp > &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, bool check = true);
|
||||
@ -40,8 +38,7 @@ public:
|
||||
double Get_Dw(void) const {return Dw;};
|
||||
void add(const cxxSurfaceComp & comp, double extensive);
|
||||
void multiply(double extensive);
|
||||
//std::string charge_name(PHREEQC_PTR_ARG);
|
||||
//static std::string get_charge_name(PHREEQC_PTR_ARG_COMMA char *token);
|
||||
|
||||
#ifdef USE_MPI
|
||||
void mpi_pack(std::vector < int >&ints, std::vector < double >&doubles);
|
||||
void mpi_unpack(int *ints, int *ii, double *doubles, int *dd);
|
||||
|
||||
@ -71,46 +71,6 @@ cxxTemperature::~cxxTemperature()
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef MOVE_TO_STRUCTURES
|
||||
struct temperature *
|
||||
cxxTemperature::cxxTemperature2temperature(PHREEQC_PTR_ARG)
|
||||
//
|
||||
// Builds a temperature structure from instance of cxxTemperature
|
||||
//
|
||||
{
|
||||
struct temperature *temperature_ptr;
|
||||
temperature_ptr =
|
||||
(struct temperature *) P_INSTANCE_POINTER PHRQ_malloc(sizeof(struct temperature));
|
||||
if (temperature_ptr == NULL)
|
||||
P_INSTANCE_POINTER malloc_error();
|
||||
|
||||
temperature_ptr->description = P_INSTANCE_POINTER string_duplicate (this->get_description().c_str());
|
||||
temperature_ptr->n_user = this->n_user;
|
||||
temperature_ptr->n_user_end = this->n_user_end;
|
||||
|
||||
// temps
|
||||
temperature_ptr->t = NULL;
|
||||
if (this->temps.size() > 0)
|
||||
{
|
||||
temperature_ptr->t =
|
||||
(LDBLE *)
|
||||
P_INSTANCE_POINTER PHRQ_malloc((size_t) (this->temps.size() * sizeof(double)));
|
||||
if (temperature_ptr->t == NULL)
|
||||
P_INSTANCE_POINTER malloc_error();
|
||||
std::copy(this->temps.begin(), this->temps.end(), temperature_ptr->t);
|
||||
}
|
||||
if (this->equalIncrements)
|
||||
{
|
||||
temperature_ptr->count_t = -(int) this->countTemps;
|
||||
}
|
||||
else
|
||||
{
|
||||
temperature_ptr->count_t = (int) this->temps.size();
|
||||
}
|
||||
return (temperature_ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SKIP
|
||||
void
|
||||
cxxTemperature::dump_xml(std::ostream & s_oss, unsigned int indent) const const
|
||||
|
||||
11
Utils.cxx
11
Utils.cxx
@ -92,17 +92,6 @@ Utilities::squeeze_white(std::string & s_l)
|
||||
s_l = str;
|
||||
}
|
||||
|
||||
#ifdef SKIP
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
Utilities::error_msg(const std::string & err_str, const int stop)
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
{
|
||||
//std::cerr << err_str << std::endl;
|
||||
output_message(OUTPUT_ERROR, err_str, stop, "", args);
|
||||
}
|
||||
#endif
|
||||
|
||||
//+NAN double: 7ff8000000000000
|
||||
//-NAN double: fff8000000000000
|
||||
/*
|
||||
|
||||
131
cxxKinetics.cxx
131
cxxKinetics.cxx
@ -117,64 +117,6 @@ cxxKinetics::~cxxKinetics()
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef MOVE_TO_STRUCTURES
|
||||
struct kinetics *
|
||||
cxxKinetics::cxxKinetics2kinetics(PHREEQC_PTR_ARG)
|
||||
//
|
||||
// Builds a kinetics structure from instance of cxxKinetics
|
||||
//
|
||||
{
|
||||
struct kinetics *kinetics_ptr = P_INSTANCE_POINTER kinetics_alloc();
|
||||
|
||||
kinetics_ptr->description = P_INSTANCE_POINTER string_duplicate (this->get_description().c_str());
|
||||
kinetics_ptr->n_user = this->n_user;
|
||||
kinetics_ptr->n_user_end = this->n_user_end;
|
||||
kinetics_ptr->step_divide = this->step_divide;
|
||||
kinetics_ptr->rk = this->rk;
|
||||
kinetics_ptr->bad_step_max = this->bad_step_max;
|
||||
kinetics_ptr->use_cvode = (int) this->use_cvode;
|
||||
kinetics_ptr->cvode_steps = this->cvode_steps;
|
||||
kinetics_ptr->cvode_order = this->cvode_order;
|
||||
|
||||
// totals
|
||||
kinetics_ptr->totals = this->totals.elt_list(P_INSTANCE);
|
||||
|
||||
// comps
|
||||
kinetics_ptr->count_comps = (int) this->kineticsComps.size();
|
||||
kinetics_ptr->comps =
|
||||
(struct kinetics_comp *) P_INSTANCE_POINTER free_check_null(kinetics_ptr->comps);
|
||||
kinetics_ptr->comps =
|
||||
cxxKineticsComp::cxxKineticsComp2kinetics_comp(P_INSTANCE_COMMA this->kineticsComps);
|
||||
|
||||
// steps
|
||||
if (this->equal_steps == 0)
|
||||
{
|
||||
kinetics_ptr->count_steps = (int) this->steps.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
kinetics_ptr->count_steps = -this->equal_steps;
|
||||
}
|
||||
kinetics_ptr->steps = (LDBLE *) P_INSTANCE_POINTER free_check_null(kinetics_ptr->steps);
|
||||
if (this->steps.size() > 0)
|
||||
{
|
||||
kinetics_ptr->steps =
|
||||
(LDBLE *)
|
||||
P_INSTANCE_POINTER PHRQ_malloc((size_t) (this->steps.size() * sizeof(double)));
|
||||
if (kinetics_ptr->steps == NULL)
|
||||
P_INSTANCE_POINTER malloc_error();
|
||||
std::copy(this->steps.begin(), this->steps.end(),
|
||||
kinetics_ptr->steps);
|
||||
/*
|
||||
int i = 0;
|
||||
for (std::vector<double>::iterator it = this->steps.begin(); it != this->steps.end(); it++) {
|
||||
kinetics_ptr->steps[i] = *it;
|
||||
}
|
||||
*/
|
||||
}
|
||||
return (kinetics_ptr);
|
||||
}
|
||||
#endif
|
||||
#ifdef SKIP
|
||||
void
|
||||
cxxKinetics::dump_xml(std::ostream & s_oss, unsigned int indent) const const
|
||||
@ -412,31 +354,6 @@ cxxKinetics::read_raw(CParser & parser, bool check)
|
||||
cxxKineticsComp ec(this->Get_io());
|
||||
|
||||
// preliminary read
|
||||
#ifdef SKIP
|
||||
std::istream::pos_type pos = parser.tellg();
|
||||
CParser::ECHO_OPTION eo = parser.get_echo_file();
|
||||
parser.set_echo_file(CParser::EO_NONE);
|
||||
CParser::ECHO_OPTION eo_s = parser.get_echo_stream();
|
||||
parser.set_echo_stream(CParser::EO_NONE);
|
||||
ec.read_raw(parser, false);
|
||||
parser.set_echo_file(eo);
|
||||
parser.set_echo_stream(eo_s);
|
||||
parser.seekg(pos).clear();
|
||||
parser.seekg(pos);
|
||||
|
||||
if (this->kineticsComps.find(ec.get_rate_name()) != this->kineticsComps.end())
|
||||
{
|
||||
cxxKineticsComp & comp = this->kineticsComps.find(ec.get_rate_name())->second;
|
||||
comp.read_raw(parser, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
cxxKineticsComp ec1;
|
||||
ec1.read_raw(parser, false);
|
||||
std::string str(ec1.get_rate_name());
|
||||
this->kineticsComps[str] = ec1;
|
||||
}
|
||||
#endif
|
||||
parser.set_accumulate(true);
|
||||
ec.read_raw(parser, false);
|
||||
parser.set_accumulate(false);
|
||||
@ -682,54 +599,6 @@ cxxKinetics::mpi_unpack(int *ints, int *ii, double *doubles, int *dd)
|
||||
*dd = d;
|
||||
}
|
||||
#endif
|
||||
#ifdef SKIP
|
||||
void
|
||||
cxxKinetics::add(const cxxKinetics & addee, double extensive)
|
||||
//
|
||||
// Add to existing ppassemblage to "this" ppassemblage
|
||||
//
|
||||
{
|
||||
if (extensive == 0.0)
|
||||
return;
|
||||
//std::list<cxxKineticsComp> kineticsComps;
|
||||
for (std::list < cxxKineticsComp >::const_iterator itadd =
|
||||
addee.kineticsComps.begin(); itadd != addee.kineticsComps.end();
|
||||
++itadd)
|
||||
{
|
||||
bool found = false;
|
||||
for (std::list < cxxKineticsComp >::iterator it =
|
||||
this->kineticsComps.begin(); it != this->kineticsComps.end();
|
||||
++it)
|
||||
{
|
||||
if (it->get_rate_name() == itadd->get_rate_name())
|
||||
{
|
||||
it->add((*itadd), extensive);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
cxxKineticsComp entity = *itadd;
|
||||
entity.multiply(extensive);
|
||||
this->kineticsComps.push_back(entity);
|
||||
}
|
||||
}
|
||||
//std::vector<double> steps;
|
||||
this->steps = addee.steps;
|
||||
//cxxNameDouble totals;
|
||||
//double step_divide;
|
||||
this->step_divide = addee.step_divide;
|
||||
//int rk;
|
||||
this->rk = addee.rk;
|
||||
//int bad_step_max;
|
||||
this->bad_step_max = addee.bad_step_max;
|
||||
//bool use_cvode;
|
||||
this->use_cvode = addee.use_cvode;
|
||||
this->cvode_steps = addee.cvode_steps;
|
||||
this->cvode_order = addee.cvode_order;
|
||||
}
|
||||
#endif
|
||||
void
|
||||
cxxKinetics::add(const cxxKinetics & addee, double extensive)
|
||||
//
|
||||
|
||||
40
cxxMix.cxx
40
cxxMix.cxx
@ -59,46 +59,6 @@ cxxMix::~cxxMix()
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef MOVE_TO_STRUCTURES
|
||||
struct mix *
|
||||
cxxMix::cxxMix2mix(PHREEQC_PTR_ARG)
|
||||
//
|
||||
// Builds a mix structure from instance of cxxMix
|
||||
//
|
||||
{
|
||||
struct mix *mix_ptr;
|
||||
mix_ptr = (struct mix *) P_INSTANCE_POINTER PHRQ_malloc(sizeof(struct mix));
|
||||
if (mix_ptr == NULL)
|
||||
P_INSTANCE_POINTER malloc_error();
|
||||
|
||||
mix_ptr->description = P_INSTANCE_POINTER string_duplicate (this->get_description().c_str());
|
||||
mix_ptr->n_user = this->n_user;
|
||||
mix_ptr->n_user_end = this->n_user_end;
|
||||
|
||||
// comps
|
||||
mix_ptr->comps = NULL;
|
||||
if (this->mixComps.size() > 0)
|
||||
{
|
||||
int i = 0;
|
||||
mix_ptr->comps =
|
||||
(struct mix_comp *)
|
||||
P_INSTANCE_POINTER PHRQ_malloc((size_t)
|
||||
(this->mixComps.size() * sizeof(struct mix_comp)));
|
||||
if (mix_ptr->comps == NULL)
|
||||
P_INSTANCE_POINTER malloc_error();
|
||||
for (std::map < int, double >::iterator it = mixComps.begin();
|
||||
it != mixComps.end(); it++)
|
||||
{
|
||||
mix_ptr->comps[i].n_solution = it->first;
|
||||
mix_ptr->comps[i].fraction = it->second;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
mix_ptr->count_comps = (int) this->mixComps.size();
|
||||
return (mix_ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SKIP
|
||||
void
|
||||
cxxMix::dump_xml(std::ostream & s_oss, unsigned int indent) const const
|
||||
|
||||
212
dumper.cpp
212
dumper.cpp
@ -29,219 +29,7 @@ void dumper::SetAll(bool tf)
|
||||
this->binList.SetAll(tf);
|
||||
|
||||
}
|
||||
#ifdef SKIP
|
||||
bool dumper::Read(CParser & parser)
|
||||
{
|
||||
|
||||
bool return_value(true);
|
||||
static std::vector < std::string > vopts;
|
||||
if (vopts.empty())
|
||||
{
|
||||
vopts.reserve(15);
|
||||
vopts.push_back("solution");
|
||||
vopts.push_back("pp_assemblage");
|
||||
vopts.push_back("equilibrium_phases");
|
||||
vopts.push_back("exchange");
|
||||
vopts.push_back("surface");
|
||||
vopts.push_back("s_s_assemblage");
|
||||
vopts.push_back("gas_phase");
|
||||
vopts.push_back("kinetics");
|
||||
vopts.push_back("file");
|
||||
vopts.push_back("append");
|
||||
vopts.push_back("all");
|
||||
}
|
||||
|
||||
std::istream::pos_type ptr;
|
||||
std::istream::pos_type next_char;
|
||||
std::string token;
|
||||
int opt_save;
|
||||
bool useLastLine(false);
|
||||
|
||||
// Read mix number and description
|
||||
//this->read_number_description(parser);
|
||||
|
||||
opt_save = CParser::OPT_DEFAULT;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
int opt;
|
||||
if (useLastLine == false)
|
||||
{
|
||||
opt = parser.get_option(vopts, next_char);
|
||||
}
|
||||
else
|
||||
{
|
||||
opt = parser.getOptionFromLastLine(vopts, next_char);
|
||||
}
|
||||
if (opt == CParser::OPT_DEFAULT)
|
||||
{
|
||||
opt = opt_save;
|
||||
}
|
||||
else
|
||||
{
|
||||
opt_save = opt;
|
||||
}
|
||||
std::set < int > accumulator;
|
||||
|
||||
// Read list of numbers or number ranges for line
|
||||
if (opt >= 0 && opt <= 7)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
CParser::TOKEN_TYPE j = parser.copy_token(token, next_char);
|
||||
std::set < int > temp_set;
|
||||
int i;
|
||||
if (j == CParser::TT_EMPTY)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if (j == CParser::TT_DIGIT)
|
||||
{
|
||||
std::replace(token.begin(), token.end(), '-', ' ');
|
||||
//if (token.find_last_of("-") != token.end())
|
||||
//{
|
||||
// token.replace(token.find_last_of("-"), token.find_last_of("-") + 1, " ");
|
||||
//}
|
||||
|
||||
std::istringstream iss(token);
|
||||
if (iss >> i)
|
||||
{
|
||||
temp_set.insert(i);
|
||||
if (iss >> i)
|
||||
{
|
||||
temp_set.insert(i);
|
||||
}
|
||||
}
|
||||
if (temp_set.size() == 1)
|
||||
{
|
||||
accumulator.insert(*(temp_set.begin()));
|
||||
}
|
||||
else if (temp_set.size() == 2)
|
||||
{
|
||||
int i1, i2;
|
||||
std::set <int>::iterator it;
|
||||
it = temp_set.begin();
|
||||
i1 = *it;
|
||||
it++;
|
||||
i2 = *it;
|
||||
for (i = i1; i <= i2; i++)
|
||||
{
|
||||
accumulator.insert(i);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
parser.error_msg("Expected positive integers for dump range.",
|
||||
CParser::OT_CONTINUE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
parser.error_msg("Expected single number or range of numbers.",
|
||||
CParser::OT_CONTINUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Process identifiers
|
||||
std::set < int >::iterator it;
|
||||
switch (opt)
|
||||
{
|
||||
case CParser::OPT_EOF:
|
||||
break;
|
||||
case CParser::OPT_KEYWORD:
|
||||
break;
|
||||
case CParser::OPT_DEFAULT:
|
||||
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);
|
||||
useLastLine = false;
|
||||
return_value = false;
|
||||
break;
|
||||
case 0:
|
||||
for (it = accumulator.begin(); it != accumulator.end(); it++)
|
||||
{
|
||||
this->solution.insert(*it);
|
||||
}
|
||||
this->bool_solution = true;
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
for (it = accumulator.begin(); it != accumulator.end(); it++)
|
||||
{
|
||||
this->pp_assemblage.insert(*it);
|
||||
}
|
||||
this->bool_pp_assemblage = true;
|
||||
break;
|
||||
case 3:
|
||||
for (it = accumulator.begin(); it != accumulator.end(); it++)
|
||||
{
|
||||
this->exchange.insert(*it);
|
||||
}
|
||||
this->bool_exchange = true;
|
||||
break;
|
||||
case 4:
|
||||
for (it = accumulator.begin(); it != accumulator.end(); it++)
|
||||
{
|
||||
this->surface.insert(*it);
|
||||
}
|
||||
this->bool_surface = true;
|
||||
break;
|
||||
case 5:
|
||||
for (it = accumulator.begin(); it != accumulator.end(); it++)
|
||||
{
|
||||
this->s_s_assemblage.insert(*it);
|
||||
}
|
||||
this->bool_s_s_assemblage = true;
|
||||
break;
|
||||
case 6:
|
||||
for (it = accumulator.begin(); it != accumulator.end(); it++)
|
||||
{
|
||||
this->gas_phase.insert(*it);
|
||||
}
|
||||
this->bool_gas_phase = true;
|
||||
break;
|
||||
case 7:
|
||||
for (it = accumulator.begin(); it != accumulator.end(); it++)
|
||||
{
|
||||
this->kinetics.insert(*it);
|
||||
}
|
||||
this->bool_kinetics = true;
|
||||
break;
|
||||
case 8: //file
|
||||
std::getline(parser.get_iss(), this->file_name);
|
||||
this->file_name = trim(this->file_name, " \t");
|
||||
if (this->file_name.size() == 0)
|
||||
{
|
||||
this->file_name = "dump.out";
|
||||
}
|
||||
|
||||
break;
|
||||
case 9: //append
|
||||
{
|
||||
CParser::TOKEN_TYPE j = parser.copy_token(token, next_char);
|
||||
//if (!(parser.get_iss() >> this->append))
|
||||
this->append = true;
|
||||
if (token.c_str()[0] == 'f' || token.c_str()[0] == 'F')
|
||||
{
|
||||
this->append = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 10: //all
|
||||
this->DumpAll(true);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (opt == CParser::OPT_EOF || opt == CParser::OPT_KEYWORD)
|
||||
break;
|
||||
}
|
||||
return(return_value);
|
||||
}
|
||||
#endif
|
||||
bool dumper::Read(CParser & parser)
|
||||
{
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user