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

Tuesday, January 17, 2023

SWMM 5.2.2 Code for LID Storage Layer

 

Variable NameTypeDescription
thicknessdoublethe layer thickness (ft)
voidFracdoublethe void volume / total volume
kSatdoublesaturated hydraulic conductivity (ft/sec)
clogFactordoubleclogging factor
coveredintBoolean flag indicating if rain barrel is covered (TRUE if it is covered)

This code defines a struct called TStorageLayer, which represents a storage layer in a Low Impact Development (LID) system. The struct contains several variables:

  • thickness: a double that represents the thickness of the layer, in feet.
  • voidFrac: a double that represents the void volume of the layer over the total volume of the layer.
  • kSat: a double that represents the saturated hydraulic conductivity, the rate at which water can flow through the soil, in feet per second.
  • clogFactor: a double that represents the clogging factor, which can be used to account for the potential reduction of the saturated hydraulic conductivity due to clogging or other factors.
  • covered: an integer that is a Boolean flag indicating if the rain barrel is covered. This is set to TRUE if the rain barrel is covered and FALSE otherwise.

The struct is used to store information about the LID storage layer, which can then be used in various calculations and simulations related to the LID system. The struct is usually used along with other parameters such as precipitation, infiltration, and evapotranspiration to evaluate the water management of the LID system.



// 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;

SWMM 5.2.2 Code for Drainage Mat Layer (for green roofs)

 

Variable NameTypeDescription
thicknessdoublethe layer thickness (ft)
voidFracdoublethe void volume / total volume
roughnessdoubleMannings n for green roof drainage mats
alphadoubleslope/roughness term in Manning equation

This code defines a struct called TDrainMatLayer, which represents a Drainage Mat Layer commonly used in green roofs. The struct contains several variables:

  • thickness: a double that represents the thickness of the layer, in feet.
  • voidFrac: a double that represents the void volume of the layer over the total volume of the layer.
  • roughness: a double that represents the Mannings n, a roughness coefficient used in the calculation of flow through open channels, for green roof drainage mats.
  • alpha: a double that represents the slope/roughness term in the Manning equation, used to estimate the resistance to flow in open channels.

The struct is used to store information about the Drainage Mat Layer, which can then be used in various calculations and simulations related to green roofs. This struct is usually used along with other layers and other parameters to evaluate the water management of green roofs.




// 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;

SWMM 5.2.2 Underdrain System (part of Storage Layer) Code

 

Variable NameTypeDescription
coeffdoubleunderdrain flow coefficient (in/hr or mm/hr)
expondoubleunderdrain head exponent (for in or mm)
offsetdoubleoffset height of underdrain (ft)
delaydoublerain barrel drain delay time (sec)
hOpendoublehead when drain opens (ft)
hClosedoublehead when drain closes (ft)
qCurveintcurve controlling flow rate (optional)

This code defines a struct called TDrainLayer, which represents an underdrain system as part of a storage layer. The struct contains several variables:

  • coeff: a double representing the underdrain flow coefficient, in units of in/hr or mm/hr.
  • expon: a double representing the underdrain head exponent, used to calculate the head loss through the underdrain.
  • offset: a double representing the offset height of the underdrain, in feet.
  • delay: a double that represents the delay time for the rain barrel drain, in seconds.
  • hOpen: a double representing the head at which the drain opens, in feet.
  • hClose: a double representing the head at which the drain closes, in feet.
  • qCurve: an integer that represents the curve controlling the flow rate of the underdrain. This is optional and may not be used in all cases.

The struct is used to store information about the underdrain system, which can then be used in various calculations and simulations related to the storage layer.





// 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;

Sunday, January 15, 2023

SWMM 5.2.2 Code for LID Function getEvapRates

This code is for calculating evaporation rates for a low impact development (LID) unit, specifically for the surface layer, pavement, soil, and storage layer. It takes in the volumes/areas of water in each layer (surfaceVol, paveVol, soilVol, and storageVol) as well as the fraction of the surface layer that is pervious (pervFrac) as inputs. It also uses a global variable EvapRate. The function first calculates the available evaporation rate and then calculates the evaporation rate for each layer using the MIN and MAX functions to ensure the evaporation rate does not exceed the available evaporation rate or the volume of water in the layer. The evaporation rate for the surface layer is multiplied by the fraction of the surface layer that is pervious. If the SurfaceInfil variable is greater than zero, the evaporation rates for the pavement, soil, and storage layers are set to zero. The code also uses Tstep variable to convert the rate to total volume over the current time step. The output of this function is updating the member variable SurfaceEvap, PaveEvap, SoilEvap, and StorageEvap and doesn't return any value.

