void  getFluxes(double theta, double lowerDepth)
//
//  Input:   upperVolume = vol. depth of upper zone (ft)
//           upperDepth  = depth of upper zone (ft)
//  Output:  none
//  Purpose: computes water fluxes into/out of upper/lower GW zones.
//
{
    double upperDepth;

    // --- find upper zone depth
    lowerDepth = MAX(lowerDepth, 0.0);
    lowerDepth = MIN(lowerDepth, TotalDepth);
    upperDepth = TotalDepth - lowerDepth;

    // --- save lower depth and theta to global variables
    Hgw = lowerDepth;
    Theta = theta;

    // --- find evaporation rate from both zones
    getEvapRates(theta, upperDepth);

    // --- find percolation rate from upper to lower zone
    UpperPerc = getUpperPerc(theta, upperDepth);
    UpperPerc = MIN(UpperPerc, MaxUpperPerc);

    // --- find loss rate to deep GW
    if ( DeepFlowExpr != NULL )
        LowerLoss = mathexpr_eval(DeepFlowExpr, getVariableValue) /
                    UCF(RAINFALL);
    else
        LowerLoss = A.lowerLossCoeff * lowerDepth / TotalDepth;
    LowerLoss = MIN(LowerLoss, lowerDepth/Tstep);

    // --- find GW flow rate from lower zone to drainage system node
    GWFlow = getGWFlow(lowerDepth);
    if ( LatFlowExpr != NULL )
    {
        GWFlow += mathexpr_eval(LatFlowExpr, getVariableValue) / UCF(GWFLOW);
    }
    if ( GWFlow >= 0.0 ) GWFlow = MIN(GWFlow, MaxGWFlowPos);
    else GWFlow = MAX(GWFlow, MaxGWFlowNeg);
}
Esempio n. 2
0
void  getFluxes(Project* project, double theta, double lowerDepth)
//
//  Input:   upperVolume = vol. depth of upper zone (ft)
//           upperDepth  = depth of upper zone (ft)
//  Output:  none
//  Purpose: computes water fluxes into/out of upper/lower project->GW zones.
//
{
    double upperDepth;

    // --- find upper zone depth
    lowerDepth = MAX(lowerDepth, 0.0);
    lowerDepth = MIN(lowerDepth, project->TotalDepth);
    upperDepth = project->TotalDepth - lowerDepth;

    // --- save lower depth and theta to global variables
    project->Hgw = lowerDepth;
    project->Theta = theta;

    // --- find evaporation rate from both zones
    getEvapRates(project,theta, upperDepth);

    // --- find percolation rate from upper to lower zone
    project->UpperPerc = getUpperPerc(project,theta, upperDepth);
    project->UpperPerc = MIN(project->UpperPerc, project->MaxUpperPerc);

    // --- find loss rate to deep project->GW
    if ( project->DeepFlowExpr != NULL )
        project->LowerLoss = mathexpr_eval(project, project->DeepFlowExpr, getVariableValue) /
                    UCF(project,RAINFALL);
    else
        project->LowerLoss = project->A.lowerLossCoeff * lowerDepth / project->TotalDepth;
    project->LowerLoss = MIN(project->LowerLoss, lowerDepth/project->Tstep);

    // --- find project->GW flow rate from lower zone to drainage system node
    project->GWFlow = getGWFlow(project,lowerDepth);
    if ( project->LatFlowExpr != NULL )
    {
		project->GWFlow += mathexpr_eval(project, project->LatFlowExpr, getVariableValue) / UCF(project, GWFLOW);
    }
    if ( project->GWFlow >= 0.0 ) project->GWFlow = MIN(project->GWFlow, project->MaxGWFlowPos);
    else project->GWFlow = MAX(project->GWFlow, project->MaxGWFlowNeg);
}
double  getRemoval(int p)
//
//  Input:   p = pollutant index
//  Output:  returns fractional removal of pollutant
//  Purpose: computes removal of a specific pollutant
//
{
    double c0 = Node[J].newQual[p];    // initial node concentration
    double r;                          // removal value
    TTreatment* treatment;                                                     //(5.1.008)

    // --- case where removal already being computed for another pollutant
    if ( R[p] > 1.0 || ErrCode )
    {
        ErrCode = 1;
        return 0.0;
    }

    // --- case where removal already computed
    if ( R[p] >= 0.0 && R[p] <= 1.0 ) return R[p];

    // --- set R[p] to value > 1 to show that value is being sought
    //     (prevents infinite recursive calls in case two removals
    //     depend on each other)
    R[p] = 10.0;

    // --- case where current concen. is zero
    if ( c0 == 0.0 )
    {
        R[p] = 0.0;
        return 0.0;
    }

    // --- apply treatment eqn.
    treatment = &Node[J].treatment[p];                                         //(5.1.008)
    r = mathexpr_eval(treatment->equation, getVariableValue);                  //(5.1.008)
    r = MAX(0.0, r);

    // --- case where treatment eqn. is for removal
    if ( treatment->treatType == REMOVAL )                                     //(5.1.008)
    {
        r = MIN(1.0, r);
        R[p] = r;
    }

    // --- case where treatment eqn. is for effluent concen.
    else
    {
        r = MIN(c0, r);
        R[p] = 1.0 - r/c0;
    }
    return R[p];
}