forked from stoiver/anuga_drainage
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathswmm_example.py
66 lines (48 loc) · 1.96 KB
/
swmm_example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
"""pyswmm example
This is a simple example based on previous work by:
Stephen Roberts, Petar Milevski, Rudy van Drie, Ole Nielsen
in December 2018
It was expanded by Zhixian Wu in September 2020 to demonstrate
some changes she made to the SWMM and PySWMM code.
"""
from pyswmm import Simulation, Nodes, Links
def run_swmm():
# =======================================
# setup all the nodes before starting
# =======================================
sim = Simulation('./pipe_test.inp')
# =======================================
# Start the simulation
# =======================================
print(sim._isStarted)
sim.start()
print(sim._isStarted)
node_names = ['Inlet', 'Outlet']
link_names = ['Culvert']
nodes = [Nodes(sim)[names] for names in node_names]
links = [Links(sim)[names] for names in link_names]
# type, area, length, orifice_coeff, free_weir_coeff, submerged_weir_coeff
opening0 = nodes[0].create_opening(4, 1.0, 1.0, 0.6, 1.6, 1.0)
opening1 = nodes[1].create_opening(4, 1.0, 1.0, 0.6, 1.6, 1.0)
print("\n")
print("n0 is coupled? ", nodes[0].is_coupled)
print("n1 is coupled? ", nodes[1].is_coupled)
nodes[0].overland_depth = 1.0
nodes[0].coupling_area = 1.0
# This step_advance should be an integer multiple of the routing step
# which is set in the ,inp file. Currently set to 1s.
# Should be able to interrogate sim to find out what the
# routing stepsize is. Maybe should issue a warning if
# step_advance is set lower than the routing step size.
# Indeed maybe step_advance should just allow advance n routing steps?
for i in range(5):
ids = dict()
nodes[0].overland_depth = 1.8854
volumes = sim.coupling_step(1.0)
print("Step:", i)
print("Current time:", sim.current_time)
print("overland depth: ",nodes[0].overland_depth)
print(volumes)
def dynamic(t):
return -0.02 * t + 1.8854
run_swmm()