-
Notifications
You must be signed in to change notification settings - Fork 19
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
Make the driver optional and provide entry points for composing ClimaAtmos simulations in Julia scripts Part I: AtmosGrids #2147
base: main
Are you sure you want to change the base?
Conversation
9531190
to
327b1d1
Compare
[skip ci][ci skip]
327b1d1
to
447b36b
Compare
[skip ci][ci skip]
447b36b
to
5ab4b9d
Compare
5ab4b9d
to
c4bf8ea
Compare
@@ -0,0 +1,701 @@ | |||
# This file contains the definitions of common AbstractAtmosGrids. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In terms of scope, these functions are just wrappers around ClimaCore objects, which leads me to think: should we just define these helper functions in ClimaCore? (otherwise we may end up repeating these patterns in the land) cc @simonbyrne
Keyword arguments | ||
================= | ||
|
||
- `nh_poly`: Horizontal polynomial degree. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we give this a better name? (put degree in it somewhere?)
|
||
- `nh_poly`: Horizontal polynomial degree. | ||
- `radius`: Radius of the sphere (in meters). | ||
- `h_elem`: Number of spectral elements per edge. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a more descriptive name? it's defined as the "number of elements across each panel of the cubed sphere"
- `x_elem`: Number of spectral elements on the x direction. | ||
- `x_max`: Length of the box (in meters) (`x_min` is 0). | ||
- `y_elem`: Number of spectral elements on the y direction. | ||
- `y_max`: Depth of the box (in meters) (`y_min` is 0). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these don't apply to the cubed sphere.
- `z_elem`: Number of spectral elements on the vertical direction. | ||
- `dz_bottom`: Resolution at the lower end of the column (in meters). | ||
- `dz_top`: Resolution at the top end of the column (in meters). | ||
- `z_max`: Height of the column (in meters). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we provide two options:
- a simple
z_grid
which takes in the column grid object, - pass any other arguments to the column grid constructor
- If we just provide
z_elem
andz_max
, it should be a uniform grid. - if we provide the
dz_X
args, it should give a stretched grid
- `topography`: Define the surface elevation profile. Provided as a warp function (or nothing). | ||
- `topo_smoothing`: Whether to order-2 smoothing on the LGL mesh. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First thing to figure out is what topography we want to support. Currently we have
ClimaAtmos.jl/src/solver/type_getters.jl
Line 129 in d978851
@assert topography in ("NoWarp", "DCMIP200", "Earth", "Agnesi", "Schar") |
-
no topography
-
analytic cases
- box/plane: Schar, Agnesi
- sphere: DCMIP200, mountain from shallow water case (not in ClimaAtmos)
-
from data file
- is preprocessed, with initial filtering applied to the data on the file lat/long grid (
"smoothing_order"
)ClimaAtmos.jl/src/solver/type_getters.jl
Lines 138 to 154 in d978851
elseif topography == "Earth" data_path = joinpath(topo_elev_dataset_path(), "ETOPO1_coarse.nc") earth_spline = NCDatasets.NCDataset(data_path) do data zlevels = Array(data["elevation"]) lon = Array(data["longitude"]) lat = Array(data["latitude"]) # Apply Smoothing smooth_degree = Int(parsed_args["smoothing_order"]) esmth = imfilter(zlevels, Kernel.gaussian(smooth_degree)) linear_interpolation( (lon, lat), esmth, extrapolation_bc = (Periodic(), Flat()), ) end @info "Generated interpolation stencil" warp_function = generate_topography_warp(earth_spline)
- interpolated to cubed sphere, with additional smoothing applied after via
"topo_smoothing"
ClimaAtmos.jl/src/utils/common_spaces.jl
Line 100 in d978851
topo_smoothing ? Hypsography.diffuse_surface_elevation!(z_surface) :
- is preprocessed, with initial filtering applied to the data on the file lat/long grid (
Closed in favor of CliMA/ClimaCore.jl#1848 |
This PR provides a user(/developer)-facing entry point to the computational grids used in
ClimaAtmos
.When working on
ClimaAtmos
, it happens often that a user(/developer) wants to quickly build the computational grid where a simulation is run. For instance, I had to do this all the time when developing and testing the diagnostics.Unfortunately, the primitives defined by
ClimaCore
are too low level to be directly helpful. On the other hand, there is no easy way to obtain the center/face spaces for the commonly used spaces in ClimaAtmos. InClimaAtmos
there is the functionget_spaces
for building the space.get_spaces
takes inparsed_args, params, comms_ctx
and returns aNamedTuple
with the center and face spaces (among the other things). This function requires defining aparsed_args
dictionary and fill it with the correct values, where "correct values" is a combination of values relevant for the configuration that one wants to build + other values (e.g., one always needs to passdz_bottom
even if we are working with uniform columns). Moreover, the function takesparams
(only to use the Earth's radius), which is a very complex object that cannot be easily created.So, at the end, the easiest way I found to create the various spaces is to run
get_integrator
with some of the various configurations, and get the space from one of the fields in the integrator. However, this is non ideal because it is much more expensive and opaque that it needs to be and also because the method doesn't work when I am actively working on the code andget_integrator
fails.With this PR, one can directly create all the spaces commonly used in ClimaAtmos. For instance, to define a
CubedSphere
with DCMIP200 topographysphere
containscenter_space
andface_space
(sphere.center_space
,sphere_face_space
).This PR addresses a second issue: the computational grid is a key object in any numerical simulation, but I think the
ClimaCore
Space
s are not the right level of abstraction for the higher-level interfaces ofClimaAtmos
. For instance, to find what is the height of my simulated columns, one needs to do something likeIt also is not easy to know what configuration is being simulated and one needs to know the details of
Meshes
andDomain
. An example of this problem is manifested by the fact that we have amodel_config
field in theAtmosModel
.model_config
is justsphere
,box
,plane
, orcolumn
, an information that should already be readily available. This PR defines the physically-relevant abstraction that most scientists will care about.In summary, this PR
ClimaAtmos
(as tested in the unit and integration tests),parsed_args
inget_spaces
,ClimaAtmos
from processing arguments and parameters, providing a way to build and work with important spaces, and improves the entangled logic inget_spaces
,