Skip to content

Commit

Permalink
Balance flows in dep tmp when travel time < hrs in dep tmp
Browse files Browse the repository at this point in the history
Like before.
  • Loading branch information
anamileva committed Jan 17, 2025
1 parent 5701bd1 commit 1700054
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 31 deletions.
4 changes: 2 additions & 2 deletions gridpath/system/water/water_flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ def determine_arrival_timepoint(mod, dep_tmp, travel_time_hours):
extensively tested, so proceed with caution.
"""
# If travel time is less than the hours in the departure timepoint,
# we send the water to the next timepoint and are done
# balancing happens within the departure timepoint
if travel_time_hours < mod.hrs_in_tmp[dep_tmp]:
arr_tmp = mod.next_tmp[dep_tmp, mod.water_system_balancing_type]
arr_tmp = dep_tmp
# If this is the last timepoint of a linear horizon, there are no
# timepoints to check and we'll return 'tmp_outside_horizon'
elif check_if_boundary_type_and_last_timepoint(
Expand Down
57 changes: 28 additions & 29 deletions tests/system/water/test_water_flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def test_data_loaded_correctly(self):
expected_wl_dp_arr_tmp = sorted(
[
("Water_Link_12", 20200101, 20200102),
("Water_Link_12", 20200102, 20200103),
("Water_Link_12", 20200102, 20200102),
("Water_Link_12", 20200103, 20200104),
("Water_Link_12", 20200104, 20200105),
("Water_Link_12", 20200105, 20200106),
Expand All @@ -157,13 +157,13 @@ def test_data_loaded_correctly(self):
("Water_Link_12", 20200111, 20200112),
("Water_Link_12", 20200112, 20200113),
("Water_Link_12", 20200113, 20200114),
("Water_Link_12", 20200114, 20200115),
("Water_Link_12", 20200115, 20200116),
("Water_Link_12", 20200116, 20200117),
("Water_Link_12", 20200114, 20200114),
("Water_Link_12", 20200115, 20200115),
("Water_Link_12", 20200116, 20200116),
("Water_Link_12", 20200117, 20200119),
("Water_Link_12", 20200118, 20200121),
("Water_Link_12", 20200119, 20200121),
("Water_Link_12", 20200120, 20200121),
("Water_Link_12", 20200120, 20200120),
("Water_Link_12", 20200121, 20200122),
("Water_Link_12", 20200122, 20200101),
("Water_Link_12", 20200123, 20200102),
Expand Down Expand Up @@ -241,7 +241,7 @@ def test_data_loaded_correctly(self):
("Water_Link_12", 20300223, 20300224),
("Water_Link_12", 20300224, "tmp_outside_horizon"),
("Water_Link_23", 20200101, 20200103),
("Water_Link_23", 20200102, 20200103),
("Water_Link_23", 20200102, 20200102),
("Water_Link_23", 20200103, 20200105),
("Water_Link_23", 20200104, 20200106),
("Water_Link_23", 20200105, 20200107),
Expand All @@ -254,12 +254,12 @@ def test_data_loaded_correctly(self):
("Water_Link_23", 20200112, 20200114),
("Water_Link_23", 20200113, 20200115),
("Water_Link_23", 20200114, 20200116),
("Water_Link_23", 20200115, 20200116),
("Water_Link_23", 20200115, 20200115),
("Water_Link_23", 20200116, 20200118),
("Water_Link_23", 20200117, 20200121),
("Water_Link_23", 20200118, 20200121),
("Water_Link_23", 20200119, 20200121),
("Water_Link_23", 20200120, 20200121),
("Water_Link_23", 20200120, 20200120),
("Water_Link_23", 20200121, 20200101),
("Water_Link_23", 20200122, 20200102),
("Water_Link_23", 20200123, 20200103),
Expand Down Expand Up @@ -351,7 +351,7 @@ def test_data_loaded_correctly(self):
expected_dep_tmp = {
("Water_Link_12", 20200101): 20200122,
("Water_Link_12", 20200102): 20200124,
("Water_Link_12", 20200103): 20200102,
("Water_Link_12", 20200103): "tmp_outside_horizon",
("Water_Link_12", 20200104): 20200103,
("Water_Link_12", 20200105): 20200104,
("Water_Link_12", 20200106): 20200105,
Expand All @@ -362,15 +362,14 @@ def test_data_loaded_correctly(self):
("Water_Link_12", 20200111): 20200110,
("Water_Link_12", 20200112): 20200111,
("Water_Link_12", 20200113): 20200112,
("Water_Link_12", 20200114): 20200113,
("Water_Link_12", 20200115): 20200114,
("Water_Link_12", 20200116): 20200115,
("Water_Link_12", 20200117): 20200116,
("Water_Link_12", 20200118): "tmp_outside_horizon", # gets
# skipped over because of short duration
("Water_Link_12", 20200114): 20200114,
("Water_Link_12", 20200115): 20200115,
("Water_Link_12", 20200116): 20200116,
("Water_Link_12", 20200117): "tmp_outside_horizon",
("Water_Link_12", 20200118): "tmp_outside_horizon",
("Water_Link_12", 20200119): 20200117,
("Water_Link_12", 20200120): "tmp_outside_horizon",
("Water_Link_12", 20200121): 20200120,
("Water_Link_12", 20200120): 20200120,
("Water_Link_12", 20200121): 20200119,
("Water_Link_12", 20200122): 20200121,
("Water_Link_12", 20200123): "tmp_outside_horizon",
("Water_Link_12", 20200124): "tmp_outside_horizon",
Expand Down Expand Up @@ -461,13 +460,13 @@ def test_data_loaded_correctly(self):
("Water_Link_23", 20200112): 20200110,
("Water_Link_23", 20200113): 20200111,
("Water_Link_23", 20200114): 20200112,
("Water_Link_23", 20200115): 20200113,
("Water_Link_23", 20200116): 20200115,
("Water_Link_23", 20200115): 20200115,
("Water_Link_23", 20200116): 20200114,
("Water_Link_23", 20200117): "tmp_outside_horizon",
("Water_Link_23", 20200118): 20200116,
("Water_Link_23", 20200119): "tmp_outside_horizon",
("Water_Link_23", 20200120): "tmp_outside_horizon",
("Water_Link_23", 20200121): 20200120,
("Water_Link_23", 20200120): 20200120,
("Water_Link_23", 20200121): 20200119,
("Water_Link_23", 20200122): "tmp_outside_horizon",
("Water_Link_23", 20200123): "tmp_outside_horizon",
("Water_Link_23", 20200124): "tmp_outside_horizon",
Expand Down Expand Up @@ -557,7 +556,7 @@ def test_data_loaded_correctly(self):
# Param: arrival_timepoint
expected_arr_tmp = {
("Water_Link_12", 20200101): 20200102,
("Water_Link_12", 20200102): 20200103,
("Water_Link_12", 20200102): 20200102,
("Water_Link_12", 20200103): 20200104,
("Water_Link_12", 20200104): 20200105,
("Water_Link_12", 20200105): 20200106,
Expand All @@ -569,13 +568,13 @@ def test_data_loaded_correctly(self):
("Water_Link_12", 20200111): 20200112,
("Water_Link_12", 20200112): 20200113,
("Water_Link_12", 20200113): 20200114,
("Water_Link_12", 20200114): 20200115,
("Water_Link_12", 20200115): 20200116,
("Water_Link_12", 20200116): 20200117,
("Water_Link_12", 20200114): 20200114,
("Water_Link_12", 20200115): 20200115,
("Water_Link_12", 20200116): 20200116,
("Water_Link_12", 20200117): 20200119,
("Water_Link_12", 20200118): 20200121,
("Water_Link_12", 20200119): 20200121,
("Water_Link_12", 20200120): 20200121,
("Water_Link_12", 20200120): 20200120,
("Water_Link_12", 20200121): 20200122,
("Water_Link_12", 20200122): 20200101,
("Water_Link_12", 20200123): 20200102,
Expand Down Expand Up @@ -653,7 +652,7 @@ def test_data_loaded_correctly(self):
("Water_Link_12", 20300223): 20300224,
("Water_Link_12", 20300224): "tmp_outside_horizon",
("Water_Link_23", 20200101): 20200103,
("Water_Link_23", 20200102): 20200103,
("Water_Link_23", 20200102): 20200102,
("Water_Link_23", 20200103): 20200105,
("Water_Link_23", 20200104): 20200106,
("Water_Link_23", 20200105): 20200107,
Expand All @@ -666,12 +665,12 @@ def test_data_loaded_correctly(self):
("Water_Link_23", 20200112): 20200114,
("Water_Link_23", 20200113): 20200115,
("Water_Link_23", 20200114): 20200116,
("Water_Link_23", 20200115): 20200116,
("Water_Link_23", 20200115): 20200115,
("Water_Link_23", 20200116): 20200118,
("Water_Link_23", 20200117): 20200121,
("Water_Link_23", 20200118): 20200121,
("Water_Link_23", 20200119): 20200121,
("Water_Link_23", 20200120): 20200121,
("Water_Link_23", 20200120): 20200120,
("Water_Link_23", 20200121): 20200101,
("Water_Link_23", 20200122): 20200102,
("Water_Link_23", 20200123): 20200103,
Expand Down

0 comments on commit 1700054

Please sign in to comment.