double getSubareaRunoff(int j, int i, double area, double precip, double evap, double tStep) // // Purpose: computes runoff & losses from a subarea over the current time step. // Input: j = subcatchment index // i = subarea index // area = sub-area area (ft2) // precip = rainfall + snowmelt over subarea (ft/sec) // evap = evaporation (ft/sec) // tStep = time step (sec) // Output: returns runoff rate from the sub-area (cfs); // updates shared variables Vinflow, Vevap, Vpevap, Vinfil & Voutflow. // { double tRunoff; // time over which runoff occurs (sec) double surfMoisture; // surface water available (ft/sec) double surfEvap; // evap. used for surface water (ft/sec) double infil = 0.0; // infiltration rate (ft/sec) double runoff = 0.0; // runoff rate (ft/sec) TSubarea* subarea; // pointer to subarea being analyzed // --- no runoff if no area if ( area == 0.0 ) return 0.0; // --- assign pointer to current subarea subarea = &Subcatch[j].subArea[i]; // --- assume runoff occurs over entire time step tRunoff = tStep; // --- determine evaporation loss rate surfMoisture = subarea->depth / tStep; surfEvap = MIN(surfMoisture, evap); // --- compute infiltration loss rate if ( i == PERV ) infil = getSubareaInfil(j, subarea, precip, tStep); // --- add precip to other subarea inflows subarea->inflow += precip; surfMoisture += subarea->inflow; // --- update total inflow, evaporation & infiltration volumes Vinflow += precip * area * tStep; Vevap += surfEvap * area * tStep; if ( i == PERV ) Vpevap += Vevap; Vinfil += infil * area * tStep; // --- if losses exceed available moisture then no ponded water remains if ( surfEvap + infil >= surfMoisture ) { subarea->depth = 0.0; } // --- otherwise reduce inflow by losses and update depth // of ponded water and time over which runoff occurs else { subarea->inflow -= surfEvap + infil; updatePondedDepth(subarea, &tRunoff); } // --- compute runoff based on updated ponded depth runoff = findSubareaRunoff(subarea, tRunoff); // --- compute runoff volume leaving subcatchment for mass balance purposes // (fOutlet is the fraction of this subarea's runoff that goes to the // subcatchment outlet as opposed to another subarea of the subcatchment) Voutflow += subarea->fOutlet * runoff * area * tStep; return runoff; }
void getSubareaRunoff(int j, int i, double precip, double evap, double tStep) // // Purpose: computes runoff & losses from a subarea over the current time step. // Input: j = subcatchment index // i = subarea index // precip = rainfall + snowmelt over subarea (ft/sec) // evap = evaporation (ft/sec) // tStep = time step (sec) // Output: none // { double tRunoff; // time over which runoff occurs (sec) double oldRunoff; // runoff from previous time period double surfMoisture; // surface water available (ft/sec) double surfEvap; // evap. used for surface water (ft/sec) double infil; // infiltration rate (ft/sec) TSubarea* subarea; // pointer to subarea being analyzed // --- assign pointer to current subarea subarea = &Subcatch[j].subArea[i]; // --- assume runoff occurs over entire time step tRunoff = tStep; // --- initialize runoff & losses oldRunoff = subarea->runoff; subarea->runoff = 0.0; infil = 0.0; Vevap = 0.0; Vinfil = 0.0; Voutflow = 0.0; Losses = 0.0; Outflow = 0.0; // --- no runoff if no area if ( subarea->fArea == 0.0 ) return; // --- determine evaporation loss rate surfMoisture = subarea->depth / tStep; surfEvap = MIN(surfMoisture, evap); // --- compute infiltration loss rate if ( i == PERV ) infil = getSubareaInfil(j, subarea, precip, tStep); // --- add precip to other subarea inflows subarea->inflow += precip; surfMoisture += subarea->inflow; // --- save volumes lost to evaporation & infiltration Vevap = surfEvap * tStep; Vinfil = infil * tStep; // --- if losses exceed available moisture then no ponded water remains Losses = surfEvap + infil; if ( Losses >= surfMoisture ) { Losses = surfMoisture; subarea->depth = 0.0; } // --- otherwise update depth of ponded water // and time over which runoff occurs else updatePondedDepth(subarea, &tRunoff); // --- compute runoff based on updated ponded depth findSubareaRunoff(subarea, tRunoff); // --- compute runoff volume leaving subcatchment for mass balance purposes // (fOutlet is the fraction of this subarea's runoff that goes to the // subcatchment outlet as opposed to another subarea of the subcatchment) if ( subarea->fOutlet > 0.0 ) { Voutflow = 0.5 * (oldRunoff + subarea->runoff) * tRunoff * subarea->fOutlet; Outflow = subarea->fOutlet * subarea->runoff; } }