MAX_ITERS 40
   hnew = hg
   predict_fail
   CVMEM cvode_error == TRUE || predict_fail after CVnls
   if (CVMEM cvode_error == TRUE) after CVNewtonIteration
   CVDoErrorTest exit(4);

model
Phreeqc.cpp
pitzer.cpp
sit.cpp
   new status ifdef'd with NPP
   250 ms delay
   new global variable std::string string_status

!!prep: switch_bases 10 to 100 orders of mag. Need to check

utilities.cpp: new status



git-svn-id: svn://136.177.114.72/svn_GW/phreeqc3/trunk@7585 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
David L Parkhurst 2013-03-29 16:03:51 +00:00
parent 2ba41a620a
commit 7bb4d37189
7 changed files with 173 additions and 3 deletions

View File

@ -1266,7 +1266,11 @@ void Phreeqc::init(void)
pr.hdf = FALSE;
pr.alkalinity = FALSE;
status_on = true;
#ifdef NPP
status_interval = 40;
#else
status_interval = 250;
#endif
status_timer = clock();
count_warnings = 0;
/* ----------------------------------------------------------------------

View File

@ -1490,6 +1490,7 @@ protected:
bool status_on;
clock_t status_interval;
clock_t status_timer;
std::string status_string;
int count_warnings;
/* ----------------------------------------------------------------------

View File

@ -101,7 +101,7 @@
#define HLB_FACTOR RCONST(100.0)
#define HUB_FACTOR RCONST(0.1)
#define H_BIAS HALF
#define MAX_ITERS 4
#define MAX_ITERS 40
/* CVSet */
@ -1680,10 +1680,11 @@ CVHin(CVodeMem cv_mem, realtype tout)
/* Set lower and upper bounds on h0, and take geometric mean
Exit with this value if the bounds cross each other */
hlb = HLB_FACTOR * tround;
hub = CVUpperBoundH0(cv_mem, tdist);
hg = RSqrt(hlb * hub);
hnew = hg;
if (hub < hlb)
{
if (sign == -1)
@ -1848,11 +1849,13 @@ CVStep(CVodeMem cv_mem)
/* Looping point for attempts to take a step */
loop
{
bool predict_fail = false;
CVMEM cvode_test = TRUE;
f(N, tn, y, ftemp, f_data);
CVMEM cvode_test = FALSE;
if (CVMEM cvode_error == TRUE)
{
predict_fail = true;
#ifdef DEBUG_CVODE
CVMEM warning_msg("Before predict, y Fail, time %e\n", tn);
#endif
@ -1910,6 +1913,10 @@ CVStep(CVodeMem cv_mem)
CVSet(cv_mem);
nflag = CVnls(cv_mem, nflag);
if (CVMEM cvode_error == TRUE || predict_fail)
{
nflag = -1;
}
#ifdef DEBUG_CVODE
cvode_test = TRUE;
f(N, tn, y, ftemp, f_data);
@ -1934,6 +1941,7 @@ CVStep(CVodeMem cv_mem)
CVMEM warning_msg("After CVnls, zn OK\n");
}
#endif
//fprintf(stderr, "\nTime %e,\th %e\n", tn, h);
kflag = CVHandleNFlag(cv_mem, &nflag, saved_t, &ncf);
if (kflag == PREDICT_AGAIN)
continue;
@ -2753,7 +2761,10 @@ CVnlsNewton(CVodeMem cv_mem, int nflag)
/* Do the Newton iteration */
ier = CVNewtonIteration(cv_mem);
if (CVMEM cvode_error == TRUE)
{
return (CONV_FAIL);
}
CVMEM cvode_test = TRUE;
f(N, tn, y, ftemp, f_data);
CVMEM cvode_test = FALSE;
@ -3062,6 +3073,7 @@ CVDoErrorTest(CVodeMem cv_mem, int *nflagPtr, int *kflagPtr,
CVMEM warning_msg("CVDoErrorTest");
/*exit(8); */
CVMEM error_msg("CVDoErrorTest", 1 /* STOP */ );
exit(4);
}
nfe++;
N_VScale(h, tempv, zn[1]);

View File

@ -76,7 +76,11 @@ model(void)
debug_model_save = debug_model;
pe_step_size_now = pe_step_size;
step_size_now = step_size;
#ifdef NPP
if (!use.Get_kinetics_in()) status(0, NULL);
#else
status(0, NULL);
#endif
iterations = 0;
count_basis_change = count_infeasible = 0;
stop_program = FALSE;

View File

@ -1841,7 +1841,11 @@ model_pz(void)
debug_model_save = debug_model;
pe_step_size_now = pe_step_size;
step_size_now = step_size;
#ifdef NPP
if (!use.Get_kinetics_in()) status(0, NULL);
#else
status(0, NULL);
#endif
iterations = 0;
gamma_iterations = 0;
count_basis_change = count_infeasible = 0;

View File

@ -959,7 +959,11 @@ model_sit(void)
debug_model_save = debug_model;
pe_step_size_now = pe_step_size;
step_size_now = step_size;
#ifdef NPP
if (!use.Get_kinetics_in()) status(0, NULL);
#else
status(0, NULL);
#endif
iterations = 0;
gamma_iterations = 0;
count_basis_change = count_infeasible = 0;

View File

@ -1388,6 +1388,7 @@ under(LDBLE xval)
/* return (exp(xval * LOG_10)) */;
}
#ifndef PHREEQCI_GUI
#ifdef NPP
/* ---------------------------------------------------------------------- */
int Phreeqc::
status(int count, const char *str, bool rk_string)
@ -1526,6 +1527,146 @@ status(int count, const char *str, bool rk_string)
}
return (OK);
}
#else
/* ---------------------------------------------------------------------- */
int Phreeqc::
status(int count, const char *str, bool rk_string)
/* ---------------------------------------------------------------------- */
{
char sim_str[20];
char state_str[45];
char spin_str[2];
clock_t t2;
#ifdef PHREEQ98
if (ProcessMessages)
ApplicationProcessMessages();
if (stop_calculations == TRUE)
error_msg("Execution canceled by user.", STOP);
#endif
if (pr.status == FALSE || phast == TRUE)
return (OK);
if (state == INITIALIZE)
{
screen_string = sformatf("\n%-80s", "Initializing...");
screen_msg(screen_string.c_str());
status_on = true;
return (OK);
}
switch (state)
{
case INITIALIZE:
break;
case TRANSPORT:
if (str != NULL)
{
if (rk_string)
{
screen_string = screen_string.substr(0, 43);
screen_string.append(str);
status_string = screen_string;
}
else
{
screen_string = "\r";
screen_string.append(str);
status_string = screen_string;
}
status_on = true;
}
case PHAST:
break;
default:
// if str not NULL, print it
if (str != NULL && !rk_string)
{
screen_string = "\r";
screen_string.append(str);
status_string = screen_string;
}
else
// print state
{
std::string stdstr;
if (str != NULL && rk_string)
{
stdstr = str;
}
sprintf(sim_str, "\rSimulation %d.", simulation);
sprintf(state_str, " ");
sprintf(spin_str, " ");
switch (state)
{
default:
break;
case INITIAL_SOLUTION:
sprintf(state_str, "Initial solution %d.", use.Get_solution_ptr()->Get_n_user());
break;
case INITIAL_EXCHANGE:
sprintf(state_str, "Initial exchange %d.", use.Get_exchange_ptr()->Get_n_user());
break;
case INITIAL_SURFACE:
sprintf(state_str, "Initial surface %d.", use.Get_surface_ptr()->Get_n_user());
break;
case INVERSE:
sprintf(state_str, "Inverse %d. Models = %d.", use.Get_inverse_ptr()->n_user, count);
break;
case REACTION:
if (use.Get_kinetics_in() == TRUE)
{
sprintf(state_str, "Kinetic step %d.", reaction_step);
}
else
{
sprintf(state_str, "Reaction step %d.", reaction_step);
}
break;
case ADVECTION:
sprintf(state_str, "Advection, shift %d.", advection_step);
break;
}
spinner++;
if (spinner == 1)
{
spin_str[0] = '/';
}
else if (spinner == 2)
{
spin_str[0] = '-';
}
else
{
spin_str[0] = '\\';
spinner = 0;
}
if (use.Get_kinetics_in() == TRUE)
{
screen_string = sformatf("%-15s%-27s%38s", sim_str, state_str, stdstr.c_str());
status_string = screen_string;
}
else
{
screen_string = sformatf("%-15s%-27s%1s%37s", sim_str, state_str, spin_str, stdstr.c_str());
status_string = screen_string;
}
}
status_on = true;
break;
}
t2 = clock();
if ((int) (1e3 / CLOCKS_PER_SEC * (t2 - status_timer)) > status_interval)
{
status_timer = t2;
screen_msg(status_string.c_str());
status_string.clear();
}
return (OK);
}
#endif /* NPP */
#endif /*PHREEQCI_GUI */
/*
** Dynamic hashing, after CACM April 1988 pp 446-457, by Per-Ake Larson.