GetSpeciesLogGammas

GetSurfaceDiffuseLayerConcentrations
GetSurfaceDiffuseLayerNames

Roughed in new methods. They appear to work but not tested much.

git-svn-id: svn://136.177.114.72/svn_GW/phreeqc3/trunk@9907 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
David L Parkhurst 2015-06-29 18:23:12 +00:00
parent 37b8b3f49e
commit f15d9155fc
4 changed files with 109 additions and 3 deletions

View File

@ -79,6 +79,7 @@ cxxSolution::operator =(const cxxSolution &rhs)
this->species_gamma = rhs.species_gamma;
this->isotopes = rhs.isotopes;
this->species_map = rhs.species_map;
this->log_gamma_map = rhs.log_gamma_map;
if (this->initial_data)
delete initial_data;
if (rhs.initial_data != NULL)
@ -308,6 +309,18 @@ cxxSolution::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out) con
}
}
// log_gamma_map
if (log_gamma_map.size() > 0)
{
s_oss << indent1;
s_oss << "-log_gamma_map" << "\n";
std::map<int, double>::const_iterator it = this->log_gamma_map.begin();
for ( ; it != log_gamma_map.end(); it++)
{
s_oss << indent2;
s_oss << it->first << " " << it->second << "\n";
}
}
return;
}
@ -957,6 +970,32 @@ cxxSolution::read_raw(CParser & parser, bool check)
opt_save = 24;
}
break;
case 25: // log_gamma_map
{
int s_num;
if (parser.peek_token() != CParser::TT_EMPTY)
{
if (!(parser.get_iss() >> s_num))
{
parser.incr_input_error();
parser.error_msg("Expected integer for species number.",
PHRQ_io::OT_CONTINUE);
}
else
{
double d;
if (!(parser.get_iss() >> d))
{
parser.incr_input_error();
parser.error_msg("Expected double for species concentration.",
PHRQ_io::OT_CONTINUE);
}
this->log_gamma_map[s_num] = d;
}
}
opt_save = 25;
}
break;
}
if (opt == CParser::OPT_EOF || opt == CParser::OPT_KEYWORD)
break;
@ -1342,6 +1381,19 @@ cxxSolution::add(const cxxSolution & addee, LDBLE extensive)
this->species_map[it->first] = it->second;
}
}
// Add gammas
std::map<int, double>::const_iterator git = addee.log_gamma_map.begin();
for ( ; git != addee.log_gamma_map.end(); git++)
{
if (this->log_gamma_map.find(git->first) != this->log_gamma_map.end())
{
this->log_gamma_map[git->first] = this->log_gamma_map[git->first] * f1 + git->second * f2;
}
else
{
this->log_gamma_map[git->first] = it->second;
}
}
}
}
@ -1494,6 +1546,7 @@ const std::vector< std::string >::value_type temp_vopts[] = {
std::vector< std::string >::value_type("density"), // 21
std::vector< std::string >::value_type("pressure"), // 22
std::vector< std::string >::value_type("soln_vol"), // 23
std::vector< std::string >::value_type("species_map") // 24
std::vector< std::string >::value_type("species_map"), // 24
std::vector< std::string >::value_type("log_gamma_map") // 25
};
const std::vector< std::string > cxxSolution::vopts(temp_vopts, temp_vopts + sizeof temp_vopts / sizeof temp_vopts[0]);

View File

