Skip to content

Commit

Permalink
refactored pyswmm example for clarity per wraseman
Browse files Browse the repository at this point in the history
  • Loading branch information
aerispaha committed Jan 3, 2025
1 parent 8e670d9 commit 84abd9a
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions docs/usage/working_with_pyswmm.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,19 @@
"import pandas as pd\n",
"\n",
"link_flows = dict()\n",
"# Run Simulation PySWMM\n",
"\n",
"# Run simulation PySWMM \n",
"with pyswmm.Simulation(model.inp.path) as sim:\n",
" \n",
" for i, step in enumerate(sim):\n",
" \n",
" # store each link's flow in a dictionary \n",
" link_flows[sim.current_time] = {\n",
" link_id: pyswmm.Links(sim)[link_id].flow \n",
" for link_id in model.inp.conduits.index\n",
" }\n",
"\n",
" # get link ids \n",
" link_ids = model.inp.conduits.index\n",
" \n",
" for step in sim:\n",
" # store each link's flow in a dictionary \n",
" link_flows[sim.current_time] = {\n",
" link_id: pyswmm.Links(sim)[link_id].flow \n",
" for link_id in link_ids\n",
" }\n",
"\n",
"pd.DataFrame(link_flows).T.plot(title='Link Flows')\n"
]
Expand Down

0 comments on commit 84abd9a

Please sign in to comment.