Skip to content

Commit

Permalink
Updates and tests for O2 photolysis (#38)
Browse files Browse the repository at this point in the history
* stub test of LUT LA-SRB calcs

* update lasrb test conditions

* add od and xs calcs to LUT LA-SRB test

* fix memory issues in tests

* finish LA-SRB LUT comparison test
  • Loading branch information
mattldawson authored Jan 26, 2024
1 parent dc042ed commit e1e7f1d
Show file tree
Hide file tree
Showing 12 changed files with 1,230 additions and 31 deletions.
3 changes: 2 additions & 1 deletion examples/ts1_tsmlt.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@
"name": "jo2_a",
"__reaction": "O2 + hv -> O + O1D",
"cross section": {
"netcdf files": [
"apply O2 bands": true,
"netcdf files": [
{
"file path": "data/cross_sections/O2_1.nc",
"lower extrapolation": { "type": "boundary" },
Expand Down
18 changes: 10 additions & 8 deletions src/photolysis_rates.F90
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ subroutine get( this, la_srb, spherical_geometry, grid_warehouse, &
!> Local variables
character(len=*), parameter :: Iam = "photolysis rates calculator"
integer :: vertNdx, rateNdx, nRates
real(dk), allocatable :: airVcol(:), airScol(:)
real(dk), allocatable :: air_vertical_column(:), air_slant_column(:)
real(dk), allocatable :: xsqyWrk(:)
real(dk), allocatable :: cross_section(:,:)
real(dk), allocatable :: quantum_yield(:,:)
Expand Down Expand Up @@ -343,13 +343,15 @@ subroutine get( this, la_srb, spherical_geometry, grid_warehouse, &
! O2 photolysis can have special la & srb band handling
if( any( this%o2_rate_indices_ == rateNdx ) ) then
airProfile => profile_warehouse%get_profile( this%air_profile_ )
allocate( airVcol( airProfile%ncells_ ), &
airScol( airProfile%ncells_ + 1 ) )
call spherical_geometry%air_mass( airProfile%exo_layer_dens_, airVcol,&
airScol )
call la_srb%cross_section( grid_warehouse, profile_warehouse, airVcol,&
airScol, cross_section, spherical_geometry )
deallocate( airVcol, airScol )
allocate( air_vertical_column( airProfile%ncells_ ), &
air_slant_column( airProfile%ncells_ + 1 ) )
call spherical_geometry%air_mass( airProfile%exo_layer_dens_, &
air_vertical_column, &
air_slant_column )
call la_srb%cross_section( grid_warehouse, profile_warehouse, &
air_vertical_column, air_slant_column, &
cross_section, spherical_geometry )
deallocate( air_vertical_column, air_slant_column )
deallocate( airProfile )
endif

Expand Down
49 changes: 37 additions & 12 deletions test/data/la_srb_bands.config.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
{
"grids" : [
{
"name": "height",
"type": "equal interval",
"units": "km",
"begins at" : 0.0,
"ends at" : 120.0,
"cell delta" : 1.0
"name": "height",
"type": "equal interval",
"units": "km",
"begins at" : 0.5,
"ends at" : 150.5,
"cell delta" : 1.0
},
{
"name": "wavelength",
"type": "from csv file",
"units": "nm",
"file path": "data/grids/wavelength/combined.grid"
"name": "wavelength",
"type": "from csv file",
"units": "nm",
"file path": "test/data/waccm2_ref_101_mod.grid"
},
{
"name": "LUT wavelength",
"type": "from csv file",
"units": "nm",
"file path": "test/data/waccm2_ref_101.grid"
}
],
"cross section parameters file": "data/cross_sections/O2_parameters.txt",
Expand All @@ -26,9 +32,28 @@
"name": "height",
"units": "km"
}
},
{
"name": "air",
"type": "air",
"units": "molecule cm-3",
"file path": "data/profiles/atmosphere/ussa.dens"
},
{
"name": "O2",
"type": "O2",
"units": "molecule cm-3",
"file path": "data/profiles/atmosphere/ussa.dens"
}
],
"O2 estimate" :{
"scale factor": 0.2095
"O2 cross section": {
"netcdf files": [
{
"file path": "data/cross_sections/O2_1.nc",
"lower extrapolation": { "type": "boundary" },
"interpolator": { "type": "fractional target" }
}
],
"type": "base"
}
}
104 changes: 104 additions & 0 deletions test/data/waccm2_ref_101.grid
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
102
120.0000
121.0000
122.0000
123.5000
124.3000
125.5000
126.3000
127.1000
130.1000
131.1000
135.0000
140.0000
145.0000
150.0000
155.0000
160.0000
165.0000
168.0000
171.0000
173.0000
174.4000
177.0000
178.6000
180.2000
181.8000
183.5000
185.2000
186.9000
188.7000
190.5000
192.3000
194.2000
196.1000
198.0000
200.0000
202.0000
204.1000
205.8000
208.0000
211.0000
214.0000
217.0000
220.0000
223.0000
226.0000
229.0000
232.0000
235.0000
238.0000
241.0000
244.0000
247.0000
250.0000
253.0000
256.0000
259.0000
263.0000
267.0000
271.0000
275.0000
279.0000
283.0000
287.0000
291.0000
295.0000
298.5000
302.5000
305.5000
308.5000
311.5000
314.5000
317.5000
322.5000
327.5000
332.5000
337.5000
342.5000
347.5000
350.0000
355.0000
360.0000
365.0000
370.0000
375.0000
380.0000
385.0000
390.0000
395.0000
400.0000
405.0000
410.0000
415.0000
420.0000
430.0000
440.0000
450.0000
500.0000
550.0000
600.0000
650.0000
700.0000
750.0000

104 changes: 104 additions & 0 deletions test/data/waccm2_ref_101_mod.grid
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
102
120.0000
121.4000
121.9000
123.5000
124.3000
125.5000
126.3000
127.1000
130.1000
131.1000
135.0000
140.0000
145.0000
150.0000
155.0000
160.0000
165.0000
168.0000
171.0000
173.0000
175.4000
177.0000
178.6000
180.2000
181.8000
183.5000
185.2000
186.9000
188.7000
190.5000
192.3000
194.2000
196.1000
198.0000
200.0000
202.0000
204.1000
206.2000
208.0000
211.0000
214.0000
217.0000
220.0000
223.0000
226.0000
229.0000
232.0000
235.0000
238.0000
241.0000
244.0000
247.0000
250.0000
253.0000
256.0000
259.0000
263.0000
267.0000
271.0000
275.0000
279.0000
283.0000
287.0000
291.0000
295.0000
298.5000
302.5000
305.5000
308.5000
311.5000
314.5000
317.5000
322.5000
327.5000
332.5000
337.5000
342.5000
347.5000
350.0000
355.0000
360.0000
365.0000
370.0000
375.0000
380.0000
385.0000
390.0000
395.0000
400.0000
405.0000
410.0000
415.0000
420.0000
430.0000
440.0000
450.0000
500.0000
550.0000
600.0000
650.0000
700.0000
750.0000

30 changes: 21 additions & 9 deletions test/unit/la_sr_bands.F90
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,31 @@ program test_la_sr_bands
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

subroutine test_optical_depth( )
use tuvx_grid, only : grid_t
use tuvx_spherical_geometry, only : spherical_geometry_t

use tuvx_profile, only : profile_t
use tuvx_grid, only : grid_t
use tuvx_spherical_geometry, only : spherical_geometry_t

real(dk), allocatable :: air_vertical_column(:), air_slant_column(:)
real(dk), allocatable :: o2_optical_depth(:,:)
class(grid_t), pointer :: height_grid => null( ) ! specified altitude working grid [km]
type(spherical_geometry_t) :: spherical_geometry
class(grid_t), pointer :: height_grid ! specified altitude working grid [km]
class(grid_t), pointer :: wavelength_grid ! [nm]
class(spherical_geometry_t), pointer :: spherical_geometry
class(profile_t), pointer :: air

height_grid => grid_warehouse%get_grid( "height", "km" )
allocate( air_vertical_column( height_grid%ncells_ ), &
air_slant_column( height_grid%ncells_ + 1 ) )
wavelength_grid => grid_warehouse%get_grid( "wavelength", "nm" )
air => profile_warehouse%get_profile( "air", "molecule cm-3" )

spherical_geometry => spherical_geometry_t( grid_warehouse )
call spherical_geometry%set_parameters( 45.0_dk, grid_warehouse )

allocate( o2_optical_depth(120, 38) )
allocate( air_vertical_column( air%ncells_ ), &
air_slant_column( air%ncells_ + 1 ) )
call spherical_geometry%air_mass( air%exo_layer_dens_, air_vertical_column,&
air_slant_column )

air_vertical_column(:) = 1
air_slant_column(:) = 3
allocate( o2_optical_depth(height_grid%ncells_, wavelength_grid%ncells_) )
o2_optical_depth(:,:) = 0

! just checking that it runs. This method apparently requires at least
Expand All @@ -93,6 +102,9 @@ subroutine test_optical_depth( )
spherical_geometry )

deallocate( height_grid )
deallocate( wavelength_grid )
deallocate( air )
deallocate( spherical_geometry )
deallocate( o2_optical_depth )
deallocate( air_vertical_column )
deallocate( air_slant_column )
Expand Down
Loading

0 comments on commit e1e7f1d

Please sign in to comment.