void findNonConduitFlow(int i, double dt) // // Input: i = link index // dt = time step (sec) // Output: none // Purpose: finds new flow in a non-conduit-type link // { double qLast; // previous link flow (cfs) double qNew; // new link flow (cfs) // --- get link flow from last iteration qLast = Link[i].newFlow; Link[i].dqdh = 0.0; // --- get new inflow to link from its upstream node // (link_getInflow returns 0 if flap gate closed or pump is offline) qNew = link_getInflow(i); if ( Link[i].type == PUMP ) qNew = getModPumpFlow(i, qNew, dt); // --- find surface area at each end of link findNonConduitSurfArea(i); // --- apply under-relaxation with flow from previous iteration; // --- do not allow flow to change direction without first being 0 if ( Steps > 0 && Link[i].type != PUMP ) { qNew = (1.0 - Omega) * qLast + Omega * qNew; if ( qNew * qLast < 0.0 ) qNew = 0.001 * SGN(qNew); } Link[i].newFlow = qNew; }
double getLinkInflow(int j, double dt) // // Input: j = link index // dt = routing time step (sec) // Output: returns link inflow (cfs) // Purpose: finds flow into upstream end of link at current time step under // Steady or Kin. Wave routing. // { int n1 = Link[j].node1; double q; if ( Link[j].type == CONDUIT || Link[j].type == PUMP || Node[n1].type == STORAGE ) q = link_getInflow(j); else q = 0.0; return node_getMaxOutflow(n1, q, dt); }