-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathComputeAX_p.m
59 lines (32 loc) · 1.38 KB
/
ComputeAX_p.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
function [Temp] = ComputeAX_p(u,r,Nr,Np,hr,hp)
%ip = Nr-1 ; jp = Np/2 ;
for i = 2:(Nr-1)
for j =1:Np
if i==2
u_r = (u(i+1,j) - u(i,j))/(2.0*hr) ;
u_rr = (u(i+1,j) - u(i,j))/(hr*hr) ;
elseif i==(Nr-1)
u_r = (u(i,j) - u(i-1,j))/(2.0*hr) ;
u_rr = (-u(i,j) + u(i-1,j))/(hr*hr) ;
else
u_r = (u(i+1,j) - u(i-1,j))/(2.0*hr) ;
u_rr = (u(i+1,j) - 2.0*u(i,j) + u(i-1,j))/(hr*hr) ;
end
if j==1
u_pp = (u(i,j+1) - 2.0*u(i,j) + u(i,Np))/(hp*hp) ;
elseif j==Np
u_pp = (u(i,1) - 2.0*u(i,j) + u(i,j-1))/(hp*hp) ;
else
u_pp = (u(i,j+1) - 2.0*u(i,j) + u(i,j-1))/(hp*hp) ;
end
%{
if i==ip && j==jp
Temp(i,j) = 0 ;
else
Temp(i,j) = u_rr + (1.0/r(i))*u_r + (1.0/(r(i)*r(i)))*u_pp ;
end
%}
Temp(i,j) = u_rr + (1.0/r(i))*u_r + (1.0/(r(i)*r(i)))*u_pp ;
end
end
end