void addRdiiInflows(DateTime currentDate) // // Input: currentDate = current date/time // Output: none // Purpose: adds RDII inflows to nodes at current date. // { int i, j, p; double q, w; int numRdiiNodes; // --- see if any nodes have RDII at current date numRdiiNodes = rdii_getNumRdiiFlows(currentDate); // --- add RDII flow to each node's lateral inflow for (i=0; i<numRdiiNodes; i++) { rdii_getRdiiFlow(i, &j, &q); if ( j < 0 ) continue; if ( fabs(q) < FLOW_TOL ) continue; Node[j].newLatFlow += q; massbal_addInflowFlow(RDII_INFLOW, q); // add pollutant load (for positive inflow) if ( q > 0.0 ) { for (p = 0; p < Nobjects[POLLUT]; p++) { w = q * Pollut[p].rdiiConcen; Node[j].newQual[p] += w; massbal_addInflowQual(RDII_INFLOW, p, w); } } } }
void addExternalInflows(DateTime currentDate) // // Input: currentDate = current date/time // Output: none // Purpose: adds direct external inflows to nodes at current date. // { int j, p; double q, w; TExtInflow* inflow; // --- for each node with a defined external inflow for (j = 0; j < Nobjects[NODE]; j++) { inflow = Node[j].extInflow; if ( !inflow ) continue; // --- get flow inflow q = 0.0; while ( inflow ) { if ( inflow->type == FLOW_INFLOW ) { q = inflow_getExtInflow(inflow, currentDate); break; } else inflow = inflow->next; } if ( fabs(q) < FLOW_TOL ) q = 0.0; // --- add flow inflow to node's lateral inflow Node[j].newLatFlow += q; massbal_addInflowFlow(EXTERNAL_INFLOW, q); // --- add on any inflow (i.e., reverse flow) through an outfall if ( Node[j].type == OUTFALL && Node[j].oldNetInflow < 0.0 ) { q = q - Node[j].oldNetInflow; } // --- get pollutant mass inflows inflow = Node[j].extInflow; while ( inflow ) { if ( inflow->type != FLOW_INFLOW ) { p = inflow->param; w = inflow_getExtInflow(inflow, currentDate); if ( inflow->type == CONCEN_INFLOW ) w *= q; Node[j].newQual[p] += w; massbal_addInflowQual(EXTERNAL_INFLOW, p, w); } inflow = inflow->next; } } }
void addDryWeatherInflows(DateTime currentDate) // // Input: currentDate = current date/time // Output: none // Purpose: adds dry weather inflows to nodes at current date. // { int j, p; int month, day, hour; double q, w; TDwfInflow* inflow; // --- get month (zero-based), day-of-week (zero-based), // & hour-of-day for routing date/time month = datetime_monthOfYear(currentDate) - 1; day = datetime_dayOfWeek(currentDate) - 1; hour = datetime_hourOfDay(currentDate); // --- for each node with a defined dry weather inflow for (j = 0; j < Nobjects[NODE]; j++) { inflow = Node[j].dwfInflow; if ( !inflow ) continue; // --- get flow inflow (i.e., the inflow whose param code is -1) q = 0.0; while ( inflow ) { if ( inflow->param < 0 ) { q = inflow_getDwfInflow(inflow, month, day, hour); break; } inflow = inflow->next; } if ( fabs(q) < FLOW_TOL ) q = 0.0; // --- add flow inflow to node's lateral inflow Node[j].newLatFlow += q; massbal_addInflowFlow(DRY_WEATHER_INFLOW, q); // --- get pollutant mass inflows inflow = Node[j].dwfInflow; while ( inflow ) { if ( inflow->param >= 0 ) { p = inflow->param; w = q * inflow_getDwfInflow(inflow, month, day, hour); Node[j].newQual[p] += w; massbal_addInflowQual(DRY_WEATHER_INFLOW, p, w); } inflow = inflow->next; } } }
void addGroundwaterInflows(double routingTime) // // Input: routingTime = elasped time (millisec) // Output: none // Purpose: adds groundwater inflows to nodes at current elapsed time. // { int i, j, p; double q, w; double f; TGroundwater* gw; // --- find where current routing time lies between latest runoff times if ( Nobjects[SUBCATCH] == 0 ) return; f = (routingTime - OldRunoffTime) / (NewRunoffTime - OldRunoffTime); if ( f < 0.0 ) f = 0.0; if ( f > 1.0 ) f = 1.0; // --- for each subcatchment for (i = 0; i < Nobjects[SUBCATCH]; i++) { // --- see if subcatch contains groundwater gw = Subcatch[i].groundwater; if ( gw ) { // --- identify node receiving groundwater flow j = gw->node; if ( j >= 0 ) { // add groundwater flow to lateral inflow q = ( (1.0 - f)*(gw->oldFlow) + f*(gw->newFlow) ) * Subcatch[i].area; if ( fabs(q) < FLOW_TOL ) continue; Node[j].newLatFlow += q; massbal_addInflowFlow(GROUNDWATER_INFLOW, q); // add pollutant load (for positive inflow) if ( q > 0.0 ) { for (p = 0; p < Nobjects[POLLUT]; p++) { w = q * Pollut[p].gwConcen; Node[j].newQual[p] += w; massbal_addInflowQual(GROUNDWATER_INFLOW, p, w); } } } } } }
void addWetWeatherInflows(double routingTime) // // Input: routingTime = elasped time (millisec) // Output: none // Purpose: adds runoff inflows to nodes at current elapsed time. // { int i, j, p; double q, w; double f; // --- find where current routing time lies between latest runoff times if ( Nobjects[SUBCATCH] == 0 ) return; f = (routingTime - OldRunoffTime) / (NewRunoffTime - OldRunoffTime); if ( f < 0.0 ) f = 0.0; if ( f > 1.0 ) f = 1.0; // for each subcatchment outlet node, // add interpolated runoff flow & pollutant load to node's inflow for (i = 0; i < Nobjects[SUBCATCH]; i++) { j = Subcatch[i].outNode; if ( j >= 0) { // add runoff flow to lateral inflow q = subcatch_getWtdOutflow(i, f); // current runoff flow // if ( fabs(q) < FLOW_TOL ) q = 0.0; //(5.0.014 - LR) Node[j].newLatFlow += q; massbal_addInflowFlow(WET_WEATHER_INFLOW, q); // add pollutant load for (p = 0; p < Nobjects[POLLUT]; p++) { w = q * subcatch_getWtdWashoff(i, p, f); Node[j].newQual[p] += w; massbal_addInflowQual(WET_WEATHER_INFLOW, p, w); } } } }
void addIfaceInflows(DateTime currentDate) // // Input: currentDate = current date/time // Output: none // Purpose: adds inflows from routing interface file to nodes at current date. // { int i, j, p; double q, w; int numIfaceNodes; // --- see if any nodes have interface inflows at current date if ( Finflows.mode != USE_FILE ) return; numIfaceNodes = iface_getNumIfaceNodes(currentDate); // --- add interface flow to each node's lateral inflow for (i=0; i<numIfaceNodes; i++) { j = iface_getIfaceNode(i); if ( j < 0 ) continue; q = iface_getIfaceFlow(i); if ( fabs(q) < FLOW_TOL ) continue; Node[j].newLatFlow += q; massbal_addInflowFlow(EXTERNAL_INFLOW, q); // add pollutant load (for positive inflow) if ( q > 0.0 ) { for (p = 0; p < Nobjects[POLLUT]; p++) { w = q * iface_getIfaceQual(i, p); Node[j].newQual[p] += w; massbal_addInflowQual(EXTERNAL_INFLOW, p, w); } } } }