HPG Testing - JMMP-Group/CO_AMM15 GitHub Wiki
Setting up HPG Tests
When using MEs vertical coordinates, HPGE (hydrostatic pressure gradient error) tests must be carried out. These tests essentially amount to turning off all inputs and fluxes to the model ocean in order to determine the stability of the model. In a perfect model these errors should be very small but big gradients in the bathymetry and vertical coordinates can lead to instabilities. This often occurs around, for example, the shelf break.
To test HPGE, you will need to recompile this configuration with the addition of a few new source files. These files are in this repository under the /hpge_testing/MY_SRC
directory. Put these in your MY_SRC and recompile. You can then rerun the model using the same settings as before.
You will also need to change the model outputs. In /hpge_testing/file_def_hpge.xml
, you will see variables such as the maximum current. This is a useful file and will help identify how well the model is performing.
It is recommended that you run this model for around a month. At least, when viewing the output variables, some level of stability should be achieved to make sure the 'ramp up' of errors is complete. This test should be iterated with the smoothing instructions below to optimise the domain_cfg file.
Envelopes Optimization
The idea here is to optimise the envelopes for reducing HPG errors. The methodology consists in smoothing the envelopes with the Martinho and Batteen (2006) algorithm to reduce their slope parameter value (and hence HPG errors) only in those grid points where spurious currents are larger than a given treshold.
Two main points have to be considered:
a) This method needs that a HPG test using non-optimised envelopes is conducted prior the optimisation: the numerical results from this earlier test will be used to generate a 2D field of maximum (in time and in the vertical) spurious currents due to HPG errors.
b) The choice of the HPG errors treshold (HPGEmax) and maximum slope parameter value to be applied locally (LOCrmax) is an iterative process in the sense that we don't know which LOCrmax is needed to reduce HPG errors below HPGEmax: the only way is to run an HPG test, assess HPGE and if we are not happy with the results change LOCrmax and/or HPGEmax and repeat the optimisation test.
The methodology includes the following script/input files:
-
create_2D_hpge_field.py: this script will create a netcdf file including two 2D fields:
-
max_hpge_0 : maximum spurious currents in the upper sub-domain of the model, which is the region of the model between eta and envelope 1, which in the specific case of the AMM* configurations we are testing includes the first 25 levels.
-
max_hpge_1 : maximum spurious currents in the deeper sub-domain of the model, which is the region of the model between envelope 1 and envelope 2, which in the specific case of the AMM* configurations we are testing includes the last 26 levels.
The following is the setting we should use for calculating AMM15 max HPGE 2d field from a previous HPGE test:
-
# Path of the folder containing HPGE spurious currents velocity files
HPGEdir = 'PATH_OF_THE_FOLDER_CONTAINING_HPGE_VELOCITY_OUTPUT_FILES'
# List of indexes of the last T-level of each vertical subdomains
# (Fortran indexening convention)
num_lev = [24,50]
# Name of the zonal and meridional velocity variables
Uvar = 'vozocrtx'
Vvar = 'vomecrty'
# Name of the variable to chunk with dask and size of chunks
chunk_var = 'time_counter'
chunk_size = 4 # This number works well at the Met Office with Gulf18 (much smaller domain than AMM15)
-
plot_hpge_vs_rmax.py: this script plots the relationship between hpge and rmax for each grid point - it can be used to have an indication for HPGEmax and LOCrmax.
-
amm15_MEs_2env_0.1_0.07_opt.inp: this is the input file we should use to optimise the envelopes. From the last meeting with Dave I understood that, as with AMM7, HPGE are important only for the deeper sub-domain: that's why I set this file to carry out HPGE-aware local smoothing only in the deeper envelope. In this file
- e_loc_vmx controls HPGEmax (this is a list, so e_loc_vmx[0] is the HPGEmax threshold for the upper envelope and so on)
- e_loc_rmx controls LOCrmax (this is a list, so e_loc_vmx[-1] is the LOCrmax for the deeper envelope and so on)
To note that it might be necessary to play also with e_glo_rmx, which is a list of the global maximum slope parameters allowed for each envelope.