Sunday, December 29, 2024

SWMM5 Delphi GUI Dtsect.pas Summary

 Below is an overview of Dtsect.pas, a Delphi unit from SWMM 5.2 that provides a form (TTransectForm) for editing the geometry of a natural channel cross-section (a “transect”). In SWMM, a transect is a set of station-elevation data plus related parameters (roughness, bank stations, scale factors) that define how water flows in an irregular open channel.


1. Purpose and Context

A transect in SWMM is typically used to model natural channels or irregular open channels. The TTransectForm lets a user:

  1. Enter a unique name for the transect.
  2. Provide descriptive text (an optional comment).
  3. Specify Manning’s roughness for the left bank, right bank, and channel.
  4. Provide station values for the left and right banks, plus scale factors for horizontal and vertical dimensions.
  5. Input the station-elevation data pairs that define the cross section shape.

Once the user is done, the form stores these parameters into a TTransect object, which SWMM uses to compute flow-area relationships during hydraulic routing.


2. Main Form: TTransectForm

2.1 Key Controls

  1. NameEdit / CommentEdit:

    • The user can set the transect’s ID and an optional comment describing it.
  2. PropEdit1 (TPropEdit):

    • A custom property editor on the right side of the form that displays a list of property labels (e.g., “Roughness,” “Bank Stations,” “Modifiers”) and their values.
    • Specifically, these are arranged in headings and numeric fields for:
      • Left Bank N / Right Bank N / Channel N
      • Left Bank Station / Right Bank Station
      • Station Factor / Elevation Factor / Meander Factor (if any).
  3. GridEdit:

    • A TGridEditFrame that allows the user to enter station-elevation pairs describing the cross-section shape.
    • Each row has columns: row index, station (horizontal coordinate), elevation (vertical coordinate).
    • The user can insert or delete rows. Typically the data must be in ascending order of station.
  4. Buttons:

    • OK: Finalizes changes (closing the form with mrOK) if the data passes validation.
    • Cancel: Closes form, discarding changes.
    • View: Opens a preview plot of the transect using TPreviewPlotForm.
    • Help: Opens context help for transects.
    • Edit: Launches a comment editor for the transect’s textual description.

3. Data Flow

3.1 SetData(I, S, Tsect)

  • Called to populate the form with an existing transect (index I, name S in Project.Lists[TRANSECT]).
  • Copies the transect’s parameters (roughness, bank stations, scale factors) into the PropList string list, displayed by PropEdit1.
  • Copies the station-elevation data from the transect’s Xdata and Ydata lists into the GridEdit.Grid rows.

3.2 GetData(S, Tsect)

  • After the user presses OK, extracts:
    • The new NameEdit.Text into S.
    • The parameters from PropList back into Tsect.Data[].
    • The station-elevation data from GridEdit.Grid into Tsect.Xdata and Tsect.Ydata.
  • Calls Tsect.SetMaxDepth, which recomputes the cross-section’s maximum depth from the input data.
  • If the name changed or the max depth changed, SWMM updates the TRANSECT object and any conduits using that transect.

3.3 Validation

  • ValidateData checks:
    1. Transect name is non-empty.
    2. The name is unique in Project.Lists[TRANSECT].
    3. The main channel roughness is not empty.
    4. The station-elevation data in the grid are valid numeric values and in ascending station order.
  • If any check fails, the form does not close and displays an error message.

3.4 Station-Elevation Grid

  • The user can input up to 1500 points in ascending station order. SWMM uses these points to define the shape of the cross section.
  • The grid has 3 columns: row index (hidden or just numbering?), station, elevation. The first row is a header row, so data starts at row 1.

3.5 View button

  • Creates a TPreviewPlotForm and calls PlotTransectData to show a quick preview of the cross-section shape. The function uses the station, elevation data plus the left and right bank station scale factors to produce a 2D chart.

4. Summary

Dtsect.pas implements the TTransectForm for editing a natural channel cross-section in SWMM. It includes:

  • Text fields for name and comment.
  • A property editor (PropEdit1) to configure roughness values, bank station definitions, and scale factors.
  • A grid (GridEdit) to input the station-elevation pairs describing the channel shape.
  • A View button to preview the cross-section shape in a separate plotting form.
  • Basic validation of user inputs (non-empty name, unique ID, correct station ordering).

The final data is stored into a TTransect object, used by SWMM’s hydraulic engine to compute flow area, top width, etc., in the irregular channel.

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