The SWMM 5 (Storm Water Management Model) source code is organized into several C modules, each responsible for different aspects of the simulation. The engine is designed to be compiled into a Dynamic Link Library (DLL) or shared object library depending on the platform (Windows, Linux, or macOS). A main.c
file is provided to build an executable that interacts with the engine, running the simulation based on input files.
Here's a breakdown of the SWMM 5 engine source code and its modules:
Header Files
These files define constants, data structures, function prototypes, and global variables used throughout the source code:
enums.h
: Contains enumerated constants (e.g., unit types, simulation options).objects.h
: Defines the main classes of objects used in SWMM (e.g., nodes, links, subcatchments).consts.h
: Defines numerical constants used in calculations.text.h
: Contains text strings used throughout the code (e.g., error messages).macros.h
: Defines macros used in the code.globals.h
: Declares global variables used in multiple modules.funcs.h
: Contains function prototypes for functions that can be called across various modules.
Core Computational Modules
These modules handle the core of the SWMM 5 simulation engine:
swmm5.c
: Supervisory control functions for the program, such as initializing the simulation, setting up objects, and managing the overall simulation flow.project.c
: Handles the creation, destruction, and management of all project data, including looking up objects by their ID names and setting default values.input.c
: Reads input data from the project files, setting up the model objects with the data.runoff.c
: Performs runoff calculations for subcatchments, including both quantity and quality of runoff.routing.c
: Routes runoff and external inflows through the drainage system network of nodes and links.massbal.c
: Performs mass balance calculations for runoff and routing.stats.c
: Collects simulation statistics such as flow rates, water depths, and number of solution iterations.statsrpt.c
: Writes summary simulation results to a status report.output.c
: Manages the reading and writing of runoff and routing results to/from a binary output file.report.c
: Prepares a status report and writes detailed results for subcatchments, nodes, and links based on user preferences.
Hydrology and Flow Modules
These modules are used to compute the hydrologic and hydraulic processes in the simulation:
rain.c
: Places data from external rainfall files into a unified rainfall interface file.gage.c
: Provides rainfall data to the model from an external source, either from an interface file or a time series.climate.c
: Provides climate data (temperature, evaporation, wind speed) to the simulation.snow.c
: Computes snow accumulation, snow removal, and snowmelt for subcatchments.infil.c
: Handles infiltration calculations for subcatchments.gwater.c
: Computes groundwater fluxes and updates groundwater depths in the simulation.subcatch.c
: Computes rainfall runoff, pollutant buildup and washoff, and street sweeping for each subcatchment.landuse.c
: Evaluates pollutant buildup and washoff based on land use for subcatchments.lid.c
: Evaluates the performance of Low Impact Development (LID) practices in the model.lidproc.c
: Computes the performance of individual LID units.
Flow and Quality Routing Modules
These modules are used to route flows and water quality constituents through the drainage network:
flowrout.c
: Controls the top-level flow routing process in the drainage system.inflow.c
: Provides direct time series inflows and recurring dry weather inflows to the drainage system at each time step.rdii.c
: Computes Rainfall Dependent Infiltration/Inflow (RDII) at selected nodes in the drainage network.inlet.c
: Calculates flow captured by street inlet drains and diverts it to sewer nodes.kinwave.c
: Implements kinematic wave flow routing for the system.dynwave.c
: Performs dynamic wave flow routing at each time step.dwflow.c
: Solves the dynamic wave continuity and momentum equations for conduits.controls.c
: Implements rule-based control actions for pumps and regulators during the simulation.qualrout.c
: Routes water quality constituents through the drainage system.treatmnt.c
: Computes pollutant removal at specific nodes where treatment functions have been assigned.node.c
: Contains functions to compute the properties and behaviors of drainage system nodes (junctions, flow dividers, storage units, outfalls).link.c
: Contains functions to compute the properties and behaviors of links (conduits, pumps, orifices, weirs, and outlets).forcmain.c
: Computes friction losses in force mains using the Hazen-Williams or Darcy-Weisbach equations.culvert.c
: Computes flow reductions in culverts due to inlet control.
Utility Modules
These modules provide various support functions for SWMM 5:
datetime.c
: Functions for manipulating and formatting dates and times.error.c
: Error reporting functions.findroot.c
: Root-finding functions for solving equations.hash.c
: Implements hash tables for fast object retrieval by ID.hotstart.c
: Manages hot start files for resuming simulations from a saved state.iface.c
: Functions for reading from and writing to routing interface files.keywords.c
: Defines lists of keywords that appear in SWMM input files.mathexpr.c
: Functions for parsing and evaluating mathematical expressions.mempool.c
: Manages a memory pool used for storing object IDs.odesolve.c
: Implements the fifth-order Runge-Kutta method for solving ordinary differential equations (ODEs).shape.c
: Computes geometric properties for closed conduits with user-defined shapes.street.c
: Reads the geometric properties of street cross-sections.table.c
: Provides functions for accessing lookup tables (e.g., curves, time series).toposort.c
: Implements topological sorting for links in a drainage network to detect closed loops.transect.c
: Creates geometric tables for irregular-shaped cross-section transects.xsect.c
: Computes geometric properties for conduit cross-sections.
Compilation and Execution
The SWMM 5 engine is compiled into a shared object or DLL that can be used by external applications. A main.c
file is provided to create an executable version of SWMM that performs the simulation based on input files, executes the necessary calculations, and outputs the results.
Conclusion
The SWMM 5 engine source code is modular, with each module performing specific tasks related to hydrologic and hydraulic modeling, flow routing, water quality simulation, and more. The system is designed to be flexible and extensible, with options for handling complex systems involving rainfall runoff, pollutant transport, and various flow control mechanisms.
No comments:
Post a Comment