-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSEASIM-MAC_4.0.3.nlogo
4101 lines (3569 loc) · 148 KB
/
SEASIM-MAC_4.0.3.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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;; Structure of the code ;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; In the code:
; - extensions are loaded (e.g. GIS for spatial data)
; - global, fish and landscape variables and parameters are defined
; - life stages, or "breeds", are defined
; - the "setup" procedure calls all procedures needed to intitialise the model before the spin up (e.g. sets up spawning area etc.), and sets the parameter values
; - the procedure "go" then calls all procedures in a time-step
; - the "spin-up" procedure calls "go" for 10 years, i.e. spins the model up for 10 years. Conditional statements are used to filter what should happen in the spin-up, and what should happen in the actual simulation
; - "go-ABC" calls "go" for as many years as we have data for ABC
; This can all be controlled from the interface using the appropriate buttons
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;; Required extensions are imported ;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
extensions
[
gis ; for remote-sensing and other spatial data
time ; tracks the date in a simulation
profiler ; provides diagnostics on the model
nw
]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;; A list of global variables and parameters ;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
globals ; variables and parameters are defined here, but their values are set later on
[
start-date
current-date
rm ; multiplier used to change parameter values etc. depending on whether the model is high or low resoltuion (see above)
z ; index for initialisation loop
report-tick-pre-spawn-mig ; time-step on which the pre-spawning migration is triggered (depends on which year in the simulation it is, Feb 1st)
report-tick-post-spawn-mig ; the same for the feeding migration
report-tick-pre-overwinter-mig; and again for the overwintering migration (October 1st)
run-year ; the current year in the simulation (0-8)
actual_year ; current "actual" year, i.e. start year + run-year
ann_step ; annual time-step, i.e. current time step in a year
month ; approximate simulation month (but some error due to 5-day time-step, i.e. 1-12)
month_days ; number of days in current month (e.g. 31 for Jan; used to apportion F among months appropriately)
start-spawn ; time-step on which spawning can commence (March 1st)
end-spawn ; final day that spawning can occur
raster ; a path to chl data
rasterSST ; the same for SST
phyto-data ; phytoplankton datasets
SST-data ; SST datasets
photo-data
currents-data
spawning_SST ; a list of SST on the spawning grounds each time-step over March, April and May. The mean of this list is used as input to the stock recruitment relationship
lat-data
lon-data
bath-data ; bathymetry
land ; shapefile of land (Ireland and Iceland)
ICES ; shapefile of ICES statistical rectangles
directory ; file path string used to load data
num-recruits ; the number of recruits to the juvenile stage (reset each year)
num-matured ; number of individuals that have reached sexual maturity (reset each year)
num-eaten ; number of individuals eaten explicitly by other mackerel (reset each year)
R_energy
egg-production ; number of eggs produced each year
larval-production ; the number of eggs that survive to larval stage each year
FeedingSSB ; biomass of mature individuals in the feeding area in mid July
sp_SSB ; SSB on May 1st
SumSSB ; biomass of mature individuals in mid July
MProp0 ; proportion of 0 year olds mature
MProp1 ; proportion of 1 year olds mature
MProp2 ; and 2 yr olds
MProp3 ; etc.
MProp4 ; etc..
M-at-36 ; average body mass of fish in the 36cm size class (for comparison with data we have)
min_lat_always_light
S0 ; normalizing constant for SMR
A0 ; normalizing constant for AMR
Cmax ; maximum ingestion rate g/day
Xprop_mac
boltz ; Boltzmann's constant eV K-1
Ea ; Activation energy (eV)
Ep ; energy content of phytoplankton kJ/g
Ae ; Assimilation efficiency
Ef ; energy content of flesh kJ/g
El ; energy content of lipid kJ/g
Fs ; energy costs of synthesising flesh kJ/g
Ls ; energy costs of synthesising lipid kJ/g
egg-mass
k ; Bertalanffy growth constant (day-1)
Loo ; Average maximum length (asymptotic length, cm)
L1 ; maximum length after first growing season
k1 ; maximum growth rate
Gmax ; age at maximum growth in first growing season
K2 ; Bertalanffy growth constant in units of 1/y
F ; Age-dependent fishing mortality (year-1)
F_multiplier
catch ; cumulative monthly catch
prop_catch_4a
C_lim ; limit fishing mortality used to prevent excessive redistribution of F outside closed areas
annual_c_lim ; sum of the monthly catch limits each year
Tref ; Reference temperature for the energy budget (12 °C or 285.15 k)
;Me ; egg mortality mortality (day-1, specified on interface)
Ar ; caudal fin aspect ratio
A ; swimming speed normalizing constant
Lm ; threshold length (cm) for maturity
Ma ; adult background mortality / day
Lhatch ; length at hatch
n_batch ; number of batches of eggs
Bint ; inter-batch interval length (days)
n_cohort ; Number of super-individuals in a cohort
a_w ; scaling exponent 1 for swimming veolicty
b_w ; scaling exponent 2 for swimming velocity
a_f ; coefficient for fecundity
b_f ; scaling exponent for fecundity
a_R
b_R
c_R
SA-TSB ; TSB for the SA for plot comparison
SA-SSB ; Same as above for SSB
SA-Rec ; and for recruitment
TSB ; Total Stock Biomass
SSB ; Spawning Stock Biomass
spawning-SSB ; SSB at spawning time
ldist ; length distribution calculated in quarter 1 on March 10th (i.e. the average date that surveys were conducted)
adist ; age distribution on feeding grounds on Aug 1 to match data
feb-adist
Q4ldist ; Quarter 4 length distribution calculated on November 18th to correspond with data
febldist ; length distribution on the feeding grounds on Aug 1
W3 ; average weight at age 3 on the feeding grounds
W4 ; and at age 4...
W5 ; age 5 etc.
W6
W7
W8
W9
W10
w11
w12
w13
dens-index
L-index
p-index
feed-area ; total area of patches visited by adult mackerel in the feeding period (km-2)
n_encounters ; number of encounters between predators and prey
catch-series
spin-up-rec
ssb_t0
month_n
;;;; some data for comparison with model outputs on the interface ;;;;
iessns_w3
iessns_w4
iessns_w5
iessns_w6
iessns_w7
sa_ssb
;;;; summary stats for ABC ;;;;
ABC-SSB ; SSB in mid July in years for which we have data for ABC
ABC-spawn-SSB
ABC-egg ; the same for eggs
ABC-rec
ABC-sum-w3
ABC-sum-w4
ABC-sum-w5
ABC-sum-w6
ABC-sum-w7
ABC-sum-w8
ABC-sum-w9
ABC-sum-w10
ABC-sum-w11
ABC-sum-w12
ABC-sum-w13
ABC-sp-w3
abc-sp-w4
abc-sp-w5
abc-sp-w6
abc-sp-w7
abc-sp-w8
abc-sp-w9
abc-sp-w10
abc-sp-w11
abc-sp-w12
;;;; summary stats for feeding strategy paper ;;;;
feed-ssb
output-area
]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;; Patch (landscape) variables ;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
patches-own ; patch variables
[
depth
X_phyto ; phytoplankton biomass (g m-2, calculated from chl)
SST ; Sea Surface temperature °C
photo_mult
u
v
PreSArea ; southern part of the spawning area where individuals aggregate before spawning (boolean)
SArea ; spawning area (bbolean)
Ricker_spawn_area ; box defined as spawning area used to obtain mean SST when fitting the Ricker stock-recruitment model. SST is averaged in this box over March, April and May for input to the stock recrtuitment relationship
NArea ; nursery area (boolean)
OWArea ; overwintering area (boolean)
shelf-edge
FArea ; feeding area (boolean)
latitude ; latitude
longitude ; longitude
true_north_heading
true_west_heading
A6 ; FAO fishing area 6 (west of Scotland/ north of Ireland)
A5 ; FAO fishing area 5 (Icelandic shelf)
A4
row ; ICES rectangle row
column ; ICES rectangle column
rectangle ; ICES rectangle defined by its row and column
feed-dist ; the rank of distance from feeding area (Shetland Isles) of all shelf edge patches. This is used to direct movement towards the feeding area along the shelf edge
spawn-dist
processed
spawn-processed
mac-density ; the density of mackerel on a patch at the end of a time-step (g patch-1)
mac-L ; average body length of mackerel on the current patch
feed-range ; whether or not any mackerel have visited the patch in the current feeding period
ocean ; whether or not the patch is in the ocean
North_Sea
coast
traditional_feeding_area?
presence
feeding_cue
profitability
]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;; Turtle (fish) variables ;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
turtles-own ; turtle variales
[
L ; length cm
standard-L ; standard length (head to base of tail fork, cm)
std-mass ; standard mass as calculated from length using known relationship (g)
structural-mass ; structural mass, i.e. total mass - gonad mass - lipid mass (g)
total-mass ; structural mass + lipid mass + gonad mass (g)
gonad-mass ; mass of the gonads (eggs, g)
energy-reserve ; kJ
maintenance-energy ; 10% of the energy stored at the beginning of spawning is saved for maintenance costs while fasting on the spawning grounds
Arrhenius ; Arrhenius function in the form exp(-Ea/K*SST) used to calculate temperature dependence of metabolic rate. Temp dependence of ingestion and growth is given relative to Tref and without reference to this variable in the code
ingestion-rate ; ingestion of a whiole super-individual (needed to calc. predation mortality) g/day
individual-IR ; sub-individual's ingestion rate g/ day
energy-assimilated ; kJ/day
energy-reserve-max ; kJ
func-response ; Holling type II functional response adjusts ingestion rate based on food and predator density
prey-choices ; identities of potential prey mackerel
prey-choice ; a randomly chosen individual from the potential prey
prey-fat-prop ; the proportion of a prey individual that is fat - used to calculate its energy content
prey-available
super-mass ; the mass of a super-individual (i.e. individual mass * number of individuals)
energy-tracker ; tracks the amount of energy assimilated before the energy budget costs are calculated. This is used to determine whether or not growth is limited by food
MR ; either active (AMR) and standard (SMR) metabolic rate depending on the conditions (kJ/day)
max-growth-rate ; maximum amount of length that can be added in a day (cm)
growth-rate ; realised amount of length added in a day if insufficient energy to grow maximally (cm)
growth-costs ; energy cost of adding new length and mass
max-R ; energy costs of synthesising a full season's eggs (kJ)
max-batch-R ; energy costs of synthesising a max sized batch of eggs (5 batches are deposited, kJ)
R ; energy accumulated for reproduction (kJ)
batches ; tracks the number of batches deposited and signals the end of spawning when reaching 5
spawning ; boolean
potential-fecundity ; the potential number of eggs that can be produced
realised-fecundity ; the actual number of eggs produced, depending on energy reserves
Amat ; the age at which an individual matured (yrs)
Lmat ; the length at which an individual matured (cm)
migrating ; boolean. Prevents individuals "moving locally" if true
feeding ; boolean. If individuals are feeding then they cannot return back down the shelf edge to the spawning areas
FK ; condition factor = 100*(W/L^3)
V_min ; max sustainable cruising speed (S_a)
realised-speed ; realised speed when migrating, i.e. within the limits of cruising speed with some random noise
divert-x ; the x coordinate of the patch to which an individual diverts if migration is obstructed by land
divert-y ; the y coordinate of the patch to which an individual diverts if migration is obstructed by land
embryo-duration ; total number of days it takes an egg to develop and hatch
development ; the number of days remaining before an egg hatches
abundance ; the actual number of individuals represented by a superindividual
age ; age (yrs)
Dage ; age (days)
gender ; male or female
exp-cohort ; All individuals in the 2007-year class. Variable is used to track them and check everything is working
Fa ; fishing mortality rate
Fda ; daily fishing mortality rate
num-fished ; proportion of a super-individual fished in a day
report-fished ; actual number of individuals in a super-individual fished per day
num-M ; proportion of a super-individual killed by background mortlaity per day
report-M ; actual number of indivuals removed from a super-individual by fishing
M ; natural mortlaity rate (year -1)
Mda ; M / day
inedible ; boolean; is the turtle a potential prey item to another? Used to determine if it is subject to explicit predation, or background mortality
spawners
cornered_x
cornered_y
optimal_x
optimal_y
d_x
d_y
d_cue_x
d_cue_y
gradient_x
gradient_y
Gx
Gy
mg
delta_Dx
delta_Dy
delta_Rx
delta_Ry
delta_Cx
delta_Cy
new_X
new_Y
optimal_orientation
Rs
p_quality_t-1
better_patch
launch_pad_R
]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;; Life stages ;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
breed [eggs egg] ; Eggs
breed [YS-larvae YS-larva] ; Yolk-sac larvae
breed [larvae larva] ; larvae
breed [juveniles juvenile] ; juveniles
breed [adults adult] ; adults
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Everything is set up prior to the spin-up ;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to setup ; initialization procedures
clear-all ; all variables are reset
;clear-plot
ifelse high-res = true
[
resize-world 0 round(478 / 3) 0 round(381 / 3)
set-patch-size 4
set rm 1
]
[
resize-world 0 round(478 / 6) 0 round(381 / 6)
set-patch-size 8
set rm 5
]
if enviro_inputs = "RS"
[
set start_year 1995
;set constant_rec? true
]
;[
; ;set start_year 1981
; set constant_rec? false
;]
set month_n (start_year - 1981) * 12
setup-dates ; time extension sets up the start date and it progresses by 1 every time-step
setup-chl ; loads initial chl
setup-SST ; load initial SST
setup-bathymetry ; bathymetry is loaded in
setup-land ; loads land shapefile
setup-coords ; assigns each patch a value for longitude and latitude
setup-ocean
setup-fishing-areas ; sets the FAO fishing areas according to long and lat
setup-feeding-grounds ; feeding grounds setup
setup-nursery-grounds ; nursery grounds setup
setup-overwintering-grounds ; overwintering grounds setup
setup-shelf-edge
setup-navigation
setup-spawning-grounds ; spawning grounds setup, needs to be done after shelf-edge, upon which it relies, is set up
setup-F ; fishing mortlaity is loaded in
setup-spin-up-recruits ; the population is loaded in from the spin-up simulation
;;;; parameter values are specified (excluding those on interface). A multiplier is used to obtain the appropriate parameter values depending on the temporal resolution ;;;;
set S0 44546413 * rm ; Hermann and Enders (2000), see TRACE
set Cmax (0.69 * rm) ; Hatanaka et al. 1957, see TRACE
set boltz (8.62 * (10 ^ -5)) ;
set Ea 0.5 ; (Gillooly et al. 2002; Sibly et al. 2015)
set ep 6.02 ; (Annis et al. 2011)
set Ae 0.95 ; (Lambert 1985)
set Ef 7 ; (Peters 1983)
set El 39.3 ; (Schmidt-nielsen 1997)
set Ls 14.7 ; Pullar and Webster (1977), see TRACE
set Fs 6 ; (Moses et al. 2008)
set egg-mass 0.001 ; (Sibly et al. 2015)
set k 0.314 * rm ; see TRACE
set Loo 42.4 ; see TRACE
set Tref 285.15 ; reference temperature for growth (arbitrary)
set A 0.15 ; Sambilay jr (1990)
set A0 88557766 * rm ; Dickson et al. (2000) see TRACE
set Ar 4.01 ; (fishbase, froese and Pualy 2016)
set L1 20 ; Villamor et al. 2004 see TRACE
set k1 0.0255 * rm ; Villamore et al. 2004 see TRACE
set Lm 26.2 ; fishbase, see TRACE ; see TRACE
set Ma 0.000411 * rm ; from the stock assessment
set Lhatch 0.3
set n_batch 5
set Bint 10
set n_cohort 70
set a_w 0.62 ; Sambilay jr 1990
set b_w 0.35 ; Sambilay jr 1990
set a_f 8.8
set b_f 3.02
set a_R 1.145121e-06
set b_R -1.323e-13
set c_R 7.019e-01
set Xprop_mac 0.064
;set c 1e-11
;set Me 0.105
set run-year 0
setup-turtles
reset-ticks
end
;;;; Dates are aligned to the "tick" counter using the time extension ;;;;
to setup-dates ; ticks are aligned to the corresponding date
set start-date time:create word start_year "-01-01" ; start date is Jan 1 1974 so that after the 10 year spin-up we begin on Jan 1 2004
set current-date time:anchor-to-ticks start-date (1 * rm) "days" ; each tick progresses the date by the appropriate number of days (1 for high res and 4 for low res)
set month 1
set month_days 31
end
;;;; Initial phytoplankton and SST are loaded in ;;;;
to setup-chl
;gis:load-coordinate-system ("F:/PhD/S.scombrus_movement_model/esriwkt.txt") ; See load-chl and load-SST procedure for full details
ifelse enviro_inputs = "RS"
[set phyto-data gis:load-dataset "F:/SEASIM-MAC_2020/inputs/sst_chl/phyto_1.asc"]
[set phyto-data gis:load-dataset (word "F:/SEASIM-MAC_2020/inputs/ESM_inputs/GFDL_" RCP "chl_1.asc")]
gis:set-world-envelope gis:envelope-of phyto-data
gis:apply-raster phyto-data X_phyto
;ask patches
;[
; set-color
;]
end
to set-color ; Generates colour bins for heatmap-style visual of phytoplankton on the interface. Can't use auto colouring because the values differ too much and scaling it is very computationally demanding
if X_phyto > 0
[
set pcolor scale-color green (log X_phyto 10) (log 0.001 10) (log 3 10)
]
; if X_phyto < 0.5
; [set pcolor sky]
; if X_phyto > 0.5 and X_phyto <= 0.75
; [set pcolor cyan]
; if X_phyto > 0.75 and X_phyto <= 1.25
; [set pcolor lime]
; if X_phyto > 1.25 and X_phyto <= 2.25
; [set pcolor green]
; if X_phyto > 2.25 and X_phyto <= 5
; [set pcolor yellow]
; if X_phyto > 5 and X_phyto <= 7.5
; [set pcolor orange]
; if X_phyto > 7.5
; [set pcolor red]
;]
;[]
end
to setup-SST
ifelse enviro_inputs = "RS"
[set SST-data gis:load-dataset "F:/SEASIM-MAC_2020/inputs/sst_chl/sst_1.asc"]
[set SST-data gis:load-dataset (word "F:/SEASIM-MAC_2020/inputs/ESM_inputs/GFDL_" RCP "tos_1.asc")]
gis:apply-raster SST-data SST
end
;;;; bathymetric data is loaded in ;;;;
to setup-bathymetry
set bath-data gis:load-dataset "F:/SEASIM-MAC_2020/inputs/sst_chl/bath.asc"
gis:apply-raster bath-data depth
end
;;;; land masses (Iceland and Ireland) are loaded in using shapefiles ;;;;
to setup-land
set land gis:load-dataset "F:/SEASIM-MAC_2020/inputs/na50km_50m_coast_lines.shp"
foreach gis:feature-list-of land
[
gis:set-drawing-color brown ; land is coloured grey
gis:draw ? 1.0 ; land is drawn with no transparency
gis:fill ? 2.0 ; land is filled
]
end
;;;; ICES fishing areas are defined using latitude and longitude ;;;;
to setup-fishing-areas
ask patches
[
ifelse (latitude >= 54.5) and (latitude <= 60) and (longitude >= -12) and (longitude <= -6.5) ; Division 6 (West of Scotland)
[set A6 true]
[set A6 false]
ifelse (X_phyto >= 0) and (latitude > 57.5) and (latitude <= 62.5) and (longitude > -4) and (longitude < 7)
[set A4 true]
[set A4 false]
ifelse (longitude <= -11) and (latitude >= 62) ; Division 5 (Icelandic waters)
[set A5 true]
[set A5 false]
]
end
;;;; coordinates of each patch are defined ;;;;
to setup-coords
set lon-data gis:load-dataset "F:/SEASIM-MAC_2020/inputs/sst_chl/lon.asc"
gis:set-world-envelope gis:envelope-of lon-data
gis:apply-raster lon-data longitude
set lat-data gis:load-dataset "F:/SEASIM-MAC_2020/inputs/sst_chl/lat.asc"
gis:set-world-envelope gis:envelope-of lat-data
gis:apply-raster lat-data latitude
ask patches with [((latitude >= 0) or (latitude <= 0)) and ((longitude >= 0) or (longitude <= 0))]
[
set longitude precision longitude 3
set latitude precision latitude 3
]
let north-data gis:load-dataset "F:/SEASIM-MAC_2020/inputs/true_north.asc"
gis:set-world-envelope gis:envelope-of lat-data
gis:apply-raster north-data true_north_heading
let west-data gis:load-dataset "F:/SEASIM-MAC_2020/inputs/true_west2.asc"
gis:set-world-envelope gis:envelope-of lat-data
gis:apply-raster west-data true_west_heading
end
;;;; Now migration "stop off" areas are defined (ie spawning, feeding, overwintering and nursery) ;;;;
to setup-spawning-grounds
ask patches
[
ifelse ((shelf-edge = true) and (longitude > -12) and (longitude < -8) and (latitude > 55) and (latitude < 58.5) ) or ( (shelf-edge = true) and (longitude > -13.5) and (longitude < -9) and (latitude > 54.5) and (latitude <= 55))
or ((shelf-edge = true) and (longitude > -16) and (longitude < -10) and (latitude >= 51.5) and (latitude <= 54.5) ) or ((shelf-edge = true) and (longitude > -16) and (longitude < -7.5) and (latitude >= 50.5) and (latitude <= 51.5))
or ((shelf-edge = true) and (longitude >= -14) and (longitude < -6) and (latitude >= 49) and (latitude <= 50.5)) or ((shelf-edge = true) and (longitude >= -14) and (longitude <= -4) and (latitude >= 47) and (latitude <= 49)) and (sst >= 0)
[
set SArea true
;set pcolor yellow
]
[set SArea false]
ifelse (X_phyto >= 0) or (SST >= 0) ; average-SST and chl are used to distinguish between land and water
[]
[set SArea false]
ifelse (SArea = true) and (pycor < 10)
[set PreSArea true]
[set PreSArea false]
ask patches with [((longitude > -12) and (longitude < -8) and (latitude > 55) and (latitude < 58.5)) or ((longitude > -13.5) and (longitude < -9) and (latitude > 54.5) and (latitude <= 55))
or ((longitude > -16) and (longitude < -10) and (latitude >= 51.5) and (latitude <= 54.5)) or ((longitude > -16) and (longitude < -7.5) and (latitude >= 50.5) and (latitude <= 51.5))
or ((longitude >= -14) and (longitude < -6) and (latitude >= 49) and (latitude <= 50.5)) or ((longitude >= -14) and (longitude <= -4) and (latitude >= 47) and (latitude <= 49))]
[set Ricker_spawn_area true]
]
end
to setup-feeding-grounds ; Everything above 62°N is a potential feeding area
ask patches
[
ifelse ((latitude >= 60) and (X_phyto >= 0)) or ((latitude > 57.5) and (latitude <= 62.5) and (longitude > -4) and (longitude < 7) and (ocean = true))
[set FArea true]
[set FArea false]
;if FArea = true
;[set pcolor black]
if (latitude > 55) and (latitude < 72) and (longitude > -6.5) and (longitude <= 18)
[set traditional_feeding_area? true]
]
end
to setup-nursery-grounds ; nursery grounds are defined by coords and by depth (< 200m deep, Jansen et al. 2014)
ask patches
[
ifelse (latitude > 50) and (latitude < 60) and (depth >= -200) and (longitude < -4) and (longitude > -12) and (sst >= 0) and (X_phyto >= 0)
[
set NArea true
;set pcolor red
]
[set NArea false]
]
end
to setup-overwintering-grounds ; Corresponds to FAO fishing area 6
ask patches
[
ifelse ((latitude > 57.5) and (latitude <= 62.5) and (longitude > -4) and (longitude < 7)) or ((latitude > 54) and (latitude <= 60) and (longitude > -12) and (longitude < -4)) and (X_phyto >= 0)
[set OWArea true]
[set OWArea false]
;if OWArea = true
;[set pcolor blue]
]
end
to setup-shelf-edge
ask patches
[
if ((depth >= -550) and (depth <= -50) and (longitude < 4) and (longitude > -13)) and ((longitude < -5) or ((longitude > 4) or (latitude < 50) or (latitude > 58.5)))
[
set shelf-edge true
set pcolor brown
]
]
end
;; to set up the position of the "destination" patches for each migration
to setup-navigation
ask patch 49 28
[
set feed-dist 1
set processed true
;set plabel feed-dist
]
while [150 < count patches with [(ocean = true) and (processed != true)]] ; The while condition is set at 20 <.... because there are 20 patches that satisfy the conditions to be "shelf-edge", but are separated from the shelf by deep water
[
ask patches with [(ocean = true)] ; i.e. patch 37 26, then more on next step
[
if processed != true [stop]
ask neighbors4 with [(processed != true) and (ocean = true)] ; ask neighbours on shelf edge that have not yet been processed
[
set feed-dist ([feed-dist] of myself) + 1
set processed true
;set plabel precision feed-dist 2
]
]
]
ask patches [set processed 0]
ask patch 46 3
[
set spawn-dist 1
set processed true
;set plabel spawn-dist
]
while [40 < count patches with [(ocean = true) and (processed != true) and (shelf-edge = true)]] ; The while condition is set at 20 <.... because there are 20 patches that satisfy the conditions to be "shelf-edge", but are separated from the shelf by deep water
[
ask patches with [(ocean = true) and (shelf-edge = true)] ; i.e. patch 37 26, then more on next step
[
if processed != true [stop]
ask neighbors4 with [(processed != true) and (ocean = true) and (shelf-edge = true)] ; ask neighbours on shelf edge that have not yet been processed
[
set spawn-dist ([spawn-dist] of myself) + 1
set processed true
;set plabel precision spawn-dist 2
]
]
]
end
;;;; fishing mortalities-at-age are setup ;;;;
to setup-F
file-open (word "F:/SEASIM-MAC_2020/inputs/F/" start_year ".txt")
set F (list file-read file-read file-read file-read file-read file-read file-read file-read file-read file-read file-read file-read file-read file-read file-read file-read)
file-close
end
to setup-spin-up-recruits
set spin-up-rec (list 5811487 5081028 3613849 3372139 4359034 4140770 4128829 4388517 3762477 3573130 3214451 3346363 3456082 3112788 2943059 2792843 2994638 2926988 2977574 3528098 2952146 4749644 5646271 3696698 5397194 7070591
6866257 5176997 4658201 4188877 5507435 7152461 5944485 5795704 5807466 5273724 7454724 8514386 8417954 8417954)
end
;;;; The initial population is imported ;;;;
to setup-turtles
file-open (word "F:/SEASIM-MAC_2020/inputs/initial_numbers/" start_year ".txt")
let initial_numbers (list file-read file-read file-read file-read file-read file-read file-read file-read file-read file-read file-read file-read file-read)
file-close
set z 0
while [z < 13]
[
create-turtles n_cohort ; a turtles is created for each row from the file
[
set age z + 0.5
set dage round (age * 365)
ifelse age < 3
[
set breed juveniles
set size 1
]
[
set breed adults
set size 2
]
set L 42.4 * (1 - exp (- 0.314 * age))
set abundance ((item z initial_numbers) / n_cohort) * 0.8 * 1000
ifelse who mod 2 = 0
[set gender 0]
[set gender 1]
]
set z z + 1
]
ask turtles
[
ifelse breed = juveniles ; life stage is determined by the "size" of the individual.
[
set color grey
set shape "fish"
set std-mass 0.00285 * (L ^ (3.325))
set energy-reserve-max ((std-mass * 0.59) * 39.3)
set energy-reserve energy-reserve-max * 0.5
set structural-mass (std-mass * 0.76)
set total-mass structural-mass + (energy-reserve / 39.3)
set standard-L (L - 0.1561) / 1.1396
set migrating false
set Mda (0.15 / 73)
move-to one-of patches with [(NArea = true) and (ocean = true)]
]
[
set color grey
set shape "fish"
set std-mass 0.00285 * (L ^ (3.325))
set energy-reserve-max ((std-mass * 0.59) * 39.3)
set energy-reserve energy-reserve-max * 0.5
set structural-mass (std-mass * 0.76)
set total-mass structural-mass + (energy-reserve / 39.3)
set standard-L (L - 0.1561) / 1.1396
set migrating false
set Mda (0.15 / 73)
move-to one-of patches with [(OWArea = true) and (sst >= 0)]
]
hatch n_multiplier - 1
[
set abundance abundance / n_multiplier
]
set abundance abundance / n_multiplier
]
end
to setup-ocean
ask patches with [((SST >= 0) or (SST <= 0)) and (X_phyto >= 0)]
[set ocean true]
ask patches
[
if count neighbors4 with [ocean = true] < 4
[set coast true]
]
ask patches with [(longitude > -3) and (latitude > 51) and (latitude < 59.1)]
[
set pcolor grey
set North_Sea true
]
set spawning_sst []
end
;;;; "loop-chl" and "loop-SST" are called only in the spin-up. They repeat the forcing for 2007 ;;;;
to loop-chl
if ((ticks - (run-year * (365 / rm))) mod (10 / rm) != 0) and (ticks - (run-year * (365 / rm)) != 73) ; Every n days (depending on high or low res) a new chl map is loaded. This is not done over winter due to a lack of data
[
set directory "F:/SEASIM-MAC_2020/inputs/sst_chl" ; location on pc of chl data
set raster (word directory "/phyto_" (((((ticks - (run-year * (365 / rm))) + 1) / (10 / rm)))) ".asc") ; appropriate file identified
set phyto-data gis:load-dataset raster
gis:set-world-envelope gis:envelope-of phyto-data ; model extent set to that of the data
gis:apply-raster phyto-data X_phyto ; patches are given values for phytoplankton biomass from the phyto-data
ask patches
[
set-color ; set patch colour according to its chl
]
]
end
to loop-SST ; SST is loaded in the same way as chl
if (ticks >= (60 / rm)) and ((ticks - (run-year * (365 / rm))) mod (10 / rm) != 0) and (ticks - (run-year * (365 / rm)) != 73)
[
set directory "F:/SEASIM-MAC_2020/inputs/sst_chl"
set rasterSST (word directory "/sst_" (((((ticks - (run-year * (365 / rm))) + 1) / (10 / rm)))) ".asc")
set SST-data gis:load-dataset rasterSST
gis:apply-raster SST-data SST
]
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;; The procedures called by "go" are evaluated on every time step during the actual simulations ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Here the spine of the model can be seen and the sequence in which procedures are implemented. See process, overview and scheduling section
;;;; in TRACE section 2 for a written description of the model schedule ;;;;
to go
tick
set ann_step ann_step + 1
; stop the simulation if using remote-sensing inputs and it is 2019
if (enviro_inputs = "RS") and (ticks = 1752)
[stop]
;;;; SST and phytoplankton are loaded in first ;;;;
ifelse enviro_inputs = "ESM"
[
load-ESM-inputs
]
[
ifelse run-year >= 10 ; if run year is less than 10 (i.e. still in the spin up), and inputs are remote-sensing data, then inputs are run on a loop
[
load-chl
load-SST
]
[
loop-chl
loop-SST
]
]
;;;; SSt on the spawning grounds is recorded over the months March, April and May. The mean of these SST recordings is used as input the the stock-recruitment relationship
if (ann_step >= (60 / rm)) and (ann_step < (120 / rm))
[calc-spawning-SST]
calc-run-year ; the current run year is calculated and used for other procedures
calc_month
time:go ; this aligns NetLogo "ticks" with real dates that are shown on the interface
;;;; Fishing mortality is loaded on the first day of each year ;;;;
if ticks - (run-year * (365 / rm)) = 1 and (((constant_rec? = true) and (run-year >= 10)) or ((constant_rec? = false))) ; new fishing mortality is only loaded if we're greater than 10 years in, i.e. the spin up is finished
[load-F] ; fishing mortality data is loaded in
;;;; If in the spin-up, recruits enter the model at the end of each year. After the spin-up this procedure is not called because adults spawn eggs and recruitment emerges
if (((ticks < (3650 / rm)) and (force_spin_up_rec = true)) or (Recruitment = "Ricker")) and (ticks - (run-year * (365 / rm)) = (360 / rm))
[input-recruits]
;;;; Migration departure dates are then calculated ;;;;
if (ticks - (run-year * (round(365 / rm))) = 2) or (ticks = 0) ; at the start of each year the time-step on which migrations are triggered is calculated
[
calc-migration-ticks
]
;;;; On the first day of each year annual population metrics are reset ;;;;
if (ticks mod (365 / rm) = 0) or (ticks = 0)
[
set num-recruits 0
set num-matured 0
set egg-production 0
set num-eaten 0
set larval-production 0
set R_energy 0
set ann_step 0
set annual_c_lim 0
set catch 0
set spawning_SST [] ; start an empty list for spawning SST each year. This will be population with mean SST on spawning grounds each time-step over MArch, April and May, then averaged for use in the RIcker model
ask patches
[
set feed-range false
set presence 0
]
ask turtles
[
set better_patch false
]
]
;;;; individuals then perform their daily routine ;;;
;;;; Restricted area search mechanism for adult movement while feeding ;;;;
repeat 5 ; repeated 5 times per time-step, i.e. once per day
[
ask adults
[
if (feeding_strategy = "GAS") and (feeding = true)
[
calc-patch-quality ; calculates current patch quality
GAS ; bases new movement on whether or no new location is more profitable than the old
]
]
]
ask turtles
[
;;;; Mortality is calculated first ;;;;
calc-F ; fishing mortality
calc-M ; background or "natural" mortality
calc-starvation ; starvation mortality
;;;; After mortality individuals move ;;;;
if breed != eggs ; eggs don't move or have an energy budget
[
calc-V_min ; minimum swimming velocity is calculated
drift ; egg and larval drift
;;;; migrations ;;;;
if (breed = juveniles) or (breed = adults)
[
spawn-migrate
feed-migrate
overwinter-migrate
ifelse (feeding_strategy = "GAS") and (feeding = true) and (ticks > 3650 / rm)
[]
[move-locally] ; individuals move locally if not migrating
]
;;;; A certain form of the Arrhenius function is needed for metabolic rate calculations and is calculated here ;;;;
if (SST <= 0) or (SST >= 0)
[
set Arrhenius exp(- Ea / (boltz * (SST + 273.15)))
]
;;;; the appropriate elements of the energy budget are calculated (minus reproduction). Energy is allocated to the processes in different orders depending on life stage and time of year. Energy storage is called by the growth procedure for juveniles and adults, wheras larvae do not store energy ;;;;
calc-ingestion
calc-assimilation
calc-maintenance
calc-growth
calc-total-mass
]
;;;; Individuals can then transform into the next life stage if they satisfy certain conditions ;;;;
transform
]
;;;; Next, at the start of the spawning period, adults calculate their potential fecundity and the associated energy costs ;;;;
ask adults
[
if ticks = start-spawn - 1
[calc-reproduction]
spawn ; when in the spawning period, individuals allocate the required amount of energy to developing eggs in the procedure "spawn". This procedure then calls another, "deposit eggs", in which batches of eggs are introduced into the model
]
;;;; New egg individuals calculate their development, which must occur after they are spawned ensure they develop from age 0 (days) ;;;;
ask eggs
[calc-egg-development]
;;;; Individuals age (days post hatch) ;;;;