OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
lid.c File Reference

Low-impact development controls, usage, and state. More...

#include <math.h>
#include "headers.h"
#include "lid.h"
Include dependency graph for lid.c:

Classes

struct  LidList
 
struct  LidGroup
 

Macros

#define _CRT_SECURE_NO_DEPRECATE
 
#define ERR_PAVE_LAYER   " - check pavement layer parameters"
 
#define ERR_SOIL_LAYER   " - check soil layer parameters"
 
#define ERR_STOR_LAYER   " - check storage layer parameters"
 
#define ERR_SWALE_SURF   " - check swale surface parameters"
 
#define ERR_GREEN_AMPT   " - check subcatchment Green-Ampt parameters"
 
#define ERR_DRAIN_OFFSET   " - drain offset exceeds storage height"
 
#define ERR_DRAIN_HEADS   " - invalid drain open/closed heads"
 
#define ERR_SWALE_WIDTH   " - invalid swale width"
 

Typedefs

typedef struct LidList TLidList
 
typedef struct LidGroup * TLidGroup
 

Enumerations

enum  LidLayerTypes {
  SURF ,
  SOIL ,
  STOR ,
  PAVE ,
  DRAINMAT ,
  DRAIN ,
  REMOVALS
}
 

Functions

void lid_create (int lidCount, int subcatchCount)
 Allocate LID process definitions and per-subcatchment LID group storage.
 
void lid_delete ()
 Deletes all LID objects.
 
int lid_readProcParams (char *toks[], int ntoks)
 Reads LID process information from line of input data file.
 
int lid_readGroupParams (char *toks[], int ntoks)
 Reads input data for a LID unit placed in a subcatchment.
 
int lid_setDrainParams (int lidIndex, double coeff, double expon, double offset)
 Updates the underdrain flow parameters of a LID process at runtime (API support). The drain parameters are read live each step (lidproc.c), so an edit takes effect on the next step.
 
void lid_writeSummary ()
 Writes summary of LID processes used to report file.
 
void lid_validate ()
 Validates LID process and group parameters.
 
void lid_initState ()
 Initializes the internal state of each LID in a subcatchment.
 
void lid_setOldGroupState (int j)
 Saves the current drain flow rate for the LIDs in a subcatchment.
 
double lid_getPervArea (int j)
 Retrieves amount of pervious LID area in a subcatchment.
 
double lid_getFlowToPerv (int j)
 Retrieves flow returned from LID treatment to pervious area of a subcatchment.
 
double lid_getStoredVolume (int j)
 Computes stored volume of water for all LIDs grouped within a subcatchment.
 
double lid_getDrainFlow (int j, int timePeriod)
 Select the previous or current total LID drain flow of a subcatchment.
 
void lid_addDrainLoads (int j, double c[], double tStep)
 Add LID drain pollutant export and BMP removal to mass-balance totals.
 
void lid_addDrainRunon (int j)
 Route previous-period LID drain flow and pollutant loads to receiving subcatchments.
 
void lid_addDrainInflow (int j, double f)
 Add temporally interpolated LID drain inflows to conveyance nodes.
 
void lid_getRunoff (int j, double tStep)
 Advance LID units and compute runoff, drain and return flows.
 
void lid_writeWaterBalance ()
 Writes a LID performance summary table to the project's report file.
 

Variables

char * LidLayerWords []
 
char * LidTypeWords []
 
double Vevap
 
double Vpevap
 
double Vinfil
 
double VlidInfil
 
double VlidIn
 
double VlidOut
 
double VlidDrain
 
double VlidReturn
 
char HasWetLids
 

Detailed Description

Low-impact development controls, usage, and state.

Author
Caleb Buahin caleb.nosp@m..bua.nosp@m.hin@g.nosp@m.mail.nosp@m..com (OpenSWMM maintenance and extensions)
License
Apache-2.0 for OpenSWMM contributions; original EPA SWMM provenance is retained.

Macro Definition Documentation

◆ _CRT_SECURE_NO_DEPRECATE

#define _CRT_SECURE_NO_DEPRECATE

◆ ERR_DRAIN_HEADS

#define ERR_DRAIN_HEADS   " - invalid drain open/closed heads"

◆ ERR_DRAIN_OFFSET

#define ERR_DRAIN_OFFSET   " - drain offset exceeds storage height"

◆ ERR_GREEN_AMPT

