mirror of
https://git.gfz-potsdam.de/naaice/iphreeqc.git
synced 2025-12-16 16:44:49 +01:00
Tony's latest changes.
New test case SC_Ohm, added to Makefile. git-svn-id: svn://136.177.114.72/svn_GW/phreeqc3/branches/concrete@10983 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
parent
d5e7aa0ab3
commit
d2dba8c291
@ -1408,6 +1408,7 @@ protected:
|
||||
int multi_Dflag; /* signals calc'n of multicomponent diffusion */
|
||||
int interlayer_Dflag; /* multicomponent diffusion and diffusion through interlayer porosity */
|
||||
LDBLE default_Dw; /* default species diffusion coefficient in water at 25oC, m2/s */
|
||||
int correct_Dw; /* if true, Dw is adapted in calc_SC */
|
||||
LDBLE multi_Dpor; /* uniform porosity of free porewater in solid medium */
|
||||
LDBLE interlayer_Dpor; /* uniform porosity of interlayer space of montmorillonite in solid medium */
|
||||
LDBLE multi_Dpor_lim; /* limiting free porewater porosity where transport stops */
|
||||
|
||||
105
readtr.cpp
105
readtr.cpp
@ -21,7 +21,7 @@ int Phreeqc::
|
||||
read_transport(void)
|
||||
/* ---------------------------------------------------------------------- */
|
||||
{
|
||||
/*
|
||||
/*
|
||||
* Reads advection and column information
|
||||
*
|
||||
* Arguments:
|
||||
@ -96,7 +96,7 @@ read_transport(void)
|
||||
int count_opt_list = 44;
|
||||
|
||||
strcpy(file_name, "phreeqc.dmp");
|
||||
/*
|
||||
/*
|
||||
* Initialize
|
||||
*/
|
||||
simul_tr++;
|
||||
@ -111,7 +111,7 @@ read_transport(void)
|
||||
old_cells = count_cells;
|
||||
count_length = count_disp = count_punch = count_print = count_por = 0;
|
||||
|
||||
length = (LDBLE *) PHRQ_malloc(sizeof(LDBLE));
|
||||
length = (LDBLE *)PHRQ_malloc(sizeof(LDBLE));
|
||||
if (length == NULL)
|
||||
malloc_error();
|
||||
|
||||
@ -127,23 +127,23 @@ read_transport(void)
|
||||
if (punch_temp == NULL)
|
||||
malloc_error();
|
||||
|
||||
print_temp = (int *) PHRQ_malloc(sizeof(int));
|
||||
print_temp = (int *)PHRQ_malloc(sizeof(int));
|
||||
if (print_temp == NULL)
|
||||
malloc_error();
|
||||
|
||||
count_length_alloc = count_disp_alloc = count_por_alloc = 1;
|
||||
transport_start = 1;
|
||||
/*
|
||||
/*
|
||||
* Read transport number (not currently used)
|
||||
*/
|
||||
ptr = line;
|
||||
read_number_description(ptr, &n_user, &n_user_end, &description);
|
||||
description = (char *) free_check_null(description);
|
||||
/*
|
||||
description = (char *)free_check_null(description);
|
||||
/*
|
||||
* Set use data to last read
|
||||
*/
|
||||
use.Set_trans_in(true);
|
||||
/*
|
||||
/*
|
||||
* Read lines
|
||||
*/
|
||||
opt_save = OPTION_DEFAULT;
|
||||
@ -519,6 +519,7 @@ read_transport(void)
|
||||
multi_Dpor = 0.3;
|
||||
multi_Dpor_lim = 0.0;
|
||||
multi_Dn = 1.0;
|
||||
correct_Dw = 0;
|
||||
if (copy_token(token, &next_char, &l) == EMPTY)
|
||||
break;
|
||||
else
|
||||
@ -574,6 +575,23 @@ read_transport(void)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (copy_token(token, &next_char, &l) == EMPTY)
|
||||
break;
|
||||
else
|
||||
{
|
||||
str_tolower(token);
|
||||
if (strstr(token, "f") == token)
|
||||
correct_Dw = 0;
|
||||
else if (strstr(token, "t") == token)
|
||||
correct_Dw = 1;
|
||||
else
|
||||
{
|
||||
input_error++;
|
||||
error_msg
|
||||
("Expected 'true' or 'false' for correcting Dw's as in Specific Conductance.",
|
||||
CONTINUE);
|
||||
}
|
||||
}
|
||||
opt_save = OPTION_DEFAULT;
|
||||
break;
|
||||
case 41: /* interlayer diffusion */
|
||||
@ -601,7 +619,7 @@ read_transport(void)
|
||||
if (sscanf(token, SCANFORMAT, &interlayer_Dpor) != 1)
|
||||
{
|
||||
input_error++;
|
||||
error_string = sformatf( "Expected interlayer porosity.");
|
||||
error_string = sformatf("Expected interlayer porosity.");
|
||||
error_msg(error_string, CONTINUE);
|
||||
break;
|
||||
}
|
||||
@ -651,7 +669,7 @@ read_transport(void)
|
||||
if (return_value == EOF || return_value == KEYWORD)
|
||||
break;
|
||||
}
|
||||
/*
|
||||
/*
|
||||
* Determine number of cells
|
||||
*/
|
||||
max_cells = count_cells;
|
||||
@ -685,7 +703,7 @@ read_transport(void)
|
||||
// warning_msg(token);
|
||||
//}
|
||||
}
|
||||
/*
|
||||
/*
|
||||
* Allocate space for cell_data
|
||||
*/
|
||||
int all_cells_now = max_cells * (1 + stag_data->count_stag) + 2;
|
||||
@ -710,7 +728,7 @@ read_transport(void)
|
||||
all_cells = all_cells_now;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Fill in data for lengths
|
||||
*/
|
||||
if (count_length == 0)
|
||||
@ -749,7 +767,7 @@ read_transport(void)
|
||||
}
|
||||
cell_data[max_cells + 1].mid_cell_x =
|
||||
cell_data[max_cells].mid_cell_x + cell_data[max_cells].length / 2;
|
||||
/*
|
||||
/*
|
||||
* Fill in data for dispersivities
|
||||
*/
|
||||
if (count_disp == 0)
|
||||
@ -777,7 +795,7 @@ read_transport(void)
|
||||
cell_data[i + 1].disp = disp[count_disp - 1];
|
||||
}
|
||||
}
|
||||
/*
|
||||
/*
|
||||
* Fill in data for porosities
|
||||
*/
|
||||
if (count_por == 0)
|
||||
@ -793,7 +811,6 @@ read_transport(void)
|
||||
"No porosities were read; used the minimal value %8.2e from -multi_D.", multi_Dpor);
|
||||
warning_msg(error_string);
|
||||
for (i = old_cells + 1; i < all_cells; i++)
|
||||
//for (i = old_cells; i < all_cells; i++)
|
||||
cell_data[i].por = multi_Dpor;
|
||||
}
|
||||
}
|
||||
@ -838,7 +855,7 @@ read_transport(void)
|
||||
cell_data[i].por_il = interlayer_Dpor;
|
||||
}
|
||||
count_cells = max_cells;
|
||||
/*
|
||||
/*
|
||||
* Account for stagnant cells
|
||||
*/
|
||||
if (stag_data->count_stag > 0)
|
||||
@ -851,7 +868,7 @@ read_transport(void)
|
||||
cell_data[i].mid_cell_x;
|
||||
}
|
||||
}
|
||||
/*
|
||||
/*
|
||||
* Fill in data for punch
|
||||
*/
|
||||
if (count_punch != 0)
|
||||
@ -874,7 +891,7 @@ read_transport(void)
|
||||
else if (simul_tr == 1)
|
||||
for (i = 1; i < all_cells; i++)
|
||||
cell_data[i].punch = TRUE;
|
||||
/*
|
||||
/*
|
||||
* Fill in data for print
|
||||
*/
|
||||
if (count_print != 0)
|
||||
@ -899,7 +916,7 @@ read_transport(void)
|
||||
cell_data[i].print = TRUE;
|
||||
//#define OLD_POROSITY
|
||||
#if defined(OLD_POROSITY)
|
||||
/*
|
||||
/*
|
||||
* Fill in porosities
|
||||
*/
|
||||
if (interlayer_Dflag && !multi_Dflag)
|
||||
@ -950,7 +967,7 @@ read_transport(void)
|
||||
error_msg(error_string, CONTINUE);
|
||||
}
|
||||
}
|
||||
/*
|
||||
/*
|
||||
* Check boundary conditions
|
||||
*/
|
||||
if ((ishift != 0) && ((bcon_first == 2) || (bcon_last == 2)))
|
||||
@ -962,7 +979,7 @@ read_transport(void)
|
||||
if (bcon_last == 2)
|
||||
bcon_last = 3;
|
||||
}
|
||||
/*
|
||||
/*
|
||||
* Retain data from previous run
|
||||
*/
|
||||
if (simul_tr > 1)
|
||||
@ -970,7 +987,7 @@ read_transport(void)
|
||||
if ((count_length == 0) && (count_disp == 0) && (count_por == 0))
|
||||
dup_print("Column data retained from former run", TRUE);
|
||||
}
|
||||
/*
|
||||
/*
|
||||
* Check heat_diffc
|
||||
*/
|
||||
if (heat_diffc < 0)
|
||||
@ -990,7 +1007,7 @@ read_transport(void)
|
||||
{
|
||||
error_string = sformatf(
|
||||
"Thermal diffusion is calculated assuming exchange factor was for\n\t effective (non-thermal) diffusion coefficient = %e.",
|
||||
(double) diffc);
|
||||
(double)diffc);
|
||||
warning_msg(error_string);
|
||||
}
|
||||
}
|
||||
@ -1012,14 +1029,14 @@ read_transport(void)
|
||||
"Only one stagnant layer permitted (-stag) when modeling thermal diffusion.");
|
||||
error_msg(error_string, CONTINUE);
|
||||
}
|
||||
/*
|
||||
/*
|
||||
* free storage for length, disp, punch
|
||||
*/
|
||||
length = (LDBLE *) free_check_null(length);
|
||||
disp = (LDBLE *) free_check_null(disp);
|
||||
pors = (LDBLE *) free_check_null(pors);
|
||||
punch_temp = (int *) free_check_null(punch_temp);
|
||||
print_temp = (int *) free_check_null(print_temp);
|
||||
length = (LDBLE *)free_check_null(length);
|
||||
disp = (LDBLE *)free_check_null(disp);
|
||||
pors = (LDBLE *)free_check_null(pors);
|
||||
punch_temp = (int *)free_check_null(punch_temp);
|
||||
print_temp = (int *)free_check_null(print_temp);
|
||||
|
||||
if (dump_in == TRUE)
|
||||
{
|
||||
@ -1079,7 +1096,7 @@ int Phreeqc::
|
||||
dump_cpp(void)
|
||||
/* ---------------------------------------------------------------------- */
|
||||
{
|
||||
/*
|
||||
/*
|
||||
* dumps solution compositions to file
|
||||
*/
|
||||
|
||||
@ -1094,7 +1111,7 @@ dump_cpp(void)
|
||||
std::ofstream fs(dump_file_name_cpp.c_str());
|
||||
if (!fs.is_open())
|
||||
{
|
||||
error_string = sformatf( "Can`t open file, %s.", dump_file_name_cpp.c_str());
|
||||
error_string = sformatf("Can`t open file, %s.", dump_file_name_cpp.c_str());
|
||||
input_error++;
|
||||
error_msg(error_string, CONTINUE);
|
||||
return (OK);
|
||||
@ -1109,11 +1126,11 @@ dump_cpp(void)
|
||||
fs << token;
|
||||
sprintf(token, "\t-iter%15d\n", itmax);
|
||||
fs << token;
|
||||
sprintf(token, "\t-tol %15.3e\n", (double) ineq_tol);
|
||||
sprintf(token, "\t-tol %15.3e\n", (double)ineq_tol);
|
||||
fs << token;
|
||||
sprintf(token, "\t-step%15.3e\n", (double) step_size);
|
||||
sprintf(token, "\t-step%15.3e\n", (double)step_size);
|
||||
fs << token;
|
||||
sprintf(token, "\t-pe_s%15.3e\n", (double) pe_step_size);
|
||||
sprintf(token, "\t-pe_s%15.3e\n", (double)pe_step_size);
|
||||
fs << token;
|
||||
sprintf(token, "\t-diag ");
|
||||
fs << token;
|
||||
@ -1128,12 +1145,12 @@ dump_cpp(void)
|
||||
fs << token;
|
||||
}
|
||||
std::map < int, SelectedOutput >::iterator so_it = SelectedOutput_map.begin();
|
||||
for ( ; so_it != SelectedOutput_map.end(); so_it++)
|
||||
for (; so_it != SelectedOutput_map.end(); so_it++)
|
||||
{
|
||||
current_selected_output = &(so_it->second);
|
||||
|
||||
sprintf(token, "SELECTED_OUTPUT %d\n", current_selected_output->Get_n_user());
|
||||
fs << token ;
|
||||
fs << token;
|
||||
//sprintf(token, "\t-file %-15s\n", "sel_o$$$.prn");
|
||||
//fs << token;
|
||||
fs << "\t-file " << "sel_o$$$" << current_selected_output->Get_n_user() << ".prn\n";
|
||||
@ -1248,19 +1265,19 @@ dump_cpp(void)
|
||||
fs << token;
|
||||
sprintf(token, "\t-bcon %6d%6d\n", bcon_first, bcon_last);
|
||||
fs << token;
|
||||
sprintf(token, "\t-timest %13.5e\n", (double) timest);
|
||||
sprintf(token, "\t-timest %13.5e\n", (double)timest);
|
||||
fs << token;
|
||||
if (!high_precision)
|
||||
{
|
||||
sprintf(token, "\t-diffc %13.5e\n", (double) diffc);
|
||||
sprintf(token, "\t-diffc %13.5e\n", (double)diffc);
|
||||
fs << token;
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(token, "\t-diffc %20.12e\n", (double) diffc);
|
||||
sprintf(token, "\t-diffc %20.12e\n", (double)diffc);
|
||||
fs << token;
|
||||
}
|
||||
sprintf(token, "\t-tempr %13.5e\n", (double) tempr);
|
||||
sprintf(token, "\t-tempr %13.5e\n", (double)tempr);
|
||||
fs << token;
|
||||
if (correct_disp == TRUE)
|
||||
{
|
||||
@ -1276,7 +1293,7 @@ dump_cpp(void)
|
||||
fs << token;
|
||||
for (int i = 1; i <= count_cells; i++)
|
||||
{
|
||||
sprintf(token, "%12.3e", (double) cell_data[i].length);
|
||||
sprintf(token, "%12.3e", (double)cell_data[i].length);
|
||||
fs << token;
|
||||
if (i > 0 && (i % 8) == 0)
|
||||
{
|
||||
@ -1292,12 +1309,12 @@ dump_cpp(void)
|
||||
{
|
||||
if (!high_precision)
|
||||
{
|
||||
sprintf(token, "%12.3e", (double) cell_data[i].disp);
|
||||
sprintf(token, "%12.3e", (double)cell_data[i].disp);
|
||||
fs << token;
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(token, "%20.12e", (double) cell_data[i].disp);
|
||||
sprintf(token, "%20.12e", (double)cell_data[i].disp);
|
||||
fs << token;
|
||||
}
|
||||
if (i > 0 && (i % 8) == 0)
|
||||
@ -1366,7 +1383,7 @@ int Phreeqc::
|
||||
dump(void)
|
||||
/* ---------------------------------------------------------------------- */
|
||||
{
|
||||
/*
|
||||
/*
|
||||
* dumps solution compositions to file
|
||||
*/
|
||||
if (dump_in == FALSE || pr.dump == FALSE)
|
||||
|
||||
@ -527,7 +527,7 @@ transport(void)
|
||||
run_reactions(i, kin_time, NOMIX, step_fraction);
|
||||
else
|
||||
run_reactions(i, kin_time, DISP, step_fraction);
|
||||
if (multi_Dflag && j < nmix)
|
||||
if (multi_Dflag)
|
||||
fill_spec(i);
|
||||
|
||||
/* punch and output file */
|
||||
@ -707,7 +707,7 @@ transport(void)
|
||||
transport_step, 0, i, max_iter);
|
||||
status(0, token);
|
||||
run_reactions(i, kin_time, NOMIX, step_fraction);
|
||||
if (multi_Dflag == TRUE && j < nmix)
|
||||
if (multi_Dflag == TRUE)
|
||||
fill_spec(i);
|
||||
if (iterations > max_iter)
|
||||
max_iter = iterations;
|
||||
@ -825,7 +825,7 @@ transport(void)
|
||||
run_reactions(i, kin_time, NOMIX, step_fraction);
|
||||
else
|
||||
run_reactions(i, kin_time, DISP, step_fraction);
|
||||
if (multi_Dflag == TRUE && j < nmix)
|
||||
if (multi_Dflag == TRUE)
|
||||
fill_spec(i);
|
||||
if ((j == nmix) && (stag_data->count_stag == 0 || i == 0
|
||||
|| (i != 1 + count_cells && Utilities::Rxn_find(Rxn_solution_map, i + 1 + count_cells) == 0)))
|
||||
@ -1624,7 +1624,7 @@ fill_spec(int l_cell_no)
|
||||
struct master *master_ptr;
|
||||
LDBLE dum, dum2;
|
||||
LDBLE lm;
|
||||
LDBLE por, por_il, viscos_f, viscos_il_f, viscos;
|
||||
LDBLE por, por_il, viscos_f, viscos_il_f, viscos, l_z, l_g, ff;
|
||||
bool x_max_done = false;
|
||||
|
||||
s_ptr2 = NULL;
|
||||
@ -1813,6 +1813,20 @@ fill_spec(int l_cell_no)
|
||||
else
|
||||
sol_D[l_cell_no].spec[count_spec].Dwt = s_ptr->dw * viscos_f;
|
||||
}
|
||||
if (correct_Dw)
|
||||
{
|
||||
if ((l_z = fabs(s_x[i]->z)) == 0)
|
||||
{ // first approximation for neutral species (HTO), but is viscosity dependent
|
||||
l_z = 1;
|
||||
l_g = -DH_A * (sqrt(mu_x) / (1 + sqrt(mu_x)));
|
||||
}
|
||||
else
|
||||
l_g = s_ptr->lg;
|
||||
ff = (mu_x < .36 * l_z ? 0.6 / sqrt(l_z) : sqrt(mu_x) / l_z);
|
||||
ff *= l_g;
|
||||
if (ff > 0) ff = 0; // is viscosity dependent (ff > 0 in KCl)
|
||||
sol_D[l_cell_no].spec[count_spec].Dwt *= under(ff);
|
||||
}
|
||||
if (sol_D[l_cell_no].spec[count_spec].Dwt * pow(por, multi_Dn) > diffc_max)
|
||||
diffc_max = sol_D[l_cell_no].spec[count_spec].Dwt * pow(por, multi_Dn);
|
||||
sol_D[l_cell_no].spec[count_spec].erm_ddl = s_ptr->erm_ddl;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user