# Question:crank nicolson system of difference scheme error

## Question:crank nicolson system of difference scheme error

Maple

Hai

Help required to plot the graphs for system  difference schemes .

I am attaching the codes and sample graphs and  maple query but still getting  error.

here is the codes

restart;
restart; Digits := 1;
Pr:=0.01:E:=1:a:=0:N:=10:

`&Delta;t`:=0.01:`&Delta;y`:=0.01:

#Discritization scheme

for i from 1 by 1 while i<=N do;
end:
for j from 0 by 1 while j<=N do;
end:

eq1[i, j] := (U[i, j+1]-U[i, j])/`&Delta;t` = (1/2)*Gr*(theta[i, j+1]+theta[i, j])+(1/2)*Gc*(C[i, j+1]+C[i, j])+(U[i-1, j+1]-2.*U[i, j+1]-2.*U[i, j]+U[i+1, j])/(2.*`&Delta;y`)^2-(1/2)*M*(U[i, j+1]+U[i, j]):

eq2[i, j] := (theta[i, j+1]-theta[i, j])/`&Delta;t` = (1/Pr)*(theta[i-1, j+1]-2*theta[i, j+1]+theta[i+1, j+1]+theta[i-1, j]-2*theta[i,j]+theta[i+1,j])/(2.*`&Delta;y`)^2-E*((1/`&Delta;y`)^2*(U[i+1, j]-U[i, j])^2):

eq3[i, j] := (C[i, j+1]-C[i, j])/`&Delta;t` = (1/Sc)*(C[i-1, j+1]-2*C[i, j+1]+C[i+1, j+1]+C[i-1, j]-2*C[i,j]+C[i+1,j])/(2*`&Delta;y`)^2-(K/2)*(C[i, j+1]-C[i, j]):
end do;
Error, reserved word `end` unexpected
end do:
Error, reserved word `end` unexpected

# initial conditions
U[i, 0] := 0:
theta[i, 0]:= 0:
C[i, 0] := 0:

NULL;
U[0,j]:=exp(a*j*`&Delta;t`):
theta[0,j]:=(j*`&Delta;t`):
C[0,j]:=j*`&Delta;t`:

U[N,j]:=0:
theta[N,j]:=0:
C[N,j]:=0:

sys := ([seq])(seq(eq[i, j], j = 0 .. N), i = 1 .. N):
nops(sys);
vars:=indets(sys):
nn := Matrix(N+1, N+1,(i, j)-> U[i-1, j-1]):
##
p:=proc(kk) local U_res,A;
U_res:=solve(eval(sys,k=kk),vars);
A:=eval(nn,U_res);
plots:-matrixplot(A)
end proc;

plots:-(U,[M],Y=0..4);

https://www.mapleprimes.com/questions/225117-How-To-Solve-This-Error-In-Maple

﻿