Skip to content

Commit

Permalink
add plotting scripts and figures for all working examples
Browse files Browse the repository at this point in the history
  • Loading branch information
tommbendall committed Sep 8, 2024
1 parent c88463f commit 0ba3372
Show file tree
Hide file tree
Showing 23 changed files with 54 additions and 52 deletions.
2 changes: 1 addition & 1 deletion examples/boussinesq/skamarock_klemp_compressible.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def skamarock_klemp_compressible_bouss(

# I/O
output = OutputParameters(
dirname=dirname, dumpfreq=dumpfreq, dump_vtus=True, dump_nc=True,
dirname=dirname, dumpfreq=dumpfreq, dump_vtus=True, dump_nc=False,
)
# list of diagnostic fields, each defined in a class in diagnostics.py
diagnostic_fields = [CourantNumber(), Divergence(), Perturbation('b')]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,28 @@
)
from gusto import (
Domain, IO, OutputParameters, SemiImplicitQuasiNewton, SSPRK3, DGUpwind,
TrapeziumRule, SUPGOptions, CompressibleKineticEnergy, PotentialEnergy,
CompressibleParameters, CompressibleEulerEquations, CompressibleSolver,
TrapeziumRule, SUPGOptions, lonlatr_from_xyz, CompressibleParameters,
CompressibleEulerEquations, CompressibleSolver, ZonalComponent,
compressible_hydrostatic_balance, Perturbation, GeneralCubedSphereMesh,
lonlatr_from_xyz
)

