Skip to content

How to Set Up and Run a Model Application

This section describes the complete workflow for setting up and running a new CE-QUAL-W2 model application. The procedure consists of seven steps, from constructing boundary condition files through evaluating model output. For a quick-start guide using an included example application, see How to Run the Model for the First Time.

Workflow Overview

  1. Construct all boundary condition files
  2. Develop the model grid
  3. Edit the main control file
  4. Edit auxiliary input files
  5. Run the preprocessor
  6. Run the W2 model
  7. Evaluate output files

Step 1: Construct All Boundary Condition Files

Boundary condition files provide the external forcing data that drive the model simulation. These files include:

  • Flow rates, temperatures, and concentrations for all inflows
  • Meteorological conditions for each waterbody
  • Water levels for head boundary conditions
  • Shading coefficients for each segment
  • Wind sheltering coefficients for segments
  • Outflow rates and withdrawal rates
  • Precipitation files

All boundary condition files can be developed in a spreadsheet application such as Microsoft Excel. Input files may have either a Comma-Separated Values (CSV, .csv) or fixed-format text (.npt) extension. The file name and file type for most input files can be specified by the user in the control file.

File Naming Conventions

Inflow files typically use the following prefixes:

Prefix Content
q Flow rate
t Temperature
c Concentration

The meteorological file is commonly named met*.npt or met*.csv.

Creating Input Files in Excel

The following procedure demonstrates how to create a flow input file for the model.

  1. Open a new Excel worksheet.
  2. Enter a descriptive comment on the first line (e.g., "Inflow #1 2003"). The first three lines are ignored by the model and are used for descriptors and column headers.
  3. Skip a line or row.
  4. On row 3, add column headers: first column JDAY, second column Q(m³/s).
  5. On row 4, enter a Julian day value (e.g., 1.5 corresponds to January 1 at 12 noon) and a corresponding flow value (e.g., 10.0, entered as a decimal).
  6. On row 5, enter the final Julian day (e.g., 365) and corresponding flow value (e.g., 15).

The model can linearly interpolate between data points or treat the values as step functions.

Saving Input Files

There are two approaches for saving input files in a format compatible with CE-QUAL-W2:

  • Fixed-format text (.npt): Select all cells in the worksheet and set all column widths to 8 characters. Use File > Save As, choose the .prn format, and enter the desired filename in quotes (e.g., "qin_branch1.npt").
  • CSV format (.csv): Save the file directly as a CSV from Excel, or use the Excel macro utility w2_tools_L.xlam (available from the Portland State University (PSU) CE-QUAL-W2 website) to write the file in CSV format. See the W2 Tools Excel Macro Utility User Manual for details.

CSV file header requirement

The first character in line 1 of a CSV input file must be a dollar sign ($).

Julian Day Conversion

CE-QUAL-W2 uses Julian days for all time references in calculations and boundary conditions. To convert a calendar date to a Julian day in Excel, use the following formula:

=<Cell with Date> - DATEVALUE("1/1/XXXX") + 1

Replace XXXX with the reference year for the start of Julian days. Convert the cell format to a number after applying the formula.

Tip

A full description of all model input file formats is provided in Part 3 of this manual.

Step 2: Develop the Model Grid

The model grid is defined by a bathymetry file for each waterbody. Use a text editor to open the existing bathymetry file for DeGray Reservoir (bth1.csv). An example of the bathymetry file format for a CSV file for a reservoir is provided in Part 3 of this manual.

Bathymetry File Development Procedure

  1. Obtain x,y,z topographic data for the waterbody.
  2. For reservoirs or rivers, merge the topographic data with digital elevation model (DEM) data using a geographic information system (GIS) or a contouring application such as Surfer.
  3. Create a centerline for the waterbody and define the grid spacing in the longitudinal (x) direction for each model branch.
  4. Draw polygons around each model segment and create a Volume-Area-Elevation curve for each segment.
  5. After choosing an appropriate vertical layer spacing, compute segment widths for each vertical layer using:

    \[B = \frac{V_{\text{layer}}}{\Delta x \cdot \Delta z}\]

    where \(V_{\text{layer}}\) is the volume in the layer, \(\Delta x\) is the segment length, and \(\Delta z\) is the layer height.

  6. Assemble all layer widths for each segment into a file compatible with the CE-QUAL-W2 bathymetry format.

