Skip to content

Commit

Permalink
Squashed 'src/' changes from 3d5242f5..e2f4d060
Browse files Browse the repository at this point in the history
e2f4d060 updated InternalCopy
d8abe83e Fixed problem with N vs NO3, for example, converting units with calculated density. Now gives same result for N or NO3.

git-subtree-dir: src
git-subtree-split: e2f4d060cd01b0b9912f0da7aa6c7cc20f77a9c5
  • Loading branch information
Darth Vader committed May 29, 2024
1 parent 57ba149 commit 99f3aa2
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
5 changes: 4 additions & 1 deletion Phreeqc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1722,7 +1722,10 @@ Phreeqc::InternalCopy(const Phreeqc* pSrc)
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;;
solution_volume_x = pSrc->solution_volume_x;
solution_mass_x = pSrc->solution_mass_x;
kgw_kgs = pSrc->kgw_kgs;
cell_pore_volume = pSrc->cell_pore_volume;
cell_porosity = pSrc->cell_porosity;
cell_volume = pSrc->cell_volume;
cell_saturation = pSrc->cell_saturation;
Expand Down
3 changes: 3 additions & 0 deletions Phreeqc.h
Original file line number Diff line number Diff line change
Expand Up @@ -1523,6 +1523,7 @@ class Phreeqc
int iterations;
int gamma_iterations;
size_t density_iterations;
LDBLE kgw_kgs;
int run_reactions_iterations;
int overall_iterations;

Expand Down Expand Up @@ -1629,6 +1630,8 @@ 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 solution_volume_x;
LDBLE solution_mass_x;
LDBLE cell_pore_volume;
LDBLE cell_porosity;
LDBLE cell_volume;
Expand Down
21 changes: 18 additions & 3 deletions basicsubs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,8 @@ calc_dens(void)
{
density_x = rho_0 * (1e3 + M_T / mass_water_aq_x) / (rho_0 * V_solutes / mass_water_aq_x + 1e3);
}
solution_mass_x = 1e-3*(M_T + s_h2o->moles * s_h2o->gfw);
solution_volume_x = solution_mass_x / density_x;
return density_x;
//M_T /= 1e3;
//solution_mass = mass_water_aq_x + M_T;
Expand All @@ -604,7 +606,7 @@ calc_dens(void)
}
/* VP: Density End */
/* DP: Function for interval halving */

#ifdef NOT_USED
LDBLE Phreeqc::
f_rho(LDBLE rho_old, void* cookie)
/* ---------------------------------------------------------------------- */
Expand All @@ -622,7 +624,8 @@ f_rho(LDBLE rho_old, void* cookie)
rho = rho + pThis->rho_0;
return (rho - rho_old);
}

#endif
#ifdef original
/* ---------------------------------------------------------------------- */
LDBLE Phreeqc::
calc_solution_volume(void)
Expand Down Expand Up @@ -653,7 +656,19 @@ calc_solution_volume(void)
LDBLE vol = 1e-3 * total_mass / rho;
return (vol);
}

#endif
/* ---------------------------------------------------------------------- */
LDBLE Phreeqc::
calc_solution_volume(void)
/* ---------------------------------------------------------------------- */
{
/*
* Calculates solution volume based on sum of mass of element plus density
*/
LDBLE rho = calc_dens();
LDBLE vol = solution_volume_x;
return (vol);
}
/* ---------------------------------------------------------------------- */
LDBLE Phreeqc::
calc_logk_n(const char* name)
Expand Down
2 changes: 2 additions & 0 deletions mainsubs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,8 @@ initial_solutions(int print)
set(TRUE);
converge = model();
}
calc_dens();
kgw_kgs = mass_water_aq_x / solution_mass_x;
density_iterations++;
if (solution_ref.Get_initial_data()->Get_calc_density())
{
Expand Down
4 changes: 4 additions & 0 deletions prep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1942,6 +1942,10 @@ convert_units(cxxSolution *solution_ptr)
strstr(initial_data_ptr->Get_units().c_str(), "/l") != NULL)
{
mass_water_aq_x = 1.0 - 1e-3 * sum_solutes;
if (density_iterations > 0)
{
mass_water_aq_x = kgw_kgs;
}
if (mass_water_aq_x <= 0)
{
error_string = sformatf( "Solute mass exceeds solution mass in conversion from /kgs to /kgw.\n"
Expand Down

0 comments on commit 99f3aa2

Please # to comment.