-
Notifications
You must be signed in to change notification settings - Fork 388
Add advection operator convergence test #583
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
Add advection operator convergence test #583
Conversation
|
@mark-petersen and @xylar here is my WIP advection operator convergence for the global advective test case. If you have some time, I'd greatly appreciate your comments. |
|
also tagging @jamilgafur |
| write_netcdf(convert(xarray.open_dataset('mesh_triangles.nc')), | ||
| 'base_mesh.nc') | ||
| write_netcdf(convert(xarray.open_dataset('mesh_triangles.nc'), | ||
| graphInfoFileName='graph.info'),'base_mesh.nc') |
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.
Perfect! My only comment here would be to indent another 5 spaces so the formatting follows the PEP8 convention.
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.
Just so I'm clear, indent the second line 5 more spaces? Is this so it is easier to see it is part of the convert function?
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.
If you load e3sm_unified you can run
autopep8 --in-place --aggressive --aggressive foo.py
on your python files for automatic pep8 spacing.
testing_and_setup/compass/ocean/cosine_bell/RMSE/default/config_driver.xml
Outdated
Show resolved
Hide resolved
| ii = line.find('=')+1 | ||
| pd = float(line[ii:]) | ||
|
|
||
| init = xr.open_dataset('../../'+resTag+'/default/init_step/initial_state.nc') |
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.
I really prefer people alter strings with .format() instead of string "addition". This may be may own prejudice but I don't see string addition used by seasoned python programmers.
| init = xr.open_dataset('../../'+resTag+'/default/init_step/initial_state.nc') | |
| init = xr.open_dataset('../../{}/default/init_step/initial_state.nc'.format(resTag)) |
|
|
||
| init = xr.open_dataset('../../'+resTag+'/default/init_step/initial_state.nc') | ||
| #find time since the beginning of run | ||
| ds = xr.open_dataset('../../'+resTag+'/default/forward/output/output.0001-01-01_00.00.00.nc') |
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.
Similar to above, maybe use .format().
| for i in range(len(latC)): | ||
| temp = R*np.arccos(np.sin(latCent)*np.sin(latC[i]) + np.cos(latCent)*np.cos(latC[i])*np.cos(lonC[i] - newLon)) | ||
| if temp < radius: | ||
| tracer[i] = psi0 / 2.0 * (1.0 + np.cos(3.1415926*temp/radius)) |
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.
Never loop if you don't have to in python.
| for i in range(len(latC)): | |
| temp = R*np.arccos(np.sin(latCent)*np.sin(latC[i]) + np.cos(latCent)*np.cos(latC[i])*np.cos(lonC[i] - newLon)) | |
| if temp < radius: | |
| tracer[i] = psi0 / 2.0 * (1.0 + np.cos(3.1415926*temp/radius)) | |
| temp = R*np.arccos(np.sin(latCent)*np.sin(latC) + np.cos(latCent)*np.cos(latC)*np.cos(lonC - newLon)) | |
| mask = temp < radius | |
| tracer[mask] = psi0 / 2.0 * (1.0 + np.cos(numpy.py*temp[mask]/radius)) |
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.
that's nice! thanks for the suggestion
| import matplotlib.pyplot as plt | ||
| import os | ||
|
|
||
| %matplotlib inline |
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.
I haven't seen this one before.
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.
this was an error in importing from jupyter notebook to python script. It's ipython magic. I've removed this.
|
@vanroekel, most of my comments are just little things that you're free to take or leave. Looks like a decent approach to me. Happy to do some testing once the time comes. |
vanroekel
left a comment
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.
Thanks @xylar I will make the changes. As I test this, I'm having a hard time controlling the plot size and position of the convergence label (annotate) command. Do you have any suggestions? Here is what a plot looks like right now
Oh, yeah, that doesn't look great. Let me see what I can figure out. |
testing_and_setup/compass/ocean/cosine_bell/RMSE/default/compute_rmse.py
Outdated
Show resolved
Hide resolved
| matplotlib.rcParams['figure.figsize'] = (16, 16) # Large figures | ||
| dpi=200; | ||
|
|
||
| ### axis_font = {'fontname':'Arial', 'size':'18'} | ||
| title_font = {'fontname':'Arial', 'size':'32', 'color':'black', 'weight':'normal'} | ||
| matplotlib.rc('xtick', labelsize=28) | ||
| matplotlib.rc('ytick', labelsize=28) |
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.
I think this is the stuff that's causing your figure to look bad. Try taking it out. I'll make a few recommendations below once you do that.
| p = np.polyfit(np.log10(xdata),np.log10(ydata),1) | ||
| conv = abs(p[0]) | ||
|
|
||
| plt.loglog(xdata,ydata,'k') |
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.
If the figure isn't the size you want, set the size here:
plt.figure(figsize=[<width>, <height>])where width and height are in inches.
| plt.loglog(xdata,ydata,'k') | ||
| plt.scatter(xdata,ydata,s=40,c='r') | ||
| plt.annotate('Order of Convergence = {}'.format(np.round(conv,2)),xy=((xdata[-1]+xdata[0])*0.4,ydata[0]),fontsize=28) | ||
| plt.savefig('convergence.png') |
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.
If the png is low resolution, set dpi=200 here. I wouldn't bother doing that earlier unless you're going to use plt.show().
|
|
||
| plt.loglog(xdata,ydata,'k') | ||
| plt.scatter(xdata,ydata,s=40,c='r') | ||
| plt.annotate('Order of Convergence = {}'.format(np.round(conv,2)),xy=((xdata[-1]+xdata[0])*0.4,ydata[0]),fontsize=28) |
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.
28 is a big font size. And it might work better to just put it in the upper left corner or something. There are probably other tricks for putting it "where it fits bets" like is done for legends. If you want that, I can look into it.
|
thanks @xylar! Your comments have been extremely helpful. Here is an updated plot |
|
@mark-petersen I've run through the advection test and here is the result The convergence order is much lower than expected. When you have a chance could you look through this test and see if I have an error? |
|
@vanroekel thanks for your work on this. The low order of convergence is certainly surprising. The direct comparison is Skamarock and Gassmann figure 4: |
|
@mark-petersen monotone is on here. We also are using the blended 3rd/4th order scheme (coeff3rdOrder =0.25). I've tried for various values of that coefficient and it doesn't help convergence order. I've also tried with non monotone and the order is roughly the same. |
src/core_ocean/mode_init/Makefile
Outdated
| mpas_ocn_init_hurricane.o \ | ||
| mpas_ocn_init_tidal_boundary.o | ||
| mpas_ocn_init_tidal_boundary.o \ | ||
| mpas_ocn_init_cosine_bell.o |
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.
Small edit, but spacing here is weird.
850201c to
45bda53
Compare
|
Rebased, compiled and tested with gnu and intel debug for initial condition. Ran QU240 test through forward. |
mark-petersen
left a comment
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.
This looks great! Thanks for your work @vanroekel. I cleaned up the COMPASS files so they are linked to templates rather than a bunch of individual files. Then it was very easy to add more resolutions in between. This still spans QU60 to QU240:

