Sunteți pe pagina 1din 12

Question1>

According to the problem we are here to find the solution of the diffusion equation
given by:

2 2
= +
t x2 y2

As per the initial condition we have

( x , y , t=0)=sin xy

Now from the above equation we may assume the solution would be in the form of

xy +t

(x , y , t)=sin

Mathematical Solution for the Above equation is solved as below:

Hence for the Forward Euler case we need to consider truncation point for the next
concurrent points.

Therefore,
Result:

clear all;
close all;
%t = [0:0.1:1];
dx = 0.05;
dy=0.05;
%clear;
a=0;
b=5;
y0=sin(pi*dx*dy);
n=100;
f=@(x,y,t) sin(pi*x*y+t);
h=(b-a)/n; % interval length
x(1)=a;
y(1)=y0;
t(1) =sin(pi*x);
for K=1:n
x(K+1)=x(K)+h;
t(K+1) = t(K)+h;
y(K+1)=y(K)+h*f(x(K),y(K),t(K));
end
plot3(x,t,y);
Question 2:

Solution: for the given wave equation for explicit condition we have,


( i+ 1n+ ni1)
n+ 1 2
i = (1)
n
n1
i +2( 1 2 ) i +

We have,

t
2
= x )2

In order to investigate the stability of the explicit scheme (1) we start with the usual
ansatz we have,

ni +1 = gn eikxl
which leads to the following expression for the amplication factor g(k)

g2=2( 1 2 ) g1+2 2 g cos( k x ) (2)

After several transformations the last expression becomes just a quadratic equation
for g, namely

2
g 2g+1=0 ..(3)

where

=12 2( sin(k x /2))2 .(4)

Solutions of the equation for g(k) read

g1,2= 21 (5)

Notice that if > 1 then at least one of absolute value of g 1,2 is bigger that one.
Therefor one should desire for < 1, i.e.,

g1,2= i 21 and |g|2 = 2 +12 = 1.

Hence |g|2 = 1 for all values <1.

That is, the scheme (1) is conditional stable. The stability condition reads

1 12 * 2sin 2 (k*x /2) 1, finally we can re arrange this into standard sin form
as:

k x /2
sin ()


0 2

Hence for the design purpose we proceed with (sin x)2

(k x )
Where x=
2

Result:
C=0.1:0.1:0.4;

%% Region of Stability
figure(1)
thetha = -180:0.5:180;
for i=1:length(C)
xpoint = sind(thetha);
ypoint = 1 -4* C(i) * xpoint.^2;%%% Von Neum stability
for Wave Eqaution
hold on
scatter(xpoint,ypoint)
end
legend('Courent No. = 0.1','Courent No. = 0.2',...
'Courent No. = 0.3','Courent No. = 0.4')
title('Complex plane')
axis([-2 2 -2 2])
grid

%% Amplification Error (diffusion)


