Merged in Tony's changes for electro diffusion.

git-svn-id: svn://136.177.114.72/svn_GW/phreeqc3/branches/concrete@12388 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
David L Parkhurst 2017-02-09 17:17:10 +00:00
parent 9bf1411f42
commit 025d2a1ee1
16 changed files with 659 additions and 508 deletions

View File

@ -1134,7 +1134,8 @@ namespace zdg_ui2 {
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
try
{
this->Icon = (cli::safe_cast<System::Drawing::Icon^ >(resources->GetObject(L"$this.Icon")));
//this->Icon = (cli::safe_cast<System::Drawing::Icon^ >(resources->GetObject(L"$this.Icon")));
this->Icon = gcnew System::Drawing::Icon("c:\\phreeqc\\phreex.ico");
}
catch (...)
{

View File

@ -3,6 +3,9 @@
<!-- In Managed Resources,
set Resource File Name:
$(IntDir)\zdg_ui2.$(InputName).resources
in VS2012: compile with resgen.exe:
click Start, All Programs, Visual Studio 20**, Visual Studio Tools, Visual Studio Command Prompt
resgen path**.Form1.resX
-->
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
@ -11,23 +14,23 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="imageList1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<metadata name="imageList1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAEAEBAQAAEABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAP8AMzOaAGgymgA0Mc0AmWVoAGdlmwBjZssAy5kvAP+ZNQDLmmMAzpmVAP/MLQDLzWUA/8xjAP3/
mAAAAAAAiIiIiIiIiIiIgAAIhIiIhHAAAAB3KXcXcAeQAAeTk5fQDd0ADdoK3b27uwALugm7u7u7AAtz
k9vbuwAAu2u7Xbu7AAva29u5zMzAAMzMzMzu7u4ADu7szOAO7gAO7u7u4ADuAA7u7u7uAAAA7u7u7u7g
AA7u7u7u7u7u7u7u7u4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAA
</value>
AAABAAEAEBAQAAEABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAP8AMzOaAGgymgA0Mc0AmWVoAGdlmwBjZssAy5kvAP+ZNQDLmmMAzpmVAP/MLQDLzWUA/8xjAP3/
mAAAAAAAiIiIiIiIiIiIgAAIhIiIhHAAAAB3KXcXcAeQAAeTk5fQDd0ADdoK3b27uwALugm7u7u7AAtz
k9vbuwAAu2u7Xbu7AAva29u5zMzAAMzMzMzu7u4ADu7szOAO7gAO7u7u4ADuAA7u7u7uAAAA7u7u7u7g
AA7u7u7u7u7u7u7u7u4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAA
</value>
</data>
</root>

View File

@ -1645,6 +1645,9 @@ listtokens(FILE * f, tokenrec * l_buf)
case tokpot_v:
output_msg("POT_V");
break;
case tokt_sc:
output_msg("T_SC");
break;
}
l_buf = l_buf->next;
}
@ -3658,6 +3661,12 @@ factor(struct LOC_exec * LINK)
n.UU.val = (parse_all) ? 1 : PhreeqcPtr->aqueous_vm(str);
}
break;
case tokphase_vm:
{
const char * str = stringfactor(STR1, LINK);
n.UU.val = (parse_all) ? 1 : PhreeqcPtr->phase_vm(str);
}
break;
case tokviscos:
{
n.UU.val = (parse_all) ? 1 : PhreeqcPtr->viscos;
@ -3675,6 +3684,12 @@ factor(struct LOC_exec * LINK)
case tokpot_v:
n.UU.val = (parse_all) ? 1 : PhreeqcPtr->use.Get_solution_ptr()->Get_potV();
break;
case tokt_sc:
{
const char * str = stringfactor(STR1, LINK);
n.UU.val = (parse_all) ? 1 : PhreeqcPtr->calc_t_sc(str);
}
break;
case toklog10:
{
@ -3689,13 +3704,6 @@ factor(struct LOC_exec * LINK)
//}
}
break;
case tokphase_vm:
{
const char * str = stringfactor(STR1, LINK);
n.UU.val = (parse_all) ? 1 : PhreeqcPtr->phase_vm(str);
}
break;
case toksin:
n.UU.val = sin(realfactor(LINK));
break;
@ -7303,6 +7311,7 @@ const std::map<const std::string, PBasic::BASIC_TOKEN>::value_type temp_tokens[]
std::map<const std::string, PBasic::BASIC_TOKEN>::value_type("phase_vm", PBasic::tokphase_vm),
std::map<const std::string, PBasic::BASIC_TOKEN>::value_type("current_a", PBasic::tokcurrent_a),
std::map<const std::string, PBasic::BASIC_TOKEN>::value_type("pot_v", PBasic::tokpot_v),
std::map<const std::string, PBasic::BASIC_TOKEN>::value_type("t_sc", PBasic::tokt_sc),
std::map<const std::string, PBasic::BASIC_TOKEN>::value_type("setdiff_c", PBasic::toksetdiff_c)
};
std::map<const std::string, PBasic::BASIC_TOKEN> PBasic::command_tokens(temp_tokens, temp_tokens + sizeof temp_tokens / sizeof temp_tokens[0]);

View File

@ -310,6 +310,7 @@ public:
tokerase,
tokeps_r,
tokvm,
tokphase_vm,
tokdh_a,
tokdh_b,
tokdh_av,
@ -333,7 +334,7 @@ public:
tokviscos_0,
tokcurrent_a,
tokpot_v,
tokphase_vm
tokt_sc
};
#if !defined(PHREEQCI_GUI)

