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

Tank Leak Hydraulic Solver Bug #439

Open
j-poff opened this issue Aug 7, 2024 · 1 comment
Open

Tank Leak Hydraulic Solver Bug #439

j-poff opened this issue Aug 7, 2024 · 1 comment
Labels

Comments

@j-poff
Copy link

j-poff commented Aug 7, 2024

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'

@kbonney
Copy link
Collaborator

kbonney commented Aug 21, 2024

Hey @michaelbynum, it appears that WNTRSimulator isn't able to simulate tank leaks. Is this an expected limitation?

@kaklise kaklise added the bug label Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants