skip to main content
Reach Water Quality
Water Quality
Reach Water Quality
The current implementation of the reach allows the user to model salinity with a simple well-mixed method or a discretized method. Temperature along with any combination of dissolved oxygen and salinity can also be modeled with the discretized methods.
On the reach, slots are added when a method from the Water Quality Routing category is selected (usually automatically based on the Reach Water Quality method); the available Water Quality Routing methods depend on the selected Reach Water Quality method and physical routing method. As a result, the documentation is organized by first listing all the slots, then the user-selectable methods, beginning of run behavior, dispatch slots and finally dispatch methods. Each method specifies whether it is valid for the well mixed or discretized set of methods.
Slots
Following is a list of all of the water quality slots used by the Reach. The slots are instantiated by the selected method in the Water Quality Routing category. Each of those methods list the slots that are instantiated.
Temperature Slots
Inflow Heat
Type: Multi Slot
Units: Heat
Description: holds the values of inflow heat for each inflow to the reservoir
I/O: Required Known
Diversion Temperature
Type: Series Slot
Units: Temperature
Description: temperature of Diversion
I/O: Optional input
Return Flow Temperature
Type: Series Slot
Units: Temperature
Description: temperature of Return Flow.
I/O: Optional input
Local Inflow Temperature
Type: Series Slot
Units: Temperature
Description: temperature of Local Inflow.
I/O: Optional input
Maximum Flow Rate for WQ Stability
Type: Table Slot
Units: Flow
Description: Input a flow rate which is greater then or equal to any anticipated for the simulation to keep the explicit solution stable.
Note:  Extremely large values will significantly increase computational cost.
I/O: Input only
Outflow Heat
Type: Series Slot
Units: Heat
Description: temperature of releases from the reservoir
I/O: Output only
Dispersion Coefficient
Type: Table Slot
Units: None
Description: longitudinal dispersion coefficient in units of L2/T
Information: used in temperature calculation
I/O: input only
Specific Heat of Water
Type: Table Slot
Units: SpecificHeat
Description: specific heat of water. Used for heat / temperature conversions.
I/O: optional input
Distributed Temperature Output
Type: Table Series Slot
Units: Various
Description: Table which displays the discretized values Water temperature with respect to distance within the Reach.
I/O: Output only - This is a temporary slot that is not saved in the model file.
Distributed Total Surface Flux Output
Type: Table Series Slot
Units: Various
Description: Table which displays the discretized values of the main components of surface heat exchange as well as the total surface flux with respect to distance.
I/O: Output only - This is a temporary slot that is not saved in the model file.
Air Temperature
Type: Series Slot
Units: Temperature
Description: air temperature at the reservoir surface
I/O: Input only
Dewpoint Temperature
Type: Series Slot
Units: Temperature
Description: dewpoint temperature at the reservoir surface
I/O: Required input
Incoming Solar Radiation
Type: Series Slot
Units: HeatFlux
Description: incoming solar radiation received by the reservoir
I/O: Required Input
Wind Velocity
Type: Series Slot
Units: Velocity
Description: wind velocity at reservoir surface
Information: This slot is assumed to be zero if not a user input.
I/O: Optional input
Distributed Temperature Output
Type: Table Series Slot
Units: Various
Description: Table which displays the discretized values Water temperature with respect to distance within the Reach.
I/O: Output only - This is a temporary slot that is not saved in the model file.
Salinity Slots
Inflow Salt Mass
Type: Series Slot
Units: Mass
Description: holds the values of inflow salinity for each inflow to the reach
I/O: Required known
Outflow Salt Mass
Type: Series Slot
Units: Mass
Description: salt mass in outflow from the reservoir
I/O: Output only
Seepage Salt Concentration
Type: Series Slot
Units: Concentration
Description: Salt concentration of the Seepage
I/O: Input, set by a rule, or propagated across a link.
Diversion Salt Concentration
Type: Series Slot
Units: Concentration
Description: salt concentration of Diversion.
I/O: Input, Output, or set by a rule.
Return Flow Salt Concentration
Type: Multi Slot
Units: Concentration
Description: salt concentration of Return Flow.
Information: When there are multiple links to this slot, the subslots will be shown. The first column is the sum column, which is not relevant as these are concentrations not mass.
I/O: Input, rules, or propagated from another object
Local Inflow Salt Concentration
Type: Series Slot
Units: Concentration
Description: salt concentration of Local Inflow.
I/O: Input, rules, solved for by dispatch method, or propagated from another object
Distributed Salt Concentration Output
Type: Table Series Slot
Units: Various
Description: Table which displays the discretized values of Salt Concentration with respect to distance within the Reach.
I/O: Output only - This is a temporary slot that is not saved in the model file.
Inflow Salt Concentration
Type: Series Slot
Units: Concentration
Description: holds the values of inflow salinity for inflow to the reach
I/O: Required known
Seepage Salt Mass
Type: Series Slot
Units: Mass
Description: Salt Mass of the Seepage
I/O: Output only
Return Flow Salt Mass
Type: Multi Slot
Units: Mass
Description: salt mass of Return Flow.
I/O: Optional known
Diversion Salt Mass
Type: Series Slot
Units: Mass
Description: The salt mass value of the Diversion from the reach
I/O: Output only
Local Inflow Salt Mass
Type: Series Slot
Units: Mass
Description: The salt mass value of the Local Inflow
I/O: Output Only
Outflow Salt Concentration
Type: Series Slot
Units: Concentration
Description: salinity of releases from the reservoir
I/O: Output only
Salt Mass Removal
Type: Series Slot
Units: Mass
Description: The mass of salt removed from the reach, typically by a linked Agg Diversion Site. This is included into the reach’s salinity mass balance. A positive Salt Mass Removal represents salt removed from (subtracted from) the Outflow Salt Mass.
I/O: Optional input, if not linked and not input, defaults to zero
Salt Available For Removal
Type: Series Slot
Units: Mass
Description: The maximum salt mass that can be removed without dropping below the specified Minimum Salt Concentration (if solving downstream) or exceeding the specified Maximum Salt Concentration (if solving upstream). If this slot is not linked, it is not used.
I/O: Output only
Salt Storage
Type: Series Slot
Units: Mass
Description: The mass of salt stored on the reach due to low flows
I/O: Initial timestep can be input, otherwise Output only.
Maximum Salt Concentration
Type: Periodic Slot
Units: Concentration
Description: The maximum possible salt concentration; i.e. the concentration at saturation
I/O: Input
Minimum Salt Concentration
Type: Periodic Slot
Units: Concentration
Description: The minimum possible salt concentration. There is no restriction on the value in this slot. It can be negative.
I/O: If the Salt Mass Removal slot is linked, this slot is required input. Otherwise it is an optional input.
Diversion Salt Concentration Maximum
Type: Series Slot with Periodic Input
Units: Concentration
Description: The maximum possible salt concentration on the diversion.
I/O: Optional input. Can be specified as a periodic or series relationship
Dissolved Oxygen Slots
Inflow Dissolved Oxygen Mass
Type: Multi Slot
Units: Mass
Description: holds the values of inflow dissolved oxygen for each inflow to the reservoir
I/O: Input, rules, or propagated across a link
Inflow Detritus Mass
Type: Multi Slot
Units: Mass
Description: holds the values of inflow detritus for each inflow to the reservoir
I/O: Input, rules, or propagated across a link
Inflow Dissolved Organics Mass
Type: Multi Slot
Units: Mass
Description: holds the values of inflow dissolved oxygen for each inflow to the reservoir
I/O: Input, rules, or propagated across a link
Inflow Ammonia Mass
Type: Multi Slot
Units: Mass
Description: holds the values of inflow ammonia for each inflow to the reservoir
I/O: Input, rules, or propagated across a link
Outflow Dissolved Oxygen Mass
Type: Series Slot
Units: Mass
Description: dissolved oxygen mass in Outflow from the reach
I/O: Output only
Outflow Detritus Mass
Type: Series Slot
Units: Mass
Description: detritus mass in Outflow from the reach
I/O: Output only
Outflow Dissolved Organics Mass
Type: Series Slot
Units: Mass
Description: dissolved oxygen mass in releases from the reach\
I/O: Output only
Outflow Ammonia Mass
Type: Series Slot
Units: Mass
Description: ammonia mass in the outflow from the reach
I/O: Output only
Diversion Detritus Concentration
Type: Series Slot
Units: Concentration
Description: detritus concentration of Diversion.
Information:  
I/O: Output only
Return Flow Detritus Concentration
Type: Series Slot
Units: Concentration
Description: detritus concentration of Return Flow.
I/O: Input, rules, solved for, or propagated across a link.
Local Inflow Detritus Concentration
Type: Series Slot
Units: Concentration
Description: detritus concentration of Local Inflow.
I/O: Input, rules, solved for, or propagated across a link.
Diversion Diss Org Concentration
Type: Series Slot
Units: Concentration
Description: dissolved organics concentration of Diversion.
I/O: Input, rules, solved for, or propagated across a link.
Return Flow Diss Org Conc
Type: Series Slot
Units: Concentration
Description: dissolved organics concentration of Return Flow.
I/O: Input, rules, solved for, or propagated across a link.
Local Inflow Diss Org Concentration
Type: Series Slot
Units: Concentration
Description: dissolved organics concentration of Local Inflow.
I/O: Input, rules, solved for, or propagated across a link.
Diversion Ammonia Concentration
Type: Series Slot
Units: Concentration
Description: detritus concentration of Diversion.
I/O: Input, rules, solved for, or propagated across a link.
Return Flow Ammonia Concentration
Type: Series Slot
Units: Concentration
Description: detritus concentration of Return Flow.
I/O: Input, rules, solved for, or propagated across a link.
Local Inflow Ammonia Concentration
Type: Series Slot
Units: Concentration
Description: ammonia concentration of Local Inflow.
I/O: Input, rules, solved for, or propagated across a link.
Diversion DO Concentration
Type: Series Slot
Units: Concentration
Description: dissolved oxygen concentration of Diversion.
I/O: Input, rules, solved for, or propagated across a link.
Return Flow DO Concentration
Type: Series Slot
Units: Concentration
Description: dissolved oxygen concentration of Return Flow.
I/O: Input, rules, solved for, or propagated across a link.
Local Inflow DO Concentration
Type: Series Slot
Units: Concentration
Description: dissolved oxygen concentration of Local Inflow.
I/O: Input, rules, solved for, or propagated across a link.
Total Dissolved Gas Slots
Inflow TDG Concentration
Type: Series
Units: Fraction
Description: TDG concentration of the Inflow
I/O: Input or output
Outflow TDG Concentration
Type: Series
Units: Fraction
Description: TDG concentration of the Outflow
I/O: Output only
TDG Lag Time
Type: Scalar
Units: Time
Description: The amount of time the TDG concentration should be lagged from the Inflow to the Outflow
I/O: Required Input
Delta Inflow
Type: Series
Units: Flow
Description: This slot represents the optimization variable for Delta Inflow
Delta Outflow
Type: Series
Units: Flow
Description: This slot represents the optimization variable for Delta Outflow.
Delta Inflow TDG Concentration
Type: Series
Units: Fraction
Description: This slot represents the optimization variable for Delta Inflow TDG Concentration.
Delta Outflow TDG Concentration
Type: Series
Units: Fraction
Description: This slot represents the optimization variable for Delta Inflow TDG Concentration.
User Methods
The following section describes the user-selectable methods for water quality modeling on the reach. These methods are necessary to choose the constituents and whether it is discretized or well mixed.
Reach Water Quality
Methods in this category are used to select the constituent and approach.
* None
No water quality solution is performed. No slots are added.
* Discretized Salt
No slots are added directly as the Water Quality Routing method adds the slots.
* Discretized Temperature
No slots are added directly as the Water Quality Routing method adds the slots.
* Discretized Temp and Salt
No slots are added directly as the Water Quality Routing method adds the slots.
* Discretized Temp and DO
No slots are added directly as the Water Quality Routing method adds the slots.
* Discretized Temp Salt and DO
No slots are added directly as the Water Quality Routing method adds the slots.
* Well Mixed Salt
No slots are added directly as the Water Quality Routing method adds the slots.
* Propagate TDG
No slots are added directly as the Water Quality Routing method adds the slots.
Water Quality Routing
On the reach, the appropriate water quality slots are added when a method is selected in the Water Quality Routing category. In this category, there are methods that are dependent on the selected constituents, solution approach, and routing method. They are used to represent how the constituents are routed through the reach.
Note:  For Discretized Salt and Propagate TDG, the method will be automatically selected based on these factors. For other approaches, you must select the method.
Each method describes when it is available and the slots that are instantiated. The slots are described above.
When the reach is an element of an Agg Reach, the aggregate controls the method selection on the elements and the element category is not shown (it is invisible). For Well Mixed Salt, the reaches can either model None or Mass Balance Salinity. For Discretized Salt, the reaches can either model None or Salinity. See the following topics for details:
* None
This is the default, no-action method for this category. It is available for any set of constituents, solution approach and routing methods. No slots are instantiated by this method.
* Time Lag; Temperature
This method is available for Discretized Temperature and the reach is configured to use Time Lag routing.
Slots Specific to This Method
• Lag Time
• Specific Heat
Method Details
This method calls the utility method solveTimeLagTemp.
* Time Lag Salt
This method is available for Discretized Salt and the reach is configured to use Time Lag routing.
Slots Specific to This Method
• Inflow Salt
• Lag Time
Method Details
This method calls the utility method solveTimeLagOutSalt.
Note:  In the associated flow routing method Time Lag Routing, you can select methods to specify/compute Local Inflow and Gain Loss. Neither of these are allowed in the WQ methods and will give an error if selected or specified. You will need to add another (no routing) reach to model these parameters.
* Time Lag; Salt and Temperature
This method is available for Discretized Temp and Salt and the reach is configured to use Time Lag routing.
Slots Specific to This Method
Method Details
This method calls the following utility methods:
* Time Lag; Temperature and DO
This method is available for Discretized Temp and DO and the reach is configured to use Time Lag routing.
Slots Specific to This Method
Method Details
This method calls the following utility methods:
* Time Lag; Salt, Temperature and Dissolved Oxygen
This method is available for Discretized Temp Salt and Dissolved Oxygen and the reach is configured to use Time Lag routing.
Slots Specific to This Method
Method Details
This method calls the following utility methods:
* Variable Time Lag Salt
This method is available for Discretized Salt and the reach is configured to use Variable Time Lag routing.
Slots Specific to This Method
• Inflow Salt
• Variable Lag Time
Method Details
This method calls the utility method solveVarTimeLagOutSalt.
Note:  In the associated flow routing method Variable Time Lag, you can select methods to specify/compute Evaporation and Precipitation, Local Inflow, Return Flow, and Gain Loss. None of these are allowed in the WQ methods and will give an error if selected or specified. You will need to add another (no routing) reach to model these parameters.
* No Routing; Temperature
This method is available for Discretized Temp and the reach is configured to use No Routing.
Slots Specific to This Method
Method Details
This method calls the following utility methods:
* Salinity
This method is available for Discretized Salt and the reach is configured to use No Routing.
Slots Specific to This Method
Method Details
This method calls the following utility methods:
* No Routing; Salt and Temperature
This method is available for Discretized Temp and Salt and the reach is configured to use No Routing.
Slots Specific to This Method
Method Details
This method calls the following utility methods:
* No Routing; Temperature and DO
This method is available for Discretized Temp and DO and the reach is configured to use No Routing.
Slots Specific to This Method
Method Details
This method calls the following utility methods:
* No Routing; Salt, Temperature and DO
This method is available for Discretized Temp Salt and DO and the reach is configured to use No Routing.
Slots Specific to This Method
Method Details
This method calls the following utility methods:
* Control Volume Explicit; Temperature
This method is available for Discretized Temperature and the reach is configured to use MacCormack, Kinematic, Kinematic Improved, Muskingum Cunge or Muskingum Cunge Improved routing.
Slots Specific to This Method
Method Details
This method calls the following utility methods:
This method solves for water temperature based on control volume mass balances. The numerical solution to the convection-diffusion equation is an explicit backward difference. To prevent instabilities, a user input maximum flow rate is required so that the water quality algorithm will maintain stability regardless of the simulation time step. This is accomplished by calculating the time step required for numerical stability based on a conservative substance. Although the mass balance for water temperature includes transformation it is assumed negligible for the stability of the solution. If the required time step for stability is less than the simulation time step, the algorithm is executed multiple times at a time step less than or equal to the required time step. The total time of these steps will cumulatively equal the simulation time step. If the user defined maximum flow is not exceeded in the simulation, the solution will remain stable.
* Control Volume Implicit; Temperature
This method is available for Discretized Temperature and the reach is configured to use MacCormack, Kinematic, Kinematic Improved, Muskingum Cunge, or Muskingum Cunge Improved routing.
Slots Specific to This Method
Method Details
This method calls the following utility methods:
The basic methodology of the controlVolumeImplicit method is no different than the controlVolumeExplicit method, with the exception of the solution technique being an implicit backward difference approximation to the convection equation. Longitudinal dispersion is not included in this method to decrease to computational effort in obtaining a solution. This numerical solution is unconditionally stable and does not require that a maximum flow rate be input by the user.
* Control Volume Explicit; Salt
This method is available for Discretized Salt, and the reach is configured to use MacCormack, Kinematic, Kinematic Improved, Muskingum Cunge, or Muskingum Cunge Improved routing.
Slots Specific to This Method
Method Details
This method calls the following utility methods:
This method solves for salt concentration based on control volume mass balances.
* Control Volume Implicit; Salt
This method is available for Discretized Salt, and the reach is configured to use MacCormack, Kinematic, Kinematic Improved, Muskingum Cunge, or Muskingum Cunge Improved routing.
Slots Specific to This Method
Method Details
This method calls the following utility methods:
The basic methodology of the controlVolumeImplicit method is no different than the controlVolumeExplicit method, with the exception of the solution technique being an implicit backward difference approximation to the convection equation.
* Control Volume Explicit; Salt and Temp
This method is available for Discretized Temp and Salt and the reach is configured to use MacCormack, Kinematic, Kinematic Improved, Muskingum Cunge, or Muskingum Cunge Improved routing.
Slots Specific to This Method
Method Details
This method calls the following utility methods:
This method solves for salt concentration and water temperature based on control volume mass balances. The numerical solution to the convection-diffusion equation is an explicit backward difference. To prevent instabilities, a user input maximum flow rate is required so that the water quality algorithm will maintain stability regardless of the simulation time step. This is accomplished by calculating the time step required for numerical stability based on a conservative substance. Although the mass balance for water temperature includes transformation it is assumed negligible for the stability of the solution. If the required time step for stability is less than the simulation time step, the algorithm is executed multiple times at a time step less than or equal to the required time step. The total time of these steps will cumulatively equal the simulation time step. If the user defined maximum flow is not exceeded in the simulation, the solution will remain stable.
* Control Volume Implicit; Salt and Temp
This method is available for Discretized Temp and Salt and the reach is configured to use MacCormack, Kinematic, Kinematic Improved, Muskingum Cunge, or Muskingum Cunge Improved routing.
Slots Specific to This Method
Method Details
This method calls the following utility methods:
The basic methodology of the controlVolumeImplicit method is no different than the controlVolumeExplicit method, with the exception of the solution technique being an implicit backward difference approximation to the convection equation. Longitudinal dispersion is not included in this method to decrease the computational effort in obtaining a solution. This numerical solution is unconditionally stable and does not require that a maximum flow rate be input by the user.
* Mass Balance Salinity
This method is available for Well Mixed Salt and the reach is configured to use No Routing.
Slots Specific to This Method
Method Details
This method exists to instantiate the appropriate slots. All of the calculations are performed in the dispatch method. The following dispatch methods are available when Mass Balance Salinity is selected:
When the reach is an element of an Agg Reach, the aggregate controls the method selection on the elements. For Well Mixed Salt, the reaches can either model None or Mass Balance Salinity. When Mass Balance Salinity is selected on the aggregate, then this method is selected on the reach but is invisible. The routing method must be No Routing or an error will be issued. See “None” and “Mass Balance Salinity” for details.
* No Routing, TDG
This method is available for Propagate TDG method and the reach is configured to use No Routing.
Slots Specific to This Method
• Inflow TDG Concentration
• Outflow TDG Concentration
The reach will route the TDG concentration:
(13.1)    
TDGO = Outflow TDG Concentration
TDGI = Inflow TDG Concentration
* Time Lag, TDG
This method is available for Propagate TDG method and the reach is configured to use No Routing.
Slots Specific to This Method
The reach will route the TDG concentration using a simple lag:
(13.2)    
TDGO = Outflow TDG Concentration
TDGI = Inflow TDG Concentration
TDGlag = TDG Lag Time
Reach Optimization Total Dissolved Gas
This category is only available if Propagate TDG method is selected for the Reach Water Quality category. It contains two methods, the default no-action None method and the Propagate TDG Deltas.
* None
This is the default no-action method.
* Propagate TDG Deltas
This is the optimization component of TDG modeling. See also the simulation model described above. This method instantiates the slots and then sets up the data necessary for the Optimization problem. The defining constraints are also described below.
Slots Specific to this Method
Delta Inflow
Type: Series
Units: Flow
Description: This slot represents the optimization variable for Delta Inflow
Delta Outflow
Type: Series
Units: Flow
Description: This slot represents the optimization variable for Delta Outflow.
Delta Inflow TDG Concentration
Type: Series
Units: Fraction
Description: This slot represents the optimization variable for Delta Inflow TDG Concentration.
Delta Outflow TDG Concentration
Type: Series
Units: Fraction
Description: This slot represents the optimization variable for Delta Inflow TDG Concentration.
For the this method, the deltas and concentrations must also be routed. A constraint is added to define the outflows as a lag from the inflow, for both delta concentration, delta flows and concentrations.
Note:  Flows and TDG deltas are lagged by separate slots which may or may not contain the same lag value.
(13.3)    
(13.4)    
(13.5)    
This method is also available when No Routing is used. In that case, the lag is assumed to be zero (and is not shown) and outflow values equal inflow values. See “Optimization Total Dissolved Gas category” for more information on the optimization solution for TDG on the Reservoir.
Solution/Dispatching
Beginning of Water Quality Run
The following behavior is executed one time at the beginning of the run. It is called from within beginning of run behavior on the Reach object.
1. If Diversion is not linked and not valid, set relevant Diversion parameter concentrations to zero.
2. If Return Flow is not linked and not valid, set relevant Return Flow parameter concentrations to zero.
3. If Return Flow Temperature is in use but not linked, issue an error if any values are missing.
4. If Local Inflow is not linked and not valid, set relevant Local Inflow parameter concentrations to zero.
5. If Specific Heat is not input, set it to 4.186 J/gC.
6. If Control Volume Explicit or Control Volume Implicit are selected water quality routing methods
– If modeling Temperature
• Check for Air Temperature, Dewpoint Temperature, and Solar Radiation data. If data is incomplete, then flag error and exit.
• If Wind Velocity data is incomplete, set is to zero.
• If Thermo Diffusion Coefficient Adjust data is incomplete, then fill values to 1.0.
– If Control Volume Explicit is selected water quality routing method, check for valid maximum flow value.
– If MacCormack or Muskingum Cunge routing, check for valid routing timestep.
• Check for initial heat and salt mass values. Flag error if not given.
• Call setWQInitConds (see setWQInitConds).
7. If modeling Total Dissolved Gas with time lag routing, check that the TDG Lag Time slot is valid.
Dispatch Methods
The following water quality dispatch methods exist on all reaches. In order for the method to be executed the first time for each timestep, both the known and unknown slot lists must be satisfied. Once a dispatch method has been invoked in normal simulation, the same method is executed again if any slot value is reset; this normally is caused by a value propagating across a link. Each dispatch method represents a possible combination of constituent and solution approach choices made at the global level.
* Solve Discretized Temp
This dispatch methods executes the selected method in the Water Quality Routing category (see “Water Quality Routing”).
Required Known slots
• Inflow
• Outflow
Unknown slots
* Solve Discretized Salt
This dispatch methods executes the selected method in the Water Quality Routing category (see “Water Quality Routing”).
Required Known Slots
• Inflow
• Outflow
Required Unknown slots
* Solve Discretized Temp and Salt
This dispatch methods executes the selected method in the Water Quality Routing category (see “Water Quality Routing”):
Required Known slots
• Inflow
• Outflow
Required Unknown Slots
* Solve Discretized Temp and DO
This dispatch methods executes the selected method in the Water Quality Routing category (see “Water Quality Routing”):
Required Known slots
• Inflow
• Outflow
Required Unknown slots
* Solve Discretized Temp Salt and DO
This dispatch methods executes the selected method in the Water Quality Routing category (see “Water Quality Routing”):
Required Known slots
• Inflow
• Outflow
Required Unknown Slots
* Solve Out Salt Given In Salt
This dispatch method is called when the Inflow, Outflow, and Inflow Salt Concentration slots are known and the Outflow Salt Concentration slot is unknown.
Required Known slots
• Inflow
• Local Inflow Salt Concentration (if Instantiated)
• Outflow
• Local Inflow (if instantiated)
Required Unknown slots
Method Details
If Maximum Salt Concentration does not contain a valid value, the run will abort.
Equivalent volumes over the timestep are calculated for the following flows: Inflow, Outflow, Diversion, Local Inflow (plus Local Inflow Adjust), Return Flow.
Inflow Salt Mass and Local Inflow Salt Mass are calculated by multiplying each concentration by the corresponding flow volume. If Local Inflow is zero and Local Inflow Salt Concentration is not specified, Local Inflow Salt Concentration and Local Inflow Salt Mass are set equal to zero.
Next calculate the diversion salt. If Diversion Salt Concentration is not specified (input or set by a rule), the local variable tempDivSaltConc is set to the minimum of the Inflow Salt Concentration and Diversion Salt Concentration Maximum (if specified). If Diversion Salt Concentration is specified, tempDivSaltConc is set to the specified value. If Diversion Salt Concentration is specified, then Return Flow must be zero (the “Special Export” condition). If Diversion Salt Concentration is specified and Return Flow is non-zero, the run will abort with an error message.
Then a check is made to see if the corresponding salt mass is available to be diverted. It will not allow more salt to be diverted than is in the inflow.
IF
IF
All of the Inflow Salt Mass will be diverted.
ELSE (Inflow Salt Mass is negative)
END IF
ELSE (There is sufficient salt mass in the inflow to meet the calculated diversion mass.)
END IF
If the Diversion Salt Concentration is not specified, then the slot value will be calculated based on the final Diversion Salt Mass.
IF
If Diversion is zero or is unused, Diversion Salt Concentration will be set to zero.
END IF
Note:  A specified Diversion Salt Concentration value will not be changed even when the Diversion Salt Mass is reduced, but a warning message will be issued to notify the user that the Diversion Salt Mass does not correspond to the specified Diversion Salt Concentration. The appropriate mass balance will be maintained.
If Return Flow Salt Mass is linked but not valid, the method will exit and wait for the linked Agg Diversion Site to solve for Return Flow Salt Mass. If Return Flow Salt Mass is not linked and does not contain a value, it will default to zero.
If Salt Storage at the previous timestep is invalid (NaN), the local variable prevSaltStorage is set equal to 0. Otherwise it is set equal to Salt Storage at the previous timestep.
If Salt Available For Removal is linked, a check is made that Minimum Salt Concentration contains a valid value (otherwise Minimum Salt Concentration is an optional input). If Minimum Salt Concentration does not contain a valid value, the run will abort and an error message will be posted. Then Salt Available For Removal is calculated as follows:
IF
ELSE (negative Outflow)
For negative Outflow, removing salt will raise the concentration, so the maximum available for removal is based on the Maximum Salt Concentration.
END IF
If Salt Mass Removal is linked, it will check for a value in the slot. If there is no value, the method will exit and wait for the linked Agg Diversion Site to solve. If the slot is not linked and it does not contain an input value, it is set to zero.
Then the initial salinity mass balance solves for the local variable tempOutSaltMass:
After setting tempOutSaltMass it then carries out the following logic to check if the Outflow Salt Mass should be adjusted:
IF
IF
If there is no Outflow, and positive tempOutSaltMass will get added to Salt Storage.
ELSE (tempOutSaltMass is negative)
IF
Any available Salt Storage will be used to bring the Outflow Salt Mass up to 0.
ELSE (There is not enough Salt Storage to make up the negative tempOutSaltMass.
The negative salt will be added to the Salt Storage to make it more negative. A warning message is posted in this case: “The reach calculated that -11587.04 * 1.0 tons of salt must be stored. The new Salt Storage is ‑11587.036381 * 1.0 tons.”
END IF
END IF
ELSE (Outflow is non-zero.)
Solve for the initial outflow concentration
IF
Set the concentration to the maximum. Any excess salt will get added to Salt Storage.
ELSE
Use up any existing Salt Storage up to the maximum concentration.
First calculate the maximum amount of salt that could be added to the Outflow without exceeding the maximum concentration.
IF
ELSE
For a negative Outflow, adding to the Outflow Salt Mass will lower the concentration, so the maximum that can be added is based on the Minimum Salt Concentration if it is specified, otherwise all Salt Storage will be added.
IF
ELSE
END IF
END IF
IF
Add all of the stored salt to the Outflow.
ELSE (Stored salt is more than the maximum that can be added.)
Only increase outflow salt up to the maximum.
END IF
END IF
END IF
Finally calculate the new Salt Storage.
* Solve In Salt Given Out Salt
This dispatch method is called when the Inflow, Outflow, and Outflow Salt Concentration slots are known and the Inflow Salt Concentration slot is unknown.
Required Known Slots
• Inflow
• Outflow
• Local Inflow (if instantiated)
• Local Inflow Salt Concentration (if Instantiated)
Required Unknown Slots
Method Details
If Maximum Salt Concentration does not contain a valid value, the run will abort.
Equivalent volumes over the timestep are calculated for the following flows: Inflow, Outflow, Diversion, Local Inflow (plus Local Inflow Adjust), Return Flow.
If Local Inflow is zero and Local Inflow Salt Concentration is not specified, Local Inflow Salt Concentration and Local Inflow Salt Mass are set equal to zero.
In order for the Reach to solve for inflow salt and diversion salt, it must know the return flow salt, which is solved for by the linked object or must be specified. If Return Flow Salt Mass is linked, and it is not linked to the same object as the Diversion Salt Concentration, then the Return Flow Salt Mass must be valid, or the method will exit and wait for more information.
If Return Flow Salt Mass and Diversion Salt Concentration are linked to the same Agg Diversion Site, the Return Flow Salt Mass from the Agg Diversion Site is calculated as follows:
Or if Return Flow is zero, then .
Therefore if the Reach knows the value for saltPickupMass, it can solve for inflow salt and diversion salt. The Reach retrieves the value for saltPickupMass from one of four slots on the Agg Diversion Site, depending on which Return Flow Salt method is selected on the Agg Diversion Site, as described in Table 13.1.
Note:  Return Flow Salt Mass can only be linked to a single slot.
 
Table 13.1   
Agg Diversion Site
Return Flow Salt Method / Salinity Pickup Method (If Applicable)
saltPickupMass
None
0
Variable Salt Pickup/Salt Pickup Concentration
Variable Salt Pickup/Salt Pickup Mass
Return Flow Salinity Pickup Mass
Distributed Annual Salt Loading
Distributed Salinity Pickup Mass
Lumped Salt
Salt Loading
If Salt Storage at the previous timestep is invalid (NaN) or negative, the local variable prevSaltStorage is set equal to 0. Otherwise it is set equal to Salt Storage at the previous timestep.
Outflow Salt Mass and Local Inflow Salt Mass are calculated by multiplying each concentration by the corresponding flow volume.
If Salt Available For Removal is linked, its value is calculated as follows:
IF
IF
IF
ELSE (negative Inflow)
END IF
ELSE (Diversion Salt Concentration is not specified)
IF
ELSE (negative Inflow)
END IF
END IF
ELSE (Return Flow is non-zero, so diversion salt cancels from the mass balance)
IF
ELSE (negative Inflow)
END IF
END IF
If Salt Mass Removal is linked, the method will check for a value in the slot. If there is no value, the method will exit and wait for the linked Agg Diversion Site to solve. If the slot is not linked and it does not contain an input value, it is set to zero.
Then the initial salinity mass balance solves for the local variable tempInSaltMass. The form of the mass balance depends on whether there is a non-zero Return Flow and whether or not Diversion Salt Concentration is specified (input or set by a rule).
IF
If Return Flow is non-zero, all diverted salt mass gets returned and thus cancels from the mass balance.
IF
There cannot be a non-zero salt mass if there is no Inflow.
IF
IF
Use any Salt Storage to make up the difference, so that Inflow Salt Mass will be zero. The change in Salt Storage will be accounted for at the end of the method.
ELSE
There is not enough Salt Storage to make up the difference. This would result in positive salt with no flow, so the run will abort with an error message.
END IF
ELSE (tempInSaltMass is negative or zero)
Any change will be added to Salt Storage.
END IF
ELSE (Inflow is non-zero)
Incorporate salt from storage if there is any.
IF
IF
If the Minimum Salt Concentration is specified, calculate the corresponding minimum mass. Minimum Salt Concentration is generally an optional input, but it is a required input if using one of the Salt Removal methods on a linked Agg Diversion Site.
ELSE
If the minimum is not specified, all Salt Storage will be incorporated.
END IF
ELSE
For a negative Inflow, incorporating more salt from storage will lower the Inflow Salt Mass but will raise the Inflow Salt Concentration, so the minimum inflow mass is based on the Maximum Salt Concentration.
END IF
IF
Use up all of the salt from storage.
ELSE
Using up all Salt Storage would take Inflow Salt Concentration below the minimum, so only take it down to the minimum.
This also takes care of the case when tempInSaltMass is already less than the minimum. It will bring the inflow salt up to the minimum, and the difference will get added to Salt Storage.
END IF
END IF
Calculate the change in Salt Storage.
ELSE (Return Flow is zero. It is either the “Special Export” condition or there is no Diversion.)
The mass balance calculation depends on whether or not Diversion Salt Concentration is an specified (input or set by a rule)
IF
IF
There cannot be a non-zero salt mass if there is no Inflow.
IF
IF
Use any Salt Storage to make up the difference, so that Inflow Salt Mass will be zero. The change in Salt Storage will be accounted for at the end of the method.
ELSE
There is not enough Salt Storage to make up the difference. This would result in positive salt with no flow, so the run will abort.
END IF
ELSE (tempInSaltMass is negative or zero)
Any change will be added to Salt Storage.
END IF
ELSE (Inflow is non-zero)
Incorporate salt from storage if there is any.
IF
IF
If the Minimum Salt Concentration is specified, calculate the corresponding minimum mass. Minimum Salt Concentration is generally an optional input, but it is a required input if using one of the Salt Removal methods on a linked Agg Diversion Site.
ELSE
If the minimum is not specified, all Salt Storage will be incorporated.
END IF
ELSE
For a negative Inflow, incorporating more salt from storage will lower the Inflow Salt Mass but will raise the Inflow Salt Concentration, so the minimum inflow mass is based on the Maximum Salt Concentration.
END IF
IF
Use up all of the salt from storage.
ELSE
Using up all Salt Storage would take Inflow Salt Concentration below the minimum, so only take it down to the minimum.
This also takes care of the case when tempInSaltMass is already less than the minimum. It will bring the inflow salt up to the minimum, and the difference will get added to Salt Storage.
END IF
END IF
Calculate the change in Salt Storage.
ELSE (Return Flow is zero, and Diversion Salt Concentration is not specified.)
Diversion Salt Concentration will either be zero (if there is no Diversion), or it will be equal to the Inflow Salt Concentration.
First calculate the initial net in salt mass. This is the Inflow Salt Mass minus the Diversion Salt Mass.
IF
There cannot be a non-zero salt mass if there is no net flow.
IF
IF
Use any Salt Storage to make up the difference, so that netInSaltMass will be zero. The change in Salt Storage will be accounted for at the end of the method.
ELSE
There is not enough Salt Storage to make up the difference. This would result in positive salt with no flow, so the run will abort.
END IF
ELSE (tempNetInSaltMass is negative or zero)
Any change will be added to Salt Storage.
END IF
ELSE (netInVol is non-zero)
Incorporate salt from storage if there is any.
IF
IF
If the Minimum Salt Concentration is specified, calculate the corresponding minimum mass. Minimum Salt Concentration is generally an optional input, but it is a required input if using one of the Salt Removal methods on a linked Agg Diversion Site.
ELSE
If the minimum is not specified, all Salt Storage will be incorporated.
END IF
ELSE
For a negative netInVol, incorporating more salt from storage will lower the netInSaltMass but will raise the concentration, so the minimum mass is based on the Maximum Salt Concentration.
END IF
IF
Use up all of the salt from storage.
ELSE
Using up all Salt Storage would take Inflow Salt Concentration below the minimum, so only take it down to the minimum.
This also takes care of the case when tempInSaltMass is already less than the minimum. It will bring the inflow salt up to the minimum, and the difference will get added to Salt Storage.
END IF
END IF
Calculate the Inflow Salt Mass and the change in Salt Storage.
END IF
END IF
Set the final Diversion Salt Concentration if it is not specified, and calculate the Diversion Salt Mass.
IF
IF
ELSE
END IF
END IF
Finally calculate the new Salt Storage.
* Solve Local In Salt Given In and Out
This dispatch method is called when the Inflow, Outflow, Local Inflow, Inflow Salt Concentration and Outflow Salt Concentration slots are known and the Local Inflow Salt Concentration slot is unknown.
Required Known slots
• Inflow
• Outflow
• Local Inflow
Required Unknown slots
Method Details
If Maximum Salt Concentration does not contain a valid value, the run will abort.
Equivalent volumes over the timestep are calculated for the following flows: Inflow, Outflow, Diversion, Local Inflow (plus Local Inflow Adjust), Return Flow.
Inflow Salt Mass and Local Inflow Salt Mass are calculated by multiplying each concentration by the corresponding flow volume. If Local Inflow is zero and Local Inflow Salt Concentration is not specified, Local Inflow Salt Concentration and Local Inflow Salt Mass are set equal to zero.
Next calculate the diversion salt. If Diversion Salt Concentration is not specified (input or set by a rule), the local variable tempDivSaltConc is set to the minimum of the Inflow Salt Concentration and Diversion Salt Concentration Maximum (if specified). If Diversion Salt Concentration is specified, tempDivSaltConc is set to the specified value. If Diversion Salt Concentration is specified, then Return Flow must be zero (the “Special Export” condition). If Diversion Salt Concentration is specified and Return Flow is non-zero, the run will abort with an error message.
Then a check is made to see if the corresponding salt mass is available to be diverted. It will not allow more salt to be diverted than is in the inflow.
IF
IF
All of the Inflow Salt Mass will be diverted.
ELSE (Inflow Salt Mass is negative)
END IF
ELSE (There is sufficient salt mass in the inflow to meet the calculated diversion mass.)
END IF
If the Diversion Salt Concentration is not specified, then the slot value will be calculated based on the final Diversion Salt Mass.
IF
If Diversion is zero or is unused, Diversion Salt Concentration will be set to zero.
END IF
Note:  A specified Diversion Salt Concentration value will not be changed even when the Diversion Salt Mass is reduced, but a warning message will be issued to notify the user that the Diversion Salt Mass does not correspond to the specified Diversion Salt Concentration. The appropriate mass balance will be maintained.
If Return Flow Salt Mass is linked but not valid, the method will exit and wait for the linked Agg Diversion Site to solve for Return Flow Salt Mass. If Return Flow Salt Mass is not linked and does not contain a value, it will default to zero.
If Salt Storage at the previous timestep is invalid (NaN) or negative, the local variable tempInSaltMass is set equal to 0. Otherwise it is set equal to Salt Storage at the previous timestep.
Inflow Salt Mass, Outflow Salt Mass and Diversion Salt Mass are calculated by multiplying each concentration by the corresponding flow volume.
If Salt Available For Removal is linked, its value is calculated as follows:
IF
ELSE (negative Local Inflow)
For negative Outflow, removing salt will lower the concentration, so the maximum available for removal is based on the Minimum Salt Concentration.
END IF
If Salt Mass Removal is linked, it will check for a value in the slot. If there is no value, the method will exit and wait for the linked Agg Diversion Site to solve. If the slot is not linked and it does not contain an input value, it is set to zero.
Then the initial salinity mass balance solves for the local variable tempInSaltMass:
After setting tempInSaltMass it then carries out the following logic to check if the Local Inflow Salt Mass should be adjusted:
IF
IF
IF
Use any Salt Storage to make up the difference, so that Local Inflow Salt Mass will be zero. The change in Salt Storage will be accounted for at the end of the method
ELSE
There is not enough Salt Storage to make up the difference. This would result in positive salt with no flow, so the run will abort.
END IF
ELSE (tempInSaltMass is negative or zero)
Any change will be added to Salt Storage.
END IF
ELSE (Local Inflow is non-zero)
Incorporate salt from storage if there is any.
IF
IF
If the Minimum Salt Concentration is specified, calculate the corresponding minimum mass. Minimum Salt Concentration is generally an optional input, but it is a required input if using one of the Salt Removal methods on a linked Agg Diversion Site.
ELSE
If the minimum is not specified, all Salt Storage will be incorporated.
END IF
ELSE
For a negative Local Inflow, incorporating more salt from storage will lower the Local Inflow Salt Mass but will raise the Local Inflow Salt Concentration, so the minimum local inflow mass is based on the Maximum Salt Concentration.
END IF
IF
Use up all of the salt from storage.
ELSE
Using up all Salt Storage would take Local Inflow Salt Concentration below the minimum, so only take it down to the minimum.
This also takes care of the case when tempInSaltMass is already less than the minimum. It will bring the local inflow salt up to the minimum, and the difference will get added to Salt Storage.
END IF
END IF
Calculate the change in Salt Storage.
* Solve Outflow TDG
This dispatch method is called when the Inflow, Outflow, Local Inflow, Inflow Salt Concentration and Outflow Salt Concentration slots are known and the Local Inflow Salt Concentration slot is unknown.
Required Known slots
Required Unknown slots
• None
This method executes the Water Quality Routing method, either No Routing, TDG or Time Lag, TDG; see “No Routing, TDG”.
Utility Methods
Utility Methods are methods (subroutines, or functions) which do not belong to a user-selectable method type. Each of the utility methods outlined below is used by one or more of the methods above.
Note:  Some of these methods set slots directly, while others return values but do not set slots explicitly.
* calcHar
This method returns Har (J/(m^2*day), the surface heat flux due to incoming solar radiation, using the following equation (Thomann and Mueller, 1987):
(13.6)    
where
The values of the Stefan-Boltzmann constant and A are constants or internally set variables. Ta is user input through the Air Temperature slot, and air vapor pressure is returned by the getAirVaporPressure method (see below).
* calcHbr
This method returns Hbr (J/(m^2*day), the longwave radiation emitted by the reach, using the Stefan-Boltzmann law for a (nearly perfect) black-body emitter:
(13.7)    
where
The values of the Stefan-Boltzmann constant and emissivity are static variables. Ts is the value of the reach segment temperature from the previous timestep (Distributed Temperature Output(‑1)).
* calcHc
This method returns Hc (J/(m^2*day), the heat flux at the reach surface due to conduction. The form of the equation is:
(13.8)    
where:
getWindEffect is a utility method (see below) and 41860 is the conversion rate from cal/cm2 to J/m2.
* calcHe
This method returns He (J/(m^2*day)), the heat flux at the surface due to evaporative heat loss. The form of the equation is:
(13.9)    
where
getWindEffect is a utility method and 41860 is the conversion rate from cal/cm2 to J/m2.
* checkSideFlowConcDO
The function checkSideFlowConcDO checks detritus, ammonia, dissolved organics, and dissolved oxygen concentrations associated with side flows and sets them if appropriate.
Method Details
First, if Local Inflow is not in use, issue an error.
Next, if Diversion concentration for each DO component is not valid, set it to the respective inflow concentrations. If the respective return flow concentrations or local inflow concentrations are linked but are not valid, the method is exited so that the other object can solve first and propagate a concentration across the link.
* checkSideFlowConcSalt
The function checkSideFlowConcSalt checks salt concentrations associated with side flows.
First, if Local Inflow Salt Concentration is linked but not valid, exit the method and wait for it to become valid. If it is not linked, but Local Inflow is linked and Local Inflow Salt Concentration is not valid, issue an error that you should specify the value.
If Return Flow Salt Concentration is linked but not valid, exit the method and wait for it to become valid. If it is not linked, but Return Flow is linked and Return Flow Salt Concentration is not valid, issue an error that you should specify the value.
* checkSideFlowTemp
The function, checkSideFlowTemp, checks temperatures associated with side flows and sets them if appropriate.
Method Details
First, if the previous Diversion Temperature is not valid, set a local variable temp to 10deg Celsius. Otherwise, set temp to the previous Diversion Temperature. This value is used to compute the density of the water. If the current Diversion Temperature is not valid, set it to:
(13.10)    
If Local Inflow is in use but Local Inflow Temperature is linked but not valid, exit the method and wait for it to become valid.
If Return Flow Temperature is linked but not valid, exit the method and wait for it to become valid.
* defaultCalcSurfaceFlux
This method is called from solveTempWQcontrolVolume Explicit and solveTempControlVolumeImplcit. This method calls several subroutines, each of which calculate a specific flux type. The total flux is recorded in the Surface Heat Flux slot. It is the sum of incoming solar radiation (input variable), long and short wave back radiation (calcHar and calcHbr), conductive/convective (calcHc), and evaporative (calcHe) heat fluxes.
* getAirVaporPressure
This method returns Air Vapor Pressure, the vapor pressure of the air mass overlying the reach
(13.11)    
where
* getDensity
This method returns water density for a given temperature, temp. Calculations are based on the following polynomial relationship with temperature:
(13.12)    
If this value evaluates to a density greater than 1x106 g/m3, the method returns 1x106 g/m3.
* getQualStep
The function getQualStep is called if one of the control volume explicit methods is selected. It looks at Maximum Flow Rate for WQ Stability provided by the user and sets an internal water quality timestep, Water Quality Timestep Computed, in order to satisfy stability. It also sets Num WQ Steps per Sim Timestep.
* getSurfaceVaporPressure
This method returns Surface Vapor Pressure, the vapor pressure at the surface of the reach:
(13.13)    
where
* getWindEffect
This method returns Coefficient of Wind Effect, the effect of wind on the surface heat flux equations.
(13.14)    
where
* solveNoRoutingDO
This method calculates Outflow Detritus Mass, Outflow Dissolved Organics Mass, Outflow Ammonia Mass, and Outflow Dissolved Oxygen Mass based on Inflow Detritus Mass, Inflow Diss Org Mass, Inflow Ammonia Mass, Inflow Diss Oxygen Mass and the associated side flow concentrations. Each constituent is calculated with the same basic equation where Constituent is DO variable.
(13.15)    
* solveNoRoutingOutSalt
This method calculates Outflow Salt Mass and Concentration based on Inflow Salt Conc, Return Flow Salt Concentration, Diversion Salt Concentration, Local Inflow Salt Concentration, Seepage Salt Concentration (if modeled) and the respective flows as follows:
If Diversion Salt Concentration is not input or set by a rule, then it is set to the Inflow Salt Concentration.
When a non-default Seepage method is selected and the water quality approach is Discretized Salt, Seepage Salt Concentration and Seepage Salt Mass slots are available. If Seepage is positive, the Seepage Salt Concentration is set to the Inflow Salt Concentration. If Seepage is negative, the Seepage Salt Concentration must be specified possibly by a link to a slot on another object. If Seepage Salt Concentration is linked but not valid, the reach exits the dispatch method and waits until the seepage Salt Concentration is available from that object. Seepage Salt Mass is computed from the Seepage Salt Concentration and the Seepage.
Note:  Although there are Seepage Routing methods, these only serve to compute the Seepage at the current timestep. In general, Outflow = Inflow - Seepage. Thus, the Seepage Salt concentration does not need to be routed; it is just the value at that timestep.
Then, for each constituent, if the concentration and the flow is valid, the mass is computed. Otherwise the mass is considered zero, but not set.
Finally:
(13.16)    
Finally, Outflow Salt Concentration is computed from the Outflow and Outflow Salt Mass.
* solveNoRoutingTemp
This method calculates Outflow Heat based on Inflow Heat, Return Flow Temperature, Diversion Temperature, and Local Inflow Salt Temperature.
(13.17)    
where is water density and H is Specific Heat of Water.
* solveSaltWQcontrolVolumeExplicit
There are two control volume water quality methods: controlVolumeExplicit and controlVolumeImplicit. Both of these methods utilize the discretized hydraulic variables generated from the hydraulic routing methods. Therefore a hydraulic routing method must be used with the control volume water quality methods. The difference between controlVolumeExplicit and controlVolumeImplicit is simply in the solution technique described in the following sections
This method uses the following mass balance equation for a conservative substance to Calculate Distributed Salt Concentration Output, the salt concentrations of each discretized segment of the reach. This function also sets Outflow Salt Mass for the reach.
(13.18)    
where M = salt mass [M], c = salt concentration [M/L3], E = longitudinal dispersion coefficient [L2/T], and A = cross sectional area [L2].
* solveSaltWQcontrolVolumeImplicit
This method uses the following mass balance equation for a conservative substance to calculate Distributed Salt Concentration Output, the salt concentrations of each discretized segment of the reach. This function also sets Outflow Salt Mass for the reach.
(13.19)    
* solveTempWQcontrolVolumeExplicit
This method uses the following mass balance equation to calculate Distributed Temperature Output, the temperature of each discretized segment of the reach. This function also sets Outflow Heat for the reach.
(13.20)    
where T = water temperature, V = elemental volume [L3], H = flux of thermal energy across the system boundaries [H/L2/T], Asi = water surface area [L2], = water density [M/L3], and c = specific heat of water [H/M/Temp.]
* solveTempWQcontrolVolumeImplicit
This method uses the following mass balance equation to calculate Distributed Temperature Output, the temperature of each discretized segment of the reach. This function also sets Outflow Heat for the reach.
(13.21)    
* solveTimeLagDO
This method calculates Outflow Detritus Mass, Outflow Diss Org Mass, Outflow Ammonia Mass, and Outflow Diss Oxygen Mass at future timesteps based on Inflow Detritus Mass, Inflow Diss Org Mass, Inflow Ammonia Mass, Inflow Diss Oxygen Mass at the current timestep and Lag Time of the reach.
* solveTimeLagOutSalt
This method calculates Outflow Salt Concentration and Mass at future timesteps based on Inflow Salt Concentration at the current timestep and Lag Time of the reach.
* solveVarTimeLagOutSalt
This method calculates Outflow Salt Concentration and Mass at future timesteps based on Inflow Salt Concentration at the current timestep (and previous timesteps) and Variable Lag Time of the reach.
This method executes when the Inflow Salt Concentration is known for the current timestep. The resulting Inflow Salt Mass is computed using the Inflow. Outflow Salt Concentration (and Mass) values are solved for at the timesteps corresponding to the Variable Lag Time. A sample calculation is given below:
(13.22)    
(13.23)    
where flowFrac1 and flowFrac2 to are calculated by the following equations:
(13.24)    
(13.25)    
In the equations given above, the integer value of a number means that the number is truncated after the decimal point with no rounding.
Since the lag time can vary with every timestep, it possible that more the one Inflow Salt Mass can contribute to a particular Outflow Salt Mass/Concentration. This method may set multiple Outflow Salt Mass/Concentrations (up to the max lag) based on a range of previous and future Inflow Salt Mass values.
* solveTimeLagTemp
This method calculates Outflow Heat based at future timesteps based on Inflow Heat at the current timestep and Lag Time of the reach.
* setWQInitConds
The function getQualStep is called if one of the control volume methods (either explicit or implicit) is selected. It sets initial salt concentrations and temperatures in each internal reach segment by setting previous values on Distributed Salt Concentration Output, and Distributed Temperature Output.
 
Revised: 06/03/2019