-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathEnthalpy_Code_SL_Cycles.m
218 lines (179 loc) · 5.27 KB
/
Enthalpy_Code_SL_Cycles.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
% Code described in Lorenzo-Trueba and Voller 2010 altered for cycling base-level
% Dual moving boundary problem - deltaic system
% Note the solution is in dimensionless numbers
clc;
clear all;
close all;
%% Input parameter values
Rab=0.2;
A=1; %sea level change at rate A*sin(B*t)
B=1; %sea level change at rate A*sin(B*t)
m=2; %set m = 1 store movie frames, m=2 for stratigrapy.
%Note stratigraphy stores delta profiles at every time step which slows run time
%% setting up the domain
nx=1000;
p=ceil(nx/2);
pos=p;
dx=.01;
%% Time vector
dt=.00005;
Tmax=22;
t=0:dt:Tmax;
nt=length(t);
%% Initialize time vectors
sc=zeros(1,nt); % cycle Shoreline position
rc=zeros(1,nt); % cycle Alluvial-basement position
sm=zeros(1,nt); % Fixed SL Shoreline position
rm=zeros(1,nt); % Fixed SL Alluvial-basement position
Zp=zeros(1,nt); %SL position
Vc=zeros(1,nt); % Volume
%% Initialize space vectors
x=zeros(1,nx);
E=zeros(1,nx); %Basement elevation
diff = zeros(nt,nx); % Elevation stored for frames of movie
%cycle values
Fc=zeros(1,nx); %sediment flux
Hc=zeros(1,nx); %Enthalpy
Hnewc=zeros(1,nx);
hc=zeros(1,nx); %height above current sea-level
%mean values
Fm=zeros(1,nx);
Hm=zeros(1,nx);
Hnewm=zeros(1,nx);
hm=zeros(1,nx);
% To define the dimension of F(flux)
for i=1:p
x(i)=(i-(p-0.5))*dx;
hc(i) = -x(i);
hm(i) = -x(i);
E(i) = -x(i);
end
for i=p:nx
x(i)=(i-(p-0.5))*dx;
E(i) = -x(i);
end
Z = 0;
Fc(1) = Rab;
%Cycle time loop
for j=1:nt
Z0 = Z;
Z = A*sin(j*dt*B);
Zp(j) = Z;
sc(j)=(pos-p)*dx - Hc(pos)*dx/(E(pos)-Z); %shoreline position
rcount = 0; %used to track ABT later
for i=2:nx-1
Fc(i) = min((hc(i) - hc(i+1))/dx, Hc(i)*dx/dt+Fc(i-1));
%track ABT
if rcount == 0 && Fc(i) ~= Fc(i-1) %find first cell where sediment deposition occurs
rcount = 1;
rc(j)=(hc(i) + Z + Rab*x(i))/(1-Rab); %Interpolated ABT position
end
%% Exner equation
Hnewc(i) = Hc(i) + dt/dx*(Fc(i-1)-Fc(i));
%tracks SH regression
if Hnewc(pos) + E(pos)> Z
pos = pos + 1;
end
%tracks SH transregression
while Hc(pos-1) + E(pos-1) < Z
pos = pos-1;
end
Hc(i)=Hnewc(i);
hc(i) = max(Hc(i)+E(i)-Z,0);
end
%% Movie
if m==2
diff(j,:) = Hc+E;
elseif m == 1 && mod(j,.05/dt) == 0
diff(j,:) = Hc+E;
end
%% Counter
if mod(j,.5/dt) == 0
disp(['t=', num2str(j*dt)]);
end
%Checks if trajectories hit boundary of domain
if j>1000 %skips roughness at first few steps
if pos == nx-1 || rc(j)/dx >= p || abs(rc(j) - rc(j-1)) >= 100*dx
disp('end of domain reached')
break
end
end
%% Volume
Vc(j) = sum(Hc)*dx;
end
if m ==1
run('Enthalpy_Code_SL_Cycles_Movie')
end
if m ==2
run('Enthalpy_Code_SL_Cycles_Stratigraphy')
end
Fm(1) = Rab;
pos = p;
%mean SL time loop
for j=1:nt
sm(j)=(pos-p)*dx - Hm(pos)*dx/(E(pos)-Z); %shoreline position
rcount = 0;
for i=2:nx-1
Fm(i) = min((hm(i) - hm(i+1))/dx, Hm(i)*dx/dt+Fm(i-1));
if rcount == 0 && Fm(i) ~= Fm(i-1)
rcount = 1;
rm(j)=(hm(i) + Rab*x(i))/(1-Rab); %Interpolated ABT position
end
%% Exner equation
Hnewm(i) = Hm(i) + dt/dx*(Fm(i-1)-Fm(i));
if Hnewm(pos) + E(pos)> Z
pos = pos + 1;
end
while Hm(pos-1) + E(pos-1) < Z
pos = pos-1;
end
Hm(i)=Hnewm(i);
hm(i) = max(Hm(i)+E(i)-Z,0);
end
%% Counter
if mod(j,.5/dt) == 0
disp(['t=', num2str(j*dt)]);
end
if j>1000 %skips roughness at first few steps
if pos == nx-1 || rm(j)/dx >= p || abs(rm(j) - rm(j-1)) >= 100*dx
disp('end of domain reached')
break
end
end
end
%Volume
figure
plot(t,Vc,t,Rab*t,'k--')
xlim([0,j*dt])
xlabel('time')
ylabel('volume');
legend('numerical','expected');
title(['Volume with Rab = ', num2str(Rab), ', Z = ',num2str(A),'*t']);
%Trajectories
figure
box on
hold on
plot(sc,t,-rc,t,'--',sm,t,'-.',-rm,t,':','linewidth',2)
plot(Zp,t,'k--')
legend('SH trajectory sea-level cycles','ABT trajectory sea-level cycles',...
'SH trajectory constant sea level','ABT trajectory constant sea level','Sea-level');
legend boxoff
title(['$$R_{ab} = ', num2str(Rab), ', Z = ', num2str(A), '\sin(',...
num2str(B), '\cdot t)$$'],'interpreter','latex');
xlabel('distance')
ylabel('time');
ylim([0 j*dt]);
%SH residuals
figure
plot(sm-sc,t,Zp,t,'k--','LineWidth',1)
xlabel('x')
ylabel('time');
legend('SH Residuals','Sea-level')
title(['$$ R_{ab} = ', num2str(Rab), ', Z = ', num2str(A), '\sin(', num2str(B), '\cdot t)$$'],'interpreter','latex');
%ABT residuals
figure
plot(rc-rm,t,Zp,t,'k--','LineWidth',1)
xlabel('x')
ylabel('time');
legend('ABT Residuals','Sea-level')
title(['$$R_{ab} = ', num2str(Rab), ', Z = ', num2str(A), '\sin(', num2str(B), '\cdot t)$$'],'interpreter','latex');