Showing posts with label SWMM 5.2.2 Code. Show all posts
Showing posts with label SWMM 5.2.2 Code. Show all posts

Saturday, January 21, 2023

SWMM 5.2.2 Code for LID Function getSurfaceOutflowRate

This code defines a function called "getSurfaceOutflowRate" which calculates the outflow rate from a LID's surface layer. The function takes in a depth of ponded water on the surface layer (in feet) and returns the outflow from the surface layer (in feet per second) as output. The function starts by initializing two variables, "delta" and "outflow", to 0.0. Then, it checks if the depth of ponded water is below the storage depth and if it is, it immediately returns 0.0.

Otherwise, the function calculates the outflow from overland flow Manning equation, which is the product of surface layer's alpha, the fifth root of delta, full width of the LID, and the area of the LID. The function also checks if the outflow is greater than the change in time step and if it is, it limits the outflow to the change in time step.

VariableDescription
deltaThe difference between the depth of ponded water and the thickness of the surface layer
outflowThe outflow rate from the surface layer
theLidProc->surface.thicknessThe thickness of the surface layer
theLidProc->surface.alphaThe alpha value used in the overland flow Manning equation
theLidUnit->fullWidthThe full width of the LID
theLidUnit->areaThe area of the LID
TstepThe change in time step

Note that this function should not be applied to swales or rain barrels.



double getSurfaceOutflowRate(double depth)
//
//  Purpose: computes outflow rate from a LID's surface layer.
//  Input:   depth = depth of ponded water on surface layer (ft)
//  Output:  returns outflow from surface layer (ft/s)
//
//  Note: this function should not be applied to swales or rain barrels.
//
{
    double delta;
    double outflow;

    //... no outflow if ponded depth below storage depth
    delta = depth - theLidProc->surface.thickness;
    if ( delta < 0.0 ) return 0.0;

    //... compute outflow from overland flow Manning equation
    outflow = theLidProc->surface.alpha * pow(delta, 5.0/3.0) *
              theLidUnit->fullWidth / theLidUnit->area;
    outflow = MIN(outflow, delta / Tstep);
    return outflow;
}

SWMM 5.2.2 Code for LID Function getPavementPermRate

This code defines a function called "getPavementPermRate" which calculates the reduced permeability of a pavement layer due to clogging. The function does not take in any inputs and returns the reduced permeability of the pavement layer (in feet per second) as output. The function starts by initializing three variables "permReduction", "clogFactor" and "regenDays".

VariableDescription
permReductionThe permeability reduction due to clogging
clogFactorThe clogging factor of the pavement layer
regenDaysThe number of days it takes to regenerate the permeability of the pavement layer

The function then checks if clogFactor is greater than 0.0, if it is, it proceeds to check if regenDays is greater than 0.0. If regenDays is greater than 0.0, the function checks if OldRunoffTime is greater than or equal to the next regeneration day, if it is, the function reduces the total volume treated by the degree of regeneration and updates the next day that regeneration occurs.

Lastly, the function calculates the permeability reduction factor and limits it to 1.0. It then returns the effective pavement permeability by multiplying the pavement's kSat value by (1-permReduction).



double getPavementPermRate()
//
//  Purpose: computes reduced permeability of a pavement layer due to
//           clogging.
//  Input:   none
//  Output:  returns the reduced permeability of the pavement layer (ft/s).
//
{
    double permReduction = 0.0;
    double clogFactor= theLidProc->pavement.clogFactor;
    double regenDays = theLidProc->pavement.regenDays;

    // ... find permeability reduction due to clogging     
    if ( clogFactor > 0.0 )
    {
        // ... see if permeability regeneration has occurred
        //     (regeneration is assumed to reduce the total
        //      volumetric loading that the pavement has received)
        if ( regenDays > 0.0 )
        {
            if ( OldRunoffTime / 1000.0 / SECperDAY >= theLidUnit->nextRegenDay )
            {
                // ... reduce total volume treated by degree of regeneration
                theLidUnit->volTreated *= 
                    (1.0 - theLidProc->pavement.regenDegree);

                // ... update next day that regenration occurs
                theLidUnit->nextRegenDay += regenDays;
            }
        }

        // ... find permeabiity reduction factor
        permReduction = theLidUnit->volTreated / clogFactor;
        permReduction = MIN(permReduction, 1.0);
    }

    // ... return the effective pavement permeability
    return theLidProc->pavement.kSat * (1.0 - permReduction);
}

