Skip to content

Commit

Permalink
Squashed 'src/' changes from 87919a00..7284fed5
Browse files Browse the repository at this point in the history
7284fed5 Fixed alignment for some of the utf-8
7babc4b4 Changed sprintf to snprintf
0d902855 Changed encoding to utf-8
3e00b232 Merge pull request #45 from dlparkhurst/viscosity
4aa80348 merged master into viscosity
166aec19 Tony tweak of t3 in transport.cpp
6a4443d0 used density_x. Added xsoln_visc test case
4ad0613f removed viscos_x and density_x
269d107f Tony's changes Mar 15, 2024
f50111a5 Tony's changes with added test cases. All test cases run

git-subtree-dir: src
git-subtree-split: 7284fed50f48610d24dc565cb530f6444940b4a3
  • Loading branch information
Darth Vader committed Apr 17, 2024
1 parent a48f347 commit 9569f07
Show file tree
Hide file tree
Showing 23 changed files with 1,145 additions and 790 deletions.
6 changes: 2 additions & 4 deletions Phreeqc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,6 @@ void Phreeqc::init(void)
solution_pe_x = 0;
mu_x = 0;
ah2o_x = 1.0;
density_x = 0;
total_h_x = 0;
total_o_x = 0;
cb_x = 0;
Expand Down Expand Up @@ -898,6 +897,7 @@ void Phreeqc::init(void)
viscos = 0.0;
viscos_0 = 0.0;
viscos_0_25 = 0.0;
density_x = 0.0;
rho_0 = 0.0;
kappa_0 = 0.0;
p_sat = 0.0;
Expand Down Expand Up @@ -1714,6 +1714,7 @@ Phreeqc::InternalCopy(const Phreeqc* pSrc)
viscos = pSrc->viscos;
viscos_0 = pSrc->viscos_0;
viscos_0_25 = pSrc->viscos_0_25; // viscosity of the solution, of pure water, of pure water at 25 C
density_x = pSrc->density_x;
cell_pore_volume = pSrc->cell_pore_volume;;
cell_porosity = pSrc->cell_porosity;
cell_volume = pSrc->cell_volume;
Expand All @@ -1722,9 +1723,6 @@ Phreeqc::InternalCopy(const Phreeqc* pSrc)
sys_tot = pSrc->sys_tot;
// solution properties
V_solutes = pSrc->V_solutes;
viscos = pSrc->viscos;
viscos_0 = pSrc->viscos_0;
viscos_0_25 = pSrc->viscos_0_25;
rho_0 = pSrc->rho_0;
kappa_0 = pSrc->kappa_0;
p_sat = pSrc->p_sat;
Expand Down
7 changes: 4 additions & 3 deletions Phreeqc.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ class Phreeqc
int sum_diffuse_layer(cxxSurfaceCharge* surface_charge_ptr1);
int calc_all_donnan(void);
int calc_init_donnan(void);
LDBLE calc_psi_avg(cxxSurfaceCharge * charge_ptr, LDBLE surf_chrg_eq, LDBLE nDbl, std::vector<LDBLE> &zcorr);
LDBLE calc_psi_avg(cxxSurfaceCharge * charge_ptr, LDBLE surf_chrg_eq, LDBLE nDbl, LDBLE f_free, std::vector<LDBLE> &zcorr);
LDBLE g_function(LDBLE x_value);
LDBLE midpnt(LDBLE x1, LDBLE x2, int n);
void polint(LDBLE* xa, LDBLE* ya, int n, LDBLE xv, LDBLE* yv,
Expand Down Expand Up @@ -555,6 +555,7 @@ class Phreeqc
LDBLE calc_PR(std::vector<class phase*> phase_ptrs, LDBLE P, LDBLE TK, LDBLE V_m);
LDBLE calc_PR();
int calc_vm(LDBLE tc, LDBLE pa);
LDBLE calc_vm0(const char *species_name, LDBLE tc, LDBLE pa, LDBLE mu);
int clear(void);
int convert_units(cxxSolution* solution_ptr);
class unknown* find_surface_charge_unknown(std::string& str_ptr, int plane);
Expand Down Expand Up @@ -995,7 +996,7 @@ class Phreeqc
LDBLE new_Dw);
int reformat_surf(const char* comp_name, LDBLE fraction, const char* new_comp_name,
LDBLE new_Dw, int cell);
LDBLE viscosity(void);
LDBLE viscosity(cxxSurface *surf_ptr);
LDBLE calc_f_visc(const char *name);
LDBLE calc_vm_Cl(void);
int multi_D(LDBLE DDt, int mobile_cell, int stagnant);
Expand Down Expand Up @@ -1274,7 +1275,6 @@ class Phreeqc
LDBLE solution_pe_x;
LDBLE mu_x;
LDBLE ah2o_x;
LDBLE density_x;
LDBLE total_h_x;
LDBLE total_o_x;
LDBLE cb_x;
Expand Down Expand Up @@ -1614,6 +1614,7 @@ class Phreeqc

