-
Notifications
You must be signed in to change notification settings - Fork 0
/
Model2S2.m
61 lines (47 loc) · 1.44 KB
/
Model2S2.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
function cost = Model2S2(inits);
% Model 2 Step 2: generate the alkalinity model
% add path to biogeochemical processes (specified in the srcsnk subfolder)
addpath srcsnk
% load data
load data/ao
load data/water_transport
% initialize A and b matrices
b = zeros(200160,1);
A = sparse(200160,200160);
% Assign initial values to each parameter
SF = inits(1);
c = inits(2);
fprintf('SF=%d,c=%d\n',inits);
do = [];
% external src/snk: balanced river and burial
do.external.on = 1;
% Set mean concentration of salinity-normalized TA
do.conc.on = 1;
do.conc.c = c;
% Calcite export and kinetic dissolution
do.kinetic_c.on=1;
do.kinetic_c.SF=SF;
do.kinetic_c.sedremin=1;
% Aragonite export and kinetic dissolution
do.kinetic_a.on=1;
do.kinetic_a.SF=SF;
do.kinetic_a.sedremin=1;
% Call the biogeochemical functions in the srcsnk subfolder
[A,b,output] = conc(A,b,do); op.conc=output;
[A,b,output] = external(A,b,do); op.external=output;
[A,b,output] = kinetic_a(A,b,do); op.kinetic_a=output;
[A,b,output] = kinetic_c(A,b,do); op.kinetic_c=output;
% Add ocean circulation (water_transport.mat)
A = A + water_transport;
% Solve tracer (e) through linear algebra
tic
e=A\b;
toc
E = ao.nanOCN;
E(ao.iocn) = e; % E is the 3-D matrix of tracer concentrations; e is 1-D
% Save the model output to the output subfolder
filename = 'output/Base_M2.mat';
save (filename,'E','A','b','op');
% Move to Model 2 Step 3: solve modeled TA0 based on the modeled TA (E)
Model2S3;
end