forked from lydia1895/PMM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PMM_metric_integral_polyfit_ASR.m
executable file
·171 lines (148 loc) · 6.29 KB
/
PMM_metric_integral_polyfit_ASR.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
function [eps_total,mu_total] =...
PMM_metric_integral_polyfit_ASR(b_x,eta,f1,N_basis_x,N_basis_y,Nx,nx,Ny,ny,...
N_intervals_x,N_intervals_y,n_points,La,ax,ay,epsilon)
w1 = b_x(2);
d1 = b_x(3);
%{
x1_1 = linspace(0,f1,n_points);
x1_2 = linspace(f1,1,n_points);
ksi = linspace(-1,1,n_points);
dx_dx1_1 = (w1/f1)*(1-eta*cos(2*pi*x1_1/f1));
dx_dx1_2 = ((d1-w1)/(1-f1))*( 1-eta*cos(2*pi*(x1_2-f1)/(1-f1)) );
%}
x1_1 = linspace(0,w1,n_points);
x1_2 = linspace(w1,d1,n_points);
ksi = linspace(-1,1,n_points);
x_1 = x1_1 - eta*(w1/(2*pi))*sin(2*pi*x1_1/w1);
x_2 = x1_2 - eta*((d1-w1)/(2*pi))*sin(2*pi*(x1_2-w1)/(d1-w1));
figure(7)
plot (x_2, x1_2, 'm', 'Linewidth', 2)
xlabel('x');
ylabel('x1');
hold off
dx_dx1_1 = 1 - eta*cos(2*pi*x1_1/w1);
dx_dx1_2 = 1 - eta*cos(2*pi*(x1_2-w1)/(d1-w1));
figure(8)
plot (x_1, dx_dx1_1,'m', 'Linewidth', 2)
xlabel('x');
ylabel('dx_dx1_1');
hold off
g_sqrt_1 = dx_dx1_1; %on the first interval [0,f1]
g_sqrt_2 = dx_dx1_2; %on the second interval [f1,1]
ksi = transpose(ksi);
x_1 = transpose(x_1);
x_2 = transpose(x_2);
g_sqrt_1 = transpose(g_sqrt_1);
g_sqrt_2 = transpose(g_sqrt_2);
g_sqrt_1_fit = fit(x_1,g_sqrt_1,'poly7');
g_sqrt_2_fit = fit(x_2,g_sqrt_2,'poly7');
g_sqrt_1_fit_num = g_sqrt_1_fit.p8+g_sqrt_1_fit.p7*x_1+g_sqrt_1_fit.p6*x_1.^2+...
+g_sqrt_1_fit.p5*x_1.^3+g_sqrt_1_fit.p4*x_1.^4+g_sqrt_1_fit.p3*x_1.^5+...
g_sqrt_1_fit.p2*x_1.^6+g_sqrt_1_fit.p1*x_1.^7;
%{
g_sqrt_1_fit = polyfit(ksi,g_sqrt_1,5);
g_sqrt_2_fit = polyfit(ksi,g_sqrt_2,5);
g_sqrt_1_fit_num = g_sqrt_1_fit(1)+g_sqrt_1_fit(2)*ksi+g_sqrt_1_fit(3)*ksi.^2+...
+g_sqrt_1_fit(4)*ksi.^3+g_sqrt_1_fit(5)*ksi.^4+g_sqrt_1_fit(6)*ksi.^5;
g_sqrt_1_polyval = polyval(g_sqrt_1_fit,ksi);
g_sqrt_2_polyval = polyval(g_sqrt_2_fit,ksi);
figure(11)
plot(ksi,g_sqrt_2,'r',ksi,g_sqrt_2_polyval,'g',...
ksi,abs(g_sqrt_2-g_sqrt_2_polyval)./g_sqrt_2, 'm', 'Linewidth', 2)
hold off
%}
figure(10)
plot(x_1,g_sqrt_1, '-sr',x_1,g_sqrt_1_fit_num,'b',...
x_1,abs(g_sqrt_1-g_sqrt_1_fit_num)./g_sqrt_1, 'm', 'Linewidth', 2)
xlabel('ksi');
ylabel('g sqrt 1, g sqrt 1 fit');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[Tx, aTx, Ux] = PMM_T_matrices_norm(Nx,nx,N_basis_x,ax,La,N_intervals_x,b_x);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
N_total_x = sum(N_basis_x); %total number of basis functions
N_total_y = sum(N_basis_y); %total number of basis functions
N_total_x3 = N_total_x - N_intervals_x; %number of basis functions in "third" basis
N_total_y3 = N_total_y - N_intervals_y;
N_total_3 = N_total_x3*N_total_y3;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Ux1(:,:) = Ux(1,:,:);
Ux2(:,:) = Ux(2,:,:);
Tx1(:,:) = Tx(1,:,:);
Tx2(:,:) = Tx(2,:,:);
aTx1(:,:) = aTx(1,:,:);
aTx2(:,:) = aTx(2,:,:);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
int_P2_sqrt_g_1 = int_P2(Ux1,Tx1,aTx1,g_sqrt_1_fit);
int_P2_sqrt_g_2 = int_P2(Ux2,Tx2,aTx2,g_sqrt_2_fit);
int_P2_sqrt_g = int_P2_sqrt_g_1+int_P2_sqrt_g_2;
Nmax_x = max(N_basis_x);
Nmax_y = max(N_basis_y);
Nmax = max(Nmax_x,Nmax_y);
p = zeros(Nmax,1);
norm = zeros(Nmax,1);
for i=0:(Nmax-1)
p(i+1) = gamma(i+2*La)/(gamma(2*La)*gamma(i+1));
%p(i)=Ci i-th Gegenbauer polynomial at 1
norm(i+1) = pi^0.5*p(i+1)*gamma(La+0.5)/(gamma(La)*(i+La));
%<Cn,Cm> = delta(n,m)*norm(n)
end
hx = zeros(N_total_x3,N_total_x3);
hy = zeros(N_total_y3,N_total_y3);
for k=1:N_intervals_x
for i=(Nx(k)+1):(Nx(k)+nx(k))
hx(i,i) = norm(i-Nx(k));
end
end
for k=1:N_intervals_y
for i=(Ny(k)+1):(Ny(k)+ny(k))
hy(i,i) = norm(i-Ny(k));
end
end
hy = eye(N_total_y3,N_total_y3);
int_sqrt_g = Kr(int_P2_sqrt_g,hy);
%int_sqrt_g = Kr(hx,hy)\Kr(int_P2_sqrt_g,hy);
diag_g = diag(int_sqrt_g);
epsilon_inv = ones(N_intervals_x,N_intervals_y)./epsilon;
mu = ones(N_intervals_x,N_intervals_y);
mu_inv = ones(N_intervals_x,N_intervals_y);
eps_xx_inv = zeros(N_total_x3,N_total_x3);
eps_yy = zeros(N_total_x3,N_total_x3);
eps_zz = zeros(N_total_x3,N_total_x3);
mu_xx_inv = zeros(N_total_x3,N_total_x3);
mu_yy = zeros(N_total_x3,N_total_x3);
mu_zz = zeros(N_total_x3,N_total_x3);
for k1=1:N_intervals_x
for k2=1:N_intervals_y
for m1=Nx(k1)+1:Nx(k1)+nx(k1)
for m2=Ny(k2)+1:Ny(k2)+ny(k2)
row = m2 + (m1-1)*N_total_y3;
for i1=1:N_total_x3
for i2=1:N_total_y3
col = i2 + (i1-1)*N_total_y3;
eps_xx_inv(row,col)=epsilon_inv(k1,k2)*int_sqrt_g(row,col);
eps_yy(row,col)=epsilon(k1,k2)*int_sqrt_g(row,col);
eps_zz(row,col)=epsilon(k1,k2)*int_sqrt_g(row,col);
mu_xx_inv(row,col)=mu_inv(k1,k2)*int_sqrt_g(row,col);
mu_yy(row,col)=mu(k1,k2)*int_sqrt_g(row,col);
mu_zz(row,col)=mu(k1,k2)*int_sqrt_g(row,col);
end
end
end
end
end
end
Uxy=eye(N_total_3,N_total_3);
eps_xy = zeros(N_total_3,N_total_3);
eps_yx = zeros(N_total_3,N_total_3);
mu_xy = zeros(N_total_3,N_total_3);
mu_yx = zeros(N_total_3,N_total_3);
eps_total(:,:,1) = Uxy/eps_xx_inv;
eps_total(:,:,2) = eps_xy;
eps_total(:,:,3) = eps_yx;
eps_total(:,:,4) = eps_yy;
eps_total(:,:,5) = Uxy/eps_zz;
mu_total(:,:,1) = Uxy/mu_xx_inv;
mu_total(:,:,2) = mu_xy;
mu_total(:,:,3) = mu_yx;
mu_total(:,:,4) = mu_yy;
mu_total(:,:,5) = Uxy/mu_zz;