int print_viscosity;
LDBLE viscos, viscos_0, viscos_0_25; // viscosity of the solution, of pure water, of pure water at 25 C
LDBLE density_x;
LDBLE cell_pore_volume;
LDBLE cell_porosity;
LDBLE cell_volume;
Expand Down
2 changes: 1 addition & 1 deletion Solution.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ cxxSolution::operator =(const cxxSolution &rhs)
this->total_h = rhs.total_h;
this->total_o = rhs.total_o;
this->density = rhs.density;
this->viscosity = rhs.viscosity;
this->viscosity = rhs.viscosity;
this->cb = rhs.cb;
this->mass_water = rhs.mass_water;
this->soln_vol = rhs.soln_vol;
Expand Down
4 changes: 2 additions & 2 deletions Solution.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class cxxSolution:public cxxNumKeyword
void Set_cb(LDBLE l_cb) {this->cb = l_cb;}
LDBLE Get_density() const {return this->density;}
void Set_density(LDBLE l_density) {this->density = l_density;}
LDBLE Get_viscosity() const { return this->viscosity; }
void Set_viscosity(LDBLE l_viscos) { this->viscosity = l_viscos; }
LDBLE Get_viscosity() const { return this->viscosity; }
void Set_viscosity(LDBLE l_viscos) { this->viscosity = l_viscos; }
LDBLE Get_mass_water() const {return this->mass_water;}
void Set_mass_water(LDBLE l_mass_water) {this->mass_water = l_mass_water;}
LDBLE Get_total_alkalinity() const {return this->total_alkalinity;}
Expand Down
34 changes: 18 additions & 16 deletions Surface.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ cxxSurface::cxxSurface(PHRQ_io *io)
dl_type = NO_DL;
sites_units = SITES_ABSOLUTE;
only_counter_ions = false;
correct_GC = false;
correct_D = false;
thickness = 1e-8;
debye_lengths = 0.0;
calc_DDL_viscosity = false;
DDL_viscosity = 1.0;
DDL_limit = 0.8;
transport = false;
Expand All @@ -56,9 +57,10 @@ cxxNumKeyword(io)
dl_type = NO_DL;
sites_units = SITES_ABSOLUTE;
only_counter_ions = false;
correct_GC = false;
correct_D = false;
thickness = 1e-8;
debye_lengths = 0.0;
calc_DDL_viscosity = false;
DDL_viscosity = 1.0;
DDL_limit = 0.8;
transport = false;
Expand Down Expand Up @@ -130,7 +132,7 @@ cxxSurface::dump_raw(std::ostream & s_oss, unsigned int indent, int *n_out) cons
s_oss << indent1;
s_oss << "-only_counter_ions " << this->only_counter_ions << "\n";
s_oss << indent1;
s_oss << "-correct_GC " << this->correct_GC << "\n";
s_oss << "-correct_D " << this->correct_D << "\n";
s_oss << indent1;
s_oss << "-thickness " << this->thickness << "\n";
s_oss << indent1;
Expand Down Expand Up @@ -193,7 +195,7 @@ cxxSurface::read_raw(CParser & parser, bool check)
this->Set_tidied(true);

bool only_counter_ions_defined(false);
//bool correct_GC_defined(false);
//bool correct_D_defined(false);
bool thickness_defined(false);
bool type_defined(false);
bool dl_type_defined(false);
Expand Down Expand Up @@ -395,7 +397,7 @@ cxxSurface::read_raw(CParser & parser, bool check)
case 11: // DDL_viscosity
if (!(parser.get_iss() >> this->DDL_viscosity))
{
this->DDL_viscosity = 0.0;
this->DDL_viscosity = 1.0;
parser.incr_input_error();
parser.error_msg("Expected numeric value for DDL_viscosity.",
PHRQ_io::OT_CONTINUE);
Expand Down Expand Up @@ -473,16 +475,16 @@ cxxSurface::read_raw(CParser & parser, bool check)
PHRQ_io::OT_CONTINUE);
}
break;
case 19: // correct_GC
if (!(parser.get_iss() >> this->correct_GC))
case 19: // correct_D
if (!(parser.get_iss() >> this->correct_D))
{
this->correct_GC = false;
this->correct_D = false;
parser.incr_input_error();
parser.
error_msg("Expected boolean value for correct_GC.",
error_msg("Expected boolean value for correct_D.",
PHRQ_io::OT_CONTINUE);
}
//correct_GC_defined = true;
//correct_D_defined = true;
break;
}
if (opt == CParser::OPT_EOF || opt == CParser::OPT_KEYWORD)
Expand All @@ -498,11 +500,11 @@ cxxSurface::read_raw(CParser & parser, bool check)
error_msg("Only_counter_ions not defined for SURFACE_RAW input.",
PHRQ_io::OT_CONTINUE);
}
//if (correct_GC_defined == false)
//if (correct_D_defined == false)
//{
// parser.incr_input_error();
// parser.
// error_msg("correct_GC not defined for SURFACE_RAW input.",
// error_msg("correct_D not defined for SURFACE_RAW input.",
// PHRQ_io::OT_CONTINUE);
//}
if (thickness_defined == false)
Expand Down Expand Up @@ -582,7 +584,7 @@ cxxSurface::add(const cxxSurface & addee_in, LDBLE extensive)
if (this->surface_comps.size() == 0)
{
this->only_counter_ions = addee.only_counter_ions;
this->correct_GC = addee.correct_GC;
this->correct_D = addee.correct_D;
this->dl_type = addee.dl_type;
this->type = addee.type;
this->sites_units = addee.sites_units;
Expand Down Expand Up @@ -754,7 +756,7 @@ cxxSurface::Serialize(Dictionary & dictionary, std::vector < int >&ints,
doubles.push_back(this->debye_lengths);
doubles.push_back(this->DDL_viscosity);
doubles.push_back(this->DDL_limit);
ints.push_back(this->correct_GC ? 1 : 0);
ints.push_back(this->correct_D ? 1 : 0);
ints.push_back(this->transport ? 1 : 0);
this->totals.Serialize(dictionary, ints, doubles);
ints.push_back(this->solution_equilibria ? 1 : 0);
Expand Down Expand Up @@ -801,7 +803,7 @@ cxxSurface::Deserialize(Dictionary & dictionary, std::vector < int >&ints,
this->debye_lengths = doubles[dd++];
this->DDL_viscosity = doubles[dd++];
this->DDL_limit = doubles[dd++];
this->correct_GC = (ints[ii++] != 0);
this->correct_D = (ints[ii++] != 0);
this->transport = (ints[ii++] != 0);
this->totals.Deserialize(dictionary, ints, doubles, ii, dd);
this->solution_equilibria = (ints[ii++] != 0);
Expand Down Expand Up @@ -830,6 +832,6 @@ const std::vector< std::string >::value_type temp_vopts[] = {
std::vector< std::string >::value_type("n_solution"), // 16
std::vector< std::string >::value_type("totals"), // 17
std::vector< std::string >::value_type("tidied"), // 18
std::vector< std::string >::value_type("correct_gc") // 19
std::vector< std::string >::value_type("correct_d") // 19
};
const std::vector< std::string > cxxSurface::vopts(temp_vopts, temp_vopts + sizeof temp_vopts / sizeof temp_vopts[0]);
9 changes: 6 additions & 3 deletions Surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ class cxxSurface:public cxxNumKeyword
void Set_debye_lengths(LDBLE t) {debye_lengths = t;}
LDBLE Get_DDL_viscosity(void) const {return DDL_viscosity;}
void Set_DDL_viscosity(LDBLE t) {DDL_viscosity = t;}
void Calc_DDL_viscosity(bool tf) {calc_DDL_viscosity = tf;}
bool Get_calc_viscosity(void) const { return calc_DDL_viscosity; }
LDBLE Get_DDL_limit(void) const {return DDL_limit;}
void Set_DDL_limit(LDBLE t) {DDL_limit = t;}
bool Get_correct_GC(void) const { return correct_GC; }
void Set_correct_GC(bool tf) { correct_GC = tf; }
bool Get_correct_D(void) const { return correct_D; }
void Set_correct_D(bool tf) { correct_D = tf; }
std::vector<LDBLE> Donnan_factors;
bool Get_transport(void) const {return transport;}
void Set_transport(bool tf) {transport = tf;}
Expand All @@ -93,8 +95,9 @@ class cxxSurface:public cxxNumKeyword
LDBLE thickness;
LDBLE debye_lengths;
LDBLE DDL_viscosity;
bool calc_DDL_viscosity;
LDBLE DDL_limit;
bool correct_GC;
bool correct_D;
bool transport;
cxxNameDouble totals;
bool solution_equilibria;
Expand Down
45 changes: 38 additions & 7 deletions SurfaceCharge.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ PHRQ_base(io)
grams = 0.0;
charge_balance = 0.0;
mass_water = 0.0;
DDL_viscosity = 0.0;
f_free = 0.0;
la_psi = 0.0;
capacitance[0] = 1.0;
capacitance[1] = 5.0;
Expand Down Expand Up @@ -68,6 +70,7 @@ cxxSurfaceCharge::dump_xml(std::ostream & s_oss, unsigned int indent) const
charge_balance << "\"" << "\n";
s_oss << indent0 << "mass_water=\"" << this->
mass_water << "\"" << "\n";
s_oss << indent0 << "f_free=\"" << this->f_free << "\"" << "\n";
s_oss << indent0 << "la_psi=\"" << this->la_psi << "\"" << "\n";
s_oss << indent0 << "capacitance=\"" << this->
capacitance[0] << " " << this->capacitance[0] << "\"" << "\n";
Expand Down Expand Up @@ -98,6 +101,8 @@ cxxSurfaceCharge::dump_raw(std::ostream & s_oss, unsigned int indent) const
s_oss << indent0 << "-grams " << this->grams << "\n";
s_oss << indent0 << "-charge_balance " << this->charge_balance << "\n";
s_oss << indent0 << "-mass_water " << this->mass_water << "\n";
s_oss << indent0 << "-f_free " << this->f_free << "\n";
s_oss << indent0 << "-ddl_viscosity " << this->DDL_viscosity << "\n";
s_oss << indent0 << "-la_psi " << this->la_psi << "\n";
s_oss << indent0 << "-capacitance0 " << this->capacitance[0] << "\n";
s_oss << indent0 << "-capacitance1 " << this->capacitance[1] << "\n";
Expand Down Expand Up @@ -155,6 +160,7 @@ cxxSurfaceCharge::read_raw(CParser & parser, bool check)
bool capacitance0_defined(false);
bool capacitance1_defined(false);
bool g_map_first(true);
bool DDL_viscosity_defined(false);

for (;;)
{
Expand Down Expand Up @@ -225,7 +231,6 @@ cxxSurfaceCharge::read_raw(CParser & parser, bool check)
mass_water_defined = true;
break;


case 5: // la_psi
if (!(parser.get_iss() >> this->la_psi))
{
Expand Down Expand Up @@ -366,10 +371,27 @@ cxxSurfaceCharge::read_raw(CParser & parser, bool check)
}
}
opt_save = 16;



break;
case 17: // f_free of water
if (!(parser.get_iss() >> this->f_free))
{
this->f_free = 0;
parser.incr_input_error();
parser.error_msg("Expected numeric value for f_free of mass_water.",
PHRQ_io::OT_CONTINUE);
}
break;
case 18: // DDL_viscosity
if (!(parser.get_iss() >> this->DDL_viscosity))
{
this->DDL_viscosity = 1.0;
parser.incr_input_error();
parser.error_msg("Expected numeric value for DDL_viscosity.",
PHRQ_io::OT_CONTINUE);
}
DDL_viscosity_defined = true;
break;

}
if (opt == CParser::OPT_EOF || opt == CParser::OPT_KEYWORD)
break;
Expand Down Expand Up @@ -454,9 +476,11 @@ cxxSurfaceCharge::add(const cxxSurfaceCharge & addee, LDBLE extensive)
this->mass_water += addee.mass_water * extensive;
this->la_psi = this->la_psi * f1 + addee.la_psi * f2;
this->capacitance[0] =
this->capacitance[0] * f1 + this->capacitance[0] * f2;
this->capacitance[0] * f1 + addee.capacitance[0] * f2;
this->capacitance[1] =
this->capacitance[1] * f1 + this->capacitance[1] * f2;
this->capacitance[1] * f1 + addee.capacitance[1] * f2;
this->f_free = this->f_free * f1 + addee.f_free * f2;
this->DDL_viscosity = this->DDL_viscosity * f1 + addee.DDL_viscosity * f2;
this->diffuse_layer_totals.add_extensive(addee.diffuse_layer_totals, extensive);
}

Expand Down Expand Up @@ -486,6 +510,8 @@ cxxSurfaceCharge::Serialize(Dictionary & dictionary, std::vector < int >&ints,
doubles.push_back(this->sigma1);
doubles.push_back(this->sigma2);
doubles.push_back(this->sigmaddl);
doubles.push_back(this->f_free);
doubles.push_back(this->DDL_viscosity);
ints.push_back((int) this->g_map.size());
{
std::map<LDBLE, cxxSurfDL>::iterator it;
Expand Down Expand Up @@ -523,6 +549,8 @@ cxxSurfaceCharge::Deserialize(Dictionary & dictionary, std::vector < int >&ints,
this->sigma1 = doubles[dd++];
this->sigma2 = doubles[dd++];
this->sigmaddl = doubles[dd++];
this->f_free = doubles[dd++];
this->DDL_viscosity = doubles[dd++];
{
this->g_map.clear();
int count = ints[ii++];
Expand Down Expand Up @@ -581,6 +609,9 @@ const std::vector< std::string >::value_type temp_vopts[] = {
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("diffuse_layer_species") // 16
std::vector< std::string >::value_type("diffuse_layer_species"),// 16
std::vector< std::string >::value_type("f_free"), // 17
std::vector< std::string >::value_type("ddl_viscosity") // 18

};
const std::vector< std::string > cxxSurfaceCharge::vopts(temp_vopts, temp_vopts + sizeof temp_vopts / sizeof temp_vopts[0]);
6 changes: 6 additions & 0 deletions SurfaceCharge.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ class cxxSurfaceCharge: public PHRQ_base
void Set_charge_balance(LDBLE d) {this->charge_balance = d;}
LDBLE Get_mass_water() const {return this->mass_water;}
void Set_mass_water(LDBLE d) {this->mass_water = d;}
LDBLE Get_DDL_viscosity(void) const { return DDL_viscosity; }
void Set_DDL_viscosity(LDBLE t) { DDL_viscosity = t; }
LDBLE Get_f_free() const {return this->f_free;}
void Set_f_free(LDBLE d) {this->f_free = d;}
LDBLE Get_la_psi() const {return this->la_psi;}
void Set_la_psi(LDBLE d) {this->la_psi = d;}
LDBLE Get_capacitance0() const {return this->capacitance[0];}
Expand Down Expand Up @@ -117,6 +121,8 @@ class cxxSurfaceCharge: public PHRQ_base
LDBLE grams;
LDBLE charge_balance;
LDBLE mass_water;
LDBLE DDL_viscosity;
LDBLE f_free;
LDBLE la_psi;
LDBLE capacitance[2];
cxxNameDouble diffuse_layer_totals;
Expand Down
Loading

0 comments on commit 9569f07

Please # to comment.