Sunday, December 29, 2024

SWMM5 Delphi GUI Dstorage.pas, Summary

 Below is an overview of Dstorage.pas, a Delphi unit from SWMM 5.2 that provides a StorageForm dialog for specifying the geometry of a storage unit node in SWMM. Storage units can have their surface area defined in different ways (functional, tabular, or shapes like cylindrical, conical, paraboloid, or pyramidal). These shapes control how surface area and volume vary with depth in the node.


1. Purpose and Context

In SWMM, storage units are nodes that hold water with a known area-depth or volume-depth relationship. The TStorageForm allows the user to choose one of several geometry options and provide parameters—either as simple numeric coefficients (functional shapes), direct tabular data (storage curves), or shape-based parameters. Once the user finishes, the data are stored back into the node’s Data[] array for use in hydraulic simulations.


2. Main Form: TStorageForm

2.1 Visual Components

  1. ListView1: A list of possible storage shapes:
    • 0: Elliptical or Circular Cylinder (Cylindrical)
    • 1: Truncated Elliptical Cone (Conical)
    • 2: Elliptical Paraboloid (Parabolic)
    • 3: Rectangular Pyramid/Box (Pyramidal)
    • 4: Functional (defined by a functional relationship)
    • 5: Tabular (defined by a named curve)
  2. CardPanel1 with separate Card pages for each geometry approach:
    • ShapeCard: For the first four items (cylindrical, conical, etc.), three numeric parameters (ParamEdit1..3) plus descriptions/labels.
    • FunctionalCard: For a functional shape (FuncEdit1..3).
    • TabularCard: Has a combo box (ComboBox1) to pick a storage curve from the project.
    • VolumeCard: A page for Area/Volume display at a given depth (DepthNumEdit).
  3. CalcLinkLabel (e.g., “Show Volume Calculator” or “Show Shape Selection”): Toggling between the shape parameters view and an interactive “calculator” view for area/volume at a user-specified depth.
  4. EditBitBtn: Launches the time series/curve editor to modify the chosen storage curve.
  5. OkBtn, CancelBtn, HelpBtn: Standard dialog actions.

2.2 Data Storage

SWMM uses string arrays (like Data[]) to store a node’s storage parameters:

  • Data[STORAGE_GEOMETRY_INDEX] : string indicating geometry type (CYLINDRICAL, CONICAL, PARABOLIC, PYRAMIDAL, FUNCTIONAL, TABULAR).
  • Data[STORAGE_COEFF0_INDEX], [STORAGE_COEFF1_INDEX], [STORAGE_COEFF2_INDEX]: numeric parameters describing the shape.
  • Data[STORAGE_ATABLE_INDEX]: name of a storage curve (if shape is TABULAR).

When the user chooses a shape and inputs parameters, these are eventually written back into Data[].


3. Workflow

3.1 SetData(Data[])

  • Called to populate the form’s controls with existing storage parameters from Data[].
  • If Data[STORAGE_GEOMETRY_INDEX] = 'FUNCTIONAL', the form’s ListView1 is set to index 4, and FuncEdit1..3 are loaded.
  • If Data[STORAGE_GEOMETRY_INDEX] = 'TABULAR', the form’s ListView1 is set to index 5, and ComboBox1 is set to the storage curve name.
  • Otherwise, the form picks the correct shape index (0..3) and loads the numeric parameters (ParamEdit1..3).

3.2 GetData(Data[])

  • After user hits OK, the form gathers user inputs back into the Data[] array.
  • If the shape is Functional (ListView1.ItemIndex=4), sets Data[STORAGE_GEOMETRY_INDEX] = 'FUNCTIONAL' and the 3 coefficients.
  • If Tabular (=5), sets geometry to 'TABULAR' and Data[STORAGE_ATABLE_INDEX] to the chosen curve name.
  • Otherwise, picks 'CYLINDRICAL', 'CONICAL', 'PARABOLIC', or 'PYRAMIDAL' depending on item index 0..3, and places the numeric parameters into STORAGE_COEFF0..2_INDEX.

3.3 OkBtnClick

  • If the shape is Tabular and the user hasn’t selected a curve, an error is raised. Otherwise, the form’s ModalResult is set to mrOK.

3.4 CalcLinkLabel / VolumeCard

  • The user can click the link “Show Volume Calculator” to see how area and volume vary with depth for the chosen shape. This triggers the code to:
    1. Fill placeholders if any required fields are blank.
    2. Temporarily store the shape parameters in local variables (A0, A1, A2, etc.).
    3. Switch to the VolumeCard page.
    4. The user can then type a depth in DepthNumEdit and see the resulting area/volume.
  • If the user clicks the link again, the form switches back to the original shape card.

3.5 Volume/Area Calculation Logic

  • For a shape-based geometry (cylindrical, conical, etc.), it uses formulas for area AA and volume VV as a function of depth:
    • E.g., Cylinder: A=π×L×W4A = \pi \times \frac{L \times W}{4}, V=A×DV = A \times D, etc.
    • E.g., Conical: area = πLW/4+D()\pi L W/4 + D(\dots), volume = \dots.
  • For a Functional shape, area is A=a0+a1×Da2A = a_0 + a_1 \times D^{a_2}.
  • For a Tabular shape, the code retrieves a user-defined curve and does a piecewise linear interpolation to find area and integrates it for volume up to the given depth.

4. Summaries of Key Methods

  • FormCreate: Prepares the UI, sets default labels for US or SI units, loads shapes into ListView1, etc.
  • ListView1SelectItem: Switches the visible card (ShapeCard, FunctionalCard, TabularCard, etc.) based on the selected shape.
  • CalcLinkLabelLinkClick: Toggles between shape-parameter editing and volume display mode.
  • DepthNumEditChange: Whenever the user modifies the depth in the calculator, updates the displayed area/volume.
  • SetData: Loads from Data[] to the form.
  • GetData: Writes from the form to Data[].
  • OkBtnClick: Final validation; if something is missing for a tabular shape (no curve name), it rejects.

5. Summary

Dstorage.pas provides a flexible UI for storage unit geometry in SWMM. It supports:

  1. Shape-based (cylindrical, conical, parabolic, pyramidal),
  2. Functional (user-supplied equation for area vs. depth),
  3. Tabular (area-depth data from a named curve).

Users can preview the area/volume at any depth, ensuring correct geometry data for subsequent hydraulic 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...