Saturday, January 21, 2023

SWMM 5.2.2 Code for LID Function swaleFluxRates

This code defines a function called "swaleFluxRates" which computes the flux rates for a vegetative swale LID. The function takes in a vector of storage levels (x) and a vector of flux rates (f) as inputs and does not return any outputs. The function starts by initializing several variables such as depth, topWidth, botWidth, length, surfInflow, surfWidth, surfArea, flowArea, lidArea, hydRadius, slope, volume, dVdT, dStore, and xDepth.

The function first retrieves the state variable of the surface water depth from the work vector, and limits it to the thickness of the surface layer. It then calculates the depression storage depth and the bottom width of the swale using the top width and the side slope. It then calculates the length of the swale and the surface area of the current ponded depth.

The function then calculates the wet volume and effective depth, the surface inflow into the swale, the evaporation rate, the infiltration rate to the native soil, and the surface outflow. If the depth is below the depression storage, the surface outflow is set to 0.0, otherwise, the function modifies the flow area to remove the depression storage and calculates the hydraulic radius using the Manning equation.

Then the function calculates the net flux rate (dV/dt) in cubic feet per second and assigns it to the SurfaceInflow and SurfaceOutflow.

Here is a table summarizing the variables and their descriptions in the code:

VariableDescription
depthdepth of surface water in swale (ft)
topWidthtop width of full swale (ft)
botWidthbottom width of swale (ft)
lengthlength of swale (ft)
surfInflowinflow rate to swale (cfs)
surfWidthtop width at current water depth (ft)
surfAreasurface area of current water depth (ft^2)
flowAreax-section flow area (ft^2)
lidAreasurface area of full swale (ft^2)
hydRadiushydraulic radius for current depth (ft)
slopeslope of swale side wall (run/rise)
volumeswale volume at current water depth (ft^3)
dVdTchange in volume w.r.t. time (cfs)
dStoredepression storage depth (ft)
xDepthdepth above depression storage (ft)
theLidProc->surface.thicknessthickness of the surface layer
theLidUnit->fullWidthfull width of the swale
theLidProc->surface.sideSlopeside slope of the sw
VariableDescription
SurfaceInflowinflow rate into the surface layer (cfs)
EvapRaterate of evaporation from the surface layer (cfs)
SurfaceInfilinfiltration rate into the native soil from the surface layer (cfs)
SurfaceOutflowoutflow rate from the surface layer (cfs)
theLidProc->surface.alphacoefficient used in the Manning equation
theLidProc->surface.voidFracvoid fraction of the swale


Note that this function is specific for swale LID, and it computes the flux rates based on the storage level and the LID properties. It calculates the depression storage, the bottom width, the length, the top width, the surface area, the flow area, the wet volume, the effective depth, the surface inflow, the evaporation rate, the infiltration rate, and the surface outflow.



void swaleFluxRates(double x[], double f[])
//
//  Purpose: computes flux rates from a vegetative swale LID.
//  Input:   x = vector of storage levels
//  Output:  f = vector of flux rates
//
{
    double depth;            // depth of surface water in swale (ft)
    double topWidth;         // top width of full swale (ft)
    double botWidth;         // bottom width of swale (ft)
    double length;           // length of swale (ft)
    double surfInflow;       // inflow rate to swale (cfs)
    double surfWidth;        // top width at current water depth (ft)
    double surfArea;         // surface area of current water depth (ft2)
    double flowArea;         // x-section flow area (ft2)
    double lidArea;          // surface area of full swale (ft2)
    double hydRadius;        // hydraulic radius for current depth (ft)
    double slope;            // slope of swale side wall (run/rise)
    double volume;           // swale volume at current water depth (ft3)
    double dVdT;             // change in volume w.r.t. time (cfs)
    double dStore;           // depression storage depth (ft)
    double xDepth;           // depth above depression storage (ft)

    //... retrieve state variable from work vector
    depth = x[SURF];
    depth = MIN(depth, theLidProc->surface.thickness);

    //... depression storage depth
    dStore = 0.0;

    //... get swale's bottom width
    //    (0.5 ft minimum to avoid numerical problems)
    slope = theLidProc->surface.sideSlope;
    topWidth = theLidUnit->fullWidth;
    topWidth = MAX(topWidth, 0.5);
    botWidth = topWidth - 2.0 * slope * theLidProc->surface.thickness;
    if ( botWidth < 0.5 )
    {
        botWidth = 0.5;
        slope = 0.5 * (topWidth - 0.5) / theLidProc->surface.thickness;
    }

    //... swale's length
    lidArea = theLidUnit->area;
    length = lidArea / topWidth;

    //... top width, surface area and flow area of current ponded depth
    surfWidth = botWidth + 2.0 * slope * depth;
    surfArea = length * surfWidth;
    flowArea = (depth * (botWidth + slope * depth)) *
               theLidProc->surface.voidFrac;

    //... wet volume and effective depth
    volume = length * flowArea;

    //... surface inflow into swale (cfs)
    surfInflow = SurfaceInflow * lidArea;

    //... ET rate in cfs
    SurfaceEvap = EvapRate * surfArea;
    SurfaceEvap = MIN(SurfaceEvap, volume/Tstep);

    //... infiltration rate to native soil in cfs
    StorageExfil = SurfaceInfil * surfArea;

    //... no surface outflow if depth below depression storage
    xDepth = depth - dStore;
    if ( xDepth <= ZERO ) SurfaceOutflow = 0.0;

    //... otherwise compute a surface outflow
    else
    {
        //... modify flow area to remove depression storage,
        flowArea -= (dStore * (botWidth + slope * dStore)) *
                     theLidProc->surface.voidFrac;
        if ( flowArea < ZERO ) SurfaceOutflow = 0.0;
        else
        {
            //... compute hydraulic radius
            botWidth = botWidth + 2.0 * dStore * slope;
            hydRadius = botWidth + 2.0 * xDepth * sqrt(1.0 + slope*slope);
            hydRadius = flowArea / hydRadius;

            //... use Manning Eqn. to find outflow rate in cfs
            SurfaceOutflow = theLidProc->surface.alpha * flowArea *
                             pow(hydRadius, 2./3.);
        }
    }

    //... net flux rate (dV/dt) in cfs
    dVdT = surfInflow - SurfaceEvap - StorageExfil - SurfaceOutflow;

    //... when full, any net positive inflow becomes spillage
    if ( depth == theLidProc->surface.thickness && dVdT > 0.0 )
    {
        SurfaceOutflow += dVdT;
        dVdT = 0.0;
    }

    //... convert flux rates to ft/s
    SurfaceEvap /= lidArea;
    StorageExfil /= lidArea;
    SurfaceOutflow /= lidArea;
    f[SURF] = dVdT / surfArea;
    f[SOIL] = 0.0;
    f[STOR] = 0.0;

    //... assign values to layer volumes
    SurfaceVolume = volume / lidArea;
    SoilVolume = 0.0;
    StorageVolume = 0.0;
}

No comments:

AI Rivers of Wisdom about ICM SWMM

Here's the text "Rivers of Wisdom" formatted with one sentence per line: [Verse 1] 🌊 Beneath the ancient oak, where shadows p...