SWMM 5.2.2 Code for LID Function getStorageExfilRate

 This code defines a function called "getStorageExfilRate" which calculates the exfiltration rate (infiltration rate) of water from a storage zone into the native soil beneath a "LID" (low impact development). The function takes in the depth of the water storage zone (in feet) and returns the infiltration rate (in feet per second) as output. The function starts by initializing two variables, "infil" and "clogFactor", to 0.0. Then, it checks if the storage zone's "kSat" value is 0.0, and if it is, it immediately returns 0.0. If not, it checks if "MaxNativeInfil" is 0.0, and if it is, it also immediately returns 0.0. Next, the function calculates a reduction factor for clogging, and limits the infiltration rate by any groundwater-imposed limits. Finally, the function returns the minimum value of the infiltration rate or the MaxNativeInfil.

double getStorageExfilRate() // // Purpose: computes exfiltration rate from storage zone into // native soil beneath a LID. // Input: depth = depth of water storage zone (ft) // Output: returns infiltration rate (ft/s) // { double infil = 0.0; double clogFactor = 0.0; if ( theLidProc->storage.kSat == 0.0 ) return 0.0; if ( MaxNativeInfil == 0.0 ) return 0.0; //... reduction due to clogging clogFactor = theLidProc->storage.clogFactor; if ( clogFactor > 0.0 ) { clogFactor = theLidUnit->waterBalance.inflow / clogFactor; clogFactor = MIN(clogFactor, 1.0); } //... infiltration rate = storage Ksat reduced by any clogging infil = theLidProc->storage.kSat * (1.0 - clogFactor); //... limit infiltration rate by any groundwater-imposed limit return MIN(infil, MaxNativeInfil);

SWMM 5.2.2 Code for LID Function getSoilPercRate

 This code defines a function called "getSoilPercRate" that takes in a single input, "theta", which represents the moisture content (fraction). The function then calculates the percolation rate of water through a LID's soil layer and returns this value as output (in units of ft/s). The function first checks if the soil moisture is less than or equal to the field capacity, and if so, the function returns 0.0 (no percolation). If the soil moisture exceeds the field capacity, the function calculates the percolation rate as the unsaturated hydraulic conductivity and returns this value.


double getSoilPercRate(double theta) // // Purpose: computes percolation rate of water through a LID's soil layer. // Input: theta = moisture content (fraction) // Output: returns percolation rate within soil layer (ft/s) // { double delta; // moisture deficit // ... no percolation if soil moisture <= field capacity if ( theta <= theLidProc->soil.fieldCap ) return 0.0; // ... perc rate = unsaturated hydraulic conductivity delta = theLidProc->soil.porosity - theta; return theLidProc->soil.kSat * exp(-delta * theLidProc->soil.kSlope);

Tuesday, January 17, 2023

SWMM 5.2.2 Code for LID Process in LID.h

 This code defines a struct named "TLidProc" which represents the LID (Low Impact Development) process, which is a generic LID design per unit of area.

The struct contains the following fields:

FieldTypeDescription
IDchar*identifying name of the LID process
lidTypeinttype of LID (corresponds to an enumerator from the "LidTypes" enumeration)
surfaceTSurfaceLayersurface layer parameters
pavementTPavementLayerpavement layer parameters
soilTSoilLayersoil layer parameters
storageTStorageLayerstorage layer parameters
drainTDrainLayerunderdrain system parameters
drainMatTDrainMatLayerdrainage mat layer
drainRmvldouble*underdrain pollutant removals

The "ID" field is a string that can be used to identify the specific LID process. The "lidType" field is an integer that corresponds to one of the enumerators from the "LidTypes" enumeration. This allows the code to determine the specific type of LID process represented by this struct.

The "surface", "pavement", "soil", "storage", "drain" and "drainMat" fields are structs themselves and they contain specific parameters for the surface layer, pavement layer, soil layer, storage layer, underdrain system and drainage mat layer respectively. The "drainRmvl" field is a pointer to an array of doubles, which represent the underdrain pollutant removals.

This struct is used to store all the information about a specific LID process and can be used to design and simulate the performance of the LID unit. The struct also contains information about different layers of LID unit, like surface layer, soil layer and storage layer which helps to simulate the performance of LID unit.


