This week I created an algorithm that, given a list of lat/lon coordinates for a WWTP, finds the nearest coastal grid cell and adds a freshwater point source. I created forcing files for these point sources and ran ROMS for two days. Every point source has a discharge flow of 1000 m3 s-1 distributed evenly between the sigma layers. Below are the results:



Figure 1 shows a snapshot of the final hour of this run.


Fig 1. Last hour of two-day point source test run.



There were two major parts of this process. First is the algorithm that finds the nearest coastal grid cell to a WWTP. Second is creating forcing files for the new point sources. Both parts are described in more detail below.


Algorithm: Nearest Coastal Grid Cell to WWTP

The main steps of the algorithm are to

  1. Determine in which grid cell the WWTP is located
  2. If the WWTP is already in water, the algorithm saves the WWTP grid cell as the point source location
  3. If the WWTP is on land, check the surrounding “ring” of grid cells for a water cell
  4. If there are no water cells, look in the next ring
  5. If there is one or more water cells in the ring, determine the grid cell that is nearest to the WWTP and save the cell location
  6. Search in the next ring for water cells that may be nearer to the WWTP
  7. If none of the water cells in the outer ring are closer than the previously saved nearest water cell, then the previously saved watercell is the nearest coastal grid cell

The reason why step 6 is necessary is because the grid cells may not all be the same size. As illustrated in Figure 2, it is possible for the nearest coastal grid cell to be several rings away, even if there are coastal grid cells in closer rings.


Fig 2. Nearest coastal grid cell is two rings away, despite the WWTP having a coastal grid cell in the adjacent ring.



Summary of Changes

The required changes for this algorithm to work are documented below. Note that I copied all files from LO/pgrid into LO_user/pgrid and modified them within LO_user.

New Scripts and Files

  1. Create a file called wwtp_loc_info.csv in LO_user/wwtps/[gridname]/wwtp_loc_info.csv with discharger names and lat lon coordinates. The location of the file can be changed later on, and updated in gfun.gstart. Here’s an example of what the file looks like:


  1. Created a script called place_dischargers.py which is the wwtp equivalent to carve_rivers. This script uses the information in wwtp_loc_info.csv to calculate the nearest coastal grid cell to use as a point source for the model. This information gets saved in LO_output/pgrid/[gridname]/roms_wwtp_info.csv (same as where river info gets saved).


Changes to gfun.py

  1. Added a line in gfun.gstart that defines location of wwtp_dir (which is LO_user/wwtps/[gridname]). This location can be changed later on. Again, wwtp_dir contains the .csv file with WWTP lat lon coordinates.


  1. Added new tag in gfun.increment_filename called “_d” to update the filename after “place_dischargers.py” has been run. The “_d” is for “dischargers”


Changes to start_grid.py

  1. Needed to update the default filename to include a “_d00” tag for dischargers


Changes to grid_to_LO.py

  1. Copy point source information into the output directory to prepare for ROMS run


Changes to plot_grid.py

  1. Changed plot_grid to add an if case if the wwtp_loc_info.csv file exists (using the location specified in gfun.gstart). If so, then plot_grid also plots WWTP location.


  1. Also added an if case if roms_wwtp_info.csv exists (after place_dischargers.py has been run). If so, then plot_grid shows where the algorithm has placed the point sources.



Forcing Files for Point Sources

Creating forcing files was a bit trickier. Right now, the main script that creates wwtp forcing (make_forcing_main.py) does not have the capability to create both wwtp and river forcing. This will need to be dealt with later on.

River forcing uses LuvSrc to introduce momentum from u- or v-faces. However, LuvSrc only allows point sources on coastal cells, and it isn’t recommended for cells already in the ocean. Since I had a test WWTP in the ocean, I needed a workaround for this issue.

Instead of LuvSrc, I used LwSrc to introduce momentum from w-faces. This had implications on the eta/xi positions of the source, the direction of the source, and the sign of the source. What I’ve found is that all three are actually easier to define using LwSrc than LuvSrc. The eta/xi positions of the source are equivalent to the rho-point indices (which were saved in place_dischargers.py). The direction of the source is simply 2 for inflow coming from w-face cells. The sign of the source is always positive for sources (always negative for sinks).

It sounds like we can enable both LuvSrc and LwSrc within the same application, as long as they are not applied to the same grid cell. However, I have yet to combine river and WWTP forcing. Making this work is the next step.

Summary of Changes

The required changes to set up WWTP forcing are described below.

Changes to forcing_list.csv

  1. I added a new forcing called wwtp. The name of the wwtp forcing is “wwtpA0” in forcing_list.csv.


Changes to BLANK.in

  1. In BLANK.in, I added a line to tell roms to look for wwtp forcing in wwtps.nc. I also commented out the river forcing.


Eventually will need to enable both river and wwtp forcing, but I’m not sure how to do that yet (two different SSFNAME files? Combined into one forcing file?)

  1. Turn on logical switch for LwSrc. (In this case I also turnedd of LuvSrc since I didn’t have any rivers.)


Changes to make_forcing_main.py

  1. Updated river_Xposition and river_Eposition to always be the rho-point i and j values (this is the case for LwSrc). The river_direction is also always 2 for LwSrc.



Here are some links I found helpful that explains the nuances of LuvSrc and LwSrc:

ROMS Wiki River Runoff has general information about setting up and using LuvSrc and LwSrc.

Enhanced Point Sources/Sinks Forcing helped me understand what to use for river_direction.

Point Sources Revisited has a nice comparison between model runs using LuvSrc and LwSrc. The results are similar, which is very reassuring.