Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply overrides in FWTW #90

Merged
merged 9 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 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, WWTW
from wsimod.nodes.wtw import WTW, WWTW, FWTW


class MyTestClass(TestCase):
Expand Down Expand Up @@ -128,6 +128,28 @@ def test_wwtw_overrides(self):
self.assertEqual(wwtw.process_parameters["volume"]["constant"], vol)
self.assertEqual(wwtw.stormwater_storage_capacity, 100)

def test_fwtw_overrides(self):
fwtw = FWTW(name="")
vol = fwtw.process_parameters["volume"]["constant"]
fwtw.apply_overrides(
{
"treatment_throughput_capacity": 20,
"process_parameters": {"phosphate": {"constant": 0.02}},
"service_reservoir_storage_capacity": 100,
"service_reservoir_storage_area": 34.7,
"service_reservoir_storage_elevation": 68.2,
}
)
self.assertEqual(fwtw.treatment_throughput_capacity, 20)
self.assertEqual(fwtw.process_parameters["phosphate"]["constant"], 0.02)
self.assertEqual(fwtw.process_parameters["volume"]["constant"], vol)
self.assertEqual(fwtw.service_reservoir_storage_capacity, 100)
self.assertEqual(fwtw.service_reservoir_tank.capacity, 100)
self.assertEqual(fwtw.service_reservoir_storage_area, 34.7)
self.assertEqual(fwtw.service_reservoir_tank.area, 34.7)
self.assertEqual(fwtw.service_reservoir_storage_elevation, 68.2)
self.assertEqual(fwtw.service_reservoir_tank.datum, 68.2)
liuly12 marked this conversation as resolved.
Show resolved Hide resolved


if __name__ == "__main__":
unittest.main()
27 changes: 27 additions & 0 deletions wsimod/nodes/wtw.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,33 @@ def __init__(
self.mass_balance_ds.append(lambda: self.service_reservoir_tank.ds())
self.mass_balance_out.append(lambda: self.unpushed_sludge)

def apply_overrides(self, overrides=Dict[str, Any]):
"""Apply overrides to the service reservoir tank and FWTW.

Enables a user to override any parameter of the service reservoir tank, and
then calls any overrides in WTW.

Args:
overrides (Dict[str, Any]): Dict describing which parameters should
be overridden (keys) and new values (values). Defaults to {}.
"""
self.service_reservoir_storage_capacity = overrides.pop(
"service_reservoir_storage_capacity",
self.service_reservoir_storage_capacity,
)
self.service_reservoir_storage_area = overrides.pop(
"service_reservoir_storage_area", self.service_reservoir_storage_area
)
self.service_reservoir_storage_elevation = overrides.pop(
"service_reservoir_storage_elevation",
self.service_reservoir_storage_elevation,
)

self.service_reservoir_tank.capacity = self.service_reservoir_storage_capacity
self.service_reservoir_tank.area = self.service_reservoir_storage_area
self.service_reservoir_tank.datum = self.service_reservoir_storage_elevation
super().apply_overrides(overrides)

def treat_water(self):
"""Pulls water, aiming to fill service reservoirs, calls WTW
treat_current_input, avoids deficit, sends liquor and solids to sewers."""
Expand Down
Loading