dcmip_3_1_meanflow_defaults = {
dcmip_3_1_gravity_wave_defaults = {
'ncells_per_edge': 8,
'nlayers': 10,
'dt': 100.0,
'dt': 50.0,
'tmax': 3600.,
'dumpfreq': 9,
'dirname': 'dcmip_3_1_meanflow'
'dirname': 'dcmip_3_1_gravity_wave'
}


def dcmip_3_1_meanflow(
ncells_per_edge=dcmip_3_1_meanflow_defaults['ncells_per_edge'],
nlayers=dcmip_3_1_meanflow_defaults['nlayers'],
dt=dcmip_3_1_meanflow_defaults['dt'],
tmax=dcmip_3_1_meanflow_defaults['tmax'],
dumpfreq=dcmip_3_1_meanflow_defaults['dumpfreq'],
dirname=dcmip_3_1_meanflow_defaults['dirname']
def dcmip_3_1_gravity_wave(
ncells_per_edge=dcmip_3_1_gravity_wave_defaults['ncells_per_edge'],
nlayers=dcmip_3_1_gravity_wave_defaults['nlayers'],
dt=dcmip_3_1_gravity_wave_defaults['dt'],
tmax=dcmip_3_1_gravity_wave_defaults['tmax'],
dumpfreq=dcmip_3_1_gravity_wave_defaults['dumpfreq'],
dirname=dcmip_3_1_gravity_wave_defaults['dirname']
):

# ------------------------------------------------------------------------ #
Expand Down Expand Up @@ -89,12 +88,10 @@ def dcmip_3_1_meanflow(

# I/O
output = OutputParameters(
dirname=dirname,
dumpfreq=dumpfreq,
dirname=dirname, dumpfreq=dumpfreq, dump_vtus=False, dump_nc=True
)
diagnostic_fields = [
Perturbation('theta'), Perturbation('rho'),
CompressibleKineticEnergy(), PotentialEnergy(eqns)
Perturbation('theta'), Perturbation('rho'), ZonalComponent('u'),
]
io = IO(domain, output, diagnostic_fields=diagnostic_fields)

Expand Down Expand Up @@ -197,38 +194,38 @@ def dcmip_3_1_meanflow(
'--ncells_per_edge',
help="The number of cells per panel edge of the cubed-sphere.",
type=int,
default=dcmip_3_1_meanflow_defaults['ncells_per_edge']
default=dcmip_3_1_gravity_wave_defaults['ncells_per_edge']
)
parser.add_argument(
'--nlayers',
help="The number of layers for the mesh.",
type=int,
default=dcmip_3_1_meanflow_defaults['nlayers']
default=dcmip_3_1_gravity_wave_defaults['nlayers']
)
parser.add_argument(
'--dt',
help="The time step in seconds.",
type=float,
default=dcmip_3_1_meanflow_defaults['dt']
default=dcmip_3_1_gravity_wave_defaults['dt']
)
parser.add_argument(
"--tmax",
help="The end time for the simulation in seconds.",
type=float,
default=dcmip_3_1_meanflow_defaults['tmax']
default=dcmip_3_1_gravity_wave_defaults['tmax']
)
parser.add_argument(
'--dumpfreq',
help="The frequency at which to dump field output.",
type=int,
default=dcmip_3_1_meanflow_defaults['dumpfreq']
default=dcmip_3_1_gravity_wave_defaults['dumpfreq']
)
parser.add_argument(
'--dirname',
help="The name of the directory to write to.",
type=str,
default=dcmip_3_1_meanflow_defaults['dirname']
default=dcmip_3_1_gravity_wave_defaults['dirname']
)
args, unknown = parser.parse_known_args()

dcmip_3_1_meanflow(**vars(args))
dcmip_3_1_gravity_wave(**vars(args))
12 changes: 6 additions & 6 deletions examples/compressible_euler/test_compressible_euler_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ def make_dirname(test_name):
return f'pytest_{test_name}'


def test_dcmip_3_1_meanflow():
from dcmip_3_1_meanflow_quads import dcmip_3_1_meanflow
test_name = 'dcmip_3_1_meanflow'
dcmip_3_1_meanflow(
def test_dcmip_3_1_gravity_wave():
from dcmip_3_1_gravity_wave import dcmip_3_1_gravity_wave
test_name = 'dcmip_3_1_gravity_wave'
dcmip_3_1_gravity_wave(
ncells_per_edge=4,
nlayers=4,
dt=100,
Expand All @@ -24,8 +24,8 @@ def test_dcmip_3_1_meanflow():


@pytest.mark.parallel(nprocs=2)
def test_dcmip_3_1_meanflow_parallel():
test_dcmip_3_1_meanflow()
def test_dcmip_3_1_gravity_wave_parallel():
test_dcmip_3_1_gravity_wave()


def test_dry_bryan_fritsch():
Expand Down
9 changes: 6 additions & 3 deletions examples/shallow_water/linear_williamson_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
from gusto import (
Domain, IO, OutputParameters, SemiImplicitQuasiNewton, DefaultTransport,
ForwardEuler, SteadyStateError, ShallowWaterParameters,
LinearShallowWaterEquations, GeneralIcosahedralSphereMesh
LinearShallowWaterEquations, GeneralIcosahedralSphereMesh,
ZonalComponent, MeridionalComponent, RelativeVorticity
)

linear_williamson_2_defaults = {
Expand Down Expand Up @@ -63,9 +64,11 @@ def linear_williamson_2(

# I/O
output = OutputParameters(
dirname=dirname, dumpfreq=dumpfreq,
dirname=dirname, dumpfreq=dumpfreq, dump_nc=False, dump_vtus=True
)
diagnostic_fields = [SteadyStateError('u'), SteadyStateError('D')]
diagnostic_fields = [SteadyStateError('u'), SteadyStateError('D'),
ZonalComponent('u'), MeridionalComponent('u'),
RelativeVorticity()]
io = IO(domain, output, diagnostic_fields=diagnostic_fields)

# Transport schemes
Expand Down
20 changes: 8 additions & 12 deletions examples/shallow_water/moist_convective_williamson_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@
from gusto import (
Domain, IO, OutputParameters, SemiImplicitQuasiNewton, SSPRK3, DGUpwind,
TrapeziumRule, ShallowWaterParameters, ShallowWaterEquations,
CourantNumber, RelativeVorticity, PotentialVorticity,
SteadyStateError, ShallowWaterKineticEnergy, ShallowWaterPotentialEnergy,
ShallowWaterPotentialEnstrophy, lonlatr_from_xyz, DG1Limiter, InstantRain,
MoistConvectiveSWSolver, ForwardEuler, SWSaturationAdjustment,
WaterVapour, CloudWater, Rain, GeneralIcosahedralSphereMesh,
xyz_vector_from_lonlatr
ZonalComponent, MeridionalComponent, SteadyStateError, lonlatr_from_xyz,
DG1Limiter, InstantRain, MoistConvectiveSWSolver, ForwardEuler,
RelativeVorticity, SWSaturationAdjustment, WaterVapour, CloudWater, Rain,
GeneralIcosahedralSphereMesh, xyz_vector_from_lonlatr
)

moist_convect_williamson_2_defaults = {
Expand Down Expand Up @@ -93,15 +91,13 @@ def moist_convect_williamson_2(

# IO
output = OutputParameters(
dirname=dirname, dumpfreq=dumpfreq, dump_nc=True, dump_vtus=True,
dirname=dirname, dumpfreq=dumpfreq, dump_nc=False, dump_vtus=True,
dumplist_latlon=['D', 'D_error']
)
diagnostic_fields = [
CourantNumber(), RelativeVorticity(), PotentialVorticity(),
ShallowWaterKineticEnergy(), ShallowWaterPotentialEnergy(parameters),
ShallowWaterPotentialEnstrophy(), SteadyStateError('u'),
SteadyStateError('D'), SteadyStateError('water_vapour'),
SteadyStateError('cloud_water')
SteadyStateError('u'), SteadyStateError('D'),
SteadyStateError('water_vapour'), ZonalComponent('u'),
MeridionalComponent('u'), RelativeVorticity()
]
io = IO(domain, output, diagnostic_fields=diagnostic_fields)

Expand Down
9 changes: 6 additions & 3 deletions examples/shallow_water/moist_thermal_williamson_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
Domain, IO, OutputParameters, Timestepper, RK4, DGUpwind,
ShallowWaterParameters, ShallowWaterEquations, Sum,
lonlatr_from_xyz, InstantRain, SWSaturationAdjustment, WaterVapour,
CloudWater, Rain, GeneralIcosahedralSphereMesh
CloudWater, Rain, GeneralIcosahedralSphereMesh, RelativeVorticity,
ZonalComponent, MeridionalComponent
)

moist_thermal_williamson_5_defaults = {
Expand Down Expand Up @@ -106,9 +107,11 @@ def moist_thermal_williamson_5(
# I/O
output = OutputParameters(
dirname=dirname, dumplist_latlon=['D'], dumpfreq=dumpfreq,
dump_vtus=False, dump_nc=True
dump_vtus=True, dump_nc=False,
dumplist=['D', 'b', 'water_vapour', 'cloud_water']
)
diagnostic_fields = [Sum('D', 'topography')]
diagnostic_fields = [Sum('D', 'topography'), RelativeVorticity(),
ZonalComponent('u'), MeridionalComponent('u')]
io = IO(domain, output, diagnostic_fields=diagnostic_fields)

# Physics ------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions examples/shallow_water/thermal_williamson_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def thermal_williamson_2(
# IO
output = OutputParameters(
dirname=dirname, dumpfreq=dumpfreq, dumplist_latlon=['D', 'D_error'],
dump_vtus=False, dump_nc=True
)

diagnostic_fields = [
Expand Down
8 changes: 5 additions & 3 deletions examples/shallow_water/williamson_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
from gusto import (
Domain, IO, OutputParameters, SemiImplicitQuasiNewton, SSPRK3, DGUpwind,
TrapeziumRule, ShallowWaterParameters, ShallowWaterEquations, Sum,
lonlatr_from_xyz, GeneralIcosahedralSphereMesh
lonlatr_from_xyz, GeneralIcosahedralSphereMesh, ZonalComponent,
MeridionalComponent, RelativeVorticity
)

williamson_5_defaults = {
Expand Down Expand Up @@ -75,9 +76,10 @@ def williamson_5(
# I/O
output = OutputParameters(
dirname=dirname, dumplist_latlon=['D'], dumpfreq=dumpfreq,
dump_vtus=True, dump_nc=False
dump_vtus=True, dump_nc=False, dumplist=['D', 'topography']
)
diagnostic_fields = [Sum('D', 'topography')]
diagnostic_fields = [Sum('D', 'topography'), RelativeVorticity(),
MeridionalComponent('u'), ZonalComponent('u')]
io = IO(domain, output, diagnostic_fields=diagnostic_fields)

# Transport schemes
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figures/shallow_water/shallow_water_1d_wave.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figures/shallow_water/williamson_2_final.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figures/shallow_water/williamson_2_initial.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figures/shallow_water/williamson_5_final.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figures/shallow_water/williamson_5_initial.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0ba3372

Please sign in to comment.