Difference between revisions of "Box model"

From UKCA
Line 24: Line 24:
   
 
Files defined in the directory '''src/control/box_control''' are the box model code wrapping the core UKCA code. The UKCA code based is those under the sections '''src/control/core''' and '''src/science'''. Currently, the box model still has dependencies on the full UM code base (defined by '''extract.path-incl[um]'''). These will be removed and replaced with appropriate replications of functionalism not currently called.
 
Files defined in the directory '''src/control/box_control''' are the box model code wrapping the core UKCA code. The UKCA code based is those under the sections '''src/control/core''' and '''src/science'''. Currently, the box model still has dependencies on the full UM code base (defined by '''extract.path-incl[um]'''). These will be removed and replaced with appropriate replications of functionalism not currently called.
  +
  +
The box model is designed to run like a single grid cell in the full UM model, with no calls to transport or physics but a full integration of the UKCA code base on each timestep. Because of its simple setup, the ''UKCA box-model'' typically takes a few minutes for a clean compile and seconds to integrate several days on a single core. This makes it an ideal test bed to for developing, debugging, testing and optimising new functionality into the UKCA model before use in a 3D model.
  +
  +
As the ''UKCA box-model'' does not does not compute the changing atmospheric, land and radiation conditions that would usually be calculated by the parent model, it instead has a set of ''environmental parameters'' predefined by the user to dictate the environmental conditions and latitude-longitude location of the grid cell being integrated. It also reads in initial mass mixing ratio (MMR, units ''kg/kg'') values for all chemical tracers (and aerosol tracers if running with GLOMAP-mode).
  +
  +
Currently ''(as of 27 May 2022)'' there are no emissions or dry/wet deposition functionality in the box model. Because of this, integration of the box-model simply progresses from the initial conditions towards a steady state. The box-model is also currently unable to use Fast-JX photolysis due to a lack of column ozone and sulfate aerosol values that are usually provided by the parent model. Instead, it uses a simple photolysis scheme is which j-rate values for different photolysis reactions are provided in a file by the user which have a diurnal cycle applied to them. We plan to add the functionality for simple emissions and deposition, as well as the ability to call Fast-JX using external files for column ozone and sulfate data, as this increased capability would make box-model more suitable for use in scientific analysis.
   
   
Line 72: Line 78:
 
The box model uses a similar setup of '''rose-meta''' to the full UM model, with options which no longer apply to the box model (mostly) removed. There is an additional namelist section added to the suite ('''nlstcall_box_options'''), which controls inputs required to run the box model and can be found in '''namelist/Model Input and Output/BOX MODEL IO Options''' in Rose. This namelist has the following options:
 
The box model uses a similar setup of '''rose-meta''' to the full UM model, with options which no longer apply to the box model (mostly) removed. There is an additional namelist section added to the suite ('''nlstcall_box_options'''), which controls inputs required to run the box model and can be found in '''namelist/Model Input and Output/BOX MODEL IO Options''' in Rose. This namelist has the following options:
   
* '''ukca_box_nml''' ''CHARACTER[*]'' The name for the external namelist file used by the UKCA box model to define the environmental inputs required to run
+
* '''ukca_box_nml''' ''CHARACTER[*]'' The name for the external namelist file to define the environmental parameters required to run the UKCA box model
 
* '''tracer_in_filename''' ''CHARACTER[*]'' The filename for initial MMR values for chemical and aerosol tracers used by the box model, any undefined tracers will have their initial value set to '''tracer_nullval'''
 
* '''tracer_in_filename''' ''CHARACTER[*]'' The filename for initial MMR values for chemical and aerosol tracers used by the box model, any undefined tracers will have their initial value set to '''tracer_nullval'''
 
* '''tracer_out_filename''' ''CHARACTER[*]'' Filename for main output file containing MMR values for each tracer in the box model
 
* '''tracer_out_filename''' ''CHARACTER[*]'' Filename for main output file containing MMR values for each tracer in the box model
* '''ntp_in_filename''' ''CHARACTER[*]'' This gives the name for input file used by the UKCA box-model to define initial MMR values for non-transported prognostics [Query delete]
+
* '''ntp_in_filename''' ''CHARACTER[*]'' This gives the name for input file used by the UKCA box-model to define initial MMR values for non-transported prognostics '''[Query delete]'''
 
* '''photol_jrate_in_filename''' ''CHARACTER[*]'' Name for input file used by the UKCA box model for precalculated J-Rate values for simple photolysis (only used with StratTrop of CRI-Strat chemistry)
 
