-
Notifications
You must be signed in to change notification settings - Fork 1
/
MalishevBullKearney_Supp.Rmd
1990 lines (1811 loc) · 72.1 KB
/
MalishevBullKearney_Supp.Rmd
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
---
title: Appendices for ‘An individual-based model of ectotherm movement integrating metabolic and microclimatic constraints’
author:
- |-
_^1^ Centre of Excellence for Biosecurity Risk Analysis, ^2^ School of BioSciences, University of Melbourne, Parkville, Melbourne, 3010, Australia_
_^3^ School of Biological Sciences, Flinders University, Adelaide, 5001, Australia_
^['This Supplementary Material can be found at https://github.com/darwinanddavis/MalishevBullKearney or https://doi.org/10.5281/zenodo.998145.']
bibliography: /Users/malishev/Documents/Melbourne Uni/Thesis_2016/library.bib
output:
word_document:
highlight: tango
keep_md: yes
pandoc_args: --smart
reference: mystyles.docx
toc: yes
pdf_document:
template: null
toc: yes
html_document:
code_folding: hide
depth: 3
number_sections: no
toc: yes
toc_float: yes
inludes:
before_body: before_body.tex
subtitle: Matthew Malishev^1,2^*, C. Michael Bull^3^, & Michael R. Kearney^2^
tags:
- nothing
- nothingness
abstract: "*Corresponding author: matthew.malishev@gmail.com \n"
---
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ TeX: { equationNumbers: {autoNumber: "all"} } });
</script>
#####
# Data collection
All data were collected at the sleepy lizard habitat study site (139°21'E, 33°55'S) at the Bundey Bore field station in the mid-north of South Australia during the breeding season (September to December, 2009). Animal data are for the adult sleepy lizard (n = 60). Individual animals were tagged with GPS units, step counters ('waddleometers'), and skin surface temperature probes at the beginning of the breeding season and tracked throughout the season using radio telemetry. Animals were captured and GPS data downloaded every two weeks throughout the breeding season for each individual, with batteries for the units replaced when needed. GPS units reported locations every 10 minutes, waddleometers recorded step counts every 2 minutes, and temperature probes recorded skin surface temperature every 2 minutes.
The simulation model uses a 2-minute time step to correspond to the frequency of observed data.
#####
# NicheMapR microclimate model overview
The NicheMapR microclimate model calculates hourly estimates of solar and infrared radiation, air temperature at 1 m and 1 cm above ground level, wind velocity, relative humidity, and soil temperature at different intervals, e.g. 0 cm, 10 cm, 20 cm, 50 cm, 100 cm, and 200 cm. The model uses minimum and maximum daily air temperature, wind speed, relative humidity, soil properties (conductivity, specific heat, density, solar reflectivity, emissivity), as well as the roughness height, slope, and aspect. Climatic data are gathered from a global data set of monthly mean daily minimum and maximum air temperatures and monthly mean daily humidity and wind speeds. Soil surface temperatures are computed using heat balance equations, accounting for heat exchange via radiation, convection, conduction, and evaporation.
For simulation time steps, the microclimate model verifies the microclimate conditions for the current simulation hour of the day, e.g. noon or 18:00, and location in space, i.e. the study site for the observed animal data, and updates patches in the simulation landscape (either sun or shade) with these microenvironment conditions. As the simulated animal moves in or out of these patches at each time step, the animal updates its current $T_b$, including rates of change in $T_b$ per 2-minute time step.
The `onelump_varenv.R` and `DEB.R` functions update the individual internal thermal and metabolic states, respectively. See below for both model functions.
#####
### `onelump_varenv.R`.
`onelump_varenv.R` available on [**Github**](https://github.com/darwinanddavis/MalishevBullKearney/blob/master/onelump_varenv.R).
```{r error=F, message=F, warning=F}
onelump_varenv<-function (t = seq(1, 3600, 60), time = 0, Tc_init = 5, thresh = 29,
AMASS = 500, lometry = 2, Tairf = Tairfun, Tradf = Tradfun,
velf = velfun, Qsolf = Qsolfun, Zenf = Zenfun, Flshcond = 0.5,
q = 0, Spheat = 3073, EMISAN = 0.95, rho = 932, ABS = 0.85,
colchange = 0, lastt = 0, ABSMAX = 0.9, ABSMIN = 0.6, customallom = c(10.4713,
0.688, 0.425, 0.85, 3.798, 0.683, 0.694, 0.743), shape_a = 1,
shape_b = 0.5, shape_c = 0.5, posture = "n", FATOSK = 0.4,
FATOSB = 0.4, sub_reflect = 0.2, PCTDIF = 0.1, press = 101325)
{
sigma <- 5.67e-08
Tair <- Tairf(time + t)
vel <- velf(time + t)
Qsol <- Qsolf(time + t)
Trad <- Tradf(time + t)
Zen <- Zenf(time + t)
Zenith <- Zen * pi/180
Tc <- Tc_init
Tskin <- Tc + 0.1
RHskin <- 100
vel[vel < 0.01] <- 0.01
abs2 <- ABS
if (colchange >= 0) {
abs2 <- min(ABS + colchange * (t - lastt), ABSMAX)
}
else {
abs2 <- max(ABS + colchange * (t - lastt), ABSMIN)
}
S2 <- 1e-04
DENSTY <- 101325/(287.04 * (Tair + 273))
THCOND <- 0.02425 + (7.038 * 10^-5 * Tair)
VISDYN <- (1.8325 * 10^-5 * ((296.16 + 120)/((Tair + 273) +
120))) * (((Tair + 273)/296.16)^1.5)
m <- AMASS/1000
C <- m * Spheat
V <- m/rho
Qgen <- q * V
L <- V^(1/3)
Flshcond <- 0.5
if (lometry == 0) {
ALENTH <- (V/shape_b * shape_c)^(1/3)
AWIDTH <- ALENTH * shape_b
AHEIT <- ALENTH * shape_c
ATOT <- ALENTH * AWIDTH * 2 + ALENTH * AHEIT * 2 + AWIDTH *
AHEIT * 2
ASILN <- ALENTH * AWIDTH
ASILP <- AWIDTH * AHEIT
L <- AHEIT
if (AWIDTH <= ALENTH) {
L <- AWIDTH
}
else {
L <- ALENTH
}
R <- ALENTH/2
}
if (lometry == 1) {
R1 <- (V/(pi * shape_b * 2))^(1/3)
ALENTH <- 2 * R1 * shape_b
ATOT <- 2 * pi * R1^2 + 2 * pi * R1 * ALENTH
AWIDTH <- 2 * R1
ASILN <- AWIDTH * ALENTH
ASILP <- pi * R1^2
L <- ALENTH
R2 <- L/2
if (R1 > R2) {
R <- R2
}
else {
R <- R1
}
}
if (lometry == 2) {
A1 <- ((3/4) * V/(pi * shape_b * shape_c))^0.333
B1 <- A1 * shape_b
C1 <- A1 * shape_c
P1 <- 1.6075
ATOT <- (4 * pi * (((A1^P1 * B1^P1 + A1^P1 * C1^P1 +
B1^P1 * C1^P1))/3)^(1/P1))
ASILN <- max(pi * A1 * C1, pi * B1 * C1)
ASILP <- min(pi * A1 * C1, pi * B1 * C1)
S2 <- (A1^2 * B1^2 * C1^2)/(A1^2 * B1^2 + A1^2 * C1^2 +
B1^2 * C1^2)
Flshcond <- 0.5 + 6.14 * B1 + 0.439
}
if (lometry == 3) {
ATOT <- (10.4713 * AMASS^0.688)/10000
AV <- (0.425 * AMASS^0.85)/10000
ASILN <- (3.798 * AMASS^0.683)/10000
ASILP <- (0.694 * AMASS^0.743)/10000
R <- L
}
if (lometry == 4) {
ATOT = (12.79 * AMASS^0.606)/10000
AV = (0.425 * AMASS^0.85)/10000
ZEN <- 0
PCTN <- 1.38171e-06 * ZEN^4 - 0.000193335 * ZEN^3 + 0.00475761 *
ZEN^2 - 0.167912 * ZEN + 45.8228
ASILN <- PCTN * ATOT/100
ZEN <- 90
PCTP <- 1.38171e-06 * ZEN^4 - 0.000193335 * ZEN^3 + 0.00475761 *
ZEN^2 - 0.167912 * ZEN + 45.8228
ASILP <- PCTP * ATOT/100
R <- L
}
if (lometry == 5) {
ATOT = (customallom[1] * AMASS^customallom[2])/10000
AV = (customallom[3] * AMASS^customallom[4])/10000
ASILN = (customallom[5] * AMASS^customallom[6])/10000
ASILP = (customallom[7] * AMASS^customallom[8])/10000
R <- L
}
if (max(Zen) >= 90) {
Qnorm <- 0
}
else {
Qnorm <- (Qsol/cos(Zenith))
}
if (Qnorm > 1367) {
Qnorm <- 1367
}
if (posture == "p") {
Qabs <- (Qnorm * (1 - PCTDIF) * ASILP + Qsol * PCTDIF *
FATOSK * ATOT + Qsol * sub_reflect * FATOSB * ATOT) *
abs2
}
if (posture == "n") {
Qabs <- (Qnorm * (1 - PCTDIF) * ASILN + Qsol * PCTDIF *
FATOSK * ATOT + Qsol * sub_reflect * FATOSB * ATOT) *
abs2
}
if (posture == "b") {
Qabs <- (Qnorm * (1 - PCTDIF) * (ASILN + ASILP)/2 + Qsol *
PCTDIF * FATOSK * ATOT + Qsol * sub_reflect * FATOSB *
ATOT) * abs2
}
Rrad <- ((Tskin + 273) - (Trad + 273))/(EMISAN * sigma *
(FATOSK + FATOSB) * ATOT * ((Tskin + 273)^4 - (Trad +
273)^4))
Rrad <- 1/(EMISAN * sigma * (FATOSK + FATOSB) * ATOT * ((Tc +
273)^2 + (Trad + 273)^2) * ((Tc + 273) + (Trad + 273)))
Re <- DENSTY * vel * L/VISDYN
PR <- 1005.7 * VISDYN/THCOND
if (lometry == 0) {
NUfor <- 0.102 * Re^0.675 * PR^(1/3)
}
if (lometry == 3 | lometry == 5) {
NUfor <- 0.35 * Re^0.6
}
if (lometry == 1) {
if (Re < 4) {
NUfor = 0.891 * Re^0.33
}
else {
if (Re < 40) {
NUfor = 0.821 * Re^0.385
}
else {
if (Re < 4000) {
NUfor = 0.615 * Re^0.466
}
else {
if (Re < 40000) {
NUfor = 0.174 * Re^0.618
}
else {
if (Re < 4e+05) {
NUfor = 0.0239 * Re^0.805
}
else {
NUfor = 0.0239 * Re^0.805
}
}
}
}
}
}
if (lometry == 2 | lometry == 4) {
NUfor <- 0.35 * Re^(0.6)
}
hc_forced <- NUfor * THCOND/L
GR <- abs(DENSTY^2 * (1/(Tair + 273.15)) * 9.80665 * L^3 *
(Tskin - Tair)/VISDYN^2)
Raylei <- GR * PR
if (lometry == 0) {
NUfre = 0.55 * Raylei^0.25
}
if (lometry == 1 | lometry == 3 | lometry == 5) {
if (Raylei < 1e-05) {
NUfre = 0.4
}
else {
if (Raylei < 0.1) {
NUfre = 0.976 * Raylei^0.0784
}
else {
if (Raylei < 100) {
NUfre = 1.1173 * Raylei^0.1344
}
else {
if (Raylei < 10000) {
NUfre = 0.7455 * Raylei^0.2167
}
else {
if (Raylei < 1e+09) {
NUfre = 0.5168 * Raylei^0.2501
}
else {
if (Raylei < 1e+12) {
NUfre = 0.5168 * Raylei^0.2501
}
else {
NUfre = 0.5168 * Raylei^0.2501
}
}
}
}
}
}
}
if (lometry == 2 | lometry == 4) {
Raylei = (GR^0.25) * (PR^0.333)
NUfre = 2 + 0.6 * Raylei
}
hc_free <- NUfre * THCOND/L
hc_comb <- hc_free + hc_forced
Rconv <- 1/(hc_comb * ATOT)
Nu <- hc_comb * L/THCOND
hr <- 4 * EMISAN * sigma * ((Tc + Trad)/2 + 273)^3
hc <- hc_comb
if (lometry == 2) {
j <- (Qabs + Qgen + hc * ATOT * ((q * S2)/(2 * Flshcond) +
Tair) + hr * ATOT * ((q * S2)/(2 * Flshcond) + Trad))/C
}
else {
j <- (Qabs + Qgen + hc * ATOT * ((q * R^2)/(4 * Flshcond) +
Tair) + hr * ATOT * ((q * S2)/(2 * Flshcond) + Trad))/C
}
kTc <- ATOT * (Tc * hc + Tc * hr)/C
k <- ATOT * (hc + hr)/C
Tcf <- j/k
Tci <- Tc
Tc <- (Tci - Tcf) * exp(-1 * k * t) + Tcf
timethresh <- log((thresh - Tcf)/(Tci - Tcf))/(-1 * k)
tau <- (rho * V * Spheat)/(ATOT * (hc + hr))
dTc <- j - kTc
list(Tc = Tc, Tcf = Tcf, tau = tau, dTc = dTc, abs2 = abs2)
}
```
#####
### `DEB.R`.
`DEB.R` function available on [**Github**](https://github.com/darwinanddavis/MalishevBullKearney/blob/master/DEB.R).
```{r error=F, message=F, warning=F}
DEB<-function (step = 1/24, z = 7.997, del_M = 0.242, F_m = 13290 *
step, kap_X = 0.85, v = 0.065 * step, kap = 0.886, p_M = 32 *
step, E_G = 7767, kap_R = 0.95, k_J = 0.002 * step, E_Hb = 73590,
E_Hj = E_Hb, E_Hp = 186500, h_a = 2.16e-11/(step^2), s_G = 0.01,
T_REF = 20, TA = 8085, TAL = 18721, TAH = 9E+4, TL = 288,
TH = 315, E_0 = 1040000, f = 1, E_sm = 1116, K = 1, andens_deb = 1,
d_V = 0.3, d_E = 0.3, d_Egg = 0.3, mu_X = 525000, mu_E = 585000,
mu_V = 5e+05, mu_P = 480000, kap_X_P = 0.1, n_X = c(1, 1.8,
0.5, 0.15), n_E = c(1, 1.8, 0.5, 0.15), n_V = c(1, 1.8,
0.5, 0.15), n_P = c(1, 1.8, 0.5, 0.15), n_M_nitro = c(1,
4/5, 3/5, 4/5), clutchsize = 2, clutch_ab = c(0.085,
0.7), viviparous = 0, minclutch = 0, batch = 1, lambda = 1/2,
VTMIN = 26, VTMAX = 39, ma = 1e-04, mi = 0, mh = 0.5, arrhenius = matrix(data = matrix(data = c(rep(TA,
8), rep(TAL, 8), rep(TAH, 8), rep(TL, 8), rep(TH, 8)),
nrow = 8, ncol = 5), nrow = 8, ncol = 5), acthr = 1,
X = 10, E_pres = 6011.93, V_pres = 3.9752^3, E_H_pres = 73592,
q_pres = 0, hs_pres = 0, surviv_pres = 1, Es_pres = 0, cumrepro = 0,
cumbatch = 0, p_B_past = 0, stage = 1, breeding = 0, pregnant = 0,
Tb = 33)
{
q_init <- q_pres
E_H_init <- E_H_pres
hs_init <- hs_pres
fecundity <- 0
clutches <- 0
clutchenergy = E_0 * clutchsize
n_O <- cbind(n_X, n_V, n_E, n_P)
CHON <- c(12, 1, 16, 14)
wO <- CHON %*% n_O
w_V = wO[3]
M_V <- d_V/w_V
y_EX<-kap_X*mu_X/mu_E # yield of reserve on food
y_XE<-1/y_EX # yield of food on reserve
y_VE<-mu_E*M_V/E_G # yield of structure on reserve
y_PX<-kap_X_P*mu_X/mu_P # yield of faeces on food
y_PE<-y_PX/y_EX # yield of faeces on reserve 0.143382353
nM <- matrix(c(1, 0, 2, 0, 0, 2, 1, 0, 0, 0, 2, 0, n_M_nitro),
nrow = 4)
n_M_nitro_inv <- c(-1 * n_M_nitro[1]/n_M_nitro[4], (-1 *
n_M_nitro[2])/(2 * n_M_nitro[4]), (4 * n_M_nitro[1] +
n_M_nitro[2] - 2 * n_M_nitro[3])/(4 * n_M_nitro[4]),
1/n_M_nitro[4])
n_M_inv <- matrix(c(1, 0, -1, 0, 0, 1/2, -1/4, 0, 0, 0, 1/2,
0, n_M_nitro_inv), nrow = 4)
JM_JO <- -1 * n_M_inv %*% n_O
etaO <- matrix(c(y_XE/mu_E * -1, 0, 1/mu_E, y_PE/mu_E, 0,
0, -1/mu_E, 0, 0, y_VE/mu_E, -1/mu_E, 0), nrow = 4)
w_N <- CHON %*% n_M_nitro
Tcorr = exp(TA * (1/(273 + T_REF) - 1/(273 + Tb)))/(1 + exp(TAL *
(1/(273 + Tb) - 1/TL)) + exp(TAH * (1/TH - 1/(273 + Tb))))
M_V = d_V/w_V
p_MT = p_M * Tcorr
k_Mdot = p_MT/E_G
k_JT = k_J * Tcorr
p_AmT = p_MT * z/kap
vT = v * Tcorr
E_m = p_AmT/vT
F_mT = F_m * Tcorr
g = E_G/(kap * E_m)
E_scaled = E_pres/E_m
V_max = (kap * p_AmT/p_MT)^(3)
h_aT = h_a * Tcorr
L_T = 0
L_pres = V_pres^(1/3)
L_max = V_max^(1/3)
scaled_l = L_pres/L_max
kappa_G = (d_V * mu_V)/(w_V * E_G)
yEX = kap_X * mu_X/mu_E
yXE = 1/yEX
yPX = kap_X_P * mu_X/mu_P
mu_AX = mu_E/yXE
eta_PA = yPX/mu_AX
w_X = wO[1]
w_E = wO[3]
w_V = wO[2]
w_P = wO[4]
if (E_H_pres <= E_Hb) {
dLdt = (vT * E_scaled - k_Mdot * g * V_pres^(1/3))/(3 *
(E_scaled + g))
V_temp = (V_pres^(1/3) + dLdt)^3
dVdt = V_temp - V_pres
rdot = vT * (E_scaled/L_pres - (1 + L_T/L_pres)/L_max)/(E_scaled +
g)
}
else {
rdot = vT * (E_scaled/L_pres - (1 + L_T/L_pres)/L_max)/(E_scaled +
g)
dVdt = V_pres * rdot
if (dVdt < 0) {
dVdt = 0
}
}
V = V_pres + dVdt
if (V < 0) {
V = 0
}
svl = V^(0.3333333333333)/del_M * 10
if (E_H_pres <= E_Hb) {
Sc = L_pres^2 * (g * E_scaled)/(g + E_scaled) * (1 +
((k_Mdot * L_pres)/vT))
dUEdt = -1 * Sc
E_temp = ((E_pres * V_pres/p_AmT) + dUEdt) * p_AmT/(V_pres +
dVdt)
dEdt = E_temp - E_pres
}
else {
if (Es_pres > 1e-07 * E_sm * V_pres) {
dEdt = (p_AmT * f - E_pres * vT)/L_pres
}
else {
dEdt = (p_AmT * 0 - E_pres * vT)/L_pres
}
}
E = E_pres + dEdt
if (E < 0) {
E = 0
}
p_M = p_MT * V_pres
p_J = k_JT * E_H_pres
if (Es_pres > 1e-07 * E_sm * V_pres) {
p_A = V_pres^(2/3) * p_AmT * f
}
else {
p_A = 0
}
p_X = p_A/kap_X
p_C = (E_m * (vT/L_pres + k_Mdot * (1 + L_T/L_pres)) * (E_scaled *
g)/(E_scaled + g)) * V_pres
p_R = (1 - kap) * p_C - p_J
if (E_H_pres < E_Hp) {
if (E_H_pres <= E_Hb) {
U_H_pres = E_H_pres/p_AmT
dUHdt = (1 - kap) * Sc - k_JT * U_H_pres
dE_Hdt = dUHdt * p_AmT
}
else {
dE_Hdt = (1 - kap) * p_C - p_J
}
}
else {
dE_Hdt = 0
}
E_H = E_H_init + dE_Hdt
if (E_H_pres >= E_Hp) {
p_D = p_M + p_J + (1 - kap_R) * p_R
}
else {
p_D = p_M + p_J + p_R
}
p_G = p_C - p_M - p_J - p_R
if ((E_H_pres <= E_Hp) | (pregnant == 1)) {
p_B = 0
}
else {
if (batch == 1) {
batchprep = (kap_R/lambda) * ((1 - kap) * (E_m *
(vT * V_pres^(2/3) + k_Mdot * V_pres)/(1 + (1/g))) -
p_J)
if (breeding == 0) {
p_B = 0
}
else {
if (cumrepro < batchprep) {
p_B = p_R
}
else {
p_B = batchprep
}
}
}
else {
p_B = p_R
}
}
if (E_H_pres > E_Hp) {
if (cumrepro < 0) {
cumrepro = 0
}
else {
cumrepro = cumrepro + p_R * kap_R - p_B_past
}
}
cumbatch = cumbatch + p_B
if (stage == 2) {
if (cumbatch < 0.1 * clutchenergy) {
stage = 3
}
}
if (E_H <= E_Hb) {
stage = 0
}
else {
if (E_H < E_Hj) {
stage = 1
}
else {
if (E_H < E_Hp) {
stage = 2
}
else {
stage = 3
}
}
}
if (cumbatch > 0) {
if (E_H > E_Hp) {
stage = 4
}
else {
stage = stage
}
}
if ((cumbatch > clutchenergy) | (pregnant == 1)) {
if (viviparous == 1) {
if ((pregnant == 0) & (breeding == 1)) {
v_baby = v_init_baby
e_baby = e_init_baby
EH_baby = 0
pregnant = 1
testclutch = floor(cumbatch/E_0)
if (testclutch > clutchsize) {
clutchsize = testclutch
clutchenergy = E_0 * clutchsize
}
if (cumbatch < clutchenergy) {
cumrepro_temp = cumrepro
cumrepro = cumrepro + cumbatch - clutchenergy
cumbatch = cumbatch + cumrepro_temp - cumrepro
}
}
if (hour == 1) {
v_baby = v_baby_init
e_baby = e_baby_init
EH_baby = EH_baby_init
}
if (EH_baby > E_Hb) {
if ((Tb < VTMIN) | (Tb > VTMAX)) {
}
cumbatch(hour) = cumbatch(hour) - clutchenergy
repro(hour) = 1
pregnant = 0
v_baby = v_init_baby
e_baby = e_init_baby
EH_baby = 0
newclutch = clutchsize
fecundity = clutchsize
clutches = 1
pregnant = 0
}
}
else {
if ((Tb < VTMIN) | (Tb > VTMAX)) {
}
if ((Tb < VTMIN) | (Tb > VTMAX)) {
}
testclutch = floor(cumbatch/E_0)
if (testclutch > clutchsize) {
clutchsize = testclutch
}
cumbatch = cumbatch - clutchenergy
repro = 1
fecundity = clutchsize
clutches = 1
}
}
if (E_H_pres > E_Hb) {
if (acthr > 0) {
dEsdt = F_mT * (X/(K + X)) * V_pres^(2/3) * f - 1 *
(p_AmT/kap_X) * V_pres^(2/3)
}
else {
dEsdt = -1 * (p_AmT/kap_X) * V_pres^(2/3)
}
}
else {
dEsdt = -1 * (p_AmT/kap_X) * V_pres^(2/3)
}
if (V_pres == 0) {
dEsdt = 0
}
Es = Es_pres + dEsdt
if (Es < 0) {
Es = 0
}
if (Es > E_sm * V_pres) {
Es = E_sm * V_pres
}
gutfull = Es/(E_sm * V_pres)
if (gutfull > 1) {
gutfull = 1
}
JOJx = p_A * etaO[1, 1] + p_D * etaO[1, 2] + p_G * etaO[1,
3]
JOJv = p_A * etaO[2, 1] + p_D * etaO[2, 2] + p_G * etaO[2,
3]
JOJe = p_A * etaO[3, 1] + p_D * etaO[3, 2] + p_G * etaO[3,
3]
JOJp = p_A * etaO[4, 1] + p_D * etaO[4, 2] + p_G * etaO[4,
3]
JOJx_GM = p_D * etaO[1, 2] + p_G * etaO[1, 3]
JOJv_GM = p_D * etaO[2, 2] + p_G * etaO[2, 3]
JOJe_GM = p_D * etaO[3, 2] + p_G * etaO[3, 3]
JOJp_GM = p_D * etaO[4, 2] + p_G * etaO[4, 3]
JMCO2 = JOJx * JM_JO[1, 1] + JOJv * JM_JO[1, 2] + JOJe *
JM_JO[1, 3] + JOJp * JM_JO[1, 4]
JMH2O = JOJx * JM_JO[2, 1] + JOJv * JM_JO[2, 2] + JOJe *
JM_JO[2, 3] + JOJp * JM_JO[2, 4]
JMO2 = JOJx * JM_JO[3, 1] + JOJv * JM_JO[3, 2] + JOJe * JM_JO[3,
3] + JOJp * JM_JO[3, 4]
JMNWASTE = JOJx * JM_JO[4, 1] + JOJv * JM_JO[4, 2] + JOJe *
JM_JO[4, 3] + JOJp * JM_JO[4, 4]
JMCO2_GM = JOJx_GM * JM_JO[1, 1] + JOJv_GM * JM_JO[1, 2] +
JOJe_GM * JM_JO[1, 3] + JOJp_GM * JM_JO[1, 4]
JMH2O_GM = JOJx_GM * JM_JO[2, 1] + JOJv_GM * JM_JO[2, 2] +
JOJe_GM * JM_JO[2, 3] + JOJp_GM * JM_JO[2, 4]
JMO2_GM = JOJx_GM * JM_JO[3, 1] + JOJv_GM * JM_JO[3, 2] +
JOJe_GM * JM_JO[3, 3] + JOJp_GM * JM_JO[3, 4]
JMNWASTE_GM = JOJx_GM * JM_JO[4, 1] + JOJv_GM * JM_JO[4,
2] + JOJe_GM * JM_JO[4, 3] + JOJp_GM * JM_JO[4, 4]
O2FLUX = -1 * JMO2/(T_REF/Tb/24.4) * 1000
CO2FLUX = JMCO2/(T_REF/Tb/24.4) * 1000
MLO2 = (-1 * JMO2 * (0.082058 * (Tb + 273.15))/(0.082058 *
293.15)) * 24.06 * 1000
GH2OMET = JMH2O * 18.01528
#metabolic heat production (Watts) = growth overhead plus dissipation power (maintenance, maturity maintenance,
#maturation/repro overheads) plus assimilation overheads. correct to 20 degrees so it can be temperature corrected
#in MET.f for the new guessed Tb
DEBQMET = ((1 - kappa_G) * p_G + p_D + (p_X - p_A - p_A *
mu_P * eta_PA))/3600/Tcorr
DRYFOOD = -1 * JOJx * w_X
FAECES = JOJp * w_P
NWASTE = JMNWASTE * w_N
if (pregnant == 1) {
wetgonad = ((cumrepro/mu_E) * w_E)/d_Egg + ((((v_baby *
e_baby)/mu_E) * w_E)/d_V + v_baby) * clutchsize
}
else {
wetgonad = ((cumrepro/mu_E) * w_E)/d_Egg + ((cumbatch/mu_E) *
w_E)/d_Egg
}
wetstorage = ((V * E/mu_E) * w_E)/d_V
wetfood = Es/21525.37/(1 - 0.18)
wetmass = V * andens_deb + wetgonad + wetstorage + wetfood
gutfreemass = V * andens_deb + wetgonad + wetstorage
potfreemass = V * andens_deb + (((V * E_m)/mu_E) * w_E)/d_V
dqdt = (q_pres * (V_pres/V_max) * s_G + h_aT) * (E_pres/E_m) *
((vT/L_pres) - rdot) - rdot * q_pres
if (E_H_pres > E_Hb) {
q = q_init + dqdt
}
else {
q = 0
}
dhsds = q_pres - rdot * hs_pres
if (E_H_pres > E_Hb) {
hs = hs_init + dhsds
}
else {
hs = 0
}
h_w = ((h_aT * (E_pres/E_m) * vT)/(6 * V_pres^(1/3)))^(1/3)
dsurvdt = -1 * surviv_pres * hs
surviv = surviv_pres + dsurvdt
p_B_past = p_B
E_pres = E
V_pres = V
E_H_pres = E_H
q_pres = q
hs_pres = hs
suriv_pres = surviv_pres
Es_pres = Es
deb.names <- c("E_pres", "V_pres", "E_H_pres", "q_pres",
"hs_pres", "surviv_pres", "Es_pres", "cumrepro", "cumbatch",
"p_B_past", "O2FLUX", "CO2FLUX", "MLO2", "GH2OMET", "DEBQMET",
"DRYFOOD", "FAECES", "NWASTE", "wetgonad", "wetstorage",
"wetfood", "wetmass", "gutfreemass", "gutfull", "fecundity",
"clutches")
results_deb <- c(E_pres, V_pres, E_H_pres, q_pres, hs_pres,
surviv_pres, Es_pres, cumrepro, cumbatch, p_B_past, O2FLUX,
CO2FLUX, MLO2, GH2OMET, DEBQMET, DRYFOOD, FAECES, NWASTE,
wetgonad, wetstorage, wetfood, wetmass, gutfreemass,
gutfull, fecundity, clutches)
names(results_deb) <- deb.names
return(results_deb)
}
```
#####
# Appendix 1
Netlogo IBM decision making model (.nlogo). Available on [**Github**](https://github.com/darwinanddavis/Sleepy_IBM/blob/master/Sleepy%20IBM_v.6.1.1_two%20strategies.nlogo).
### space and time scales
```{RNetLogo error=F, message=F, warning=F}
; Spatial scale: 1500 * 1500 m
; 1 patch = 2 m
; 1 tick = 2 min
; 1 day = 720 ticks
; 1 tick = 2 bites possible for small food; 4 bites possible for large food
```
### interface
```{RNetLogo error=F, message=F, warning=F}
; Energy cost of individual
; =========================
; Movement-cost: Cost (J) of moving one patch (2 m). Calculated from DEB model.
; Maintenance-cost: Cost (J) of paying maintenance. Calculated from DEB model.
; Energy gain of individual
; =================
; Low-food gain: Energy gain (J) from small food items (Brown 1991).
; kap_X: Conversion efficiency of assimilated energy from food (J) (Kooijman 2010).
; Food patch growth
; =================
; Large-food-initial: Initial energy level (J) of large food items at setup. Parameterised from literature.
; Small-food-initial: Initial energy level (J) of small food items at setup. Parameterised from literature.
; Individual attributes
; ===================
; Maximum-reserve: Maximum reserve level (J). Appears in 'to setup' and 'to make decision'.
; Minimum-reserve: Define the critical starvation period. Individuals can survive without food for two hours in this state (reasonable estimate).
```
###globals
```{RNetLogo error=F, message=F, warning=F}
globals
[
in-shade? ; Reports TRUE if turtle is in shade
in-food? ; Reports TRUE if turtle is in a food patch
min-energy ; Minimum food unit level for individual to lose interest and move away from patch. This eliminates the incentive for individuals to return immediately to the previously visited food patch after vacating it.
reserve-level ; Reserve level of individual.
min-vision ; Minimum (normal) vision range of individuals (Auburn et al. 2009).
max-vision ; Maximum vision range of individuals activated by starvation mode. See 'to starving' procedure (Auburn et al. 2009)
ctmincount ; Counter for time spent under min_T_b_
feedcount ; Counter for time spent in feeding state.
restcount ; Counter for the time spent resting in shade
searchcount ; Counter for time spent searching for food.
starvecount ; Counter for time spent in starvation state.
shadecount ; Counter for time spent searching for shade following a feeding bout.
transcount ; Counter for frequency of transitions between any of the three activity states--searching, feeding, resting.
zenith ; Zenith angle of sun (update-sun procedure).
tempXY ; XY coords for drawing homerange
gutfull ; Reports gut level of DEB model
movelist ; List of cumulative movement costs
fh_ ; String for working dir to export results
]
```
###turtles-own
```{RNetLogo error=F, message=F, warning=F}
turtles-own
[
activity-state ; Individual is either under a Searching, Feeding, or Resting state for each tick. The transition between the various activity states defines the global behavioural repertoire.
energy-gain ; Converted energy gained from food
T_b_ ; Body temperature (T_b) of individual (Celsius)
T_b_basking_ ; Basking body temperature of individual (Celsius)
T_opt_range ; Foraging body temperature range of individual (Celsius)
T_opt ; Median foraging body temperature of individual (Celsius)
T_opt_lower_ ; Lower foraging body temperature of individual (Celsius)
T_opt_upper_ ; Upper foraging body temperature of individual (Celsius)
min-T_b_ ; Lower critical body temperature (min-T_b) of individual (Celsius)
max-T_b_ ; Upper critical body temperature (max-T_b) of individual (Celsius)
vision-range ; Vision (no. of patches) range of individual.
has-been-starving? ; Results reporter only variable for reporting stavation time only if individual has starved
has-been-feeding? ; Results reporter only variable for reporting feeding time only if individual has been feeding
X ; List of x coords for homerange
Y ; List of y coords for homerange
gutthresh_ ; Threshold for gutlevel to motivate turtle to move
V_pres_ ; DEB structural volume
wetgonad_ ; DEB wet mass reproductive organ volume
wetstorage_ ; DEB wet mass storage
wetfood_ ; DEB converted food mass
]
```
### patches-own
```{RNetLogo error=F, message=F, warning=F}
patches-own
[
patch-type ; Defines type of patches in environment as either Food or Shade.
food-level ; *> Interface <* Defines the initial and updated level of energy (J) in food patches. Food level increases (plant growth; see 'Food patch growth' in Interface) and decreases (feeding by individual) with each tick.
shade-level ; *> Interface <* Defines the initial and updated level of shade in shade patches. Shade levels remain constant throughout simulation.
]
```
###breeds
```{RNetLogo error=F, message=F, warning=F}
breed
[homeranges homerange]
```
### setup
```{RNetLogo error=F, message=F, warning=F}
to setup
ca
if Food-patches + Shade-patches > count patches
[ user-message (word "Lower the sum of shade and food patches to < " count patches ".")
stop ]
random-seed 1 ; Outcomment to generate seed for spatial configuration of all patches in the landscape (food and shade). For reproducibility. NB: turtle movement is still stochastic. See below random-seed primitive for complete function.
set min-energy Small-food-initial
set min-vision 5 ; 10m (Auburn et al. 2009)
ask patches
[set patch-type "Sun"
set pcolor (random 1 + blue)]
let NumFoodPatches Food-patches / 10
ask n-of NumFoodPatches patches [
ask n-of 10 patches in-radius 4 [ ; Sets 10 random food patches within a 5-patch radius of Food-patches
let food-amount random 100
ifelse food-amount < 50
[set food-level (Small-food-initial) + random-float 1 * 10 ^ -5] ; Makes only one food patch attractive to turtle because turtles love good chow
[set food-level (Large-food-initial) + random-float 1 * 10 ^ -5]
set pcolor PatchColor
set patch-type "Food"
]
]
ifelse Shade-density = "Random"[ ; chooser for setting Random or Clumped shade patches (similar to food patch arrangement)
let NumShadePatches Shade-patches
ask n-of NumShadePatches patches [
let shade-amount random 100
ifelse shade-amount < 50
[set shade-level (Low-shade + random-float 1 * 10 ^ -5) ; Makes only one shade patch attractive to turtle
set pcolor black + 2]
[set shade-level (High-shade + random-float 1 * 10 ^ -5)
set pcolor black]
set patch-type "Shade"
]
]
[
let NumShadePatches Shade-patches / 10
ask n-of NumShadePatches patches [
ask n-of 10 patches in-radius 4 [ ; Sets 10 random food patches within a 5-patch radius of Food-patches
let shade-amount random 100
ifelse shade-amount < 50
[set shade-level (Low-shade + random-float 1 * 10 ^ -5) ; Makes only one shade patch attractive to turtle
set pcolor black + 2]
[set shade-level (High-shade + random-float 1 * 10 ^ -5)
set pcolor black]
set patch-type "Shade"
]
]
]; close else shade loop
ask patch 0 0 [set patch-type "Shade"
set pcolor black]
set movelist (list 0)
; ask one-of patches with [patch-type = "Shade"]
; [sprout 1]
crt 1
random-seed new-seed ; Outcomment to generate seed for spatial configuration of all patches in the landscape (food and shade).
ask turtle 0
[
setxy 0 0 ;random-xcor random-ycor
set reserve-level Maximum-reserve
set T_b_basking_ 14
set T_opt_range (list 26 27 28 29 30 31 32 33 34 35 ) ; From Pamula thesis
set T_opt_upper last T_opt_range
set T_opt_lower first T_opt_range
set T_opt median T_opt_range
set min-T_b_ min-T_b
set max-T_b_ max-T_b
set V_pres_ V_pres
set wetgonad_ wetgonad
set wetstorage_ wetstorage
set wetfood_ wetfood
set activity-state "S"
set vision-range min-vision
if [patch-type] of patch-here = "Shade"
[set in-shade? TRUE]
if [patch-type] of patch-here = "Food"
[set in-food? TRUE]
set shape "lizard"
set size 2
set color red
pen-down
set X (list xcor)
set Y (list ycor)
]
setup-spatial-plot
set fh_ fh
reset-ticks
end
```
### go
```{RNetLogo error=F, message=F, warning=F}
to go
tick
if not any? turtles
[
get-homerange
print "All turtles dead. Check output of model results."
repeat 3 [beep wait 0.2]
stop
save-world
]
if (ticks * 2 / 60 / 24) = No.-of-days
[
ask turtle 0
[report-results]
stop
save-world
]
ifelse show-plots?
[]
[clear-all-plots]
ask turtle 0
[
report-patch-type
ask turtles with [reserve-level > Minimum-reserve]
[set vision-range min-vision]
update-T_b
make-decision
set X lput xcor X ; populate X list with turtle X coords to generate home range
set Y lput ycor Y ; populate Y list with turtle Y coords to generate home range
]
if any? turtles with [reserve-level <= 0]
[ask turtle 0 [report-results]
stop
]
ask patches with [patch-type = "Food"]
[update-food-levels]
end
```
### update _T~b~_
```{RNetLogo error=F, message=F, warning=F}
to update-T_b
ask turtles with [T_b >= max-T_b]
[stop]
if T_b <= min-T_b
[set ctmincount ctmincount + 1]
if (ctmincount * 2 / 60) = ctminthresh
[stop]
end
```
### make-decision
```{RNetLogo error=F, message=F, warning=F}
to make-decision
;-------------------------------------------------------------------------------------
;-------------------------------------Optimising-------------------------------------
;-------------------------------------------------------------------------------------
ifelse (strategy = "Optimising")
[; start optimising loop
ifelse (T_b > T_opt_upper) or (T_b < T_opt_lower)
[
ask turtle 0
[;set label "Resting"
set activity-state "R"
if [patch-type] of patch-here != "Shade"
[shade-search]
if ([patch-type] of patch-here = "Shade") and (T_b < T_b_basking_)
[set in-shade? TRUE]
]
if (activity-state = "R") and (T_b >= T_b_basking_) and (T_b < T_opt_upper) ; Basking behaviour
[set in-shade? FALSE
; set transcount transcount + 1 ; Outcomment to include basking behaviour as activity state
; plotxy xcor ycor
]
set restcount restcount + 1
]
[; else optimising loop
if (activity-state = "R")
[
set restcount restcount + 1
; set label "Resting"
if ((T_b <= T_opt_upper) and (T_b >= T_opt_lower)); and reserve-level < search-energy
[set transcount transcount + 1
plotxy xcor ycor
set activity-state "S"]
; [set activity-state "R"]
]
if (activity-state = "F");
[