Skip to content

Commit

Permalink
Merge pull request #28 from firedrakeproject/fix_NL_boolean_argument
Browse files Browse the repository at this point in the history
Fix boolean argument in Nair Lauritzen divergent
  • Loading branch information
tommbendall authored Sep 9, 2024
2 parents 8fcc1ef + 86c9427 commit aeb3510
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
21 changes: 11 additions & 10 deletions case_studies/transport/nair_lauritzen_divergent.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@
nair_lauritzen_divergent_defaults = {
'initial_conditions': 'slotted_cylinder', # one of 'slotted_cylinder',
# 'cosine_bells' or 'gaussian'
'background_flow': True, # whether background flow is applied
'ncells_per_edge': 16, # num points per icosahedron edge (ref level 4)
'dt': 900.0, # 15 minutes
'tmax': 12.*24.*60.*60., # 12 days
'dumpfreq': 288, # once every 3 days with default values
'no_background_flow': False, # option to remove the background flow
'ncells_per_edge': 16, # num points per icosahedron edge (ref level 4)
'dt': 900.0, # 15 minutes
'tmax': 12.*24.*60.*60., # 12 days
'dumpfreq': 288, # once every 3 days with default values
'dirname': 'nair_lauritzen_divergent'
}


def nair_lauritzen_divergent(
initial_conditions=nair_lauritzen_divergent_defaults['initial_conditions'],
background_flow=nair_lauritzen_divergent_defaults['background_flow'],
no_background_flow=nair_lauritzen_divergent_defaults['no_background_flow'],
ncells_per_edge=nair_lauritzen_divergent_defaults['ncells_per_edge'],
dt=nair_lauritzen_divergent_defaults['dt'],
tmax=nair_lauritzen_divergent_defaults['tmax'],
Expand Down Expand Up @@ -101,7 +101,7 @@ def nair_lauritzen_divergent(
lamda, theta, _ = lonlatr_from_xyz(xyz[0], xyz[1], xyz[2])

# Set up the divergent, time-varying, velocity field
if background_flow:
if not no_background_flow:
def u_t(t):
k = 5.*radius/tau
u_background = 2*pi*radius/tau
Expand Down Expand Up @@ -208,10 +208,11 @@ def u_t(t):
default=nair_lauritzen_divergent_defaults['initial_conditions']
)
parser.add_argument(
'--background_flow',
help="Whether the transporting velocity includes a background flow",
'--no_background_flow',
help="Whether to remove the background flow of the transporting velocity. "
+ "This defaults to False, which means there is a background flow.",
type=bool,
default=nair_lauritzen_divergent_defaults['background_flow']
default=nair_lauritzen_divergent_defaults['no_background_flow']
)
parser.add_argument(
'--ncells_per_edge',
Expand Down
4 changes: 1 addition & 3 deletions case_studies/transport/test_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def test_four_part_sbr():
def test_nair_lauritzen_divergent_cylinder():
nair_lauritzen_divergent(
initial_conditions='slotted_cylinder',
background_flow=True,
ncells_per_edge=3,
dt=900.0,
tmax=1800.0,
Expand All @@ -31,7 +30,7 @@ def test_nair_lauritzen_divergent_cylinder():
def test_nair_lauritzen_divergent_cosine():
nair_lauritzen_divergent(
initial_conditions='cosine_bells',
background_flow=False,
no_background_flow=True,
ncells_per_edge=3,
dt=900.0,
tmax=1800.0,
Expand All @@ -43,7 +42,6 @@ def test_nair_lauritzen_divergent_cosine():
def test_nair_lauritzen_divergent_gaussian():
nair_lauritzen_divergent(
initial_conditions='gaussian',
background_flow=True,
ncells_per_edge=3,
dt=900.0,
tmax=1800.0,
Expand Down

0 comments on commit aeb3510

Please sign in to comment.