Antoine Renaud
email: antoine.renaud@ens-lyon.fr

Antoine Venaille
email: antoine.venaille@ens-lyon.fr

Freddy Bouchet
email: freddy.bouchet@ens-lyon.fr

Equilibrium statistical mechanics and energy partition for the shallow water model

Keywords: Equilibrium statistical mechanics, shallow water model, large deviations, turbulence, inertia-gravity waves, geostrophic flows

published or not. The documents may come

Equilibrium statistical mechanics and energy partition

for the shallow water model

Introduction

Geophysical turbulent flows have the propensity to self-organize into large scale coherent structures such as cyclones, anticyclones and jets. These coherent structures are long lived, but can also loose energy, for instance through the radiation of waves that eventually break into small scale structures. The aim of this paper is to understand the energy partition into large scale structures and small scale fluctuations in the framework of freely evolving shallow water dynamics, using statistical mechanics arguments. Indeed, geophysical turbulent flows involve a huge number of degrees of freedom coupled through non-linear interactions, which strongly motivates a statistical mechanics approach. This approach allows to reduce the study of self-organization and energy partition down to a few parameters, such as the total energy of the flow and its total enstrophy.

In the case of the three dimensional Euler equations, equilibrium statistical mechanics predicts that all the energy is lost into small scales, consistently with the classical picture of a small scale energy transfer. By contrast, two-dimensional flows are characterized by a large scale energy transfer, and equilibrium tools are appropriate to describe the large scale structure resulting from self-organization at the domain scale, in the absence of forcing and dissipation. The idea goes back to Onsager [START_REF] Onsager | Statistical hydrodynamics[END_REF], and has been mostly developed during the nineties after the work of Miller-Robert-Sommeria [START_REF] Miller | Statistical mechanics, Euler's equation, and Jupiter's Red Spot[END_REF][START_REF] Robert | Statistical equilibrium states for two-dimensional flows[END_REF], see also Refs. [START_REF] Majda | Nonlinear Dynamics and Statistical Theories for Basic Geophysical Flows[END_REF][START_REF] Eyink | Onsager and the theory of hydrodynamic turbulence[END_REF][START_REF] Bouchet | Statistical mechanics of two-dimensional and geophysical flows[END_REF] and references therein. Importantly, the theory predicts that the contribution of small scale fluctuations to the total energy are negligible in the two-dimensional case. Equilibrium statistical mechanics of two-dimensional and quasi-geostrophic flows is now fairly well understood. It has been applied to various problems in geophysical context such as the description of Jovian vortices [START_REF] Turkington | Statistical equilibrium predictions of jets and spots on Jupiter[END_REF][START_REF] Bouchet | Emergence of intense jets and Jupiter's Great Red Spot as maximum-entropy structures[END_REF], oceanic rings and jets [START_REF] Venaille | Oceanic Rings and Jets as Statistical Equilibrium States[END_REF][START_REF] Weichman | Equilibrium theory of coherent vortex and zonal jet formation in a system of nonlinear Rossby waves[END_REF], equilibria on a sphere [START_REF] Herbert | Additional invariants and statistical equilibria for the 2d euler equations on a spherical domain[END_REF], and to describe the vertical energy partition in continuously stratified quasi-geostrophic flows [START_REF] Merryfield | Effects of stratification on quasi-geostrophic inviscid equilibria[END_REF][START_REF] Venaille | The catalytic role of the beta effect in barotropization processes[END_REF][START_REF] Venaille | Bottom-trapped currents as statistical equilibrium states above topographic anomalies[END_REF].

Due to the combined effect of stable stratification, thin aspect ratio and rotation, geophysical flows are very different from classical three-dimensional turbulence. However, such flows are not purely twodimensional. Here we consider the shallow water equations, which is an intermediate model between three-dimensional and two-dimensional turbulence. This model describes the dynamics of a thin layer a fluid with homogeneous density. On the one hand, shallow water equations admit conservation laws similar to two-dimensional Euler equations, that lead to self-organization of the energy at large scale in the Euler case. On the other hand, shallow water dynamics support the presence of inertia-gravity waves that are absent from purely two-dimensional turbulence. A small scale energy transfer may exist due to the existence of these inertia-gravity waves in the shallow water system. The quasi-geostrophic model is recovered as a limit case of the shallow water model, when the Rossby parameter (comparing inertial terms to Coriolis forces) is small. A small Rossby number corresponds to a strong rotation limit. It is then natural to ask whether previously computed statistical equilibrium states of the quasi-geostrophic models remain equilibrium states of the shallow water model. More generally, given a certain amount of energy in an unforced, undissipated geophysical flow, will the flow self-organize into a large scale coherent structure, just as in two dimensional turbulence? Or will the energy be transferred towards the small scales, just as in three dimensional homogeneous turbulence? The aim of this paper is to answer these questions by computing statistical equilibrium states of the inviscid shallow water model.

The first step before computing equilibrium states is to identify a suitable phase space to describe microscopic configurations of the system. The phase space variables must satisfy a Liouville theorem, which ensures that the flow in phase space is divergence-less. Consequently, a uniform measure on a constant energy-Casimirs shell of phase space is invariant (microcanonical measure). The second step is to describe the system at a macroscopic level. The macrostates will be the sets of microstates sharing the same macroscopic behavior. The third step is to find the most probable macrostate, and to show that almost all the microstates correspond to this macrostate for given values of the constraints. While these three steps may be straightforward for differential equations with a finite number of degrees of freedom, for continuous systems described by partial differential equations, these three steps require the introduction of discrete approximations of the continuous field and of the invariant measure, and to study the continuous field limit of these discrete approximations. This point will be further discussed in the following. This program has been achieved in the 90s for the two-dimensional Euler equations. Indeed, a Liouville theorem is satisfied by the vorticity field, which describes therefore a microscopic configuration of the system. A macrostate can be defined as a probability field describing the distribution of vorticity levels at a given point, either through a coarse graining procedure [START_REF] Miller | Statistical mechanics of euler equations in two dimensions[END_REF][START_REF] Miller | Statistical mechanics, Euler's equation, and Jupiter's Red Spot[END_REF] or directly by the introduction of Young measures [START_REF] Robert | Etats d'équilibre statistique pour l'écoulement bidimensionnel d'un fluide parfait[END_REF][START_REF] Robert | A maximum-entropy principle for two-dimensional perfect fluid dynamics[END_REF][START_REF] Robert | Statistical equilibrium states for two-dimensional flows[END_REF].

For the shallow water dynamics, they are further issues that need to be overcome. The existence of a Liouville theorem for the shallow water flow was found by Warn [START_REF] Warn | Statistical mechanical equilibria of the shallow water equations[END_REF] by describing the flow configurations on a basis given by the eigenmodes of the linearized dynamics. However, the constraints of the problem given by dynamical invariants are not easily expressed in terms of the variables satisfying this Liouville theorem (except in the weak flow limit discussed by Warn [START_REF] Warn | Statistical mechanical equilibria of the shallow water equations[END_REF]). This difficulty has been overcome by Weichman and Petrich [START_REF] Weichman | Statistical Equilibrium Solutions of the Shallow Water Equations[END_REF] who considered first a Lagrangian representation of the flow, and then used a formal change of variable to describe the flow configurations with Eulerian variables convenient to express the constraints of the problem. Using a different method that does not require a Lagrangian representation of the fluid, we will show the existence of a formal Liouville theorem.

A second difficulty concerns the choice of a relevant discrete approximation that allows to keep as much as possible geometric conservations laws of the continuous dynamics. Those geometric conservation laws include the Liouville property, the Lagrangian conservation laws (i.e. the conservation of the volume carried by each fluid particle), and global dynamical invariants. Unfortunately, we are not aware of a discrete model that does not break at least one of those geometric conservation laws. However, we will argue that there is no logical need for the discrete model to satisfy all the conservation laws of the continuous dynamics in order to guess the correct microcanonical measure of the continuous system by considering the limit of a large number of degrees of freedom.

A third difficulty is that local small scale fluctuations of the fields may have a substantial contribution to the total energy. This contrasts with 2d Euler dynamics, for which small scale fluctuations of the vorticity field have a vanishingly small contribution to the total energy in the continuous limit. In the shallow water case, it is not a priori obvious that the contribution of these small scale fluctuations to the total energy can be expressed in terms of the macroscopic probability density field.

In order to overcome the second and the third difficulty, we introduce in this paper a semi-Lagrangian discretization : one the one hand, we consider fluid particles of equal volume, which allows to keep track of the Lagrangian conservation laws of the dynamics. On the other hand, the particle positions are restricted to a uniform horizontal grid, and each grid node may contain many particles, which allows for an Eulerian representation of the macrostates and to keep track of global conservation laws, while taking into account the presence of small scale fluctuations contributing to the total energy. We then derive the statistical mechanics theory for this discrete representation of the shallow water model, using large deviation theory.

We will argue that in the limit of a large number of degrees of freedom, the equilibrium states of the semi-Lagrangian discrete model are the equilibrium states of the actual shallow water system, and we will also show that we recover with this model results already obtained in several limiting cases. While the statistical mechanics treatment of our discrete model is rigorous, there is some arbitrariness in our definition of the discrete model, which is not fully satisfactory.