#define ERR_GREEN_AMPT   " - check subcatchment Green-Ampt parameters"

◆ ERR_PAVE_LAYER

#define ERR_PAVE_LAYER   " - check pavement layer parameters"

◆ ERR_SOIL_LAYER

#define ERR_SOIL_LAYER   " - check soil layer parameters"

◆ ERR_STOR_LAYER

#define ERR_STOR_LAYER   " - check storage layer parameters"

◆ ERR_SWALE_SURF

#define ERR_SWALE_SURF   " - check swale surface parameters"

◆ ERR_SWALE_WIDTH

#define ERR_SWALE_WIDTH   " - invalid swale width"

Typedef Documentation

◆ TLidGroup

typedef struct LidGroup* TLidGroup

◆ TLidList

typedef struct LidList TLidList

Enumeration Type Documentation

◆ LidLayerTypes

Enumerator
SURF 
SOIL 
STOR 
PAVE 
DRAINMAT 
DRAIN 
REMOVALS 

Function Documentation

◆ lid_addDrainInflow()

void lid_addDrainInflow ( int j,
double f )

Add temporally interpolated LID drain inflows to conveyance nodes.

Parameters
[in]jValid contributing subcatchment index.
[in]fCurrent-period interpolation weight, normally in [0, 1]; old values use weight 1 - f and the function does not clamp extrapolation.
Postcondition
Updates receiving Node.newLatFlow and newQual loading rates and wet-weather mass-balance totals, after applying drain pollutant removal.
Here is the call graph for this function:

◆ lid_addDrainLoads()

void lid_addDrainLoads ( int j,
double c[],
double tStep )

Add LID drain pollutant export and BMP removal to mass-balance totals.

Parameters
[in]jValid contributing subcatchment index.
[in]cBorrowed Nobjects[POLLUT] concentration array, in pollutant mass per liter.
[in]tStepRunoff interval in seconds.
Postcondition
Updates loading totals for BMP_REMOVAL_LOAD and eligible RUNOFF_LOAD. Drain-to-pervious units are excluded; absent LID groups perform no action.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ lid_addDrainRunon()

void lid_addDrainRunon ( int j)

Route previous-period LID drain flow and pollutant loads to receiving subcatchments.

Parameters
[in]jValid contributing subcatchment index.
Postcondition
Adds drain runon and pollutant loading rates to configured receiving subcatchments. Uses oldDrainFlow and the source oldQual, adjusted by drain removal. No action is taken when the source has no LID group.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ lid_create()

void lid_create ( int lidCount,
int subcatchCount )

Allocate LID process definitions and per-subcatchment LID group storage.

Parameters
[in]lidCountNonnegative number of LID process definitions.
[in]subcatchCountNonnegative number of subcatchment group slots.
Postcondition
Initializes module pointers/counts and default layer properties. Each process receives a pollutant-removal array. Allocation failure sets ErrorCode to ERR_MEMORY and leaves partial allocations for lid_delete().
Precondition
Previous project LID storage has already been released.

◆ lid_delete()

void lid_delete ( void )

Deletes all LID objects.

◆ lid_getDrainFlow()

double lid_getDrainFlow ( int j,
int timePeriod )

Select the previous or current total LID drain flow of a subcatchment.

Parameters
[in]jValid subcatchment/LidGroups index.
[in]timePeriodPREVIOUS selects oldDrainFlow; any other value selects newDrainFlow.
Returns
Drain flow in cubic feet per second, or zero when no LID group exists.
Here is the caller graph for this function:

◆ lid_getFlowToPerv()

double lid_getFlowToPerv ( int j)

Retrieves flow returned from LID treatment to pervious area of a subcatchment.

Parameters
[in]jSubcatchment index.
Returns
Flow returned to pervious area (cfs).
Here is the caller graph for this function:

◆ lid_getPervArea()

double lid_getPervArea ( int j)

Retrieves amount of pervious LID area in a subcatchment.

Parameters
[in]jSubcatchment index.
Returns
Amount of pervious LID area (ft2).
Here is the caller graph for this function:

◆ lid_getRunoff()

void lid_getRunoff ( int j,
double tStep )

Advance LID units and compute runoff, drain and return flows.

