-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_eigen_ellipticity.m
executable file
·206 lines (165 loc) · 5.86 KB
/
test_eigen_ellipticity.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
% Test inversion using surf96 kernels
%
% This version solves for Vs, Vp, and Rho by enforcing Vp/Vs and Rho/Vs of
% the starting model. The inversion includes kernels for Vs, Vp, Rho such
% that each iteration accounts for perturbations in all three.
%
% jbrussell 6/5/2020
% modified 11/23/2021
% modified 11/20/2022
%
%
% WARNING!!!! writemod_surf96 set to FLAT EARTH
%
clear
path2BIN = './bin_v3.30/'; % path to surf96 binary
PATH = getenv('PATH');
if isempty(strfind(PATH,path2BIN))
% setenv('PATH', [PATH,':',path2BIN]);
setenv('PATH', [path2BIN,':',PATH]);
end
addpath('./functions/')
% Make binary files executable
!chmod ++x ./bin_v3.30/*
%% Starting model
Nmodes = 3; % number of modes to plot
zh2o = 5; % water depth
zsed = 0.5; %0.25; % sediment thickness
ylims = [0 100];
vec_T = [1:0.05:15];
% Make homogeneous starting model
dzz = 1; % km
z = [0 zh2o [zh2o+zsed : dzz : 100]];
dz = [diff(z) 0];
vs = [0 1.0 3.2*ones(size([zh2o+zsed : dzz : 100]))];
vp = [1.5 3.0 5.8*ones(size([zh2o+zsed : dzz : 100]))]; %1.75*vs;
rho = [1.0 1.8 3*ones(size([zh2o+zsed : dzz : 100])) ];
startmod = [dz(:), vp(:), vs(:), rho(:)];
startmod(1:end-1,:);
% discs = [zmoho]; % [km] depth to sharp discontinuities
discs = []; % for this simple example, don't allow discontinuities
% % Make homogeneous starting model
% z = [0 zh2o zh2o+zsed 10 20 30 40 50 60 70 80 90 100];
% dz = [diff(z) 0];
% vs = [0 1.0 3.2 3.2 3.2 3.2 3.2 3.2 3.2 3.2 3.2 3.2 4.5];
% vp = [1.5 3.0 5.8 5.8 5.8 5.8 5.8 5.8 5.8 5.8 5.8 5.8 5.8]; %1.75*vs;
% rho = [1.0 1.8 3 3 3 3 3 3 3 3 3 3 3 ];
% startmod = [dz(:), vp(:), vs(:), rho(:)];
% startmod(1:end-1,:);
% % discs = [zmoho]; % [km] depth to sharp discontinuities
% discs = []; % for this simple example, don't allow discontinuities
% % Make homogeneous starting model
% z = [0 20 100];
% dz = [diff(z) 0];
% vs = [3 5 5];
% vp = [7 7 7]; %1.75*vs;
% rho = vp / 2.5;
% startmod = [dz(:), vp(:), vs(:), rho(:)];
% % discs = [zmoho]; % [km] depth to sharp discontinuities
% discs = []; % for this simple example, don't allow discontinuities
clrs = jet(Nmodes);
for ii = 1:Nmodes
Nmode = ii-1;
c_R = dispR_surf96(vec_T,startmod,Nmode); % "predictions";
grv_R = dispR_surf96(vec_T,startmod,Nmode,'U'); % "predictions";
disper = calc_amplification_ellipticity_gamma(vec_T,startmod,'R',Nmode);
if isempty(grv_R)
continue
end
%%
if ii == 1
figure(1); clf;
set(gcf,'position',[70 81 1526 842]);
end
subplot(2,3,1);
box on; hold on;
h = plotlayermods(startmod(:,1),startmod(:,3),'-b');
h.LineWidth = 2;
xlabel('Vs (km/s)');
ylabel('Depth (km)');
title('Starting Model');
set(gca,'FontSize',18,'linewidth',1.5);
ylim(ylims);
subplot(2,3,2);
box on; hold on;
plot(vec_T(1:length(c_R)),c_R,'-','color',clrs(ii,:),'linewidth',2);
plot(vec_T(1:length(grv_R)),grv_R,'--','color',clrs(ii,:),'linewidth',2);
xlabel('Period (s)');
ylabel('Phase Velocity (km/s)');
set(gca,'FontSize',18,'linewidth',1.5);
lgd{ii} = num2str(Nmode);
xlim([min(vec_T) max(vec_T)]);
subplot(2,3,3);
box on; hold on;
plot(vec_T(1:length(disper.gamma)),disper.gamma,'-','color',clrs(ii,:),'linewidth',2);
xlabel('Period (s)');
ylabel('Gamma (1/km)');
set(gca,'FontSize',18,'linewidth',1.5);
lgd{ii} = num2str(Nmode);
xlim([min(vec_T) max(vec_T)]);
subplot(2,3,5);
box on; hold on;
plot(vec_T(1:length(disper.A_R)),disper.A_R,'-','color',clrs(ii,:),'linewidth',2);
xlabel('Period (s)');
ylabel('A_R');
set(gca,'FontSize',18,'linewidth',1.5);
xlim([min(vec_T) max(vec_T)]);
subplot(2,3,6);
box on; hold on;
h4(ii) = plot(vec_T(1:length(disper.RZ)),disper.RZ,'-','color',clrs(ii,:),'linewidth',2);
xlabel('Period (s)');
ylabel('Ellipticity R/Z');
set(gca,'FontSize',18,'linewidth',1.5);
xlim([min(vec_T) max(vec_T)]);
end
pos = get(gca,'position');
legend(h4,lgd,'location','eastoutside');
set(gca,'position',pos);
%% Eigenfunctions
ipers = [1 50 100 200];
linetype = {'-','--',':'};
for ii = 1:Nmodes
Nmode = ii-1;
eig = calc_eigenfunctions96(vec_T,startmod,'R',Nmode);
%%
if ii == 1
figure(2); clf;
set(gcf,'position',[70 81 1526 842]);
end
for iper = 1:length(ipers)
subplot(1,length(ipers),iper);
box on; hold on;
plot(eig.uz(:,ipers(iper)),eig.z,linetype{ii},'color',[1 0 0],'linewidth',2);
plot(eig.ur(:,ipers(iper)),eig.z,linetype{ii},'color',[0 0 1],'linewidth',2);
plot(eig.tz(:,ipers(iper)),eig.z,linetype{ii},'color',[1 0 1],'linewidth',2);
plot(eig.tr(:,ipers(iper)),eig.z,linetype{ii},'color',[0 1 1],'linewidth',2);
xlabel('Eigenfunction');
ylabel('Depth (km)');
title([num2str(eig.periods(ipers(iper))),' s']);
set(gca,'FontSize',18,'linewidth',1.5,'ydir','reverse');
ylim(ylims);
legend({'Uz','Ur','Tz','Tr'},'location','southeast');
end
end
%% Ellipticity
for ii = 1:Nmodes
Nmode = ii-1;
eig = calc_eigenfunctions96(vec_T,startmod,'R',Nmode);
%%
if ii == 1
figure(3); clf;
set(gcf,'position',[70 81 1526 842]);
end
for iper = 1:length(ipers)
subplot(1,length(ipers),iper);
box on; hold on;
plot(eig.ur(:,ipers(iper)) ./ eig.uz(:,ipers(iper)),eig.z,linetype{ii},'color',[1 0 0],'linewidth',2);
plot(eig.tr(:,ipers(iper)) ./ eig.tz(:,ipers(iper)),eig.z,linetype{ii},'color',[0 0 1],'linewidth',2);
xlabel('Ellipticity');
ylabel('Depth (km)');
title([num2str(eig.periods(ipers(iper))),' s']);
set(gca,'FontSize',18,'linewidth',1.5,'ydir','reverse');
ylim(ylims);
legend({'Ur/Uz','Tr/Tz'},'location','southeast');
end
end