We stress that our approach to guess the invariant measure of the continuous shallow-water system is heuristic: there is to our knowledge no simple way to define mathematically the microcanonical measure or the Gibbs measure of an Hamiltonian infinite dimensional system. As far as we know the only example of a rigorous work for defining invariant measures in the class of deterministic partial differential equations of interest, is a work by [START_REF] Bourgain | Periodic nonlinear schrödinger equation and invariant measures[END_REF] on the periodic nonlinear Schrodinger equation. For the 2d Euler equations, the microcanonical measure seems clear from a physical point of view because different discretizations, for instance either Eulerian ones [START_REF] Miller | Statistical mechanics of euler equations in two dimensions[END_REF][START_REF] Robert | On the statistical mechanics of 2d euler equation[END_REF] or Lagrangian ones (see [START_REF] Dubinkina | Statistical relevance of vorticity conservation in the Hamiltonian particle-mesh method[END_REF], lead to a consistent picture in the thermodynamics limit, but even in that case no clear mathematical construction of the invariant measure exists.

There exist only a very limited number of results on statistical equilibrium states of the shallow water system. Warn [START_REF] Warn | Statistical mechanical equilibria of the shallow water equations[END_REF] studied the equilibrium states in a weak flow limit in the energy-enstrophy ensemble. He showed that in the absence of lateral boundaries and in the absence of bottom topography, all the initial energy of a shallow water flow is transferred towards small scales. Here we relax the hypothesis of a weak flow, generalizing the conclusions of Warn [START_REF] Warn | Statistical mechanical equilibria of the shallow water equations[END_REF] for any flow, and we discuss the effect of bottom topography. We show that when there is a non zero bottom topography and when the flow is rotating, there is a large scale flow associated with the equilibrium states.

Refs. [START_REF] Merryfield | Equilibrium Statistical Mechanics of Barotropic Flow over Finite Topography[END_REF][START_REF] Chavanis | Statistical mechanics of the shallow water system[END_REF] did compute statistical equilibrium states of "balanced" shallow water flows, by assuming that all the energy remain in the large scale flow. The equilibria described by Merryfield et al [START_REF] Merryfield | Equilibrium Statistical Mechanics of Barotropic Flow over Finite Topography[END_REF] were obtained in the framework of the energy-enstrophy theory, neglecting any other potential vorticity moments than the potential enstrophy. Similar states were described as minima of the potential enstrophy for the macroscopic potential vorticity field by Sanson [START_REF] Sansón | Evolution and decay of a rotating flow over random topography[END_REF].

Chavanis and Sommeria [START_REF] Chavanis | Statistical mechanics of the shallow water system[END_REF] proposed a generalization of the 2D-Euler variational problem given by the Miller-Robert-Sommeria theory to the shallow water case. Their main result is a relationship between the large scale streamfunction and height field. This result was very interesting and inspiring to us. However, Chavanis and Sommeria did not derive their variational problem from statistical mechanics arguments but proceeded through analogy. They were moreover neglecting height fluctuations. This does not allow for energy partition between vortical flow and fluctuations, and moreover leads to inconsistencies for some range of parameters, as the Chavanis-Sommeria constrained entropy can be shown to have no maxima for negative temperatures (the negative temperature critical points of this variational problem are saddles rather than maxima). As a consequence a range of possible energy values can not be achieved in this phenomenological framework. Nevertheless, with an approach based on statistical mechanics, we will confirm, in this study, the form of the variational problem proposed by Chavanis and Sommeria [START_REF] Chavanis | Statistical mechanics of the shallow water system[END_REF] for describing part of the field, for a restricted range of parameters. We stress however, that generically part of the energy will be carried by the fluctuations, and thus that the Chavanis-Sommeria variational problem should be considered with an energy value which is not the total one. Determining which part of the energy should be taken into account requires a full statistical mechanics treatment, taking into account height fluctuations. We also note that for some other ranges of parameters, all the energy will be carried by the fluctuations, and thus the Chavanis-Sommeria variational problem then does not make sense.

In the preparation of this work, we have also been inspired by the work of Weichman and Petrich [START_REF] Weichman | Statistical Equilibrium Solutions of the Shallow Water Equations[END_REF]. In this work, the authors computed a class of statistical equilibrium states of the shallow water system, starting from a grand canonical distribution. The main result of their work is the same equation describing the relation between the large scale stream function and height field, as the one previously obtained by Chavanis and Sommeria [START_REF] Chavanis | Statistical mechanics of the shallow water system[END_REF]. The Weichman-Petrich approach seemed more promising than the Chavanis-Sommeria one as it was based on a statistical mechanics treatment. However it also fails to predict which part of the energy goes into fluctuations, and to recognize the range of parameters for which the mean field equation for the largest scale is relevant. The reason is that, while natural in condensed matter physics, the hypothesis of a Gibbs or a grand canonical distribution, is questionable for an inertial flow equation which is in contact neither with an energy bath, nor with a potential vorticity bath. Related to this issue, Weichman and Petrich had to assume an ad hoc scaling for the thermodynamical parameters, in order to obtain statistical ensembles where entropy actually balances conservation laws. It has been recognized for a long time that this kind of theoretical difficulties are related to the Rayleigh-Jeans paradox. The proper way to address these issues, in some fluid models like for instance the two-dimensional Euler equation, is to start from the microcanonical measure rather than from a canonical or grand canonical one [START_REF] Bouchet | Statistical mechanics of two-dimensional and geophysical flows[END_REF]. We will overcome all these problems in this work by solving the microcanonical problem, which may seem more difficult, but which can be handled using large deviation theory. It also leads to a more precise description of macrostate probabilities.

In this paper, starting from the microcanonical measure, we propose a complete computation of the macrostate entropy for the shallow water equations. In order to achieve this goal, we consider a large-deviation approach that allows to perform the statistical mechanics computation in an explicit and clear way, and that gives a precise description of most-probable macrostates. Moreover, we compute explicitly both the large scale flow and the small scales fluctuations of the equilibrium states. Our results are thus a complete statistical mechanics treatment of the shallow water equations.

We also connect our general results to some of the partial treatment discussed in the previous literature. For instance, we show that only one subclass of the states described by [START_REF] Merryfield | Equilibrium Statistical Mechanics of Barotropic Flow over Finite Topography[END_REF][START_REF] Weichman | Statistical Equilibrium Solutions of the Shallow Water Equations[END_REF][START_REF] Chavanis | Statistical mechanics of the shallow water system[END_REF] are actual statistical equilibria of the shallow water model. More precisely, we will see that the large scale flow and the small scales fluctuations can be interpreted as two subsystems in thermal contact, and that the temperature of small scales fluctuations is necessarily positive. The large scale flow is therefore also characterized by a positive temperature.

The paper is organized as follows. The shallow water model and its properties are introduced in section 2. Equilibrium statistical mechanics of a discrete flow model arguably relevant to describe the continuous shallow water system is derived in section 3. Computation of the equilibrium states and a description of their main properties are presented in section 4. Energy partition between a large scale flow and small scale fluctuations is computed analytically in the quasi-geostrophic limit in section 5, which also includes a geophysical application to the Zapiola anticyclone. The main results are summarized and discussed in the conclusion.

Shallow water model

Dynamics

The shallow water equations describe the dynamics of a fluid layer with uniform mass density, in the limit where the layer depth is very small compared to the horizontal length scales of the flow [46,29]. In this limit the vertical momentum equation yields hydrostatic equilibrium, and the horizontal velocity field (u, v) = u(x,t) is depth independent, where x = (x, y) is any point of a two-dimensional simply connected domain D. We consider the Coriolis force in the f-plane approximation, i.e. with a constant Coriolis parameter f and a rotation axis along the vertical direction. We denote η (x,t) the vertical displacement of the upper interface and h b (x) the bottom topography (see Fig. 1). The origin of the z axis is chosen such that

ˆD dx h b (x) = 0, (1)
and the vertical displacement is defined such that

ˆD dx η (x,t) = 0 (2)
as well. We introduce the total depth

h = H -h b + η (x,t) , (3)
where

H = 1 |D| ˆD dr h (r) (4)
is the mean depth of the fluid, with |D| the area of the flow domain. The horizontal and vertical length units can always be chosen such that the domain area and the mean height H are equal to one (|D| = 1, H = 1), and this choice will be made in the remainder of this paper. The dynamics is given by the horizontal momentum equations

∂ t u + u∂ x u + v∂ y u -f v = -g∂ x (h + h b ) ∂ t v + u∂ x v + v∂ y v + f u = -g∂ y (h + h b ) (5)
and the mass continuity equation where ∇ = (∂ x , ∂ y ), with impermeability boundary conditions

∂ t h + ∇ • (hu) = 0, (6)
u • n = 0 on ∂ D, ( 7
)
where n is the outward border-normal unit vector. By introducing the Bernoulli function

B ≡ 1 2 u 2 + g (h + h b -1) , (8)
the relative vorticity field

ω = ∂ x v -∂ y u, (9)
the divergence field

ζ = ∇ • u = ∂ x u + ∂ y v, (10)
and the potential vorticity field

q = ω + f h , (11)
the momentum equations ( 5) can be recast into a conservative form

∂ t u -qhv = -∂ x B ∂ t v + qhu = -∂ y B . ( 12
)
One can get from the momentum equations [START_REF] Fofonoff | Steady flow in a frictionless homogeneous ocean[END_REF] a dynamical equations for the potential vorticity field [START_REF] Farge | Wave-vortex dynamics in rotating shallow water[END_REF] and for the divergence field [START_REF] Eyink | Onsager and the theory of hydrodynamic turbulence[END_REF], respectively:

∂ t q + u • ∇q = 0, ( 13
)
∂ t ζ -∇ ⊥ • (qhu) = -∆ B, (14)
where ∆ = ∇ • ∇ is the Laplacian operator and ∇ ⊥ = (-∂ y , ∂ x ). In order to show that the shallow water system described by (h, u) is also fully described by the triplet (h, q, ζ ), we introduce the velocity streamfunction ψ(x, y,t) and the velocity potential φ (x, y,t) through the Helmholtz decomposition of the velocity1 :

u = ∇ ⊥ ψ + ∇φ . ( 15
)
The boundary condition for the velocity given in Eq. ( 7) yields

n • ∇ ⊥ ψ = 0 n • ∇φ = 0 on ∂ D, ( 16
)
where n is the boundary normal vector. The relative vorticity [START_REF] Dubinkina | Statistical relevance of vorticity conservation in the hamiltonian particle-mesh method[END_REF] and the divergence ( 10) can be expressed in terms of the velocity streamfunction and velocity potential as

ω = ∆ ψ, ζ = ∆ φ . ( 17
)
To the fields ω and ζ correspond a unique field ψ and a field φ defined up to a constant with the boundary condition [START_REF] Herbert | Restricted equilibrium and the energy cascade in rotating and stratified flows[END_REF]. Thus, to the fields ω = qhf and ζ corresponds a unique velocity vector written formally as

u = ∇ ⊥ ∆ -1 (qh -f ) + ∇∆ -1 ζ . ( 18
)
It will also be useful to consider the field µ defined as

µ = ∆ 1/2 φ , (19)
where ∆ 1/2 is the linear operator whose eigenmodes are Laplacian eigenmodes in the domain D with the boundary condition n • ∇ = 0 on ∂ D, and whose eigenvalues are the negative square root of the modulus of Laplacian eigenvalues. The field µ can be interpreted as a measure of the amplitude of the potential contribution to the velocity field, given that ´D µ 2 = ´D (∇φ ) 2 . This field will also be referred to as the divergence field in the following. To the field µ correspond a unique field φ (up to a constant). Thus, the shallow water system is fully described by the triplet (h, q, µ), and the velocity vector can be written formally in terms of these fields as

u = ∇ ⊥ ∆ -1 [hq -f ] + ∇∆ -1/2 [µ] . (20)

Stationary states

We investigate in this subsection the conditions for stationarity of the flow in the shallow water model following [START_REF] Chavanis | Statistical mechanics of the shallow water system[END_REF]. Using a Helmholtz decomposition, one can define the mass transport streamfunction Ψ (x, y,t) and the mass transport potential Φ(x, y,t) , not to be confused with ψ and φ defined in Eq. ( 15) and ( 16):

hu = ∇ ⊥ Ψ + ∇Φ. (21)
The boundary condition for the velocity given in Eq. ( 7) yields

n • ∇ ⊥ Ψ = 0 n • ∇Φ = 0 on ∂ D. ( 22
)
It will be useful in the remainder of the paper to express the vorticity field defined in Eq. ( 9) and the divergent field defined in Eq. ( 10) in terms of these transport streamfunction Ψ and transport potential Φ :

ω = ∇ • 1 h ∇Ψ + J 1 h , Φ , (23)
ζ = ∇ • ∇Φ h -J 1 h ,Ψ , (24)
where

J ( f , g) = ∂ x f ∂ y g -∂ y f ∂ x g (25)
is the Jacobian operator. The dynamics in Eqs. ( 6), ( 13) and ( 14) can also be written in terms of Ψ and Φ:

∂ t h = -∆ Φ, (26)
∂ t q + 1 h J(Ψ , q) + 1 h ∇Φ • ∇q = 0, ( 27
)
∂ t ζ + J(Φ, q) -q∆Ψ -∇q • ∇Ψ = -∆ B. (28)
We see that ∂ t h = 0 implies Φ = Cst, and ∂ t q = 0 implies J(Ψ , q) = 0, which means that isolines of potential vorticity are the mass transport streamlines. This is the case if for instance q = F (Ψ ).

Reciprocally, if Φ = Cst and if q and Ψ have the same isolines, then ∂ t h = 0 and ∂ t q = 0, which also implies ∂ t Ψ = 0. Thus, through the decomposition [START_REF] Michel | Large deviations for young measures and statistical mechanics of infinite dimensional dynamical systems with conservation law[END_REF], the velocity field is also stationary, with u = (1/h) ∇ ⊥ Ψ . We conclude that a necessary and sufficient condition for a shallow water flow (h, u) to be stationary is Φ = Cst, q and Ψ have the same isolines.

There is an additional relation verified by the stationary flow. This relation may be obtained by considering stationarity of the kinetic energy. The dynamics of the kinetic energy is obtained from Eq. ( 12):

∂ t u 2 2 = - 1 h J(Ψ , B) - 1 h ∇Φ • ∇B. ( 30
)
Stationarity of the kinetic energy field and Eq. ( 29) gives J(Ψ , B) = 0: the Bernoulli function defined in Eq. ( 8) and the mass transport streamfunction Ψ have the same isolines. In addition, in any subdomain where q = F(Ψ ), the stationarity of the velocity field and the momentum equations [START_REF] Fofonoff | Steady flow in a frictionless homogeneous ocean[END_REF] give the relation

q = dB dΨ . (31)

Conserved quantities

Provided that the velocity and height fields remain differentiable, the shallow water dynamics in Eqs. ( 6), ( 13) and ( 14) conserves the total energy

E [u, h] = 1 2 ˆdx hu 2 + g (h + h b -1) 2 , (32)
which includes a kinetic energy contribution and a potential energy contribution. It is known that the shallow water dynamics sometimes leads to shocks that prevent energy conservation. We postpone a discussion of this important point to the last section of this paper.

As a consequence of particle relabeling symmetry there is an infinite number of other conserved quantities called Casimir functionals, see e.g. [START_REF] Salmon | Lectures on Geophysical Fluid Dynamics[END_REF]. These functionals are written

C s = ˆdx hs(q) , ( 33
)
where s is any distribution. This conservation can be easily checked from Eqs. ( 13) and ( 6). The conservation of all the Casimirs implies the conservation of all the potential vorticity moments

∀k ∈ N, Z k = ˆdx hq k . ( 34
)
These Casimir functionals include the total mass conservation (k = 0), the conservation of the circulation2 (k = 1) and the conservation of the enstrophy (k = 2).

The conservation of all the Casimirs is equivalent to the conservation of mass plus the conservation of the potential vorticity distribution D [q] defined through

∀σ , D [q] (σ ) dσ = ˆdx hI {σ ≤q≤σ +dσ } ( 35
)
where I {σ ≤q≤σ +dσ } is the characteristic function, i.e. it returns one if σ ≤ q (x) ≤ σ + dσ and zero otherwise. It means that the global volume of each potential vorticity level σ q is conserved through the dynamics.

We will restrict ourselves to initial states where the potential vorticity field has a distribution characterized by its moments only, then the knowledge of its global distribution given in Eq. ( 35) and of the total mass is equivalent to the knowledge of the moments given in Eq. [START_REF] Robert | Relaxation towards a statistical equilibrium state in two-dimensional perfect fluid dynamics[END_REF].

Depending on the domain geometry, there could be additional invariants. For the sake of simplicity, we do not discuss the role of these additional invariant in this paper, but it would not be difficult to generalize our results by taking them into account.

In the quasi-geostrophic or two-dimensional Euler models, dynamical invariants have important consequences such as the large scale energy transfer, the self-organization at the domain scale, and the existence of an infinite number of stable states for the dynamics, see for instance Ref. [START_REF] Bouchet | Statistical mechanics of two-dimensional and geophysical flows[END_REF] and references therein. We show in the present paper that these dynamical invariants play a similar role in the shallow water case, allowing for a large-scale circulation associated with the potential vorticity field, even if this process may be associated with a concomitant loss of energy toward small scales.

Equilibrium statistical mechanics of a discrete shallow water model

The aim of this section is to compute statistical equilibrium states of a discrete model of the shallow water system and to consider the thermodynamic limit for this model. In the first subsection, a formal Liouville theorem is given for the triplet of variables (h, hu, hv) and then the triplet (h, q, µ) after a change of variables. The derivation given with more details in Appendix A is made in the Eulerian representation. This allows to write formally the microcanonical measure of the shallow water model for these triplets of fields.

In the second subsection, a finite dimensional semi-Lagrangian discretization of the model is proposed to give a physical meaning to the formal measure. Other discretizations of the shallow water system may have been considered but any other choices we have tried were not taking into account the fluid particle mass conservation and led to inconsistent results (for instance the equilibrium states were not stationary, not stable by coarse-graining, and unbalanced, see Appendix E).

Then the macroscopic states are defined through a coarse-graining procedure in a third subsection. The variational problem leading to the equilibrium states, i.e. the most probable macroscopic state, is introduced in the fourth subsection. This variational problem generalizes the Miller-Robert-Sommeria equilibrium theory to the shallow water system.

Liouville theorem

The first step before computing equilibrium states is to define what is a microscopic configuration of the system, which requires to identify the relevant phase space. The simplest set of variables to consider are those that satisfy a Liouville theorem. A Liouville theorem means that the flow in phase space is non-divergent, which implies the time invariance of the microcanonical ensemble. The existence of a Liouville theorem for the shallow water system was initially shown by Warn [START_REF] Warn | Statistical mechanical equilibria of the shallow water equations[END_REF] who considered a decomposition of the flow fields on a basis given by the eigenmodes of the linearized dynamics. A Liouville theorem was shown by Weichman and Petrich [START_REF] Weichman | Statistical Equilibrium Solutions of the Shallow Water Equations[END_REF] for a Lagrangian representation of the dynamics. Following a general method proposed by one of us and described by Thalabard [START_REF] Thalabard | Contributions to the statistical mechanics of ideal two and a half dimensional flows[END_REF], it is shown in Appendix A that the triplet (h, hu, hv) does satisfy a formal Liouville theorem. At a formal level, the microcanonical measure can then be written3

dµ h,hu,hv E, {Z k } k≥0 = 1 Ω E, {Z k } k≥0 D [h] D [hu] D [hv] δ (E -E) +∞ ∏ k=0 δ (Z k -Z k ) , (36)
with the phase space volume

Ω E, {Z k } k≥0 = ˆD [h] D [hu] D [hv] δ (E -E) +∞ ∏ k=0 δ (Z k -Z k ) . ( 37
)
Here E is the energy of a microscopic configuration defined in Eq. [START_REF] Robert | On the statistical mechanics of 2d euler equation[END_REF], and the {Z k } k≥0 are the potential vorticity moments of a microscopic configuration defined in Eq. [START_REF] Robert | Relaxation towards a statistical equilibrium state in two-dimensional perfect fluid dynamics[END_REF]

Assuming ergodicity, the ensemble average A dµ h,hu,hv can finally be interpreted as the time average of the observable A .

The triplet (h, hu, hv) is not a convenient one to work with, since the Casimir functionals {Z k } k≥0 defined in Eq. ( 34) are not easily expressed in terms of these fields. Indeed, the expression of the Casimir functionals {Z k } k≥0 involve not only the triplet (h, hu, hv), but also the triplet of the horizontal derivatives of these fields. We showed in subsection 2.1 that the triplet of fields (h, q, µ) fully describes the shallow water dynamics in a closed domain, and the functionals {Z k } k≥0 are much more easily expressed in terms of the fields h, q. It is therefore more convenient to use these fields as independent variables. The price to pay is that the simple form of the energy defined in Eq. [START_REF] Robert | On the statistical mechanics of 2d euler equation[END_REF] in terms of the triplet (h, hu, vh) becomes more complicated when expressed in terms of the triplet (h, q, µ). However, we will propose a simplified version of this energy functional, and argue in Appendix B that this is the relevant form of the energy to consider to compute the equilibrium state.

Unfortunately no direct proof of a Liouville theorem can be obtained for the triplet (h, q, µ). However, it is still possible to start from the microcanonical measure built with (h, hu, hv) in Eq. [START_REF] Salmon | The shape of the main thermocline, revisited[END_REF], and change variables at a formal level.It is shown in Appendix A.2 that the Jacobian of the transformation is 4

J (h, hu, hv) (q, h, µ) = Ch 3 . ( 39
)
where C is a constant. We conclude that the microcanonical measure can therefore be formally written

dµ h,q,µ E, {Z k } k≥0 = 1 Ω E, {Z k } k≥0 h 3 D [h] D [q] D [µ] δ (E -E) +∞ ∏ k=0 δ (Z k -Z k ) , (40)
with

Ω E, {Z k } k≥0 = ˆh3 D [h] D [q] D [µ] δ (E -E) +∞ ∏ k=0 δ (Z k -Z k ) . (41)
In that case, the expectation of an observable A [q, h, µ] in the microcanonical ensemble is given by

A dµ q,h,µ = ˆdµ q,h,µ A [q, h, µ] . (42)
A finite-dimensional projection of the fields will be given in the next subsection to give a meaning to the formal notations of this subsection.

A discrete model

In this subsection, we devise a discrete model of the shallow water system based on a semi-Lagrangian representation. This allows to give a finite dimensional representation of the formal measure given Eq. [START_REF] Thalabard | Contributions to the statistical mechanics of ideal two and a half dimensional flows[END_REF].

In order to keep track of the conservation properties of the continuous dynamics, we propose a convenient discretization of the shallow water system in terms of fluid particles. Since the fluid is considered incompressible, it is discretized into equal volume particles. The fluid particles do not have necessarily the same height, and the horizontal velocity field may be divergent. It is not possible to build a uniform grid with a single fluid particle per grid point since two particles with equal volume and different height can not occupy the same area. In order to bypass this difficulty, we define a uniform grid where several fluid particles can occupy a given site. To keep track that the actual fluid is continuous and incompressible, we add the condition that the area occupied by the particles inside a grid site fit the available area of the grid site.

In a first step the ensemble of microscopic configurations (the ensemble of the microstates of the discrete model) is defined. In a second step, the constraints of the discrete shallow water system are introduced, which allows to define the microcanonical measure of the discrete model in a third step. 4 The h 3 term that appears after the change of variables in the functional integral must be understood as a "functional product" ∏ x∈D h 3 (x), see also the finite-dimensional representation of this measure given in the next subsection.

Definition of the ensemble of microscopic configurations

For the sake of simplicity, the domain D where the flow takes place is considered rectangular but generalizing the results to any shape would be straightforward. We recall that the horizontal and vertical length units have been chosen such that the domain area and the mean height are equal to one (|D| = L x L y = 1, H = 1). The domain D is discretized into a uniform grid with N = N x × N y sites. The area of a grid site is |D| /N = 1/N. Each site can contain many fluid particles. It is assumed that the fluid contains N × M fluid particles of equal mass and volume (the fluid is incompressible), where M is the average number of particles per site. The volume of a fluid particle is therefore

δV = |D| H NM = 1 NM . ( 43
)
The grid sites are indexed by (i, j) with 1 ≤ i, j ≤ N x , N y and the fluid particles by n with 1 ≤ n ≤ NM.

Each fluid particle is characterized by its position (I n , J n ) on the grid, by its potential vorticity q n ∈ [q min , q max ], its divergence µ n ∈ [-µ max , µ max ] and its height h n ∈ [h min , h max ]. The cutoffs on the potential vorticity can be physically related to actual minimum and maximum in the global distribution of potential vorticity level defined in Eq. [START_REF] Salmon | Lectures on Geophysical Fluid Dynamics[END_REF], since this distribution is conserved by the dynamics. Such a justification does not exist for the other cutoffs. We will consider first the limit of an infinite number of fluid particles per grid site (M → +∞), then the limit of an infinite number of grid site (N → ∞) and finally the limit of infinite height and divergence cut-off µ max → +∞, h max → +∞, h min → 0. We will see that the result does not depend on those cut-off.

Let us introduce M i j the number of particles per grid site (i, j), defined as

M i j = NM ∑ n=1 δ I n ,i δ J n , j . (44)
The set of the particles that belong to the site (i, j) is denoted

M i j = {1 ≤ n ≤ NM | (I n , J n ) = (i, j) } , ( 45
)
whose cardinal is M i j . Mass conservation states that the total number of particles filling the grid is a constant, which gives the constraint

∑ i j M i j = NM, (46)
where ∑ i j means that we sum over the all the sites of the grid. A fluid particle labeled by n and carrying the height h n occupies an area δV /h n . The constraint that the area of each grid site is covered by fluid particles leads to the constraint ∀i, j 1

M ∑ n∈M i j 1 h n = 1, (47)
where M i j is the set defined in Eq. [START_REF] Vallis | Mechanisms and parameterizations of geostrophic adjustment and a variational approach to balanced flow[END_REF].

The ensemble of microstates of the discrete model is given by the set of all reachable values of grid positions, potential vorticities, divergences and heights of each fluid particle in accordance with the constraint of particle filling the area of each grid site:

X micro ≡ χ micro = {(I n , J n ) , q n , µ n , h n } 1≤n≤MN ∀i, j 1 ≤ i, j ≤ N x , N y 1 M ∑ n∈M i j 1 h n = 1 . (48)

Coarse-graining

Here we consider a microstate χ micro = {(I n , J n ) , q n , µ n , h n } 1≤n≤MN and an arbitrary function

g : n → g n = g (h n , q n , µ n ) . (49)
We introduce two different coarse-graining procedures: an areal coarse-graining, and a volumetric coarse-graining.

The areal coarse-graining of the function g is defined at each grid point (i, j) as

g i j ≡ 1 M ∑ n∈M i j 1 h n g n (50)
where M i j is a set defined in Eq. [START_REF] Vallis | Mechanisms and parameterizations of geostrophic adjustment and a variational approach to balanced flow[END_REF]. The terms 1/h n appearing in Eq. ( 50) means that we consider local average of g n weighted by the area occupied by each fluid particle. Note that we will only consider function g such that g i j converges to a finite value in the limit of large M i j ∼ M. This means that the terms g n should not be allowed to scale with M. This is the reason why we will consider first the large M limit, and then the limit of large cut-off µ max and h max for the fields µ and h.

The area filling constraint in Eq. ( 47) can then be written in terms of this areal coarse graining:

1 i j = 1. ( 51
)
for any i, j. We also notice that the areal coarse-grained height field is simply the ratio of the number of particles in the site (i, j) over the averaged number of particles per site:

h i j = M i j M . (52)
The volumetric coarse-graining of the function g is defined at each grid point (i, j) as

g i j ≡ 1 M i j ∑ n∈M i j g n . (53)
This field corresponds to the average of the function g carried by a fluid particle on site (i, j). The volumetric coarse-graining is related to the areal one through

g i j = hg i j h i j . (54)

Definition of a velocity field on the grid

Let us now define a large scale velocity field (or mean flow) on the uniform grid of the discrete model. We will introduce later a field accounting for small scale fluctuations of the velocity at each grid point.

In the case of the actual shallow water model, for a given triplet of continuous fields h, q, µ, the velocity field is computed by using Eq. ( 20), which involves two spatial differential operators, namely ∇ ⊥ ∆ -1 and ∇∆ -1/2 . Discrete approximations of these spatial operators are well defined on the uni- form grid of the discrete model. Discrete approximations of Eq. ( 20) can therefore be used to define a velocity field on the uniform grid. Let us consider a coarse-grained vorticity field ω = h qf and a coarse-grained divergent field µ = µ defined on the same uniform grid. Discrete approximations of the operators appearing in Eq. ( 20) can be written respectively as

∇ ⊥ ∆ -1 [ ω] i j = ∑ kl G ω i j,kl . ω kl and ∇ ⊥ ∆ -1 [ µ] i j = ∑ kl G µ i j,kl .
µ kl , where the sum ∑ kl is performed over each grid site (k, l). In the remainder of this paper, we do not need the explicit expression of the kernels {G ω } and {G µ } , which depend only on the domain geometry. Using these notations, we define the large scale velocity field as

u m f ,i j = ∇ ⊥ ∆ -1 h q -f i j + ∇∆ -1/2 [ µ ] i j , (55)
where the index "m f " stands for "mean flow". At this point one may wonder why the relevant coarse-grained fields used to define the large scale flow u m f should be h, µ , q (which, using Eq. ( 54) , is equivalent to either the triplet h, hµ, hq or to the triplet h -1 , µ , q ). Our motivation for such a choice is twofold. First, we will see a posteriori that this allows to recover previous results derived in several limit cases (weak flow limit, quasi-geostrophic limit), and to obtain consistent results in the general case. Second, in physical space, the number of fluid particles at each grid site is given by the areal-coarse-grained height field h, according to the previous section. The relevant macroscopic potential vorticity field or divergent field is then given by the volumetric coarse-graining q = hq/h and µ = hµ/h. In that respect, the phase space variable h does not play the same role as q and µ when considering macroscopic quantities in physical space, and this is why we do not consider the triplet h , µ , q to describe the system at a macroscopic level.

Definition of the microcanonical ensemble for the discrete model.

Here we introduce a set of constraints associated with the discrete model in order to define the microcanonical ensemble. These constraints are a discrete version of the Casimirs functional and the energy of the continuous shallow water model, defined in Eqs. ( 34) and [START_REF] Robert | On the statistical mechanics of 2d euler equation[END_REF], respectively. Additional assumptions on the form of the energy will be required, and we will discuss the relevance of such assumptions.

Note that we introduce here constraints for the discrete shallow water model, but we do not define what would be the dynamics of the discrete model. Indeed, it is not necessary to know the dynamics in order to compute the equilibrium state of the system. Only the knowledge of constraints provided by dynamical invariants is required.

Let us consider a given microstates χ micro = {(I n , J n ) , q n , µ n , h n } 1≤n≤MN , which belongs to the en- semble X micro of possible configurations of the discrete model defined in Eq. [START_REF] Venaille | Bottom-trapped currents as statistical equilibrium states above topographic anomalies[END_REF]. By construction of the ensemble X micro , each element χ micro satisfies the areal filling constraint given in Eq. (47).

The potential vorticity moments of the discrete model are defined as

∀k ≥ 0, Z k ≡ 1 NM NM ∑ n=1 q k n = 1 N ∑ i j hq k i j . (56)
The notation ∑ i j means that the sum is performed over each grid point, with 1 ≤ i ≤ N x , 1 ≤ j ≤ N y . It is shown in Appendix B that those discrete potential vorticity moments tend to the potential vorticity moments of the continuous dynamics defined in Eq. ( 34) in the limit of large number of fluid particles NM.

We also define the total energy of the discrete model as

E ≡ 1 NM NM ∑ n=1 1 2 u 2 m f ,I n J n + 1 2 µ n -µ I n J n 2 + g h n 2 + h bI n J n -E cst . ( 57
)
where h b,i j is the discrete topography 5 , where u m f ,i j is the mean flow defined in Eq. ( 55), and where E cst h bi j is an unimportant functional of h b chosen such that E = 0 at rest (i.e. when µ n = 0, u m f I n J n = 0, h n = 1h bI n J n for any n and M i j = M for any (i, j)):

E Cst = 1 N ∑ i j g 2 1 -h 2 bi j . (58)
A simple interpretation for this form of the total energy is that each fluid particle carries a kinetic energy associated with the mean flow u m f , as well as a kinetic energy associated with local fluctuations of the divergence field and finally a potential energy (the height of the center of mass of the fluid particle is

h bI n J n + h n /2).
It is argued in Appendix B that with only a few reasonable assumptions on the properties of the equilibrium state, the energy of the discrete model defined in Eq. ( 57) would also be the energy of the equilibrium state of the actual shallow water model defined in Eq. ( 32) in the limit of large number of fluid particles NM. Note also that according to Eq. ( 57), the vortical part of the velocity field does not contribute to local small scale kinetic energy, which is analogous to previous statistical mechanics results for non-divergent flow models such as two-dimensional Euler equations or quasi-geostrophic equations [START_REF] Miller | Statistical mechanics, Euler's equation, and Jupiter's Red Spot[END_REF][START_REF] Robert | Statistical equilibrium states for two-dimensional flows[END_REF]. Qualitatively, this is due to the fact that inverting the Laplacian operator smooth out local fluctuations of the relative vorticity ω = hq -1 so that the streamfunction associated with the microscopic vorticity field is the same as the streamfunction associated with the coarse-grained relative vorticity field, see Appendix B for more details.

The expression of the energy in Eq. ( 57) involves a sum over the NM fluid particles. This sum can be recast into a sum over the N points of the grid, by using the definition of the areal coarse-graining in Eq. ( 50) and the definition of volumetric coarse-graining in Eq. ( 53):

E = 1 N ∑ i j 1 2 h i j u 2 m f ,i j + 1 2 h i j µ 2 i j -µ 2 i j + g 2 h i j + h b,i j -1 2 + h 2 i j -h 2 i j . (59)
This Eulerian representation of the energy allows to identify three different contributions.

One first contribution to the total energy is given by the sum over each grid point (i, j) of the kinetic energy of the mean flow u m f (which is carried by M i j = Mh i j fluid particles), and of the potential energy of the areal coarse-grained height field h i j :

E m f ≡ 1 2N ∑ i j h i j u 2 m f ,i j + g h i j + h b,i j -1 2 . ( 60
)
This contribution will be referred to as the total mean flow energy, or the energy of the large scale flow.

A second contribution to the total energy is given by the sum over each grid points of the variance of the divergence levels µ carried by fluid particles at site (i, j) , times the number of fluid particles (M i j = Mh i j ):

E δ µ ≡ 1 2N ∑ i j h i j µ 2 i j -µ 2 i j . (61)
This term can be interpreted as a subgrid-scale (or small scale) kinetic energy term due entirely to the divergent part of the velocity field (see Appendix B).

The last contribution to the total energy is the sum over each grid point of the potential energy associated with local fluctuations of the height field:

E δ h ≡ g 2N ∑ i j h 2 i j -h 2 i j . (62)
This term can be interpreted as a subgrid-scale (or small scale) potential energy term.

One can finally check that total energy defined in Eq. ( 59) is the sum of the three contributions given in Eqs. ( 60), ( 61) and ( 62) :

E = E m f + E δ µ + E δ h . (63)
It is well known that for the 2D Euler model or the quasi-geostrophic model, there is no contribution to the energy from the sub-grid fluctuations of the potential vorticity in the limit of vanishing grid size (see [START_REF] Miller | Statistical mechanics of euler equations in two dimensions[END_REF][START_REF] Robert | Statistical equilibrium states for two-dimensional flows[END_REF]). For the shallow water model, this is also the case. However the sub-grid fluctuations of height and divergence do contribute to the energy (see Eqs. ( 61), ( 62) and ( 63)). A qualitative reason for this contribution of local height and divergence fluctuations to the total energy is that those two fields may be decomposed on the basis of inertia-gravity waves, which are known to develop a small scale energy transfer [START_REF] Warn | Statistical mechanical equilibria of the shallow water equations[END_REF], and consequently to a loss of energy at subgrid-scales in the discretized model. Now that we have defined the configurations space in Eq. ( 48), the potential vorticity moments {Z k [χ micro ]} k≥0 of the discrete model in Eq. ( 56) and the energy E [χ micro ] of the discrete model in Eq. ( 59), we introduce the microcanonical ensemble as the restriction of the configurations space X micro to configurations with fixed values of energy E and Casimirs {Z k } k≥0 :

χ micro = {(I n , J n ) , q n , µ n , h n } 1≤n≤MN ∈ X micro | E [χ micro ] = E, ∀k ∈ N Z k [χ micro ] = Z k . (64)
In our discrete model, we assume that the microcanonical measure over the ensemble of configurations X micro is :

dµ N,M E,{Z k } k≥0 (χ micro ) = δ (E [χ micro ] -E) Ω (E, {Z k } k≥0 ) ∞ ∏ k=0 δ (Z k [χmicro] -Z k ) ∏ i j δ (1 i j [χmicro] -1) × NM ∏ n=1 h 3 n dh n dq n dµ n dI n dJ n , (65)
where Ω (E, {Z k }) is the phase space volume defined as

Ω (E, {Z k } k≥0 ) = N x ∑ I 1 =1 • • • N x ∑ I n =1 N y ∑ J 1 =1 • • • N y ∑ J n =1 ˆ NM ∏ n=1 h 3 n dh n dq n dµ n δ (E [χ micro ]-E) ∞ ∏ k=0 δ (Z k [χ micro ]-Z k ) × ∏ i j δ (1 i j [χ micro ] -1). (66)
The terms dI n and dJ n are discrete measures with support on the grid coordinates:

dI n ( f ) = ∑ N x i=1 f i , dJ n ( f ) = ∑ N y j=1 f j .
The product ∏ i j is performed over the grid sites (i, j) with 1 ≤ i ≤ N x and 1 ≤ j ≤ N y . The constraint δ 1 i j [χ micro ] -1 corresponds to the area filling constraint defined in Eq. ( 51), which must be satisfied by each microstate χ micro ∈ X micro .

Note that Eq. ( 65) is a discrete version of the formal microcanonical measure given in Eq. ( 40) for the continuous case. The expectation of an observable A [χ micro ] in the microcanonical ensemble is

A N,M E,{Z k } k≥0 = dµ N,M E,{Z k } k≥0 (A ) = ˆdµ N,M E,{Z k } k≥0 (χ micro )A [χ micro ]. ( 67
)
The problem is now to compute the macrostate entropy, which accounts for the logarithm of the number of microstates corresponding to the same macrostate. Although we do not need to consider this problem in the present work, it would be very interesting to have continuous or discrete approximation of the shallow water equation that have the invariant measure (65), in an analogous way as what was achieved for the 2D Euler equations [START_REF] Dubinkina | Statistical relevance of vorticity conservation in the hamiltonian particle-mesh method[END_REF][START_REF] Frank | A hamiltonian particle-mesh method for the rotating shallow-water equations[END_REF].

Macrostates and their entropy

The aim of this subsection is to compute the equilibrium state of the discrete model introduced in the previous subsection. The first step is to define the macrostates of the system, the next step is to compute the most probable macrostates, using large deviation theory, which yields also a concentration property asymptotically for large N and M (almost all the microstates correspond to the most probable macrostate).

Definition of the empirical density field

Let us consider a microstate χ micro = {(I n , J n ) , q n , µ n , h n } 1≤n≤MN picked in the ensemble of configura- tions X micro defined in Eq. ( 48). The empirical density field of this microstate is defined for each grid point (i, j) as

p i j σ h , σ q , σ µ [χ micro ] ≡ δ (h -σ h ) δ (q -σ q ) δ µ -σ µ i j , (68)
where the overline operator is the areal coarse-graining defined in [START_REF] Venaille | Oceanic Rings and Jets as Statistical Equilibrium States[END_REF]. This field contains all the statistical information of the system at the grid level. The constraint that each grid site (i, j) is covered by particles is given by Eq. ( 51), which ensures the normalization:

ˆdσ h dσ q dσ µ p i j = 1. ( 69
)
Let us consider a function g(h n , q n , µ n ) depending on the height, potential vorticity and divergence carried by a fluid particle. Let us then consider the discrete microscopic field n → g n = g(h n , q n , µ n ) with 1 ≤ n ≤ NM. Following Eqs. ( 50) and (68), the corresponding coarse-grained field g i j is expressed solely in terms of the empirical density field p i j : g i j = ˆdσ h dσ q dσ µ g(σ h , σ q , σ µ )p i j σ h , σ q , σ µ .

(70)

If we consider for instance the function g(h, q, µ) = q , then g n = q n the microscopic potential vorticity field, and coarse-grained potential vorticity field q i j is obtained by a direct application of Eq. (70): q i j = ´dσ h dσ q dσ µ σ q p i j .

Importantly, the constraints {Z k [χ micro ] = Z k } k≥0 and E [χ micro ] = E defined in Eq. ( 56) and (59) depend only on the empirical density field p i j (since they depend only on local areal coarse-grained moments of the different fields). The empirical density is therefore a relevant variable to fully characterize the system at a macroscopic level.

Definition of the macrostates

The macrostates are defined as the set of microscopic configurations leading to a given value p i j = ρ i j of the empirical density field:

ρ ≡ χ micro ∈ X micro ∀i, j p i j [χ micro ] = ρ i j . ( 71
)
For the sake of simplicity, we make a small abuse of notation by denoting ρ both the macrostate defined in Eq. ( 71) and the field ρ = ρ i j . The values of the constraints are the same for all microstates within a given macrostate since they depend only on the local coarse-grained moments of the different fields, which remain unchanged for a prescribed empirical density field. The energy and the Casimirs, defined in Eqs. ( 57) and ( 56) respectively, have the same values for all the microstates within a single macrostate and will therefore be denoted by E [ρ] and {Z k [ρ]} k≥0 .

Macroscopic observables and empirical density

Let us now consider an observable A [χ micro ] on the configuration space X micro defined in Eq. ( 48) such that their dependance on the microscopic configuration χ micro occurs only through the empirical density field:

A [χ micro ] = A p i j [χ micro ] . (72)
This is actually the case for any observable written as a sum over the fluid particles, i.e. for any observable appearing in Eq. (67). It is therefore possible to change variables from χ micro to the empirical density field values ρ i j 1≤i, j≤N x, N y in Eq. (67):

A N,M E,{Z k } k≥0 = ˆ ∏ i j D [ρ i j ] A ρ i j Ω (ρ) Ω E, {Z k } k≥0 δ (E [ρ] -E) ∞ ∏ k=0 δ (Z k [ρ] -Z k ) × ∏ i j δ 1 i j [ρ i j ] -1 , (73)
where

Ω (ρ) = N x ∑ I 1 =1 • • • N x ∑ I n =1 N y ∑ J 1 =1 • • • N y ∑ J n =1 ˆ NM ∏ n=1 h 3 n dh n dq n dµ n ∏ i j δ (p i j [χ micro ] -ρ i j ) (74)
is the volume of a macrostate ρ defined in Eq. ( 71) in the configuration space X micro defined in Eq. ( 48), and where Ω E, {Z k } k≥0 is the total volume in phase space defined in Eq. ( 66). The constraint δ 1 i j [ρ i j ] -1 is a normalization constraint for the ρ i j , since 1 i j [ρ i j ] = ´dσ h dσ q dσ µ ρ i j . This nor- malization constraint also corresponds to the constraint that the fluid particles within a site must fit the available area, see Eq. ( 47). The term ´D [ρ i j ] means that the integral is performed over all the possible functions ρ i j . The term δ (p i j -ρ i j ) is a Dirac delta distribution on the functional space of the empirical density field values ρ i j (σ h , σ q , σ µ ), with p i j σ h , σ q , σ µ [χ micro ] the empirical density field defined in Eq. (68).

Asymptotic behavior of the macrostates volume and derivation of its entropy

Let us compute the asymptotic form of Ω (ρ) defined in Eq. (74), by considering the limit M → ∞, where M is the average number of particles per grid site (i, j). For a given set of macrostates ρ defined in Eq. ( 71), the number of fluid particles per grid site is

M i j = M ˆdσ h dσ q dσ µ σ h ρ i j . (75)
This is the only constraint on the particle positions in the grid for a microstate that belongs to the macrostates ρ. All the realizations of the particle positions that satisfies (75) count equally in the ensemble of macrostates ρ. Through combinatorial calculation, the number of realizations of {(I n , J n )} that satisfy (75) is (NM)!/ ∏ i j M i j !. Using Eq. ( 52) to express M i j in terms of h i j , we get

Ω (ρ) = (NM)! ∏ i j Mh i j ! ∏ i j Ω i j , (76)
where

Ω i j ≡ ˆ Mh i j ∏ m=1 h 3 m dh m dq m dµ m δ   1 M Mh i j ∑ m=1 1 h m δ (h m -σ h ) δ (q m -σ q ) δ µ m -σ µ -ρ i j   (77)
is the number of possible configurations for a given set of M i j = Mh i j fluid particles at site (i, j).

The asymptotic behavior of the pre-factor in Eq. ( 76) is computed through the Stirling formula:

log (NM)! ∏ i j Mh i j ! ∼ M→∞ MN - 1 N ∑ i j h i j log h i j + log (N) . (78)
The asymptotic behavior with M of Ω i j defined in Eq. ( 77) can be computed by using Sanov's theorem.

Before applying this theorem to our problem, let us consider the simpler case of K independent and identically distributed variables {χ k } 1≤k≤K with common probability density function F (χ). Those variable take values in a bounded interval of R. 6 Sanov's theorem describes the large deviation of the empirical density distribution

f K ≡ 1 K K ∑ k=1 δ (χ k -χ) , (79)
which can be considered as an actual probability distribution for the variable χ. The probability distribution functional of this empirical density function is

P [ f ] ≡ ˆK ∏ k=1 F (χ k ) dχ k δ ( f -f K ) . (80)
Sanov's theorem is a statement about the asymptotic behavior of the logarithm of P

[ f ]. For a given function f (χ), Sanov's theorem states log (P [ f ]) ∼ K→+∞ -K ˆdχ f (χ) log f (χ) F (χ) (81)
if ´dχ f (χ) = 1 and log (P [ f ]) ∼ -∞ otherwise. An heuristic discussion of Sanov's theorem is given in Ref [START_REF] Touchette | The large deviation approach to statistical mechanics[END_REF]. Combining Eqs. (79), ( 80) and (81) and generalizing this result to K independent and identically distributed L-tuple of variables χ l,k 1≤l≤L 1≤k≤K with common probability density function

F {χ l } 1≤l≤L , Sanov's theorem is written in compact form as log ˆK ∏ k=1 F χ l,k 1≤l≤L L ∏ l=1 dχ l,k δ f - 1 K K ∑ k=1 L ∏ l=1 δ χ l,k -χ l ∼ K→∞ -K ˆL ∏ l=1 dχ l f log f F (82) if ´∏L l=1 dχ l f {χ l } 1≤l≤L = 1.
Let us come back to the asymptotic behavior of Ω i j defined in Eq. (77), in the large M limit. Before applying Sanov's theorem, it is needed to recast this equation into a form similar to the argument of the logarithm in the lhs of Eq. (82). Because of the 1/h m term appearing in the delta Dirac function of Eq. (77), one needs to perform first a change of variable from ρ i j to

π i j ≡ σ h h i j ρ i j (83)
The formal Jacobian J arising from this change of variable in the functional delta Dirac function depend only on h i j which does not depend on M and will therefore not matter for the asymptotic behavior of log (Ω i j ). In addition, the factor h 3 m appearing in front of the Lebesgue measure in Eq. ( 77) must be divided by a normalization factor Z = ´h3 m dh m dq m dµ m so that P(h m , q m , µ m ) = h 3 m /Z can be interpreted as a probability distribution function. 7 Then Ω i j writes :

Ω i j = J Z Mh i j ˆMh i j ∏ m=1 h 3 m Z dh m dq m dµ m δ   π i j - 1
Mh i j Mh i j ∑ m=1 δ (h m -σ h ) δ (q m -σ q ) δ µ m -σ µ   .
(84) A direct application of Sanov's theorem to Eq. (84) then yields log

(Ω i j ) ∼ M→∞ Mh i j -ˆdσ h dσ q dσ µ π i j log π i j σ 3 h . ( 85
)
The normalization constraint on the distributions π i j is already fulfilled by the definition of the coarse- grained height fields h i j = h i j ´dσ h dσ q dσ µ π i j (see Eq. ( 70)). The inverse change of variable ρ i j = h i j π i j /σ h in Eq. (85) yields

log (Ω i j ) ∼ M→∞ M -ˆdσ h dσ q dσ µ σ h ρ i j log ρ i j σ 2 h + h i j log h i j . (86)
Combining Eq. ( 76) with Eqs. ( 78) and (86), we obtain the asymptotic behavior of Ω (ρ) with M:

log (Ω (ρ)) ∼ M→∞ MN S [ρ] , (87)
where

S [ρ] = - 1 N ∑ i j ˆdσ h dσ q dσ µ σ h ρ i j log ρ i j σ 2 h ( 88
)
is the macrostate entropy8 .

Continuous limit

Expressions of the macrostate entropy, energy and potential vorticity moments

Considering now the limit of an infinite number of grid site (N → ∞), the site coordinates (i, j) tend toward the continuous space coordinates x and the macrostate entropy S derived in Eq. (88) becomes

S [ρ] = -ˆdxdσ h dσ q dσ µ σ h ρ x, σ h , σ q , σ µ log ρ x, σ h , σ q , σ µ σ 2 h . (89)
The empirical density has become a probability density function (pdf). For any function g : n → g n = g (h n , q n , µ n ), its continuous coarse-grained field is now computed through

g (x) = ˆdσ h dσ q dσ µ ρ x, σ h , σ q , σ µ g σ h , σ q , σ µ , (90)
The discrete mean flow defined in Eq. ( 55) becomes (by construction):

u m f h, hq, hµ = ∇ ⊥ ∆ -1 hq -f + ∇∆ -1/2 hµ h , (91)
where all the coarse-grained fields have been expressed in terms of an areal coarse-graining, using Eq. ( 54). Similarly, the potential vorticity moments defined in Eq. ( 56) for the discrete model become

∀k ∈ N Z k [ρ] = ˆdx hq k . ( 92
)
The total energy defined in Eq. ( 59) for the discrete model becomes

E [ρ] = 1 2 ˆdx hu 2 m f + hµ 2 - hµ 2 h + g(h + h b -1) 2 . ( 93
)
We note that the total energy is a functional of h, h 2 , hq, hµ, hµ 2 . Just as in the discrete case, this energy can be separated into a mean flow contribution (a large scale contribution including kinetic and potential energy), as well as a contribution from small scale kinetic energy due to local fluctuations of the divergent velocity field and a contribution from small scale potential energy due to local height fluctuations. The large scale (or mean flow) energy defined in Eq. ( 60) for the discrete model becomes

E m f h, hq, hµ = 1 2 ˆdx hu 2 m f + g h + h b -1 2 . ( 94
)
The small scale (or subgrid-scale) kinetic energy due to local fluctuations of the divergent part of the velocity field defined in Eq. ( 61) becomes

E δ µ h, µ, µ 2 = 1 2 ˆdx hµ 2 - hµ 2 h , (95)
and the small scale (or sub-grid scale) potential energy due to local height fluctuations defined in Eq. ( 62) becomes

E δ h h, h 2 = g 2 ˆdx h 2 -h 2 . ( 96
)
One can check that the total energy in Eq. ( 93) is the sum of the three contributions given in Eq (94), (95) and ( 96):

E = E m f + E δ µ + E δ h . (97)

Microcanonical variational problem for the probability density field

Let us come back to the average of a macroscopic observable A defined in Eq. ( 73). Using the asymptotic estimate for Ω [ρ] given in Eq. (87), the average of an observable A defined in Eq. (73) becomes9

A dµ M,N q,h,µ = ˆD [ρ] A [ρ] e NM S [ρ] Ω (E, {Z k }) δ (E [ρ] -E) ∞ ∏ k=0 δ (Z k [ρ] -Z k ) ∏ x δ 1 [ρ] -1 . ( 98
)
It comes to a Laplace-type integral where NM → ∞. Thus, the value of A dµ M,N q,h,µ will be completely dominated by the contribution of the pdf ρ that maximizes the macrostate entropy defined in Eq. ( 89) while satisfying the normalization constraint

1 [ρ] = ˆdσ h dσ q dσ µ ρ x, σ h , σ q , σ µ = 1, (99)
and the microcanonical constraints

E [ρ] = E , {Z k [ρ] = Z k } k≥0
, where the energy is defined in Eq.

(93) and the potential vorticity moments are defined in Eq. ( 92). This variational problem can be written in compact form as:

max ρ S [ρ] E [ρ] = E, ∀k ∈ N Z k [ρ] = Z k , ∀x ∈ D 1(x) [ρ] = 1 . (100)
The probability measure ρ induced by the empirical density field has a concentration property. In other words, the average of an observable depending only on macrostates is dominated by the most probable macrostates, which are solutions of the variational problem (100). An interesting limit case for the entropy in Eq. ( 89) is worth mentioning in order to relate the variational problem in Eq. ( 100) with previous studies on the shallow water system. Let us assume that there is neither height variation nor divergent fluctuations, which would be the case if considering a quasi-geostrophic model or 2d incompressible Euler equations. Then the only height level and the only divergence level are σ h = 1, σ µ = 0, respectively. Defining ρ q (x, σ q ) = ρ (x, 1, σ q , 0), Eq. ( 89) becomes up to an unimportant constant: S [ρ q (x, σ q )] = -ˆdxdσ q ρ q log ρ q .

(101)

We recover in that case the macrostate entropy of the Miller-Robert-Sommeria theory [START_REF] Miller | Statistical mechanics of euler equations in two dimensions[END_REF][START_REF] Robert | Relaxation towards a statistical equilibrium state in two-dimensional perfect fluid dynamics[END_REF].

Let us now assume that the height varies with position but that there is no local height fluctuations. Then at point x the only height level is σ h = h(x) = h(x). Defining ρ qµ x, σ q , σ µ = ρ x, h(x), σ q , σ µ , the macrostate entropy in Eq. ( 89) becomes up to an unimportant constant:

S ρ qµ x, σ q , σ µ , h (x) = -ˆdxdσ q dσ µ hρ qµ log ρ qµ . (102)
This form of the entropy was proposed by [START_REF] Chavanis | Statistical mechanics of the shallow water system[END_REF], without microscopic justification. Interestingly, [START_REF] Chavanis | Statistical mechanics of the shallow water system[END_REF] obtained Eq. ( 102) by assuming that the macrostate entropy can be written as

S = ˆdxdσ q dσ µ h(x)s ρ qµ x, σ q , σ µ , (103)
and by noting that s(ρ) = -ρ log ρ is the only function that leads to equilibrium states that are stationary.

4 General properties of the equilibria and simplification of the theory in limiting cases.

General properties of equilibrium states, solutions of the variational problem in Eq. ( 100), are discussed in this section. Critical points of the variational problem are given in the first subsection ; they are computed in appendix C. This allows to obtain an equation for the large scale flow, and to show that equilibrium states of the shallow water model are positive temperature states. A weak height fluctuation limit is considered in a second subsection. It is found that the large scale flow and the small scale fluctuations are decoupled in this limit, and that there is equipartition between small scale potential energy and small scale kinetic energy. The quasi-geostrophic limit is investigated in a third subsection.

4.1 Equilibrium states are stationary states with positive temperatures

Properties of the critical points

Critical points of the equilibrium variational problem defined in Eq. ( 100) are solutions of the equation

∀δ ρ, δ S [ρ] -β δ E [ρ] - +∞ ∑ k=0 α k δ Z k [ρ] -ˆdx ξ (x) ˆdσ h dσ q dσ µ δ ρ = 0 ( 104
)
where β , {α k } k≥0 and ξ (x) are the Lagrange multipliers associated with the conservation of the energy, the potential vorticity moments, and with the normalization constraint, respectively. The computation of the critical points is performed in Appendix C.

A first key result of Appendix C is that solutions of Eq. ( 104) factorize as

ρ = ρ h (x, σ h ) ρ q (x, σ q ) ρ µ x, σ µ . (105)
A second result of Appendix C is that the pdf of the divergence field is a Gaussian

ρ µ x, σ µ = β 2π exp - β 2 σ µ -µ 2 . ( 106
)
Recalling that β = ∂ S/∂ E is the inverse temperature, we see that the variance of the pdf of the divergence field is given by the temperature of the flow:

µ 2 -µ 2 = β -1 . (107)
This equation has important physical consequences. First, fluctuations of the divergent field do not vary with space. Second, the temperature of the equilibrium state is necessary positive. This contrasts with equilibrium states of two-dimensional Euler flow, which can be characterized by negative temperature states [START_REF] Robert | Statistical equilibrium states for two-dimensional flows[END_REF][START_REF] Miller | Statistical mechanics, Euler's equation, and Jupiter's Red Spot[END_REF]. This was realized first by Onsager for the point vortex model [START_REF] Onsager | Statistical hydrodynamics[END_REF]. In the context of 2D Euler equations in doubly periodic domains, the equilibrium states are always characterized by negative temperature, just as in the case discussed by Onsager (this result is shown in [START_REF] Bouchet | Statistical mechanics for geophysical flows[END_REF]). However, the existence of large scale flow structures characterized by positive temperatures are possible at low energy in the presence of lateral boundaries and non-zero circulation, and/or in the presence of bottom topography in the framework of QG model. Such positive temperature states are known and documented in the literature (see e.g. the original papers by [START_REF] Miller | Statistical mechanics, Euler's equation, and Jupiter's Red Spot[END_REF], [START_REF] Robert | Relaxation towards a statistical equilibrium state in two-dimensional perfect fluid dynamics[END_REF] and [START_REF] Majda | The emergence of large-scale coherent structure under small-scale random bombardments[END_REF] or [START_REF] Bouchet | Statistical mechanics of two-dimensional and geophysical flows[END_REF] and references therein).

In addition, it follows from Eqs. (95), ( 105) and (107) that the temperature is directly related to small scale kinetic energy due to the divergent velocity field:

E δ µ = 1 2β . (108)
A third result of Appendix C is the expression of the pdf of the height field:

ρ h (x, σ h ) = 1 G h (x) σ 2 h exp -β g 2 σ h - ξ h (x) σ h , G h (x) = ˆdσ h σ 2 h exp -β g 2 σ h - ξ h (x) σ h , (109)
where ξ h (x) a function related to h (x) through h = ´dσ h σ h ρ h .

A fourth result of Appendix C is the expression of the pdf of the potential vorticity field:

ρ q (x, σ q ) = 1 G q βΨ m f exp βΨ m f σ q - +∞ ∑ k=1 α k σ k q , G q βΨ m f = ˆdσ q exp βΨ m f σ q - +∞ ∑ k=1 α k σ k q , ( 110
)
where Ψ m f h, q, µ is the mass transport streamfunction of the mean flow defined through an Helmholtz decomposition of hu m f :

hu m f = ∇ ⊥ Ψ m f + ∇Φ m f . (111)
According to Eq. ( 110), the coarse-grained potential vorticity field is a function of the mass transport streamfunction:

q = G ′ q (βΨ m f ) G q (βΨ m f ) . (112)
A fifth result of Appendix C is that the mass transport potential of the mean flow defined in Eq. (111) vanishes:

Φ m f = 0, ( 113
)
and the velocity field can now be written

u m f = 1 h ∇ ⊥ Ψ m f . (114)
A sixth result of Appendix C concerns the Bernoulli function of the mean flow defined as

B m f = 1 2 u 2 m f + g h + h b -1 . (115)
According to Eq. ( 218), combining Eq. ( 216) and Eq. ( 217) of Appendix C allows to express B m f in terms of β , G q , G h and a constant A 0 that can be computed in principle using the conservation of the total mass Z 0 = 1:

B m f = β -1 log (G q G h ) + gh + A 0 . (116)

Equation for the large scale flow

Let us now establish the equations allowing to compute the large scale flow. A first equation is obtained by injecting the expression for the mean flow u m f given in Eq. ( 114) into the expression of the Bernoulli function defined in Eq. ( 115), and by combining Eq. (115) with Eq. (116):

1 2 1 h 2 ∇Ψ m f 2 + gh b = 1 β log (G q G h ) + A 1 , (117)
with A 1 = A 0 + g. A second equation is obtained by taking first the curl of Eq. ( 91), which yields hqf = ∇ ⊥ u m f . Then, replacing u m f by its expression given in Eq. ( 114), remembering that the potential vorticity field and the height field of the critical points of the variational problem are decorrelated (qh = hq), and replacing q by its expression given in Eq. (112) yields

h G ′ q βΨ m f G q βΨ m f -f = ∇ ∇Ψ m f h . ( 118
)
The closed system of partial differential equations ( 117) and (118) must be solved for h and Ψ m f for a given value of β , G q , G h , and A 1 . The set of parameters β , {α k } k≥1 , A 1 must in fine be expressed in terms of the constraints of the problem given by the energy E, and the potential vorticity moments {Z k } k≥0 . This may require a numerical resolution in the general case.

We have seen in subsection 2.2 that a flow described by (h, u) (or equivalently by (h, q, µ), or by (h, Φ,Ψ )) is a stationary state of the shallow water model if and only if J(q,Ψ ) = 0 and Φ = 0.

According to Eqs. ( 112) and (113), the large scale flow h, u m f is a stationary state of the shallow water model.

Comparison with previous results

The set of equations ( 117) and (118) describing the large scale flow is similar to the one obtained by Weichman and Petrich [START_REF] Weichman | Statistical Equilibrium Solutions of the Shallow Water Equations[END_REF] (through a Kac-Hubbard-Stratonovich transformation) and by Chavanis and Sommeria [START_REF] Chavanis | Statistical mechanics of the shallow water system[END_REF] (through a phenomenological generalization of the Miller-Robert-Sommeria theory), excepted that the rhs of Eq. ( 117) contains an additional term 1 β log (G h ) + A 1 which does not appear in these previous works. The reason for the presence of this additional term is that we have taken into account the presence of small scale fluctuations of height and velocity, which were neglected in Refs. [START_REF] Weichman | Statistical Equilibrium Solutions of the Shallow Water Equations[END_REF][START_REF] Chavanis | Statistical mechanics of the shallow water system[END_REF]. We will see in subsection 4.3 that this additional term becomes negligible with respect to the others in the quasi-geostrophic limit, in which case we recover exactly the set of equations for the large scale flow obtained in Refs. [START_REF] Weichman | Statistical Equilibrium Solutions of the Shallow Water Equations[END_REF][START_REF] Chavanis | Statistical mechanics of the shallow water system[END_REF].

In addition, we have shown in subsection 4.1.1 that only positive temperature states are allowed, which shows that only one subclass of the states described by Eqs. ( 117) and ( 118) are actual equilibrium states.

Equipartition and decoupling in the limit of weak local height fluctuations

We consider in this subsection the limit of weak local height fluctuations. This step makes possible computation of explicit solutions of the variational problem (100). Meanwhile, it allows to explore the consequence of the presence of these small scale fluctuations on the structure of the large scale flow. By "limit of weak local height fluctuations", we mean

∀x ∈ D, h 2 -h 2 1/2 ≪ h. (119)
As already argued in [START_REF] Weichman | Statistical Equilibrium Solutions of the Shallow Water Equations[END_REF], this limit of weak local fluctuations is physically relevant, since the presence of shocks in the actual dynamics tends to dissipate small scale fluctuations of height or kinetic energy. This will be further discussed in subsection 5.2.

The height distribution

Assuming in addition that height levels σ h such that σ h -h ≫ h 2h 2 1/2 do not contribute significantly to the pdf ρ h defined in Eq. (109), we perform an asymptotic development with σ h /h -1 ≪ 1, and obtain at lowest order in this small parameter a Gaussian shape for the pdf:

ρ h (x, σ h ) = gβ 2πh (x) exp - gβ 2h (x) σ h -h (x) 2 . (120)
Similarly, the term G h defined in Eq. ( 109) can be computed explicitly in this limit. One gets at lowest order

G h = h 2 (x) 2πh (x) gβ exp -gβ h (x) . (121)
Using Eq. ( 120), the weak local height fluctuation limit given in Eq. ( 119) can be interpreted as a low temperature limit gh ≫ 1/β . Injecting Eq. ( 121) in the previously established relation in Eq. ( 116) yields

B m f = 1 β log G q + 5 2β log h + A 2 , ( 122
)
where A 2 is a free parameter determined by the conservation of the total volume. In the rhs of Eq. (122), there remains an additional term 5 2β log h which is not present in the large scale flow equation obtained by [START_REF] Weichman | Statistical Equilibrium Solutions of the Shallow Water Equations[END_REF][START_REF] Chavanis | Statistical mechanics of the shallow water system[END_REF], but considering the weak flow limit allowed to obtain an explicit expression for this additional term. We will see in subsection 4.3 that this term becomes negligible with respect to 1 β log G q in the quasi-geostrophic limit. 4.2.2 Equipartition and the limit of weak small scale energy Injecting Eq. (120) in the expression of the small scale potential energy defined in Eq. ( 96) yields

E δ h = 1 2β . ( 123
)
Comparing this result with Eq. ( 108) shows equipartition of the small scale energy between the potential energy and the kinetic energy. The total energy due to small scale fluctuations is

E f luct ≡ E δ h + E δ µ = 1 β . ( 124
)
This equipartition result of the small scale energy was already obtained by Warn when computing equilibrium states of the Galerking truncated dynamics in a weak flow limit [START_REF] Warn | Statistical mechanical equilibria of the shallow water equations[END_REF]. More precisely, Warn decomposed the dynamics into vortical modes and inertia-gravity modes (which are defined as the eigenmodes of the linearized dynamics), and concluded that the energy of the equilibrium state should be equipartitioned among inertia-gravity modes in the limit of infinite wavenumber cut-off. This equipartition of energy among inertia-gravity modes would lead to equipartition between potential and kinetic energy at small scales, just as in our case. Here we have recovered this result with a different approach and we have generalized it beyond the weak flow limit.

Finally, we remark that the equipartition result of Eq. ( 124) shows that the low temperature limit gh ≫ 1/β corresponds to a limit of weak small scale energy due to local fluctuation of the height field and of the divergent field:

gh ≫ E f luct .

(125)

Decoupling between the large scale flow and the fluctuations

Still by considering the weak local height fluctuation limit, let us assume that E f luct defined in Eq. ( 124) is given, which means that the temperature is given. According to Eq. (118) and Eq. (117), knowing the coarse-grained height field h and the pdf of potential vorticity levels ρ q (x, σ q ) (which allows to compute G q ) is sufficient to determine the mass transport streamfunction Ψ m f , and hence the velocity u m f by using Eq. (114). Then the mean-flow energy defined in Eq. (94) does not depend on ρ µ :

E m f h, ρ q = 1 2 ˆdx hu 2 m f h, q + g h + h b -1 2 . ( 126
)
The total energy defined in Eq. ( 97) is therefore the sum of the mean-field energy associated with a large scale flow that depends only on h and ρ q , and of the energy of small scale fluctuations associated with height and divergence fluctuations:

E = E m f h, ρ q + E f luct . (127)
In addition, injecting Eq. (105) in Eq. (92) gives the expression of the potential vorticity moments as a functional of h and ρ q only: ∀k ∈ N Z k h, ρ q = ˆdxdσ q hρ q σ k q .

(128)

Let us now consider the macrostate entropy functional defined in Eq. (89). Injecting Eqs. ( 106) and (120) in Eq. ( 105), and performing the asymptotic expansion of the integrand of the mean-field entropy with σ h /h -1 ≪ 1 leads at lowest order to (up to a irrelevant constant)

S = S m f h, ρ q + S f luct E f luc , (129)
S m f h, ρ q ≡ -ˆdxdσ q hρ q log ρ q h 5/2 , (130)

S f luct E f luct ≡ log E f luct . (131)
Since ρ q and h are two fields allowing to compute the large scale flow of energy E m f , and since the fluctuations of the potential vorticity field do not contribute to the small scale energy E f luct , the entropy S m f h, ρ q will be referred to as the macrostate entropy of the large scale flow.

The second contribution to the total entropy in Eq. ( 129) depends only on the energy of the small scale fluctuations E f luct . Since this energy is solely due to the local variance of the height field and of the divergent field, it will be referred to as the entropy of the small scale fluctuations. Note that in that case the height field is involved both in the large scale flow through its local mean value, and in the small scale fluctuations through its local variance.

The decoupling of the energy and the macrostate entropy functional into a part that depends only on ρ q , h and another part that depends only on small scale height and divergent fluctuations with energy E f luct has both a useful practical consequence and an interesting physical interpretation. The variational problem in Eq. ( 100) can now be recast into two simpler variational problems:

S E, {Z k } k≥0 = max E f luct S m f E -E f luct , {Z k } k≥0 + S f luct E f luct , (132)
S m f E m f , {Z k } k≥0 = max ρ q , ´ρq =1,h S m f h, ρ q E m f h, ρ q , = E m f , ∀k ∈ N Z k ρ q , h = Z k , (133)
where S m f , E m f and Z k are the functional defined in Eqs. (130), (126), and (128), respectively. The variational problem in Eq. (132) describes two subsystems in thermal contact. In order to compute the equilibrium state, one can then compute independently the equilibrium state of each subsystem, and then equating their temperature in order to find the global equilibrium state. This classical argument follows directly from the maximization of (132). If the two subsystems can not have the same temperature (for instance when the temperature of both subsystem have a different sign), all the energy is stored in the subsystem with positive temperature in order to maximize the global entropy.

In the present case, a first subsystem is given by the large scale flow of energy E m f , which involves the field h and the potential vorticity field described by the pdf of vorticity levels ρ q . The equilibrium state of this subsystem is obtained by solving the variational problem in Eq. ( 133). This variational problem corresponds to the one introduced by [START_REF] Chavanis | Statistical mechanics of the shallow water system[END_REF] except that large scale flow energy is not the total energy but only the available energy when the energy of the fluctuations has been removed. The entropy of the large scale flow (130) in the variational problem (133) is closely related to the entropy introduced in [START_REF] Chavanis | Statistical mechanics of the shallow water system[END_REF] (up to a functional of h). The potential vorticity moment constraints apply only to this subsystem. These additional constraints are essential since they allow for the possible existence of a large scale flow, see e.g. [START_REF] Bouchet | Statistical mechanics of two-dimensional and geophysical flows[END_REF].

The second subsystem is given by the local small scale height fluctuations and the local small scale divergent fluctuations with total energy E f luct , and with the entropy given in Eq. (131). The inverse temperature of this subsystem β = dS f luct /dE f luct , which, using Eq. ( 131), yields a temperature of

β -1 = E f luct .
In practice, it is easier to compute directly equilibrium states of the large scale flow subsystem in the canonical ensemble, where the energy constraint is relaxed. In that case the equilibrium states of this subsystem depend on the temperature E f luct and on the dynamical invariants {Z k } k≥0 . One just need to check a posteriori that this ensemble is equivalent to the microcanonical one by verifying that each admissible energy E m f is reached when varying E f luct form 0 to +∞ , for a given set of potential vorticity moments {Z k } k≥0 . In order to find the actual equilibrium state associated with the total energy E, one then needs to solve the equation

E = E m f E f luct , {Z k } k≥0 + E f luct . (134)
To conclude, it is now possible to study independently the large scale flow subsystem, to consider if necessary any approximation on this flow, such as the quasi-geostrophic limit or the Euler 2D limit, and finally to couple this subsystem with the small scale height and divergence fluctuations subsystem in order to select the actual equilibrium state. If one linearize the large scale flow entropy entropy (130) and the large scale flow energy (126), this picture of two subsystems in thermal contact gives a justification to the variational problem introduced by [START_REF] Vallis | Mechanisms and parameterizations of geostrophic adjustment and a variational approach to balanced flow[END_REF] and extended by [START_REF] Nageswaran | Minmax variational principle for steady balanced solutions of the rotating shallow water equations[END_REF]. [START_REF] Vallis | Mechanisms and parameterizations of geostrophic adjustment and a variational approach to balanced flow[END_REF][START_REF] Nageswaran | Minmax variational principle for steady balanced solutions of the rotating shallow water equations[END_REF] suggest that for a given frozen in space potential vorticity, the dynamics should relax through geostrophic adjustment to a state minimizing the total energy. This result is recovered from the coupled variational problem (132).

Either a non-zero circulation or a non-zero bottom topography is required to sustain a large scale flow at equilibrium

It is shown in appendix D that when circulation is zero (i.e. when Z 1 = f ) and when topography is zero (h b = 0), a state with a large scale flow at rest (u m f = 0) is a maximizer of the large scale flow macrostate entropy among all the possible energies:

S(0, {Z k } k≥0 ) = max E m f S m f E m f , {Z k } k≥0 when Z 1 = f and h b = 0. (135)
According to Eq. ( 131), the fluctuation entropy S f luct increases with the fluctuation energy E f luct . The total macroscopic entropy S m f E -E f luct , {Z k } k≥0 + S f luct E f luct is therefore maximal when all the energy is transferred into fluctuations (E f luct = E). This generalizes to a wider range of flow parameters and to a wider set of flow geometries a result previously obtained by Warn in a weak flow limit for a doubly periodic domain without bottom topography [START_REF] Warn | Statistical mechanical equilibria of the shallow water equations[END_REF]. In addition, we will see in the next section that when there is a non-zero bottom topography and rotation, a large scale flow can be sustained at equilibrium.

The quasi-geostrophic limit

We show in this subsection that the variational problem of the Miller Robert Sommeria theory is recovered from Eq. (133) for the large scale flow subsystem when considering the quasi-geostrophic limit, which applies to strongly rotating and strongly stratified flows.

Geostrophic balance

Let E 1/2 m f be the typical velocity of the large-scale flow and let L = |D| be the typical horizontal scale of the domain where the flow takes place. We introduce the Rossby number and the Rossby radius of deformation respectively defined as

Ro ≡ E 1/2 m f f L , R ≡ √ gH f . ( 136
)
Here f is the Coriolis parameter, H = 1 is the mean depth and g the gravity, see subsection 2.1. If f = 0 we can always rescale time unit so that f = 1, and we make this choice in the following. It is also assumed that the aspect ratio of the domain where the flow takes place is of order one, so that L = 1 since we chose length unit so that |D| = 1. The quasi-geostrophic limit corresponds to small Rossby number, and to a Rossby radius of deformation that is not significantly larger than the domain length scale:

Ro ≪ 1, R -1 = O (1) . ( 137
)
By construction, the mean flow is of the order of the Rossby number: |u m f | ∼ Ro. The coarse-grained interface height is given by

η = h -1 + h b . (138)
Let us assume that the spatial variations in fluid depth are small compared to the total depth H = 1, with the scaling η ∼ R -2 Ro. At lowest order in Ro, the mean flow Bernoulli potential defined in Eq. ( 115) becomes B m f = R 2 η. Remembering that we consider in addition to the quasi-geostrophic limit a weak fluctuation limit given by Eq. ( 125), which can be expressed as R 2 ≫ β -1 , Eq. (122) yields at lowest order

B m f = R 2 η = β -1 log G q + cst. (139)
This equation implies dB m f /dΨ m f = q, consistently with what we expected for a stationary flow in the absence of small scale fluctuations, see subsection 2.2. Taking the curl of Eq. ( 139) and collecting the lowest order terms yields geostrophic balance10

R 2 ∇ ⊥ η = u m f . (140)
Eq. ( 140) also shows that the scaling hypothesis for η is self-consistent.

It is remarkable that equilibrium statistical mechanics predicts the emergence of geostrophic balance. We stress that those results, which have been obtained through the introduction of a semi-Lagrangian discrete model, are valid whatever the amplitude of bottom topography variations (i.e. beyond the usual approximation h b ∼ Ro required to derive the quasi-geostrophic dynamics). By contrast, in the framework of a Eulerian discrete model, one would find that the large scale flow is not at geostrophic equilibrium unless h b ∼ Ro or h b ≪ Ro, see Appendix E.

Quasi-geostrophic dynamics

The geostrophic balance is not a dynamical equation. When h b ∼ Ro, the dynamics if given by the quasi-geostrophic equations. At lowest order in Ro, we get hu m f = u m f , and

ψ m f = Ψ m f , φ m f = Φ m f = 0. ( 141
)
where Ψ m f and ψ m f are the transport streamfunction and the streamfunction obtained through the Helmholtz decomposition of hu m f and u m f , respectively. In that case, the relative vorticity is

ω = ∆ ψ m f . (142)
The geostrophic balance (140) is equivalent to η = R -2 ψ m f + C. The value of ψ m f at the domain boundary can always be chosen such that the constant term vanishes, which yields

η = ψ m f R 2 . ( 143
)
Mass conservation given in Eq. ( 2) leads then to the following constraint on the streamfunction:

ˆdx ψ m f = 0. ( 144
)
Given a potential vorticity level σ q , a change of variable can be performed by introducing quasi- geostrophic potential vorticity levels 11σ g ≡ (σ q -1) .

(145)

The pdf of quasi-geostrophic levels is

ρ g (x, σ g ) = ρ q (x, 1 + σ g ) . (146)
The local quasi-geostrophic potential vorticity moments are defined as

∀k ∈ N, q k g ≡ ˆdσ g σ k g ρ g . (147)
At lowest order in Ro, the coarse-grained quasi-geostrophic potential vorticity obtained by considering k = 1 in Eq. ( 147) becomes

q g = ω -η + h b . (148)
which, using Eqs. ( 142) and ( 143), yields

q g = ∆ ψ m f - ψ m f R 2 + h b . (149)
In the quasi-geostrophic limit, the large scale flow is fully described by the streamfunction ψ m f , which can be obtained by inverting the coarse-grained potential vorticity field defined in Eq. (149).

Quasi-geostrophic constraints and variational problem

At lowest order in Ro, and after an integration by part, the expression of the mean-flow energy in Eq. ( 126) is equal to the quasi-geostrophic energy:

E m f ,g q g ≡ 1 2 ˆdx ∇ψ m f 2 + ψ 2 m f R 2 , (150)
where ψ m f can be expressed in terms of q g through Eq. (149). Similarly, the conservation of the potential vorticity moments defined in Eq. ( 128) implies the conservation of quasi-geostrophic potential vorticity moments

∀k ∈ N, Z g,k ≡ ˆdx q k g , (151)
and the macrostate entropy of the large scale flow defined in Eq. ( 130) writes now

S m f ,g [ρ g ] = -ˆdxdσ q ρ g log ρ g . (152)
Using Eq. ( 150), ( 151) and (152), the variational problem in Eq. ( 133) is now recast into a simpler variational problem on the pdf ρ g :

S m f ,g E m f , {Z k } k≥1 = max ρ g , ´ρg =1 S m f ,g [ρ g ] E m f ,g [ρ g ] = E m f , ∀k ∈ N Z g,k [ρ g ] = Z k . (153)
The entropy S m f ,g , the energy E m f ,g and the potential vorticity moments Z g,k k≥1 are defined in Eqs. ( 152), ( 150) and (151). The variational problem defined in Eq. ( 153) is the variational problem of the Miller-Robert-Sommeria statistical mechanics [START_REF] Miller | Statistical mechanics of euler equations in two dimensions[END_REF][START_REF] Robert | Statistical equilibrium states for two-dimensional flows[END_REF].

4.3.4

Maximum energy states and consistency of the quasi-geostrophic approximation.

We have shown that in the weak height fluctuation limit and the quasi-geostrophic limit, computation of the large scale flow associated with the equilibrium state amounts to the computation of the solution of the variational problem in Eq. ( 153), with the restriction that the temperature is positive (due to the coupling with small scale fluctuations of height and divergence, as discussed in subsection 4.1.1).

Here we discuss the solutions of this variational problem, which are energy maxima for a given set of potential vorticity moments Z g,k k≥1 . Although the initial weak fluctuation or quasi-geostrophic limit may not be fulfilled for such states, they can always be computed, and it provides an upper bound for the energy of the large scale flow obtained in those limits.

It is known that for positive temperatures (β -1 = E f luct > 0), the equilibrium entropy defined in Eq. ( 153) is concave [START_REF] Bouchet | Statistical mechanics of two-dimensional and geophysical flows[END_REF], and the energy increases when β decreases. This means that the state with a maximum energy is reached when β → 0, see e.g. [START_REF] Robert | Statistical equilibrium states for two-dimensional flows[END_REF].

Injecting β = 0 in the expression of ρ q in Eq. ( 110) leads to a uniform mean potential vorticity field. According to Eq. ( 146) and ( 147), this implies that the quasi-geostrophic potential vorticity field is also uniform: q g = Z g,1 where Z g,1 = ´dx q g is the circulation. Since q g is a constant, this state is referred to as the "mixed" state. We get

∆ ψ mix - ψ mix R 2 = Z g,1 -h b . (154)
Let us call E mix the energy of the mixed state:

E mix ≡ max ρ g , ´ρg =1 E m f |∀k ∈ N Z g,k = Z g,k . (155)
Using Eq. ( 150), it can formally be written

E mix = - 1 2 ˆ(Z g,1 -h b ) ∆ - 1 R 2 -1 (Z g,1 -h b ) . ( 156
)
For a given domain geometry, a given circulation Z g,1 and a given bottom topography field h b , a non trivial large scale flow can be observed whenever E mix > 0. We see from Eq. ( 156) and (155) that the condition for a large scale flow to exist is that either the circulation Z g,1 is non zero or the bottom topography h b is non-zero. If both Z g,1 = 0 and h b = 0, then the energy of the large scale flow vanishes (E m f = 0), and all the energy is lost in small scale fluctuations (E = E f luct ), consistently with the results of subsection 4.2.4. In this case, coupling thermally a large scale flow with fluctuations leads to a state with all the energy lost in fluctuations. Note that in the case Z g,1 = 0 R ∼ 1, E mix can also be interpreted as a norm of the topography field h b .

Since E m f ≤ E mix, and since E mix depends only on the problem parameters (namely the circulation, the Rossby radius and the bottom topography), a sufficient condition to have Ro ≪ 1 is

E 1/2 mix ≪ 1. ( 157
)
If this condition is fulfilled, the quasi-geostrophic assumption is self-consistent (as well as for the scaling h b ∼ Ro in the case Z g,1 = 0).

Explicit computation of phase diagrams and discussion

The aim of this section is to apply the results of the previous section to the actual computation of equilibria and their energy partition. In order to solve analytically the variational problem of the statistical mechanics theory, we focus on a subclass of equilibria referred to as the energy-enstrophy equilibrium states. This allows to build phase diagrams in a two parameter space, and to discuss the energy partition between a large scale flow and small scale fluctuations when these parameters are varied. We finally discuss the role of shocks that occur in the actual shallow water dynamics, and present a geophysical application to the Zapiola anticyclone.

5.1 Energy-enstrophy equilibria for the quasi-geostrophic model.

We consider the variational problem

S g,m f (E, Z 2 ) = max ρ g , ´ρg =1 S m f ,g [ρ g ] E m f ,g [ρ g ] = E m f , Z g2 [ρ g ] = Z 2 , Z g1 [ρ g ] = 0 , ( 158
)
where the functionals S m f ,g , E m f ,g , Z g1,2 are defined in Eqs. ( 152), (150), and (151), respectively. The peculiarity of this variational problem is that only two potential vorticity moments (the circulation and the enstrophy) have been retained as a constraint, in addition to the energy. Such energyenstrophy equilibria are a subclass of statistical equilibria solutions of the more general variational problem given in Eq. ( 153), see e.g. [START_REF] Bouchet | Simpler variational problems for statistical equilibria of the 2d euler equation and other systems with long range interactions[END_REF][START_REF] Naso | Statistical mechanics of two-dimensional Euler flows and minimum enstrophy states[END_REF]. For a given global distribution of potential vorticity, several limit cases on the energy allow to simplify the computation of the solutions of the variational problem in Eq. ( 153) into the computation of the simpler variational problem in Eq. ( 158). For instance, assuming that bottom topography is non zero, and that the global potential distribution is such that the mixed state q = cst exists, the solutions of (158) are the solutions of the more general variational problem Eq. ( 153) when E → E mix .

The set of all potential vorticity fields q corresponding to solutions of the variational problem in Eq. ( 158) have been previously described by [START_REF] Chavanis | Classification of self-organized vortices in two-dimensional turbulence: the case of a bounded domain[END_REF][START_REF] Venaille | Statistical ensemble inequivalence and bicritical points for two-dimensional flows and geophysical flows[END_REF][START_REF] Venaille | Solvable phase diagrams and ensemble inequivalence for two-dimensional and geophysical turbulent flows[END_REF][START_REF] Naso | Statistical mechanics of two-dimensional Euler flows and minimum enstrophy states[END_REF] in the case of a bounded geometry, and phase diagrams were obtained with energy E and circulation Z 1 as external parameters. The role of enstrophy Z 2 was not discussed. The main reason is that for a given large scale flow characterized by E 1 and Z 1 , changing Z 2 would only imply changes in the small scale fluctuations of potential vorticity levels, see e.g. [START_REF] Naso | Statistical mechanics of two-dimensional Euler flows and minimum enstrophy states[END_REF], and such small scale fluctuations do not contribute to the total energy. In the present case, Z 2 will play an important role in determining the energy partition between the large scale (vortical) flow and small scale fluctuations due to the height and divergent velocity field. For the sake of simplicity we consider vanishing circulations Z 1 = 0.

The problem (158) is solved in Appendix F for positive temperature states, and we present here the main results. A typical phase diagram is shown on Fig. 2. This figure is obtained by assuming that the bottom topography is proportional to the first Laplacian eigenmode (see Fig. 2-c) but it is explained in Appendix F that this phase diagram is generic to any bottom topography. 12There are two important quantities related to the height field: the maximum allowed energy E mix defined in Eq. ( 156), and the available potential enstrophy

Z b ≡ ˆdx h 2 b , (159)
which is the maximum reachable value for the macroscopic enstrophy ´dx q g 2 , see Appendix F. Both Z b and E mix are a norm for the height field. The phase diagram of the quasi-geostrophic energy-enstrophy ensemble restricted to positive temperature states is presented in Fig. 2-a. As explained in subsection 4.3, the energy of the large scale flow E m f can not exceed the value E mix defined in Eq. ( 155), due the restriction of positive temperature states. Depending on the sign of Z 2 -Z b , where the potential enstrophy Z b is defined in Eq. (159), the system behaves differently:

-When Z 2 > Z b the minimum admissible large scale flow energy is zero.

-When Z 2 < Z b , there exists a minimum reachable large scale flow energy E min (Z 2 ) below which there is no equilibria. The curve E min increases from 0 to E mix when Z 2 decreases from Z b to 0.

The thick black line in Fig. 2-a delimits the domain of existence for the equilibria. The thin dashed black curves represent the isotherm, i.e. the points of the diagram with the same value of E f luct . Note that there is no bifurcation in this phase diagram; to each point (E m f , Z 2 ) corresponds a single equilibrium state, whose expression is given explicitly in Appendix F. The structure of an equilibrium large scale flow above a topographic bump at low and high energy are presented in the last subsection.

The phase diagram in Fig. 2 allows to discuss the energy partition between small scale fluctuations and large scale flow when the quasi-geostrophic flow is coupled to small scale fluctuations of the height field and divergence field (through the shallow water dynamics). The motivation behind the works of [START_REF] Warn | Statistical mechanical equilibria of the shallow water equations[END_REF] and [START_REF] Weichman | Statistical Equilibrium Solutions of the Shallow Water Equations[END_REF] was the prediction of energy partition between large scale flow and small scale fluctuations. Here we provide for the first time an explicit expression for such energy partition.

We have seen that in the weak height fluctuation limit, the temperature of the large scale flow at equilibrium is given by the energy of the small scale fluctuations of height and divergence fields. The parameters are now the total energy E and enstrophy Z 2 . The mean flow energy E m f and the fluctuation energy E f luct are found by solving

E = E m f E f luct , Z 2 + E f luct , (160)
which is easily done graphically using the diagram of Fig. 2-a -When Z 2 < Z b , the ratio E m f /E tends to 1 when E tends to the minimal admissible energy E min (Z 2 ).

-When Z 2 > Z b , the ratio E m f /E tends to 0 when E tends to zero.

-

When Z 2 > Z b with Z 2 -Z b ∼ E α with α > 1/2, the ratio E m f /E tends to 1/5 when E tends to zero. -When Z 2 > Z b with Z 2 -Z b ∼ E 1/2
, the ratio E m f /E tends to a finite value (depending on the proportionality coefficient between Z 2 -Z b and E 1/2 and the bottom topography).

-When Z 2 > Z b with Z 2 -Z b ∼ E α with α < 1/2,
the ratio E m f /E tends to 0. Whenever Z 2 ≥ Z b , we found E f luct ∼ E. We see on Fig. 2-b that the ratio E m f /E converges to one when E → E min (Z 2 < Z b ), that it converges to zero for Z 2 > Z b , and that it converges to 1/5 for Z b = Z 2 . Note also that E m f is bounded by E mix such that E m f /E tends to zero when E tends to infinity.

The effect of energy dissipation and enstrophy dissipation

The actual shallow water dynamics is known to be characterized by shocks that prevent energy conservation. In addition, the presence of viscosity, no matter how small it is, may lead to enstrophy dissipation, and more generally would break the conservation of potential vorticity moments. The aim of this subsection is to discuss qualitatively the effect of these dissipative processes on the large scale flow, assuming that the system evolves through a sequence a equilibrium states, which is a natural hypothesis if there exists a separation of time scales.

For the sake of simplicity, let us focus on the phase diagram obtained in the energy-enstrophy ensemble and described in the previous subsection. Let us consider that the system has reached at some time an arbitrary equilibrium state denoted by A in Fig. 3.

Let us first consider a case where energy is conserved, but enstrophy is dissipated. Then the system will evolve form point A to point C of Fig. 3. In other words, the small scale enstrophy Z 2 will be dissipated so that the enstrophy of the system tends to the minimum admissible value of enstrophy Z 2 min (E m f ). Note that the curve Z 2 min (E m f ) is nothing but the curve of energy minima for a given Z 2 < Z b . We saw previously that the mean-flow energy E m f dominates the fluctuation energy E f luc on this line. We conclude that enstrophy dissipation alone drives the system towards a large scale flow without small scale fluctuations. This large scale flow vanished when topography vanished (since E mix and Z b would also vanish).

Let us now consider that the enstrophy is not dissipated and look the effect of energy dissipation. Let us first explain why one may expect that even weak dissipation can lead to a significant decrease of the large scale flow energy E m f when E f luct = 0 (in the absence of small scale fluctuations, E m f would not decrease significantly with weak dissipation). At equilibrium, the energy of the small scale fluctuations E f luct should be equipartitioned among all the modes of the height field and divergent field. Since there is an infinite number of such modes, this means a loss of energy through dissipative process, no matter how small they are. Since E m f decreases with E f luct , dissipating the energy E f luct amounts to diminish the energy E m f . For a given enstrophy Z 2 > Z b , as in the case of point A Fig. [START_REF] Bouchet | Emergence of intense jets and Jupiter's Great Red Spot as maximum-entropy structures[END_REF], this dissipative process drives the system towards a zero energy state B. For a given enstrophy Z 2 < Z b , this process would drive the system towards the line of minimal energy.

We expect to see both enstrophy and energy dissipation working together, so the trajectory of the system in phase diagram will be somewhere between the trajectory A → B and the trajectory A → C, e.g. the trajectory e.g. A → D. We conclude that in the presence of topography and small scale dissipation, we eventually reach a geostrophic regime at large time, provided that the initial enstrophy is sufficiently low (otherwise the final state contains no large scale flow). In addition, each time the system is perturbed by adding a little amount of energy without changing the enstrophy, it drives the system a bit more towards the mixed state E m f = E mix , Z 2 = 0 . 5.3 Flow structure of the equilibrium states: application to the Zapiola Anticyclone.

So far we have discussed energy partition for shallow water equilibria in the quasi-geostrophic limit.

Here we focus on the structure of the large scale flow associated with these equilibrium states. We consider for that purpose an oceanic application to the Zapiola anticyclone.

The Zapiola anticyclone is a strong anticyclonic recirculation taking place in the Argentine basin above a sedimentary bump known as the Zapiola drift [START_REF] Weatherly | On deep-current and hydrographic observations from a mudwave region and elsewhere in the argentine basin[END_REF][START_REF] Saunders | Bottom currents derived from a shipborne adcp on woce cruise a11 in the south atlantic[END_REF][START_REF] Miranda | On the dynamics of the zapiola anticyclone[END_REF]. The anticyclone is characterized by a mass transport as large as any other major oceanic current such as the Gulf Stream. It is a quasibarotropic (depth independent) flow, with typical velocities of the order of 0.1 m.s -1 , and a lateral extension of the order of 800 km.

It is known from the earlier statistical mechanics studies that positive temperature states in the energy enstrophy ensemble of one layer models lead to anticyclonic circulations above topography anomalies, see e.g. [START_REF] Salmon | Lectures on Geophysical Fluid Dynamics[END_REF] and references therein. A generalization of this result to the continuously stratified case with application to the Zapiola anticyclone is given in [START_REF] Venaille | Bottom-trapped currents as statistical equilibrium states above topographic anomalies[END_REF].

We have shown in this paper that quasi-geostrophic equilibria characterized by positive temperature states are also shallow water equilibria. The Zapiola anticyclone can therefore be interpreted as an equilibrium state of the shallow water model. Let us now show the qualitative difference between low energy states (when Z 2 > Z b and E m f → 0) and high energy states (when E m f → E mix ), which are shown on Fig. 4-a In both cases the bottom topography is the same, and its isolines are visualized with thin black lines. Bottom topography has been obtained from data available online and described in [START_REF] Smith | Global seafloor topography from satellite altimetry and ship depth soundings[END_REF]. We isolated the largest close contour defining the Zapiola drift (the sedimentary bump above which the recirculation takes place), and considered the actual bottom topography inside this contour, and a flat bottom outside this contour. It allows to focus on the interesting flow structure occurring above the Zapiola drift.

Energy-enstrophy equilibrium states are then computed using Eq. ( 234) in Appendix F. We have seen that low energy limit corresponds to β → +∞ with Z 2 > Z b . Taking this limit in Eq. (234) yields ψ m f = (Z 2 -Z b ) h b /β : the equilibrium state is a Fofonoff flow [START_REF] Fofonoff | Steady flow in a frictionless homogeneous ocean[END_REF], meaning that streamlines are proportional to the isolines of topography, just as in Fig. 3-a.

The maximum energy state corresponds to the case β = 0, which corresponds to the mixed state defined in Eq. ( 154). The streamfunction is

ψ mix = R -2 -∆ -1 h b . The operator R -2 -∆ -1 with
R ∼ 1 is expected to smooth out the small scale topography features, just as in Fig. 4-a.

Conclusion

We have presented in this paper analytical computations of equilibrium states for the shallow water system, giving thus predictions for the energy partition into small scale fluctuations and large scale flow. Our results rely on the definition of a discrete version of the shallow water model. Once our semi-Lagrangian discrete model was introduced, the whole machinery of equilibrium statistical mechanics could be applied. We found that equilibrium states of the shallow water system are associated with the concomitant existence of a large scale flow which is a stationary state of the shallow water dynamics, superimposed with small scale fluctuations that may contain in some cases a substantial part of the total energy. The novelty of our work was to explicitly compute the contribution of these small scale fluctuations, and to decipher the physical consequences of the presence of these fluctuations.

In particular, we found that the presence of small scale fluctuations implies a positive temperature for the equilibrium state. This explains a previous result by Warn [START_REF] Warn | Statistical mechanical equilibria of the shallow water equations[END_REF], who showed that equilibrium states in a weak flow limit admit no large scale flow when there is no bottom topography and no lateral boundaries. We have generalized these results, by showing that a large scale vortical flow exists at equilibrium when there is both rotation and bottom topography, or when there is a non-zero circulation.

In the limit of weak height fluctuations, we found equipartition of the small scale kinetic and potential energy. We also obtained an interesting physical picture of the equilibrium state, which may be interpreted in that limit as two subsystems in thermal contact. One subsystem is the "large scale" potential vortical flow whose entropy is closely related to the one introduced heuristically by Chavanis and Sommeria (see [START_REF] Chavanis | Statistical mechanics of the shallow water system[END_REF]). Our work provides therefore a microscopic justification of their entropy with a complete statistical mechanics derivation and a generalization of this results by including the presence of small scales fluctuations of the height and divergence fields. We note however that it is wrong to interpret the "large scale" potential vortical flow entropy as the entropy of the system, it is only one part of it. The other subsystem contains the field of height fluctuations associated with small scale potential energy, and the field of velocity fluctuations, associated with small scale kinetic energy. These velocity fluctuations are due solely to the divergent part of the velocity field. Warn obtained a similar result in the weak flow limit, by projecting the non-linear dynamics into eigenmodes of the linearized dynamics [START_REF] Warn | Statistical mechanical equilibria of the shallow water equations[END_REF]. He found an energy partition into a vortical flow on the one side, and on inertia-gravity waves on the other side, with a weak coupling between both subsystems. Hence we may interpret local height and divergent velocity fields fluctuations appearing in our model as inertia gravity waves.

We studied the quasi-geostrophic limit for the large scale flow, taking into account the presence of small scale fluctuations. We recovered in this limit the variational problem of the Miller-Robert-Sommeria theory, with the additional constraint that the temperature is positive. We obtained phase diagrams in the particular case of energy-enstrophy equilibria, with explicit prediction for the ratio of energy between small scale fluctuations and a large scale quasi-geostrophic flow. This allowed to discuss the qualitative effect of small scale dissipation and shocks on the temporal evolution of the system. The main result is that such dissipative processes drive the system towards a minimum energy state (depending on the enstrophy), which may be non-zero.

In view of those results, the semi-Lagrangian discrete model seems to be a good discretization of the shallow water system. It has the key desired properties to take into account of the conservation of fluid particle volume, while working in an Eulerian framework. This gives a clear framework, which allows for a rigorous derivation once the discretization is assumed. Moreover we stress that it leads to equilibrium states that are stationary states of the shallow water model, by contrast with other choices of discretization. What is not completely satisfactory however is that there is a degree of arbitrariness in the definition of the discrete model. We have tried to have the model consistent with the geometric constraints related to the Liouville theorem, even though the link between the model and the Liouville theorem is clearly not rigorous. There is clearly room for improvement, but we are afraid we are faced with extremely tricky mathematical problems. Nevertheless we guess that the invariant measure of the discrete model converge to the actual invariant measure of the shallow water system in the continuous limit, but proving this is beyond the scope of this paper.

The statistical mechanics prediction of a vanishing large scale flow in the absence of boundary and bottom topography seems to contradict some numerical results performed in such configurations, in which case long lived vortex were reported, see e.g. [START_REF] Farge | Wave-vortex dynamics in rotating shallow water[END_REF]. This issue is related to the estimation of a time scale for the convergence towards equilibrium. Indeed, if the coupling between the large scale flow (potential vortical modes) and the small scale fluctuations (inertia-gravity waves) is weak, and if one starts from an initially balanced and unstable large scale flow, then this large scale flow may self-organize spontaneously on a short time scale into an equilibrium state of the quasi-geostrophic subsystem. This justifies the physical interest of the variational principle for the large scale flow introduced by [START_REF] Chavanis | Statistical mechanics of the shallow water system[END_REF] without small scale fluctuation. According to our statistical mechanics predictions, the energy of this large scale flow should leak into small scale fluctuations, but this process may be slow if coupling between both subsystems is weak. This difficult issue was already raised by Warn [START_REF] Warn | Statistical mechanical equilibria of the shallow water equations[END_REF], and the interaction between geostrophic motion and inertia-gravity waves remains an active field of research [START_REF] Vanneste | Balance and Spontaneous Wave Generation in Geophysical Flows[END_REF]. In particular, very interesting models of interactions between near-inertial waves and geostrophic motion have been proposed [START_REF] Young | Propagation of near-inertial oscillations through a geostrophic flow[END_REF][START_REF] Gertz | Near-inertial oscillations and the damping of midlatitude gyres: A modeling study[END_REF][START_REF] Xie | A generalised-lagrangian-mean model of the interactions between near-inertial waves and mean flow[END_REF]. In the context of statistical mechanics approaches, it has been proposed to compute equilibrium states with frozen degrees of freedom [START_REF] Salmon | The shape of the main thermocline, revisited[END_REF] or restricted partition functions in order to avoid the presence of inertia-gravity waves [START_REF] Herbert | Restricted equilibrium and the energy cascade in rotating and stratified flows[END_REF].

One of the main interests of the present study is the prediction of a concomitant large scale energy transfer associated with a large scale potential vortical flow and a small scale transfer of energy that is lost into small scale fluctuations interpreted as inertia-gravity waves. In that respect, the shallow water model lies between three dimensional and two-dimensional turbulence. There are other models for which the energy may be partitioned into a large scale flow and small scale fluctuations. There are, for instance, some strong analogies with the case of three-dimensional axisymmetric Euler equations, that is also intermediate between 2D and 3D flows. A statistical mechanics theory has been recently derived for this system by Thalabard et al [START_REF] Thalabard | Statistical mechanics of the 3d axisymmetric euler equations in a taylorcouette geometry[END_REF]. This statistical theory can also be understood as two subsystems in contact, one of them being the fluctuations, and thus leading to positive temperatures [START_REF] Thalabard | Statistical mechanics of the 3d axisymmetric euler equations in a taylorcouette geometry[END_REF]. From this key observation, [START_REF] Thalabard | Statistical mechanics of the 3d axisymmetric euler equations in a taylorcouette geometry[END_REF] concluded that the temperature of the system, that measures the variance of the fluctuations, is positive and uniform in space, as previously stressed in [START_REF] Naso | Statistical mechanics of beltrami flows in axisymmetric geometry: Theory reexamined[END_REF]. More generally, and beyond those simplified flow models that allow for analytical treatment, it is common to observe in bounded laboratory experiment the emergence of large scale structures at the domain scale superimposed with small scale energy fluctuations, see e.g. [START_REF] Thalabard | Ferro-turbulence : a statistical mechanics framework for the large-scale structure of turbulent von karman flows[END_REF]. It is not clear whether equilibrium theory may be relevant to describe such problems, but we believe that it is at least a useful first step to address these questions.

A Invariant measure and formal Liouville theorem

A.1 Formal Liouville theorem for the triplet of fields (h, hu, hv)

The existence of a formal Liouville theorem for the shallow water dynamics is shown in this appendix. The shallow water system is fully described by the triplet of fields (h, hu, hv). We consider a measure written formally as

dµ = CD [h] D [hu] D [hv] ,
with uniform density in (h, hu, hv)-space (C is a constant). The average of any functional A over this measure is

∀A [h, uh, vh] , A µ = ˆdµ A . ( 161
)
The term

´D [h] D [hu] D [hv]
means that the integral is formally performed over each possible triplet of fields (h, hu, hv).

The measure is said to be invariant if

∀A , d dt A µ = 0 (162)
This yields the condition

∀A , ˆD [h] D [hu] D [hv] ˆdx δ A δ h ∂ t h + δ A δ (hu) ∂ t (hu) + δ A δ (hv) ∂ t (hu) = 0. ( 163
)
An integration by parts yields

∀A , ˆD [h] D [hu] D [hv] A ˆdx δ ∂ t h δ h + δ ∂ t (hu) δ (hu) + δ ∂ t (hv) δ (hv) = 0. ( 164
)
We say that the equation follows a formal Liouville theorem if we formally have

ˆdx δ ∂ t h δ h + δ ∂ t (hu) δ (hu) + δ ∂ t (hv) δ (hv) = 0, (165)
which ensures that the measure dµ is invariant. The shallow water equations ( 5) and ( 6) can be written on the form

∂ t (hu) = -∂ x hu 2 + 1 2 gh 2 -∂ y (huv) + f hv, (166)
∂ t (hv) = -∂ y hv 2 + 1 2 gh 2 -∂ x (huv) -f hu, (167)
∂ t h + ∂ x (hu) + ∂ y (hv) = 0. ( 168
)
We see that

δ ∂ t h δ h + δ ∂ t (hu) δ (hu) + δ ∂ t (hv) δ (hv) = -∇ • δ (hu) δ h + δ (huu) δ (hu) + δ (hvu) δ (hv) . ( 169
)
As the divergence operator is a linear operator, it commutes with the functional derivatives. This allows to conclude that the measure µ is invariant. This shows formally the existence of a Liouville theorem for the fields (h, uh, vh).

A.2 Change of variables from (h, hu, hv) to (h, q, µ)

The microcanonical measure can formally be written

dµ h,hu,hv = D [h] D [hu] D [hv] δ (E -E) +∞ ∏ k=0 δ (Z k -Z k ) , (170)
The constraints are more easily expressed in terms of the variables

h, q = -∂ y u + ∂ x v + f h , µ = ∆ -1/2 (∂ x u + ∂ y v) . (171)
It will thus be more convenient to use these fields as independent variables. We call J [(h, hu, hv)/(h, q, µ)] the Jacobian of the transformation. We proceed step by step to compute this Jacobian. The change of variables (h, hu, hv) → (h, u, v) involves a upper-diagonal Jacobian matrix at each point r:

J (h, hu, hv) (h, u, v) = 1 u v 0 h 0 0 0 h (172)
which implies det (J [(h, hu, hv)/(h, u, v)]) = h 2 and

D [h] D [hu] D [hv] = h 2 D [h] D [u] D [v] . (173)
The change of variable (h, u, v) → (h, ω, µ) involves linear operators that do not depend on space coordinates, thus the determinant of the Jacobian of the transformation is an unimportant constant:

D [h] D [u] D [v] = CD [h] D [ω]D [µ]. (174)
Using ω = qh -1, the change of variable (h, ω, µ) → (h, q, µ) involves an upper diagonal Jacobian matrix at each point r:

J (h, ω, µ) (h, q, µ) = 1 q 0 0 h 0 0 0 1 , (175)
with a determinant det (J [(h, ω, µ)/(q, h, µ)]) = h. Finally, the Jacobian of the transformation is J [(hu, hv, h)/(q, h, µ)] = h 3 and the microcanonical measure can formally be written

dµ h,q,µ = Ch 3 D [h] D [q] D [µ]δ (E -E) +∞ ∏ k=0 δ (Z k -Z k ) . (176)
We note the presence of the pre-factor h 3 which gives the weight of each microscopic configuration in the (h, q, µ)-space.

B Relevance of the constraints for the discrete model

In this appendix, we explain how the dynamical invariants of the shallow water model, given in Eqs. [START_REF] Robert | On the statistical mechanics of 2d euler equation[END_REF] and (34) respectively, are related to the constraints of the microcanonical ensemble for the discrete model, given in Eqs. ( 92) and (97), respectively.

B.1 Areal coarse-graining for continuous fields

Let us consider a field g (x) on the domain D where the flow takes place, and let us consider the uniform grid introduced in subsection 3.2.1. We define the local areal coarse-graining of the continuous field g (x) over a site (i, j) as

g i j = N ˆsite (i, j) dx g (x) , (177)
where 1/N is the area of the site (i, j) and where ´site (i, j) means that we integrate over the site (i, j) only. With an abuse of notation, we use here the same notation g i j as in Eq. ( 50), since the coarse-graining operator defined in Eq. ( 177)

generalizes to the continuous case the areal coarse-graining operator defined in Eq. ( 50) for the discrete microscopic model, taking into account the fact that for a fluid particle "n" of area dx n and height h n , we get Ndx n = 1/(Mh n ). We denote g the continuous limit (large N) of g i j . Integrating a continuous field g amounts to perform the integration over its local average field g:

ˆdx g (x) = ˆdx g (x) . (178)

B.2 Potential vorticity moments

Using (178), the potential vorticity moments in Eq. ( 34) simply leads to

Z k = ˆdx hq k . ( 179
)
Now that the potential vorticity moments are expressed in terms of the areal coarse-graining of moments of h and q, it can directly be expressed in terms of the probability density field ρ σ h , σ q , σ µ through Eq. ( 90), and we recover the expression of the constraint given in Eq. ( 92), whose discrete representation is given in Eq. ( 56).

B.3 Energy

Using (178), recalling that we restrict ourself to bottom topographies such that h b = h b , the total energy of the shallow water model defined in Eq. ( 32) can be decomposed into a mean flow kinetic energy defined in Eq. ( 94), a potential energy term due to local height fluctuations and defined in Eq. ( 96), a fluctuating kinetic energy term

E c, f luct ≡ E -E m f -E δ h (180) E c, f luct ≡ 1 2 ˆdx hu 2 -hu 2 m f , (181)
where the velocity fields u and u m f are computed from the triplet (h, q, µ) and from the triplet h, hq, hµ , respectively through

u = ∇ ⊥ ψ + ∇φ , (hq -f ) = ∆ ψ, µ = ∆ 1/2 φ , (182)
and through

u m f = ∇ ⊥ ψ m f + ∇φ m f , hq -f = ∆ ψ m f , hµ h = ∆ 1/2 φ m f . (183)
We want to discuss the relation between decomposition of the energy for the discrete model, Eq. ( 97) and the decomposition for the actual total energy defined in Eq. [START_REF] Robert | On the statistical mechanics of 2d euler equation[END_REF]. Our construction is relevant if these two decomposition coincide in the continuous limit, or equivalently if E c, f luct is equal to E δ µ (95) in the continuous limit. In the following we show that this is the case if some cross correlations are actually negligible. More precisely, we assume that 1. For any positive integers k, l, m , the coarse-grained fields h k q l µ m (x) defined through the coarse graining procedure in Eq. ( 178) exist. In the framework of our microscopic model introduced in subsection 3.2, this hypothesis is automatically satisfied by assuming that the cut-off µ min , µ max , q min , q max , h max scales as N α with α < 1. Other fields may be characterized by local extreme values such that the limit defined in Eq. ( 178) does not converge. For instance, we will see that the actual divergence ζ = ∆ φ of the equilibrium state is not bounded, i.e. that ζ would have no meaning. 2. The fields h, q, µ are decorrelated (in particular, h k q l µ m = h k q l µ m ). This point will be shown to be self-consistent when computing the equilibrium state. 3. The coarse-grained divergent velocity field is equal to the mean-flow velocity field ∇φ = ∇φ m f . 4. ∆ φφ m f 2 = 0. While ∇(φ -φ m f ) is a random vector field characterized by wild local fluctuation, this hypoth- esis amounts to assume that those fluctuations have no preferential direction.

We believe that these four assumptions would be satisfied by a typical triplet of fields (h, q, µ) picked at random among all the possible states satisfying the constraints of the dynamics. By typical, we mean that an overwhelming number of fields would share these properties.

We then prove that these four assumptions are sufficient to prove that E c, f luct is equal to E δ µ (95) in the continuous limit. According to the assumption 1, ω = hq -1 is well defined. Classical arguments show that the streamfunction of the coarse-grained vorticity field ω is equal to the streamfunction of the vorticity field, i.e. that∇ψ m f = ∇ψ, see e.g. [START_REF] Robert | Statistical equilibrium states for two-dimensional flows[END_REF][START_REF] Michel | Large deviations for young measures and statistical mechanics of infinite dimensional dynamical systems with conservation law[END_REF]. Qualitatively, this is due to the fact that inverting the Laplacian operator smooth out local fluctuations of the vorticity 13 . This yields

u = u m f + ∇ φ -φ m f .
(184) Injecting this expression in the kinetic energy density expression Eq. (181), using that h and µ are not correlated (assumption 2), and using ∇φ = ∇φ m f (assumption 3) yields

E c, f luct = 1 2 ˆdx h ∇ φ -φ m f 2 . ( 185
)
Let us now remember the definition of the coarse-graining operator in Eq. ( 178):

∇ φ -φ m f 2 = lim N→∞ N Ŝij dx ∇ φ -φ m f 2 , for x ∈ S i j , (186)
where S i j is the surface covered by a grid site (i, j). An integration by parts yields

N Ŝij dx ∇ φ -φ m f 2 = -N Ŝij dx ∆ -1/2 (µ -µ) ∆ 1/2 (µ -µ) + N ∂ S i j dl n • φ -φ m f ∇ φ -φ m f (187)
Projecting the first term of the rhs on Laplacian eigenmodes allows to simplify the expression of the first term of the rhs in Eq. ( 187):

-N

Ŝij dx ∆ -1/2 (µ -µ) ∆ 1/2 (µ -µ) = N Ŝij dx (µ -µ) 2 . ( 188
)
The second term of the rhs in Eq. ( 187) can be written as

N ∂ S i j dl n • φ -φ m f ∇ φ -φ m f = N 2 ˆSij ∆ φ -φ m f 2 (189)
which, according to assumption 4, vanishes in the large N limit. Finally, the kinetic energy density of the fluctuations is simply expressed as

E c, f luct = 1 2 ˆdx h µ 2 -µ 2 . (190)
Finally, we use again the assumption 2 to get

E c, f luct = 1 2 ˆdx hµ 2 - hµ 2 h = E δ µ , (191)
which is the expected result.

C Critical points of the mean-flow variational problem

In this Appendix, we compute the critical points of the mean-flow variational problem (100) stated in section 3. In a first step, we solve an intermediate variational problem in order to show the factorization of the probability density ρ with a Gaussian behavior for the divergence fluctuations. Knowing that, we solve in a second step the original variational problem.

C.1 Intermediate variational problem

As the energy and the potential vorticity moments depend only on the coarse-grained fields h, h

The idea of introducing the intermediate variational problem is to find a simpler ansatz for the probability density field ρ . This ansatz will be used afterward into the general variational problem (100).

In order to compute the critical points of the variational problem (192), we introduce the Lagrange multipliers α h (x) , α h2 (x) , α hµ (x) , α hµ2 (x) , α hq,k (x) k≥0 and ξ (x) associated with the constraints h, h 2 , hµ, hµ 2 , hq k k≥1 and the normalization constraint, respectively. Using Eq. ( 89) and the first variations

∀δ ρ, δ S -ˆdx α h δ h + α h2 δ h 2 + α hµ δ hµ + α hµ2 δ hµ 2 + +∞ ∑ k=1 α hq,k δ hq k + ξ ˆδ ρ = 0, (193)
leads to

σ h log ρ σ 2 h + σ h + ξ + α h σ h + α h2 σ 2 h + α hµ σ h σ µ + α hµ2 σ h σ 2 µ + +∞ ∑ k=1 α hq,k σ h σ k q = 0 (194)
We readily see from Eq. ( 194) that the probability density ρ factorizes into three decoupled probability densities ρ q , ρ h and ρ µ corresponding respectively to the probability densities of the potential vorticity, the height and the divergence:

ρ = ρ q (x, σ q ) ρ h (x, σ h ) ρ µ x, σ µ . (195)
Using the constraints µ = ´dσ µ σ µ ρ µ , µ 2 = ´dσ µ σ 2 µ ρ µ , as well as the normalization constraints ´dσ µ ρ µ = ´dσ h ρ h = ´dσ q ρ q = 1, we get

                                                     ρ q (x, σ q ) = exp - +∞ ∑ k=1 α hq,k (x) σ k q ˆdσ , q exp - +∞ ∑ k=1 α hq,k (x) σ ,k q ρ h (x, σ h ) = σ 2 h exp -α h2 (x) σ h - ξ (x) σ h ˆdσ , h σ ,2 h exp -α h2 (x) σ , h - ξ (x) σ , h ρ µ x, σ µ = exp - 1 2 σ µ -µ (x) 2 µ 2 (x) -µ 2 (x) (2π) 1/2 µ 2 (x) -µ 2 (x) 1/2 . ( 196
)
We could now re-inject these expressions into the main variational problem (100), but only factorization and the Gaussian form of ρ µ will be kept as an ansatz for ρ, which will simplify the computations. Thanks to this intermediate variational problem, we now know that the critical points of the original variational problem must be of the form:

ρ x, σ h , σ q , σ µ = ρ h (σ h , x) ρ q (σ q , x) exp -1 2 (σµ -µ) 2 µ 2 -µ 2 (2π) 1/2 µ 2 -µ 2 1/2 . ( 197
)
The entropy defined in Eq. ( 89) is therefore (up to a constant):

S ρ h , ρ q , μ, μ2 -μ2 = -ˆdxdσ h σ h ρ h log ρ h σ 2 h -ˆdx h ˆdσ q ρ q log (ρ q ) + ˆdx h 2 log µ 2 -µ 2 . ( 198
)
As a consequence of Eq. (197), the height field, the potential vorticity field and the divergence field are decorrelated. This property allows to rewrite the energy defined in Eq. ( 93)

E ρ h , ρ q , µ, µ 2 -µ 2 = E m f h, q, µ + E δ µ h, µ 2 -µ 2 + E δ h h, h 2 , (199)
where

         E m f h, q, µ = 1 2 ´dx hu 2 m f + g h + h b -1 2 E δ µ h, µ 2 -µ 2 = 1 2 ´dx h µ 2 -µ 2 E δ h h, h 2 = g 2 ´dx h 2 -h 2 (200) with u m f = ∇ ⊥ ∆ -1 qh -f + ∇∆ -1/2 µ .
Similarly the potential vorticity moments (96) can be rewritten

∀k Z k h, q k = ˆdx hq k (201)
where the coarse-grained moments are now defined as

h l = ˆdσ h σ l h ρ h , q m = ˆdσ q σ m q ρ q . (202)
Thus, the general variational problem of the equilibrium theory given in Eq. ( 100) can be recast into a new variational problem on the independent variables ρ h (x, σ h ) , ρ q (x, σ q ) , µ (x) and µ 2 -µ 2 (x):

S (E, D) = max ρ h ,ρq,µ,µ 2 -µ 2 ´ρh =1, ´ρq=1 S ρ h , ρ q , µ, µ 2 -µ 2 | E ρ h , ρ q , µ, µ 2 -µ 2 = E, ∀k Z k [ρ h , ρ q ] = Z k . (203)

C.2 Computation of the critical points

In this subsection, we compute the critical points of the variational problem defined in Eq. (203). We introduce the Lagrange multiplier β , {α k } k≥0 , ξ q (r) and ξ h (r) associated respectively with the energy, the potential vorticity moments and the normalization constraints. Critical points of the variational problem (203) are solutions of

∀δ ρ q , δ ρ h , δ µ, δ µ 2 -µ 2 , δ S -β δ E - +∞ ∑ k=0 α k δ Z k -ˆdx ξ q ˆδ ρ q + ξ h ˆδ ρ h = 0. ( 204
)
The first variations of the macrostate entropy S (198) are

               δ S δ ρ h = -σ h log ρ h σ 2 h + 1 -σ h ´dσ q ρ q log (ρ q ) + σ h 1 2 log µ 2 -µ 2 δ S δ ρq = -h (log (ρ q ) + 1) δ S δ µ = 0 δ S δ µ 2 -µ 2 = h 2 µ 2 -µ 2 . ( 205
)
First variations of the energy given in Eqs. (199) and (200) contain three contributions:

δ E = δ E m f + δ E δ µ + δ E δ h . The first contribution is δ E m f = ˆdx B m f δ h + hu m f • δ u m f , (206)
where B m f = u 2 m f /2 + g h + h b -1 is the mean-flow Bernoulli function defined in Eq. (115). Then, using the Helmholtz decompositions u m f = ∇ ⊥ ψ m f + ∇φ m f and recalling that hu m f = ∇ ⊥ Ψ m f + ∇Φ m f , two integrations by parts with the impermeability boundary condition yield

δ E m f = ˆdx B m f δ h -Ψ m f δ ∆ ψ m f -Φ m f δ ∆ φ m f . (207)
Using ∆ ψ m f = hqf and ∆ 1/2 φ m f = µ and the definition of the operator ∆ 1/2 leads to the final expression

δ E m f = ˆdx B m f -qΨ m f δ h -hΨ m f δ q -∆ 1/2 Φ m f δ µ . (208)
Finally, we get:

             δ E δ ρ h = σ h B m f -qΨ m f + µ 2 -µ 2 2 + g σ h 2 -h δ E δ ρq = -σ q Ψ m f h δ E δ μ = -∆ 1/2 Φ m f δ E δ µ 2 -µ 2 = h 2 , (209)
First variations of the potential vorticity moments are

∀k ∈ N              δ Z k δ ρ h = σ h q k δ Z k δ ρq = hσ k q δ Z k δ µ = 0 δ Z k δ µ 2 -µ 2 = 0 , (210)
Injecting Eqs. ( 205), (209), and (210) in Eq. ( 204), and collecting the term in factor of δ µ 2 -µ 2 leads to

µ 2 -µ 2 = 1 β . (211)
Injecting Eq. ( 211) in the expression of ρ µ given in Eq. ( 196) yields then

ρ µ x, σ µ = β 2π 1/2 exp - 1 2 β σ µ -µ (x) 2 . (212)
Similarly, collecting the term in factor of δ ρ q in Eq. ( 204) leads to

0 = h (log (p q ) + 1) -β σ q Ψ m f h + +∞ ∑ k=0 α k hσ k q + ξ q , (213)
which, using the normalization constraint, leads to

ρ q (x, σ q ) = 1 G q exp β σ q Ψ m f - +∞ ∑ k=1 α k σ k q , G q = ˆdσ , q exp β σ , q Ψ m f - +∞ ∑ k=1 α k σ ,k q . ( 214
)
Note that the sum inside the exponential is performed from k = 1 to k = +∞ . The Lagrange parameter ξ q has been determined using the normalization condition for the pdf.

Collecting the term in factor of δ ρ h in Eq. (204) yields

-log ρ h σ 2 h + 1 -ˆdσ q ρ q log (ρ q ) - 1 2 log (β ) -β B m f + β -1 2 + g σ h 2 -h - ξ h σ h + β qΨ m f -∑ k≥0 α k q k = 0, ( 215
) which, using Eq. ( 214), leads to

-log ρ h σ 2 h + 1 + log (G q ) - 1 2 log β -β B m f + β -1 2 + g σ h 2 -h - ξ h σ h -α 0 = 0. ( 216
)
Using the fact that G q and B m f are fields depending only on x, and using the normalization constraint for the pdf ρ h (x, σ h ), Eq. (216) yields

ρ h (x, σ h ) = σ 2 h G h exp -β g 2 σ h - ξ h σ h , G h = ˆdσ , h σ 2 h exp -β g 2 σ , h + ξ h σ , h . (217)
Injecting Eq. (217) back into Eq. (216) yields

B m f = β -1 log (G q G h ) + gh + β -1 -α 0 - 3 2 + 1 2 log β . (218)
One can notice that α 0 the Lagrange parameter related to the conservation of the total mass appears only here. Thus the last term β -1 (α 0 -3/2 + log (β )/2) in Eq. ( 218) can be computed from the conservation of the total mass Z 0 = Z 0 and will be denoted A 0 in the following.

Collecting the terms in factor of δ µ in Eq. ( 204) leads to

Φ m f = 0. ( 219
)

D Global maximizers of the entropy of the large scale flow

We compute in this appendix an upper-bound for the macrostate entropy of the large scale flow defined in Eq. ( 130), for a given set of potential vorticity moment constraints defined in Eq. (92) (and arbitrary energy), and then show that when Z 1 = f and h b = 0, this upper bound for the macroscopic entropy is reached by the rest state.

This upper bound is the solution of the following variational problem:

S m f ,max = max h,ρq ´ρq=1 S m f h, ρ q ∀k Z k h, ρ q = Z k . (220)
Introducing Lagrange parameters {γ k } k≥0 associated with the potential vorticity moment constraints and the Lagrange parameter ξ (x) associated with the normalization constraint, the cancellation of first variations yields

∀δ ρ q , δ h, δ S m f - +∞ ∑ k=0 γ k δ Z k + ˆdx ξ δ 1 = 0. (221)
The solution of this equation is

ρ q = exp -∑ +∞ k=1 γ k σ k ´dσ exp -∑ +∞ k=1 γ k σ k ≡ ρ global (σ ) (222)
where ρ global depends only on the potential vorticity moments constraints {Z k } k≥1 , and is independent from x and

h (x) = 1 (223)
Note that the states characterized ρ q = ρ global , h = 1 are solutions of the variational problem in Eq. ( 220), but this is only a subclass of the solutions of the variational problem of the equilibrium theory given in Eq. ( 153), which includes an additional energy constraint We have shown in subsection (4.1) that for a given ρ q , the large scale flow which is a solution (153) is obtained by solving Eqs. ( 117) and (118) for Ψ m f and h. Here we consider the particular case ρ q = ρ global and h = 1. One can compute hq global = ´dx σ ρ global = Z 1 . We conclude that the large scale flow of the equilibrium state is also a global entropy maximizer, i.e. a solution of (220) when

Z 1 -f = ∆Ψ m f , (224)
1 2 ∇Ψ m f 2 + gh b = A 2 . ( 225
)
where A 2 = β log G q -A 1 is a constant. We see that in the case (Z 1 = f , h b = 0) , the solution of Eqs. ( 224) and ( 225) is the rest state Ψ m f = cst (with A 2 = 0). We conclude that the maximum of the macroscopic entropy of the large scale flow is reached by a flow at rest when there is no circulation (Z 1 = f ) and no bottom topography (h b = 0).

E Comparison with a Eulerian discrete model

The aim of this appendix is to discuss the construction of a possible invariant measure for the shallow water equations through an Eulerian discretization. We prove that the obtained equilibrium states differ from the one obtained through the semi-Lagrangian discretization used in the core of the paper. Moreover, we prove that the equilibrium states are not stationary states of the shallow water equations and that the statistical equilibria are not stable through coarse-graining. We define a purely Eulerian discrete model by considering the same uniform N × N grid as for the semi-Lagrangian model, but assuming that each node is now divided into a finer n × n uniform microscopic grid. A microscopic configuration is given by the values of the fields (h, q, µ) for all the nodes of the microscopic grid:

y micro ≡ {h IJ,i j , q IJ,i j , µ IJ,i j } 1≤I,J≤N 1≤i, j≤n , (226)
where (I, J) and (i, j) correspond respectively to the position on the macroscopic grid and the position on the microscopic grid within the macroscopic node. Contrary to the semi-Lagrangian model, the Eulerian model has the desired property to possibly be compatible with the formal Liouville theorem derived in Appendix A for the continuous dynamics (although no mathematical result exist). However, the volume of fluid varies from one microscopic grid node to another in the Eulerian model, depending on the value of the height h IJ,i j . By comparison, our semi-Lagrangian approach respects the Lagrangian conservation laws (the height h is defined through the particle mass conservation). Because of the need to go through a discretization to build the microcanonical measure, we see that both the Eulerian and the semi-Lagrangian approaches necessarily break part of the geometric conservation laws of the continuous model. Hopefully rigorous mathematical proof of the convergence of the measures of one of the discretized model to an invariant measure of the continuous equations will settle rigorously this issue in a near future, however nobody seem to know how to attack this problem mathematically. We are thus led to the conclusion that based on current knowledge, there is no clear mathematical or theoretical a priori argument to choose either the Eulerian or the semi-Lagrangian discretization in order to guess the microcanonical measures. For now, the use of one discrete model or another to guess the microcanonical measure of the continuous shallow water equations can therefore only be justified a posteriori.

Let us now define the empirical density field as

d IJ (σ h , σ q , σ µ )[y micro ] = 1 n n ∑ i, j=1 δ (h IJ,i j -σ h )δ (q IJ,i j -σ q )δ (µ IJ,i j -σ µ ). (227)
One can now compute the entropy of the macrostates ρ = {y micro | ∀I, J d IJ [y micro ] = ρ IJ }, which, after taking first the limit n → ∞ and then the limit N → ∞ leads to S Eul [ρ] = -ˆdxdσ h dσ q dσ µ ρ(x, σ h , σ q , σ µ ) log ρ(x, σ h , σ q , σ µ )

σ 3 h . ( 228
)
This Eulerian macrostate entropy has to be compared with the macrostate entropy for the semi-Lagrangian discrete model given in Eq. (89). We can switch from expression to the other by changing ρ into σ h ρ. We note that the two entropies become equivalent at lowest order in the limit of weak height fluctuations and weak height variations. However, in the general case, they are different, and therefore lead to different equilibrium states. In particular, is it straightforward to show that because of the absence of the factor σ h in the expression of this Eulerian macrostate entropy (228), the critical points ρ(x, σ h , σ q , σ µ ) of the microcanonical variational problem do not factorize. Consequently, small scale height and velocity fluctuations of the equilibrium state are correlated. One can then show that those correlations are associated with non-zero Reynolds stresses in the momentum equations. In particular, the equilibrium state of Eulerian model satisfies J(Ψ , q) = -J(Ψ ′ , q ′ ) -J(Φ ′ , q ′ ),

where the r.h.s. is non-zero. If one removes those small scale fluctuations, the large scale flow is not a stationary state of the dynamics since J(Ψ , q) = 0. In other words, the equilibrium states of the Eulerian model are not stable by coarsegraining, contrary to the equilibria of the semi-Lagrangian model. Moreover, Eq. ( 229) and the properties of stationary states derived in subsection 2.2 imply that neither the potential vorticy field q nor the Bernoulli potential B mf can simply be expressed as a function of Ψ mf . As shown in subsection 4.3.1), the fact that B mf is a function of Ψ mf is essential to prove that the equilibrium is characterized by geostrophic balance at lowest order in the Rossby number Ro, when Ro → 0. Consequently, the proof of geostrophic balance derived in the framework of the semi-Lagrangian model does not hold in the framework of the Eulerian model, unless the bottom topography is sufficiently small (h b ∼ Ro).

