Beispiel #1
0
void  findSFLinkQual(int i, double tStep)
//
//  Input:   i = link index
//           tStep = routing time step (sec)
//  Output:  none
//  Purpose: finds new quality in a link at end of the current time step for
//           Steady Flow routing.
//
{
    int j = Link[i].node1;
    int p;
    double c1, c2;
    double lossRate;
    double t = tStep;

    // --- for each pollutant
    for (p = 0; p < Nobjects[POLLUT]; p++)
    {
        // --- conduit's quality equals upstream node quality
        c1 = Node[j].newQual[p];
        c2 = c1;

        // --- apply first-order decay over travel time
        if ( Pollut[p].kDecay > 0.0 )
        {
            c2 = c1 * exp(-Pollut[p].kDecay * t);
            c2 = MAX(0.0, c2);
            lossRate = (c1 - c2) * Link[i].newFlow;
            massbal_addReactedMass(p, lossRate);
        }
        Link[i].newQual[p] = c2;
    }
}
Beispiel #2
0
double getReactedQual(int p, double c, double v1, double tStep)
//
//  Input:   p = pollutant index
//           c = initial concentration (mass/ft3)
//           v1 = initial volume (ft3)
//           tStep = time step (sec)
//  Output:  none
//  Purpose: applies a first order reaction to a pollutant over a given
//           time step.
//
{
    double c2, lossRate;
    double kDecay = Pollut[p].kDecay;

    if ( kDecay == 0.0 ) return c;
    c2 = c * (1.0 - kDecay * tStep);
    c2 = MAX(0.0, c2);
    lossRate = (c - c2) * v1 / tStep;
    massbal_addReactedMass(p, lossRate);
    return c2;
}
Beispiel #3
0
void  treatmnt_treat(int j, double q, double v, double tStep)
//
//  Input:   j     = node index
//           q     = inflow to node (cfs)
//           v     = volume of node (ft3)
//           tStep = routing time step (sec)
//  Output:  none
//  Purpose: updates pollutant concentrations at a node after treatment.
//
{
    int    p;                          // pollutant index
    double cOut;                       // concentration after treatment
//  double cLost;                      // concentration lost by treatment      //(5.0.017 - LR)
    double massLost;                   // mass lost by treatment per time step

    // --- set global variables for node j
    if ( Node[j].treatment == NULL ) return;
    ErrCode = 0;
    J  = j;                            // current node
    Dt = tStep;                        // current time step
    Q  = q;                            // current inflow rate
    V  = v;                            // current node volume

    // --- initialze each removal to indicate no value
    for ( p=0; p<Nobjects[POLLUT]; p++) R[p] = -1.0;

    // --- determine removal of each pollutant
    for ( p=0; p<Nobjects[POLLUT]; p++)
    {
        // --- removal is zero if there is no treatment equation
        Treatment = &Node[j].treatment[p];
        if ( Treatment->equation == NULL ) R[p] = 0.0;

        // --- otherwise evaluate the treatment expression to find R[p]
        else getRemoval(p);
    }

    // --- check for error condition
    if ( ErrCode == ERR_CYCLIC_TREATMENT )
    {
        report_writeErrorMsg(ERR_CYCLIC_TREATMENT, Node[J].ID);
    }

    // --- update nodal concentrations and mass balances
    else for ( p=0; p<Nobjects[POLLUT]; p++ )
        {
            if ( R[p] == 0.0 ) continue;

            // --- removal-type treatment equations get applied to inflow stream
            if ( Treatment->treatType == REMOVAL )
            {
                // --- if no pollutant in inflow then cOut is current nodal concen.
                if ( Cin[p] == 0.0 ) cOut = Node[j].newQual[p];

                // ---  otherwise apply removal to influent concen.
                else cOut = (1.0 - R[p]) * Cin[p];

                // --- cOut can't be greater than mixture concen. at node
                //     (i.e., in case node is a storage unit)
                cOut = MIN(cOut, Node[j].newQual[p]);
            }

            // --- concentration-type equations get applied to nodal concentration
            else
            {
                cOut = (1.0 - R[p]) * Node[j].newQual[p];
            }

            // --- mass lost must account for any initial mass in storage          //(5.0.017 - LR)
            massLost = (Cin[p]*q*tStep + Node[j].oldQual[p]*Node[j].oldVolume -    //(5.0.017 - LR)
                        cOut*(q*tStep + Node[j].oldVolume)) / tStep;                //(5.0.017 - LR)
            massLost = MAX(0.0, massLost);                                         //(5.0.017 - LR)

            // --- add mass loss to mass balance totals and revise nodal concentration
            massbal_addReactedMass(p, massLost);
            Node[j].newQual[p] = cOut;
        }
}