-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathL-Grid-14-8-11-sql.nlogo
4631 lines (3821 loc) · 171 KB
/
L-Grid-14-8-11-sql.nlogo
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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
extensions [mysql sql]
breed [ sewers sewer ] ;; This creates icons for the sewers
breed [ GI a-GI ] ;; This creates icons for green infrastructure
breed [ outflow-cells outflow-cell ] ;; This creates an icon for the outflow cell
breed [ inflow-cells inflow-dell ]
breed [ road-cells road-cell ] ;; This creates icons to distinguish road cells
breed [ rain-barrels rain-barrel ]
breed [ swales swale ]
breed [ permeable-pavers permeable-paver ]
breed [ green-roofs green-roof ]
globals [
;; The next are used by Tia's code for the SQL extension and to identify the run information
db
query
runID
studyID
efficiencyList
interventionMap
maxWaterHeightList
waterHeightList
elevationGradient
maximum-monetary-damage
Good-neighbor-calibration-run?
max-depth-water
configure?
configuration-run?
data-visualized
Flow-limit?
Neighborhood-type
good-neighbor-inflow-list
outflow-list
good-neighbor?
bad-neighbor?
max-water-in-pipes
max-possible-GI-cost
Sewer-calibration-run?
Upstream-neighbor?
;; Formerlt sliders, switches, or choosers.
; Sewer-calibration-run?
Outlet-control-height
; GI-placement
Number-inlets
Starting-soil-saturation
Starting-fullness-GI-extra-storage
Starting-fullness-of-sewers-percent
Extreme-flood-definition
Flood-definition
; when-sewers-full
activate-outlet?
Sewer-intake-regulator?
Vary-landscape?
Repetitions-per-Iteration
Blocks-vertical
; Storm-type
storm-hours
percent-impervious
Slope-percent
%-landscape-swale
GI-concentrated-near-outlet
%-impermeable-rain-barrels
%-impermeable-green-roof
Green-Alleys?
activate-sewers?
curbs?
; GI-Budget
public-install-budget-sentence
private-install-budget-sentence
public-maintenance-budget-sentence
private-maintenance-budget-sentence
pre-flow-water
post-flow-water
flow-error
Water-near-outlet-now
water-near-outlet-previous
water-near-outlet-error
;; Constant = value will not change within a single model run.
;; Dynamic = value changes throughout the run.
;; Cell-specific units = the level of water, in mm, on a single cell, or essentially thei height of water specific to a dimensions of 1 cell. To convert the number in variable with the numerical value stored in it of n,
;; assuming it is labeled as being in this type of unit, to volume, the equation would be ( ( cell-dimension ^ 2 ) * n )
;; setup variables. all constant.
max-outflow
stop-tick ;; The tick when the model will stop. Set to be two days after the end of the rain event.
storm-length ;; The length of the storm in minutes.
cell-dimension ;; length of one side of a cell in mm. All cells are square, so either length or width could be represented by cell-dimension.
cell-dimension-m ;; The width of the dquare in m
road-width-m ;; the width of a road in meters
; Repetitions-per-Iteration ;; the number of subroutines per minute iteration. e.g, of this is set to 4, then each subroutine is 15 seconds. A subroutine is simple a full repetition of all the model processes.
conversion-multiplier ;; a multiplier that converts amounts in cell-specific variable amounts to m^3.
;; tracking of total amounts. all dynamic
global-precipitation ;; cumulative precipitation that has fallen across entire landscape in m^3
global-infiltration ;; cumulative infiltration from all types of cells across the entire landscape in m^3
global-GI-infiltration ;; cumulative infiltration in green infrastructure cells over the entire landscape in m^3
global-Non-GI-infiltration ;; cumulative infiltration in permeable cover cells over entire landscape in m^3
global-evapotrans ;; cumulative evapotranspiration across the entire landscape in m^3
global-evapo ;; cumulative evaporation across the entire landscape in m^3
global-sewer ;; cumulative intake by the sewers cross the entire landscape in m^3
global-sewer-drain ;; cumulative water that has been treated by sewage treatment plant in cell-specific units.
global-CSO ;; cumulative volume of any CSOs. in cell-specific units.
global-outflow ;; cumulative water that has flowed from the outlet cell and left the landscape. in m^3
global-inflow
global-precipitation-ft3
global-GI-infiltration-ft3
global-Non-GI-infiltration-ft3
global-sewer-ft3
global-outflow-ft3
global-evapo-ft3
global-evapotrans-ft3
non-GI-accumulated-water-ft3
water-in-storage-ft3
total-extra-storage-ft3
global-inflow-ft3
global-cso-ft3
potential-rain
;; Metrics!
Cost-install-private-GI
Cost-install-public-GI
Cost-total-install
Cost-private-maintenance
Cost-public-maintenance
Cost-total-maintenance
Cost-private-property-damage
Cost-public-property-damage
Cost-stormwater-treatment
Normalized-Cost-install-private-GI
Normalized-Cost-install-public-GI
Normalized-Cost-total-install
Normalized-Cost-private-maintenance
Normalized-Cost-public-maintenance
Normalized-Cost-total-maintenance
Normalized-Cost-private-property-damage
Normalized-cost-public-property-damage
Normalized-cost-stormwater-treatment
Normalized-Costs-total-storm-damage
Normalized-Costs-total
time-to-lesser-flood
time-to-greater-flood
time-duration-lesser-flood
time-duration-greater-flood
time-to-dry
Normalized-time-to-lesser-flood
Normalized-time-to-greater-flood
Normalized-time-duration-lesser-flood
Normalized-time-duration-greater-flood
Normalized-time-to-dry
global-standing-water
greatest-depth-standing-water
global-standing-water-ft3
greatest-depth-standing-water-ft
global-rain-barrel-ft3
global-green-roof-ft3
global-green-alleys-ft3
global-swales-ft3
global-GI-total-ft3
global-efficiency-rain-barrels
global-efficiency-green-roofs
global-efficiency-green-alleys
global-efficiency-swales
global-efficiency-total
Normalized-global-outflow-ft3
Normalized-global-inflow-ft3
Normalized-global-sewer-ft3
Normalized-global-standing-water-ft3
Normalized-greatest-depth-standing-water-ft
Normalized-global-rain-barrel-ft3
Normalized-global-green-roof-ft3
Normalized-global-green-alleys-ft3
Normalized-global-swales-ft3
Normalized-global-GI-total-ft3
Normalized-global-GI-infiltration-ft3
Normalized-global-GI-total
global-rain-barrel
global-green-roof
global-green-alleys
global-swales
global-GI-total
;; landscape performance variables. all dynamic
accumulated-water ;; all accumulated water on the surface, including water in green infrastructure storage. in m^3
non-GI-accumulated-water
; above-0-accumulated-water ;; total volume in m^3 of water accumulated on cell surfaces, excluding water in green infrastructure storage capacity
; above-0-non-GI
water-in-storage ;; total volume in m^3 of water in swale above soil storage
total-extra-storage
average-water-height ;; average water depth across landscape in mm
average-water-height-roads ;; average water depth on roads only in mm
total-flooded ;;; number flooded that iteration
max-flooded ;; records the number of cells flooded (water-column > 1cm) at the point during the storm event when the flooding is at its greatest extent.
impermeable-flooded
impermeable-ever-flooded
impermeable-extreme-flooded
impermeable-ever-extreme-flooded
road-extreme-flooded
road-ever-extreme-flooded
cumulative-margin-of-error ;; global tracker that determines proportional difference between all water that has fallen and water with known outcomes. Error is due to flow code.
error-now
;; process variables
total-rainfall ;; the total amount of rain in mm that will fall during the storm event. constant.
rainfall-rate ;; in millimeters, the amount of rainfall that falls in one subroutine . Constant.
daily-evaporation-rate ;; the daily rate of evaporation, calibrated for Chicago at 4.66 mm per 24 hour period. constant
evapo-rate ;; in millimeters per time period of a subroutine, the amount of water that evaporates after rainfall stops. constant.
daily-evapotranspiration-rate ;; the daily rate of evapotranspiration. constant.
evapotrans-rate ;; in millimeters per time period of a subroutine, the amount of water that evapotranspirates. Constant.
hydraulic-conductivity ;; in millimeters per tipe period of the subroutine. used by Green-Ampt. Constant.
;; sewer variables
water-in-pipes ;; the total amount of water that has left the sewer intake cells' catchment basins but is still awaiting treatment by the virtual treatment plant.
;; in the "cell-specific" units of measure. dynamic
max-sewer-capacity ;; the total amount of water, in cell-specific" units of measure, that the sewers can handle before they fill and lose some capacity to intake water unless CSOs are allowed.
;; calibrated with 24-hour, 5-year storms as the baseline for what the sewer system is engineered to handle without flooding. constant.
benchmark-storm ;; used to set the max-sewer-capacity. the average amount of rain in mm that can fall on a patch without the sewers flooding.
full-sewers? ;; a yes/no variable about whether the water in the pipes has reached the maximum capacity they can handle
sewer-basin-capacity ;; the volume of water in m^3 a basin can hold.
adjusted-sewer-basin-capacity ;; height (or capacity) of a sewer basin in mm. volume the same, but the height adjusted to represent the height if the basin had the same dimensions as the cells. constant
sewer-basin-height-below-pipe ;; the amount of water that will never flow out of a sewer catchment basin through the pipe, ie the % of the basin that is below the outlet pipe. We calculate it is 62% of the sewer-basin-capacity. constant
sewer-rate ;; the maximum potential rate at which water enters the sewer syetem. in mm per minute. constant
base-sewer-rate ;; the sewer-rate, but divided by the number of subroutines per minute. constant
full-sewer-rate ;; the rate at which water enters the sewer system if the sewer system is full (essentially meaning that intake is restricted to the water treatment rate at teh plant unless there are CSOs. constant.
used-sewer-rate ;; the actual sewer intake rate that will be used at that iteration. It is either the base-sewer-rate or the full-sewer-rate. constant.
sewer-drain-rate ;; the amount of water treated by the sewage treatment plant each model iteration.
;; Sewer-drain-rate scales with the landscape so that larger landscapes have correspondingly higher treatment rates.
;; in cell-specific units. Constant.
;;; permeable pavement
paver-underdrain-depth ;; in mm. depth below surface of the underdrain
paver-underdrain-rate ;; rate in mm per iteration. based on .5 inches per hour
;; Misc. Variables
max-elevation ;; the maximum elevation in the landscape. set to speed up the visualizations. constant.
iteration-CSO ;; the amount of CSO that happens during that iteration. in cell-specific units. dynamic
total-on-outlet
group-counter
gi-patches
permeable-patches
impermeable-patches
sum-storage-capacity
sum-infil-capacity
tracked-cell
max-height-tracked-cell
list-roads-alleys
list-non-roads-or-alleys
rain-barrel-storage
time
;; Costs
cost-a-permeable-paver
cost-a-green-roof
cost-a-swale
cost-a-rain-barrel
remaining-private-install-budget
remaining-public-install-budget
maintenance-a-paver
maintenance-a-swale
maintenance-a-roof
maintenance-a-barrel
Private-Install-Budget-dollars
Public-install-budget-dollars
Private-maintenance-budget-dollars
Public-maintenance-budget-dollars
Flood-definition-mm
Extreme-flood-definition-mm
Outlet-control-height-mm
iteration-flow
;;; Max dry volume of GI in m^3
volume-rain-barrels
volume-green-roofs
volume-green-alleys
volume-swales
volume-total-GI
volume-rain-barrels-ft3
volume-green-roofs-ft3
volume-green-alleys-ft3
volume-swales-ft3
volume-total-GI-ft3
volume-a-rain-barrel
volume-a-green-roof
volume-a-paver
volume-a-swale
volume-a-rain-barrel-ft3
volume-a-green-roof-ft3
volume-a-paver-ft3
volume-a-swale-ft3
cubic-m-to-cubic-ft
inflow-limit-reached?
Landscape-Elevation-list ;; List of the all the patches ordered by elevation (small to large)
world-dimensions-vertical
world-dimensions-horizontal
road-spacing-vertical
road-spacing-horizontal
outlet-longitudinal-slope
]
patches-own [
intersection?
flood-depth-feet
;;; for the outlet and movement
max-flow-height
max-flow-volume
longitudinal-slope
roughness
mannings-coefficient
velocity
channel-width
water-depth
hydraulic-radius
cross-sectional-area
wetting-perimeter
cover
Public?
Private?
base-color
;; Variables tracking water and water movement during an iteration before being reset. dynamic
iteration-infiltration ;; the amount of water in cell-specific units that infiltrated on a cell in a given iteration
iteration-precipitation ;; the amount of precipitation in cell-specific units that fell on a cell in given iteration
iteration-evapotrans ;; the amount of water in cell-specific units that evapotransporates in a cell in a given iteration
iteration-evapo ;; the amount of water in cell-specific units that evaporates in a cell in a given iteration
iteration-sewers ;; the amount of water in cell-specific units that leaves the system through the storm sewers in a cell in a given iteration. Process only occurs in sewer cells.
iteration-outflow ;; the amount of water in cell-specific units that leaves the system though the outlet in a cell in a given iteration. Process only occurs in outlet cell.
iteration-inflow
infiltration-amount ;; the amount of water in cell-specific units that infiltrated on a cell in a given iteration
;; Variables for type of cell and cell soil properties. constant
storage-capacity ;; the potential amount of water that can stay behind on a cell in storage rather than flowing. Constant.
water-in-swale
count-sewer-inlets ;; yes/no whether the cell contains a storm sewer. Constant.
outflow? ;; yes/no whether the cell is the outflow cell. Constant.
inflow?
height-in-sewer-basin ;; height in mm of water in the sewer catchment basin, if the basin had the same dinemsions of the cells.
Neighbor-Elevation-list ; A list of the patch's neighbors sorted by elevation (small to large)
;;; new
GI?
type-of-GI ;; rain barrel, swale, permeable pavement, greenroof
max-extra-GI-storage
extra-GI-storage
install-cost-here
maintenance-cost-here
;;; rain barrel
;;; have a small volume to hold water on site. should be located next to impermeable cells
;;; volume rain barrels can have in m^3 or mm^3- decide later
;;; this can berain-barrel-storage capacity ;;; converted volume of rain barrels to height per 10x10 m cell
;;; swale
;; same as current default GI
;;; check storage capacity, however, since our storage capacity was based on
;;; permeable pavement
;;; greenroof
;;; lookup storage capacities- it is small
;;; surface flow does not go over these cells, so they need a high elevation
;;; make sure that water will not flow out of greenroofs unless it is above the storage capacity- as it is now, this may be a problem since GI was desihned to allow flow between GI cells
;; Variables for surface flow
water-column ;; the height of surface water on a cell in millimeters. dynamic
elevation ;; the height in mm of the non-water portion of a cell's elevation. e.g. the underlying elevation. Constant.
;; Variables for green-ampt infiltration model
max-wet-depth ;; depth to which water can infiltratee in millimeters. Represents the depth to bedrock or the water table. Set by slider, revised by storage capacity. Constant.
initial-moisture-deficit ;; hydrologic characteristic of a cell's soil, determined from a table, indicating initial moisture condition of a cell (Vol. of Air / Vol. of Voids,
;; expressed as a fraction). Constant.
capillary-suction ;; the suction at the wetting front, a measure of the pressure with which water moves into soil voids, Psi, based on soil type, from a table. Constant.
saturated-hydraulic-conductivity ;; the hydraulic conductivity of the soil, a measure of the ease at which water can move between voids
;; stays constant for a given soil type at a specific temperature. May need to be modified for cold soils. Constant.
base-max-wet-depth ;; in mm, the maximum depth to which the wetting front of infiltrated water can reach afterwhich infiltration is much slpwer.
cumulative-infiltration-amount ;; the amount of water that has infiltrated so far, in millimeters
max-infil-value ;; calculated value for the maximum amount of water that can be infiltrated given the moisture deficit and the the max wet depth. In millimeters. Constant.
infiltration-rate ;; maximum rate at which water could theoretically infiltrate into a given soil type given the amount of water that has already infiltrated.
;; May be higher than the actual infiltration rate which is limited by the rainfall-rate.
;; Misc. Variables
;; yes/no- whether the water-level on the cell is over 1cm or not.
Distance-outlet ;; variable used in some of the GI location rules. The distance from a cell to the outlet.
impervious-neighbors ;; variable for GI location rules. The count of upstream neighbors with impervious surface
patch-flooded-level
extreme-patch-flooded-level
group
patch-marker
lot-number
flooded?
ever-flooded?
extreme-flooded?
ever-extreme-flooded?
highest-water-level
depth-to-flood
percent-damage-structure
percent-damage-contents
damage-in-dollars
]
;; Sets variables that belong to agents. Empty because we use agents (turtles) as graphics to show green infrastructure, roads, sewers, and the outlet, and they have no variables of their own.
turtles-own [
]
;; Sets initial model conditions
to setup
clear-all
setup-globals ;; This sets up numerous global-level variables needed for other processes
;; set the storm-type using code below that considers the length and statistical frequency of a storm to determine total rainfall
setup-storm-type
;; setting some process rates at daily rates
set daily-evaporation-rate 3.5625 ;; mm per day
set daily-evapotranspiration-rate 1.66 ;; mm per day
;; sets the rates that will actually be used by the code when opering in each subroutine, i.e. mm per 15 seconds
set rainfall-rate ( ( total-rainfall ) / ( storm-hours * 60 * Repetitions-per-Iteration ) )
set evapo-rate ( ( ( ( daily-evaporation-rate ) / ( 24 * 60 ) ) / Repetitions-per-Iteration ) )
set evapotrans-rate ( ( ( ( daily-evapotranspiration-rate ) / ( 24 * 60 ) ) / Repetitions-per-Iteration ) )
set inflow-limit-reached? false
set potential-rain rainfall-rate * Repetitions-per-Iteration * storm-length * conversion-multiplier * ( count patches )
;; Setup costs of GI
setup-costs
;; Creates land cover for landscape
setup-land-cover
ask patches [
;; Assume that starting conditions include no standing aboveground water
set water-column 0
set flooded? false
]
;; setup the sewer locations
setup-sewers
;; setup permeable paver drain info
setup-paver-underdrain
;; setup soil conditions for infiltration
setup-green-ampt
;; setup the colors and icons that show green infrastructure, sewers, roads, and the outlet
setup-colors
setup-agents
setup-flow-values ;; Values used in Manning's equations to determine flow volumes
if record-movie? = true [
;let movietitle word date-and-time ".mov"
movie-start (word (word "results" (remove "-" (remove " " (remove "." (remove ":" date-and-time)))) ".mov"))
]
ifelse Normalization-calibration-run? = false and Good-neighbor-calibration-run? = false and Outflow-calibration-run? = false and Sewer-calibration-run? = false [
;; Not a calibration run, so use recorded value from the calibration run as the max damages
file-open "maximum-damages.txt" ;; file-open (word (word "run" behaviorspace-run-number (remove "-" (remove " " (remove "." (remove ":" date-and-time)))) ".txt"))
set Maximum-monetary-damage precision file-read 2
; type "max damages for normalilization = " print Maximum-monetary-damage
file-close
file-open "maximum-depth.txt"
set max-depth-water precision file-read 2
file-close
]
[
;; This means it is a calibration run in some way, so use 1 for now; normalization of damages will not be used
set Maximum-monetary-damage 1
set max-depth-water 1
]
if Outflow-calibration-run? = true [
if file-exists? "outflow-calibration-values.txt" [
file-delete "outflow-calibration-values.txt"
]
file-open "outflow-calibration-values.txt" ;; file-open (word (word "run" behaviorspace-run-number (remove "-" (remove " " (remove "." (remove ":" date-and-time)))) ".txt"))
]
if Good-neighbor-calibration-run? = true [
if file-exists? "good-neighbor-calibration-values.txt" [
file-delete "good-neighbor-calibration-values.txt"
]
file-open "good-neighbor-calibration-values.txt" ;; file-open (word (word "run" behaviorspace-run-number (remove "-" (remove " " (remove "." (remove ":" date-and-time)))) ".txt"))
]
reset-ticks
end
to setup-globals
;; This sets up numerous variables that are used in many processes, often by many processes.
;; This should be reorganized later to see if some can be moved to places where they would be better fits, but leave here for now to make sure thet are set before they are needed
if Storm-duration = "1-hour" [ set storm-hours 1 ]
if Storm-duration = "2-hour" [ set storm-hours 2 ]
if Storm-duration = "3-hour" [ set storm-hours 3 ]
if Storm-duration = "6-hour" [ set storm-hours 6 ]
if Storm-duration = "12-hour" [ set storm-hours 12 ]
if Storm-duration = "24-hour" [ set storm-hours 24 ]
set configure? Outflow-calibration-run? OR Normalization-calibration-run?
if configure? = false [
set configure? not MYSQL?
]
set data-visualized "flooding definitions" ;"flooding definitions" ; "elevation"
set Neighborhood-type "Blue Island - Import"
set Flow-limit? "all-equilibrium"
set Sewer-calibration-run? false
; set Sewer-calibration-run? false
;;; Variables formerly sliders
set Number-inlets 3
set Starting-soil-saturation 0
set Starting-fullness-GI-extra-storage 0
set Extreme-flood-definition 6
set Flood-definition 1
; set when-sewers-full "no-CSO"
set Sewer-intake-regulator? false
set Good-neighbor-calibration-run? false
set Repetitions-per-Iteration 1
set Blocks-vertical 1
; ifelse Sewer-calibration-run? = true [
; set Storm-type "5-year"
; ]
; [
; set Storm-type "100-year"
; ]
set efficiencyList ""
set waterHeightList ""
set maxWaterHeightList ""
set elevationGradient ""
set interventionMap ""
ifelse Normalization-calibration-run? = false and Good-neighbor-calibration-run? = false and Outflow-calibration-run? = false and Sewer-calibration-run? = false [
set configuration-run? false
]
[
set configuration-run? true
]
set Starting-fullness-of-sewers-percent precision ( 1 - ( Initial-sewer-capacity / 100 ) ) 2
if Neighbor-option = "No neighbor inflows" [
set Upstream-neighbor? false
set good-neighbor? false
set bad-neighbor? false
]
if Neighbor-option = "Fixed neighbor inflows (bad neighbors)" [
set Upstream-neighbor? true
set good-neighbor? false
set bad-neighbor? true
]
if Neighbor-option = "Neighbors install same GI as here, possible inflow reductions (good neighbors)" [
set Upstream-neighbor? true
set good-neighbor? true
set bad-neighbor? false
]
if Outflow-calibration-run? = true [
set Upstream-neighbor? false
set good-neighbor? false
set bad-neighbor? true
]
if Good-neighbor-calibration-run? = true [
set Upstream-neighbor? true
set good-neighbor? false
set bad-neighbor? true
]
; set storm-hours 24
set percent-impervious 60
set Vary-landscape? false
set Slope-percent 0.08
set %-landscape-swale 5
set GI-concentrated-near-outlet 30
set %-impermeable-rain-barrels 5
set %-impermeable-green-roof 5
set Green-Alleys? true
set activate-sewers? true
set curbs? true
set activate-outlet? true
; set GI-Budget 10000000
set max-possible-GI-cost 51122645.16
set Type-to-Place "Swales"
; set GI-placement "Imported" ;;"User selected" "Sliders" "Imported"
set Outlet-control-height 6 ;; in inches
set-patch-size 15
if Neighborhood-type = "Dense residential (e.g. Wicker Park)" or Neighborhood-type = "Bungalow belt" or Neighborhood-type = "Humboldt Park" or Neighborhood-type = "Albany Park" or Neighborhood-type = "Albany Park - Import" or Neighborhood-type = "Random"[
set world-dimensions-vertical ( ( Blocks-vertical * 24 ) + 2 )
set world-dimensions-horizontal ( ( Blocks-vertical * 24 ) + 2 )
set road-spacing-vertical 24
set road-spacing-horizontal 12
]
if Neighborhood-type = "Palos Heights" or Neighborhood-type = "Palos Heights - Import" [
set world-dimensions-vertical ( ( Blocks-vertical * 21 ) + 1 )
set world-dimensions-horizontal ( ( Blocks-vertical * 18 ) + 1 )
set road-spacing-vertical 21
set road-spacing-horizontal 9
]
if Neighborhood-type = "Dixmoor" or Neighborhood-type = "Dixmoor - Import"[
set world-dimensions-vertical ( ( Blocks-vertical * 19 ) + 1 ) ;; 17 lots vertical
set world-dimensions-horizontal ( ( Blocks-vertical * 19 ) + 2 )
set road-spacing-vertical 19
set road-spacing-horizontal 10
]
if Neighborhood-type = "Morrill School - 13 x 7 6 blocks" or Neighborhood-type = "Morrill School - Import" [
set world-dimensions-vertical ( ( Blocks-vertical * 2 * 14 ) + 1 ) ;; 17 lots vertical
set world-dimensions-horizontal ( ( Blocks-vertical * 3 * 7 ) + 4 )
set road-spacing-vertical 14
set road-spacing-horizontal 8
]
if Neighborhood-type = "Blue Island - Import" [
set world-dimensions-vertical 25
set world-dimensions-horizontal 23
set road-spacing-vertical 8
set road-spacing-horizontal 10
]
;; Set the size of the landscape to match the dimensions on the world-dimensions slider
resize-world 0 ( world-dimensions-horizontal - 1 ) 0 ( world-dimensions-vertical - 1 )
set cubic-m-to-cubic-ft 35.3147
set Private-Install-Budget-dollars Private-Install-Budget * 1000
set Public-install-budget-dollars Public-install-budget * 1000
set Private-maintenance-budget-dollars Private-maintenance-budget * 1000
set Public-maintenance-budget-dollars Public-maintenance-budget * 1000
; set max-damage-cost 94305
set Flood-definition-mm Flood-definition * 25.4 ;; convert inches to mm
set Extreme-flood-definition-mm Extreme-flood-definition * 25.4 ;; convert to mm
set Outlet-control-height-mm Outlet-control-height * 25.4 ;; convert inches to mm
set time-to-lesser-flood 0
set time-to-greater-flood 0
set time-duration-lesser-flood 0
set time-duration-greater-flood 0
set time-to-dry 0
;; setting some variables that are more mechanistic in nature as they control other processes.
; set decimal-places 20 ;; when the precision primitive is used, it will record variables to only 20 decinal places.
; set Repetitions-per-Iteration 3 ;; means 20 second subroutines
set cell-dimension 12405.4 ; in mm.
set cell-dimension-m cell-dimension / 1000
set road-width-m cell-dimension-m
set storm-length ( storm-hours * 60 ) ;; converting the storm length from hours to minutes
set stop-tick 2880 ; storm-length + 1440 ;; setting the maximum length of a simulation is the surface water does not dry first. max length is 2 days beyond the end of a storm.
set conversion-multiplier ( ( cell-dimension ^ 2 ) / 1000000000 ) ;; used to convert from cell-specific units to m^3.
end
;; Sets amount of rain that will fall during a storm with a given statistical frequency and a given duration
to setup-storm-type
if storm-type = "1-year" [
if storm-hours = 1 [ set total-rainfall 29.972 ]
if storm-hours = 2 [ set total-rainfall 35.56 ]
if storm-hours = 3 [ set total-rainfall 37.846 ]
if storm-hours = 6 [ set total-rainfall 45.212 ]
if storm-hours = 12 [ set total-rainfall 52.324 ]
if storm-hours = 24 [ set total-rainfall 61.722 ]
]
if storm-type = "2-year" [
if storm-hours = 1 [ set total-rainfall 36.576 ]
if storm-hours = 2 [ set total-rainfall 43.18 ]
if storm-hours = 3 [ set total-rainfall 46.228 ]
if storm-hours = 6 [ set total-rainfall 55.372 ]
if storm-hours = 12 [ set total-rainfall 63.754 ]
if storm-hours = 24 [ set total-rainfall 74.93 ]
]
if storm-type = "5-year"[
if storm-hours = 1 [ set total-rainfall 45.72 ]
if storm-hours = 2 [ set total-rainfall 54.61 ]
if storm-hours = 3 [ set total-rainfall 58.928 ]
if storm-hours = 6 [ set total-rainfall 71.12 ]
if storm-hours = 12 [ set total-rainfall 81.28 ]
if storm-hours = 24 [ set total-rainfall 95.758]
]
if storm-type = "10-year" [
if storm-hours = 1 [ set total-rainfall 52.832 ]
if storm-hours = 2 [ set total-rainfall 63.246 ]
if storm-hours = 3 [ set total-rainfall 68.58 ]
if storm-hours = 6 [ set total-rainfall 84.328 ]
if storm-hours = 12 [ set total-rainfall 96.012 ]
if storm-hours = 24 [ set total-rainfall 113.03 ]
]
if storm-type = "25-year" [
if storm-hours = 1 [ set total-rainfall 62.484 ]
if storm-hours = 2 [ set total-rainfall 75.438 ]
if storm-hours = 3 [ set total-rainfall 82.042 ]
if storm-hours = 6 [ set total-rainfall 103.632 ]
if storm-hours = 12 [ set total-rainfall 117.348 ]
if storm-hours = 24 [ set total-rainfall 138.176 ]
]
if storm-type = "50-year" [
if storm-hours = 1 [ set total-rainfall 70.104 ]
if storm-hours = 2 [ set total-rainfall 85.344 ]
if storm-hours = 3 [ set total-rainfall 92.964 ]
if storm-hours = 6 [ set total-rainfall 120.142 ]
if storm-hours = 12 [ set total-rainfall 135.382 ]
if storm-hours = 24 [ set total-rainfall 159.512 ]
]
if storm-type = "100-year" [
if storm-hours = 1 [ set total-rainfall 78.232 ]
if storm-hours = 2 [ set total-rainfall 95.758 ]
if storm-hours = 3 [ set total-rainfall 104.648 ]
if storm-hours = 6 [ set total-rainfall 137.922 ]
if storm-hours = 12 [ set total-rainfall 154.94 ]
if storm-hours = 24 [ set total-rainfall 182.88 ]
]
if Sewer-calibration-run? [
set total-rainfall 77.216 ;; 3.04" - per John Watson - 7/25/14. 2-year, 24-hour storm for NE Illinois, taken from ISWS Bulletin 70
]
end
to setup-costs
;; Costs
;; All costs are in dollars
;; For rain barrels, the cost is for one rain barrel. For all other types, the cost is calculated
;; Costs are relative to the cell size
let cell-area cell-dimension-m * cell-dimension-m
set cost-a-permeable-paver precision ( cell-area * 114.33 ) 2
set cost-a-green-roof precision ( cell-area * 123.55 ) 2
set cost-a-swale precision ( cell-area * 84.12 ) 2
set cost-a-rain-barrel 125
set maintenance-a-paver precision ( cell-area * .25 ) 2
set maintenance-a-roof precision ( cell-area * .74 ) 2
set maintenance-a-swale precision ( cell-area * 2.39 ) 2
set maintenance-a-barrel 0
end
;; Defines landcover for all cells, sets up the cover specific variables
to setup-land-cover
setup-elevation
;; sets up roads
if Neighborhood-type = "Morrill School - Import" [
file-open "MorrillSchool2.txt"
let cover-list file-read
( foreach sort patches cover-list
[ ask ?1 [
set cover ?2
] ] )
file-close
]
if Neighborhood-type = "Blue Island - Import" [
file-open "BlueIsland2.txt"
let cover-list file-read
( foreach sort patches cover-list
[ ask ?1 [
set cover ?2
] ] )
file-close
]
setup-roads
;; Create a single outflow cell in the lower left corner of the landscape
ask patch (max-pxcor) (0) [
set outflow? true
]
if Upstream-neighbor? = true[
if Number-inlets = 1 [
ask patch 0 max-pycor [
set inflow? true
]
]
if Number-inlets = 3 [
ask patch 0 max-pycor [
set inflow? true
]
ask patch 0 0 [
set inflow? true
]
ask patch max-pxcor max-pycor [
set inflow? true
]
]
]
;; sets all cells to cover-type 2 first, which is the impermeable surface
;; determining which set of rules to use for GI placement based on the GI-Location chooser
;; the options can be divided into two basic classes.
;; the first class:
ifelse Neighborhood-type = "Morrill School - Import" [
ask patches with [ cover != "r" ] [
ifelse ( pxcor > 8 and pxcor < 16 and pycor > 14 and pycor < 28 )
;or
[
set public? true
set private? false
]
[
ifelse cover = "a" [
set public? true
set private? false
]
[
set public? false
set private? true
]
]
]
]
[
ask patches with [ cover != "r" ] [
ifelse cover = "a" [
set public? true
set private? false
]
[
set public? false
set private? true
]
]
]
Setup-GI
assign-cell-data
;; Now creating lists of patches sorted by elevation (small to large) for the overall landscape and of each patches neighbors.
set Landscape-Elevation-list sort-on [ elevation ] patches
; show Landscape-Elevation-list
ask patches [
set Neighbor-Elevation-list sort-on [ elevation ] neighbors4
; print ""
; show Neighbor-Elevation-list
]
end
to setup-elevation
;; create an underlying slope in the base elevation of cells that slopes downwards to the lower left (southwest) corner of the landscape
ifelse Neighborhood-type != "Blue Island - Import" [
ask patches [
;; Create an elevation multiplier, which is the distance from the outlet to create a smooth slope
let elevation-multiplier distance patch (max-pxcor) (max-pycor)
;; adjusts the elevation of all cells based upon the slope-percent, set by a slider, and the elevation-multiplier.
set elevation 327 + ( elevation-multiplier * ( Slope-percent / 100 ) * cell-dimension ) ;; 350 as base because 127 subtracted for roads and 200 subtracted for swales
]
]
[
file-open "BIElevation.txt"
let elevation-list file-read
( foreach sort patches elevation-list
[ ask ?1 [
set elevation ?2
] ] )
file-close
]
ask patches [
set outflow? false
set flooded? false
set ever-flooded? false
set extreme-flooded? false
set ever-extreme-flooded? false
]
;; Determining the maximum elevation. This is used by the model in some of the visualization options.
set max-elevation max [ elevation ] of patches
if Vary-landscape? = true [
let height-differential ( [ elevation ] of patch 0 1 ) - ( [ elevation ] of patch 0 0 )
ask patches [
let elevation-randomizer random-normal 0 ( height-differential / 2 )
set elevation elevation + elevation-randomizer + 200
]
]
end
to setup-roads
if curbs? = true [
ask patches [
if cover = "r" [
;; roads
ifelse all? neighbors4 [ cover = "r" ] [
;; Intersection
set elevation elevation - 127 ;; 127 is 5" in mm
set intersection? true
]
[
;; not intersection
set elevation elevation - 127 ;; 127 is 5" in mm
set intersection? false
]
]
]
]
set list-non-roads-or-alleys patches with [ cover = "p" or cover = "i" or cover = "b" ]
end