The output.c
file in SWMM5 (Storm Water Management Model) is responsible for managing binary output file operations related to system simulation results, including subcatchments, nodes, links, and pollutants. It handles the writing and reading of simulation data to and from a binary file, as well as the storage of various results (e.g., flow, depth, volume, and pollutant concentrations). The file supports large datasets, including the ability to handle the storage of results over multiple time periods.
Key Features of the Code:
1. File Operations:
- File Management:
output_openOutFile()
: Opens the binary output file for saving simulation results.output_saveID()
: Saves the ID of an object (subcatchment, node, link, or pollutant) to the binary output file.output_saveResults()
: Writes computed results for the current report time to the binary file.output_end()
: Writes closing records to the binary file, including positions of saved data and the final results.output_checkFileSize()
: (Deprecated) Checks if the file size is too large for 32-bit systems to handle.output_saveAvgResults()
: Saves the averaged results (e.g., average flow) for nodes and links at the end of a reporting period.
2. Data Structures and Variables:
TAvgResults
: Structure used to store averaged results for nodes and links.SysResults[MAX_SYS_RESULTS]
: Stores system-wide variables such as total rainfall, evaporation, runoff, and system storage.SubcatchResults
,NodeResults
,LinkResults
: Arrays to store results for subcatchments, nodes, and links, respectively.AvgNodeResults
,AvgLinkResults
: Arrays to store average results for nodes and links over the reporting period.
3. Averaging Results:
output_openAvgResults()
: Allocates memory for storing average results for nodes and links.output_closeAvgResults()
: Frees memory used for storing average results.output_initAvgResults()
: Initializes average results to zero for nodes and links.output_updateAvgResults()
: Updates the average results for nodes and links after each simulation step.output_saveAvgResults()
: Saves the average results to the binary file.
4. Subcatchment, Node, and Link Results:
- Subcatchment Results: Includes variables like rainfall, snow depth, evaporation, infiltration, runoff, and groundwater flow.
- Node Results: Includes variables like depth, head, volume, lateral inflow, and overflow.
- Link Results: Includes variables like flow, depth, velocity, volume, capacity, and pollutant concentrations.
5. System-Wide Results:
SysResults[SYS_*]
: Stores various system-wide variables such as total rainfall, evaporation, infiltration, runoff, and storage.output_saveSubcatchResults()
: Saves computed subcatchment results to the binary output file.output_saveNodeResults()
: Saves computed node results to the binary output file.output_saveLinkResults()
: Saves computed link results to the binary output file.
6. Time Management:
output_readDateTime()
: Reads the date and time for a specific reporting period from the binary output file.output_readSubcatchResults()
: Reads subcatchment results for a specific time period.output_readNodeResults()
: Reads node results for a specific time period.output_readLinkResults()
: Reads link results for a specific time period.
7. Large File Support:
- The code includes provisions for handling large files by using 64-bit file offsets (
F_OFF
) and conditional compilation for Windows and non-Windows platforms to handle large files.
Workflow:
-
File Initialization:
- The output file is opened, and basic project data is written to the binary file, including subcatchment, node, link, and pollutant data.
- The file is structured to store the ID names of objects, followed by their results for each reporting period.
-
Saving Results:
- The results for each subcatchment, node, and link are saved to the binary file. This includes both instantaneous results (e.g., flow, depth, volume) and averaged results (e.g., average flow over the reporting period).
-
Averaging Results:
- At the end of each reporting period, the average results for nodes and links are calculated and saved to the binary file. This allows for reporting of the average conditions over a given period.
-
System-Wide Results:
- System-wide results, such as total rainfall, total runoff, and total storage, are computed and stored in the
SysResults
array. These results are saved to the binary file after each reporting period.
- System-wide results, such as total rainfall, total runoff, and total storage, are computed and stored in the
-
Memory Management:
- Memory for storing results is dynamically allocated and freed as needed. This includes memory for average results and individual object results.
Summary:
The output.c
file is responsible for managing the output of SWMM5 simulations, specifically for saving and reading results in a binary format. It handles the calculation and storage of results for subcatchments, nodes, links, and pollutants over time. The file includes features for averaging results over reporting periods, supporting large files, and efficiently managing memory for storing simulation data. The integration of these features allows SWMM5 to generate detailed, time-step based output for various hydrological and water quality parameters.
No comments:
Post a Comment