figure(2)
Cx=[0.1:0.1:0.6];
delta = 0:0.5:180;
for i=1:length(Cx)
xpoint1 = sind(delta);
ypoint1 = 1 -4* Cx(i) * xpoint1.^2;%%% Von Neum
stability for Wave Eqaution
y = sqrt(xpoint1.^2 + ypoint1.^2);
hold on
plot(delta,y,'LineWidth',5.5);
end
hm = legend('Courent No. = 0.1','Courent No. =
0.2',...
'Courent No. = 0.3','Courent No. = 0.4','Courent No. =
0.5','Courent No. = 0.6');
set(hm,'FontSize',10);
hx = xlabel('delta');
gy = ylabel('Amplification factor A(k)');
set(hx,'FontSize',10);
set(gy,'FontSize',10);
set(gca,'fontsize',10)
%
grid
%
Question 3>

Consider the wave equation in single order.

dz
= z ..(1)
dt

As we know that from leap frog scheme we have,


n+1 n1 n
z =z + 2 tz (2)

In this case, arises as an eigenvalue of a local Jacobian of the function f(t,z), so it


may be complex. One of the simplications made to get insight is to use a constant
step size t > 0. Because the test equation is linear and homogeneous, stability
amounts to computed solutions having the same behaviour as solutions of the ODE
itself. We assume that the eigenvalues all satisfy Re()0 because we are most
concerned about the stability of numerical methods for computing solutions that are
themselves stable. Many methods have unsatisfactory behaviour for on the
imaginary axis. The midpoint method is quite attractive then because it produces a
bounded solution, which is to say that it is stable, for t*[i,i]. Unfortunately, it is
not stable for any t* with Re() < 0.

where it is convenient to introduce z = h. An equation of this kind has a solution of

the form y n= n provided that is a root of the characteristic equation

2 = 1+2z, namely

1=z+ 1+ z 2 2=z (1+ z 2) .(3)

The two roots lead to two linearly independent solutions, so in general yn has the

form y n= 1 + 2 ..(4)

with constants , that are determined by the initial values y0,y1.

The absolute stability region of the method is the region S in Re(z) 0 such that if z
S, then |yn| is bounded for all n. For linear multistep methods like the midpoint
method, this is equivalent to the region in the left-half complex plane where the
characteristic roots have magnitude no greater than 1.

All we need right now is the observation that if the eigenvalue is pure imaginary, =
i, and (h)2 1, then both roots satisfy

||2 = (h)2+[1(h)2] =1. This says that the method is stable for z in the interval [i,
+i].
Question 4>

According to the given question we have,

u
( 2) v2 u
=
x x2 for 0 x 1 .(1)
u
+0.5
t

With v = 0.003, u (0, t) = 0 and u(x,t=0) = -sin(pi*x).

To find: solution of the above equation until max(|u(x,t)|) - 0.1.

For a differential scheme whose criteria matches with the criteria of EF/Up-
winding scheme in soling partial differential scheme.
Consider case 3 and 4 here
For Up winding scheme we have the solution of equations as shown below:
u
u
u
u
u
u 2
2

j+1n 2unj
+ ..2

( j unj ) v
n +1
=
t 2
v

2

n+ 1 n
By rearranging the above equation 1 for u j +1 , u j and delayed cases of
n+ 1 n
u j +1 , uj in both n and j subscripts we have,
n +1 n
un+
j
1
1+ ( vc

vc n +1
)
x 2 x
u j1+
vc n+1 n+1 vc
2 x
u j +1 =u j +1
2 x (u c
j+1
2s
+u nj ) (
vc u jc
+
2 x 2 s )
+1 +
vc
2 x

vc
u nj1
2 x .(3)
In case of a & b we assume AB3 and CN diffusion for the above Berger equation
1.

u u u u
u u ( j +1n ) ( j +1n1 ) ( j+1n2 )

u u u u u
+ - +

( j unj ) v
n +1
v
= 23 16 5
t 2 2
24 1 1
(4)
By rearranging the above equation, we get

un+ 1
j +1 ( 2vc x )+u ( 1+ 2vc x )+u ( 2vc x )+u ( 16
n +1
j
n +1
j
24
c u )+u (
n1
j+1
16
24
n1
j+1
5
c u )+u ( c u )+u (
24
n1
j
16
24
n 1
cu
j
n2
j +1
n2
j+1
n2
j +1

unj +1 ( 2vc x 2324 u )+u (1 vcx 2324 u )+ u


n
j +1
n
j
n
j
n
j1 (
vc
)
2 x (5)

Hence from the equation 3,4,5 we have the solution for solving in matrix form as
given below:
n+1 n 1 n2 n
Cf 1 u +Cf 2u +Cf 3 u =Cf 4 u

Hence
un+ 1=cf 11 (Cf 2u n1 Cf 3 un2 +Cf 4 un )

Equally

un+ 1=cf 11 (Cf 4 unCf 2un 1Cf 3 un2)

Where cf 1, cf 2,cf 3 are the coffecient matix for the solutionU


clear
close all
clc

% 1981
v = 0.003;
thresh = 0.1;
dx = 0.04;
N = (1/dx) + 1;
dt = dx/100;
c = dt/dx;
% c=0
%% X grid
X_grid = 0:dx:1;
%% Initliak conditions
prev_u = -sin(pi * X_grid)';
%% Constructing system matrix with boundary conditions
cf12 = cf1in(prev_u,c,v,dx);
cf23 = cf2in(c,v,dx,N);
cf23_INV = inv(cf23);
%% Boundary conditions of Matrix

%% Solution
figure(1)
plot(X_grid,prev_u,'LineWidth',5.5)
grid
h = xlabel('X');
g = ylabel('U');
title(sprintf('Solution U for dx = %1.1d',dx))
set(h,'FontSize',10);
set(g,'FontSize',10);
set(gca,'fontsize',10)
hold on
hold on
i=1;
count=1;
while(true)
new_u = cf23_INV * cf12 * prev_u;
prev_u = new_u;
if(mod(i,3000)==0)
count = count+1;
plot(X_grid,prev_u,'LineWidth',5.5)
end
max(abs(prev_u))
cf12 = cf1in(prev_u,c,v,dx);
i=i+1;
if(max(abs(prev_u)) < thresh)
break;
end
end

t(1) = 0;
Legend=cell(count,1)% two positions
for i=2:count
t(i) = t(i-1) + (dt*(i-1))
end

for j=1:count
Legend{j} = sprintf(('t = %1.1d'),t(j))
end
legend(Legend);

S-ar putea să vă placă și