Sunday, December 29, 2024

SWMM5 Delphi GUI Dlanduse.pas Summary

 Below is an overview of Dlanduse.pas, a Delphi unit from SWMM 5.2 that provides a dialog (TLanduseForm) for creating or editing Land Use objects. A land use can have:

  • General Properties (e.g., name, street sweeping interval)
  • Buildup properties (how pollutants accumulate)
  • Washoff properties (how pollutants wash off with runoff)

1. Purpose and Context

In SWMM, Land Use objects define how pollutants build up over time and wash off during a rainfall event. This helps simulate nonpoint source pollution loading in subcatchments. The TLanduseForm allows users to specify:

  1. General: Land use name, description, street sweeping data.
  2. Buildup: How pollutants accumulate on the land surface over time.
  3. Washoff: How pollutants are washed off by runoff or how an Event Mean Concentration (EMC) is defined.

2. Key Form Elements

2.1 Controls

  • TabControl1: Has three tabs:
    1. General (land use name, description, street cleaning)
    2. Buildup (power, exponential, saturation, or external time series)
    3. Washoff (exponential, rating curve, or EMC)
  • TPropEdit (PropEditor) on each tab to edit properties in a name/value table.
  • BuildupGrid & WashoffGrid: Hidden string grids that store pollutant-specific data for Buildup/Washoff.
  • PollutCombo: Drop-down list of pollutants for the Buildup and Washoff tabs.
  • GeneralProps: A TStringlist that holds the general land use properties.
  • OKBtn, CancelBtn, HelpBtn: Standard dialog buttons.

2.2 Property Records

Three sets of TPropRecord arrays define how each tab's properties appear in the PropEditor:

  1. DefGeneralProps (name, description, street sweeping).
  2. DefBuildupProps1 and DefBuildupProps2 (for different buildup “Function” types; EXT has different fields).
  3. DefWashoffProps (exponential, rating curve, EMC).

These records specify each property’s display label, editing style (e.g., esEdit, esComboList, esButton), valid input mask (e.g., numeric only), and other characteristics.


3. Data Structures in SWMM

3.1 TLanduse

  • Holds an array (Data[]) for general properties such as:
    • Data[COMMENT_INDEX] = Description
    • Data[LANDUSE_CLEANING_INDEX] = Street sweeping interval
    • Data[LANDUSE_AVAILABLE_INDEX] = Fraction of buildup available for sweeping
    • Data[LANDUSE_LASTCLEAN_INDEX] = Days since last sweeping
  • Contains a list of TNonpointSource objects (one per pollutant), each with:
    • BuildupData[] (array of up to five strings).
    • WashoffData[] (another array of up to five strings).

3.2 TNonpointSource

  • Manages buildup/washoff properties for one pollutant under a land use.
  • Buildup properties: function type, coefficients, normalizer, etc.
  • Washoff properties: function type, coefficients, exponent, BMP efficiency, etc.

4. Workflow and Event Handling

4.1 FormCreate

  • Creates a string list (GeneralProps) for general properties.
  • Instantiates the PropEditor, setting column titles, read-only color, event handlers (OnButtonClick, OnValidate, OnRowSelect), etc.

4.2 SetData(I: Integer)

Called to load an existing land use (index I) or start a new one:

  1. GeneralProps receives default or existing values:
    • Name, Description, Sweeping Interval, etc.
  2. BuildupGrid / WashoffGrid are sized to have one row per pollutant. Each row stores the buildup/washoff parameters for that pollutant.
  3. If I >= 0, it reads the existing land use object Project.Lists[LANDUSE].Objects[I]:
    • Copies general properties into GeneralProps.
    • Reads each pollutant’s TNonpointSource into BuildupGrid and WashoffGrid rows.

4.3 TabControl1Change

When the user switches tabs:

  • Tab 0 (General): Display DefGeneralProps in PropEditor, with data from GeneralProps.
  • Tab 1 (Buildup) or Tab 2 (Washoff): Show PollutCombo (if there are pollutants).
    • If the tab is Buildup, then either use BuildupProps1 or BuildupProps2 depending on whether the selected function is EXT. The data come from the current row of BuildupGrid (matching the selected pollutant).
    • If the tab is Washoff, display DefWashoffProps, with data from WashoffGrid.

4.4 PollutComboClick

  • The user changes the active pollutant in PollutCombo.
  • The form loads that pollutant’s buildup or washoff row in PropEditor.
  • This allows switching between pollutants’ parameters without leaving the tab.

4.5 OKBtnClick

  • Validates the land use name to ensure it isn’t blank or duplicated.
  • If valid, calls GetData to write the edited properties back to the SWMM data structures.
  • Closes the form with ModalResult := mrOK.

4.6 GetData(I: Integer)

  • Retrieves name, description, street sweeping info from GeneralProps.
  • Either updates an existing TLanduse or creates a new one if I < 0.
  • Clears any existing NonpointSource objects on that TLanduse, then for each pollutant row in BuildupGrid / WashoffGrid:
    • Creates a new TNonpointSource with those properties.
    • Adds it to the land use’s list of nonpoint sources.

4.7 Other Events

  • OnValidate (ValidateData) triggers whenever a user changes a property value in PropEditor. It sets HasChanged := True and checks if the user changed the Buildup “Function” to or from “EXT,” then reloads the correct property set.
  • OnButtonClick (EditComment): opens a text editor dialog for the land use “Description” property (the second field in GeneralProps).

5. Summary of Operation

  1. Initialization: The form is created, and SetData is called with the index of a land use in the project (or -1 if new).
  2. Editing: The user picks among tabs:
    • General: Edits name, description, sweeping parameters.
    • Buildup: Switches pollutants in PollutCombo, edits buildup parameters in PropEditor.
    • Washoff: Similarly, edits washoff properties per pollutant.
  3. Validation and Save: On OK, the code checks for a valid (non-duplicate) name, then calls GetData to write changes back to the SWMM project data structures.
  4. Result: The project now has updated land use definitions that specify how each pollutant accumulates and washes off for each land use category.

By splitting parameters into General, Buildup, and Washoff tabs, Dlanduse.pas provides a clear, tab-based editor for land use configurations—integral to modeling stormwater quality in SWMM.

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