Fortran: heat transfer program quick help

  • Fortran
  • Thread starter ttiger2k7
  • Start date
58
0

Main Question or Discussion Point

You are given a solid, homogenous block of material, 48x24x12 inches suspended in air at 70 degrees. The block is initially at 70 degrees as well. Then, a laser is used to heat one corner of the block to a constant 200 degrees. Model the heat transfer through the block and report the average, maximum and minimum temperature of the block once it reaches steady state. How many time-cycles does it take to reach steady state (steady state has been reached when no cube's temperature changes by more the 0.1 degrees between iterations.)?

**

I've written some of the program already. I've got two arrays, one at time T and what at time T+1. After I calculated the temperature of each cube in the T+1 array, then it becomes the T array for the next iteration. How should I go about making it stop when the temperature at T+1 minus the temperature at T is less than or equal to .1?

btw, this is f90
 

Answers and Replies

alphysicist
Homework Helper
2,238
1
Hi ttiger2k7,

If I understand your program correctly, if you let A be the array at time T and B be the array at time T+1, I think this would signal that the steady state condition had been met:


if ( maxval ( abs( A - B )) <= 0.1 ) then
--executable statements to record time-cycles--
stop
endif
 
58
0
okay, so something like this?

IF (MAXVAL(ABS(temp-temp2))<=0.1) THEN


DO i=2,49
DO j=2,25
DO k=2,13

temp(i,j,k) = (1/6)*(temp(i-1,j,k)+temp(i+3,j,k)+temp(i,j-1,k)+temp(i,j+3,k)+temp(i,j,k-1)+temp(i,j,k+3))

END DO
END DO
END DO

temp=temp2

END IF

END DO
 
alphysicist
Homework Helper
2,238
1
Hi ttiger2k7,

It's difficult for me to make remarks since I don't know details about your programs. But here's some thoughts; maybe they will be useful. Or not.

1. Inside the triple do loop, should that be temp2(i,j,k) on the left hand side of the line?

2. That line seems to be taking a spatial average over the neighbors of each cell to get the new temperature of the cell. But I was wondering about the integer offsets you use. For example, when the program runs and at the point when i,j,k are all equal to 2, that line will be

temp(2,2,2)=(1/6)( temp(1,2,2)+temp(5,2,2)+temp(2,1,2)+temp(2,5,2)+temp(2,2,1)+temp(2,2,5) )


Should your line be

temp(i,j,k) = (1/6)*(temp(i-1,j,k)+temp(i+1,j,k)+temp(i,j-1,k)+temp(i,j+1,k)+temp(i,j,k-1)+temp(i,j,k+1))

There's no way for me to be sure since I don't know which algorithm you are using, but this way would be a symmetric average about each point.

3. It looks to me like you want to keep looping over these lines until the steady state condition is reached; once the steady state temperature is reached you need the loop to end. Something like:

------------------------------

DO

IF (MAXVAL(ABS(temp-temp2))<=0.1) EXIT


DO i=2,49
DO j=2,25
DO k=2,13

temp(i,j,k) = (1/6)*(temp(i-1,j,k)+temp(i+3,j,k)+temp(i,j-1,k)+temp(i,j+3,k)+temp(i,j,k-1)+temp(i,j,k+3))

END DO
END DO
END DO

temp=temp2


END DO

-----------------------------------

(If you need to know how many times the loop ran, you can put an incrementing counter inside the loop.) So the outermost DO loop keeps running until the steady state condition is reached; at that point the IF statement is true and the program exits the do loop.
 

Related Threads for: Fortran: heat transfer program quick help

  • Last Post
Replies
6
Views
4K
Replies
6
Views
2K
Replies
1
Views
2K
  • Last Post
Replies
1
Views
3K
Replies
10
Views
4K
Replies
1
Views
7K
Replies
3
Views
2K
Replies
13
Views
2K
Top