View File

@ -112,6 +112,7 @@ public:
LDBLE calc_logk_p(const char *name);
LDBLE calc_logk_s(const char *name);
LDBLE calc_surface_charge(const char *surface_name);
LDBLE calc_t_sc(const char *name);
LDBLE diff_layer_total(const char *total_name, const char *surface_name);
LDBLE edl_species(const char *surf_name, LDBLE * count, char ***names, LDBLE ** moles, LDBLE * area, LDBLE * thickness);
int get_edl_species(cxxSurfaceCharge & charge_ref);
@ -1748,6 +1749,7 @@ protected:
LDBLE sys_tot;
LDBLE V_solutes, rho_0, rho_0_sat, kappa_0, p_sat/*, ah2o_x0*/;
LDBLE SC; // specific conductance mS/cm
LDBLE eps_r; // relative dielectric permittivity
LDBLE DH_A, DH_B, DH_Av; // Debye-Hueckel A, B and Av
LDBLE QBrn; // Born function d(ln(eps_r))/dP / eps_r * 41.84004, for supcrt calc'n of molal volume
@ -1792,7 +1794,6 @@ protected:
/* input.cpp ------------------------------- */
int check_line_return;
int reading_db;
std::ostringstream definitions_for_parallelizer;
/* integrate.cpp ------------------------------- */
LDBLE midpoint_sv;
@ -1991,7 +1992,6 @@ protected:
friend class IPhreeqcMMS;
friend class IPhreeqcPhast;
friend class PhreeqcRM;
friend class Parallelizer;
std::vector<int> keycount; // used to mark keywords that have been read
@ -2021,7 +2021,7 @@ public:
# if __GNUC__ && (__cplusplus >= 201103L)
# define PHR_ISFINITE(x) std::isfinite(x)
# else
# define PHR_ISFINITE(x) isfinite(x)
# define PHR_ISFINITE(x) isfinite(x)
# endif
#elif defined(HAVE_FINITE)
# define PHR_ISFINITE(x) finite(x)

View File

