Skip to content

Commit

Permalink
Updating numerical tests to pass after recent bugfix in OpenOil termi…
Browse files Browse the repository at this point in the history
…nal velocities
  • Loading branch information
knutfrode committed Sep 23, 2022
1 parent 01778a1 commit 457ed0f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
12 changes: 6 additions & 6 deletions tests/models/openoil/test_oillibrary.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,14 @@ def test_dispersion():
meanlon = 4.81742
elif oil == 'SMORBUKK KONDENSAT' and windspeed == 8:
fraction_dispersed = 0.092
fraction_submerged = 0.390
fraction_evaporated = 0.473
meanlon = 4.809
fraction_submerged = 0.288
fraction_evaporated = 0.517
meanlon = 4.816
elif oil == 'SKRUGARD' and windspeed == 8:
fraction_dispersed = 0.139
fraction_submerged = 0.481
fraction_submerged = 0.418
fraction_evaporated = 0.123
meanlon = 4.819
meanlon = 4.825
else:
fraction_dispersed = -1 # not defined

Expand Down Expand Up @@ -197,7 +197,7 @@ def test_no_dispersion():
b = o.get_oil_budget()
actual_dispersed = b['mass_dispersed'] / b['mass_total']
np.testing.assert_almost_equal(actual_dispersed[-1], 0)
np.testing.assert_array_almost_equal(o.elements.lon[4:7], [4.808, 4.796, 4.8], 3)
np.testing.assert_array_almost_equal(o.elements.lon[4:7], [4.804, 4.796, 4.8], 3)


def test_biodegradation():
Expand Down
8 changes: 4 additions & 4 deletions tests/models/test_physics.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def test_vertical_mixing_plantoil_windonly(self):
o.set_config('vertical_mixing:timestep', 4)
o.run(duration=timedelta(hours=2), time_step_output=900, time_step=900)
#o.plot_vertical_distribution()
self.assertAlmostEqual(o.elements.z.min(), -49.4, 1)
self.assertAlmostEqual(o.elements.z.min(), -49.5, 1)
#######################################################


Expand All @@ -178,7 +178,7 @@ def test_vertical_mixing_plantoil_windonly(self):
o.run(duration=timedelta(hours=2),
time_step_output=1800, time_step=1800)
#o.plot_vertical_distribution()
self.assertAlmostEqual(o.elements.z.min(), -49.6, 1)
self.assertAlmostEqual(o.elements.z.min(), -49.1, 1)
########################################################

def test_verticalmixing_schemes(self):
Expand All @@ -200,9 +200,9 @@ def test_verticalmixing_schemes(self):
o.run(duration=timedelta(hours=2), time_step=900)

if scheme == 'environment': # presently this is fallback
self.assertAlmostEqual(o.elements.z.min(), -48.8, 1)
self.assertAlmostEqual(o.elements.z.min(), -49.6, 1)
elif scheme == 'windspeed_Large1994':
self.assertAlmostEqual(o.elements.z.min(), -48.8, 1)
self.assertAlmostEqual(o.elements.z.min(), -49.6, 1)
elif scheme == 'windspeed_Sundby1983':
self.assertAlmostEqual(o.elements.z.min(), -51.75, 1)
elif scheme == 'constant':
Expand Down
10 changes: 5 additions & 5 deletions tests/models/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ def test_seed_seafloor(self):
#o.plot_property('z')
z, status = o.get_property('z')
self.assertAlmostEqual(z[0,0], -147.3, 1) # Seeded at seafloor depth
self.assertAlmostEqual(z[-1,0], -122.44, 1) # After some rising
self.assertAlmostEqual(z[-1,0], -132.31, 1) # After some rising

def test_seed_above_seafloor(self):
o = OpenOil(loglevel=30)
Expand All @@ -634,7 +634,7 @@ def test_seed_above_seafloor(self):
#o.plot_property('z')
z, status = o.get_property('z')
self.assertAlmostEqual(z[0,0], -97.3, 1) # Seeded at seafloor depth
self.assertAlmostEqual(z[-1,0], -71.9, 1) # After some rising
self.assertAlmostEqual(z[-1,0], -38.4, 1) # After some rising

def test_seed_below_reader_coverage(self):
o = OpenOil(loglevel=20)
Expand All @@ -654,7 +654,7 @@ def test_seed_below_reader_coverage(self):
o.set_config('vertical_mixing:timestep', 1) # s
o.run(steps=3, time_step=300, time_step_output=300)
z, status = o.get_property('z')
self.assertAlmostEqual(z[-1,0], -133.9, 1) # After some rising
self.assertAlmostEqual(z[-1,0], -235.5, 1) # After some rising

def test_seed_below_seafloor(self):
o = OpenOil(loglevel=20)
Expand All @@ -676,7 +676,7 @@ def test_seed_below_seafloor(self):
o.run(steps=3, time_step=300, time_step_output=300)
z, status = o.get_property('z')
self.assertAlmostEqual(z[0,0], -147.3, 1) # Seeded at seafloor depth
self.assertAlmostEqual(z[-1,0], -132.35, 1) # After some rising
self.assertAlmostEqual(z[-1,0], -138.3, 1) # After some rising

def test_seed_below_seafloor_deactivating(self):
o = OpenOil(loglevel=50)
Expand All @@ -702,7 +702,7 @@ def test_seed_below_seafloor_deactivating(self):
self.assertEqual(o.num_elements_active(), 1)
self.assertEqual(o.num_elements_deactivated(), 1)
self.assertAlmostEqual(z[0,1], -100, 1) # Seeded at seafloor depth
self.assertAlmostEqual(z[-1,1], -81.3, 1) # After some rising
self.assertAlmostEqual(z[-1,1], -56.7, 1) # After some rising

def test_lift_above_seafloor(self):
# See an element at some depth, and progapate towards coast
Expand Down

0 comments on commit 457ed0f

Please sign in to comment.