The HEC Water Quality Engine was developed using modern Fortran. This language was chosen for two reasons: 

  1. the computational speed of the language for problems involving large watersheds, highly resolved areas, or large numbers of water quality constituents, and
  2. interfacing with pre-existing ERDC-EL water quality libraries, which are also written in Fortran.

Communication between the driving program (HEC-ResSim, written in Java) and the HEC-WQ Engine utilizes the Java Native Interface (JNI), a framework which allows Java code to call libraries written in platform-dependent languages. Fortran API routines, bundled as a static library (.lib file) are called through C++ wrappers, which are bundled as a dynamic library (.dll). The JNI and C++ wrappers pass simple arrays of primitive variables for efficient communication. From the Java side, a specific class (WQEngineAdapter) provides Java calls to access the native methods.

The WQEngineAdapter class is part of a package of Java classes that provide support for interaction with the HEC-WQ Engine. These routines may be used by other driving programs written in Java in order to run the engine. They may also be called through the HEC-ResSim scripting interface provided for operational rules and state variables. This interface allows users to access water quality compute variables during the compute, and may be utilized to:

  • update water quality boundary conditions during the compute,
  • update water quality parameters (e.g., algal growth rates) during the compute,
  • access water quality concentrations and use them to determine reservoir operations, 
  • access water quality concentrations and use them to determine in diversion operations, and
  • tabulate and output derived water quality quantities or metrics (e.g., number of days with an average downstream water temperature above a certain threshold).

Computed water quality constituent concentrations are output at a user-defined time interval to a Hierarchical Data Format, version 5 (HDF5) file. This format was chosen because of its efficiency in storing large two-dimensional arrays, its hierarchical dataset organization, its established use, documentation and support. In the output file, results are organized by water quality subdomain (the reach or reservoir in HEC-ResSim) as shown below. Water quality constituents are stored in separate HDF5 datasets. For each dataset, the columns correspond to the water quality cell (reaches) or vertical layer (reservoirs). Reach cell numbers increase from upstream to downstream in reaches; reservoir layer numbers increase from lower to higher elevations. Dataset rows correspond to the output times.

Output times are provided as separate one-dimensional datasets - one gives times in datetime string format and another the fractional days from the start of the simulation. All output data is given as instantaneous values (not period-averaged). In addition to constituent concentrations, derived variables, nutrient and heat fluxes, and cell/layer water volumes and constituent masses can be output to the HDF5 file. An example of the dataset organization is shown below.

ResSim water quality hdf5 dataset organization. Directories are given for Geometry and Results. In each directory, subdirectories exist for the WQ geometry representation of each ResSim element. Each WQ constituent has it's own dataset in the Results folder.