Skip to content

Commit

Permalink
Add and test WWTW overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
barneydobson committed Feb 27, 2024
1 parent 7cfab64 commit 82c7455
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tests/test_wtw.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from unittest import TestCase

from wsimod.core import constants
from wsimod.nodes.wtw import WTW
from wsimod.nodes.wtw import WTW, WWTW


class MyTestClass(TestCase):
Expand Down Expand Up @@ -101,5 +101,18 @@ def test_override(self):
wtw.apply_overrides(overrides)
self.assertSetEqual(set(overrides.keys()), set(['name']))
self.assertEqual(wtw.treatment_throughput_capacity, 20)

def test_wwtw_overrides(self):
wwtw = WWTW(name='')
vol = wwtw.process_parameters['volume']['constant']
wwtw.apply_overrides({'treatment_throughput_capacity' : 20,
'process_parameters' : {'phosphate' :
{'constant' : 0.01}},
'stormwater_storage_capacity': 100})
self.assertEqual(wwtw.treatment_throughput_capacity, 20)
self.assertEqual(wwtw.process_parameters['phosphate']['constant'], 0.01)
self.assertEqual(wwtw.process_parameters['volume']['constant'], vol)
self.assertEqual(wwtw.stormwater_storage_capacity, 100)

if __name__ == "__main__":
unittest.main()
17 changes: 17 additions & 0 deletions wsimod/nodes/wtw.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,23 @@ def __init__(
lambda: self.ds_vqip(self.liquor, self.liquor_)
) # Change in liquor

def apply_overrides(self, overrides=Dict[str, Any]):
"""Apply overrides to the stormwater tank and WWTW.
"""
self.stormwater_storage_capacity = overrides.pop(
"stormwater_storage_capacity",
self.stormwater_storage_capacity)
self.stormwater_storage_area = overrides.pop(
"stormwater_storage_area",
self.stormwater_storage_area)
self.stormwater_storage_elevation = overrides.pop(
"stormwater_storage_elevation",
self.stormwater_storage_elevation)
self.stormwater_tank.area = self.stormwater_storage_area
self.stormwater_tank.capacity = self.stormwater_storage_capacity
self.stormwater_tank.datum = self.stormwater_storage_elevation
super().apply_overrides(overrides)

def calculate_discharge(self):
"""Clear stormwater tank if possible, and call treat_current_input."""
# Run WWTW model
Expand Down

0 comments on commit 82c7455

Please sign in to comment.