SpeedyWeather / SpeedyWeather.jl

Play atmospheric modelling like it's LEGO.
https://speedyweather.github.io/SpeedyWeather.jl/dev
MIT License
433 stars 27 forks source link

shallow-water case for a global ocean #412

Closed miniufo closed 6 months ago

miniufo commented 10 months ago

Hi, Just want to know if this wonderful model can be adapted slightly into a global ocean model in the case of shallow-water dynamics. What I know is that the deformation radius in the atmosphere and the ocean is quite different. So how to turn this into a global ocean simulation (in shallow-water case)?

milankl commented 10 months ago

Yeah that's possible. You can change the layer thickness and orography to be something more ocean-like. For gravity you can use as default or a reduced gravity. There might be other things you'd want to change too. The only thing you can't do is boundaries because of the spherical harmonics. But you could tweak the orography so that continents get really shallow.

pukpr commented 9 months ago

Here from a twitter comment. Definitely will need to apply a reduced effective gravity due to the small density difference along the thermocline, which is where most of the action is. I am not sure boundaries are that important apart from defining the standing-wave modes of such behaviors such as ENSO and Tropical Instability Waves. These always occur with the same characteristic spatial wavenumber so that ocean basin boundary conditions must apply, but that the spherical harmonics can be narrowed down to match the number of wavelengths that will fit across a basin. For ENSO in particular we are talking about a constrained waveguide structure so those properties must apply. Then as is well known, the travelling-wave offshoots of ENSO, such as Madden-Julian Oscillation can be simulated. But as my tweet indicated, the lunisolar tidal forcing is the key aspect to aligning/synchronizing with the climate index time-series.

milankl commented 9 months ago

At the moment gravity enters the shallow water equations via the Bernoulli potential $$\frac{1}{2}(u^2 + v^2) + g\eta$$ where however, the last term is currently calculted in spectral space. If both $g$ and $\eta$ depend on space (and time) then this operation would need to be moved to grid-point space together with the kinetic energy. Or alternatively, as it's done in the primitive equations, define a surface geopotential $\Phi_0 = gh_b$ with $h_b$ the orography and calculate the geopotential on every layer by adding to the surface geopotential (terrain following coordinates). However, if gravity was time dependent then we'd need to recalculate the surface geopotential in grid-point space on every time step and transform to spectral space.

In your examples you mention many coupled phenomenon like ENSO, note that while the shallow water system has Kelvin and Rossby waves important for El Nino, there's no temperature and the thermocline would need to take the form of the interface in the 1.5-layer shallow water model. The primitive equations here are for atmosphere only (the ideal gas law is hardcoded into the equations), so you'd need to find a setup that works for your case first.

pukpr commented 9 months ago

I'm thinking that there may be a bridge between adapting your atmospheric targeted simulations to the tighter deformation radius of ocean dynamics. Consider the QBO, which shares many characteristics of ENSO (constrained waveguide, standing waves, density stratification, lunisolar tidal forcing) but exists in the atmosphere only. Albeit the standing wave of QBO has a wavenumber of zero since there are no boundary conditions nor orographic constraints, i.e. it is longitudinally invariant. Overall this makes the lunisolar forcing much simpler since the group symmetry of wavenumber=0 implies that only nodal cycles can contribute to the wave stimulus (no synodic). I first identified the QBO cycle as being a straightforward nonlinear tidal mixing result of the annual nodal cycle with the nodal (Draconic) lunar cycle of 27.212 days -- QBO freq = (365.242/27.2122) mod 1 = 0.422/year => 2.37 year period. That is the criteria to use to calibrate the forced response of a fluid dynamics simulation of QBO.

As with many of these simulations, sure they can do essentially dead-reckoning physics from current conditions; but as far as I know, they have never been able to predict intrinsic spatiotemporal behaviors such as QBO with any consensus. And the QBO is important to global behaviors as there have been may claims of correlations between circulation direction and polar vortex dynamics.

milankl commented 9 months ago

If I implemented an interface for a space-time varying gravity in the shallow water model or the primitive equations, would you be able to formulate these dynamics into a problem we can set up and you could study?

pukpr commented 9 months ago

Yes, certainly. I am an Ada language person from years of software engineering experience but have an admiration for any software written in Julia. Within the last year have been doing experiments with the Julia Flux NN library so am comfortable with working with it.

milankl commented 6 months ago

