Skip to content

Commit

Permalink
check for active weathering before trying to calculate spreading
Browse files Browse the repository at this point in the history
  • Loading branch information
coconnor8 committed Aug 1, 2024
1 parent d263aea commit 5131ca9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion py_gnome/gnome/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,7 @@ def release_elements(self, start_time, end_time):
env = self.compile_env()
for sc in self.spills.items():
# release particles
num_released = sc.release_elements(start_time, end_time, environment=env)
num_released = sc.release_elements(start_time, end_time, environment=env, weathering_active = self.has_weathering)
# initialize data - currently only weatherers do this so cycle
# over weatherers collection - in future, maybe movers can also do
# this
Expand Down
4 changes: 2 additions & 2 deletions py_gnome/gnome/spill_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ def _get_fate_mask(self, fate):
w_mask = np.logical_and(w_mask, self['mass'] > 0.0)
return w_mask

def release_elements(self, start_time, end_time, environment=None):
def release_elements(self, start_time, end_time, environment=None, weathering_active=True):
"""
:param start_time: -- beginning of the release
:param end_time: -- end of the release.
Expand All @@ -892,7 +892,7 @@ def release_elements(self, start_time, end_time, environment=None):
if not spill.on:
continue

num_rel = spill.release_elements(self, start_time, end_time, environment=environment)
num_rel = spill.release_elements(self, start_time, end_time, environment=environment, weathering_active=weathering_active)
if num_rel > 0:
# update 'spill_num' ArrayType's initial_value so it
# corresponds with spill number for this set of released
Expand Down
19 changes: 10 additions & 9 deletions py_gnome/gnome/spills/spill.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ def prepare_for_model_run(self, timestep):
'''
self.release.prepare_for_model_run(timestep)

def release_elements(self, sc, start_time, end_time, environment=None):
def release_elements(self, sc, start_time, end_time, environment=None, weathering_active=True):
"""
Releases and partially initializes new LEs
Note: this will have to be updated if we allow backwards runs for continuous spills
Expand All @@ -457,9 +457,10 @@ def release_elements(self, sc, start_time, end_time, environment=None):

self.substance.initialize_LEs(to_rel, sc, environment=environment)

self.release.initialize_LEs_post_substance(to_rel, sc,
start_time, end_time,
environment=environment)
if weathering_active:
self.release.initialize_LEs_post_substance(to_rel, sc,
start_time, end_time,
environment=environment)

return to_rel

Expand Down Expand Up @@ -520,7 +521,7 @@ def _setup_spill(release,
spill.substance.windage_persist = windage_persist

return spill

def point_line_spill(num_elements,
start_position,
release_time,
Expand Down Expand Up @@ -584,7 +585,7 @@ def point_line_spill(num_elements,
if len(start_position) == 2:
start_position = *start_position[:2], 0
if end_position is not None and len(end_position) == 2:
end_position = (*end_position[:2], 0)
end_position = (*end_position[:2], 0)

release = PointLineRelease(release_time=release_time,
start_position=start_position,
Expand All @@ -604,7 +605,7 @@ def point_line_spill(num_elements,
)


return spill
return spill

def surface_point_line_spill(num_elements,
start_position,
Expand Down Expand Up @@ -907,7 +908,7 @@ def spatial_release_spill(start_positions,
)

return spill

def polygon_release_spill(filename,
release_time=None,
substance=None,
Expand All @@ -926,7 +927,7 @@ def polygon_release_spill(filename,
release = PolygonRelease(filename = filename,
release_time=release_time,
name=name)

spill = _setup_spill(release=release,
water=water,
substance=substance,
Expand Down

0 comments on commit 5131ca9

Please sign in to comment.