-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Linear boussinesq #491
Merged
Merged
Linear boussinesq #491
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2bd560a
linear Boussinesq equation class and example file
jshipton f223ca0
fix lint but not sure what the deal is with this term
jshipton 250a29e
Merge branch 'main' into linear_boussinesq
tommbendall e87a83d
Merge branch 'main' of https://github.com/firedrakeproject/gusto into…
jshipton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
""" | ||
The gravity wave test case of Skamarock and Klemp (1994), solved using the | ||
incompressible Boussinesq equations. | ||
|
||
Buoyancy is transported using SUPG. | ||
""" | ||
|
||
from gusto import * | ||
from firedrake import (PeriodicIntervalMesh, ExtrudedMesh, | ||
sin, SpatialCoordinate, Function, pi) | ||
import sys | ||
|
||
# ---------------------------------------------------------------------------- # | ||
# Test case parameters | ||
# ---------------------------------------------------------------------------- # | ||
|
||
dt = 0.5 | ||
L = 3.0e5 # Domain length | ||
H = 1.0e4 # Height position of the model top | ||
|
||
if '--running-tests' in sys.argv: | ||
tmax = dt | ||
dumpfreq = 1 | ||
columns = 30 # number of columns | ||
nlayers = 5 # horizontal layers | ||
|
||
else: | ||
tmax = 3600. | ||
dumpfreq = int(tmax / (2*dt)) | ||
columns = 300 # number of columns | ||
nlayers = 10 # horizontal layers | ||
|
||
# ---------------------------------------------------------------------------- # | ||
# Set up model objects | ||
# ---------------------------------------------------------------------------- # | ||
|
||
# Domain | ||
m = PeriodicIntervalMesh(columns, L) | ||
mesh = ExtrudedMesh(m, layers=nlayers, layer_height=H/nlayers) | ||
domain = Domain(mesh, dt, 'CG', 1) | ||
|
||
# Equation | ||
parameters = BoussinesqParameters(cs=300) | ||
eqns = LinearBoussinesqEquations(domain, parameters) | ||
|
||
# I/O | ||
output = OutputParameters(dirname='skamarock_klemp_linear') | ||
# list of diagnostic fields, each defined in a class in diagnostics.py | ||
diagnostic_fields = [CourantNumber(), Divergence(), Perturbation('b')] | ||
io = IO(domain, output, diagnostic_fields=diagnostic_fields) | ||
|
||
# Transport schemes | ||
b_opts = SUPGOptions() | ||
transport_methods = [DGUpwind(eqns, "p"), | ||
DGUpwind(eqns, "b", ibp=b_opts.ibp)] | ||
|
||
|
||
# Time stepper | ||
stepper = Timestepper(eqns, RK4(domain), io, spatial_methods=transport_methods) | ||
|
||
# ---------------------------------------------------------------------------- # | ||
# Initial conditions | ||
# ---------------------------------------------------------------------------- # | ||
|
||
b0 = stepper.fields("b") | ||
p0 = stepper.fields("p") | ||
|
||
# spaces | ||
Vb = b0.function_space() | ||
Vp = p0.function_space() | ||
|
||
x, z = SpatialCoordinate(mesh) | ||
|
||
# first setup the background buoyancy profile | ||
# z.grad(bref) = N**2 | ||
N = parameters.N | ||
bref = z*(N**2) | ||
# interpolate the expression to the function | ||
b_b = Function(Vb).interpolate(bref) | ||
|
||
# setup constants | ||
a = 5.0e3 | ||
deltab = 1.0e-2 | ||
b_pert = deltab*sin(pi*z/H)/(1 + (x - L/2)**2/a**2) | ||
# interpolate the expression to the function | ||
b0.interpolate(b_b + b_pert) | ||
|
||
p_b = Function(Vp) | ||
boussinesq_hydrostatic_balance(eqns, b_b, p_b) | ||
p0.assign(p_b) | ||
|
||
# set the background buoyancy | ||
stepper.set_reference_profiles([('p', p_b), ('b', b_b)]) | ||
|
||
# ---------------------------------------------------------------------------- # | ||
# Run | ||
# ---------------------------------------------------------------------------- # | ||
stepper.run(t=0, tmax=tmax) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the results look odd when running incompressible Boussinesq with RK4 but are fine with SIQN - this comment is about the forcing term which makes me suspicious...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be related to issues @atb1995 saw when having a divergence term in the shallow-water equations? And in
forcing.py
we ensure that the incompressibility term is treated implicitly. So would we expect this to work with an explicit time stepper?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd assume it should work fine for small enough
dt
- the issue I was having was that the range of stabledt
for the IMEX RK schemes was being limited by effectively treating adiv(u)
term explicitly. You could try using IMEX RK, with the div term labeled first explicitly, then implicitly and see if you see the same issues when it is explicit (but not when it is implicit). Or just use smallerdt
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, it's not that - sorry, I should have been clearer. The results don't show instability - they're just wrong. And the reason is that this isn't really an evolution equation for the pressure. What we're trying to do is solve for the pressure that gives us a non-divergent velocity. When we use the SIQN time stepper, the incompressible term is implicit and, as the comment here says, we overwrite the pressure rather than updating it.