-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #326 from matt-frey/develop
Add 3D model
- Loading branch information
Showing
76 changed files
with
15,162 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
## How to contribute to EPIC | ||
Hi there. The core developers of EPIC thank you for your contribution. We have some guidelines though which we like you to follow before opening pull request. | ||
|
||
<!-- 29 November 2021 --> | ||
<!-- https://stackoverflow.com/questions/11948245/markdown-to-create-pages-and-table-of-contents?page=1&tab=votes#tab-top --> | ||
#### Table of Contents | ||
1. [Unit Testing](#unit-testing) | ||
2. [Coding Style](#coding-style) | ||
2. [Opening a pull request](#pull-request) | ||
|
||
### Unit Testing <a name="unit-testing"></a> | ||
Please write unit tests for newly added features and routines. All unit tests are located in the directory `unit-tests`. | ||
|
||
### Coding Style <a name="coding-style"></a> | ||
Please follow our coding style when contributing to EPIC. | ||
* use an indentation of 4 spaces | ||
* use lower case letters only | ||
* names of variables and subroutines / functions that consists of multiple words should be separated by underscores, e.g. `this_is_my_subroutine` | ||
* add a whitespace character before and after mathematical operations, e.g. `i = i + 1` | ||
* add a whitespace character after `if` and `while`, e.g. `if (i == 0)` | ||
|
||
|
||
### Opening a pull request <a name="pull-request"></a> | ||
Developers should fork the main repo and work with the branch `develop`. We only accept pull requests into `develop` of this repository. From time to time we pull all changes in `develop` into `main` and publish a release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# transpose the fields too! | ||
import xarray as xr | ||
import argparse | ||
import os.path | ||
import netCDF4 as nc | ||
import numpy as np | ||
|
||
parser = argparse.ArgumentParser() | ||
|
||
parser.add_argument("input_file_name", type=str) | ||
args = parser.parse_args() | ||
input_file_name = args.input_file_name | ||
|
||
file_root, file_ext = os.path.splitext(input_file_name) | ||
|
||
if not (file_ext == ".hdf5"): | ||
raise argparse.ArgumentTypeError('Argument filename must end on ".hdf5"') | ||
|
||
|
||
ds_nc=nc.Dataset(input_file_name) | ||
|
||
# set up time array | ||
tstep_keys=[] | ||
for key in ds_nc.groups.keys(): | ||
if 'step#' in key: | ||
tstep_keys.append(key) | ||
|
||
tlen=len(tstep_keys) | ||
time_array=np.zeros(tlen) | ||
for i_time in range(tlen): | ||
time_array[i_time]=ds_nc.groups[tstep_keys[i_time]].t | ||
|
||
# set up spatial arrays | ||
extent=ds_nc.groups['box'].extent | ||
origin=ds_nc.groups['box'].origin | ||
ncells=ds_nc.groups['box'].ncells | ||
|
||
x_array=np.linspace(origin[0],origin[0]+extent[0],ncells[0]+1)[:-1] | ||
y_array=np.linspace(origin[1],origin[1]+extent[1],ncells[1]+1)[:-1] | ||
z_array=np.linspace(origin[2],origin[2]+extent[2],ncells[2]+1) | ||
elem_array=range(3) | ||
|
||
step0=ds_nc.groups[tstep_keys[0]] | ||
|
||
ds_xr = xr.Dataset() | ||
|
||
for variable in step0.variables: | ||
n_dims=len(np.shape(step0[variable][:])) | ||
if(n_dims==3): | ||
ds_xr[variable] = xr.DataArray(coords=[time_array, z_array, y_array, x_array], dims=["time", "z","y","x"]) | ||
elif(n_dims==4): | ||
ds_xr[variable] = xr.DataArray(coords=[time_array, z_array, y_array, x_array, elem_array], dims=["time", "z","y","x", "index"]) | ||
|
||
ds_xr['diffB'] = xr.DataArray(coords=[time_array, z_array, y_array, x_array], dims=["time", "z","y","x"]) | ||
|
||
for i_time in range(tlen): | ||
this_step=ds_nc.groups[tstep_keys[i_time]] | ||
for variable in this_step.variables: | ||
ds_xr[variable][i_time]=np.transpose(this_step[variable][:]) | ||
if 'dry buoyancy' in this_step.variables: | ||
ds_xr['diffB'][i_time]=np.transpose(this_step['total buoyancy'][:])-np.transpose(this_step['dry buoyancy'][:]) | ||
|
||
ds_xr.to_netcdf(file_root + ".nc") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
``` | ||
&EPIC | ||
|
||
field_file = 'moist.hdf5' ! input field file | ||
field_tol = 1.0e-9 ! tolerance for parcel generation | ||
|
||
! | ||
! h5 output info | ||
! | ||
output%h5_field_freq = 50 ![s] write after these many seconds to the field HDF5 file | ||
output%h5_parcel_freq = 50 ![s] write after these many seconds to the parcel HDF5 file | ||
output%h5_parcel_stats_freq = 50 ![s] write after these many seconds to parcel stats HDF5 file | ||
output%h5_field_stats_freq = 50 ![s] write after these many seconds to the field stats HDF5 file | ||
output%h5_write_fields = .true. ! enable / disable field dump | ||
output%h5_write_parcels = .true. ! enable / disable parcel dump | ||
output%h5_write_parcel_stats = .true. ! enable / disable parcel statistics | ||
output%h5_write_field_stats = .true. ! enable / disable field statistics | ||
output%h5_overwrite = .true. ! replace existing HDF5 files | ||
output%h5_basename = 'moist' ! HDF5 output base name | ||
|
||
! | ||
! parcel info | ||
! | ||
parcel%n_per_cell = 8 ! initial number of parcels per cell | ||
parcel%lambda_max = 5.0 ! maximum parcel aspect ratio | ||
parcel%min_vratio = 36.0 ! minimum ratio of grid cell volume / parcel volume | ||
parcel%max_vratio = 2.89 ! maximum 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 | ||
|
||
! | ||
! stepper info | ||
! | ||
time%limit = 2000.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 | ||
/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
&MODELS | ||
|
||
model = 'MoistPlume' | ||
|
||
h5fname = 'moist.hdf5' | ||
|
||
box%ncells = 32, 32, 32 | ||
|
||
box%extent = 6280, 6280, 6280 | ||
box%origin = 0, 0, 0 | ||
|
||
moist%H = 0.8 | ||
moist%z_c = 2500 | ||
moist%mu = 0.9 | ||
moist%z_d = 4000 | ||
moist%z_m = 5000 | ||
moist%r_plume = 800 | ||
moist%e_values = 0.3, -0.4, 0.5 | ||
moist%l_condense = 1000.0 | ||
moist%q0 = 0.015 | ||
moist%theta_l0 = 288.0 | ||
/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
``` | ||
&EPIC | ||
|
||
field_file = 'robert3d.hdf5' ! input field file | ||
field_tol = 1.0e-9 ! tolerance for parcel generation | ||
|
||
! | ||
! h5 output info | ||
! | ||
output%h5_field_freq = 30 ![s] write after these many seconds to the field HDF5 file | ||
output%h5_parcel_freq = 30 ![s] write after these many seconds to the parcel HDF5 file | ||
output%h5_parcel_stats_freq = 30 ![s] write after these many seconds to parcel stats HDF5 file | ||
output%h5_field_stats_freq = 30 ![s] write after these many seconds to the field stats HDF5 file | ||
output%h5_write_fields = .true. ! enable / disable field dump | ||
output%h5_write_parcels = .true. ! enable / disable parcel dump | ||
output%h5_write_parcel_stats = .true. ! enable / disable parcel statistics | ||
output%h5_write_field_stats = .true. ! enable / disable field statistics | ||
output%h5_overwrite = .true. ! replace existing HDF5 files | ||
output%h5_basename = 'robert3d' ! HDF5 output base name | ||
|
||
! | ||
! parcel info | ||
! | ||
parcel%n_per_cell = 8 ! initial number of parcels per cell | ||
parcel%lambda_max = 5.0 ! maximum parcel aspect ratio | ||
parcel%min_vratio = 36.0 ! minimum ratio of grid cell volume / parcel volume | ||
parcel%max_vratio = 2.89 ! maximum 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 | ||
|
||
! | ||
! stepper info | ||
! | ||
time%limit = 1600.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 | ||
/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
&MODELS | ||
|
||
model = 'Robert' | ||
h5fname = 'robert3d.hdf5' | ||
|
||
box%ncells = 32, 32, 32 | ||
box%extent = 1000, 1000, 1000 | ||
box%origin = -500.0, -500.0, 0.0 | ||
|
||
robert_flow%n_bubbles = 3 | ||
|
||
robert_flow%bubbles(1)%dtheta_max = 0.5 | ||
robert_flow%bubbles(1)%center = 0.0, 0.0, 300.0 | ||
robert_flow%bubbles(1)%radius = 150.0 | ||
robert_flow%bubbles(1)%width = 50.0 | ||
|
||
robert_flow%bubbles(2)%dtheta_max = -0.15 | ||
robert_flow%bubbles(2)%center = 60.0, 60.0, 640.0 | ||
robert_flow%bubbles(2)%radius = 0.0 | ||
robert_flow%bubbles(2)%width = 50.0 | ||
|
||
robert_flow%bubbles(3)%dtheta_max = -0.35 | ||
robert_flow%bubbles(3)%center = -95.0, -80.0, 780.0 | ||
robert_flow%bubbles(3)%radius = 0.0 | ||
robert_flow%bubbles(3)%width = 70.0 | ||
|
||
/ |
Oops, something went wrong.