Below is an overview of Dsnow.pas, a Delphi unit from SWMM 5.2 that defines a form (TSnowpackForm) for defining or editing a Snowpack object’s properties in SWMM. A Snowpack object models how snow and ice accumulate, melt, and are removed from subcatchment surfaces (plowable, impervious, or pervious areas).
1. Purpose and Context
In SWMM’s snowmelt routine, each subcatchment can reference a Snowpack object that specifies:
- Melt coefficients (minimum and maximum)
- Base temperature
- Free water capacity
- Initial snow/ice depth
- Parameters for different land surface types (plowable, impervious, pervious)
- Snow removal or “plowing” parameters.
TSnowpackForm presents these options via a two-page TPageControl
:
- First Page (TabSheet1) includes a
TGridEditFrame
(PackGrid
) containing separate columns for plowable, impervious, and pervious parameters. - Second Page (TabSheet2) handles snow removal options.
Once the user inputs or edits values, the form validates them (ensuring no negative or invalid ranges) and, upon OK, stores them back to the TSnowpack object in SWMM.
2. Main Form: TSnowpackForm
2.1 Visual Components
- NameEdit: A text box for the Snowpack’s unique name (no duplicates, not empty).
- PackGrid (
TGridEditFrame
):- A grid with columns for each sub-area type (plowable, impervious, pervious) and rows for parameters such as Melt Coefficients, Base Temp, Free Water Fraction, etc.
- Each cell is text-based, storing numeric values.
- FracPlowableEdit: Fraction of the impervious area that is “plowable.”
- NumEdit1..NumEdit6: Numeric fields for snow removal parameters, like removal depth, removal fractions, etc.
- SubcatchNameEdit: Name of the subcatchment that will receive plowed snow.
- PageControl1 with TabSheet1 (Snowpack properties) and TabSheet2 (Snow removal).
3. Data Structures: TSnowpack
A TSnowpack object has fields:
- Data[i][j]: a 2D array (3 columns for plowable/impervious/pervious, and 7 rows for parameters, typically something like:
- Min Melt Coeff
- Max Melt Coeff
- Base Temperature
- Fraction Free Water
- Initial Snow Depth
- Initial Free Water
- Depth at 100% Cover
- FracPlowable: fraction of impervious area that can be plowed
- Plowing[i]: an array for 1..6 representing snow removal parameters (including the subcatchment name in index 7)
4. Workflow
4.1 SetData(Index, SP)
NameEdit.Text
= Snowpack name fromProject.Lists[SNOWPACK].Strings[Index]
PackGrid.Grid
is populated withSP.Data[...]
values across 7 rows * 3 columns (for each land surface type).- The “plowable fraction” (
FracPlowableEdit.Text
) and the plowing parameters (NumEdit1..NumEdit6
, plusSubcatchNameEdit
) are set fromSP.Plowing[...]
.
4.2 GetData(S, SP)
- After OK is pressed, the form retrieves:
S := Trim(NameEdit.Text)
as the Snowpack name.- For each cell in
PackGrid.Grid
,SP.Data[i][j]
gets that cell’s numeric string. SP.FracPlowable
,SP.Plowing[1..7]
from the relevant fields on TabSheet2.
4.3 Validation (in ValidateInput
)
- Snowpack Name not empty or duplicated.
- Non-negative numeric parameters for melt coefficients, base temperature, etc.
- Min. melt coeff <= Max. melt coeff.
- Free water fraction <= 1.0.
FracPlowableEdit
is in [0..1].- If snow removal depth > 0, ensure a subcatchment name is provided.
- Sum of removal fractions does not exceed 1.0.
If any check fails, a message is shown, the user is re-focused on the offending control, and OK is canceled.
5. Event Handlers
- NameEditChange / PackGridSelectCell / PackGridDrawCell:
- Keep track of changes, ensure the plowable column doesn’t allow an input in “Depth at 100% Cover.”
- OKBtnClick: Runs
ValidateInput
; if everything is correct, closes withModalResult := mrOK
. - HelpBtnClick: Brings up context help, which changes depending on which TabSheet is active.
6. Summary
Dsnow.pas provides a form to manage the parameters for a Snowpack object in SWMM. By splitting parameters across plowable/impervious/pervious areas and providing a second tab for snow removal rules, it ensures that each Snowpack can be fully defined, validated, and stored. After confirming, the updated Snowpack is available in the model for snowmelt-related computations.
No comments:
Post a Comment