Problem with variable flux


can you solve my problem? I can`t figure out how fix it?!
codes:

program project
implicit none
doubleprecision :: l,w,dx,dy,tig,errorr,eps,beta,tb
doubleprecision,allocatable :: x(:),y(:),t(:,:),told(:,:),q2(:,:slight_smile:
integer ::n,m,i,j,iteration

!open file
open(10,file=“input.txt”)
open(11,file=“output.plt”)
open(12,file=“output.txt”)
!reading input
read(10,)
read(10,
) l
read(10,)
read(10,
) w
read(10,)
read(10,
) n
read(10,)
read(10,
) m
read(10,)
read(10,
) tig
read(10,)
read(10,
) tb
read(10,)
read(10,
) eps

!allocating
allocate (x(n),y(m),t(n,m),told(n,m),q2(n,m))

!grid generation
dx=l/(n-1)
dy=w/(m-1)
do i=1,n
x(i)=(i-1)*dx
end do
do j=1,m
y(j)=(j-1)*dy
end do
beta=dx/dy

!intial guess

t(:,:)=tig

!boundry condition
t(:,0)=tb

! function flux

do i=1,n
do j=1,m
q2(i,j)=(t(i-1,j)-2.0t(i,j)+t(i+1,j))/(dx**2.0)
q2(0,j)=5
j+27
q2(i,0)=0.0
q2(n,j)=0.0
q2(i,m)=0.0
end do
end do

!solving problem
told(:,:)=t(:,:slight_smile:
iteration=0
do
errorr=0.0
iteration=iteration+1
do i=2,n-1
do j=2,m-1
t(i,j) = (t(i-1,j)+told(i+1,j)+((beta2.0)(t(i,j-1)+told(i,j+1))))/(2.0(1.0+(beta2.0)))
errorr =max((abs(t(i,j)-told(i,j))),errorr)
q2(i,j)=(t(i-1,j)-2.0t(i,j)+t(i+1,j))/(dx**2.0)
if (q2(0,j)=5
j+27) exit
end do
end do

    if(errorr<eps) exit
     told(:,:)=t(:,:)
     print *, iteration,errorr
end do

!writing results
write (11,)‘variables=x,y,T zone i=’,m,‘j=’,n
do i=1,n
do j=1,m
write (11,
) x(i),y(j),t(i,j)
write (12,*) x(i),y(j),t(i,j)
end do
end do

end program project

Welcome to the forum! Please note that if you post source code, you best use the </> button to copy and paste the text with preservation of indentation and such. This makes it much more readable. And it avoids the replacement of certain combinations of characters by formatting, like the italics and the emoticons I now see.

Is this a homework assignment? The problem you say you are trying to solve is rather textbook :slight_smile: . And the updating of t(i,j) seems to be wrong - t(i-1,j) instead of told(|i-1,j) and what is the role of beta? Also beta does not seem to have been set to a particular value.

If the flux is variable (in time I resume), where is it updated?

Please elaborate on what you are trying to do and what you have tried so far. And what it is you think is going wrong. We are quite willing to help you solve it, but we do not intend to do your work :slight_smile: .

sorry, I am new.
yes this is my homework.
flux doesn’t need update, its variable and change temperature. I cant related them with each other.

Please edit your post and format the code (including proper indentations) as suggested by @Arjen . As it is, it is difficult to read.

Then please state more precisely what is the problem. Which values you get, and which values you are expecting. Also, without knowing the equations you are trying to translate to code, it can be hard to tell where is the problem in the code.