Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes for BOMEX..PR in progress. #589

Draft
wants to merge 47 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
8da1fd1
Initial work on new thermodynamics
May 10, 2023
1d788d1
Ongoing work on thermodynamics
May 11, 2023
ef1fe18
Merge remote-tracking branch 'origin/3d-mpi-model' into thermodynamics
May 11, 2023
061400f
More ongoing work on thermodynamics
May 11, 2023
16da9d5
Compiling code
sjboeing May 11, 2023
54189c1
Small fixes in openmp
sjboeing May 11, 2023
89a181f
Merge remote-tracking branch 'origin/bndry-surface-fluxes' into therm…
sjboeing May 11, 2023
7977b2a
Restoring double correction factor, some name fixes
sjboeing May 11, 2023
b4b1ba3
Merge remote-tracking branch 'origin/3d-mpi-model' into thermodynamics
sjboeing May 12, 2023
3346732
Merge branch 'thermodynamics' into thermo_and_fluxes
sjboeing May 12, 2023
667d52e
Adding back multiplication at boundaries in par2grid_diag (needed)
sjboeing May 12, 2023
2dc4d3e
Merge remote-tracking branch 'origin/thermodynamics' into thermo_and_…
sjboeing May 12, 2023
5b2d499
Adding in pre-compiler directives for dry case
sjboeing May 12, 2023
ffa55ba
Merge remote-tracking branch 'origin/thermodynamics' into thermo_and_…
sjboeing May 12, 2023
14b927a
Bugfixes in 1) Dry mode and 2) Diagnostic par2grid somehow needs volg
sjboeing May 12, 2023
e1091a7
Bugfixes in 1) Dry mode and 2) Diagnostic par2grid somehow needs volg
sjboeing May 12, 2023
fddb018
Merge remote-tracking branch 'origin/thermodynamics' into thermo_and_…
sjboeing May 12, 2023
c6b5dff
Surface fluxes setup added
sjboeing May 13, 2023
02d2773
Fixes to run BOMEX, temporarily disable vorticity correction
sjboeing May 13, 2023
41c80a9
Fix to parcel correction
sjboeing May 13, 2023
134cc3f
Merge remote-tracking branch 'origin/bndry-surface-fluxes' into therm…
Jul 30, 2023
f8c16b9
Cleanup
Jul 30, 2023
3314ea9
Fix mistake in random merge test
Jul 30, 2023
d6e9e69
adjust amax
matt-frey Jul 31, 2023
9c0c008
Replace remaining binc
sjboeing Aug 1, 2023
9a6b5eb
BOMEX changes
Aug 15, 2023
b3d7abb
Work in progress on ls forcings
sjboeing Aug 16, 2023
70f3c3b
Merge and changes to more accurately represent BOMEX
sjboeing Aug 18, 2023
80ea37a
FOMEX with damping diffusion
sjboeing Oct 6, 2023
80423ca
Damping changes to prevent negative numbers
sjboeing Oct 6, 2023
08e2c94
Set surface pressure like in MONC
sjboeing Oct 7, 2023
b4fa704
Remove vortcor
sjboeing Oct 7, 2023
8e4ccbd
Remove needless call 2 par2grid. Cosmetics on 1/1.0
sjboeing Oct 7, 2023
3444e06
Use the much simpler approach which exploits par2grid, including
sjboeing Oct 12, 2023
09c3455
Merge remote-tracking branch 'origin/main' into fomex_merge_1024
Oct 23, 2024
12b7e11
Changes to ensure compilation works
Oct 23, 2024
7a32e18
Remove additional fields no longer used
Oct 23, 2024
6641f3b
Delete post-processing script that only calculates mean mass-flux
Oct 23, 2024
f2d23a4
Add options for ls_forcings
Oct 23, 2024
d7b60de
Remove double allocation
Oct 24, 2024
c3130df
Merge remote-tracking branch 'origin/main' into fomex_merge_1024
Oct 24, 2024
32ca742
Merge remote-tracking branch 'origin/explicit-setter' into fomex_merg…
Oct 24, 2024
e837126
Merge remote-tracking branch 'origin/main' into fomex_merge_1024
Oct 25, 2024
ee973b6
Whitespace: revert
Oct 25, 2024
da12cae
Add call to saturation adjustment, remove needless call to get_strain…
Oct 25, 2024
cbba6cf
File renaming
Oct 25, 2024
e53efe9
Revent epic_config.py.in
Oct 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions convention.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ volg -- volume
velog -- velocity
velgradg -- velocity gradient tensor
vortg -- vorticity
tbuoyg -- total buoyancy
dbuoyg -- dry buoyancy
humg -- specific humidity
humlig -- condensed humidity
tbuoyg -- total buoyancy (in m/s^2)
thetag -- potential temperature
qvg -- water vapour specific humidity
qlg -- liquid water specific humidity
nparg -- number of parcels per grid box
40 changes: 40 additions & 0 deletions examples/fomex.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
```
&EPIC

field_file = 'bomex_setup192x192x96.nc' ! input field file
flux_file = 'bomex_flux_192x192.nc' ! input field file

!
! output info
!
output%field_freq = 300 ![s] write after these many seconds to the field NetCDF file
output%parcel_freq = 3600 ![s] write after these many seconds to the parcel NetCDF file
output%parcel_stats_freq = 100 ![s] write after these many seconds to parcel stats NetCDF file
output%field_stats_freq = 100 ![s] write after these many seconds to the field stats NetCDF file
output%write_fields = .true. ! enable / disable field dump
output%write_parcels = .true. ! enable / disable parcel dump
output%write_parcel_stats = .true. ! enable / disable parcel statistics
output%write_field_stats = .true. ! enable / disable field statistics
output%overwrite = .true. ! replace existing NetCDF files
output%basename = 'fomex' ! NetCDF output base name

!
! parcel info
!
parcel%n_per_cell = 8 ! initial number of parcels per cell
parcel%lambda_max = 4.0 ! maximum parcel aspect ratio
parcel%min_vratio = 20.0 ! minimum ratio of grid cell volume / parcel volume
parcel%correction_iters = 2 ! how many parcel correction iterations
parcel%gradient_pref = 1.8 ! gradient correction prefactor
parcel%max_compression = 0.5 ! gradient correction maximum compression

! BOMEX ls forcings
forcings%l_ls_forcings = .true. ! use BOMEX large-scale forcings

!
! stepper info
!
time%limit = 21600.0 ! time limit (s)
time%alpha = 0.2 ! scaling factor for the strain and buoyancy gradient time step
time%precise_stop = .false. ! time limit exact
/
2 changes: 1 addition & 1 deletion models/3d/moist_3d.f90
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module moist_3d
double precision :: e_values(3) ! To create asymmetry, we vary the buoyancy in the plume
! according to b = b_pl*[1 + (e1*x*y+e2*x*z+e3*yz)/R^2].
double precision :: r_smooth_frac ! Fraction of radius where smooth transition starts

end type plume_type

type(plume_type) :: moist
Expand Down
25 changes: 15 additions & 10 deletions mpi-tests/parcel_merge_serial.f90
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,10 @@ subroutine do_group_merge(parcels, isma, iclo, n_merge, Bm, vm)
double precision :: x0(n_merge), y0(n_merge)
double precision :: posm(3, n_merge)
double precision :: delx, vmerge, dely, delz, B33, mu
double precision :: buoym(n_merge), vortm(3, n_merge)
double precision :: thetam(n_merge), vortm(3, n_merge)
#ifndef ENABLE_DRY_MODE
double precision :: hum(n_merge)
double precision :: qvm(n_merge)
double precision :: qlm(n_merge)
#endif
double precision, intent(out) :: Bm(6, n_merge) ! B11, B12, B13, B22, B23, B33
double precision, intent(out) :: vm(n_merge)
Expand Down Expand Up @@ -124,9 +125,10 @@ subroutine do_group_merge(parcels, isma, iclo, n_merge, Bm, vm)
posm(3, l) = parcels%volume(ic) * parcels%position(3, ic)

! buoyancy and humidity
buoym(l) = parcels%volume(ic) * parcels%buoyancy(ic)
thetam(l) = parcels%volume(ic) * parcels%theta(ic)
#ifndef ENABLE_DRY_MODE
hum(l) = parcels%volume(ic) * parcels%humidity(ic)
qvm(l) = parcels%volume(ic) * parcels%qv(ic)
qlm(l) = parcels%volume(ic) * parcels%ql(ic)
#endif
vortm(:, l) = parcels%volume(ic) * parcels%vorticity(:, ic)

Expand All @@ -151,9 +153,10 @@ subroutine do_group_merge(parcels, isma, iclo, n_merge, Bm, vm)
posm(3, n) = posm(3, n) + parcels%volume(is) * parcels%position(3, is)

! Accumulate buoyancy and humidity
buoym(n) = buoym(n) + parcels%volume(is) * parcels%buoyancy(is)
thetam(n) = thetam(n) + parcels%volume(is) * parcels%theta(is)
#ifndef ENABLE_DRY_MODE
hum(n) = hum(n) + parcels%volume(is) * parcels%humidity(is)
qvm(n) = qvm(n) + parcels%volume(is) * parcels%qv(is)
qlm(n) = qlm(n) + parcels%volume(is) * parcels%ql(is)
#endif
vortm(:, n) = vortm(:, n) + parcels%volume(is) * parcels%vorticity(:, is)
enddo
Expand All @@ -180,9 +183,10 @@ subroutine do_group_merge(parcels, isma, iclo, n_merge, Bm, vm)
call apply_periodic_bc(posm(:, m))

! buoyancy and humidity
buoym(m) = vmerge * buoym(m)
thetam(m) = vmerge * thetam(m)
#ifndef ENABLE_DRY_MODE
hum(m) = vmerge * hum(m)
qvm(m) = vmerge * qvm(m)
qlm(m) = vmerge * qlm(m)
#endif
vortm(:, m) = vmerge * vortm(:, m)
enddo
Expand Down Expand Up @@ -220,9 +224,10 @@ subroutine do_group_merge(parcels, isma, iclo, n_merge, Bm, vm)
parcels%position(2, ic) = posm(2, l)
parcels%position(3, ic) = posm(3, l)

parcels%buoyancy(ic) = buoym(l)
parcels%theta(ic) = thetam(l)
#ifndef ENABLE_DRY_MODE
parcels%humidity(ic) = hum(l)
parcels%qv(ic) = qvm(l)
parcels%ql(ic) = qlm(l)
#endif
parcels%vorticity(:, ic) = vortm(:, l)

Expand Down
8 changes: 4 additions & 4 deletions mpi-tests/test_utils.f90
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ subroutine setup_parcels(xlen, ylen, zlen, l_shuffle, l_variable_nppc)
parcels%vorticity(3, l) = 20.0d0 * rn(6) - 10.d0

! buoyancy between -1 and 1: y = 2 * x - 1
parcels%buoyancy(l) = 2.0d0 * rn(7) - 1.d0
parcels%theta(l) = 2.0d0 * rn(7) - 1.d0

if ((x >= xlo) .and. (x <= xhi) .and. &
(y >= ylo) .and. (y <= yhi) .and. &
Expand Down Expand Up @@ -242,9 +242,9 @@ subroutine shuffleall
parcels%vorticity(:, rand_target) = parcels%vorticity(:, shuffle_index)
parcels%vorticity(:, shuffle_index) = tmp_vec

tmp_var = parcels%buoyancy(rand_target)
parcels%buoyancy(rand_target) = parcels%buoyancy(shuffle_index)
parcels%buoyancy(shuffle_index) = tmp_var
tmp_var = parcels%theta(rand_target)
parcels%theta(rand_target) = parcels%theta(shuffle_index)
parcels%theta(shuffle_index) = tmp_var

tmp_var = parcels%volume(rand_target)
parcels%volume(rand_target) = parcels%volume(shuffle_index)
Expand Down
164 changes: 164 additions & 0 deletions python-scripts/bomex_with_fluxes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
#!/usr/bin/env python
from tools.nc_fields import nc_fields
import numpy as np
import argparse

try:
parser = argparse.ArgumentParser(description="Create surface flux setup")

parser.add_argument(
"--nx",
type=int,
required=False,
default=192,
help="number of cells in x",
)

parser.add_argument(
"--ny",
type=int,
required=False,
default=192,
help="number of cells in y",
)

parser.add_argument(
"--nz",
type=int,
required=False,
default=96,
help="number of cells in z",
)

parser.add_argument(
"--L",
type=float,
required=False,
default=3200.0,
help="domain extent",
)

args = parser.parse_args()

thetafluxmag = 8.0e-3
qvfluxmag = 5.2e-5

# number of cells
nx = args.nx
ny = args.ny
nz = args.nz

L = args.L

ncf = nc_fields()

ncf.open("bomex_setup" + str(nx) + "x" + str(ny) + "x" + str(nz) + ".nc")

# domain origin
origin = (-1.0 * L, -1.0 * L, 0.0)

# domain extent
extent = (2.0 * L, 2.0 * L, L)

# mesh spacings
dx = extent[0] / nx
dy = extent[1] / ny
dz = extent[2] / nz

theta = np.zeros((nz + 1, ny, nx))
qv = np.zeros((nz + 1, ny, nx))
yvort = np.zeros((nz + 1, ny, nx))
xvort = np.zeros((nz + 1, ny, nx))
novort = np.zeros((nz + 1, ny, nx))

# ranges from 0 to nz
for k in range(nz + 1):
zz = k * dz
if zz < 520.0:
theta[k, :, :] = 298.7
elif zz < 1480:
theta[k, :, :] = 298.7 + (zz - 520.0) * (302.4 - 298.7) / (1480.0 - 520.0)
elif zz < 2000:
theta[k, :, :] = 302.4 + (zz - 1480.0) * (308.2 - 302.4) / (2000.0 - 1480.0)
else:
theta[k, :, :] = 308.2 + (zz - 2000.0) * (311.85 - 308.2) / (
3000.0 - 2000.0
)

# specific humidity
if zz < 520.0:
qv[k, :, :] = 1e-3 * (17.0 + zz * (16.3 - 17.0) / 520.0)
elif zz < 1480:
qv[k, :, :] = 1.0e-3 * (
16.3 + (zz - 520.0) * (10.7 - 16.3) / (1480.0 - 520.0)
)
elif zz < 2000:
qv[k, :, :] = 1.0e-3 * (
10.7 + (zz - 1480.0) * (4.2 - 10.7) / (2000.0 - 1480.0)
)
else:
qv[k, :, :] = 1.0e-3 * (
4.2 + (zz - 2000.0) * (3.0 - 4.2) / (3000.0 - 2000.0)
)

if zz < 300.0:
xvort[k, :, :] = 0.0043 * np.cos(np.pi * (zz + 600) / 1200.0) + 0.0023
yvort[k, :, :] = 0.0062 * np.cos((np.pi * (zz - 300) / 600.0) ** 2) - 0.0067
elif zz < 600.0:
xvort[k, :, :] = 0.0043 * np.cos(np.pi * (zz + 600) / 1200.0) + 0.0023
yvort[k, :, :] = 0.0027 * np.cos(np.pi * (zz - 300) / 600.0) - 0.0032
elif zz < 1400.0:
xvort[k, :, :] = -0.001 - 0.001 * np.cos(np.pi * (zz - 600.0) / 800.0)
yvort[k, :, :] = 0.005 * np.cos(np.pi * (zz - 1400.0) / 1600.0) - 0.0032
else:
xvort[k, :, :] = 0.0
yvort[k, :, :] = 0.0018

# add perturbation
rng = np.random.default_rng(seed=42)
noise = rng.uniform(low=-0.05, high=0.05, size=(nz + 1, ny, nx))
theta += noise

# write all provided fields
ncf.add_field("x_vorticity", xvort, unit="1/s")
ncf.add_field("y_vorticity", yvort, unit="1/s")
ncf.add_field("z_vorticity", novort, unit="1/s")
ncf.add_field("theta", theta, unit="K", long_name="potential temperature")
ncf.add_field("qv", qv, unit="kg/kg", long_name="water vapour spec. hum.")

ncf.add_box(origin, extent, [nx, ny, nz])

ncf.close()

#
# Setup surface fluxes:
#

ncf_flux = nc_fields()

ncf_flux.set_dim_names(["x", "y"])

ncf_flux.open("bomex_flux_" + str(nx) + "x" + str(ny) + ".nc")

# domain origin
origin = (-1.0 * L, -1.0 * L)

# domain extent
extent = (2.0 * L, 2.0 * L)

# mesh spacings
dx = extent[0] / nx
dy = extent[1] / ny

thetaflux = np.ones((ny, nx)) * thetafluxmag
qvflux = np.ones((ny, nx)) * qvfluxmag

ncf_flux.add_field("thetaflux", thetaflux, unit="K m/s")
ncf_flux.add_field("qvflux", qvflux, unit="kg/kg m/s")

ncf_flux.add_box(origin, extent, [nx, ny])

ncf_flux.close()

except Exception as err:
print(err)
Loading