In the ShallowWaterModel docs the gravity only enters through $g\eta$ but this is done in spectral space, so gravity could depend on time, but currently not on space. (You can't multiply two spectral variables without a transform). model.planet.gravity is mutable so you could define a callback (see here) that changes its value while the model is running.

In the primitive equation models, gravity enters the equations both through model.planet.gravity (physics) and the surface geopotential in model.orography.geopot_surf (dynamics). As before, it'll be anything but straight forward to make this dependent on space, but more so to make it dependent on time. You can also do this with a callback. The model.planet.gravity you can just set, like model.planet.gravity = 10 but the surface geopotential I'd scale, like

model.orography.geopot_surf .*= 1.1

to increase gravity by 10%.

pukpr commented 6 months ago

Not sure if the effective gravity actually needs to be time or space-dependent. The concept of effective gravity is a fictitious interaction, much like a fictitious centrifugal force is to the real centripetal force. The centrifugal force arises from needing to invent a force within a rotating reference frame, while a reduced effective gravity comes about from the reference frame of two stratified fluids of differing densities, thus only appearing to exist within a lower gravity environment.

So the decision is whether to adjust the model with a modified $g_{eff}$ or to treat the simulation with an emphasis on the strong stratification of layers with slightly different densities. It may in fact be possible to treat the thermocline level as the surface of the ocean, and the water above that as a very dense and heavy atmosphere generating a large pressure on the thermocline "surface". Of course that will remove wind convection from the model, which is considered the main driving force for surface waves.

This is the behavior I would think one would want to emulate for the ocean -- El Nino/La Nina thermocline cycles, since the thermocline is where all the action is.

milankl commented 6 months ago

I know this as the one and a half layer model, e.g. from Vallis book

image image image

So yes these are just the shallow water equations again as implemented and you can use a reduced gravity in SpeedyWeather by doing

julia> spectral_grid = SpectralGrid();

julia> planet = Earth(spectral_grid, gravity=0.1)
Earth{Float32} <: Main.SpeedyWeather.AbstractPlanet
├ rotation::Float32 = 7.29e-5
├ gravity::Float32 = 0.1
├ daily_cycle::Bool = true
├ length_of_day::Second = 86400 seconds
├ seasonal_cycle::Bool = true
├ length_of_year::Second = 31557600 seconds
├ equinox::DateTime = 2000-03-20T00:00:00
├ axial_tilt::Float32 = 23.4
└ solar_constant::Float32 = 1365.0

I haven't played much with reduced gravity, maybe there would be bugs, I don't know. If you use it, report back here? You won't get a proper ENSO because if you use SpeedyWeather for a shallow water ocean then you don't have an atmosphere to couple to with a Walker circulation that can adapt to SST changes. But you can get Rossby and Kelvin waves bouncing around. Technically you would need those to reflect off the basin boundaries (which we don't have because it's a spectral model) but maybe steep orography gradients are enough. I haven't tried that.

pukpr commented 6 months ago

There is not a strong 2-way coupling of ENSO to the atmosphere. That's merely a correlation which has been misinterpreted over the years. The change in the wind associated with ENSO events is a byproduct effect of the altered thermocline level. As described by Lin & Qian (https://www.nature.com/articles/s41598-019-49678-w), consider 3 types of ocean waves: free ocean wave, free ocean-atmosphere coupled wave, and forced ocean wave. The free Kelvin waves associated with MJO are delayed by ~21 days from the SOI time-series so are a traveling-wave effect, not a cause . It's definitely not a coupled wave because a subsurface wave is moving when the surface is neutral. So only tides can cause the forced internal ocean wave.

I only joined the conversation here because I noticed the top-level discussion on Twitter. I already have an analytical form for applying the forced tidal approach on a waveguide published at the same time as Lin & Qian. It may not be worth my time to toy with SpeedyWeather as I can cross-validate ENSO observations with a much simpler closed-form approach. Good luck, as it is still interesting to follow.

milankl commented 6 months ago

Thanks for the insight, I'm still (?) in the textbook thinking that ENSO is largely the dynamics of equatorial Kelvin and Rossby waves that reflect at the basin boundaries, (stochastically) forced or reinforced by atmospheric winds. Interesting that he ENSO prediction is still so challenging.

Feel free to pop by anytime, but yeah, for equatorial wave dynamics it's probably better to use a model that can have proper boundaries and is not based on spherical harmonics like SpeedyWeather.