Qs: Write a FORTRAN program to approximately solve elliptic equation :-u_xx-u_yy=1 on a unit square -1<x<1, -1<y<1, with u=0 on the entire boundary.
Use the five -point finite difference formula on a uniform mesh of size h in each direction.
Set up the matrix system Au=b (taking the natural ordering of the nodes) and program the Jacobi iteration method to solve it, i.e.
u^k = (I-D^-1 A)u^(k-1) + D^-1 b, where k is the iteration index and D is the diagonal of A.
=> So far my program
PROGRAM Jacobi_method
IMPLICIT NONE
! Declare Variables
Real, allocatable :: x),u,
Real:: m,xy,h,Smax
Integer:: i,j,JI
Print *, 'Enter the space size:'
read*, xy
Print*, 'Enter the final space:'
read*, Smax
h=Smax/xy !The size of spacestep
Print*, 'This gives stepsize of space h=',h
JI=20 ! Total number of space stepsize
allocate (x(0:JI),u(0:JI+1,0:JI+1))
open(10,file='Jacobi_method.m')
do i=1, JI
do j=1,JI
! Using 5-point scheme Formulae
u(i+1,j)+u(i,j+1)+u(i-1,j)+u(i,j-1)-4*u(i,j)=-h**2
end do
end do
there are alots of code missing .can anyone please help me. Iam really stuck in this programing.....Thanks alot in advance.
END PROGRAM Jacobi_method
Use the five -point finite difference formula on a uniform mesh of size h in each direction.
Set up the matrix system Au=b (taking the natural ordering of the nodes) and program the Jacobi iteration method to solve it, i.e.
u^k = (I-D^-1 A)u^(k-1) + D^-1 b, where k is the iteration index and D is the diagonal of A.
=> So far my program
PROGRAM Jacobi_method
IMPLICIT NONE
! Declare Variables
Real, allocatable :: x),u,
Real:: m,xy,h,Smax
Integer:: i,j,JI
Print *, 'Enter the space size:'
read*, xy
Print*, 'Enter the final space:'
read*, Smax
h=Smax/xy !The size of spacestep
Print*, 'This gives stepsize of space h=',h
JI=20 ! Total number of space stepsize
allocate (x(0:JI),u(0:JI+1,0:JI+1))
open(10,file='Jacobi_method.m')
do i=1, JI
do j=1,JI
! Using 5-point scheme Formulae
u(i+1,j)+u(i,j+1)+u(i-1,j)+u(i,j-1)-4*u(i,j)=-h**2
end do
end do
there are alots of code missing .can anyone please help me. Iam really stuck in this programing.....Thanks alot in advance.
END PROGRAM Jacobi_method