This is beautiful! The extra test cases give us more confidence in the slope.
I also was able to clean up the simulations. It had been writing output and restart files very frequently. It now can run all seven cases in 12 minutes on 4 nodes on grizzly with gnu.
|
@jonbob This one is ready to merge when we have an open E3SM slot. It changes both COMPASS and init mode Fortran code. |
|
I have a draft PR for moving the COMPASS changes from this PR to the new COMPASS repo: MPAS-Dev/compass#8 Once MPAS-Dev/compass#2 has been merged, we need to:
|
@vanroekel, would you like to remove the COMPASS changes from this PR, or would you prefer I do it? Here is a link that I think describes the approach we would use: https://stackoverflow.com/a/17824718/7728169 |
|
@vanroekel, I went ahead and tried the rebase. The link I posted above wasn't much help, I just needed to keep deleting modified contents in |
|
@xylar thanks for taking the time to pull the COMPASS changes out of that branch. It looks good to me. |
|
@vanroekel, I'm going to take that as tacit permission to alter your branch to update this PR. |
7db1d00 to
905dcd4
Compare
|
@mark-petersen, please merge this when it is convenient for E3SM. Then, we can update the |
|
@xylar, thanks for rebasing. Hopefully we can continue to merge these peripheral PRs during the mushy freeze. |
Adds the Skamarock and Gassmann cosine bell test case and a regression suite across resolutions to test operator convergence
905dcd4 to
0f1b805
Compare
0f1b805 to
f3f049a
Compare
|
Rebased. Corrected author and test case names. Tested successfully using COMPASS case, which is here: MPAS-Dev/compass#8, with gnu optimized and debug. |
Merge PR #583 'vanroekel/ocean/addCosineBellTest' into ocean/develop
|
Rebased version passes nightly regression suite with gnu debug. Ran convergence test here: MPAS-Dev/compass#8 with gnu debug an optimized, produces same plot as above. Takes 12 minutes on grizzly with 4 nodes. |
Add cosine bell advection test case This PR brings in a new mpas-source submodule with changes only to the ocean core. It adds initial condition for cosine bell test case, used for converge test of tracer advection. See MPAS-Dev/MPAS-Model#583 and MPAS-Dev/compass#8. [BFB]
Add cosine bell advection test case This PR brings in a new mpas-source submodule with changes only to the ocean core. It adds initial condition for cosine bell test case, used for converge test of tracer advection. See MPAS-Dev/MPAS-Model#583 and MPAS-Dev/compass#8. [BFB]
Merge PR MPAS-Dev#583 'vanroekel/ocean/addCosineBellTest' into ocean/develop






Adds the Skamarock and Gassmann cosine bell test case and a regression
suite across resolutions to test operator convergence
Reference: Section 2a in Skamarock, W.C. and A. Gassmann, 2011: Conservative Transport Schemes for Spherical Geodesic Grids: High-Order Flux Operators for ODE-Based Time Integration. Mon. Wea. Rev., 139, 2962–2975, https://doi.org/10.1175/MWR-D-10-05056.1