-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdifferential.m
100 lines (85 loc) · 3.3 KB
/
differential.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
%% ATNmodel.m
%% Previous authors -------------------------------------------------------
% Program by: Rosalyn Rael
% Modified by Barbara Bauer
%% Last update ------------------------------------------------------------
% when: 3-6-2018
% who: Valentin Cocco
% mail: [email protected]
% what: personal writing
%% Description ------------------------------------------------------------
% Determine the temporal derivative of B and E
% Called by:
% - webdriver.m
% Inputs:
% - X: [B;E]
% - x: array of metabolic rates
% - y: array of maximum assimilation rates
% - r: array of growth rates
% - c: array of intraspecific predator interference
% - K: global carrying capacity
% - e: matrix of metabolization efficiency
% - Bs: array of half-saturation density
% - nicheweb:
% - harvest: logical array. indicates which trophic species are harvested
% - mu: market openness
% - co: cost of fishing per unit of effort
% - ca: catchability per unit of effort per unit of biomass
% - a, b: price parameters
% - price: indicate the price model chosen : 'linear', 'isoelastic', 'nl-ni'
% - Bext: extinctionthreshold
%%
function [dXdt]=differential(t,X,x,y,r,K,e,h,c,Bs,nicheweb,harvest,mu,co,ca,a,b,price,Bext)
spe=length(nicheweb);
B=X(1:spe);
E=X(spe+1:end);
B(B<Bext)=0;
E(E<0)=0;
%% ----------------------------------------------------------------------------
% BIOENERGETIC MODEL ----------------------------------------------------------
% -----------------------------------------------------------------------------
%% 1. NPP: Net Primary Production
basal=(sum(nicheweb,2)==0);
NPP=r.*(1-sum(B(basal))./K).*B;
%% 2. MetaLoss: Metabolic Loss (mortality, energy exependiture for basal metabolism, activity, thermoregulation...)
MetaLoss=x.*B;
%% 3. F: Functional Response
w=zeros(spe,1);
nonbasal=~basal;
w(nonbasal)=1./sum(nicheweb(nonbasal,B~=0),2); %only the remaining species are taken into account
w(w==Inf)=0; %predators whose all preys have a null biomass
w=w*ones(1,spe);
w=w.*nicheweb; %w_i_j: preference of i for j amongst its preys
wBh=w.*(ones(spe,1)*B').^h;
Bsh=(ones(spe,1)*Bs').^h;
cBBsh=(c.*B*ones(1,spe)).*Bsh;
sumwBh=sum(wBh,2)*ones(1,spe);
F=wBh./(Bsh+cBBsh+sumwBh); %Bsh is always different from zero --> no problem of division
%% 4. TrophLoss and TrophGain: Loss and Gain of organic matter by consumer-resource interaction
gain=(x.*y.*B)*ones(1,spe).*F;
loss=gain./e;
TrophGain=sum(gain,2);
TrophLoss=sum(loss,1)';
%% 5. HarvLoss: Loss by fishing
HarvLoss=zeros(spe,1);
HarvLoss(harvest)=ca*E.*B(harvest);
%% 6. dBdt: array of temporel derivatives of B_i
dBdt=NPP - MetaLoss - TrophLoss + TrophGain - HarvLoss;
%% -----------------------------------------------------------------------------
% ECONOMIC MODEL ---------------------------------------------------------------
% ------------------------------------------------------------------------------
%% 7. p: price
Y=HarvLoss(harvest);
if price=='linear'
p=a*(1-b*Y);
elseif price=='isoelastic'
p=a/Y^b;
p(p==Inf)=0;
else %non linear non isoelastic: 'nl-ni'
p=a/(1+b*Y);
p(p==Inf)=0;
end
%% 8. dEdt
dEdt=mu*(ca*p.*B(harvest).*E-co*E);
%% --------------------------------------------------------------------------------
dXdt=[dBdt;dEdt];