[GRASS-SVN] r58139 - grass/trunk/raster/r.topmodel
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Nov 2 06:56:29 PDT 2013
Author: hcho
Date: 2013-11-02 06:56:29 -0700 (Sat, 02 Nov 2013)
New Revision: 58139
Modified:
grass/trunk/raster/r.topmodel/global.h
grass/trunk/raster/r.topmodel/infiltration.c
grass/trunk/raster/r.topmodel/topmodel.c
Log:
Renamed functions.
Print a warning and calculate infiltration when max no. of iterations reached.
Modified: grass/trunk/raster/r.topmodel/global.h
===================================================================
--- grass/trunk/raster/r.topmodel/global.h 2013-11-02 12:41:48 UTC (rev 58138)
+++ grass/trunk/raster/r.topmodel/global.h 2013-11-02 13:56:29 UTC (rev 58139)
@@ -24,12 +24,12 @@
double calculate_lambda(void);
void initialize(void);
void calculate_flows(void);
-double calculate_Em(void);
+double calculate_efficiency(void);
void calculate_others(void);
void run_topmodel(void);
/* infiltration.c */
-double calculate_f(double t, double R);
+double calculate_infiltration(int timestep, double R);
/* Topographic index statistics file */
Modified: grass/trunk/raster/r.topmodel/infiltration.c
===================================================================
--- grass/trunk/raster/r.topmodel/infiltration.c 2013-11-02 12:41:48 UTC (rev 58138)
+++ grass/trunk/raster/r.topmodel/infiltration.c 2013-11-02 13:56:29 UTC (rev 58139)
@@ -1,13 +1,14 @@
#include <math.h>
-#include <grass/raster.h>
+#include <grass/gis.h>
+#include <grass/glocale.h>
#include "global.h"
/* The Green-and-Ampt Model */
-double calculate_f(double t, double R)
+double calculate_infiltration(int timestep, double R)
{
static double cumf = 0.0, f_ = 0.0;
static char ponding = 0;
- double f, f1, f2, fc, R2, cnst, pt, psi_dtheta, sum;
+ double t, f, f1, f2, fc, R2, cnst, pt, psi_dtheta, sum;
int factorial;
int i, j;
@@ -20,6 +21,7 @@
return 0.0;
}
+ t = timestep * input.dt;
f1 = cnst = pt = 0.0;
psi_dtheta = params.psi * params.dtheta;
if (!ponding) {
@@ -66,10 +68,11 @@
if (fabs(f) < TOLERANCE)
break;
}
- if (i == MAXITER) {
- Rast_set_d_null_value(&f, 1);
- return f;
- }
+ if (i == MAXITER)
+ G_warning(
+ _("Maximum number of iterations exceeded at timestep %d!"),
+ timestep);
+
pt = t - input.dt + (f_ - cumf) / R;
if (pt > t) {
f = R;
@@ -108,10 +111,9 @@
if (fabs(f) < TOLERANCE)
break;
}
- if (i == MAXITER) {
- Rast_set_d_null_value(&f, 1);
- return f;
- }
+ if (i == MAXITER)
+ G_warning(_("Maximum number of iterations exceeded at timestep %d!"),
+ timestep);
if (f_ < cumf + R * input.dt) {
f = (f_ - cumf) / input.dt;
Modified: grass/trunk/raster/r.topmodel/topmodel.c
===================================================================
--- grass/trunk/raster/r.topmodel/topmodel.c 2013-11-02 12:41:48 UTC (rev 58138)
+++ grass/trunk/raster/r.topmodel/topmodel.c 2013-11-02 13:56:29 UTC (rev 58139)
@@ -161,7 +161,7 @@
if (params.infex) {
misc.f[i] = input.dt *
- calculate_f((i + 1) * input.dt, input.R[i] / input.dt);
+ calculate_infiltration(i + 1, input.R[i] / input.dt);
misc.fex[i] = input.R[i] - misc.f[i];
R = misc.f[i];
}
@@ -266,7 +266,7 @@
}
/* Objective function for hydrograph suggested by Servet and Dezetter(1991) */
-double calculate_Em(void)
+double calculate_efficiency(void)
{
int i;
double Em, numerator, denominator;
@@ -311,7 +311,7 @@
misc.Qt_mean /= input.ntimesteps;
if (file.qobs) {
- misc.Em = calculate_Em();
+ misc.Em = calculate_efficiency();
for (i = 0; i < input.ntimesteps; i++) {
if (!i || misc.Qobs_peak < misc.Qobs[i]) {
misc.Qobs_peak = misc.Qobs[i];
More information about the grass-commit
mailing list