-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetupSuperSymbionts.m
78 lines (70 loc) · 3.54 KB
/
setupSuperSymbionts.m
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
function [startSymFractions, superStartYear, superSeedFraction, oneShot] = ...
setupSuperSymbionts(superMode, RCP, E, superAdvantage, superStart, maxReefs)
%SETUPSUPERSYMBIONTS Set symbiont internal variables based on input choices.
% Summary of superMode options, rules for adding symbionts.
%
% Advantage:
% 0, 5, and 6: Fixed advantage relative to historical temperature.
% 1, 3: Advantage relative to mean of the last 10 years before introduction.
% 2, 4: Advantage relative to max of the last 10 years before introduction.
% 7, 8, 9: Advantage is dynamic, added relative to the native symbiont.
%
% Introduction date:
% 0, 1, 2, 7, 9: Fixed year as specified.
% 3, 4, 5: After 5 years of mortality.
% 6: At the first year of bleaching.
% 8: As determined by bleaching events in timeIteration.
% Note that 7 and 9 are the same in terms of this logic. The difference is that
% in mode 9 there is a growth penalty against the coral when there are more
% tolerant than sensitive symbionts.
% For now (January 2020) assume that in mode 9 only we combine both symbiont
% populations in a single coral population.
% TODO If the other modes are used again, this should be revisited.
% Some MATLAB doesn't like mixing int32 and double, so
superStart = double(superStart);
if superMode == 9
startSymFractions = [1.0-10^-6 10^-6]; % Starting fraction for native and shuffled symbionts.
else
startSymFractions = [1.0 0.0]; % Starting fraction for native and super symbionts.
end
if strcmp(RCP, 'control400')
last = 1860+400+1;
else
last = 2100 + 1;
end
if superMode >= 3 && superMode <=5
fn = strcat('longMortYears_', RCP, '_', num2str(E));
load(fn, 'longMortYears');
superStartYear = longMortYears;
% XXX - next two lines for testing only!!!
%subFrom = (superStartYear > 1882);
%superStartYear = superStartYear - 20*subFrom;
elseif superMode == 6
fn = strcat('firstBleachYears_', RCP, '_', num2str(E));
load(fn, 'firstBleachYears');
superStartYear = firstBleachYears;
elseif superAdvantage == 0.0
% If there's no advantage it's a case where there's no addition.
% Delay to the end or we'll end up "seeding" extra symbionts.
superStartYear = last*ones(maxReefs, 1); % Until this date set S(:, 3:4) to zero. Use 1861 to start from the beginning.
else
% Start the symbionts in this fixed year for all reefs.
superStartYear = superStart*ones(maxReefs, 1); % Until this date set S(:, 3:4) to zero. Use 1861 to start from the beginning.
end
assert(length(superStartYear) == maxReefs, 'By-year symbiont starts should have a start year for every reef.');
% superStartYear may be zero if a reef never bleached - this should be
% treated as beyond the end of the run.
superStartYear(superStartYear < 1800) = last;
%superInitYears = [2025 2035]; % Years from which adaptation temp is selected.
superSeedFraction = 10^-3; % Fraction of S_seed to use for seeding super symbionts.
% sizing notes: for massive,
% KSm = 3000000
% seed = 100000
% KSm/seed = 30
% the seed fraction is a fraction of this value.
% for 0.01 -> KSm/introduced = 3000
% for 0.0001 -> KSm/introduced = 300000
oneShot = false; % After supersymbiont introduction, set its seed to zero.
assert(superMode == 9 || startSymFractions(2) == 0, 'Start with no symbionts if they are to be suppressed at first.');
assert(sum(startSymFractions) == 1.0, 'Start fractions should sum to 1.');
end