Let us finally argue that the stability by coarse-graining is a desirable physical property for the equilibrium states. The first argument is a body of empirical observations. In either experiments, geophysical flows or numerical simulations flows governed by the shallow water equations (or the Navier-Stokes equations or the primitive equations in a shallow water regime) in the inertial limit (when they are subjected to weak forcing and dissipation, with a clear time scale separation) do actually self-organize and form large scale coherent structures for which there is a gradual decoupling of the flow large scales and small scales. A prominent example is the velocity field of Jupiter's troposphere.

The second argument follows. Macrostates that evolve through an autonomous equation, must increase the Boltzmann entropy. This is a general result in statistical mechanics, which is a consequence of the definition of the macrostate entropy as a Boltzmann entropy. Indeed as the Boltzmann's entropy measure the number of microstates corresponding to a given macrostate, it must increase for most of initial conditions. When there is furthermore a concentration property (which is the case for the shallow water case, both the the Eulerian and sem-Lagrangian discretizations), the number of initial conditions for which the entropy can decrease decays exponentially with N (N is often the number of particles in statistical mechanics, here the number of degrees of freedom of our discretization). As a consequence, the set of equilibrium macrostates (entropy maxima) has to be stable through the dynamics for most initial conditions. In the shallow water case, in statistical equilibrium, obtained either using the semi-Lagrangian or Eulerian discretization discussed above, the stream function concentrates close to a single field (the stream function fluctuations vanish in the large N limit). As a consequence the macrostate stream function, which is a single field thanks to this concentration property, has to be stationary for the dynamics. Those two properties, that follow from the definition of the Boltzmann entropy, are actually verified for the equilibrium measure constructed from a semi-Lagrangian discretization, but not for the equilibrium measure constructed from a Eulerian discretization. For this reason, we conclude that the microcanonical measure constructed from the purely Eulerian discretization is inconsistent with the shallow water dynamics.

