Reverse flow in a link of SWMM 5 occurs if the downstream head is greater than the upstream head. The flow calculations for the link are based on the time step head, cross sectional area(s), hydraulic radius and old time step flow of the link. The only extra criterion for the link flow is the requirement that the flow cannot reverse during one iteration but must first become zero before being allowed to be negative if the old flow was positive or positive if the old iteration flow (qLast) was negative. This calculation is done in dynwave.c using the current iteration flow, q, the last iteration flow, qLast and the sign of the current iteration flow q. The requirement prevents the flow from oscillating sign during the iterative process in a time step.
In this example, a large flow from Upnode_2 causes a high head at node Middle which causes a reverse flow up link UpPipe1 to node UpNode_1. The image show here shows the flow in Link UpPipe1
if ( q * qLast < 0.0 ) q = 0.001 * SGN(q);