@ -63,6 +63,7 @@ class cxxSolution:public cxxNumKeyword
cxxNameDouble & Get_master_activity(void) {return this->master_activity;}
cxxNameDouble & Get_species_gamma(void) {return this->species_gamma;}
std::map<int, double> & Get_species_map(void) {return this->species_map;}
std::map<int, double> & Get_log_gamma_map(void) {return this->log_gamma_map;}
std::map < std::string, cxxSolutionIsotope > & Get_isotopes(void) {return this->isotopes;}
const std::map < std::string, cxxSolutionIsotope > & Get_isotopes(void)const {return this->isotopes;}
void Set_isotopes(const std::map < std::string, cxxSolutionIsotope > &iso ) {this->isotopes = iso;}
@ -134,6 +135,7 @@ class cxxSolution:public cxxNumKeyword
cxxISolution *initial_data;
const static std::vector < std::string > vopts;
std::map<int, double> species_map;
std::map<int, double> log_gamma_map;
};
#endif // !defined(SOLUTION_H_INCLUDED)

View File

@ -98,6 +98,20 @@ cxxSurfaceCharge::dump_raw(std::ostream & s_oss, unsigned int indent) const
s_oss << "-diffuse_layer_totals" << "\n";
this->diffuse_layer_totals.dump_raw(s_oss, indent + 1);
// DL species
//s_oss << indent0;
//s_oss << "-diffuse_layer_species" << "\n";
if (dl_species_map.size() > 0)
{
s_oss << indent0;
s_oss << "-diffuse_layer_species" << "\n";
std::map<int, double>::const_iterator it = this->dl_species_map.begin();
for ( ; it != dl_species_map.end(); it++)
{
s_oss << indent1;
s_oss << it->first << " " << it->second << "\n";
}
}
s_oss << indent0 << "# Surface workspace variables #\n";
s_oss << indent0 << "-sigma0 " << this->sigma0 << "\n";
s_oss << indent0 << "-sigma1 " << this->sigma1 << "\n";
@ -320,6 +334,33 @@ cxxSurfaceCharge::read_raw(CParser & parser, bool check)
else
git->second.Set_psi_to_z(dummy);
}
break;
case 16: // dl_species_map
int s_num;
if (parser.peek_token() != CParser::TT_EMPTY)
{
if (!(parser.get_iss() >> s_num))
{
parser.incr_input_error();
parser.error_msg("Expected integer for species number.",
PHRQ_io::OT_CONTINUE);
}
else
{
double d;
if (!(parser.get_iss() >> d))
{
parser.incr_input_error();
parser.error_msg("Expected double for species concentration.",
PHRQ_io::OT_CONTINUE);
}
this->dl_species_map[s_num] = d;
}
}
opt_save = 16;
break;
}
if (opt == CParser::OPT_EOF || opt == CParser::OPT_KEYWORD)
@ -435,6 +476,7 @@ const std::vector< std::string >::value_type temp_vopts[] = {
std::vector< std::string >::value_type("sigma1"), // 12
std::vector< std::string >::value_type("sigma2"), // 13
std::vector< std::string >::value_type("sigmaddl"), // 14
std::vector< std::string >::value_type("g_map") // 15
std::vector< std::string >::value_type("g_map"), // 15
std::vector< std::string >::value_type("diffuse_layer_species") // 16
};
const std::vector< std::string > cxxSurfaceCharge::vopts(temp_vopts, temp_vopts + sizeof temp_vopts / sizeof temp_vopts[0]);

View File

@ -1534,7 +1534,7 @@ xsolution_save(int n_user)
*/
temp_solution.Get_totals()[master[i]->elt->name] = master[i]->total;
}
if (pitzer_model == TRUE || sit_model == TRUE || this->save_species)
if (pitzer_model == TRUE || sit_model == TRUE)
{
for (int j = 0; j < count_s_x; j++)
{
@ -1604,6 +1604,15 @@ xsolution_save(int n_user)
temp_solution.Get_species_map()[s_x[i]->number] = s_x[i]->moles / temp_solution.Get_soln_vol();
}
}
// saves gamma
temp_solution.Get_log_gamma_map().clear();
for (int i = 0; i < this->count_s_x; i++)
{
if (s_x[i]->type <= H2O)
{
temp_solution.Get_log_gamma_map()[s_x[i]->number] = s_x[i]->lg;
}
}
}
/*
* Save solution