void getEvapRates(double surfaceVol, double paveVol, double soilVol,
    double storageVol, double pervFrac)
//
//  Purpose: computes surface, pavement, soil, and storage evaporation rates.
//  Input:   surfaceVol = volume/area of ponded water on surface layer (ft)
//           paveVol    = volume/area of water in pavement pores (ft)
//           soilVol    = volume/area of water in soil (or pavement) pores (ft)
//           storageVol = volume/area of water in storage layer (ft)
//           pervFrac   = fraction of surface layer that is pervious
//  Output:  none
//
{
    double availEvap;

    //... surface evaporation flux
    availEvap = EvapRate;
    SurfaceEvap = MIN(availEvap, surfaceVol/Tstep);
    SurfaceEvap = MAX(0.0, SurfaceEvap);
    availEvap = MAX(0.0, (availEvap - SurfaceEvap));
    availEvap *= pervFrac;

    //... no subsurface evap if water is infiltrating
    if ( SurfaceInfil > 0.0 )
    {
        PaveEvap = 0.0;
        SoilEvap = 0.0;
        StorageEvap = 0.0;
    }
    else
    {
        //... pavement evaporation flux
        PaveEvap = MIN(availEvap, paveVol / Tstep);
        availEvap = MAX(0.0, (availEvap - PaveEvap));

        //... soil evaporation flux
        SoilEvap = MIN(availEvap, soilVol / Tstep);
        availEvap = MAX(0.0, (availEvap - SoilEvap));

        //... storage evaporation flux
        StorageEvap = MIN(availEvap, storageVol / Tstep);
    }
}

}

SWMM 5.2.2 Function for LID getSurfaceOverflowRate

 This code is for calculating the surface overflow rate from a low impact development (LID) unit. It takes in the surface depth of water stored in the surface layer as an input, and returns the overflow rate in cubic feet per second. It calculates the overflow rate by first determining the difference between the surface depth and the LID unit's surface layer thickness. If this difference is less than or equal to zero, the function returns zero, indicating no overflow. Otherwise, it sets the surface depth to the surface layer thickness, and calculates the overflow rate as the difference times the void fraction of the surface layer divided by the time step (Tstep).


double getSurfaceOverflowRate(double* surfaceDepth) // // Purpose: finds surface overflow rate from a LID unit. // Input: surfaceDepth = depth of water stored in surface layer (ft) // Output: returns the overflow rate (ft/s) // { double delta = *surfaceDepth - theLidProc->surface.thickness; if ( delta <= 0.0 ) return 0.0; *surfaceDepth = theLidProc->surface.thickness; return delta * theLidProc->surface.voidFrac / Tstep; }

SWMM 5.2.2 Function for LID updateWaterBalance

 This code is for updating the water balance for a low impact development (LID) unit. It takes in several input parameters such as inflow, evaporation, infiltration, surface flow, drain flow, and storage. It then calculates the volume of water treated, and updates the water balance object for the LID unit with the inflow, evaporation, infiltration, surface flow, drain flow, and final volume of water stored in the unit. The time step (Tstep) is used to convert the rates to total volumes for the current time step. The output of this function is updating the member variables of the passed in LID unit and doesn't return any value.

void updateWaterBalance(TLidUnit *lidUnit, double inflow, double evap, double infil, double surfFlow, double drainFlow, double storage) // // Purpose: updates components of the water mass balance for a LID unit // over the current time step. // Input: lidUnit = a particular LID unit // inflow = runon + rainfall to the LID unit (ft/s) // evap = evaporation rate from the unit (ft/s) // infil = infiltration out the bottom of the unit (ft/s) // surfFlow = surface runoff from the unit (ft/s) // drainFlow = underdrain flow from the unit // storage = volume of water stored in the unit (ft) // Output: none // { lidUnit->volTreated += inflow * Tstep; lidUnit->waterBalance.inflow += inflow * Tstep; lidUnit->waterBalance.evap += evap * Tstep; lidUnit->waterBalance.infil += infil * Tstep; lidUnit->waterBalance.surfFlow += surfFlow * Tstep; lidUnit->waterBalance.drainFlow += drainFlow * Tstep; lidUnit->waterBalance.finalVol = storage; }

What Does "Percent Not Converging" Mean in SWMM5?

What Does "Percent Not Converging" Mean in SWMM5? The SWMM 5 Routing Time Step Summary is your window into the model's heart, ...