Fortran: heat transfer program quick help

Click For Summary

Discussion Overview

The discussion revolves around a Fortran program designed to model heat transfer in a solid block of material. Participants are addressing how to implement a stopping condition for the simulation when the temperature reaches a steady state, as well as refining the algorithm for calculating temperature updates within the block.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Homework-related

Main Points Raised

  • One participant describes the initial setup of the program, including the use of two arrays to represent temperature at time T and T+1, and seeks advice on how to implement a condition to stop iterations when temperature changes are minimal.
  • Another participant suggests a method to check for steady state using the maximum absolute difference between the two temperature arrays, proposing a specific code snippet to achieve this.
  • A subsequent post questions the correctness of the temperature update formula, suggesting that the indices used may be incorrect and proposing a symmetric averaging approach for temperature calculation.
  • Further, a participant provides a more structured approach to the loop, recommending an outer loop that continues until the steady state condition is met, and includes a suggestion for tracking the number of iterations.

Areas of Agreement / Disagreement

Participants are engaged in refining the program and discussing various aspects of the implementation. There is no consensus on the exact formulation of the temperature update or the stopping condition, as different suggestions are made and questioned.

Contextual Notes

There are unresolved details regarding the specific algorithm being used for temperature calculation, as well as potential issues with the indexing in the temperature update formula. The discussion reflects a collaborative effort to clarify these points without reaching a definitive resolution.

ttiger2k7
Messages
57
Reaction score
0
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
 
Technology news on Phys.org
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
 
okay, so something like this?

IF (MAXVAL(ABS(temp-temp2))<=0.1) THENDO 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
 
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.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 13 ·
Replies
13
Views
3K
Replies
7
Views
2K
Replies
1
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 20 ·
Replies
20
Views
2K
  • · Replies 21 ·
Replies
21
Views
3K
  • · Replies 3 ·
Replies
3
Views
8K