CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

convergence criteria

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 1, 2012, 18:36
Default convergence criteria
  #1
New Member
 
ramila.h
Join Date: Dec 2010
Posts: 29
Rep Power: 15
afnene is on a distinguished road
I am trying to write a convergence criteria for a code ans I really need your help to do so
it's like (tempnew-tempold) less than 1e-6
do k=1,mstep

do i=0,n
do j=0,n
temp(0,0)=0.0
temp(i,j)=th(i,j)
diff=temp(i,j)-temp1(i,j)
enddo
enddo
temp1=temp
if (diff.lt.temp1e-6)then
stop
endif
enddo

Last edited by afnene; May 1, 2012 at 18:40. Reason: error
afnene is offline   Reply With Quote

Old   May 1, 2012, 22:48
Default
  #2
Senior Member
 
cdegroot's Avatar
 
Chris DeGroot
Join Date: Nov 2011
Location: Canada
Posts: 414
Rep Power: 17
cdegroot is on a distinguished road
Your logic doesn't make sense.

do k=1,mstep
do i=0,n
do j=0,n
temp(0,0)=0.0 <-- Why is this inside the loop; doesn't depend on i, j, or k
temp(i,j)=th(i,j) <-- What is "th"? It is never used
diff=temp(i,j)-temp1(i,j) <-- You calculate "diff" inside the loop and do nothing with it; it's not an array so it will be erased each time the loop is incremented
enddo
enddo
temp1=temp <-- What is this supposed to do?
if (diff.lt.temp1e-6)then <-- "diff" is meaningless here since it is only that value for i=j=n
stop
endif
enddo

To check time convergence you could do something like:

maxdiff=0.0
do i=0,n
do j=0,n
diff=abs(tempnew(i,j)-tempold(i,j))
if (diff>maxdiff) then
maxdiff=diff
end if
end do
end do
if (maxdiff<1.0e-6) then
stop
end if
cdegroot is offline   Reply With Quote

Old   May 2, 2012, 15:40
Default
  #3
New Member
 
ramila.h
Join Date: Dec 2010
Posts: 29
Rep Power: 15
afnene is on a distinguished road
Thank you so much for your precious help
I am just a beginner in CFD computation, The first step I did was to try how convergence can be written in a code
Please tell me how to read the old a new value of temperature inside iterrations?
afnene is offline   Reply With Quote

Old   May 2, 2012, 15:47
Default
  #4
Senior Member
 
cdegroot's Avatar
 
Chris DeGroot
Join Date: Nov 2011
Location: Canada
Posts: 414
Rep Power: 17
cdegroot is on a distinguished road
Quote:
Originally Posted by afnene View Post
Thank you so much for your precious help
I am just a beginner in CFD computation, The first step I did was to try how convergence can be written in a code
Please tell me how to read the old a new value of temperature inside iterrations?
I'm not sure I totally understand your question, but I will try my best to answer. I think you are asking about how to access an old value of temperature inside your loop. If you have a temperature array T(n,n) that you are working with, you should also define an array to store your old temperature, for example TO(n,n). Before updating T with your new solution you should transfer it to TO so you still have access to it when you go to check convergence. See below for an outline of what you should do.

1. Initialize T and TO
2. According to your numerical model find a new temperature field T
3. Check convergence between T and TO (see my previous post)
3a. If converged, exit
3b. If not converged, transfer T to TO and go to step 2
cdegroot is offline   Reply With Quote

Old   May 2, 2012, 16:05
Default
  #5
New Member
 
ramila.h
Join Date: Dec 2010
Posts: 29
Rep Power: 15
afnene is on a distinguished road
Thanks again,
I will do what you explained and let you know if it works for me
afnene is offline   Reply With Quote

Old   May 2, 2012, 18:36
Default
  #6
New Member
 
ramila.h
Join Date: Dec 2010
Posts: 29
Rep Power: 15
afnene is on a distinguished road
Well, It sounds working,but I really want that you check that with me and of course if you don't mind
the subroutine which compute temperature is as following:


subroutine tcalcu(f,temp,temp1,n,m)
real f(0:8,0:n,0:m),temp(0:n,0:m),temp1(0:n,0:m)
temp1=temp
do j=0,m
do i=0,n
sum=0.0
do k=0,8
sum=sum+f(k,i,j)
end do
temp(i,j)=sum
enddo
enddo

I called 'temp1' the new temperature value and insert it inside the subroutine and 'temp' as an old value......does it make sense?
return
end
afnene is offline   Reply With Quote

Old   May 6, 2012, 23:52
Default
  #7
Senior Member
 
cdegroot's Avatar
 
Chris DeGroot
Join Date: Nov 2011
Location: Canada
Posts: 414
Rep Power: 17
cdegroot is on a distinguished road
Your subroutine seems to be doing what you intend, but I can't really say if it is "correct" without knowing a bit more about what sort of algorithm you are using. So you are filling in temp1 with the existing temp array, i.e. as an old value. Then you update temp as the sum of all the local elements of f. If that is what you intend, then you are good.
cdegroot is offline   Reply With Quote

Old   May 7, 2012, 19:21
Default
  #8
New Member
 
ramila.h
Join Date: Dec 2010
Posts: 29
Rep Power: 15
afnene is on a distinguished road
It worked fine, I checked that by printing old and new values of temperature.

Thanks again Cdegroot, you were very helpful.

Afnene
afnene is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convergence Centurion2011 FLUENT 48 June 15, 2022 00:29
SIMPLE algorithm, convergence criteria bbasal Main CFD Forum 3 December 3, 2011 00:24
Force can not converge colopolo CFX 13 October 4, 2011 23:03
What value shall I set for the Convergence criteria? steventay CFX 7 May 14, 2010 13:44
Convergence Criteria edwin FLUENT 1 February 14, 2008 20:24


All times are GMT -4. The time now is 05:14.