Parameters
[in]jValid subcatchment index with initialized runoff state.
[in]tStepPositive runoff interval in seconds.
Postcondition
Updates LID states, group newDrainFlow/flowToPerv, and shared evaporation, infiltration, inflow, runoff, drain and return volumes. Flow rates use cfs and interval volumes use cubic feet. Missing groups or lists return unchanged.
Note
Operates on shared current-subcatchment flux state and is not reentrant.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ lid_getStoredVolume()

double lid_getStoredVolume ( int j)

Computes stored volume of water for all LIDs grouped within a subcatchment.

Parameters
[in]jSubcatchment index.
Returns
Stored volume of water (ft3).
Here is the caller graph for this function:

◆ lid_initState()

void lid_initState ( void )

Initializes the internal state of each LID in a subcatchment.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lid_readGroupParams()

int lid_readGroupParams ( char * toks[],
int ntoks )

Reads input data for a LID unit placed in a subcatchment.

Parameters
toksArray of string tokens.
[in]ntoksNumber of tokens.
Returns
Error code Format of input data line is: Subcatch_ID LID_ID Number Area Width InitSat FromImp ToPerv (RptFile DrainTo FromPerv) where: Subcatch_ID = name of subcatchment LID_ID = name of LID process Number (n) = number of replicate units Area (x[0]) = area of each unit Width (x[1]) = outflow width of each unit InitSat (x[2]) = % that LID is initially saturated FromImp (x[3]) = % of impervious runoff sent to LID ToPerv (x[4]) = 1 if outflow goes to pervious sub-area; 0 if not RptFile = name of detailed results file (optional) DrainTo = name of subcatch/node for drain flow (optional) FromPerv (x[5]) = % of pervious runoff sent to LID.
Here is the call graph for this function:

◆ lid_readProcParams()

int lid_readProcParams ( char * toks[],
int ntoks )

Reads LID process information from line of input data file.

Parameters
toksArray of string tokens.
[in]ntoksNumber of tokens.
Returns
Error code Format for first line that defines a LID process is: LID_ID LID_Type Followed by some combination of lines below depending on LID_Type: LID_ID SURFACE parameters LID_ID PAVEMENT parameters LID_ID SOIL parameters LID_ID STORAGE parameters LID_ID DRAIN parameters LID_ID DRAINMAT parameters LID_ID REMOVALS parameters.
Here is the call graph for this function:

◆ lid_setDrainParams()

int lid_setDrainParams ( int lidIndex,
double coeff,
double expon,
double offset )

Updates the underdrain flow parameters of a LID process at runtime (API support). The drain parameters are read live each step (lidproc.c), so an edit takes effect on the next step.

Parameters
[in]lidIndexLID process index.
[in]coeffUnderdrain flow coeff. (in/hr or mm/hr).
[in]exponUnderdrain head exponent.
[in]offsetOffset height of underdrain (in or mm).
Returns
0 if successful, 1 for a bad index, 2 for a bad value (units match readDrainData; the API wrapper maps the codes).
Here is the call graph for this function:

◆ lid_setOldGroupState()

void lid_setOldGroupState ( int j)

Saves the current drain flow rate for the LIDs in a subcatchment.

Parameters
[in]jSubcatchment index.
Here is the caller graph for this function:

◆ lid_validate()

void lid_validate ( void )

Validates LID process and group parameters.

Here is the caller graph for this function:

◆ lid_writeSummary()

void lid_writeSummary ( void )

Writes summary of LID processes used to report file.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lid_writeWaterBalance()

void lid_writeWaterBalance ( void )

Writes a LID performance summary table to the project's report file.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ HasWetLids

char HasWetLids
extern

◆ LidLayerWords

char* LidLayerWords[]
Initial value:
= {"SURFACE", "SOIL", "STORAGE", "PAVEMENT",
"DRAINMAT", "DRAIN", "REMOVALS", NULL}

Note: DRAINMAT must be placed before DRAIN so the two keywords can be distinguished from one another when parsing a line of input.

◆ LidTypeWords

char* LidTypeWords[]
Initial value:
= {"BC",
"RG",
"GR",
"IT",
"PP",
"RB",
"VS",
"RD",
NULL}

◆ Vevap

double Vevap
extern

◆ Vinfil

double Vinfil
extern

◆ VlidDrain

double VlidDrain
extern

◆ VlidIn

double VlidIn
extern

◆ VlidInfil

double VlidInfil
extern

◆ VlidOut

double VlidOut
extern

◆ VlidReturn

double VlidReturn
extern

◆ Vpevap

double Vpevap
extern