The massbal.c
file is responsible for handling mass balance calculations in the SWMM5 (Storm Water Management Model) system. It ensures that water, pollutants, and groundwater mass are properly tracked and conserved throughout the system. The file provides functions for initializing, updating, and reporting mass balances for various components, such as runoff, groundwater, flow routing, and water quality (WQ).
Key Features of the Code:
Constants:
MAX_RUNOFF_BALANCE_ERR
: The maximum allowed error in runoff mass balance (set to 10%).MAX_FLOW_BALANCE_ERR
: The maximum allowed error in flow mass balance (set to 10%).
Shared Variables:
RunoffTotals
: Tracks total values for surface runoff (rainfall, evaporation, infiltration, runoff, etc.).LoadingTotals
: Tracks pollutant mass balance totals (washoff, deposition, infiltration, etc.).GwaterTotals
: Tracks groundwater mass balance totals (infiltration, evaporation, percolation, etc.).FlowTotals
: Tracks total flow mass balance totals (inflows, outflows, flooding, storage, etc.).StepFlowTotals
: Stores flow totals for the current time step.StepQualTotals
: Stores water quality totals for the current time step.NodeInflow
andNodeOutflow
: Store the total inflows and outflows for each node.TotalArea
: The total drainage area for the system.
Exportable Variables:
NodeInflow
andNodeOutflow
: Store the inflows and outflows for each node in the system.TotalArea
: Represents the total drainage area in square feet.
Key Functions:
-
massbal_open()
:- Initializes the mass balance system by setting up the global totals for water, pollutants, and flow for the system. It allocates memory for arrays that track water quality totals, inflows, and outflows, and initializes continuity errors.
-
massbal_close()
:- Frees the memory allocated by the mass balance system.
-
massbal_report()
:- Reports mass balance results for the system. It calculates and reports errors in runoff, groundwater, and flow routing mass balances.
-
massbal_getBuildup()
:- Computes the total buildup of pollutants in the system by summing up the contributions from various subcatchments.
-
massbal_updateRunoffTotals()
:- Updates the runoff totals (e.g., rainfall, infiltration, runoff) after each time step.
-
massbal_updateGwaterTotals()
:- Updates groundwater totals, tracking values like infiltration, evaporation, percolation, and groundwater outflow.
-
massbal_updateRoutingTotals()
:- Updates routing totals for flow and water quality over the current time step. It tracks the inflows, outflows, and losses for both flow and pollutants.
-
massbal_addInflowFlow()
andmassbal_addOutflowFlow()
:- Adds inflow and outflow flow values for routing totals, respectively.
-
massbal_addInflowQual()
andmassbal_addOutflowQual()
:- Adds inflow and outflow pollutant mass values for routing totals.
-
massbal_addReactedMass()
:- Adds the mass of pollutants that have reacted during the current time step.
-
massbal_getStorage()
:- Computes the total system storage, summing up the volumes in both nodes and links.
-
massbal_getStoredMass()
:- Computes the total mass of pollutants stored in the system, accounting for both nodes and links.
-
massbal_getRunoffError()
:- Calculates the mass balance error for runoff, comparing the inflows and outflows in the system.
-
massbal_getLoadingError()
:- Calculates the mass balance error for pollutant loadings, comparing the total buildup and removal of pollutants.
-
massbal_getGwaterError()
:- Computes the mass balance error for groundwater, comparing the total inflows and outflows in the groundwater system.
-
massbal_getFlowError()
:- Computes the flow routing mass balance error, comparing the total inflows and outflows of the flow system.
-
massbal_getQualError()
:- Computes the water quality routing mass balance error, comparing the inflows and outflows of pollutants.
-
massbal_getStepFlowError()
:- Computes the flow error for the current time step, comparing the inflows and outflows of the system.
Mass Balance for Runoff, Pollutants, and Groundwater:
- The system tracks water and pollutant movements through the network of subcatchments, nodes, and links. Each component (e.g., runoff, pollutants, groundwater) has its own set of continuity totals that are updated as the simulation progresses.
- Runoff: Tracks rainfall, infiltration, evaporation, and runoff flows.
- Water Quality (WQ): Tracks pollutant buildup, deposition, infiltration, and runoff.
- Groundwater: Tracks infiltration into groundwater, evaporation from groundwater, and percolation into deeper layers.
Error Handling:
- The code checks for mass balance errors in various components (runoff, pollutants, groundwater, flow routing) and ensures that the system conserves mass throughout the simulation. Any errors in the mass balance are flagged and reported.
Reporting:
- At the end of the simulation or during the process, the
massbal_report()
function generates a report detailing the mass balance errors for runoff, pollutants, groundwater, and flow routing. This is crucial for assessing the accuracy and performance of the model.
Summary:
The massbal.c
file is a critical component for mass balance calculations in SWMM5. It ensures that water, pollutants, and groundwater are properly tracked and conserved throughout the simulation. The system handles both the mass balance updates during each time step and the final reporting of any errors in the conservation of mass. By keeping track of inflows, outflows, and changes in storage, the code ensures that the system behaves in a physically realistic manner and helps identify any inconsistencies or errors in the model's performance.
No comments:
Post a Comment