mirror of
https://git.gfz-potsdam.de/naaice/iphreeqc.git
synced 2025-12-16 16:44:49 +01:00
Implemented Tony's Peng-Robinson changes. Need to run his test cases.
git-svn-id: svn://136.177.114.72/svn_GW/phreeqcpp/branches/ErrorHandling@5731 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
parent
d2c28c17a4
commit
f8887170b9
40
GasPhase.cxx
40
GasPhase.cxx
@ -27,6 +27,7 @@ cxxGasPhase::cxxGasPhase(PHRQ_io * io)
|
||||
{
|
||||
total_p = 0;
|
||||
volume = 0;
|
||||
v_m = 0;
|
||||
gasPhaseComps.type = cxxNameDouble::ND_NAME_COEF;
|
||||
}
|
||||
|
||||
@ -52,6 +53,7 @@ cxxNumKeyword(io)
|
||||
}
|
||||
total_p = gas_phase_ptr->total_p;
|
||||
volume = gas_phase_ptr->volume;
|
||||
v_m = gas_phase_ptr->v_m;
|
||||
|
||||
// gas_phase components
|
||||
for (i = 0; i < gas_phase_ptr->count_comps; i++)
|
||||
@ -70,6 +72,7 @@ cxxNumKeyword(io)
|
||||
gasPhaseComps.type = cxxNameDouble::ND_NAME_COEF;
|
||||
total_p = 0;
|
||||
volume = 0;
|
||||
v_m = 0;
|
||||
bool first = true;
|
||||
//
|
||||
// Mix
|
||||
@ -93,6 +96,7 @@ cxxNumKeyword(io)
|
||||
this->type = entity_ptr->type;
|
||||
this->total_p = entity_ptr->total_p * it->second;
|
||||
this->volume = entity_ptr->volume * it->second;
|
||||
this->v_m = entity_ptr->v_m * it->second;
|
||||
first = false;
|
||||
}
|
||||
else
|
||||
@ -108,6 +112,7 @@ cxxNumKeyword(io)
|
||||
|
||||
this->total_p += entity_ptr->total_p * it->second;
|
||||
this->volume += entity_ptr->volume * it->second;
|
||||
this->v_m += entity_ptr->v_m * it->second;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -181,6 +186,9 @@ cxxGasPhase::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out) con
|
||||
s_oss << indent1;
|
||||
s_oss << "-volume " << this->volume << std::endl;
|
||||
|
||||
s_oss << indent1;
|
||||
s_oss << "-v_m " << this->v_m << std::endl;
|
||||
|
||||
// gasPhaseComps
|
||||
s_oss << indent1;
|
||||
s_oss << "-component" << std::endl;
|
||||
@ -199,8 +207,9 @@ cxxGasPhase::read_raw(CParser & parser, bool check)
|
||||
vopts.push_back("type"); //0
|
||||
vopts.push_back("total_p"); //1
|
||||
vopts.push_back("volume"); //2
|
||||
vopts.push_back("component"); //3
|
||||
vopts.push_back("pressure"); //4
|
||||
vopts.push_back("v_m"); //3
|
||||
vopts.push_back("component"); //4
|
||||
vopts.push_back("pressure"); //5
|
||||
}
|
||||
|
||||
std::istream::pos_type ptr;
|
||||
@ -216,6 +225,7 @@ cxxGasPhase::read_raw(CParser & parser, bool check)
|
||||
bool type_defined(false);
|
||||
bool total_p_defined(false);
|
||||
bool volume_defined(false);
|
||||
bool v_m_defined(false);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
@ -265,7 +275,7 @@ cxxGasPhase::read_raw(CParser & parser, bool check)
|
||||
break;
|
||||
|
||||
case 1: // total_p
|
||||
case 4: // pressure
|
||||
case 5: // pressure
|
||||
if (!(parser.get_iss() >> this->total_p))
|
||||
{
|
||||
this->total_p = 0;
|
||||
@ -289,7 +299,19 @@ cxxGasPhase::read_raw(CParser & parser, bool check)
|
||||
useLastLine = false;
|
||||
break;
|
||||
|
||||
case 3: // component
|
||||
case 3: // v_m
|
||||
if (!(parser.get_iss() >> this->v_m))
|
||||
{
|
||||
this->v_m = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for v_m.",
|
||||
CParser::OT_CONTINUE);
|
||||
}
|
||||
v_m_defined = true;
|
||||
useLastLine = false;
|
||||
break;
|
||||
|
||||
case 4: // component
|
||||
if (this->gasPhaseComps.read_raw(parser, next_char) !=
|
||||
CParser::PARSER_OK)
|
||||
{
|
||||
@ -299,7 +321,7 @@ cxxGasPhase::read_raw(CParser & parser, bool check)
|
||||
("Expected gas component name and moles for gasPhaseComps.",
|
||||
CParser::OT_CONTINUE);
|
||||
}
|
||||
opt_save = 3;
|
||||
opt_save = 4;
|
||||
useLastLine = false;
|
||||
break;
|
||||
}
|
||||
@ -327,6 +349,12 @@ cxxGasPhase::read_raw(CParser & parser, bool check)
|
||||
parser.error_msg("Volume not defined for GAS_PHASE_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
}
|
||||
if (v_m_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("V_m not defined for GAS_PHASE_RAW input.",
|
||||
CParser::OT_CONTINUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -347,6 +375,7 @@ cxxGasPhase::mpi_pack(std::vector < int >&ints,
|
||||
}
|
||||
doubles.push_back(this->total_p);
|
||||
doubles.push_back(this->volume);
|
||||
doubles.push_back(this->v_m);
|
||||
}
|
||||
|
||||
void
|
||||
@ -369,6 +398,7 @@ cxxGasPhase::mpi_unpack(int *ints, int *ii, double *doubles, int *dd)
|
||||
}
|
||||
this->total_p = doubles[d++];
|
||||
this->volume = doubles[d++];
|
||||
this->v_m = doubles[d++];
|
||||
*ii = i;
|
||||
*dd = d;
|
||||
}
|
||||
|
||||
@ -49,6 +49,7 @@ class cxxGasPhase:public cxxNumKeyword
|
||||
GP_TYPE Get_type(void) const {return type;};
|
||||
double Get_total_p(void) const {return total_p;};
|
||||
double Get_volume(void) const {return volume;};
|
||||
double Get_v_m(void) const {return v_m;};
|
||||
cxxNameDouble & Get_totals(void) {return totals;};
|
||||
|
||||
protected:
|
||||
@ -59,6 +60,7 @@ protected:
|
||||
GP_TYPE type;
|
||||
double total_p;
|
||||
double volume;
|
||||
double v_m;
|
||||
cxxNameDouble totals;
|
||||
|
||||
};
|
||||
|
||||
@ -63,7 +63,6 @@ output_msg(const std::string & stdstr)
|
||||
{
|
||||
if (this->io)
|
||||
{
|
||||
//this->io->phreeqc_handler(PHRQ_io::ACTION_OUTPUT, PHRQ_io::OUTPUT_MESSAGE, stdstr.c_str(), stop!=0, "", NULL);
|
||||
this->io->output_msg(stdstr.c_str());
|
||||
}
|
||||
else
|
||||
|
||||
@ -25,6 +25,7 @@ PHRQ_base(io)
|
||||
//
|
||||
{
|
||||
si = 0;
|
||||
si_org = 0;
|
||||
moles = 0;
|
||||
delta = 0;
|
||||
initial_moles = 0;
|
||||
@ -43,6 +44,7 @@ PHRQ_base(io)
|
||||
this->Set_name(pure_phase_ptr->name);
|
||||
this->Set_add_formula(pure_phase_ptr->add_formula);
|
||||
si = pure_phase_ptr->si;
|
||||
si_org = pure_phase_ptr->si_org;
|
||||
moles = pure_phase_ptr->moles;
|
||||
delta = pure_phase_ptr->delta;
|
||||
initial_moles = pure_phase_ptr->initial_moles;
|
||||
@ -75,6 +77,7 @@ cxxPPassemblageComp::dump_xml(std::ostream & s_oss, unsigned int indent) const
|
||||
s_oss << indent0 << "add_formula=\"" << this->
|
||||
add_formula << "\"" << std::endl;
|
||||
s_oss << indent0 << "si=\"" << this->si << "\"" << std::endl;
|
||||
s_oss << indent0 << "si_org=\"" << this->si_org << "\"" << std::endl;
|
||||
s_oss << indent0 << "moles=\"" << this->moles << "\"" << std::endl;
|
||||
s_oss << indent0 << "delta=\"" << this->delta << "\"" << std::endl;
|
||||
s_oss << indent0 << "initial_moles=\"" << this->
|
||||
@ -109,6 +112,7 @@ cxxPPassemblageComp::dump_raw(std::ostream & s_oss, unsigned int indent) const
|
||||
if (this->add_formula.size() != 0)
|
||||
s_oss << indent1 << "-add_formula " << this->add_formula << std::endl;
|
||||
s_oss << indent1 << "-si " << this->si << std::endl;
|
||||
s_oss << indent1 << "-si_org " << this->si_org << std::endl;
|
||||
s_oss << indent1 << "-moles " << this->moles << std::endl;
|
||||
s_oss << indent1 << "-delta " << this->delta << std::endl;
|
||||
s_oss << indent1 << "-initial_moles " << this->initial_moles << std::endl;
|
||||
@ -135,6 +139,7 @@ cxxPPassemblageComp::read_raw(CParser & parser, bool check)
|
||||
vopts.push_back("dissolve_only"); // 6
|
||||
vopts.push_back("force_equality"); // 7
|
||||
vopts.push_back("precipitate_only"); // 8
|
||||
vopts.push_back("si_org"); // 9
|
||||
}
|
||||
|
||||
std::istream::pos_type ptr;
|
||||
@ -145,6 +150,7 @@ cxxPPassemblageComp::read_raw(CParser & parser, bool check)
|
||||
opt_save = CParser::OPT_ERROR;
|
||||
bool name_defined(false);
|
||||
bool si_defined(false);
|
||||
bool si_org_defined(false);
|
||||
bool moles_defined(false);
|
||||
bool delta_defined(false);
|
||||
bool initial_moles_defined(false);
|
||||
@ -288,6 +294,16 @@ cxxPPassemblageComp::read_raw(CParser & parser, bool check)
|
||||
this->dissolve_only = false;
|
||||
}
|
||||
break;
|
||||
case 9: // si_org
|
||||
if (!(parser.get_iss() >> this->si_org))
|
||||
{
|
||||
this->si_org = 0;
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Expected numeric value for si_org.",
|
||||
CParser::OT_CONTINUE);
|
||||
}
|
||||
si_org_defined = true;
|
||||
break;
|
||||
}
|
||||
if (opt == CParser::OPT_EOF || opt == CParser::OPT_KEYWORD)
|
||||
break;
|
||||
@ -347,6 +363,12 @@ cxxPPassemblageComp::read_raw(CParser & parser, bool check)
|
||||
("Force_equality not defined for PPassemblageComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
}
|
||||
if (si_org_defined == false)
|
||||
{
|
||||
parser.incr_input_error();
|
||||
parser.error_msg("Si_org not defined for PPassemblageComp input.",
|
||||
CParser::OT_CONTINUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -360,6 +382,7 @@ cxxPPassemblageComp::mpi_pack(std::vector < int >&ints,
|
||||
ints.push_back(dictionary.string2int(this->name));
|
||||
ints.push_back(dictionary.string2int(this->add_formula));
|
||||
doubles.push_back(this->si);
|
||||
doubles.push_back(this->si_org);
|
||||
doubles.push_back(this->moles);
|
||||
doubles.push_back(this->delta);
|
||||
doubles.push_back(this->initial_moles);
|
||||
@ -377,6 +400,7 @@ cxxPPassemblageComp::mpi_unpack(int *ints, int *ii, double *doubles, int *dd)
|
||||
this->name = dictionary.int2stdstring(ints[i++]);
|
||||
this->add_formula = dictionary.int2stdstring(ints[i++]);
|
||||
this->si = doubles[d++];
|
||||
this->si_org = doubles[d++];
|
||||
this->moles = doubles[d++];
|
||||
this->delta = doubles[d++];
|
||||
this->initial_moles = doubles[d++];
|
||||
@ -453,6 +477,8 @@ cxxPPassemblageComp::add(const cxxPPassemblageComp & addee, double extensive)
|
||||
}
|
||||
//double si;
|
||||
this->si = this->si * f1 + addee.si * f2;
|
||||
//double si_org;
|
||||
this->si_org = this->si_org * f1 + addee.si_org * f2;
|
||||
//double moles;
|
||||
this->moles += addee.moles * extensive;
|
||||
//double delta;
|
||||
|
||||
@ -50,6 +50,7 @@ class cxxPPassemblageComp: public PHRQ_base
|
||||
return (this->totals);
|
||||
};
|
||||
double Get_si() const {return this->si;};
|
||||
double Get_si_org() const {return this->si_org;};
|
||||
double Get_moles() const {return this->moles;};
|
||||
double Get_delta() const {return this->delta;};
|
||||
double Get_initial_moles() const {return this->initial_moles;};
|
||||
@ -69,6 +70,7 @@ protected:
|
||||
std::string name;
|
||||
std::string add_formula;
|
||||
double si;
|
||||
double si_org;
|
||||
double moles;
|
||||
double delta;
|
||||
double initial_moles;
|
||||
|
||||
@ -325,7 +325,11 @@ Phreeqc::Phreeqc(void)
|
||||
{"iso", tokiso},
|
||||
{"iso_unit", tokiso_unit},
|
||||
{"phase_formula", tokphase_formula},
|
||||
{"list_s_s", toklist_s_s}
|
||||
{"list_s_s", toklist_s_s},
|
||||
{"pr_p", tokpr_p},
|
||||
{"pr_phi", tokpr_phi},
|
||||
{"gas_p", tokgas_p},
|
||||
{"gas_vm", tokgas_vm}
|
||||
};
|
||||
NCMDS = (sizeof(command_temp) / sizeof(struct const_key));
|
||||
command = new const_key[NCMDS];
|
||||
|
||||
@ -86,6 +86,8 @@ LDBLE calc_surface_charge(const char *surface_name);
|
||||
LDBLE diff_layer_total(const char *total_name, const char *surface_name);
|
||||
LDBLE equi_phase(const char *phase_name);
|
||||
LDBLE find_gas_comp(const char *gas_comp_name);
|
||||
LDBLE find_gas_p(void);
|
||||
LDBLE find_gas_vm(void);
|
||||
LDBLE find_misc1(const char *s_s_name);
|
||||
LDBLE find_misc2(const char *s_s_name);
|
||||
LDBLE find_s_s_comp(const char *s_s_comp_name);
|
||||
@ -96,6 +98,8 @@ LDBLE kinetics_moles(const char *kinetics_name);
|
||||
LDBLE log_activity(const char *species_name);
|
||||
LDBLE log_molality(const char *species_name);
|
||||
LDBLE molality(const char *species_name);
|
||||
LDBLE pr_pressure(const char *phase_name);
|
||||
LDBLE pr_phi(const char *phase_name);
|
||||
LDBLE saturation_ratio(const char *phase_name);
|
||||
int saturation_index(const char *phase_name, LDBLE * iap, LDBLE * si);
|
||||
LDBLE solution_sum_secondary(const char *total_name);
|
||||
@ -550,6 +554,7 @@ int setup_exchange(void);
|
||||
int setup_gas_phase(void);
|
||||
int setup_master_rxn(struct master **master_ptr_list,
|
||||
struct reaction **pe_rxn);
|
||||
LDBLE calc_PR(struct phase **phase_ptrs, int n_g, LDBLE P, LDBLE TK, LDBLE V_m);
|
||||
int setup_pure_phases(void);
|
||||
int setup_related_surface(void);
|
||||
int setup_s_s_assemblage(void);
|
||||
@ -627,6 +632,10 @@ int read_conc(int n, int count_mass_balance, char *str);
|
||||
int *read_list_ints_range(char **ptr, int *count_ints, int positive,
|
||||
int *int_list);
|
||||
int read_log_k_only(char *ptr, LDBLE * log_k);
|
||||
int read_t_c_only(char *ptr, LDBLE *t_c);
|
||||
int read_p_c_only(char *ptr, LDBLE * p_c);
|
||||
int read_omega_only(char *ptr, LDBLE *omega);
|
||||
int read_delta_v_only(char *ptr, LDBLE * delta_v);
|
||||
int read_number_description(char *ptr, int *n_user, int *n_user_end,
|
||||
char **description, int allow_negative=FALSE);
|
||||
int check_key(char *str);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user