Sunday, December 29, 2024

SWMM5 Delphi GUI Ulid.pas Summary

 Extended and Expanded Summary of the Ulid.pas Unit

The Ulid.pas unit in EPA SWMM provides functionality for managing Low Impact Development (LID) controls and their assignment to subcatchments. LID controls represent various best management practices such as bio-retention cells, infiltration trenches, permeable pavement, and so on.

Below is a thorough overview of:

  1. Purpose and Scope
  2. Core Data Structures
  3. Key Constants
  4. Important Routines
  5. Workflow (How LIDs are read, stored, and used)
  6. Integration With Other Units

1. Purpose and Scope

Ulid.pas handles:

  • The creation, editing, and storage of LID process data (e.g., infiltration trench geometry, green roof layers, or underdrain parameters).
  • The definition of LID usage in specific subcatchments (e.g., how many units of permeable pavement in a subcatchment, or the fraction of impervious runoff directed to a bio-retention cell).
  • Reading LID controls from project input files and writing them back out to text.
  • Integrating LIDs into the subcatchment object model used by SWMM.

2. Core Data Structures

2.1 LID Process Class: TLid

TLid = class(TObject)
  ProcessType  : Integer;
  SurfaceLayer : array [0..4] of String;
  PavementLayer: array [0..6] of String;
  SoilLayer    : array [0..6] of String;
  StorageLayer : array [0..4] of String;
  DrainLayer   : array [0..6] of String;
  DrainMatLayer: array [0..2] of String;
  DrainRemovals: TStringlist;
  constructor Create;
  destructor Destroy; override;
end;

Each TLid instance holds parameters for a specific LID control design:

  • ProcessType: Identifies which type of LID (bio-cell, green roof, infiltration trench, etc.).
  • SurfaceLayer: An array of strings defining surface layer properties.
  • PavementLayer: For permeable pavement.
  • SoilLayer: Soil layer parameters.
  • StorageLayer: Storage layer parameters (e.g., thickness, void ratio).
  • DrainLayer: Underdrain (e.g., orifice or weir) parameters.
  • DrainMatLayer: Drainage mat properties (used in green roofs).
  • DrainRemovals: Pollutant-specific removal efficiencies for the underdrain outflow.

A TLid object is stored in Project.Lists[LID].

2.2 LID Unit Class: TLidUnit

TLidUnit = class(TObject)
  Data: array[0..9] of String;
end;

Each TLidUnit object represents the application of a specific LID process within a subcatchment:

  • The array Data[0..9] holds usage parameters, e.g., number of units, area, initial moisture, drainage outlet, etc.

LID units (one or more) are stored in a subcatchment’s LIDs string list (with the LID name as the string, and a TLidUnit object as the Objects[] element).


3. Key Constants

  1. LID Process Types

    BIO_CELL, RAIN_GARDEN, GREEN_ROOF, INFIL_TRENCH,
    PERM_PAVE, RAIN_BARREL, ROOF_DISCON, VEG_SWALE
    
  2. LID Process Layers

    SURFACE_LAYER, PAVEMENT_LAYER, SOIL_LAYER, STORAGE_LAYER,
    DRAIN_LAYER, DRAINMAT_LAYER, DRAIN_REMOVALS
    
  3. LID Unit Parameters (indices for TLidUnit.Data[])

    UNIT_COUNT, UNIT_AREA, UNIT_WIDTH, INIT_MOISTURE,
    FROM_IMPERV, ROUTE_TO, RPT_FILE_NAME, DRAIN_TO, FROM_PERV, ...
    

    These define how many units are installed, how big they are, how they’re connected, etc.

  4. Default layer property arrays (e.g., DefSurfaceLayer, DefPavementLayer, etc.)
    Provide fallback or initial parameter values.


4. Important Routines

4.1 LID Creation and Editing

  1. EditLID(const I: Integer): String;

    • Launches a form (TLidControlDlg) to create or edit a TLid object.
    • If I < 0, a new TLid is created. If I >= 0, an existing LID is edited.
    • On success, returns the final name of the LID.
  2. UpdateLIDName(const OldName, NewName: String);

    • Replaces all references to LID OldName with NewName in the subcatchment usage lists.