* '''photol_jrate_in_filename''' ''CHARACTER[*]'' Name for input file used by the UKCA box model for precalculated J-Rate values for simple photolysis (only used with StratTrop of CRI-Strat chemistry)
 
* '''tracer_nullval''' ''REAL'' The default MMR value for UKCA-box tracers that are not included in the input tracer file ('''tracer_in_filename''')
 
* '''tracer_nullval''' ''REAL'' The default MMR value for UKCA-box tracers that are not included in the input tracer file ('''tracer_in_filename''')
   
The model will search for all of the files whose filename is defined in the above options in the ''file'' directory of the suite being run:
+
Most of these options define filenames which contain the initial conditions required to run the box-model. Changing the scenario being run is mostly a case of changing one of the above options to point to either another existing file or a new file created by the user. The model will search for all of the files whose filename is defined in the above options in the ''file'' directory of the suite being run:
   
 
~/roses/u-<suite_id>/app/ukca/file
 
~/roses/u-<suite_id>/app/ukca/file
   
  +
the example suite *** contains the following files in that directory:
The ''ukca_box_nml'' namelist file contains
 
   
  +
* '''chem_ntp_pars''' Initial MMR values for '''[Query delete]'''
In addition to the above namelist options, the following input files are required (with default name provided):
 
  +
* '''chem_tracer_pars''' '''[Query delete]'''
  +
* '''chem_tracer_pars_basic_ST''' Initial tracer MMR
  +
* '''chem_tracer_pars_gpu_test1'''
  +
* '''chem_tracer_pars_gpu_test2_urban'''
  +
* '''chem_tracer_pars_OffOx'''
  +
* '''chem_tracer_pars_OffOx_LowAero'''
  +
* '''chem_tracer_pars_OffOx_NoGP'''
  +
* '''chem_tracer_pars_STwGMaero'''
  +
* '''chem_tracer_pars_STwGMaero_EqTropopause'''
  +
* '''chem_tracer_pars_STwGM_NO3NH4aero_EqTropopause'''
  +
* '''djrat_0lat_12z_969hPa.dat'''
  +
* '''djrat_0lat_12z_969hPa_v2.txt'''
  +
* '''nml_sfc.box'''
  +
* '''nml_strat.box'''
  +
* '''nml_tropopause.box'''
  +
 
The ''ukca_box_nml'' namelist file contains
   
   
Line 119: Line 142:
   
   
 
In addition to the above namelist options, the following input files are required (with default name provided):
   
 
* chem_tracer_pars: Initial values of chemical (and/or aerosol) tracers required to fill the '''tracer''' array when running UKCA
 
* chem_tracer_pars: Initial values of chemical (and/or aerosol) tracers required to fill the '''tracer''' array when running UKCA

Revision as of 12:02, 27 May 2022

UKCA Box Model - Version 1

The UKCA Box Model is a set of wrapper code which allow the running of the UKCA code base, taken directly from the repository trunk, independently of the UM as if running the chemistry and aerosol code over a single grid cell. The box model is designed to be used primarily for development and testing purposes - due to it's simple design it can quickly compiled and run on a single core in minutes, making debugging of changes to the core chemistry routines substantially faster than on the 3D model. The model has been tested to run in three broad modes, currently it only works with chemical mechanisms which utilise the ASAD framework:

  • Chemistry only, using StratTrop or CRI-Strat chemical mechanisms
  • GLOMAP Aerosol with offline oxidents
  • Coupled online chemistry-aerosol, using GLOMAP-MODE aerosol and StratTrop or CRI-Strat chemical mechanisms.

As well as use for development and testing, the box model is an integral part of the broader UKCA development strategy, as part of the ExCALIBUR ['LINK'] project, to enable the wholesale movement of the UKCA code base out of the UM into a seperpate repository. This transfer is occurring as part of the changes being made for UM vn13.0, Ticket #6717.


Overview

The source code for the box model can be found as a branch of the UKCA repository - in time these will merged into a single trunk which contains the UKCA source code and code to run the box model. The latest (10 May 2022) working branch can be found at:

https://code.metoffice.gov.uk/trac/ukca/browser/main/branches/dev/scottarchernicholls/r1_ukcabox_move_UKCA_br_G

This branch is designed to run with the first iteration of the UKCA repository, which can be found:

