Step 4: Refine and implement a solution
The estimates in Step 3 can be improved by zooming in on the portion of the graph near the sag time. A more sophisticated approach is to observe that the minimum DO level occurs when the oxygen deficit is at its maximum value. Moreover, the maximum deficit occurs at the instant in time when the tangent line to the graph of is horizontal. This condition is equivalent to finding the time when the right-hand side of the Streeter-Phelps equation is zero.
> eqnD;
> Dhoriz_eqn := rhs(eqnD) = 0;
The explicit solution to the Streeter-Phelps and remaining BOD equations are already known"
> solnD; solnL;
>
Substitution of these solutions into the right-hand side of the Streeter-Phelps equation can be done in two steps. First, replace with and with :
> sag_eqn := eval( Dhoriz_eqn, [ L(t)=L, DD(t)=DD ] );
Second, substitute the exact solutions into the equation:
> sag_eqn := eval( sag_eqn, [ solnL, solnD ] );
>
In this form the sag equation looks rather forbidding. Notice, however, that the equation is actually only a linear combination of two exponential functions:
> sag_eqn := collect( sag_eqn, { exp(-kd*t), exp(-kr*t) } );
Further simplification of this expression is possible, but is not particularly useful at this point.
>
The sag time predicted by this equation is:
> tcrit := solve( sag_eqn, {t} );
>