limit on eps_r in utilities.cpp.

Added check when reading pitzer parameters that the right number of species is read.

git-svn-id: svn://136.177.114.72/svn_GW/phreeqc3/trunk@9390 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
David L Parkhurst 2015-03-24 20:25:58 +00:00
parent ffd459c6db
commit 4d47ed13fc
2 changed files with 14 additions and 1 deletions

View File

@ -79,8 +79,16 @@ pitz_param_read(char *string, int n)
ptr = string;
for (i = 0; i < n; i++)
{
if (copy_token(token, &ptr, &l) == EMPTY)
int j = copy_token(token, &ptr, &l);
if (j == EMPTY)
return (NULL);
if (j != UPPER)
{
input_error++;
std::ostringstream err;
err << "Wrong number of species for a Pitzer parameter.\n" << line;
error_msg(err.str().c_str(), CONTINUE);
}
pzp.species[i] = string_hsave(token);
}
k = 0;

View File

@ -237,6 +237,11 @@ calc_dielectrics(LDBLE tc, LDBLE pa)
LDBLE b = u7 + u8 / T + u9 * T;
LDBLE pb = pa * 1.01325; // pa in bar
eps_r = d1000 + c * log((b + pb) / (b + 1e3)); // relative dielectric constant
if (eps_r <= 0)
{
eps_r = 10.;
warning_msg("Relative dielectric constant is negative.\nTemperature is out of range of parameterization.");
}
/* qe^2 / (eps_r * kB * T) = 4.803204e-10**2 / 1.38065e-16 / (eps_r * T)
= 1.671008e-3 (esu^2 / (erg/K)) / (eps_r * T) */