We note moreover that the stability of the equilibrium macrostates through coarse graining ensures that the equilibrium states of the inviscid system are not affected by perturbations such as a weak small scale dissipation in momentum equations. This property is not a-priori required for the invariant measure of the shallow-water equations. However It is extremely interesting as it is a hint that this invariant measure may be relevant for non perfect flow in the inertial limit.

F Energy-Enstrophy ensemble

F.1 Computation of the critical points

In this Appendix, we compute the solutions of the variational problem (158) and describe the corresponding phase diagram. Critical points of the variational problem (158) are computed through the variational principle:

∀δ ρ g , δ S m f ,g - 1 E f luct δ E m f ,g -γ 2 δ Z g2 -γ 1 δ Z g1 -ˆdx ξ (x) ˆdσ q δ ρ g = 0, (230)
where γ 2 , γ 1 and ξ (x are Lagrange multipliers associated with the enstrophy conservation, the circulation conservation, and the normalization respectively. Anticipating the coupling between the large scale quasi-geostrophic flow and the small scale fluctuations, the temperature is denoted E f luct (the inverse temperature is the Lagrange parameter associated with energy conservation).This yields

ρ g (x, σ q ) = 1 2π Z 2 -Z 2 exp - 1 2 Z 2 -Z 2 σ q - ψ m f E f luct -γ 1 Z 2 -Z 2 2 ( 231
)
where we have introduced the enstrophy of the coarse-grained potential vorticity

Z 2 ≡ ˆdxq 2 g . (232)
Injecting (231) in Eq. (147) , using the mass conservation constraint given in Eq. ( 144) and the zero circulation constraint Z 1 q g = 0 yields

q g = β ψ m f with β ≡ Z 2 -Z 2 E f luct . ( 233
)
Note that β is necessarily positive given that Z 2 -Z 2 ≥ 0. Injecting Eq. (233) in Eq. ( 149), the streamfunction can be computed explicitly by solving

β ψ m f = ∆ ψ m f - 1 R 2 ψ m f + h b . (234)
In order to solve this equation, it is convenient to introduce the Laplacian eigenmodes of the domain D, with k ∈ N + :

∆ e k = -λ 2 k e k with e k = 0 on ∂ D,

where the eigenvalues -λ 2 k are arranged in decreasing order. We assume those eigenvalues are pairwise distinct. We also assume that the bottom topography is sufficiently smooth such that ∑ k |h bk | 2 λ 2 k < +∞. Then, given that β > 0 , the projection of the mean flow streamfunction on the Laplacian eigenmode e k (x) is obtained directly from Eq. (234):

ψ k = h bk β + λ 2 k + R -2 . ( 236
)
We see that there is a unique solution ψ m f for each value of β . This solution is therefore the equilibrium state. All the large scale flows associated with statistical equilibrium states of the shallow water system restricted to the energy-enstrophy ensemble with zero circulation are obtained from Eq. ( 236) when varying β from 0 to +∞.

F.2 Construction of the phase diagram

The problem is now to find which equilibrium state is associated with the constraints (E, Z 2 ). In the following, we explain how to find the equilibrium states associated with parameters (E m f , Z 2 ), and how to compute the temperature E f luc for each of those states. It is then straightforward to obtained the total energy E = E m f + E f luc .

Injecting Eq. ( 236) in the expression of the quasi-geostrophic mean-flow energy defined in Eq. ( 150) yields

E m f = 1 2 +∞ ∑ k=1 λ 2 k + R -2 |h bk | β + λ 2 k + R -2 2 . ( 237
)
The mixing energy E mix defined in Eq. ( 155) is recovered for β = 0, given that Z 1 = 0. In the range β > 0, the energy E m f is a decreasing function of β , varying from E m f = E mix to E m f = 0, see Fig. 5-b and Fig. 5-d.

Injecting Eq. ( 236) in the expression of the macroscopic enstrophy given in Eq (232) yields

Z 2 = +∞ ∑ k=1 |h bk | 2 1 - λ 2 k + R -2 β + λ 2 k + R -2 2 . (238)
The potential enstrophy Z b defined in Eq. ( 159) is recovered for β = +∞. The macroscopic enstrophy Z 2 is an increasing function of β , varying from Z 2 = 0 (for β = 0) to Z 2 = Z b for ( β = +∞ ), see Fig. 5-a and Fig. 5-c.

Two expressions of the macroscopic enstrophy Z 2 in terms of the parameters β have been obtained: one is given by Eq. (238), the other arises from the definition of β in Eq. (233), which yields

Z 2 = Z 2 -E f luct β . ( 239
)
For given values of E f luct and Z 2 , the values of β and Z 2 are obtained by finding the intersection between the two curves defined in Eq. ( 238) and (239), respectively. Once β is obtained, Eq. (237) gives directly the value of the mean-flow energy E m f . The phase diagram presented in Fig. 2 is obtained numerically by using this procedure. Graphical arguments presented in the following allow to understand the structure of this phase diagram.

F.3 Limit cases for the energy partition

Let us first note through Figs. 5-a and 5-c that β is an decreasing function of E f luct . Indeed, β is given by the intersection between the solid curve representing the expression of Z 2 given Eq. ( 238) and the dashed line representing the affine expression of Z 2 given Eq. (239) where -E f luct is the slope. Then we know that the total energy E = E m f ( β ) + E f luct is an increasing function of E f luct . Let us now consider different limit cases.

The limit E → ∞ with Z 2 fixed: In this limit, we have also E f luct → ∞. and β → 0 Hence, one gets from Eq. (237) (see also Figs

E m f E = 1. ( 241
)
The limit E → 0 with Z 2 > Z b fixed: In this limit, we have also E f luct → 0. One gets from Fig. 5-a that β → ∞ and that Z 2 → Z b . Hence, from Eqs. (237) and (239), we obtain:

   E m f = C b β -2 + o β -2 β ∼ E→0 (Z 2 -Z b ) E -1 f luct , with C b = 1 2 +∞ ∑ k=1 |h bk | 2 λ 2 k + R -2 . (242)
Here, C b is a constant depending on the topography only. Thus we have E m f ∼ E 2 f luct C b / (Z 2 -Z b ) 2 , which leads to:

lim E→0 E m f E f luct = 0, lim E→0 E m f E = 0. ( 243
)
The limit E → 0 with Z 2 -Z b ∼ C α E α with α ≥ 0: In this limit, we have E f luct → 0. One gets from Fig. 5-a that β → ∞. Hence, from Eqs. (237) and (238), we obtain:

   E m f = C b β -2 + o β -2 Z b -Z 2 = 4C b β -1 + o β -1 , (244)
where C b is defined in Eq. (242). From those two equations along with Eq. (239) and using Z 2 -Z b ∼ C α E α , we can extract:

β ∼ E→0 C α E α + C 2 α E 2α + 20C b E 2E . (245)
Now, we have to consider different cases for the value of α.

lim E→0 E m f E = 2C b /C 2 α 1 + 1 + 20C b /C 2 α 2 . ( 248
)
Contrary to the previous cases, here, the partition of the energy depends on the bottom topography.

Fig. 1 :

 1 Fig. 1: Scheme of a vertical slice of fluid, η is the upper interface displacement, h b is the bottom topography, h is the height field and H is the mean height of the fluid ( h )

Fig. 2 :

 2 Fig. 2: a) Phase diagram of the energy-enstrophy ensemble in the plane (Z 2 , E m f ). Z b is the maximum reachable value for the macroscopic enstrophy defined in Eq. (159). E mix is the maximum reachable energy for the mean-flow defined in Eq. (155). The dashed lines corresponds to isotherms, on which the energy E f luct of the small scale fluctuations is constant. The thick black line on the bottom left corner is a boundary below which no equilibria exist. b) Ratio between the energy of the large scale flow E m f over the total energy E m f /E as a function of the total energy E = E m f + E f luct . The different curves correspond to different values of the initial microscopic enstrophy Z 2 represented by horizontal marked lines on panel a. The x-axis is on a logarithmic scale. c) Colormap plot of the bottom topography h b used to compute the phase diagram in Fig. 2-a-b and 3. Here, h b = sin(πx) is a single mode of the Laplacian operator. Thus the stream function ψ and the potential vorticity field q g are simply proportional to h b for any values of the initial enstrophy Z 2 and the initial energy E.

  , and performed numerically in practice, see Appendix F for more details. The ratio of the large scale energy E m f over the total initial energy E as a function of the total initial energy E is shown on Fig.2-bfor different values of initial enstrophy Z 2 . According to computations performed in Appendix F, four cases for the energy partition in the low energy limit are distinguished depending on the sign of Z 2 -Z b and the scaling of Z 2 -Z b with E:

