From ff8aa556d1c40a5139c49e41fc7269a22b30e203 Mon Sep 17 00:00:00 2001 From: Caitlin O'Connor Date: Fri, 2 Aug 2024 14:36:16 -0700 Subject: [PATCH] use a default water temp instaad of checking if weathering is active --- py_gnome/gnome/model.py | 2 +- py_gnome/gnome/ops/default_constants.py | 2 +- py_gnome/gnome/spill_container.py | 4 ++-- py_gnome/gnome/spills/release.py | 13 +++++++++---- py_gnome/gnome/spills/spill.py | 9 ++++----- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/py_gnome/gnome/model.py b/py_gnome/gnome/model.py index 0dc930f65..aa6abf98c 100644 --- a/py_gnome/gnome/model.py +++ b/py_gnome/gnome/model.py @@ -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, weathering_active = self.has_weathering) + num_released = sc.release_elements(start_time, end_time, environment=env) # initialize data - currently only weatherers do this so cycle # over weatherers collection - in future, maybe movers can also do # this diff --git a/py_gnome/gnome/ops/default_constants.py b/py_gnome/gnome/ops/default_constants.py index 0ffd097f7..1713e7ecb 100644 --- a/py_gnome/gnome/ops/default_constants.py +++ b/py_gnome/gnome/ops/default_constants.py @@ -4,7 +4,7 @@ default_salinity=1.1 default_water_density=1025 -default_water_temperature=283.15 +default_water_temperature=288.15 # 15C minimum_wind=0.01 visc_curvfit_param = 1.5e3 # units are sec^0.5 / m visc_f_ref = 0.84 \ No newline at end of file diff --git a/py_gnome/gnome/spill_container.py b/py_gnome/gnome/spill_container.py index 25c49ded2..74e95fb63 100644 --- a/py_gnome/gnome/spill_container.py +++ b/py_gnome/gnome/spill_container.py @@ -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, weathering_active=True): + def release_elements(self, start_time, end_time, environment=None): """ :param start_time: -- beginning of the release :param end_time: -- end of the release. @@ -892,7 +892,7 @@ def release_elements(self, start_time, end_time, environment=None, weathering_ac if not spill.on: continue - num_rel = spill.release_elements(self, start_time, end_time, environment=environment, weathering_active=weathering_active) + num_rel = spill.release_elements(self, start_time, end_time, environment=environment) if num_rel > 0: # update 'spill_num' ArrayType's initial_value so it # corresponds with spill number for this set of released diff --git a/py_gnome/gnome/spills/release.py b/py_gnome/gnome/spills/release.py index 56f429787..dbd648554 100644 --- a/py_gnome/gnome/spills/release.py +++ b/py_gnome/gnome/spills/release.py @@ -36,6 +36,7 @@ from gnome.array_types import gat from gnome.utilities.plume import Plume, PlumeGenerator + from gnome.outputters import NetCDFOutput from gnome.gnomeobject import GnomeId from gnome.environment.timeseries_objects_base import (TimeseriesData, @@ -45,7 +46,8 @@ from gnome.weatherers.spreading import FayGravityViscous from gnome.environment import Water from gnome.constants import gravity -from gnome.exceptions import ReferencedObjectNotSet +from gnome.ops import default_constants +#from gnome.exceptions import ReferencedObjectNotSet from .initializers import (InitRiseVelFromDropletSizeFromDist, InitRiseVelFromDist) @@ -407,10 +409,12 @@ def initialize_LEs_post_substance(self, to_rel, sc, start_time, end_time, enviro if sc.substance.is_weatherable: if environment['water'] is not None: water = environment['water'] + temp_k=water.get('temperature') else: - raise ReferencedObjectNotSet("water object not found in environment collection") + temp_k = default_constants.default_water_temperature + #raise ReferencedObjectNotSet("water object not found in environment collection") - visc = sc.substance.kvis_at_temp(temp_k=water.get('temperature')) + visc = sc.substance.kvis_at_temp(temp_k) thickness_limit = FayGravityViscous.get_thickness_limit(visc) sc['fay_area'][sl] = (sc['init_mass'][sl] / sc['density'][sl]) / thickness_limit @@ -622,7 +626,8 @@ def initialize_LEs_post_substance(self, to_rel, sc, start_time, end_time, enviro if environment['water'] is not None: water = environment['water'] else: - raise ReferencedObjectNotSet("water object not found in environment collection") + water = Water(default_constants.default_water_temperature) + #raise ReferencedObjectNotSet("water object not found in environment collection") spread = FayGravityViscous(water=water) spread.prepare_for_model_run(sc) diff --git a/py_gnome/gnome/spills/spill.py b/py_gnome/gnome/spills/spill.py index d163d28dd..807947f0c 100644 --- a/py_gnome/gnome/spills/spill.py +++ b/py_gnome/gnome/spills/spill.py @@ -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, weathering_active=True): + def release_elements(self, sc, start_time, end_time, environment=None): """ Releases and partially initializes new LEs Note: this will have to be updated if we allow backwards runs for continuous spills @@ -457,10 +457,9 @@ def release_elements(self, sc, start_time, end_time, environment=None, weatherin self.substance.initialize_LEs(to_rel, sc, environment=environment) - if weathering_active: - self.release.initialize_LEs_post_substance(to_rel, sc, - start_time, end_time, - environment=environment) + self.release.initialize_LEs_post_substance(to_rel, sc, + start_time, end_time, + environment=environment) return to_rel