-
Notifications
You must be signed in to change notification settings - Fork 223
Description
Summary
When adding a leak to a tank object in WNTR and attempting a simulation, the hydraulic solver attempts to retrieve information about the tank head but gets a key error because they are not provided the same way that they are for junctions. The exact error message is provided below and the error is easily reproducible across different water networks.
Example
import wntr
import numpy as np
inp_file = r"C:\Users\poffja\Downloads\Net3.inp"
wn = wntr.network.WaterNetworkModel(inp_file)
leak_diameter = 0.25 # m
damage_t = 2 * 3600 # start leak at 2 hours
tank1 = wn.get_node('1')
tank1.add_leak(wn, np.pi*(leak_diameter**2)/4,
discharge_coeff=0.75, start_time=damage_t,
end_time=None)
sim = wntr.sim.WNTRSimulator(wn)
results = sim.run_sim()
Environment
Provide information on your computing environment.
- Operating system: Windows 11 Enterprise
- Python version: 3.9.16
- WNTR version: 1.2.0
Additional context
Exact error message:
Traceback (most recent call last):
File ~\Anaconda3\envs\PytorchEnv\lib\site-packages\spyder_kernels\py3compat.py:356 in compat_exec
exec(code, globals, locals)
File \depot.engr.oregonstate.edu\users\poffja\windows.documents\my documents\github\cimd_fork\scripts\experiment_hub\untitled0.py:16
results = sim.run_sim()
File ~\Anaconda3\envs\PytorchEnv\lib\site-packages\wntr\sim\core.py:1281 in run_sim
wntr.sim.hydraulics.update_model_for_controls(self._model, self._wn, self._model_updater, self._change_tracker)
File ~\Anaconda3\envs\PytorchEnv\lib\site-packages\wntr\sim\hydraulics.py:118 in update_model_for_controls
model_updater.update(m, wn, obj, attr)
File ~\Anaconda3\envs\PytorchEnv\lib\site-packages\wntr\sim\models\utils.py:20 in update
func(m, wn, self, obj, attr)
File ~\Anaconda3\envs\PytorchEnv\lib\site-packages\wntr\sim\models\utils.py:31 in update
cls.build(m, wn, updater, index_over=[obj.name])
File ~\Anaconda3\envs\PytorchEnv\lib\site-packages\wntr\sim\models\constraint.py:645 in build
h = m.head[node_name]
File ~\Anaconda3\envs\PytorchEnv\lib\site-packages\wntr\sim\aml\aml.py:411 in getitem
return self._data[key]
KeyError: '1'