-
Notifications
You must be signed in to change notification settings - Fork 0
/
techdesign.py
263 lines (214 loc) · 10.1 KB
/
techdesign.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
# -*- coding: utf-8 -*-
"""
@file
@author Peter M Bach <peterbach@gmail.com>
@version 0.5
@section LICENSE
This file is part of VIBe2
Copyright (C) 2011 Peter M Bach
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
"""
import math as m
import numpy as np
import designbydcv as ddcv
########################################################
#DESIGN FUNCTIONS FOR DIFFERENT TECHNOLOGIES #
########################################################
#---BIOFILTRATION SYSTEM/RAINGARDEN [BF]----------------------------------------
def design_BF(Aimp, dcv, tarQ, tarTSS, tarTP, tarTN, soilK, maxsize ):
#Design of Biofiltration systems
# input: Imparea = Impervious Area to treat
# tarQ = Runoff reduction target
# tarTSS = TSS reduction target
# tarTP = TP reduction target
# tarTN = TN reduction target
# soilK = soil hydraulic conductivity
# maxsize = maximum allowable system size
if Aimp == 0: #if there is no impervious area to design for, why bother?
return [np.inf, 1]
#size the system
psystem = ddcv.retrieveDesign(dcv, "BF", soilK, [tarQ, tarTSS, tarTP, tarTN, 100])
if psystem == np.inf:
return [np.inf, 1]
system_area = Aimp * psystem
#if the system design has passed to this point: i.e. not impossible and there is impervious to treat, then add planning constraints
#an infiltrating system (extra space around it required), determine the setback required
if soilK > 180:
setback = 1.0 #metres
elif soilK > 36:
setback = 2.0 #metres
elif soilK > 3.6:
setback = 4.0 #metres
else:
setback = 5.0 #metres
Areq = m.pow((m.sqrt(system_area)+2*setback),2)
diff = Areq/system_area
#final check, if the system has exceeded maximum size, return 'impossible' = inf
if Areq > maxsize: #if the final design exceeds the maximum allowable size, forget it!
print "Warning, Maximum System Size Exceeded"
return [np.inf, 1]
return [Areq, diff]
#---INFILTRATION SYSTEMS [IS]---------------------------------------------------
def design_IS(Aimp, dcv, tarQ, tarTSS, tarTP, tarTN, soilK, maxsize ):
#Design of Infiltration systems
# input: Imparea = Impervious Area to treat
# tarQ = Runoff reduction target
# tarTSS = TSS reduction target
# tarTP = TP reduction target
# tarTN = TN reduction target
# soilK = soil hydraulic conductivity
# maxsize = maximum allowable system size
if Aimp == 0: #if there is no impervious area to design for, why bother?
return [np.inf, 1]
#size the system
psystem = ddcv.retrieveDesign(dcv, "IS", soilK, [tarQ, tarTSS, tarTP, tarTN, 100])
if psystem == np.inf: #if the system cannot be designed, it will return infinity
return [np.inf, 1]
system_area = Aimp * psystem
#if the system design has passed to this point: i.e. not impossible and there is impervious to treat, then add planning constraints
#find setback requirement based on soilK
if soilK >= 3600:
setback = 1.0
elif soilK >= 1800:
setback = 1.0
elif soilK >= 360:
setback = 1.0
elif soilK >= 180:
setback = 1.0
elif soilK > 36:
setback = 2
elif soilK > 3.6:
setback = 4.0 #metres
else:
print "Soil is unsuitable for infiltration"
return [np.inf, 1]
Areq = m.pow((m.sqrt(system_area)+2*setback),2)
diff = Areq/system_area
if Areq > maxsize: #if the final design exceeds the maximum allowable size, forget it!
print "Warning, Maximum System Size Exceeded"
return [np.inf, 1]
return [Areq, diff]
#---PONDS & BASINS [PB]---------------------------------------------------------
def design_PB(Aimp, dcv, tarQ, tarTSS, tarTP, tarTN, soilK, maxsize ):
#Design of Ponds & Lakes
# input: Imparea = Impervious Area to treat
# tarQ = Runoff reduction target
# tarTSS = TSS reduction target
# tarTP = TP reduction target
# tarTN = TN reduction target
# soilK = soil hydraulic conductivity
# maxsize = maximum allowable system size
if Aimp == 0: #if there is no impervious area to design for, why bother?
return [np.inf, 1]
#size the system
psystem = ddcv.retrieveDesign(dcv, "PB", soilK, [tarQ, tarTSS, tarTP, tarTN, 100])
if psystem == np.inf: #if the system cannot be designed, it will return infinity
return [np.inf, 1]
system_area = Aimp * psystem
#add extra area to the system (multipliers for batters)
batter_multiplier = 1.3
Areq = system_area * batter_multiplier
diff = Areq/system_area
if Areq > maxsize: #if the final design exceeds the maximum allowable size, forget it!
print "Warning, Maximum System Size Exceeded"
return [np.inf, 1]
return [Areq, diff]
#---RAINWATER TANKS [RT]--------------------------------------------------------
def design_RT(self, currentID):
dcRT = [[0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.5,2.0], \
[0,45,59,70,78,81,86,90,91,95,97,98,99,99.9,100], \
[0,40,49,56,61,69,71,78,81,82,85,88,90,91,96], \
[0,37,41,48,51,58,60,65,69,71,73,78,80,84,90], \
[0,34,39,42,48,50,54,59,60,62,67,69,70,76,81]]
return True
#---SURFACE WETLANDS [WSUR]-----------------------------------------------------
def design_WSUR(Aimp, dcv, tarQ, tarTSS, tarTP, tarTN, soilK, maxsize ):
#Design of Ponds & Lakes
# input: Imparea = Impervious Area to treat
# tarQ = Runoff reduction target
# tarTSS = TSS reduction target
# tarTP = TP reduction target
# tarTN = TN reduction target
# soilK = soil hydraulic conductivity
# maxsize = maximum allowable system size
if Aimp == 0: #if there is no impervious area to design for, why bother?
return [np.inf, 1]
#size the system
psystem = ddcv.retrieveDesign(dcv, "PB", soilK, [tarQ, tarTSS, tarTP, tarTN, 100])
if psystem == np.inf: #if the system cannot be designed, it will return infinity
return [np.inf, 1]
system_area = Aimp * psystem
#add extra area to the system (multipliers for batters)
batter_multiplier = 1.3
Areq = system_area * batter_multiplier
diff = Areq/system_area
if Areq > maxsize: #if the final design exceeds the maximum allowable size, forget it!
print "Warning, Maximum System Size Exceeded"
return [np.inf, 1]
return [Areq, diff]
#---SWALES & BUFFER STRIPS [SW]-------------------------------------------------
def design_SW(Aimp, dcv, tarQ, tarTSS, tarTP, tarTN, soilK, maxsize ):
#Design of Ponds & Lakes
# input: Imparea = Impervious Area to treat
# tarQ = Runoff reduction target
# tarTSS = TSS reduction target
# tarTP = TP reduction target
# tarTN = TN reduction target
# soilK = soil hydraulic conductivity
# maxsize = maximum allowable system size
dcSW = [[0,0.1,0.2,0.5,1.0,1.5,2,2.5,3], \
[0,50,70,81,89,90,91,91.5,92], \
[0,30,45,55,60,62,64,65,65], \
[0,7,11,19,24,28,30,32.5,35]]
#design curve for swales & buffer strips
#column 0 = area of system (as % of imp. area)
#columns 1 to 3 = TSS, TP, TN reduction achieved (%)
sizes = [] #initialize variables
targets = [tarTSS, tarTP, tarTN]
pollutant = ["TSS", "TP", "TN"]
cannot_meet = 0
for pol_index in [1, 2, 3]:
#find size for TSS
lower_bound = None
upper_bound = dcSW[pol_index][0]
up_row = 0
for i in dcSW[pol_index][1:]:
if max(dcSW[pol_index]) < targets[pol_index-1]:
print "Warning, cannot meet "+str(pollutant[pol_index-1])+" Target with current design standards!"
cannot_meet = 1
sizes.append(max(dcSW[0]))
break
up_row = up_row + 1
lower_bound = upper_bound
upper_bound = i
if targets[pol_index-1] <= upper_bound:
slope = (dcSW[0][up_row] - dcSW[0][up_row-1])/(upper_bound - lower_bound)
sizes.append(dcSW[0][up_row-1]+(slope*(targets[pol_index-1] - lower_bound)))
break
#calculate surface area of system required
if cannot_meet == 1:
return [np.inf, 1]
else:
size_req = max(sizes)
Asystem = Aimp * size_req/100
#add extra area to the system
if Aimp == 0:
Areq = np.inf
#print "no area - no system"
else:
Areq = Asystem #swales drain into a pipe, so no additional area required, just need to check what minimum allowable width is
if Areq > maxsize: #if the final design exceeds the maximum allowable size, forget it!
print "Warning, Maximum System Size Exceeded"
Areq = np.inf
diff = 1.0
return [Areq, diff]