mirror of
https://git.gfz-potsdam.de/naaice/iphreeqc.git
synced 2025-12-16 16:44:49 +01:00
Exchange changes have been made, but need to debug.
git-svn-id: svn://136.177.114.72/svn_GW/phreeqcpp/branches/ErrorHandling@5960 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
parent
02839d601d
commit
b52ab4dfea
@ -37,7 +37,7 @@ cxxExchComp::cxxExchComp(PHRQ_io *io)
|
||||
//rate_name = NULL;
|
||||
formula_z = 0.0;
|
||||
}
|
||||
|
||||
#ifdef SKIP
|
||||
cxxExchComp::cxxExchComp(struct exch_comp * exch_comp_ptr, PHRQ_io *io)
|
||||
//
|
||||
// constructor for cxxExchComp from struct exch_comp
|
||||
@ -57,7 +57,7 @@ formula_totals(exch_comp_ptr->formula_totals), totals(exch_comp_ptr->totals)
|
||||
this->Set_rate_name(exch_comp_ptr->rate_name);
|
||||
formula_z = exch_comp_ptr->formula_z;
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef SKIP
|
||||
cxxExchComp::cxxExchComp(std::vector < cxxExchComp > &ec_vector,
|
||||
std::vector < double >&f_vector)
|
||||
|
||||
@ -14,7 +14,7 @@ class cxxExchComp: public PHRQ_base
|
||||
|
||||
public:
|
||||
cxxExchComp(PHRQ_io *io=NULL);
|
||||
cxxExchComp(struct exch_comp *, PHRQ_io *io=NULL);
|
||||
//cxxExchComp(struct exch_comp *, PHRQ_io *io=NULL);
|
||||
~cxxExchComp();
|
||||
|
||||
void dump_xml(std::ostream & os, unsigned int indent = 0) const;
|
||||
@ -121,8 +121,8 @@ class cxxExchComp: public PHRQ_base
|
||||
this->formula_totals = nd;
|
||||
}
|
||||
|
||||
const cxxNameDouble & Get_totals() const {return (this->totals);};
|
||||
const cxxNameDouble & Get_formula_totals(void) const {return this->formula_totals;};
|
||||
cxxNameDouble & Get_totals() {return (this->totals);};
|
||||
cxxNameDouble & Get_formula_totals(void) {return this->formula_totals;};
|
||||
|
||||
|
||||
void add(const cxxExchComp & comp, double extensive);
|
||||
|
||||
39
Exchange.cxx
39
Exchange.cxx
@ -26,9 +26,12 @@ cxxExchange::cxxExchange(PHRQ_io *io)
|
||||
//
|
||||
: cxxNumKeyword(io)
|
||||
{
|
||||
new_def = false;
|
||||
solution_equilibria = false;
|
||||
n_solution = -999;
|
||||
pitzer_exchange_gammas = true;
|
||||
}
|
||||
|
||||
#ifdef SKIP
|
||||
cxxExchange::cxxExchange(struct exchange * exchange_ptr, PHRQ_io *io)
|
||||
//
|
||||
// constructor for cxxExchange from struct exchange
|
||||
@ -53,6 +56,7 @@ cxxNumKeyword(io)
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
cxxExchange::cxxExchange(const std::map < int, cxxExchange > &entities,
|
||||
cxxMix & mix, int l_n_user, PHRQ_io *io):
|
||||
cxxNumKeyword(io)
|
||||
@ -362,7 +366,7 @@ cxxExchange::totalize()
|
||||
{
|
||||
this->totals.clear();
|
||||
// component structures
|
||||
for (std::map < std::string, cxxExchComp >::const_iterator it = exchComps.begin();
|
||||
for (std::map < std::string, cxxExchComp >::iterator it = exchComps.begin();
|
||||
it != exchComps.end(); ++it)
|
||||
{
|
||||
this->totals.add_extensive((*it).second.Get_totals(), 1.0);
|
||||
@ -381,8 +385,8 @@ cxxExchange::Set_pitzer_exchange_gammas(bool b)
|
||||
this->pitzer_exchange_gammas = b;
|
||||
}
|
||||
|
||||
const std::map < std::string, cxxExchComp > &
|
||||
cxxExchange::Get_exchComps(void) const
|
||||
std::map < std::string, cxxExchComp > &
|
||||
cxxExchange::Get_exchComps(void)
|
||||
{
|
||||
return (this->exchComps);
|
||||
}
|
||||
@ -391,3 +395,30 @@ cxxExchange::Get_totals() const
|
||||
{
|
||||
return totals;
|
||||
}
|
||||
cxxExchComp *cxxExchange::ExchComp_find(std::string s)
|
||||
{
|
||||
std::map<std::string, cxxExchComp>::iterator it = this->exchComps.begin();
|
||||
for ( ; it != this->exchComps.end(); it++)
|
||||
{
|
||||
cxxNameDouble nd(it->second.Get_totals());
|
||||
cxxNameDouble::iterator nd_it;
|
||||
for (nd_it = nd.begin(); nd_it != nd.end(); nd_it++)
|
||||
{
|
||||
if(nd_it->first == s)
|
||||
{
|
||||
return (&it->second);
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
std::vector<cxxExchComp *> cxxExchange::Vectorize(void)
|
||||
{
|
||||
std::vector<cxxExchComp *> vlist;
|
||||
std::map<std::string, cxxExchComp>::iterator it = exchComps.begin();
|
||||
for ( ; it != this->exchComps.end(); it++)
|
||||
{
|
||||
vlist.push_back(&it->second);
|
||||
}
|
||||
return vlist;
|
||||
}
|
||||
16
Exchange.h
16
Exchange.h
@ -16,7 +16,7 @@ class cxxExchange:public cxxNumKeyword
|
||||
|
||||
public:
|
||||
cxxExchange(PHRQ_io *io=NULL);
|
||||
cxxExchange(struct exchange *, PHRQ_io *io=NULL);
|
||||
//cxxExchange(struct exchange *, PHRQ_io *io=NULL);
|
||||
cxxExchange(const std::map < int, cxxExchange > &exchange_map,
|
||||
cxxMix & mx, int n_user, PHRQ_io *io=NULL);
|
||||
~cxxExchange();
|
||||
@ -32,10 +32,19 @@ public:
|
||||
bool Get_pitzer_exchange_gammas() const;
|
||||
void Set_pitzer_exchange_gammas(bool b);
|
||||
|
||||
const std::map < std::string, cxxExchComp > &Get_exchComps(void) const;
|
||||
bool Get_new_def(void) const {return this->new_def;};
|
||||
void Set_new_def(bool tf) {this->new_def = tf;};
|
||||
bool Get_solution_equilibria(void) const {return this->solution_equilibria;};
|
||||
void Set_solution_equilibria(bool tf) {this->solution_equilibria = tf;};
|
||||
int Get_n_solution(void) const {return this->n_solution;};
|
||||
void Set_n_solution(int i) {this->n_solution = i;};
|
||||
cxxExchComp *ExchComp_find(std::string s);
|
||||
|
||||
std::map < std::string, cxxExchComp > &Get_exchComps(void) ;
|
||||
void totalize();
|
||||
|
||||
const cxxNameDouble & Get_totals() const;
|
||||
std::vector<cxxExchComp *> Vectorize(void);
|
||||
|
||||
#ifdef USE_MPI
|
||||
void mpi_pack(std::vector < int >&ints, std::vector < double >&doubles);
|
||||
@ -47,6 +56,9 @@ protected:
|
||||
void dump_xml(std::ostream & os, unsigned int indent = 0) const;
|
||||
|
||||
protected:
|
||||
bool new_def;
|
||||
bool solution_equilibria;
|
||||
int n_solution;
|
||||
std::map < std::string, cxxExchComp > exchComps;
|
||||
bool pitzer_exchange_gammas;
|
||||
cxxNameDouble totals;
|
||||
|
||||
19
Phreeqc.cpp
19
Phreeqc.cpp
@ -202,9 +202,16 @@ size_t Phreeqc::list_components(std::list<std::string> &list_c)
|
||||
}
|
||||
|
||||
// exchangers
|
||||
for (i = 0; i < count_exchange; i++)
|
||||
//for (i = 0; i < count_exchange; i++)
|
||||
//{
|
||||
// cxxExchange entity(&exchange[i], phrq_io);
|
||||
// entity.totalize();
|
||||
// accumulator.add_extensive(entity.Get_totals(), 1.0);
|
||||
//}
|
||||
std::map<int, cxxExchange>::const_iterator cit = Rxn_exchange_map.begin();
|
||||
for (; cit != Rxn_exchange_map.end(); cit++)
|
||||
{
|
||||
cxxExchange entity(&exchange[i], phrq_io);
|
||||
cxxExchange entity = cit->second;
|
||||
entity.totalize();
|
||||
accumulator.add_extensive(entity.Get_totals(), 1.0);
|
||||
}
|
||||
@ -311,7 +318,7 @@ void Phreeqc::init(void)
|
||||
|
||||
max_solution = MAX_SOLUTION;
|
||||
max_pp_assemblage = MAX_PP_ASSEMBLAGE;
|
||||
max_exchange = MAX_PP_ASSEMBLAGE;
|
||||
//max_exchange = MAX_PP_ASSEMBLAGE;
|
||||
max_surface = MAX_PP_ASSEMBLAGE;
|
||||
max_gas_phase = MAX_PP_ASSEMBLAGE;
|
||||
max_kinetics = MAX_PP_ASSEMBLAGE;
|
||||
@ -331,7 +338,7 @@ void Phreeqc::init(void)
|
||||
|
||||
count_solution = 0;
|
||||
count_pp_assemblage = 0;
|
||||
count_exchange = 0;
|
||||
//count_exchange = 0;
|
||||
count_surface = 0;
|
||||
count_gas_phase = 0;
|
||||
count_kinetics = 0;
|
||||
@ -383,7 +390,7 @@ void Phreeqc::init(void)
|
||||
transport_warnings = TRUE;
|
||||
|
||||
pp_assemblage = 0;
|
||||
exchange = 0;
|
||||
//exchange = 0;
|
||||
surface = 0;
|
||||
gas_phase = 0;
|
||||
kinetics = 0;
|
||||
@ -701,7 +708,7 @@ void Phreeqc::init(void)
|
||||
*/
|
||||
dbg_use = &use;
|
||||
dbg_solution = solution;
|
||||
dbg_exchange = exchange;
|
||||
//dbg_exchange = exchange;
|
||||
dbg_surface = surface;
|
||||
dbg_pp_assemblage = pp_assemblage;
|
||||
dbg_kinetics = kinetics;
|
||||
|
||||
28
Phreeqc.h
28
Phreeqc.h
@ -128,11 +128,12 @@ public:
|
||||
int system_total_elt_secondary(const char *total_name);
|
||||
LDBLE total(const char *total_name);
|
||||
LDBLE total_mole(const char *total_name);
|
||||
int system_total_solids(struct exchange *exchange_ptr,
|
||||
struct pp_assemblage *pp_assemblage_ptr,
|
||||
struct gas_phase *gas_phase_ptr,
|
||||
struct s_s_assemblage *s_s_assemblage_ptr,
|
||||
struct surface *surface_ptr);
|
||||
//int system_total_solids(struct exchange *exchange_ptr,
|
||||
int system_total_solids(cxxExchange *exchange_ptr,
|
||||
struct pp_assemblage *pp_assemblage_ptr,
|
||||
struct gas_phase *gas_phase_ptr,
|
||||
struct s_s_assemblage *s_s_assemblage_ptr,
|
||||
struct surface *surface_ptr);
|
||||
|
||||
static LDBLE f_rho(LDBLE rho_old, void *cookie);
|
||||
|
||||
@ -815,7 +816,8 @@ public:
|
||||
// step.cpp -------------------------------
|
||||
int step(LDBLE step_fraction);
|
||||
int xsolution_zero(void);
|
||||
int add_exchange(struct exchange *exchange_ptr);
|
||||
//int add_exchange(struct exchange *exchange_ptr);
|
||||
int add_exchange(cxxExchange *exchange_ptr);
|
||||
int add_gas_phase(struct gas_phase *gas_phase_ptr);
|
||||
int add_kinetics(struct kinetics *kinetics_ptr);
|
||||
//int add_mix(struct mix *mix_ptr);
|
||||
@ -849,6 +851,8 @@ protected:
|
||||
struct elt_list *elt_list_dup(struct elt_list *elt_list_ptr_old);
|
||||
int elt_list_print(struct elt_list *elt_list_ptr);
|
||||
struct elt_list *elt_list_save(void);
|
||||
cxxNameDouble elt_list_NameDouble(void);
|
||||
#ifdef SKIP
|
||||
public:
|
||||
struct exchange *exchange_alloc(void);
|
||||
struct exchange *exchange_bsearch(int k, int *n);
|
||||
@ -873,6 +877,7 @@ protected:
|
||||
int n_user_new);
|
||||
struct exchange *exchange_search(int n_user, int *n, int print);
|
||||
int exchange_sort(void);
|
||||
#endif
|
||||
static int gas_comp_compare(const void *ptr1, const void *ptr2);
|
||||
public:
|
||||
struct gas_phase *gas_phase_alloc(void);
|
||||
@ -1142,8 +1147,8 @@ public:
|
||||
struct mix * cxxMix2mix(const cxxMix *mx);
|
||||
struct kinetics *cxxKinetics2kinetics(const cxxKinetics * kin);
|
||||
struct kinetics_comp * cxxKineticsComp2kinetics_comp(const std::list < cxxKineticsComp > * el);
|
||||
struct exchange * cxxExchange2exchange(const cxxExchange * ex);
|
||||
struct exch_comp * cxxExchComp2exch_comp(const std::map < std::string, cxxExchComp > * el);
|
||||
//struct exchange * cxxExchange2exchange(const cxxExchange * ex);
|
||||
//struct exch_comp * cxxExchComp2exch_comp(const std::map < std::string, cxxExchComp > * el);
|
||||
struct master * Get_exch_master(const cxxExchComp * ec);
|
||||
struct gas_phase * cxxGasPhase2gas_phase(const cxxGasPhase * gp);
|
||||
struct gas_comp * cxxGasPhaseComp2gas_comp(const cxxGasPhase * gp);
|
||||
@ -1265,6 +1270,7 @@ public:
|
||||
// utilities.cpp -------------------------------
|
||||
public:
|
||||
int add_elt_list(struct elt_list *elt_list_ptr, LDBLE coef);
|
||||
int add_elt_list(const cxxNameDouble & nd, LDBLE coef);
|
||||
protected:
|
||||
int backspace_screen(int spaces);
|
||||
LDBLE calc_alk(struct reaction *rxn_ptr);
|
||||
@ -1376,11 +1382,15 @@ protected:
|
||||
/* ----------------------------------------------------------------------
|
||||
* Exchange
|
||||
* ---------------------------------------------------------------------- */
|
||||
|
||||
#ifdef SKIP
|
||||
struct exchange *exchange;
|
||||
struct exchange *dbg_exchange;
|
||||
int count_exchange;
|
||||
int max_exchange;
|
||||
#endif
|
||||
|
||||
std::map<int, cxxExchange> Rxn_exchange_map;
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
* Kinetics
|
||||
* ---------------------------------------------------------------------- */
|
||||
|
||||
@ -183,6 +183,18 @@ read_exchange_raw(void)
|
||||
|
||||
cxxExchange ex(phrq_io);
|
||||
ex.read_raw(parser);
|
||||
int n_user = ex.Get_n_user();
|
||||
int n_user_end = ex.Get_n_user_end();
|
||||
ex.Set_n_user_end(n_user);
|
||||
Rxn_exchange_map[n_user] = ex;
|
||||
if (n_user_end > n_user)
|
||||
{
|
||||
for (int i = n_user + 1; i <= n_user_end; i++)
|
||||
{
|
||||
Utilities::Rxn_copy(Rxn_exchange_map, n_user, i);
|
||||
}
|
||||
}
|
||||
#ifdef SKIP
|
||||
//struct exchange *exchange_ptr = ex.cxxExchange2exchange(PHREEQC_THIS);
|
||||
struct exchange *exchange_ptr = cxxExchange2exchange(&ex);
|
||||
int n;
|
||||
@ -209,6 +221,7 @@ read_exchange_raw(void)
|
||||
}
|
||||
exchange_free(exchange_ptr);
|
||||
free_check_null(exchange_ptr);
|
||||
#endif
|
||||
|
||||
// Need to output the next keyword
|
||||
if (return_value == KEYWORD) echo_msg(sformatf( "\t%s\n", line));
|
||||
@ -1258,7 +1271,7 @@ read_exchange_modify(void)
|
||||
// find exchange number
|
||||
char token[MAX_LENGTH];
|
||||
char *next;
|
||||
int l, n_user, n;
|
||||
int l, n_user;
|
||||
next = line;
|
||||
copy_token(token, &next, &l);
|
||||
if (copy_token(token, &next, &l) != DIGIT)
|
||||
@ -1300,6 +1313,38 @@ read_exchange_modify(void)
|
||||
parser.set_echo_file(CParser::EO_NOKEYWORDS);
|
||||
}
|
||||
|
||||
cxxExchange * entity = Utilities::Rxn_find(Rxn_exchange_map, n_user);
|
||||
if (entity == NULL)
|
||||
{
|
||||
input_error++;
|
||||
error_string = sformatf( "Exchange %d not found for EXCHANGE_MODIFY.\n", n_user);
|
||||
error_msg(error_string, CONTINUE);
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
// read entity
|
||||
entity->read_raw(parser, false);
|
||||
|
||||
/* recalculate formula_totals */
|
||||
std::map<std::string, cxxExchComp>::iterator cit = entity->Get_exchComps().begin();
|
||||
for ( ; cit != entity->Get_exchComps().end(); cit++)
|
||||
{
|
||||
char * temp_formula = string_duplicate(cit->second.Get_formula().c_str());
|
||||
char *ptr = temp_formula;
|
||||
|
||||
count_elts = 0;
|
||||
paren_count = 0;
|
||||
get_elts_in_species(&ptr, 1.0);
|
||||
|
||||
cxxNameDouble nd(elt_list_save());
|
||||
//exchange[n].comps[i].formula_totals = elt_list_save();
|
||||
//free_check_null(temp_formula);
|
||||
cit->second.Set_formula_totals(elt_list_save());
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef SKIP
|
||||
if (exchange_bsearch(n_user, &n) == NULL)
|
||||
{
|
||||
input_error++;
|
||||
@ -1341,7 +1386,7 @@ read_exchange_modify(void)
|
||||
//exchange[n].new_def = TRUE;
|
||||
exchange_free(entity_ptr);
|
||||
free_check_null(entity_ptr);
|
||||
|
||||
#endif
|
||||
|
||||
// Need to output the next keyword
|
||||
if (return_value == OPTION_KEYWORD) echo_msg(sformatf( "\t%s\n", line));
|
||||
@ -1945,6 +1990,22 @@ delete_entities(void)
|
||||
}
|
||||
|
||||
// exchangers
|
||||
if (delete_info.Get_exchange().Get_defined())
|
||||
{
|
||||
if (delete_info.Get_exchange().Get_numbers().size() == 0)
|
||||
{
|
||||
Rxn_exchange_map.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::set < int >::iterator it;
|
||||
for (it = delete_info.Get_exchange().Get_numbers().begin(); it != delete_info.Get_exchange().Get_numbers().end(); it++)
|
||||
{
|
||||
Rxn_exchange_map.erase(*it);
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef SKIP
|
||||
if (delete_info.Get_exchange().Get_defined())
|
||||
{
|
||||
if (delete_info.Get_exchange().Get_numbers().size() == 0)
|
||||
@ -1966,7 +2027,7 @@ delete_entities(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
// surfaces
|
||||
if (delete_info.Get_surface().Get_defined())
|
||||
{
|
||||
@ -2433,6 +2494,27 @@ dump_ostream(std::ostream& os)
|
||||
}
|
||||
|
||||
// exchanges
|
||||
if (dump_info.Get_bool_exchange())
|
||||
{
|
||||
if (dump_info.Get_exchange().size() == 0)
|
||||
{
|
||||
Utilities::Rxn_dump_raw(Rxn_exchange_map, os, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::set < int >::iterator it;
|
||||
for (it = dump_info.Get_exchange().begin(); it != dump_info.Get_exchange().end(); it++)
|
||||
{
|
||||
cxxExchange *p = Utilities::Rxn_find(Rxn_exchange_map, *it);
|
||||
|
||||
if (p != NULL)
|
||||
{
|
||||
p->dump_raw(os, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef SKIP
|
||||
if (dump_info.Get_bool_exchange())
|
||||
{
|
||||
if (dump_info.Get_exchange().size() == 0)
|
||||
@ -2457,7 +2539,7 @@ dump_ostream(std::ostream& os)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
// surfaces
|
||||
if (dump_info.Get_bool_surface())
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user