https://code.metoffice.gov.uk/trac/um/browser/main/branches/dev/lukeabraham/vn12.2_move_ukca#src/io_services/common

The build options are defined in the file fcm_make/inc/ukca-box-common.cfg; UKCA files/directories used for the build are defined under extract.path-incl[ukca] =

Files defined in the directory src/control/box_control are the box model code wrapping the core UKCA code. The UKCA code based is those under the sections src/control/core and src/science. Currently, the box model still has dependencies on the full UM code base (defined by extract.path-incl[um]). These will be removed and replaced with appropriate replications of functionalism not currently called.

The box model is designed to run like a single grid cell in the full UM model, with no calls to transport or physics but a full integration of the UKCA code base on each timestep. Because of its simple setup, the UKCA box-model typically takes a few minutes for a clean compile and seconds to integrate several days on a single core. This makes it an ideal test bed to for developing, debugging, testing and optimising new functionality into the UKCA model before use in a 3D model.

As the UKCA box-model does not does not compute the changing atmospheric, land and radiation conditions that would usually be calculated by the parent model, it instead has a set of environmental parameters predefined by the user to dictate the environmental conditions and latitude-longitude location of the grid cell being integrated. It also reads in initial mass mixing ratio (MMR, units kg/kg) values for all chemical tracers (and aerosol tracers if running with GLOMAP-mode).

Currently (as of 27 May 2022) there are no emissions or dry/wet deposition functionality in the box model. Because of this, integration of the box-model simply progresses from the initial conditions towards a steady state. The box-model is also currently unable to use Fast-JX photolysis due to a lack of column ozone and sulfate aerosol values that are usually provided by the parent model. Instead, it uses a simple photolysis scheme is which j-rate values for different photolysis reactions are provided in a file by the user which have a diurnal cycle applied to them. We plan to add the functionality for simple emissions and deposition, as well as the ability to call Fast-JX using external files for column ozone and sulfate data, as this increased capability would make box-model more suitable for use in scientific analysis.



Compiling and Running

Virtual Machine

The UKCA box model was developed to run on the Virtual Machine framework:

Instruction on how to set up the Virtual Machine to run UKCA can be found here:

Once the virtual machine is set up, it should be possible to run the box model. First, make a copy of the suite u-cn637:

 rosie copy u-cn637

This suite is designed to run using the branch r1_ukcabox_move_UKCA_br_G. We would recommend making a local copy of this branch in the directory UKCA-Box. This is required because, at the moment, the metadata required to run the box model is not committed, therefore there needs to be a local copy of r1_ukcabox_move_UKCA_br_G containing the relevant metadata. The suite expects this to be in $HOME/UKCA-Box, so it is simplest to download the branch to that directory:

cd ~/
mkdir UKCA-Box
cd UKCA-Box
fcm checkout fcm:ukca.x_br/dev/scottarchernicholls/r1_ukcabox_move_UKCA_br_G

The new suite (initially a copy of u-cn637) can then be opened, edited and run using the rose gui:

cd ~/roses/u-<suite_id>
rose edit -M ~/UKCA-Box/r1_ukcabox_move_UKCA_br_G/rose-meta/ &

Alternatively, the suite options can be edited by modifying the suite.rc and app/ukca/rose-app.conf then running the suite using:

rose suite-run

Met Office computer

(Pedro?)



Inputs

The box model uses a similar setup of rose-meta to the full UM model, with options which no longer apply to the box model (mostly) removed. There is an additional namelist section added to the suite (nlstcall_box_options), which controls inputs required to run the box model and can be found in namelist/Model Input and Output/BOX MODEL IO Options in Rose. This namelist has the following options:

  • ukca_box_nml CHARACTER[*] The name for the external namelist file to define the environmental parameters required to run the UKCA box model
  • tracer_in_filename CHARACTER[*] The filename for initial MMR values for chemical and aerosol tracers used by the box model, any undefined tracers will have their initial value set to tracer_nullval
  • tracer_out_filename CHARACTER[*] Filename for main output file containing MMR values for each tracer in the box model
  • ntp_in_filename CHARACTER[*] This gives the name for input file used by the UKCA box-model to define initial MMR values for non-transported prognostics [Query delete]
  • photol_jrate_in_filename CHARACTER[*] Name for input file used by the UKCA box model for precalculated J-Rate values for simple photolysis (only used with StratTrop of CRI-Strat chemistry)
  • tracer_nullval REAL The default MMR value for UKCA-box tracers that are not included in the input tracer file (tracer_in_filename)

