Showing posts with label SWMM 5.2.2 Code for LID Function barrelFluxRates. Show all posts
Showing posts with label SWMM 5.2.2 Code for LID Function barrelFluxRates. Show all posts

Saturday, January 21, 2023

SWMM 5.2.2 Code for LID Function barrelFluxRates

This code defines a function called "barrelFluxRates" which computes the flux rates for a rain barrel 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 three variables, "storageDepth", "head" and "maxValue" to 0.0. Then it assigns the value of 0.0 to the SurfaceVolume, SoilVolume, and assigns the value of storageDepth to the StorageVolume. The function then initializes the SurfaceInfil, SurfaceOutflow, and StorageDrain to 0.0.

The function then checks if the drain delay is 0.0 or if the dry time is greater than or equal to the drain delay, if it is, it calculates the head and if the head is greater than 0.0, it calculates the StorageDrain using the getStorageDrainRate function, and limits the StorageDrain to the maxValue which is equal to the head divided by the time step.

The function then limits the StorageInflow to the available storage by calculating the maxValue and comparing it to the SurfaceInflow. The SurfaceInfil is then assigned the value of StorageInflow.

Finally, the function assigns the values to the layer flux rates. The SurfaceInflow minus StorageInflow is assigned to f[SURF], the StorageInflow minus StorageDrain is assigned to f[STOR], and 0.0 is assigned to f[SOIL].

VariableDescription
SurfaceVolumeThe volume of water in the surface layer
SoilVolumeThe volume of water in the soil layer
StorageVolumeThe volume of water in the storage layer
SurfaceInfilThe infiltration rate into the surface layer
SurfaceOutflowThe outflow rate from the surface layer
StorageDrainThe drainage rate from the storage layer
StorageInflowThe inflow rate into the storage layer
SurfaceInflowThe inflow rate into the surface layer
theLidProc->drain.delayThe delay time before drainage begins from the storage layer
theLidUnit->dryTimeThe time since the last rain
theLidProc->drain.offsetThe offset for determining the head for drainage
theLidProc->storage.thicknessThe thickness of the storage layer
TstepThe change in time step

Note that this function is specific for rain barrel LID, and it computes the flux rates based on the storage level and the LID properties.



void barrelFluxRates(double x[], double f[])
//
//  Purpose: computes flux rates for a rain barrel LID.
//  Input:   x = vector of storage levels
//  Output:  f = vector of flux rates
//
{
    double storageDepth = x[STOR];
    double head;
    double maxValue;

    //... assign values to layer volumes
    SurfaceVolume = 0.0;
    SoilVolume = 0.0;
    StorageVolume = storageDepth;

    //... initialize flows
    SurfaceInfil = 0.0;
    SurfaceOutflow = 0.0;
    StorageDrain = 0.0;

    //... compute outflow if time since last rain exceeds drain delay
    //    (dryTime is updated in lid.evalLidUnit at each time step)
    if ( theLidProc->drain.delay == 0.0 ||
        theLidUnit->dryTime >= theLidProc->drain.delay )
    {
        head = storageDepth - theLidProc->drain.offset;
        if ( head > 0.0 )
        {
            StorageDrain = getStorageDrainRate(storageDepth, 0.0, 0.0, 0.0);
            maxValue = (head/Tstep);
            StorageDrain = MIN(StorageDrain, maxValue);
        }
    }

    //... limit inflow to available storage
    StorageInflow = SurfaceInflow;
    maxValue = (theLidProc->storage.thickness - storageDepth) / Tstep +
        StorageDrain;
    StorageInflow = MIN(StorageInflow, maxValue);
    SurfaceInfil = StorageInflow;

    //... assign values to layer flux rates
    f[SURF] = SurfaceInflow - StorageInflow;
    f[STOR] = StorageInflow - StorageDrain;
    f[SOIL] = 0.0;
}

Today is day 356 or 97.5 percent of the year 2024

English: Today is day 356 or 97.5 percent of the year 2024 Mandarin Chinese: 今天是2024年的第356天,即97.5% Hindi: आज 2024 का 356वां दिन या 97.5 प्रत...