Fig. 3 :

 3 Fig. 3: Phase diagram of Fig. 2-a with hypothetical trajectories of the shallow water system in the presence of dissipation. Trajectory A-B: the dynamics dissipates small scale fluctuations of height and divergence field only. Trajectory A-C: the dynamics dissipates small scale fluctuations of potential vorticity. Trajectory A-D: the dynamics dissipates small scale fluctuations of all the fields.

  and Fig 4-b, respectively.

Fig. 4 :

 4 Fig. 4: Plots of the streamfunction isolines (colored lines) from higher values (red) to lower values (blue) over the Zapiola Drift topography iso-contours (black lines) for a small mean-flow energy (a)) and for a high mean-flow energy (b)).

Fig. 5 :

 5 Fig. 5: a) Variation of the macroscopic enstrophy Z 2 over β , case Z 2 > Z b . b) Variation of the mean-flow energy E m f with β , case Z 2 < Z b . c) Variation of the macroscopic enstrophy Z 2 with β , case Z 2 < Z b . d) Variation of the mean-flow energy E m f with β , case Z 2 < Z b .

  2 , hµ, hµ 2 and the local potential vorticity moments hq k , we introduce an intermediate variational problem where these coarse-grained fields are given as constraint:

	max ρ, ´ρ=1	S [ρ] h, h 2 , hµ, hµ 2 , hq k	k≥1	"fixed" .

  For α > 1/2, we have from Eq. (245) that β ∼ √ 5C b E -1/2 . Injecting this in Eq. (244), we gets:For α < 1/2, we have from Eq. (245) that β ∼ C α E α-1 . Injecting this in Eq. (244), we gets:For α = 1/2, we have from Eq. (245) that β ∼ C 1/2 E -1/2 1 + 1 + 20C b /C 2 α /2.Injecting this in Eq. (244), we gets:

	lim E→0	E m f E	=	1 5	(246)
	lim E→0	E m f E	= 0	(247)