@ -218,10 +218,10 @@ LDBLE Phreeqc::
calc_SC(void)
/* ---------------------------------------------------------------------- */
{
int i;
LDBLE lm, a, l_z, Dw, SC, ff;
//int i;
//LDBLE lm, a, l_z, Dw, SC, ff;
SC = 0;
//SC = 0;
# ifdef SKIP
for (i = 0; i < count_species_list; i++)
{
@ -262,7 +262,7 @@ calc_SC(void)
SC *= viscos_0_25 / viscos;
return (SC);
# endif
//# endif
for (i = 0; i < count_s_x; i++)
{
if (s_x[i]->type != AQ && s_x[i]->type != HPLUS)
@ -294,144 +294,150 @@ calc_SC(void)
SC *= viscos_0_25 / viscos;
return (SC);
#ifdef SKIP
# endif
int i;
LDBLE lm, a, ka, l_z, Dw, SC, ff, sqrt_mu;
boolean DebOns_sc = false;
LDBLE ka, l_z, Dw, ff, sqrt_mu;
sqrt_mu = sqrt(mu_x);
SC = 0;
for (i = 0; i < count_species_list; i++)
LDBLE ta1, ta2, ta3, ta4;
for (i = 0; i < count_s_x; i++)
{
if (species_list[i].s->dw_a || species_list[i].s->dw_a_exp)
// ** for optimizing, get numbers from -analyt for H+ = H+...
if (!strcmp(s_x[i]->name, "H+"))
{
DebOns_sc = true;
ta1 = s_x[i]->logk[2];
ta2 = s_x[i]->logk[3];
ta3 = s_x[i]->logk[4];
ta4 = s_x[i]->logk[5];
break;
}
if (species_list[i].s->type > HPLUS)
//
}
for (i = 0; i < count_s_x; i++)
{
if (s_x[i]->type != AQ && s_x[i]->type != HPLUS)
continue;
if (i > 0
&& strcmp(species_list[i].s->name,
species_list[i - 1].s->name) == 0)
continue;
if (species_list[i].s == s_h2o)
continue;
if ((Dw = species_list[i].s->dw) == 0)
continue;
if ((l_z = fabs(species_list[i].s->z)) == 0)
continue;
lm = species_list[i].s->lm;
if (lm > -9)
if ((Dw = s_x[i]->dw) == 0)
{
ka = DH_B * (species_list[i].s->dha ? species_list[i].s->dha : 4.0);
if (mu_x > 1)
ka *= pow(mu_x, 0.25 / mu_x);
if (correct_Dw)
Dw = default_Dw;
else
ka *= pow(mu_x, 0.25); //sqrt_mu;
ff = pow((int) 10, -l_z * l_z * DH_A * sqrt_mu / (1 + ka));
ff = pow(ff, 0.7 / sqrt(l_z));
//ff = pow(ff, 0.6);
a = species_list[i].s->moles / mass_water_aq_x * ff;
if (species_list[i].s->dw_t)
Dw *= exp(species_list[i].s->dw_t / tk_x - species_list[i].s->dw_t / 298.15); // the viscosity multiplier is done in SC
SC += a * l_z * l_z * Dw;
continue;
}
}
if (!DebOns_sc)
{
SC *= 1e7 * F_C_MOL * F_C_MOL / (R_KJ_DEG_MOL * 298160.0);
SC *= viscos_0_25 / viscos_0;
return (SC);
}
/*Debye-Onsager according to Robinson and Stokes, 1954, JACS 75, 1991,
but with sqrt charge multiplier for B2 and mu^ff dependent ka */
LDBLE q, B1, B2, m_plus, m_min, eq_plus, eq_min, eq_dw_plus, eq_dw_min, z_plus, z_min, t1, t2, t2a, Dw_SC;
m_plus = m_min = eq_plus = eq_min = eq_dw_plus = eq_dw_min = z_plus = z_min = 0;
SC = 0;
for (i = 0; i < count_species_list; i++)
{
if (species_list[i].s->type > HPLUS)
continue;
if (i > 0
&& strcmp(species_list[i].s->name,
species_list[i - 1].s->name) == 0)
continue;
if (species_list[i].s == s_h2o)
continue;
if ((Dw = species_list[i].s->dw) == 0)
continue;
if ((l_z = species_list[i].s->z) == 0)
continue;
if ((lm = species_list[i].s->lm) < -9)
continue;
// ** for optimizing...
if (!strcmp(species_list[i].s->name, "H+"))
t2a = species_list[i].s->Jones_Dole[2];
//
if (species_list[i].s->dw_t)
Dw *= exp(species_list[i].s->dw_t / tk_x - species_list[i].s->dw_t / 298.15); // the viscosity multiplier cancels in q...
if (l_z > 0)
if ((l_z = fabs(s_x[i]->z)) == 0)
l_z = 1; // only a 1st approximation for correct_Dw in electrical field
if (s_x[i]->dw_t)
Dw *= exp(s_x[i]->dw_t / tk_x - s_x[i]->dw_t / 298.15); // the viscosity multiplier is done in SC
if (s_x[i]->dw_a2)
ka = DH_B * s_x[i]->dw_a2 * sqrt_mu / (1 + pow(mu_x, 0.75));
else
{
m_plus += species_list[i].s->moles;
t1 = species_list[i].s->moles * l_z;
eq_plus += t1;
eq_dw_plus += t1 * Dw;
ka = DH_B * 4.73 * sqrt_mu / (1 + pow(mu_x , 0.75));
//ka = DH_B * ta1 * sqrt_mu / (1 + pow(mu_x, ta2));
//ka = DH_B * ta1 * sqrt_mu / (1 + mu_x / ta2);
}
if (s_x[i]->dw_a)
{
ff = exp(-s_x[i]->dw_a * DH_A * l_z * sqrt_mu / (1 + ka));
if (print_viscosity)
{
ff *= pow((viscos_0 / viscos), s_x[i]->dw_a_visc);
}
}
else
{
m_min += species_list[i].s->moles;
t1 = species_list[i].s->moles * l_z;
ff = exp(-1.6 * DH_A * l_z * sqrt_mu / (1 + ka));
//ff = exp(-ta3 * DH_A * l_z * sqrt_mu / (1 + ka));
}
Dw *= ff;
s_x[i]->dw_corr = Dw;
if (s_x[i]->z == 0)
continue;
s_x[i]->dw_t_SC = s_x[i]->moles / mass_water_aq_x * l_z * l_z * Dw;
SC += s_x[i]->dw_t_SC;
}
SC *= 1e7 * F_C_MOL * F_C_MOL / (R_KJ_DEG_MOL * 298150.0);
/* correct for temperature dependency...
SC_T = SC_298 * (Dw_T / T) * (298 / Dw_298) and
Dw_T = Dw_298 * (T / 298) * (viscos_298 / viscos_T) give:
SC_T = SC_298 * (viscos_298 / viscos_T)
*/
SC *= viscos_0_25 / viscos_0;
return (SC);
}
#ifdef SKIP
/*Debye-Onsager according to Robinson and Stokes, 1954, JACS 75, 1991,
but with sqrt charge multiplier for B2 and mu^ff dependent ka */
LDBLE q, B1, B2, m_plus, m_min, eq_plus, eq_min, eq_dw_plus, eq_dw_min, Sum_m_dw, z_plus, z_min, t1, t2, Dw_SC;
m_plus = m_min = eq_plus = eq_min = eq_dw_plus = eq_dw_min = Sum_m_dw = z_plus = z_min = 0;
SC = 0;
for (i = 0; i < count_s_x; i++)
{
if (s_x[i]->type != AQ && s_x[i]->type != HPLUS)
continue;
if ((l_z = s_x[i]->z) == 0)
continue;
if ((lm = s_x[i]->lm) < -9)
continue;
if ((Dw = s_x[i]->dw) == 0)
Dw = 1e-9;
if (s_x[i]->dw_t)
Dw *= exp(s_x[i]->dw_t / tk_x - s_x[i]->dw_t / 298.15); // the viscosity multiplier cancels in q...
if (l_z > 0)
{
m_plus += s_x[i]->moles;
t1 = s_x[i]->moles * l_z;
eq_plus += t1;
eq_dw_plus += t1 * Dw;
Sum_m_dw += s_x[i]->moles * Dw;
}
else
{
m_min += s_x[i]->moles;
t1 = s_x[i]->moles * l_z;
eq_min -= t1;
eq_dw_min -= t1 * Dw;
Sum_m_dw += s_x[i]->moles * Dw;
}
}
// Dw's weighted by eq...
eq_dw_plus /= eq_plus; eq_dw_min /= eq_min;
z_plus = eq_plus / m_plus; // |z1|
z_min = eq_min / m_min; // |z2|
q = z_plus * z_min / (z_plus + z_min) * (eq_dw_plus + eq_dw_min) / (z_min * eq_dw_plus + z_plus * eq_dw_min);
t1 = pow(1.60218e-19, 2) / (6 * pi);
// Falkenhagen, q = (Sum(z1 * m1*Dw1) + Sum(z2 *m2*Dw2)) / ((Sum(m1*Dw1) + Sum(m2*Dw2))(av_z1 + av_z2))
z_plus = eq_plus / m_plus; // |av_z1|
z_min = eq_min / m_min; // |av_z2|
q = (eq_dw_plus + eq_dw_min) / (Sum_m_dw * (z_min + z_plus));
t1 = 1.60218e-19 * 1.60218e-19 / (6 * pi);
B1 = t1 / (2 * 8.8542e-12 * eps_r * 1.38066e-23 * tk_x) *
q / (1 + sqrt(q)) * DH_B * 1e10 * z_plus * z_min; // DH_B is per Angstrom (*1e10)
t2 = 1e3 * calc_solution_volume();
t2 = (1 - t2a) * viscos_0 + t2a * viscos;
t2 = viscos_0; // (1 - 0.5) * viscos_0 + 0.5 * viscos;
B2 = t1 * AVOGADRO / t2 * DH_B * 1e17; // DH_B per Angstrom (*1e10), viscos in mPa.s (*1e3), B2 in cm2 (*1e4)
Dw_SC = viscos_0_25 / t2 * 1e4 * F_C_MOL * F_C_MOL / (R_KJ_DEG_MOL * 298160.0);
for (i = 0; i < count_species_list; i++)
for (i = 0; i < count_s_x; i++)
{
if (species_list[i].s->type > HPLUS)
if (s_x[i]->type != AQ && s_x[i]->type != HPLUS)
continue;
if (i > 0
&& strcmp(species_list[i].s->name,
species_list[i - 1].s->name) == 0)
if ((l_z = fabs(s_x[i]->z)) == 0)
continue;
if (species_list[i].s == s_h2o)
continue;
if ((Dw = species_list[i].s->dw) == 0)
continue;
if ((l_z = fabs(species_list[i].s->z)) == 0)
continue;
if ((lm = species_list[i].s->lm) < -9)
if ((lm = s_x[i]->lm) < -9)
continue;
if ((Dw = s_x[i]->dw) == 0)
Dw = 1e-9;
Dw *= Dw_SC;
if (species_list[i].s->dw_t)
Dw *= exp(species_list[i].s->dw_t / tk_x - species_list[i].s->dw_t / 298.15); // the viscosity factor is in Dw_SC
a = (species_list[i].s->dw_a ? species_list[i].s->dw_a : 3.5);
if (s_x[i]->dw_t)
Dw *= exp(s_x[i]->dw_t / tk_x - s_x[i]->dw_t / 298.15); // the viscosity factor is in Dw_SC
a = (s_x[i]->dw_a ? s_x[i]->dw_a : 3.5);
ka = DH_B * a;
if (species_list[i].s->dw_a_exp)
ka *= pow((double) mu_x, species_list[i].s->dw_a_exp);
if (s_x[i]->dw_a2)
ka *= pow((double) mu_x, s_x[i]->dw_a2);
else
ka *= sqrt_mu;
// Falkenhagen...
/*SC += under(lm) * l_z * l_z * (Dw - B2 * l_z * sqrt_mu / (1 + ka)) * (1 - B1 * sqrt_mu /
((1 + ka) * (1 + ka * sqrt(q) + ka * ka / 6)));*/
//SC += under(lm) * l_z * l_z * (Dw - B2 * l_z * sqrt_mu / (1 + ka)) * (1 - B1 * sqrt_mu /
// ((1 + ka) * (1 + ka * sqrt(q) + ka * ka / 6)));
t1 = (Dw - (B1 * Dw + B2) * sqrt_mu / (1 + ka));
//t1 = (Dw - (B1 * Dw + B2 * sqrt(l_z)) * sqrt_mu / (1 + ka));
@ -441,7 +447,6 @@ calc_SC(void)
}
return (SC * 1e3);
#endif
}
/* VP: Density Start */
/* ---------------------------------------------------------------------- */
@ -1054,6 +1059,28 @@ diff_layer_total(const char *total_name, const char *surface_name)
}
return (0);
}
/* ---------------------------------------------------------------------- */
LDBLE Phreeqc::
calc_t_sc(const char *name)
/* ---------------------------------------------------------------------- */
{
char token[MAX_LENGTH];
struct species *s_ptr;
strcpy(token, name);
s_ptr = s_search(token);
if (s_ptr != NULL)
{
if (!s_ptr->z)
return (0);
calc_SC();
if (!SC)
return (0);
LDBLE t = s_ptr->dw_t_SC * 1e7 * F_C_MOL * F_C_MOL / (R_KJ_DEG_MOL * 298150.0) * viscos_0_25 / viscos_0;
return (t / SC);
}
return (-999.99);
}
/* ---------------------------------------------------------------------- */
LDBLE Phreeqc::