Most of these options define filenames which contain the initial conditions required to run the box-model. Changing the scenario being run is mostly a case of changing one of the above options to point to either another existing file or a new file created by the user. The model will search for all of the files whose filename is defined in the above options in the file directory of the suite being run:

~/roses/u-<suite_id>/app/ukca/file

the example suite *** contains the following files in that directory:

  • chem_ntp_pars Initial MMR values for [Query delete]
  • chem_tracer_pars [Query delete]
  • chem_tracer_pars_basic_ST Initial tracer MMR
  • chem_tracer_pars_gpu_test1
  • chem_tracer_pars_gpu_test2_urban
  • chem_tracer_pars_OffOx
  • chem_tracer_pars_OffOx_LowAero
  • chem_tracer_pars_OffOx_NoGP
  • chem_tracer_pars_STwGMaero
  • chem_tracer_pars_STwGMaero_EqTropopause
  • chem_tracer_pars_STwGM_NO3NH4aero_EqTropopause
  • djrat_0lat_12z_969hPa.dat
  • djrat_0lat_12z_969hPa_v2.txt
  • nml_sfc.box
  • nml_strat.box
  • nml_tropopause.box

The ukca_box_nml namelist file contains


!-----------------------------------------------
! Box-MODEL test NAMELIST - surface
!-----------------------------------------------
! Section to define environmental parameters for box model
&ENVIRONMENT_PARS
  latitude_1       = 30.     ! Latitude, degrees North, -90:90
  longitude_1      = 0.      ! Longitude, degrees East, 0:360
  t_theta_levels_1 = 288.15  ! Temperature, K
  p_theta_levels_1 = 100000. ! Pressure, Pa
  land_sea_mask_1  = .TRUE.  ! Land/sea mask, logical
  tstar_1          = 288.15  ! Tmperature at surface, K
  zbl_1            = 1000.   ! Height of boundary layer, m
  pstar_1          = 101325. ! Pressure at surface, Pa
  q_1              = 0.01    ! Mass fraction of water vapour in air
  qcf_1            = 0.0     ! Mass fraction of cloud ice in air
  qcl_1            = 0.0     ! Mass fraction of liquid cloud water in air
  surf_albedo_1    = 0.2     ! Surface albedo
/ 

! Section to define Offline Oxidant MMR values
! (only used if running with offline oxidants scheme)
&OFFLINE_OXIDANT_MMR
  O3             = 5.0000e-08
  OH             = 5.0000e-14
  HO2            = 5.0000e-12
  H2O2           = 5.0000e-10
  NO3            = 5.0000e-12
/


In addition to the above namelist options, the following input files are required (with default name provided):

  • chem_tracer_pars: Initial values of chemical (and/or aerosol) tracers required to fill the tracer array when running UKCA

All gas-phase chemical species should be provided as mass mixing ratios (kg/kg). Not all values need to be provided - any not initialised are set to a default initial value of 1e-15 (*n.b. should make this a namelist option*)


  • chem_ntp_pars: Initial mass mixing ratios of non-transported prognostics required to fill the ntp_data array

Example input files can be found in the directory:

~/roses/<suite_id>/app/ukca/file

This directory should contain the following files:


Output

Values for he chemical (and aerosol) tracers at each timestep are outputed (by default) to:

~/cylc_run/u-<suite_id>/work/1/ukca/tracer_out.csv

This is a simple text file of comma separated variables of each of the tracer values in mass mixing ratio units (kg/kg). The top line is a commented out legend, naming each of the columns. The first column is timestep (by default, one timestep = one hour), each of the following columns are the tracers in the tracer array in the order they appear in the UKCA code.

A simple way to plot these is using gnuplot. This can be installed on the Virtual Machine using the command:

sudo apt-get install gnuplot

As an example, ozone (the 2nd species in the tracer array, therefore the third column after timestep and O(3P)) can be plotted as follows:

gnuplot
set datafile separator ","
plot "tracer_out.csv" using 1:3 with linespoints

      • Add example plot of ozone, using default setup ***



  • Scraps*

Usage:

A. Met Office desktop:
/home/h02/hadzm/eval_v2/camb_chem/eval_tropchem_spice.py -i <ppfiles> [-s STASHlist] [-m trmap]

Options
-h, --help show this help message and exit
-i Required: ppfiles (12) from the year to analyse -full path-