In the particular case of a bi-periodic domain, i.e. with periodic boundary conditions for the velocity u, one would need to describe in addition the homogeneous part of the velocity field, which is both divergence-less and irrotational.

The actual circulation is usually defined as Γ ≡ ´∂D dl • u, where dl is a vector tangent to the domain boundary. Stokes theorem yields to Z 1 = Γ + f .

The letter "µ" appearing in the measure denoted dµ is not related to the divergent field denoted µ.

Here, the bottom topography is assumed sufficiently smooth to be considered constant over a grid site. A fluctuating topography would require further discussion.

The fact that the variable χ k have to be bounded is the reason why we set the cutoffs on the values of h n , q n and µ n .

Here, Z depends on the cutoffs introduced in subsection 3.2. But we will see that it will vanish from the expression of the entropy in the end.

Here we dropped the term log N coming from Eq. (78) as it is constant that can be discarded by redefining Ω E,{Z k } k≥0 .

Strictly speaking, the equal sign should be noted ≍ which means that the logarithm of the terms on both sides are equivalent, see e.g. Ref.[START_REF] Touchette | The large deviation approach to statistical mechanics[END_REF].

For the shallow water model, the fluid is at hydrostatic balance. Thus the pressure in the fluid is P(x, y, z,t) = P o + ρg(H + η(x, y,t)z). Then the pressure horizontal gradient is simply proportional to the interface height horizontal gradient. Hence, the geostrophic balance simply writes R 2 ∇ ⊥ η = u m f .

