angus-g / python-ale

Interface to MOM6 regridding/remapping in Python
MIT License
0 stars 0 forks source link

Alternative to global minimum smoothing: biharmonic smoother #10

Closed AndyHoggANU closed 4 months ago

AndyHoggANU commented 9 months ago

Suggesting that we add the option of making the background smoothing biharmonic, to reduce the damping of eddy-scale curvature while still smoothing out grid point-scale noise near weakly stratified regions ...

angus-g commented 8 months ago

I've just made the https://github.com/angus-g/python-ale/tree/adaptive-biharmonic branch which changes the ADAPT_MIN_SMOOTH parameter to ADAPT_BIHARMONIC_SMOOTHING (which acts like $\kappa$ in a regular diffusion equation, I think). The weighting for the density/pressure adaptivity now switches between 0 and 1, instead of 0 and 1 - min_smooth.

AndyHoggANU commented 8 months ago

OK, cool - I'll take a look. Any chance you can build it for me, like the ones in your python-ale/build/ directory?

angus-g commented 8 months ago

I've put it in python-ale/build-biharmonic, hopefully that works!

AndyHoggANU commented 8 months ago

Trying now, but not sure it is picking up the right version, for some reason. I am using

sys.path = ["/g/data/x77/ahg157/python-ale/build-biharmonic/lib.linux-x86_64-cpython-310"] + sys.path

and made a new .toml file with the ADAPT_BIHARMONIC_SMOOTHING parameter set, but it doesn't seem to pick it up, and instead lists the old parameter:

 init_MOM_state ADAPT_ALPHA_RHO:   -1.0000000000000000     
 init_MOM_state ADAPT_ALPHA_P:   -1.0000000000000000     
 init_MOM_state ADAPT_TIMESCALE:    3600.0000000000000     
 init_MOM_state ADAPT_MEAN_H:  F
 init_MOM_state ADAPT_SLOPE_CUTOFF:    1.0000000000000000E-002
 init_MOM_state ADAPT_SMOOTH_MIN:    0.0000000000000000     
 init_MOM_state ADAPT_ADJUSTMENT_SCALE:   0.10000000000000001     
 init_MOM_state ADAPT_RESTORING_TIMESCALE:    864000.00000000000     
 init_MOM_state ADAPT_TWIN_GRADIENT:  T
 init_MOM_state ADAPT_PHYSICAL_SLOPE:  T
 init_MOM_state ADAPT_RESTORE_MEAN:  F

Is this expected behaviour?

AndyHoggANU commented 8 months ago

Also, I'm trying to set:

ADAPT_BIHARMONIC_SMOOTHING = 1.0

under the assumption there is a dependence on grid size build in. Is that assumption correct?

angus-g commented 8 months ago

Is this expected behaviour?

No, that's a bit bizarre! I can reproduce that myself though, so I'll see if I can figure out what's going on.

Is that assumption correct?

That should be correct, yes.

angus-g commented 8 months ago

Okay! It was some dynamic linker silliness where it was loading libMOM6.so from the non-biharmonic build directory. Should be fixed now.

AndyHoggANU commented 8 months ago

Yep, now it picks up the new parameter. I'll give it a burl and report back.

AndyHoggANU commented 8 months ago

Tried to run -- it starts and seems to select the right parameters now. But it hangs, even for a single iteration, on the 10th cell in this notebook:

https://github.com/AndyHoggANU/anu-tub/blob/master/diagnostics/AG_Diagnostic_Test-biharmonic.ipynb

@angus-g -- can you reproduce this one?

angus-g commented 8 months ago

Interesting that the error messages aren't coming through in the notebook, I guess because they're generated from Fortran. Anyway, running standalone I get a lot of tangles like this:

 FATAL error: MOM_regridding, check_grid_column: Negative layer thickness implied by re-gridding, in build_grid_adaptive
 k,h,hnew=          17   9.9999999999999995E-007  -1.3702797938728304E-002
 dzI(k+1),dzI(k)=  -8.9444179059934353E-004  -1.4598239729327648E-002

I think I'll need to re-think how the limiting works for the biharmonic smoothing (and use this as my test case, because my other test didn't generate any tangles!)

AndyHoggANU commented 8 months ago

Yeah, it is strange, because I get lots of other fortran print statements coming through. Also surprising it hung, rather than crashed. Anyway, I can see limiters might need to be different for biharmonic ... Let me know if you get something new to test.

angus-g commented 7 months ago

We have discussed this a bit offline, but it seems possible that the inherent oscillations in a biharmonic filter might make this unsuitable for iterated application, as we're doing here. The other sources of diffusion in a running model are probably sufficient to make this approach work in that context.

AndyHoggANU commented 4 months ago

I would say that we have better options than biharmonic smoothing to solve this issue, so am closing this now. See issue #11 for details.