// LID Process - generic LID design per unit of area typedef struct { char* ID; // identifying name int lidType; // type of LID TSurfaceLayer surface; // surface layer parameters TPavementLayer pavement; // pavement layer parameters TSoilLayer soil; // soil layer parameters TStorageLayer storage; // storage layer parameters TDrainLayer drain; // underdrain system parameters TDrainMatLayer drainMat; // drainage mat layer double* drainRmvl; // underdrain pollutant removals } TLidProc;

SWMM 5.2.2 Code for Defining LID data in LID.h

 This code defines several structs that are used to store information about different layers of a LID (Low Impact Development) unit. The structs define the properties of each layer, such as thickness, porosity, permeability, and other parameters that are specific to each layer.

The structs defined in this code are:

Struct NameDescription
TSurfaceLayerInformation about the surface layer of the LID unit, such as depression storage or berm height, roughness, slope, and alpha term in Manning equation.
TPavementLayerInformation about the pavement layer of the LID unit, such as thickness, void fraction, permeability, clogging factor, and regeneration interval.
TSoilLayerInformation about the soil layer of the LID unit, such as thickness, porosity, field capacity, wilting point, suction, saturated hydraulic conductivity.
TStorageLayerInformation about the storage layer of the LID unit, such as thickness, void fraction, saturated hydraulic conductivity, clogging factor and information about whether it is covered or not.
TDrainLayerInformation about the underdrain system of the LID unit, such as flow coefficient, head exponent, offset height, delay time, head when drain opens and closes, flow rate curve.
TDrainMatLayerInformation about the drainage mat layer of the LID unit, such as thickness, void fraction, roughness, slope/roughness term in Manning equation.

The fields of all the structs are double type except for the "covered" field which is of int type.

The code also defines a MAX_LAYERS macro which is set to 4. This macro is used as a constant throughout the code to specify the maximum number of layers that are allowed in the LID unit.

This way, the code defines the different layers of LID unit and the properties of each layer with the help of structs. This makes it easy to simulate and analyze the performance of LID unit by using these structs to store the information about different layers and their properties.



#define MAX_LAYERS 4 // LID Surface Layer typedef struct { double thickness; // depression storage or berm ht. (ft) double voidFrac; // available fraction of storage volume double roughness; // surface Mannings n double surfSlope; // land surface slope (fraction) double sideSlope; // swale side slope (run/rise) double alpha; // slope/roughness term in Manning eqn. char canOverflow; // 1 if immediate outflow of excess water } TSurfaceLayer; // LID Pavement Layer typedef struct { double thickness; // layer thickness (ft) double voidFrac; // void volume / total volume double impervFrac; // impervious area fraction double kSat; // permeability (ft/sec) double clogFactor; // clogging factor double regenDays; // clogging regeneration interval (days) double regenDegree; // degree of clogging regeneration } TPavementLayer; // LID Soil Layer typedef struct { double thickness; // layer thickness (ft) double porosity; // void volume / total volume double fieldCap; // field capacity double wiltPoint; // wilting point double suction; // suction head at wetting front (ft) double kSat; // saturated hydraulic conductivity (ft/sec) double kSlope; // slope of log(K) v. moisture content curve } TSoilLayer; // LID Storage Layer typedef struct { double thickness; // layer thickness (ft) double voidFrac; // void volume / total volume double kSat; // saturated hydraulic conductivity (ft/sec) double clogFactor; // clogging factor int covered; // TRUE if rain barrel is covered } TStorageLayer; // Underdrain System (part of Storage Layer) typedef struct { double coeff; // underdrain flow coeff. (in/hr or mm/hr) double expon; // underdrain head exponent (for in or mm) double offset; // offset height of underdrain (ft) double delay; // rain barrel drain delay time (sec) double hOpen; // head when drain opens (ft) double hClose; // head when drain closes (ft) int qCurve; // curve controlling flow rate (optional) } TDrainLayer; // Drainage Mat Layer (for green roofs) typedef struct { double thickness; // layer thickness (ft) double voidFrac; // void volume / total volume double roughness; // Mannings n for green roof drainage mats double alpha; // slope/roughness term in Manning equation } TDrainMatLayer;

The Goal of SWMM5 Input Files

 🌟 SWMM5 (Storm Water Management Model 5) is a widely used urban hydrology and hydraulic modeling software developed by the United States E...