forked from biogeochemistry/MyLake_v2_Vansjo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyLake_Vansjo_run_T_scenarios.m
308 lines (221 loc) · 15.4 KB
/
MyLake_Vansjo_run_T_scenarios.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
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
scen = {'T_only_full_scen_base_historical_20y', 'T_only_RCP4_GFDL', 'T_only_RCP4_IPSL', 'T_only_RCP8_GFDL', 'T_only_RCP8_IPSL', 'T_only_RCP45_NorESM', 'T_only_RCP85_NorESM'}
% start = {}
% scen = {'P_gradual_increase_2050_cutoff_to_0', 'P_gradual_increase_2045_cutoff_to_0', 'P_gradual_increase_2040_cutoff_to_0', 'P_gradual_increase_2035_cutoff_to_0', 'P_gradual_increase_2030_cutoff_to_0', 'P_gradual_increase_2025_cutoff_to_0', 'P_gradual_increase_2020_cutoff_to_0', 'P_gradual_increase_2015_cutoff_to_0'}
% scen = {'P_gradual_increase_2015_cutoff_to_0'}
parfor s = 1:size(scen,2)
% m_start=[1985, 1, 1]; %
% m_stop=[2040, 12, 31]; %
m_start=[2015, 1, 1]; %
m_stop=[2070, 12, 31]; %
[lake_params, sediment_params] = load_params();
% name_of_scenario = 'IO/airT_Scenarios/T_only_RCP4_IPSL.txt'
% file_name = 'IO/airT_Scenarios/T_only_RCP4_IPSL.mat'
% inaccurate but faster:
sediment_params{73} = 192;
sediment_params{74} = 0; % pH algo disabled;
% sediment_params{72} = 0; % effective depth test
% new added for cores
sediment_params{1} = 1.0549e-01; % 'k_Chl', % % 1
sediment_params{2} = 1.2624e-02; % 'k_POP', % % 1
sediment_params{3} = 5.2341e-02; % 'k_POC', % % 0.01
sediment_params{4} = 1.2941e-02; % 'k_DOP', % % 1
sediment_params{5} = 8.7662e-02; % 'k_DOC', % % 1
sediment_params{23} = 6.3601e+00; % 'k_pdesorb_a', %
sediment_params{24} = 1.1171e+01; % 'k_pdesorb_b', %
sediment_params{54} = 4.9036e+01; % 'k_pdesorb_c', %
% SO4 boundary
sediment_params{75} = 9.1213e+01;% % flux of sulphate from bottom of the sediment. Custom boundary condition for Vansjo
% for cores too (scaling unknown inputs):
lake_params{22} = 6.9253e+01;% scaling factor for inflow concentration of Chl a (-)
lake_params{25} = 8.4622e-01;% Scaling factor for inflow concentration of O2 (-)
lake_params{27} = 1.6113e+01;% Scaling factor for inflow concentration of NO3 (-)
lake_params{34} = 3.6356e+01;% Scaling factor for inflow concentration of Fe3 (-)
lake_params{35} = 4.1063e+01;% Scaling factor for inflow concentration of Al3 (-)
lake_params{37} = 6.4648e+01;% Scaling factor for inflow concentration of CaCO3 (-)
% P minerals:
sediment_params{31} = 9.4278e-01;% k_apa_pre
sediment_params{32} = 7.7780e+00;% k_apa_pre
sediment_params{40} = 1.3434e+00;% k_viv_pre
sediment_params{41} = 2.1799e+00;% k_viv_pre
sediment_params{8} = 8.7728e+01;% Km FeOH3
sediment_params{9} = 3.1972e+00;% Km FeOOH
lake_params{24} = 1.0120e+00; % 390.1162e-003 % 24 scaling factor for inflow concentration of POP (-)
lake_params{20} = 7.6529e-01; % 1 % 20 scaling factor for inflow concentration of TP (-)
lake_params{47} = 1.6558e-01; % 50.0000e-003 % 47 settling velocity for Chl1 a (m day-1)
lake_params{49} = 1.7861e-01; % 110.6689e-003 % 49 loss rate (1/day) at 20 deg C
lake_params{50} = 1.3772e+00; % 1.0000e+000 % 50 specific growth rate (1/day) at 20 deg C
lake_params{53} = 2.9236e-01; % 638.9222e-003 % 53 Half saturation growth P level (mg/m3)
lake_params{56} = 1.1681e-01; % 204.8121e-003 % 56 Settling velocity for Chl2 a (m day-1)
lake_params{57} = 2.3063e-01; % 167.6746e-003 % 57 Loss rate (1/day) at 20 deg C
lake_params{58} = 1.4571e+00; % 1.0985e+000 % 58 Specific growth rate (1/day) at 20 deg C
lake_params{59} = 3.2470e-01; % 1.5525e+000 % 59 Half saturation growth P level (mg/m3)
lake_params{46} = 7.7897e-02; % 53.9466e-003 % % 46 settling velocity for S (m day-1)
lake_params{10} = 8.3890e-05; % 24.5705e-006 % 10 PAR saturation level for phytoplankton growth (mol(quanta) m-2 s-1)
lake_params{54} = 7.3357e-05; % 75.5867e-006 % 16 PAR saturation level for phytoplankton growth (mol(quanta) m-2 s-1)
lake_params{12} = 4.5000e-02; % 45.0000e-003 % 12 Optical cross_section of chlorophyll (m2 mg-1)
lake_params{55} = 4.5000e-02; % 29.6431e-003 % 17 Optical cross_section of chlorophyll (m2 mg-1)
% ======================================================================
% NOTE: trials
lake_params{24} = 1.0; % 390.1162e-003 % 24 scaling factor for inflow concentration of POP (-)
lake_params{20} = 1.0; % 20 scaling factor for inflow concentration of TP (-)
sediment_params{52} = 40;% accel
lake_params{37} = 1;% Scaling factor for inflow concentration of CaCO3 (-)
lake_params{50} = 2.5; % 1.0000e+000 % 50 specific growth rate (1/day) at 20 deg C
lake_params{58} = 2.5; % 1.0985e+000 % 58 Specific growth rate (1/day) at 20 deg C
lake_params{47} = 0.05; % 50.0000e-003 % 47 settling velocity for Chl1 a (m day-1)
lake_params{56} = 0.05; % 204.8121e-003 % 56 Settling velocity for Chl2 a (m day-1)
lake_params{46} = 0.05; % 53.9466e-003 % % 46 settling velocity for S (m day-1)
lake_params{53} = 10; % 638.9222e-003 % 53 Half saturation growth P level Chl1 (mg/m3)
lake_params{59} = 10; % 1.5525e+000 % 59 Half saturation growth P level Chl2 (mg/m3)
lake_params{10} = 1.03890e-05; % 24.5705e-006 % 10 PAR saturation level for phytoplankton growth (mol(quanta) m-2 s-1)
lake_params{54} = 1.03357e-05; % 75.5867e-006 % 16 PAR saturation level for phytoplankton growth (mol(quanta) m-2 s-1)
lake_params{18} = 10; % 1.5525e+000 % 18 Isc C
lake_params{22} = 10; % 1.5525e+000 % 22 Isc Chl
% Sediment cores:
lake_params{24} = 1.4; % 390.1162e-003 % 24 scaling factor for inflow concentration of POP (-)
lake_params{20} = 1.9; % 20 scaling factor for inflow concentration of TP (-)
lake_params{46} = 0.1; % 53.9466e-003 % % 46 settling velocity for S (m day-1)
lake_params{19} = 100+20; % 19 scaling factor for inflow concentration of POC (-)
sediment_params{8} = 1.5*10*100*2.5;% Km FeOH3 pvc 100, umol/g, rho = 2.5
sediment_params{9} = 1.5*10*100*2.5;% Km FeOOH
sediment_params{15} = sediment_params{8};% 'Kin_FeOH3', % 15 % the same as Km rho=2.5
sediment_params{16} = sediment_params{9};% 'Kin_FeOOH', % 16 % the same as Km rho=2.5
lake_params{34} = 550; % Scaling factor for inflow concentration of Fe3 (-)
lake_params{31} = 1; % 'I_scCa2', % 31 Scaling factor for inflow concentration of Ca2 (-)
lake_params{37} = 5; % Isc CaCO3
% sediment_params{31} = 0.00037; % 'k_apa_pre', % 31
% sediment_params{62} = 0; % 7.2; % 'alfa0', % 62
sediment_params{23} = 40; % 'k_pdesorb_a', %
sediment_params{24} = 40; % 'k_pdesorb_b', %
sediment_params{54} = 40; % 'k_pdesorb_c', %
lake_params{35} = 0.001;% Scaling factor for inflow concentration of Al3 (-)
% -> FeS -> FeS2 -> FeOOH
sediment_params{30} = 0.04; % 'k_fe_pre', %
sediment_params{45} = 0.12; % 'k_FeSpre', %
sediment_params{75} = 0.5; % 9.0;% % flux of SO4 Vansjo
sediment_params{10} = 1000;% Km SO4
% Apatite:
sediment_params{33} = 10^-10.22;
sediment_params{31} = 0.000037/3; %/10; % apa_pre
sediment_params{32} = 0.037; % apa_dis
% % Vivenite
sediment_params{40} = 0.00037*10*1.5; % 0.00037; %, 'k_viv_pre', % 40
sediment_params{41} = 0.37/7; % 0.37; %, 'k_viv_dis', % 41
% sediment_params{40} = 0.00037*10*4; % 0.00037; %, 'k_viv_pre', % 40
% sediment_params{41} = 0.2; % 0.37; %, 'k_viv_dis', % 41
% FeCO3 and CaCO3
% sediment_params{37} = 180; % 'k_FeCO3_pre', % 37 % Cappellen (1996)
% sediment_params{38} = 0.25; % 'k_FeCO3_dis', % 38 % Cappellen (1996)
% sediment_params{34} = 0.04; %0.04, 'k_CaCO3_pre', % 34 % Katsev (2013)
% sediment_params{35} = 0.05; %0.05, 'k_CaCO3_dis', % 35 % Katsev (2013)
% NOTE: Chl changed here
lake_params{50} = 2; % 1.0000e+000 % 50 specific growth rate (1/day) at 20 deg C
lake_params{58} = 2; % 1.0985e+000 % 58 Specific growth rate (1/day) at 20 deg C
lake_params{47} = 0.05; % 50.0000e-003 % 47 settling velocity for Chl1 a (m day-1)
lake_params{56} = 0.05; % 204.8121e-003 % 56 Settling velocity for Chl2 a (m day-1)
lake_params{53} = 15; % 638.9222e-003 % 53 Half saturation growth P level Chl1 (mg/m3)
lake_params{59} = 15; % 1.5525e+000 % 59 Half saturation growth P level Chl2 (mg/m3)
% changed OM rates:
sediment_params{52} = 300;% accel
sediment_params{1} = 1/13 * 0.1; % 'k_Chl', % % 1
sediment_params{2} = 1/13 * 0.012; % 'k_POP', % % 1
sediment_params{3} = 1/13 * 0.05; % 'k_POC', % % 0.01
sediment_params{4} = 1/13 * 0.013; % 'k_DOP', % % 1
sediment_params{5} = 1/13 * 0.088; % 'k_DOC', % % 1
% To play with this parameter
sediment_params{72} = 30; % 'effective_depth', % 72 % depth below which the lake is affected by sediments, [m], if -1 (experimental) , then sediments below pycnocline
% Bioirrigation
sediment_params{62} = 7.2; %7.2, 'alfa0', % 62
sediment_params{62} = 1; %0.15*0.5, 'Kd_fe2', % 53
% rate of dissollution and precipitation should be equal for Viv and Apa
% Apatite:
sediment_params{33} = 10^-10.22;
sediment_params{31} = 0.000037/3/10*1.1; %/10; % apa_pre
sediment_params{32} = 0.037; % apa_dis
% % Vivenite
sediment_params{40} = 0.00037*10*1.5*2; % 0.00037; %, 'k_viv_pre', % 40
sediment_params{41} = 0.37/7/10; % 0.37; %, 'k_viv_dis', % 41
lake_params{37} = 5/2; % Isc CaCO3
lake_params{34} = 600; % Scaling factor for inflow concentration of Fe3 (-)
% To improove fit of Ca2=>PO4, we can play with initial CaCO3 concentration;
sediment_params{23} = 5; % 'k_pdesorb_a', %
sediment_params{24} = 5; % 'k_pdesorb_b', %
sediment_params{54} = 5; % 'k_pdesorb_c', %
% NOTE: Chl changed here
lake_params{50} = 2*0.8; % 1.0000e+000 % 50 specific growth rate (1/day) at 20 deg C
lake_params{58} = 2*0.8; % 1.0985e+000 % 58 Specific growth rate (1/day) at 20 deg C
lake_params{47} = 0.05*1.2; % 50.0000e-003 % 47 settling velocity for Chl1 a (m day-1)
lake_params{56} = 0.05*1.2; % 204.8121e-003 % 56 Settling velocity for Chl2 a (m day-1)
lake_params{53} = 15*0.8; % 638.9222e-003 % 53 Half saturation growth P level Chl1 (mg/m3)
lake_params{59} = 15*0.8; % 1.5525e+000 % 59 Half saturation growth P level Chl2 (mg/m3)
lake_params{24} = 1.4; % 390.1162e-003 % 24 scaling factor for inflow concentration of POP (-)
lake_params{20} = 1.6; % 20 scaling factor for inflow concentration of TP (-)
% % NOTE: setting up sediments below pycnocline:
sediment_params{72} = 17; % 'effective_depth', % 72 % depth below which the lake is affected by sediments, [m], if -1 (experimental) , then sediments below pycnocline
lake_params{24} = 1.0; % 390.1162e-003 % 24 scaling factor for inflow concentration of POP (-)
lake_params{20} = 1.0; % 20 scaling factor for inflow concentration of TP (-)
% % NOTE: setting up sediments below pycnocline:
sediment_params{72} = 17; % 'effective_depth', % 72 % depth below which the lake is affected by sediments, [m], if -1 (experimental) , then sediments below pycnocline
lake_params{24} = 1.0; % 390.1162e-003 % 24 scaling factor for inflow concentration of POP (-)
lake_params{20} = 1.0; % 20 scaling factor for inflow concentration of TP (-)
% Q10 off
% lake_params{70} = 1, % 70 Q10 for reactions of respiration
name_of_scenario = strcat('IO/Scenarios/', scen{s}, '.txt')
% file_name = strcat('IO/Scenarios/', num2str(sediment_params{73}),'ts_', scen{s}, '2000_2030.mat')
file_name = strcat('IO/Scenarios/', num2str(sediment_params{73}), 'ts_', scen{s}, '_17m_sediment_2015_2070.mat')
tic
disp('Started at:')
disp(datetime('now'));
is_metrics = true; % print metrics in the end
save_initial_conditions = false; % save final concentrations as initial for the next run
% try
run_ID = 0;
clim_ID = 0;
run_INCA = 0; % 1- MyLake will run INCA, 0- No run
use_INCA = 0; % 1- MyLake will take written INCA input, either written just now or saved before, and prepare inputs from them. 0- MyLake uses hand-made input files
[MyLake_results, Sediment_results] = fn_MyL_application(m_start, m_stop, sediment_params, lake_params, name_of_scenario, use_INCA, run_INCA, run_ID, clim_ID, save_initial_conditions); % runs the model and outputs obs and sim
disp('Saving results...')
parsave(file_name, MyLake_results, Sediment_results)
disp('Finished at:')
disp(datetime('now'));
% if is_metrics == true
% load('Postproc_code/Vansjo/VAN1_data_2017_02_28_10_55.mat')
% depths = [5;10;15;20;25;30;35;40];
% rmsd_O2 = 0;
% for i=1:size(depths,1)
% d = depths(i);
% zinx=find(MyLake_results.basin1.z == d);
% O2_measured = res.T(res.depth1 == d);
% day_measured = res.date(res.depth1 == d);
% day_measured = day_measured(~isnan(O2_measured));
% O2_measured = O2_measured(~isnan(O2_measured));
% O2_mod = MyLake_results.basin1.concentrations.O2(zinx,:)'/1000;
% [T_date,loc_sim, loc_obs] = intersect(MyLake_results.basin1.days, day_measured);
% % rmsd_O2 = rmsd_O2 + RMSE(O2_mod(loc_sim, 1), O2_measured(loc_obs, 1));
% rmsd_O2 = rmsd_O2 + sqrt(mean((O2_mod(loc_sim, 1)-O2_measured(loc_obs, 1)).^2));
% end
% zinx=find(MyLake_results.basin1.z<4);
% TP_mod = mean((MyLake_results.basin1.concentrations.P(zinx,:)+MyLake_results.basin1.concentrations.PP(zinx,:) + MyLake_results.basin1.concentrations.DOP(zinx,:) + MyLake_results.basin1.concentrations.POP(zinx,:))', 2);
% Chl_mod = mean((MyLake_results.basin1.concentrations.Chl(zinx,:)+MyLake_results.basin1.concentrations.C(zinx,:))', 2);
% P_mod = mean((MyLake_results.basin1.concentrations.P(zinx,:))', 2);
% POP_mod = mean((MyLake_results.basin1.concentrations.POP(zinx,:) + MyLake_results.basin1.concentrations.PP(zinx,:))', 2);
% load 'obs/store_obs/TOTP.dat' % measured
% load 'obs/store_obs/Cha.dat' % measured
% load 'obs/store_obs/PO4.dat' % measured
% load 'obs/store_obs/Part.dat' % measured
% [TP_date,loc_sim, loc_obs] = (intersect(MyLake_results.basin1.days, TOTP(:,1)));
% rmsd_TOTP = sqrt(mean((TP_mod(loc_sim, 1)-TOTP(loc_obs, 2)).^2));
% [TP_date,loc_sim, loc_obs] = (intersect(MyLake_results.basin1.days, Cha(:,1)));
% rmsd_Chl = sqrt(mean((Chl_mod(loc_sim, 1)-Cha(loc_obs, 2)).^2));
% [TP_date,loc_sim, loc_obs] = (intersect(MyLake_results.basin1.days, PO4(:,1)));
% rmsd_PO4 = sqrt(mean((P_mod(loc_sim, 1)-PO4(loc_obs, 2)).^2));
% [TP_date,loc_sim, loc_obs] = (intersect(MyLake_results.basin1.days, Part(:,1)));
% rmsd_PP = sqrt(mean((POP_mod(loc_sim, 1)-Part(loc_obs, 2)).^2));
% disp('RMSD 3xRMSE(P)+RMSE(O2):')
% disp(sum([3*rmsd_TOTP, 3*rmsd_Chl, 3*rmsd_PO4, 3*rmsd_PP, rmsd_O2]))
% disp('RMSD = RMSE(P)+RMSE(O2):')
% disp(sum([rmsd_TOTP, rmsd_Chl, rmsd_PO4, rmsd_PP, rmsd_O2]))
% end
% toc
end
% end