View File

@ -277,7 +277,7 @@ write_banner(void)
/* version */
#ifdef NPP
len = sprintf(buffer, "* PHREEQC-%s *", "3.2.2a AmpŠre");
len = sprintf(buffer, "* PHREEQC-%s *", "3.3.9 AmpŠre");
#else
len = sprintf(buffer, "* PHREEQC-%s *", "@VERSION@");
#endif
@ -301,7 +301,7 @@ write_banner(void)
/* date */
#ifdef NPP
len = sprintf(buffer, "%s", "November 25, 2015");
len = sprintf(buffer, "%s", "November 23, 2016");
#else
len = sprintf(buffer, "%s", "@VER_DATE@");
#endif
@ -331,7 +331,7 @@ process_file_names(int argc, char *argv[], std::istream **db_cookie,
* Prepare error handling
*/
try {
if (phrq_io == NULL)
if (phrq_io == NULL)
{
std::cerr << "No PHRQ_io output handler defined in process_file_names" << "\n";
}
@ -441,7 +441,7 @@ process_file_names(int argc, char *argv[], std::istream **db_cookie,
error_string = sformatf( "Error opening file, %s.", in_file);
error_msg(error_string, STOP);
}
/*
* Open data base
*/
@ -491,10 +491,11 @@ process_file_names(int argc, char *argv[], std::istream **db_cookie,
screen_msg(sformatf("Database file: %s\n\n", token));
strcpy(db_file, token);
#ifdef NPP
output_msg(sformatf("Using PHREEQC: version 3.2.2a Ampère, compiled November 25, 2015\n"));
//output_msg(sformatf("Using PHREEQC: version 3.2.2a Ampère, compiled March 9, 2016\n"));
#endif
output_msg(sformatf(" Input file: %s\n", in_file));
output_msg(sformatf(" Output file: %s\n", out_file));
output_msg(sformatf("Using PHREEQC: version 3.3.9 Ampère, compiled November 23, 2016\n"));
output_msg(sformatf("Database file: %s\n\n", token));
#ifdef NPP
output_flush();
@ -532,7 +533,7 @@ process_file_names(int argc, char *argv[], std::istream **db_cookie,
* Prepare error handling
*/
try {
if (phrq_io == NULL)
if (phrq_io == NULL)
{
std::cerr << "No PHRQ_io output handler defined in process_file_names" << "\n";
}
@ -641,7 +642,7 @@ process_file_names(int argc, char *argv[], std::istream **db_cookie,
error_string = sformatf( "Error opening file, %s.", in_file);
error_msg(error_string, STOP);
}
/*
* Open data base
*/
@ -746,6 +747,7 @@ open_input_stream(char *query, char *default_name, std::ios_base::openmode mode,
{
std::cerr << "Failed defining name." << std::endl;
}
l = (int) strlen(name);
name[l - 1] = '\0';
if (name[0] == '\0')
@ -772,7 +774,7 @@ open_input_stream(char *query, char *default_name, std::ios_base::openmode mode,
#endif
error_flush();
batch = FALSE;
continue;
continue;
}
break;
}
@ -801,7 +803,7 @@ open_output_stream(char *query, char *default_name, std::ios_base::openmode mode
#else
FILE * error_file_save = phrq_io->Get_error_file();
#endif
for (;;)
{
/*
@ -815,7 +817,7 @@ open_output_stream(char *query, char *default_name, std::ios_base::openmode mode
#else
phrq_io->Set_error_file(stderr);
#endif
screen_msg(sformatf("%s\n", query));
if (default_name[0] != '\0')
{
@ -826,6 +828,7 @@ open_output_stream(char *query, char *default_name, std::ios_base::openmode mode
{
std::cerr << "Failed defining name." << std::endl;
}
l = (int) strlen(name);
name[l - 1] = '\0';
if (name[0] == '\0')
@ -848,7 +851,7 @@ open_output_stream(char *query, char *default_name, std::ios_base::openmode mode
screen_msg(error_string);
error_flush();
batch = FALSE;
continue;
continue;
}
break;
}
@ -877,7 +880,7 @@ open_output_file(char *query, char *default_name, std::ios_base::openmode mode,
#else
FILE * error_file_save = phrq_io->Get_error_file();
#endif
for (;;)
{
@ -902,6 +905,7 @@ open_output_file(char *query, char *default_name, std::ios_base::openmode mode,
{
std::cerr << "Failed defining name." << std::endl;
}
l = (int) strlen(name);
name[l - 1] = '\0';
if (name[0] == '\0')
@ -924,7 +928,7 @@ open_output_file(char *query, char *default_name, std::ios_base::openmode mode,
screen_msg(error_string);
error_flush();
batch = FALSE;
continue;
continue;
}
break;
}

View File

@ -132,19 +132,19 @@
#define MAX_LM 3.0 /* maximum log molality allowed in intermediate iterations */
#define MAX_M 1000.0
#ifdef USE_DECIMAL128
//#define MIN_LM -80.0 /* minimum log molality allowed before molality set to zero */
//#define LOG_ZERO_MOLALITY -80 /* molalities <= LOG_ZERO_MOLALITY are considered equal to zero */
//#define MIN_TOTAL 1e-60
//#define MIN_TOTAL_SS MIN_TOTAL/100
//#define MIN_RELATED_SURFACE MIN_TOTAL*100
//#define MIN_RELATED_LOG_ACTIVITY -60
// #define MIN_LM -80.0 /* minimum log molality allowed before molality set to zero */
// #define LOG_ZERO_MOLALITY -80 /* molalities <= LOG_ZERO_MOLALITY are considered equal to zero */
// #define MIN_TOTAL 1e-60
// #define MIN_TOTAL_SS MIN_TOTAL/100
// #define MIN_RELATED_SURFACE MIN_TOTAL*100
// #define MIN_RELATED_LOG_ACTIVITY -60
#else
//#define MIN_LM -30.0 /* minimum log molality allowed before molality set to zero */
//#define LOG_ZERO_MOLALITY -30 /* molalities <= LOG_ZERO_MOLALITY are considered equal to zero */
//#define MIN_TOTAL 1e-25
//#define MIN_TOTAL_SS MIN_TOTAL/100
//#define MIN_RELATED_SURFACE MIN_TOTAL*100
//#define MIN_RELATED_LOG_ACTIVITY -30
// #define MIN_LM -30.0 /* minimum log molality allowed before molality set to zero */
// #define LOG_ZERO_MOLALITY -30 /* molalities <= LOG_ZERO_MOLALITY are considered equal to zero */
// #define MIN_TOTAL 1e-25
// #define MIN_TOTAL_SS MIN_TOTAL/100
// #define MIN_RELATED_SURFACE MIN_TOTAL*100
// #define MIN_RELATED_LOG_ACTIVITY -30
#endif
#define REF_PRES_PASCAL 1.01325E5 /* Reference pressure: 1 atm */
/*
@ -668,8 +668,11 @@ struct species
LDBLE z; /* charge of species */
LDBLE dw; /* tracer diffusion coefficient in water at 25oC, m2/s */
LDBLE dw_t; /* correct Dw for temperature: Dw(TK) = Dw(298.15) * exp(dw_t / TK - dw_t / 298.15) */
LDBLE dw_a; /* ion size parm for calc'ng SC = SC0 - (B1 * SC0 + B2) * kk * dw_a / (1 + kk * dw_a) */
LDBLE dw_a_exp; /* power term for ionic strength correction of dw_a */
LDBLE dw_a; /* parms for calc'ng SC = SC0 * exp(-dw_a * z * mu^0.5 / (1 + DH_B * dw_a2 * mu^0.5)) */
LDBLE dw_a2; /* */
LDBLE dw_a_visc; /* viscosity correction of SC */
LDBLE dw_t_SC; /* contribution to SC, for calc'ng transport number with BASIC */
LDBLE dw_corr; /* dw corrected for TK and mu */
LDBLE erm_ddl; /* enrichment factor in DDL */
LDBLE equiv; /* equivalents in exchange species */
LDBLE alk; /* alkalinity of species, used for cec in exchange */
@ -1046,7 +1049,7 @@ struct sol_D
struct J_ij
{
const char *name;
LDBLE tot1; /* species change in cells i and j */
LDBLE tot1, tot2; /* species change in cells i and j */
};
struct M_S
{

View File

@ -1646,6 +1646,7 @@ set_and_run(int i, int use_mix, int use_kinetics, int nsaver,
converge = model();
}
sum_species();
viscosity();
return (converge);
}

View File

@ -1281,14 +1281,14 @@ pitzer(void)
F = F1 = F2 = -A0 * (DI / (1.0 + B * DI) + 2.0 * log(1.0 + B * DI) / B);
if (patm_x > 1.0)
{
LDBLE pap;
LDBLE pap = 0.0;
pap = (7e-5 + 1.93e-9 * pow(TK - 250.0, 2.0)) * patm_x;
B1 = B - (pap > 0.2 ? 0.2 : pap);
if (TK <= 263)
pap = 0;
else
if (TK > 263.0)
{
pap = (9.65e-10 * pow(TK - 263.0, 2.773)) * pow(patm_x, 0.623);
//pap = (-5.22e-4 + 7.19e-8 * pow(TK - 263.0, 2.0)) * pow(patm_x, 0.623);
}
B2 = B - (pap > 0.2 ? 0.2 : pap);
if (B1 != 0)
F1 = -A0 * (DI / (1.0 + B1 * DI) + 2.0 * log(1.0 + B1 * DI) / B1);
@ -1709,7 +1709,6 @@ set_pz(int initial)
tk_x = tc_x + 273.15;
patm_x = solution_ptr->Get_patm(); // done in calc_rho_0(tc, pa)
potV_x = solution_ptr->Get_potV();
/*
* H+, e-, H2O

View File

@ -4096,10 +4096,11 @@ calc_PR(std::vector<struct phase *> phase_ptrs, LDBLE P, LDBLE TK, LDBLE V_m)
}
}
if (P <= 0) // iterations = -1
P = 1.;
P = 1;
} else
{
if (P < 1e-10) P = 1e-10;
if (P < 1e-10)
P = 1e-10;
r3[1] = b_sum - R_TK / P;
r3_12 = r3[1] * r3[1];
r3[2] = -3.0 * b2 + (a_aa_sum - R_TK * 2.0 * b_sum) / P;
@ -5719,7 +5720,7 @@ k_temp(LDBLE tc, LDBLE pa) /* pa - pressure in atm */
for (i = 0; i < count_s_x; i++)
{
//if (s_x[i]->rxn_x->logk[vm_tc])
/* calculate delta_v for the reaction, assume Vm = 0 if not defined for a species... */
/* calculate delta_v for the reaction... */
s_x[i]->rxn_x->logk[delta_v] = calc_delta_v(s_x[i]->rxn_x, false);
if (tc == current_tc && s_x[i]->rxn_x->logk[delta_v] == 0)
continue;

View File

@ -2108,7 +2108,7 @@ print_totals(void)
* Print total concentrations of elements, molality and moles.
*/
int i, pure_water;
LDBLE EC, dens;
LDBLE dens;
if (pr.totals == FALSE || pr.all == FALSE)
return (OK);
@ -2217,15 +2217,15 @@ print_totals(void)
/*
* Others
*/
EC = calc_SC();
if (EC > 0)
calc_SC();
if (SC > 0)
{
//output_msg(sformatf("%36s%i%7s%i\n",
output_msg(sformatf("%35s%3.0f%7s%i\n",
#ifdef NO_UTF8_ENCODING
"Specific Conductance (uS/cm, ", tc_x, "oC) = ", (int) EC));
"Specific Conductance (uS/cm, ", tc_x, "oC) = ", (int) SC));
#else
"Specific Conductance (µS/cm, ", tc_x, "°C) = ", (int) EC));
"Specific Conductance (µS/cm, ", tc_x, "°C) = ", (int) SC));
#endif
}
/* VP: Density Start */

View File

@ -429,7 +429,6 @@ read_exchange_species(void)
association = TRUE;
s_ptr = NULL;
if (reading_db == 0) definitions_for_parallelizer << line << "\n";
/*
* Read eqn from file and call parser
*/
@ -867,7 +866,6 @@ read_exchange_species(void)
}
if (return_value == EOF || return_value == KEYWORD)
break;
if (reading_db == 0) definitions_for_parallelizer << line << "\n";
}
return (return_value);
}
@ -1155,7 +1153,6 @@ read_exchange_master_species(void)
struct element *elts_ptr;
struct species *s_ptr;
char token[MAX_LENGTH], token1[MAX_LENGTH];
if (reading_db == 0) definitions_for_parallelizer << line << "\n";
for (;;)
{
j = check_line("Exchange species equation", FALSE, TRUE, TRUE, TRUE);
@ -1163,7 +1160,6 @@ read_exchange_master_species(void)
{
break;
}
if (reading_db == 0) definitions_for_parallelizer << line << "\n";
/*
* Get element name with valence, allocate space, store
*/
@ -2889,7 +2885,7 @@ read_aq_species_vm_parms(char *ptr, LDBLE * delta_v)
if (j < 1)
{
input_error++;
error_msg("Expecting numeric values for calculating the species molar volume from the supcrt database.",
error_msg("Expecting numeric values for calculating the species molar volume.",
CONTINUE);
return (ERROR);
}
@ -3186,9 +3182,6 @@ read_viscosity_parms(char *ptr, LDBLE * Jones_Dole)
CONTINUE);
return (ERROR);
}
// The B0 are for 25°C, subtract the temperature factor...
if (Jones_Dole[1] != 0)
Jones_Dole[0] -= Jones_Dole[1] * exp(Jones_Dole[2] * 25.0);
return (OK);
}
@ -3252,7 +3245,6 @@ read_master_species(void)
struct species *s_ptr;
char token[MAX_LENGTH], token1[MAX_LENGTH];
if (reading_db == 0) definitions_for_parallelizer << line << "\n";
elts_ptr = NULL;
for (;;)
{
@ -3261,7 +3253,6 @@ read_master_species(void)
{
break;
}
if (reading_db == 0) definitions_for_parallelizer << line << "\n";
/*
* Get element name with valence, allocate space, store
*/
@ -3840,7 +3831,6 @@ read_phases(void)
"vm" /* 15, molar volume, must replace delta_v */
};
int count_opt_list = 16;
if (reading_db == 0) definitions_for_parallelizer << line << "\n";
association = FALSE;
/*
* Read eqn from file and call parser
@ -4023,7 +4013,6 @@ read_phases(void)
*/
phase_ptr = NULL;
ptr = line;
if (reading_db == 0) definitions_for_parallelizer << line << "\n";
copy_token(token, &ptr, &l);
/*
* Get and parse equation
@ -4112,7 +4101,6 @@ read_phases(void)
}
if (return_value == EOF || return_value == KEYWORD)
break;
if (reading_db == 0) definitions_for_parallelizer << line << "\n";
}
return (return_value);
}
@ -4762,7 +4750,6 @@ read_selected_output(void)
ptr = line;
int n_user, n_user_end;
char *description;
if (reading_db == 0) definitions_for_parallelizer << line << "\n";
read_number_description(ptr, &n_user, &n_user_end, &description);
SelectedOutput temp_selected_output;
@ -4819,7 +4806,6 @@ read_selected_output(void)
temp_selected_output.Set_new_def(true);
}
}
CParser parser(this->phrq_io);
/*
@ -5136,7 +5122,6 @@ read_selected_output(void)
}
if (return_value == EOF || return_value == KEYWORD)
break;
if (reading_db == 0) definitions_for_parallelizer << line << "\n";
}
if (temp_selected_output.Get_new_def() || so == SelectedOutput_map.end())
@ -6028,11 +6013,10 @@ read_species(void)
/* VP: Density Start */
"millero", /* 21 */
/* VP: Density End */
"vm", /* 22, parms for molar volume, a1..a4 and w_ref from supcrt, I terms */
"vm", /* 22, parms for molar volume, a1..a4 and w_ref, I terms */
"viscosity" /* 23, b and d parms for viscosity, (b1 + b2 * exp(-b3 * tc)) * c + (d1 * exp(-d2 * tc)) * c ^ d3 */
};
int count_opt_list = 24;
if (reading_db == 0) definitions_for_parallelizer << line << "\n";
association = TRUE;
s_ptr = NULL;
/*
@ -6338,9 +6322,10 @@ read_species(void)
input_error++;
break;
}
s_ptr->dw_t = s_ptr->dw_a = s_ptr->dw_a_exp = 0;
i = sscanf(next_char, SCANFORMAT SCANFORMAT SCANFORMAT SCANFORMAT, &s_ptr->dw, &s_ptr->dw_t,
&s_ptr->dw_a, &s_ptr->dw_a_exp);
s_ptr->dw_t = 0; s_ptr->dw_a = 0; s_ptr->dw_a2 = 0; s_ptr->dw_a_visc = 0;
i = sscanf(next_char, SCANFORMAT SCANFORMAT SCANFORMAT SCANFORMAT SCANFORMAT, &s_ptr->dw, &s_ptr->dw_t,
&s_ptr->dw_a, &s_ptr->dw_a2, &s_ptr->dw_a_visc);
s_ptr->dw_corr = s_ptr->dw;
opt_save = OPTION_DEFAULT;
break;
case 20: /* enrichment factor in the DDL */
@ -6527,7 +6512,6 @@ read_species(void)
}
if (return_value == EOF || return_value == KEYWORD)
break;
if (reading_db == 0) definitions_for_parallelizer << line << "\n";
}
return (return_value);
}
@ -6794,7 +6778,6 @@ read_surface_species(void)
"vm" /* 18 */
};
int count_opt_list = 19;
if (reading_db == 0) definitions_for_parallelizer << line << "\n";
association = TRUE;
/*
* Read eqn from file and call parser
@ -7173,7 +7156,6 @@ read_surface_species(void)
}
if (return_value == EOF || return_value == KEYWORD)
break;
if (reading_db == 0) definitions_for_parallelizer << line << "\n";
}
return (return_value);
}
@ -7817,7 +7799,6 @@ read_surface_master_species(void)
int count_opt_list = 0;
opt_save = OPTION_DEFAULT;
return_value = UNKNOWN;
if (reading_db == 0) definitions_for_parallelizer << line << "\n";
for (;;)
{
opt = get_option(opt_list, count_opt_list, &next_char);
@ -7908,7 +7889,6 @@ read_surface_master_species(void)
}
if (return_value == EOF || return_value == KEYWORD)
break;
if (reading_db == 0) definitions_for_parallelizer << line << "\n";
}
return (return_value);
}
@ -9254,7 +9234,6 @@ read_rates(void)
"end" /* 1 */
};
int count_opt_list = 2;
if (reading_db == 0) definitions_for_parallelizer << line << "\n";
/*
* Read advection number (not currently used)
*/
@ -9364,7 +9343,6 @@ read_rates(void)
}
if (return_value == EOF || return_value == KEYWORD)
break;
if (reading_db == 0) definitions_for_parallelizer << line << "\n";
}
/* output_msg(sformatf( "%s", rates[0].commands));
*/
@ -9398,7 +9376,6 @@ read_user_print(void)
"end" /* 1 */
};
int count_opt_list = 2;
if (reading_db == 0) definitions_for_parallelizer << line << "\n";
opt_save = OPTION_DEFAULT;
/*
* Read lines
@ -9460,7 +9437,6 @@ read_user_print(void)
}
if (return_value == EOF || return_value == KEYWORD)
break;
if (reading_db == 0) definitions_for_parallelizer << line << "\n";
}
/* output_msg(sformatf( "%s", rates[0].commands));
*/ return (return_value);
@ -9494,7 +9470,6 @@ read_user_punch(void)
"headings" /* 3 */
};
int count_opt_list = 4;
if (reading_db == 0) definitions_for_parallelizer << line << "\n";
opt_save = OPTION_DEFAULT;
/*
* Read lines
@ -9612,7 +9587,6 @@ read_user_punch(void)
}
if (return_value == EOF || return_value == KEYWORD)
break;
if (reading_db == 0) definitions_for_parallelizer << line << "\n";
}
UserPunch_map.erase(n_user);
UserPunch_map[n_user] = temp_user_punch;
@ -9775,7 +9749,6 @@ read_user_graph(void)
};
int count_opt_list = 14;
int i;
if (reading_db == 0) definitions_for_parallelizer << line << "\n";
opt_save = OPTION_DEFAULT;
/*
* Read lines
@ -9981,7 +9954,6 @@ read_user_graph(void)
if (return_value == EOF || return_value == KEYWORD)
break;
if (reading_db == 0) definitions_for_parallelizer << line << "\n";
}
#ifdef PHREEQ98
for (i = 0; i < user_graph_count_headings; i++)
@ -10937,7 +10909,6 @@ read_named_logk(void)
};
int count_opt_list = 11;
logk_ptr = NULL;
if (reading_db == 0) definitions_for_parallelizer << line << "\n";
/*
* Read name followed by options
*/
@ -11130,7 +11101,6 @@ read_named_logk(void)
}
if (return_value == EOF || return_value == KEYWORD)
break;
if (reading_db == 0) definitions_for_parallelizer << line << "\n";
}
return (return_value);
}

View File

@ -822,9 +822,9 @@ read_transport(void)
"No porosities were read; used the value %8.2e from -multi_D.", multi_Dpor);
else
error_string = sformatf(
"No porosities were read; used the minimal value %8.2e from -multi_D.", multi_Dpor);
"No porosities were read; used the value %8.2e from -multi_D.", multi_Dpor);
warning_msg(error_string);
for (i = old_cells + 1; i < all_cells; i++)
for (i = 1; i < all_cells; i++)
cell_data[i].por = multi_Dpor;
}
}

View File

@ -2073,7 +2073,7 @@ s_init(struct species *s_ptr)
s_ptr->dw = 0.0;
s_ptr->dw_t = 0.0;
s_ptr->dw_a = 0.0;
s_ptr->dw_a_exp = 0.0;
s_ptr->dw_a2 = 0.0;
s_ptr->erm_ddl = 1.0;
s_ptr->equiv = 0;
s_ptr->alk = 0.0;

File diff suppressed because it is too large Load Diff