Note

Cross-sections can also be used directly to compute segment widths at various elevations. This approach is appropriate when the cross-section is representative of the model segment.

Step 3: Edit the Main Control File

The main control file, w2_con.csv, is the central file that describes how the model will run. This file is generated from the Excel macro workbook w2_conDeGray4.5.xlsm. Do not edit the CSV file directly. Instead, edit the parameters within the .xlsm workbook and produce the w2_con.csv file by pressing the output button on the corresponding tab.

Enable macros

The Excel .xlsm file must have macros enabled for the output buttons to work.

The control file specifies:

  • Simulation start and end times
  • Inflow and outflow locations
  • Input and output file names
  • Water quality kinetic parameters
  • Output file designations and content

The .xlsm workbook also contains additional sheets that serve as auxiliary control files for different processes, as described in Step 4.

Step 4: Edit Auxiliary Input Files

If additional processes are to be included in the simulation, auxiliary input files are required. Templates for these files are included in the .xlsm workbook. The following table lists the auxiliary input files and their associated processes.

File Process
w2_diagenesis.npt Sediment diagenesis
w2_selective.npt Automatic port selection
particle.csv Particle tracking
w2_aerate.npt Aeration
w2_envirp.npt Environmental performance
w2_habitat.npt Habitat suitability
constriction.npt Channel constrictions
pH_buffering.npt pH buffering
dynselevX.npt Dynamic selective withdrawal elevation
dynpumpX.npt Dynamic pump operation
dynpipe.npt Dynamic pipe flow
w2_systdg.npt System Total Dissolved Gas (TDG)
multiple_WB.npt Multiple waterbody coupling
w2_Algae_Toxin.csv Algae toxin modeling

Output procedure for auxiliary files

Unlike the main control file (w2_con.csv), auxiliary input files require the user to first select the cells in the .xlsm workbook and then press the output button to write the file.

Step 5: Run the Preprocessor

The preprocessor executable, preW2-4_64.exe, checks the control file, bathymetry file, and all boundary condition files for errors before running the full simulation.

  1. Double-click preW2-4_64.exe to launch the preprocessor.
  2. Review the preprocessor screen output.
  3. Examine the output files produced by the preprocessor:
File Description
pre.opt Echo of input data and other diagnostic information
pre.err Fatal error messages
pre.wrn Warning messages

Resolve all errors before proceeding

Always review both pre.wrn and pre.err before running the model. Correct any errors reported in pre.err and rerun the preprocessor until no errors remain.

Step 6: Run the W2 Model

The model executable is w2_v4_64.exe. Double-click the executable to launch the simulation. The model displays a dialog box showing simulation progress and a dynamic animation of results during the run.

Step 7: Evaluate Output Files

CE-QUAL-W2 output files have either an .opt or .csv extension, depending on the output type specified by the user in the control file.

Key Output Files

File Description
snp.opt Snapshot file containing water surface elevations, velocities, temperatures, and constituent concentrations at user-specified intervals
Time Series Result (TSR) files Time series output files suitable for plotting in Excel
Spreadsheet files Additional output files in spreadsheet-compatible format
Contour plot (CPL) output Contour plot output compatible with Tecplot 360 (www.tecplot.com) for animating results

The post-processor utility w2_post.exe can be used to generate animations and contour plots from model output.

Tip

Open snp.opt in a text editor for a quick review of model results. Use the TSR and spreadsheet output files for detailed analysis and comparison with observed data. For a complete description of all output file formats, see Part 3 of this manual.