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
- 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)
- 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
).
- ShapeCard: For the first four items (cylindrical, conical, etc.), three numeric parameters (
- 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.
- EditBitBtn: Launches the time series/curve editor to modify the chosen storage curve.
- 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 isTABULAR
).
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’sListView1
is set to index 4, andFuncEdit1..3
are loaded. - If
Data[STORAGE_GEOMETRY_INDEX] = 'TABULAR'
, the form’sListView1
is set to index 5, andComboBox1
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
), setsData[STORAGE_GEOMETRY_INDEX] = 'FUNCTIONAL'
and the 3 coefficients. - If Tabular (
=5
), sets geometry to'TABULAR'
andData[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 intoSTORAGE_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:
- Fill placeholders if any required fields are blank.
- Temporarily store the shape parameters in local variables (
A0, A1, A2
, etc.). - Switch to the VolumeCard page.
- 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 and volume as a function of depth:
- E.g., Cylinder: , , etc.
- E.g., Conical: area = , volume = .
- For a Functional shape, area is .
- 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:
- Shape-based (cylindrical, conical, parabolic, pyramidal),
- Functional (user-supplied equation for area vs. depth),
- 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:
Post a Comment