finalizing compute_gfw

using map for rates

git-svn-id: svn://136.177.114.72/svn_GW/phreeqc3/trunk@8888 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
David L Parkhurst 2014-07-29 20:39:38 +00:00
parent 685a4d45b3
commit 98741bbe32
4 changed files with 23 additions and 3 deletions

View File

@ -1913,6 +1913,7 @@ protected:
/* utilities.cpp ------------------------------- */
int spinner;
std::map<std::string, double> gfw_map;
std::map<std::string, int> rates_map;
/* new after release of Version 3 */
std::map<std::string, std::vector < std::string> > sum_species_map;

View File

@ -281,9 +281,11 @@ calc_solution_volume(void)
*/
LDBLE total_mass = 0;
LDBLE gfw;
compute_gfw("H", &gfw);
//compute_gfw("H", &gfw);
gfw = s_hplus->primary->gfw;
total_mass = total_h_x * gfw;
compute_gfw("O", &gfw);
//compute_gfw("O", &gfw);
gfw = s_h2o->primary->gfw;
total_mass += total_o_x * gfw;
for (int i = 0; i < count_master; i++)

View File

@ -9190,7 +9190,9 @@ read_rates(void)
break;
}
/* output_msg(sformatf( "%s", rates[0].commands));
*/ return (return_value);
*/
rates_map.clear();
return (return_value);
}
/* ---------------------------------------------------------------------- */

View File

@ -1649,6 +1649,19 @@ rate_search(const char *name, int *n)
* if found, the address of the pp_assemblage element
* if not found, NULL
*/
std::string str(name);
std::map<std::string, int>::iterator it;
it = rates_map.find(str);
if (it != rates_map.end())
{
*n = it->second;
if (*n >= 0)
{
return &(rates[it->second]);
}
return NULL;
}
int i;
*n = -1;
for (i = 0; i < count_rates; i++)
@ -1656,12 +1669,14 @@ rate_search(const char *name, int *n)
if (strcmp_nocase(rates[i].name, name) == 0)
{
*n = i;
rates_map[str] = i;
return (&(rates[i]));
}
}
/*
* rate name not found
*/
rates_map[str] = *n;
return (NULL);
}