diff --git a/examples/compressible/skamarock_klemp_hydrostatic.py b/examples/compressible/skamarock_klemp_hydrostatic.py index 36b500540..9988a6d72 100644 --- a/examples/compressible/skamarock_klemp_hydrostatic.py +++ b/examples/compressible/skamarock_klemp_hydrostatic.py @@ -39,10 +39,9 @@ domain = Domain(mesh, dt, "RTCF", 1) # Equation -parameters = CompressibleParameters() -Omega = as_vector((0., 0., 0.5e-4)) +parameters = CompressibleParameters(Omega=0.5e-4) balanced_pg = as_vector((0., -1.0e-4*20, 0.)) -eqns = CompressibleEulerEquations(domain, parameters, Omega=Omega, +eqns = CompressibleEulerEquations(domain, parameters, extra_terms=[("u", balanced_pg)]) # I/O diff --git a/gusto/core/configuration.py b/gusto/core/configuration.py index 5aebf5a33..252f25187 100644 --- a/gusto/core/configuration.py +++ b/gusto/core/configuration.py @@ -114,6 +114,7 @@ class BoussinesqParameters(Configuration): g = 9.810616 N = 0.01 # Brunt-Vaisala frequency (1/s) cs = 340 # sound speed (for compressible case) (m/s) + Omega = None class CompressibleParameters(Configuration): @@ -136,6 +137,7 @@ class CompressibleParameters(Configuration): w_sat2 = -17.27 # second const. in Teten's formula (no units) w_sat3 = 35.86 # third const. in Teten's formula (K) w_sat4 = 610.9 # fourth const. in Teten's formula (Pa) + Omega = None # Rotation rate class ShallowWaterParameters(Configuration): diff --git a/gusto/equations/boussinesq_equations.py b/gusto/equations/boussinesq_equations.py index eae09369e..0711259e1 100644 --- a/gusto/equations/boussinesq_equations.py +++ b/gusto/equations/boussinesq_equations.py @@ -1,6 +1,6 @@ """Defines the Boussinesq equations.""" -from firedrake import inner, dx, div, cross, split +from firedrake import inner, dx, div, cross, split, as_vector from firedrake.fml import subject from gusto.core.labels import ( time_derivative, transport, prognostic, linearisation, @@ -40,7 +40,6 @@ class BoussinesqEquations(PrognosticEquationSet): def __init__(self, domain, parameters, compressible=True, - Omega=None, space_names=None, linearisation_map='default', u_transport_option="vector_invariant_form", @@ -54,8 +53,6 @@ def __init__(self, domain, parameters, the model's physical parameters. compressible (bool, optional): flag to indicate whether the equations are compressible. Defaults to True - Omega (:class:`ufl.Expr`, optional): an expression for the planet's - rotation vector. Defaults to None. space_names (dict, optional): a dictionary of strings for names of the function spaces to use for the spatial discretisation. The keys are the names of the prognostic variables. Defaults to None @@ -191,11 +188,12 @@ def __init__(self, domain, parameters, # -------------------------------------------------------------------- # # Extra Terms (Coriolis) # -------------------------------------------------------------------- # - if Omega is not None: + if self.parameters.Omega is not None: # TODO: add linearisation - residual += coriolis(subject(prognostic( + Omega = as_vector((0, 0, self.parameters.Omega)) + coriolis_form = coriolis(subject(prognostic( inner(w, cross(2*Omega, u))*dx, 'u'), self.X)) - + residual += coriolis_form # -------------------------------------------------------------------- # # Linearise equations # -------------------------------------------------------------------- # @@ -227,7 +225,6 @@ class LinearBoussinesqEquations(BoussinesqEquations): def __init__(self, domain, parameters, compressible=True, - Omega=None, space_names=None, linearisation_map='default', u_transport_option="vector_invariant_form", @@ -241,8 +238,6 @@ def __init__(self, domain, parameters, the model's physical parameters. compressible (bool, optional): flag to indicate whether the equations are compressible. Defaults to True - Omega (:class:`ufl.Expr`, optional): an expression for the planet's - rotation vector. Defaults to None. space_names (dict, optional): a dictionary of strings for names of the function spaces to use for the spatial discretisation. The keys are the names of the prognostic variables. Defaults to None @@ -278,7 +273,6 @@ def __init__(self, domain, parameters, super().__init__(domain=domain, parameters=parameters, compressible=compressible, - Omega=Omega, space_names=space_names, linearisation_map=linearisation_map, u_transport_option=u_transport_option, diff --git a/gusto/equations/compressible_euler_equations.py b/gusto/equations/compressible_euler_equations.py index b6b89cd8c..73b80b7d6 100644 --- a/gusto/equations/compressible_euler_equations.py +++ b/gusto/equations/compressible_euler_equations.py @@ -2,7 +2,7 @@ from firedrake import ( sin, pi, inner, dx, div, cross, FunctionSpace, FacetNormal, jump, avg, dS_v, - conditional, SpatialCoordinate, split, Constant + conditional, SpatialCoordinate, split, Constant, as_vector ) from firedrake.fml import subject, replace_subject from gusto.core.labels import ( @@ -34,7 +34,7 @@ class CompressibleEulerEquations(PrognosticEquationSet): pressure. """ - def __init__(self, domain, parameters, Omega=None, sponge_options=None, + def __init__(self, domain, parameters, sponge_options=None, extra_terms=None, space_names=None, linearisation_map='default', u_transport_option="vector_invariant_form", @@ -47,8 +47,6 @@ def __init__(self, domain, parameters, Omega=None, sponge_options=None, mesh and the compatible function spaces. parameters (:class:`Configuration`, optional): an object containing the model's physical parameters. - Omega (:class:`ufl.Expr`, optional): an expression for the planet's - rotation vector. Defaults to None. sponge_options (:class:`SpongeLayerParameters`, optional): any parameters for applying a sponge layer to the upper boundary. Defaults to None. @@ -216,10 +214,12 @@ def __init__(self, domain, parameters, Omega=None, sponge_options=None, # -------------------------------------------------------------------- # # Extra Terms (Coriolis, Sponge, Diffusion and others) # -------------------------------------------------------------------- # - if Omega is not None: + if parameters.Omega is not None: # TODO: add linearisation - residual += coriolis(subject(prognostic( - inner(w, cross(2*Omega, u))*dx, "u"), self.X)) + Omega = as_vector((0, 0, parameters.Omega)) + coriolis_form = coriolis(subject(prognostic( + inner(w, cross(2*Omega, u))*dx, 'u'), self.X)) + residual += coriolis_form if sponge_options is not None: W_DG = FunctionSpace(domain.mesh, "DG", 2) @@ -279,7 +279,7 @@ class HydrostaticCompressibleEulerEquations(CompressibleEulerEquations): equations. """ - def __init__(self, domain, parameters, Omega=None, sponge=None, + def __init__(self, domain, parameters, sponge=None, extra_terms=None, space_names=None, linearisation_map='default', u_transport_option="vector_invariant_form", diffusion_options=None, @@ -291,8 +291,6 @@ def __init__(self, domain, parameters, Omega=None, sponge=None, mesh and the compatible function spaces. parameters (:class:`Configuration`, optional): an object containing the model's physical parameters. - Omega (:class:`ufl.Expr`, optional): an expression for the planet's - rotation vector. Defaults to None. sponge (:class:`ufl.Expr`, optional): an expression for a sponge layer. Defaults to None. extra_terms (:class:`ufl.Expr`, optional): any extra terms to be @@ -325,7 +323,7 @@ def __init__(self, domain, parameters, Omega=None, sponge=None, NotImplementedError: only mixing ratio tracers are implemented. """ - super().__init__(domain, parameters, Omega=Omega, sponge=sponge, + super().__init__(domain, parameters, sponge=sponge, extra_terms=extra_terms, space_names=space_names, linearisation_map=linearisation_map, u_transport_option=u_transport_option,