Skip to content

Commit

Permalink
Merge branch 'main' into tim_FML_notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
tommbendall authored Dec 19, 2024
2 parents e821829 + e305589 commit 34bc22c
Show file tree
Hide file tree
Showing 41 changed files with 1,460 additions and 301 deletions.
9 changes: 2 additions & 7 deletions examples/compressible_euler/unsaturated_bubble.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,16 +216,11 @@ def unsaturated_bubble(
R_v = eqns.parameters.R_v
epsilon = R_d / R_v

# make expressions for determining water_v0
exner = thermodynamics.exner_pressure(eqns.parameters, rho_averaged, theta0)
p = thermodynamics.p(eqns.parameters, exner)
T = thermodynamics.T(eqns.parameters, theta0, exner, water_v0)
r_v_expr = thermodynamics.r_v(eqns.parameters, rel_hum, T, p)

# make expressions to evaluate residual
exner_expr = thermodynamics.exner_pressure(eqns.parameters, rho_averaged, theta0)
p_expr = thermodynamics.p(eqns.parameters, exner_expr)
T_expr = thermodynamics.T(eqns.parameters, theta0, exner_expr, water_v0)
water_v_expr = thermodynamics.r_v(eqns.parameters, rel_hum, T_expr, p_expr)
rel_hum_expr = thermodynamics.RH(eqns.parameters, water_v0, T_expr, p_expr)
rel_hum_eval = Function(Vt)

Expand All @@ -247,7 +242,7 @@ def unsaturated_bubble(

# first solve for r_v
for _ in range(max_inner_solve_count):
water_v_eval.interpolate(r_v_expr)
water_v_eval.interpolate(water_v_expr)
water_v0.assign(water_v0 * (1 - delta) + delta * water_v_eval)

# compute theta_vd
Expand Down
19 changes: 18 additions & 1 deletion gusto/core/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ def __setattr__(self, name, value):

# Almost all parameters should be Constants -- but there are some
# specific exceptions which should be kept as integers
if type(value) in [float, int] and name not in ['dumpfreq', 'pddumpfreq', 'chkptfreq']:
non_constants = [
'dumpfreq', 'pddumpfreq', 'chkptfreq',
'fixed_subcycles', 'max_subcycles', 'subcycle_by_courant'
]
if type(value) in [float, int] and name not in non_constants:
object.__setattr__(self, name, Constant(value))
else:
object.__setattr__(self, name, value)
Expand Down Expand Up @@ -265,6 +269,19 @@ class BoundaryLayerParameters(Configuration):
mu = 100. # Interior penalty coefficient for vertical diffusion


class HeldSuarezParameters(Configuration):
"""
Parameters used in the default configuration for the Held Suarez test case.
"""
T0stra = 200 # Stratosphere temp
T0surf = 315 # Surface temperature at equator
T0horiz = 60 # Equator to pole temperature difference
T0vert = 10 # Stability parameter
sigmab = 0.7 # Height of the boundary layer
tau_d = 40 * 24 * 60 * 60 # 40 day time scale
tau_u = 4 * 24 * 60 * 60 # 4 day timescale


class SubcyclingOptions(Configuration):
"""
Describes the process of subcycling a time discretisation, by dividing the
Expand Down
9 changes: 6 additions & 3 deletions gusto/core/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

from gusto.core.coordinates import Coordinates
from gusto.core.function_spaces import Spaces, check_degree_args
from firedrake import (Constant, SpatialCoordinate, sqrt, CellNormal, cross,
inner, grad, VectorFunctionSpace, Function, FunctionSpace,
perp)
from firedrake import (
Constant, SpatialCoordinate, sqrt, CellNormal, cross, inner, grad,
VectorFunctionSpace, Function, FunctionSpace, perp, curl
)
import numpy as np


Expand Down Expand Up @@ -124,12 +125,14 @@ def __init__(self, mesh, dt, family, degree=None,
V = VectorFunctionSpace(mesh, "DG", sphere_degree)
self.outward_normals = Function(V).interpolate(CellNormal(mesh))
self.perp = lambda u: cross(self.outward_normals, u)
self.divperp = lambda u: inner(self.outward_normals, curl(u))
else:
kvec = [0.0]*dim
kvec[dim-1] = 1.0
self.k = Constant(kvec)
if dim == 2:
self.perp = perp
self.divperp = lambda u: -u[0].dx(1) + u[1].dx(0)

# -------------------------------------------------------------------- #
# Construct information relating to height/radius
Expand Down
Loading

0 comments on commit 34bc22c

Please sign in to comment.