-
Notifications
You must be signed in to change notification settings - Fork 11
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
Coupled transport #415
Coupled transport #415
Changes from all commits
d3dca64
01883ef
cf99916
82a313f
6e789f0
e967b7a
cf67da5
a459916
95bbc2e
5efcaf4
8566d10
f316ef9
7636609
74f1c91
89b1191
6c5f493
1f72c1f
f750f57
3260258
0bc261f
6be702c
e99818b
783213f
90642ef
c96900c
1d53ca5
ff3af57
b151e54
dc70f40
8b503e3
451000d
a3c5e7b
f70f4d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
""" | ||
Tests the CoupledTransportEquation class. | ||
Two tracers are transported using combinations of advective and | ||
conservative forms. The tracers are set to be a mixing ratio when | ||
using the advective form and a density for the conservative form. | ||
|
||
""" | ||
|
||
from firedrake import norm | ||
from gusto import * | ||
import pytest | ||
|
||
|
||
def run(timestepper, tmax, f_end): | ||
timestepper.run(0, tmax) | ||
norm1 = norm(timestepper.fields("f1") - f_end) / norm(f_end) | ||
norm2 = norm(timestepper.fields("f2") - f_end) / norm(f_end) | ||
return norm1, norm2 | ||
|
||
|
||
@pytest.mark.parametrize("geometry", ["slice", "sphere"]) | ||
@pytest.mark.parametrize("equation_form1", ["advective", "continuity"]) | ||
@pytest.mark.parametrize("equation_form2", ["advective", "continuity"]) | ||
def test_coupled_transport_scalar(tmpdir, geometry, equation_form1, equation_form2, tracer_setup): | ||
setup = tracer_setup(tmpdir, geometry) | ||
domain = setup.domain | ||
|
||
if equation_form1 == "advective": | ||
tracer1 = ActiveTracer(name='f1', space='DG', | ||
variable_type=TracerVariableType.mixing_ratio, | ||
transport_eqn=TransportEquationType.advective) | ||
else: | ||
tracer1 = ActiveTracer(name='f1', space='DG', | ||
variable_type=TracerVariableType.density, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest that you keep |
||
transport_eqn=TransportEquationType.conservative) | ||
|
||
if equation_form2 == "advective": | ||
tracer2 = ActiveTracer(name='f2', space='DG', | ||
variable_type=TracerVariableType.mixing_ratio, | ||
transport_eqn=TransportEquationType.advective) | ||
else: | ||
tracer2 = ActiveTracer(name='f2', space='DG', | ||
variable_type=TracerVariableType.density, | ||
transport_eqn=TransportEquationType.conservative) | ||
|
||
tracers = [tracer1, tracer2] | ||
|
||
V = domain.spaces("HDiv") | ||
eqn = CoupledTransportEquation(domain, active_tracers=tracers, Vu=V) | ||
|
||
transport_scheme = SSPRK3(domain) | ||
transport_method = [DGUpwind(eqn, 'f1'), DGUpwind(eqn, 'f2')] | ||
|
||
timestepper = PrescribedTransport(eqn, transport_scheme, setup.io, transport_method) | ||
|
||
# Initial conditions | ||
timestepper.fields("f1").interpolate(setup.f_init) | ||
timestepper.fields("f2").interpolate(setup.f_init) | ||
timestepper.fields("u").project(setup.uexpr) | ||
|
||
error1, error2 = run(timestepper, setup.tmax, setup.f_end) | ||
assert error1 < setup.tol, \ | ||
'The transport error for tracer 1 is greater than the permitted tolerance' | ||
assert error2 < setup.tol, \ | ||
'The transport error for tracer 2 is greater than the permitted tolerance' |
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.
This is great, I think it's the right idea to test these combinations