4.2 LID Group Editing

  • EditLIDGroup(...)
    • Allows the user to manage multiple LID units (instances of TLidUnit) assigned to a single subcatchment.
    • E.g., a subcatchment might have some area in permeable pavement, some area in infiltration trenches, etc.

4.3 LID Input/Output

  1. ReadLidData(...)

    • Parses [LID_CONTROLS] input lines from an INP file.
    • Supports reading each layer’s parameters for a given LID (Surface, Pavement, Soil, etc.).
  2. ReadLidUsageData(...)

    • Parses [LID_USAGE] input lines from an INP file, assigning an LID to a specific subcatchment.
  3. ExportLIDs(...)

    • Writes [LID_CONTROLS] section lines to an output file.
    • Calls ExportLIDRemovals(...) if there are pollutant removal lines.
  4. ExportLIDGroups(...)

    • Writes [LID_USAGE] section lines to an output file.
    • Summarizes all TLidUnit usage from each subcatchment.

4.4 Utility Methods

  • GetPcntLidArea(I: Integer): Extended;

    • Computes total % area of subcatchment I covered by LIDs.
  • GetPcntArea(Nunits: Integer; AreaStr: String): String;

    • Returns a user-friendly string with percent area that an LID usage occupies.
  • HasLIDType(SC: TSubcatch; const LIDType: Integer): Boolean;

    • Checks if subcatchment SC uses a particular LID process.
  • FreeLIDUnits(LidUnits: TStringlist);

    • Frees all the TLidUnit objects from a subcatchment’s LID usage list.

5. Workflow

  1. Defining an LID

    • The user creates a new LID control via EditLID(I=-1).
    • This defines the LID’s layers: surface, pavement, soil, storage, etc.
  2. Assigning LIDs to Subcatchments

    • The user calls EditLIDGroup(indexOfSubcatch, ...) to select from existing LIDs and apply them in the chosen subcatchment.
    • Each usage is stored as a TLidUnit object in that subcatchment’s LIDs list.
  3. Reading from an INP File

    • ReadLidData() reads the [LID_CONTROLS] section to create TLid objects.
    • ReadLidUsageData() reads the [LID_USAGE] section, creating TLidUnit objects that get added to each subcatchment.
  4. Writing to an INP File

    • ExportLIDs() writes out each LID’s definition in the [LID_CONTROLS] section.
    • ExportLIDGroups() writes the usage of each LID in [LID_USAGE].
  5. Deleting/Updating LIDs

    • If an LID is renamed, UpdateLIDName() updates references.
    • If an LID is deleted, references in subcatchments are removed (via EditLID() or manual name blanking).

6. Integration With Other Units

  • Uproject.pas

    • Houses the global Project object containing lists for LIDs and subcatchments.
  • Uglobals.pas

    • Defines the indexes for LID object lists and subcatchment categories.
    • Manages unit systems (US/SI) used in area conversions.
  • Dlid.pas (the LID Control Editor Form)

    • Allows a single LID’s layers to be edited.
    • Called from EditLID().
  • Dlidgroup.pas (the LID Group Editor Form)

    • Allows multiple LID units to be assigned to a subcatchment.
    • Called from EditLIDGroup().
  • Uimport.pas

    • Provides routines for reading lines from an INP file, calling ReadLidData() or ReadLidUsageData().
  • Uexport.pas

    • Provides path manipulations, used for writing file references in ExportLIDs() or ExportLIDGroups().

Concluding Remarks

  • Ulid.pas is the primary repository for LID “control” definitions and their usage in subcatchments.
  • The code uses short arrays (e.g., [0..4], [0..6]) for each LID layer to store numeric text parameters.
  • LID usage is a separate concept from LID definition: the TLid class describes the process/layer specs, while TLidUnit describes how a subcatchment uses it.

This modular approach simplifies reading/writing LID data, editing them in specialized dialog forms, and referencing them from the rest of SWMM’s data structures.

No comments:

A comprehensive explanation of how minimum travel distance relates to link length in InfoSewer

In hydraulic modeling of sewer networks, the minimum travel distance is a fundamental parameter that affects how accurately the model can si...