Added SOLUTION_MIX m-n keyword that mixes solutions without doing a full reaction calculation.

Results of mix are stored as SOLUTION m-n.

git-svn-id: svn://136.177.114.72/svn_GW/phreeqc3/trunk@6665 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
David L Parkhurst 2012-06-13 23:15:49 +00:00
parent 77b082d0e8
commit fc2d4425fb
6 changed files with 141 additions and 2 deletions

View File

@ -122,7 +122,8 @@ std::map<const std::string, Keywords::KEYWORDS>::value_type("solid_solution_modi
std::map<const std::string, Keywords::KEYWORDS>::value_type("reaction_pressure", Keywords::KEY_REACTION_PRESSURE),
std::map<const std::string, Keywords::KEYWORDS>::value_type("reaction_pressures", Keywords::KEY_REACTION_PRESSURE),
std::map<const std::string, Keywords::KEYWORDS>::value_type("reaction_pressure_raw", Keywords::KEY_REACTION_PRESSURE_RAW),
std::map<const std::string, Keywords::KEYWORDS>::value_type("reaction_pressure_modify", Keywords::KEY_REACTION_PRESSURE_MODIFY)
std::map<const std::string, Keywords::KEYWORDS>::value_type("reaction_pressure_modify", Keywords::KEY_REACTION_PRESSURE_MODIFY),
std::map<const std::string, Keywords::KEYWORDS>::value_type("solution_mix", Keywords::KEY_SOLUTION_MIX)
};
std::map<const std::string, Keywords::KEYWORDS> Keywords::phreeqc_keywords(temp_keywords, temp_keywords + sizeof temp_keywords / sizeof temp_keywords[0]);
@ -196,6 +197,7 @@ std::map<Keywords::KEYWORDS, const std::string>::value_type(Keywords::KEY_REACTI
std::map<Keywords::KEYWORDS, const std::string>::value_type(Keywords::KEY_REACTION_TEMPERATURE_MODIFY, "REACTION_TEMPERATURE_MODIFY"),
std::map<Keywords::KEYWORDS, const std::string>::value_type(Keywords::KEY_REACTION_PRESSURE, "REACTION_PRESSURE"),
std::map<Keywords::KEYWORDS, const std::string>::value_type(Keywords::KEY_REACTION_PRESSURE_RAW, "REACTION_PRESSURE_RAW"),
std::map<Keywords::KEYWORDS, const std::string>::value_type(Keywords::KEY_REACTION_PRESSURE_MODIFY, "REACTION_PRESSURE_MODIFY")
std::map<Keywords::KEYWORDS, const std::string>::value_type(Keywords::KEY_REACTION_PRESSURE_MODIFY, "REACTION_PRESSURE_MODIFY"),
std::map<Keywords::KEYWORDS, const std::string>::value_type(Keywords::KEY_SOLUTION_MIX, "SOLUTION_MIX")
};
std::map<Keywords::KEYWORDS, const std::string> Keywords::phreeqc_keyword_names(temp_keyword_names, temp_keyword_names + sizeof temp_keyword_names / sizeof temp_keyword_names[0]);

View File

@ -76,6 +76,7 @@ public:
KEY_REACTION_PRESSURE,
KEY_REACTION_PRESSURE_RAW,
KEY_REACTION_PRESSURE_MODIFY,
KEY_SOLUTION_MIX,
KEY_COUNT_KEYWORDS // must be last in list
};

View File

