Sunday, December 29, 2024

SWMM5 Delphi GUI Dsubland.pas Summary

 Below is an overview of Dsubland.pas, a Delphi unit from SWMM 5.2 that implements a SubLandUsesForm dialog. This dialog is used to edit how land uses are distributed within a subcatchment. In SWMM, a subcatchment can be allocated among different land uses (e.g., residential, commercial, industrial) that have distinct buildup/washoff parameters for pollutants. The TSubLandUsesForm allows the user to specify what percentage of the subcatchment’s area each land use occupies.


1. Purpose and Context

SWMM can model nonpoint source pollutant buildup/washoff using land use objects. Each Subcatchment can contain a mix of multiple land uses (for instance, 30% residential, 70% commercial). The TSubLandUsesForm helps the user assign these percentages:

  • The user sees a list of land uses (one per row).
  • For each land use, the user enters the percent of subcatchment area occupied by that land use.

These allocations can sum to 100%. During simulation, pollutant buildup/washoff rates are scaled by these percentages.


2. Main Form: TSubLandUsesForm

2.1 Visual Components

  1. PropEdit1 (TPropEdit):
    • A custom property editor placed on Panel1.
    • The editor has two columns:
      • Property (the land use name)
      • Value (the percent of subcatchment area).
  2. PropList (TStringList):
    • Holds the values (the percentages) for each land use row.
  3. OKBtn, CancelBtn, HelpBtn:
    • Standard form action buttons at the bottom.

2.2 Data Organization

  • LanduseCount / PropCount: the number of land uses in the project.
  • Each row in PropEdit1 corresponds to one land use.
  • The name (land use) is shown in the first column, the user’s input (percentage) in the second column.
  • The string list PropList holds these percentage values in the same order the land uses appear in Project.Lists[LANDUSE].

3. Key Methods and Events

3.1 FormCreate

  1. Sets up the PropEdit1 with column headings (“Land Use,” “% of Area”).
  2. Allocates an array of TPropRecord (PropRecd) to match the number of land uses in the project.
  3. For each land use name in Project.Lists[LANDUSE], it sets:
    • PropRecd[i].Name to the land use name,
    • PropRecd[i].Style := esEdit,
    • PropRecd[i].Mask := emPosNumber (ensuring only numeric input for the percent).

3.2 SetData(LandUses)

  • Called externally to load an existing distribution of land use areas for a subcatchment.
  • Each entry in the LandUses string list has the format: landuseName=percentValue.
  • For each land use in the entire project, it checks if it appears in LandUses. If it does, the matching percentage is appended to PropList; if not, it appends an empty string (“”).

3.3 GetData(LandUses, Count)

  • After the user presses OK, the form calls GetData to store the final distribution:
    1. Clears LandUses.
    2. Walks through each row in PropList.
    3. Converts the string to a float (P).
    4. If P > 0, it adds landuseName=P to the LandUses list, increments Count.
  • This results in a list of land uses with nonzero percent allocations.

3.4 OKBtnClick

  • The user’s final step.
  • Calls:
    1. PropEdit1.IsValid (ensuring no invalid numeric inputs).
    2. ValidateInput:
      • Sums all percentages. If they exceed 101%, shows an error (“Percentages exceed 100%.“).
      • If OK, ModalResult := mrOK.

3.5 ValidateInput

  • Gathers each line in PropList, parses it as a float, sums the values.
  • If the sum > 101, returns an error. (The 101% threshold accounts for rounding error in user input.)

4. Usage Example

  1. A subcatchment has land uses: Residential, Commercial, Open Space.
  2. The user calls SetData(LandUses) where LandUses might have lines like Residential=25 and Commercial=50 for the existing configuration.
  3. The form displays three rows in PropEdit1: “Residential,” “Commercial,” “Open Space.” The first two have “25,” “50” and the third is blank.
  4. The user changes values—maybe sets “Residential=30,” “Commercial=50,” “Open Space=20.” The sum is 100%.
  5. On OK, GetData(LandUses, Count) returns these final lines, and Count=3.

5. Summary

Dsubland.pas provides a simple TSubLandUsesForm dialog to let users specify or edit percentage allocations of land uses within a subcatchment:

  • The form displays all land uses in the model (one row each),
  • The user enters a percentage for each relevant land use,
  • The form ensures the sum does not exceed 101%,
  • The final data are stored in a string list for the subcatchment’s land uses.

This helps SWMM track which portion of the subcatchment belongs to which land use categories, crucial for pollutant buildup/washoff modeling.

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