This code is a function called "trenchFluxRates" that calculates flux rates from the layers of an infiltration trench LID. It takes in two input arrays, "x" and "f", which represent the vector of storage levels and the vector of flux rates, respectively. The function uses several intermediate variables, including "availVolume" and "maxRate". It also makes use of several properties of the storage layer, such as "storageThickness" and "storageVoidFrac".
The code first retrieves the moisture levels from the input vector "x" and converts them to volumes. It then calculates the ET rates and nominal storage inflow, as well as the exfiltration rate out of the storage layer. The code also checks for underdrain flow and limits the exfiltration rate and underdrain flow by available volume. The storage inflow is limited to not exceed the storage layer capacity. Finally, the function finds the net fluxes for each layer and stores them in the output array "f".
A table of the variables used in this function and their descriptions is as follows:
Variable Name | Description |
---|
x[SURF], x[STOR] | Input vector of storage levels |
f[SURF], f[STOR], f[SOIL] | Output vector of flux rates |
surfaceDepth | Moisture level variable for the surface layer |
storageDepth | Moisture level variable for the storage layer |
availVolume | Intermediate variable for available volume |
maxRate | Intermediate variable for maximum rate |
storageThickness | Property of the storage layer representing its thickness |
storageVoidFrac | Property of the storage layer representing its void fraction |
SurfaceVolume | Converted surface moisture level to volume |
SoilVolume | Converted soil moisture level to volume |
StorageVolume | Converted storage moisture level to volume |
SurfaceInflow | Rate of inflow to the surface layer |
SurfaceEvap | Rate of evaporation from the surface layer |
SurfaceOutflow | Rate of outflow from the surface layer |
StorageInflow | Rate of inflow to the storage layer |
StorageEvap | Rate of evaporation from the storage layer |
StorageExfil | Rate of exfiltration from the storage layer |
StorageDrain | Rate of underdrain flow from the storage layer |
Tstep | Time step |
theLidProc | Pointer to LID process data |
void trenchFluxRates(double x[], double f[])
//
// Purpose: computes flux rates from the layers of an infiltration trench LID.
// Input: x = vector of storage levels
// Output: f = vector of flux rates
//
{
// Moisture level variables
double surfaceDepth;
double storageDepth;
// Intermediate variables
double availVolume;
double maxRate;
// Storage layer properties
double storageThickness = theLidProc->storage.thickness;
double storageVoidFrac = theLidProc->storage.voidFrac;
//... retrieve moisture levels from input vector
surfaceDepth = x[SURF];
storageDepth = x[STOR];
//... convert moisture levels to volumes
SurfaceVolume = surfaceDepth * theLidProc->surface.voidFrac;
SoilVolume = 0.0;
StorageVolume = storageDepth * storageVoidFrac;
//... get ET rates
availVolume = (storageThickness - storageDepth) * storageVoidFrac;
getEvapRates(SurfaceVolume, 0.0, 0.0, StorageVolume, 1.0);
//... no storage evap if surface ponded
if ( surfaceDepth > 0.0 ) StorageEvap = 0.0;
//... nominal storage inflow
StorageInflow = SurfaceInflow + SurfaceVolume / Tstep;
//... exfiltration rate out of storage layer
StorageExfil = getStorageExfilRate();
//... underdrain flow rate
StorageDrain = 0.0;
if ( theLidProc->drain.coeff > 0.0 )
{
StorageDrain = getStorageDrainRate(storageDepth, 0.0, 0.0, surfaceDepth);
}
//... limit storage exfiltration by available storage volume
maxRate = StorageInflow - StorageEvap + storageDepth*storageVoidFrac/Tstep;
StorageExfil = MIN(StorageExfil, maxRate);
StorageExfil = MAX(StorageExfil, 0.0);
//... limit underdrain flow by volume above drain offset
if ( StorageDrain > 0.0 )
{
maxRate = -StorageExfil - StorageEvap;
if (storageDepth >= storageThickness ) maxRate += StorageInflow;
if ( theLidProc->drain.offset <= storageDepth )
{
maxRate += (storageDepth - theLidProc->drain.offset) *
storageVoidFrac/Tstep;
}
maxRate = MAX(maxRate, 0.0);
StorageDrain = MIN(StorageDrain, maxRate);
}
//... limit storage inflow to not exceed storage layer capacity
maxRate = (storageThickness - storageDepth)*storageVoidFrac/Tstep +
StorageExfil + StorageEvap + StorageDrain;
StorageInflow = MIN(StorageInflow, maxRate);
//... equate surface infil to storage inflow
SurfaceInfil = StorageInflow;
//... find surface outflow rate
SurfaceOutflow = getSurfaceOutflowRate(surfaceDepth);
// ... find net fluxes for each layer
f[SURF] = SurfaceInflow - SurfaceEvap - StorageInflow - SurfaceOutflow /
theLidProc->surface.voidFrac;;
f[STOR] = (StorageInflow - StorageEvap - StorageExfil - StorageDrain) /
theLidProc->storage.voidFrac;
f[SOIL] = 0.0;
}
No comments:
Post a Comment