@ -395,6 +395,7 @@ public:
int initial_exchangers(int print);
int initial_gas_phases(int print);
int initial_solutions(int print);
int solution_mix(void);
int step_save_exch(int n_user);
int step_save_surf(int n_user);
int initial_surfaces(int print);
@ -687,6 +688,7 @@ public:
int *read_list_t_f(char **ptr, int *count_ints);
int read_master_species(void);
int read_mix(void);
int read_solution_mix(void);
int read_named_logk(void);
int read_phases(void);
int read_print(void);
@ -1192,6 +1194,7 @@ protected:
*---------------------------------------------------------------------- */
std::map<int, cxxMix> Rxn_mix_map;
std::map<int, cxxMix> Dispersion_mix_map;
std::map<int, cxxMix> Rxn_solution_mix_map;
/*----------------------------------------------------------------------
* Irreversible reaction

View File

@ -686,6 +686,8 @@ cxxSolution::zero()
this->totals.type = cxxNameDouble::ND_ELT_MOLES;
this->master_activity.type = cxxNameDouble::ND_SPECIES_LA;
this->species_gamma.type = cxxNameDouble::ND_SPECIES_GAMMA;
this->patm = 1.0;
this->initial_data = NULL;
}
void

View File

@ -1035,6 +1035,25 @@ initial_solutions(int print)
}
/* ---------------------------------------------------------------------- */
int Phreeqc::
solution_mix()
/* ---------------------------------------------------------------------- */
{
/*
* Go through list of solution_mix, mix, save solutions
*/
std::map<int, cxxMix>::iterator it;
for (it = Rxn_solution_mix_map.begin(); it != Rxn_solution_mix_map.end(); it++)
{
int i = 1;
cxxSolution sol(Rxn_solution_map, it->second, it->second.Get_n_user(), this->phrq_io);
Rxn_solution_map[it->second.Get_n_user()] = sol;
Utilities::Rxn_copies(Rxn_solution_map, it->second.Get_n_user(), it->second.Get_n_user_end());
}
Rxn_solution_mix_map.clear();
return OK;
}
/* ---------------------------------------------------------------------- */
int Phreeqc::
initial_exchangers(int print)
/* ---------------------------------------------------------------------- */
{
@ -2626,6 +2645,11 @@ run_simulations(void)
*/
if (new_solution)
initial_solutions(TRUE);
/*
* Calculate mixed solutions
*/
if (Rxn_solution_mix_map.size() > 0)
solution_mix();
/*
* Calculate distribution for exchangers
*/

View File

@ -112,6 +112,9 @@ read_input(void)
case Keywords::KEY_MIX:
read_mix();
break;
case Keywords::KEY_SOLUTION_MIX:
read_solution_mix();
break;
case Keywords::KEY_USE:
read_use();
break;
@ -3390,6 +3393,110 @@ read_mix(void)
return (return_value);
}
/* ---------------------------------------------------------------------- */
int Phreeqc::
read_solution_mix(void)
/* ---------------------------------------------------------------------- */
{
/*
* Reads mixing fractions
*/
int n_user, n_user_end;
int return_value;
int n_solution;
LDBLE fraction;
int j, i, l;
char *ptr;
char token[MAX_LENGTH];
char *description;
cxxMix temp_mix;
/*
* Read mix number
*/
ptr = line;
read_number_description(ptr, &n_user, &n_user_end, &description);
temp_mix.Set_n_user(n_user);
temp_mix.Set_n_user_end(n_user_end);
temp_mix.Set_description(description);
free_check_null(description);
#ifdef SKIP
/*
* Set use data to first read
*/
if (use.Get_mix_in() == FALSE)
{
use.Set_mix_in(true);
use.Set_n_mix_user(n_user);
}
#endif
/*
* Read mixture data
*/
for (;;)
{
return_value = check_line("Mix raw data", FALSE, TRUE, TRUE, TRUE);
/* empty, eof, keyword, print */
if (return_value == EOF || return_value == KEYWORD)
{
break;
}
ptr = line;
/*
* Read n_user
*/
i = copy_token(token, &ptr, &l);
if (i == DIGIT)
{
sscanf(token, "%d ", &n_solution);
}
else
{
input_error++;
error_msg("Expected a solution number in mix_raw input.", CONTINUE);
error_msg(line_save, CONTINUE);
continue;
}
/*
* Read fraction for solution
*/
copy_token(token, &ptr, &l);
j = sscanf(token, SCANFORMAT, &fraction);
if (j != 1)
{
input_error++;
error_msg("Expected a mixing fraction.", CONTINUE);
error_msg(line_save, CONTINUE);
continue;
}
/*
* Save data
*/
temp_mix.Add(n_solution ,fraction);
}
if (temp_mix.Get_mixComps().size() == 0)
{
input_error++;
error_msg
("Must define at least one solution number and mixing fraction for MIX_RAW input.",
CONTINUE);
}
Rxn_solution_mix_map[n_user] = temp_mix;
#ifdef SKIP
// copy if needed
if (n_user_end > n_user)
{
int i;
for (i = n_user + 1; i <= n_user_end; i++)
{
Utilities::Rxn_copy(Rxn_mix_map, n_user, i);
}
}
#endif
return (return_value);
}
/* ---------------------------------------------------------------------- */
int Phreeqc::