This change of variable is a guess guided by the fact that the QG potential vorticity is usually obtained by expanding the SW potential vorticity in the limit of small height variations minus a constant and unimportant term. Here we start by removing the unimportant constant (1 in our unit system) from the potential vorticity levels, and then perform the small scale expansion in height.

For such a bottom topography, the topography, the stream function and the potential vorticity field are all proportional to each other for any initial condition for the enstrophy Z 2 and the energy E. That is why we do not show plots of the flows for different point of the phase diagram in Fig.2. We rather choose to consider the case of the Zapiola drift in subsection 5.3 to see the effect of different value for the initial energy.

The divergent part of the velocity field can not be treated in the same way. Indeed, the operator ∆ -1/2 is less smooth than the operator ∆ -1 , and one can not derive φ = φ m f by inverting µ = ∆ 1/2 φ . One may want to use ζ = ∆ φ , but the result would be the same since ζ is not bounded (the field µ is characterized by fluctuations which are controlled by the kinetic energy, and hence by the total energy, but this is not the case for ζ ).

Acknowledgements The authors warmly thank M. Potters and A. Licari for their preliminary work on this subject during a traineeship under the supervision of FB. The research leading to these results has received funding from the European Research Council under the European Union's Seventh Framework Programme (FP7/2007-2013 Grant Agreement no. 616811) (FB and AV). We warmly thank the three referees for their very positive evaluation of our work and for the numerous remark that helped us to improve our work. The level of commitment of the three referee in reading the detail of our computations has been extremely high, and we thank them for this important work.