Sunday, December 29, 2024

SWMM5 Delphi GUI Dlid.pas Summary

 Below is an overview of Dlid.pas, a Delphi unit from SWMM 5.2 that provides a dialog (TLidControlDlg) to create or edit an LID Control definition. SWMM uses Low Impact Development (LID) controls—such as bioretention cells, rain barrels, permeable pavement, etc.—to model best management practices in a watershed.


1. Purpose and Context

Each LID Control in SWMM represents a reusable design template that can be assigned to multiple subcatchments. This dialog enables the user to:

  1. Specify the LID type (e.g., Rain Garden, Green Roof, Permeable Pavement, etc.)
  2. Provide layer properties (surface layer, pavement layer, soil layer, storage layer, drain layer, etc.)
  3. Handle pollutant removals in the underdrain outflow.

These controls reflect how infiltration, storage, and outflow are handled for a particular type of LID.


2. Main Form: TLidControlDlg

2.1 Key Controls

  1. NameEdit: The name of the LID control (must be unique among LID controls).
  2. TypeCombo: A dropdown listing the LID process types (Bio Cell, Rain Garden, Green Roof, etc.).
  3. PageControl1 with multiple TTabSheet pages, each containing TNumEdit controls for layer properties:
    • TabSheet1: Surface layer (e.g., Berm Height, Surface Storage, Vegetative cover, etc.)
    • TabSheet2: Pavement layer (thickness, void ratio, impervious surfaces)
    • TabSheet3: Soil layer (thickness, porosity, infiltration rates, etc.)
    • TabSheet4: Storage layer (thickness, void ratio, infiltration, optional “rain barrel” coverage)
    • TabSheet5: Drain layer (flow coefficient, offset, underdrain capacity)
    • TabSheet6: Drainage mat (for Green Roofs)
    • TabSheet7: Roof Disconnection (downspout parameters)
    • TabSheet8: Pollutant Removals (optional percent removals for underdrain outflow)
  4. RemovalsEditor: A TValueListEditor containing a row for each pollutant, storing underdrain removal efficiency.
  5. CoveredCheckBox: An option for a covered rain barrel.
  6. OK, Cancel, and Help buttons.

3. Data Structures

3.1 TLid Object

A single TLid object has:

  • ProcessType: integer matching the selected item in TypeCombo.
  • SurfaceLayer: array of up to 5 strings.
  • PavementLayer: array of up to 7 strings.
  • SoilLayer: array of up to 7 strings.
  • StorageLayer: array of up to 5 strings (four numeric + “YES/NO” for rain barrel coverage).
  • DrainLayer: array of up to 7 strings (6 numeric + 1 reference to a control curve).
  • DrainMatLayer: array of 3 strings (for Green Roof drainage mat).
  • DrainRemovals: string list of Key=Value entries for each pollutant’s removal efficiency.

Note: Many fields are stored as strings so that SWMM can parse them at runtime without losing formatting or the user’s numeric precision.


4. Form Lifecycle

4.1 SetData(Index, aLID)

  • Called to initialize the dialog:
    • If Index >= 0, fetch the LID’s name from Project.Lists[LID].Strings[Index] and place it in NameEdit.
    • Set TypeCombo.ItemIndex := aLID.ProcessType.
    • Fill each relevant TNumEdit (e.g., SurfaceEdit1..SurfaceEdit5, PavementEdit1..PavementEdit7, etc.) from aLID.SurfaceLayer[], aLID.PavementLayer[], etc.
    • Assign the underdrain pollutant removals into RemovalsEditor.
    • Update which tab sheets (TabSheet1..TabSheet8) are visible or hidden based on the chosen LID type (via TypeComboClick).
    • Mark Modified := False.

4.2 TypeComboClick

  • Adjusts TabSheet visibility based on the selected LID type. For example:
    • Rain Barrel hides the surface layer tab, makes the storage tab more specialized, etc.
    • Green Roof hides the storage tab, shows the drain mat tab.
    • Roof Disconnection shows a simpler layout, no drain or storage tab.
    • Vegetative Swale hides the storage/drain tabs, modifies surface label usage.
  • Also updates the icon in LIDImage to reflect the chosen type.

4.3 User Interaction

  1. The user edits layer parameters in the TNumEdits across multiple tabs.
  2. Optionally checks the CoveredCheckBox for a Rain Barrel.
  3. Edits pollutant removal percentages in RemovalsEditor.
  4. Switches LID type from the drop-down, which triggers re-configuration of visible tabs.

4.4 Validation

OkBtnClick:

  1. Checks that NameEdit is non-empty and not duplicated.
  2. Runs LayerDepthsValid to ensure certain layer thickness fields (soil, pavement, storage, drainage mat) are > 0 if required by the chosen LID type.
  3. If invalid, displays an error message, sets focus to the offending field, and does not close.
  4. Otherwise, sets ModalResult := mrOK.

4.5 GetData

  • Called after OK is pressed and validation passes, to store the final results into the TLid object:
    • LID name is read from NameEdit.Text.
    • ProcessType from TypeCombo.ItemIndex.
    • The numeric TNumEdits from each layer tab are written back into e.g. aLID.SurfaceLayer[i-1], aLID.PavementLayer[i-1], etc.
    • The pollutant removal Key=Value pairs from RemovalsEditor.Strings go into aLID.DrainRemovals.
    • The “Covered” rain barrel option is saved as aLID.StorageLayer[4] := 'YES' or 'NO'.

5. Notable Procedures

5.1 LayerDepthsValid

  • Checks that certain layer thickness TNumEdits are greater than zero, depending on LID type:
    • Biocell/Rain Garden/Green Roof => soil layer must be > 0.
    • Permeable Pavement => pavement layer must be > 0.
    • If infiltration trench => storage layer must be > 0.
    • Green Roof => drainage mat must be > 0.
    • Vegetative Swale => berm height must be > 0.

If any are 0, it shows an error message and makes the form remain open.

5.2 RemovalsEditorValidate

  • Ensures the user’s entered removal fraction is numeric and in [0..100].
  • If invalid, it reverts to the prior value.

5.3 NumEditExit

  • For certain fraction-based fields (e.g., infiltration fraction), ensures it’s < 1.0. If not, prompts an error.

6. Summary

Dlid.pas provides a multi-tabbed dialog to define or edit a Low Impact Development template, specifying layering and outflow pollutant removals. The LID control can then be reused in subcatchments. By splitting parameters across separate tabs (Surface, Pavement, Soil, Storage, Drain, etc.), the form makes it clearer to configure the LID’s layered structure and internal drainage properties. Validation ensures consistent entries for thickness, name uniqueness, and pollutant removal rates.

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...