-
Notifications
You must be signed in to change notification settings - Fork 0
/
dtt5d.m
219 lines (192 loc) · 6.16 KB
/
dtt5d.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
% This script calculates tsunami travel time from a point to a 5x5 grid.
%
% Input:
% bathy: 5x5 matrix of bathymetry, positive: depth
% xgd: 5x5 matrix of x-coordinate
% ygd: 5x5 matrix of y-coordinate
% arrt_in: input grid of arrival time.
function Tart5 = dtt5d(bathy, xgd, ygd)
% dtt5.m
% g0 = 9.81;
% g0 -> gv(ygd(cy));
% g0 -> gv(ygd(cj));
Tart5 = inf*ones(5,5); % travel time
Tart5(3,3) = 0;
% xgd->x_dist
% ygd->y_dist
x_dist = zeros(5,5);
for jj = 1:5
x_dist(jj,:) = xgd*2*pi*6371.008/360.*cosd(ygd(jj))*1000;
end
y_dist = (ygd*2*pi*6371.008/360)'*1000;
% Center point
cy = 3; cx = 3;
% Slowness
slo = zeros(5,5);
for jj = 1:5
slo(jj,:) = 1./sqrt(gv(ygd(jj)).*bathy(jj,:));
end
%% For center 9 elements
% o o o o o
% o • • • o
% o • @ • o
% o • • • o
% o o o o o
%
Tart5(2:4,2:4) = dtt3s( slo(2:4,2:4), xgd(2:4), ygd(2:4));
%% For L step elements in 4 quadrant
% @: center point, •: L-corner grid point
% 8 points, each quadrant has 2 points: (p1y,p1x) and (p2y,p2x)
% R1_half, R2_half: half distance between @ and •
% dep_mid1, dep_mid2: depth at the middle between @ and •
%
% o • o • o
% • o o o •
% o o @ o o
% • o o o •
% o • o • o
%
for ofx = [1 -1]
for ofy = [1 -1]
% calculation
p1y = cy + 2*ofy; p1x = cx + ofx;
p2y = cy + ofy; p2x = cx + 2*ofx;
R1_half = 0.5*deg2m( xgd(cx), ygd(cy), xgd(p1x), ygd(p1y));
R2_half = 0.5*deg2m( xgd(cx), ygd(cy), xgd(p2x), ygd(p2y));
v_p1_half = sqrt( gv(ygd(cy+ofy))*0.5*( bathy(cy+ofy,cx+ofx) + bathy(cy+ofy,cx ) ) );
v_p2_half = sqrt( gv(ygd(cy))*0.5*( bathy(cy+ofy,cx+ofx) + bathy(cy ,cx+ofx) ) );
Tart5(p1y,p1x) = 0.5*R1_half*slo(cy,cx) + R1_half./v_p1_half + 0.5*R1_half*slo(p1y,p1x);
Tart5(p2y,p2x) = 0.5*R2_half*slo(cy,cx) + R2_half./v_p2_half + 0.5*R2_half*slo(p2y,p2x);
end
end
%% For center 9 elements of 4 diagonal elements
%
% o o o o o
% o o o o o
% • • • o o
% • @ • o o
% • • • o o
%
% cj = 2; ci = 2;
subi = 1:3; subj = 1:3;
Tart5(subj,subi) = dtt3s( slo(subj,subi), xgd(subi), ygd(subj), Tart5(subj,subi));
%
% o o o o o
% o o o o o
% o o • • •
% o o • @ •
% o o • • •
%
% cj = 2; ci = 4;
subi = 3:5; subj = 1:3;
Tart5(subj,subi) = dtt3s( slo(subj,subi), xgd(subi), ygd(subj), Tart5(subj,subi));
%
% o o • • •
% o o • @ •
% o o • • •
% o o o o o
% o o o o o
%
% cj = 4; ci = 4;
subi = 3:5; subj = 3:5;
Tart5(subj,subi) = dtt3s( slo(subj,subi), xgd(subi), ygd(subj), Tart5(subj,subi));
%
% • • • o o
% • @ • o o
% • • • o o
% o o o o o
% o o o o o
%
% cj = 4; ci = 2;
subi = 1:3; subj = 3:5;
Tart5(subj,subi) = dtt3s( slo(subj,subi), xgd(subi), ygd(subj), Tart5(subj,subi));
%% For center 9 elements of 4 connecting elements
%
% o o o o o
% o o o o o
% o • • • o
% o • @ • o
% • • • • •
%
% ## cj = 2; ci = 3; ##
% ===== 9 elements =====
subj = 1:3; subi = 2:4;
Tart5(subj,subi) = dtt3s( slo(subj,subi), xgd(subi), ygd(subj), Tart5(subj,subi));
% ===== L-corner =====
% ----- Down-side ----- ofy = -1
cj = 2; ci = 3;
p1y = cj - 1; p1x = ci + 2;
p2y = cj - 1; p2x = ci - 2;
R1_half = 0.5*deg2m( xgd(ci), ygd(cj), xgd(p1x), ygd(p1y));
R2_half = 0.5*deg2m( xgd(ci), ygd(cj), xgd(p2x), ygd(p2y));
v_p1_half = sqrt( gv(ygd(cj))*0.5*( bathy(cj-1,ci+1) + bathy(cj,ci+1) ) );
v_p2_half = sqrt( gv(ygd(cj))*0.5*( bathy(cj-1,ci-1) + bathy(cj,ci-1) ) );
Tart5(p1y,p1x) = min([Tart5(p1y,p1x), Tart5(cj,ci) + 0.5*R1_half*slo(cj,ci) + R1_half./v_p1_half + 0.5*R1_half*slo(p1y,p1x)]);
Tart5(p2y,p2x) = min([Tart5(p2y,p2x), Tart5(cj,ci) + 0.5*R2_half*slo(cj,ci) + R2_half./v_p2_half + 0.5*R2_half*slo(p2y,p2x)]);
%
% • • • • •
% o • @ • o
% o • • • o
% o o o o o
% o o o o o
%
% ## cj = 4; ci = 3; ##
% ===== 9 elements =====
subj = 3:5; subi = 2:4;
Tart5(subj,subi) = dtt3s( slo(subj,subi), xgd(subi), ygd(subj), Tart5(subj,subi));
% ===== L-corner =====
% ----- Up-side ----- ofy = 1;
cj = 4; ci = 3;
p1y = cj + 1; p1x = ci + 2;
p2y = cj + 1; p2x = ci - 2;
R1_half = 0.5*deg2m( xgd(ci), ygd(cj), xgd(p1x), ygd(p1y));
R2_half = 0.5*deg2m( xgd(ci), ygd(cj), xgd(p2x), ygd(p2y));
v_p1_half = sqrt( gv(ygd(cj))*0.5*( bathy(cj+1,ci+1) + bathy(cj,ci+1) ) );
v_p2_half = sqrt( gv(ygd(cj))*0.5*( bathy(cj+1,ci-1) + bathy(cj,ci-1) ) );
Tart5(p1y,p1x) = min([Tart5(p1y,p1x), Tart5(cj,ci) + 0.5*R1_half*slo(cj,ci) + R1_half./v_p1_half + 0.5*R1_half*slo(p1y,p1x)]);
Tart5(p2y,p2x) = min([Tart5(p2y,p2x), Tart5(cj,ci) + 0.5*R2_half*slo(cj,ci) + R2_half./v_p2_half + 0.5*R2_half*slo(p2y,p2x)]);
%
% • o o o o
% • • • o o
% • @ • o o
% • • • o o
% • o o o o
%
% ## cj = 3; ci = 2; ##
% ===== 9 elements =====
subj = 2:4; subi = 1:3;
Tart5(subj,subi) = dtt3s( slo(subj,subi), xgd(subi), ygd(subj), Tart5(subj,subi));
% ===== L-corner =====
% ----- Left-side ----- ofx = -1
cj = 3; ci = 2;
p1y = cj + 2; p1x = ci - 1;
p2y = cj - 2; p2x = ci - 1;
R1_half = 0.5*deg2m( xgd(ci), ygd(cj), xgd(p1x), ygd(p1y));
R2_half = 0.5*deg2m( xgd(ci), ygd(cj), xgd(p2x), ygd(p2y));
v_p1_half = sqrt( gv(ygd(cj))*0.5*( bathy(cj+1,ci-1) + bathy(cj+1,ci) ) );
v_p2_half = sqrt( gv(ygd(cj))*0.5*( bathy(cj-1,ci-1) + bathy(cj-1,ci) ) );
Tart5(p1y,p1x) = min([Tart5(p1y,p1x), Tart5(cj,ci) + 0.5*R1_half*slo(cj,ci) + R1_half./v_p1_half + 0.5*R1_half*slo(p1y,p1x)]);
Tart5(p2y,p2x) = min([Tart5(p2y,p2x), Tart5(cj,ci) + 0.5*R2_half*slo(cj,ci) + R2_half./v_p2_half + 0.5*R2_half*slo(p2y,p2x)]);
%
% o o o o •
% o o • • •
% o o • @ •
% o o • • •
% o o o o •
%
% ## cj = 3; ci = 4; ##
% ===== 9 elements =====
subj = 2:4; subi = 3:5;
Tart5(subj,subi) = dtt3s( slo(subj,subi), xgd(subi), ygd(subj), Tart5(subj,subi));
% ===== L-corner =====
% ----- Right-side ----- ofx = 1;
cj = 3; ci = 4;
p1y = cj + 2; p1x = ci + 1;
p2y = cj - 2; p2x = ci + 1;
R1_half = 0.5*deg2m( xgd(ci), ygd(cj), xgd(p1x), ygd(p1y));
R2_half = 0.5*deg2m( xgd(ci), ygd(cj), xgd(p2x), ygd(p2y));
v_p1_half = sqrt( gv(ygd(cj))*0.5*( bathy(cj+1,ci+1) + bathy(cj+1,ci) ) );
v_p2_half = sqrt( gv(ygd(cj))*0.5*( bathy(cj-1,ci+1) + bathy(cj-1,ci) ) );
Tart5(p1y,p1x) = min([Tart5(p1y,p1x), Tart5(cj,ci) + 0.5*R1_half*slo(cj,ci) + R1_half./v_p1_half + 0.5*R1_half*slo(p1y,p1x)]);
Tart5(p2y,p2x) = min([Tart5(p2y,p2x), Tart5(cj,ci) + 0.5*R2_half*slo(cj,ci) + R2_half./v_p2_half + 0.5*R2_half*slo(p2y,p2x)]);
end % end of function dtt5