Fortran: heat transfer program quick help

In summary, the program runs 49 times and then exits. The average temperature of the block is 197 degrees, the maximum temperature is 210 degrees, and the minimum temperature is 192 degrees.
  • #1
ttiger2k7
58
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
  • #2
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
 
  • #3
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
 
  • #4
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.
 

1. What is Fortran?

Fortran is a high-level programming language used for scientific and engineering applications, particularly in the field of numerical computation. It was first introduced in the 1950s and has since undergone several updates and improvements.

2. What is a heat transfer program?

A heat transfer program is a computer program that simulates the flow of heat through different materials. It uses mathematical equations to calculate the transfer of thermal energy and can be used to model and predict the behavior of various systems, such as buildings or electronic devices.

3. How does Fortran help with heat transfer calculations?

Fortran is a powerful language for performing complex calculations, making it well-suited for heat transfer programs. It has built-in functions for dealing with arrays and matrices, which are commonly used in heat transfer calculations. Additionally, Fortran allows for efficient memory management and can handle large amounts of data, making it an ideal choice for computationally intensive tasks such as heat transfer simulations.

4. Is Fortran still widely used in scientific computing?

Yes, Fortran is still a popular choice for scientific computing, particularly in fields such as physics, engineering, and meteorology. It is known for its high performance and reliability, making it a preferred language for applications that require precise and efficient calculations.

5. Can Fortran be used for other types of programs besides heat transfer?

Yes, Fortran is a general-purpose programming language and can be used for a wide range of applications, not just heat transfer programs. It is commonly used in fields such as computational fluid dynamics, weather forecasting, and data processing. Some companies and organizations, such as NASA and the National Weather Service, still use Fortran for their critical systems and applications.

Similar threads

  • Programming and Computer Science
Replies
4
Views
572
  • Engineering and Comp Sci Homework Help
Replies
13
Views
1K
  • Advanced Physics Homework Help
Replies
1
Views
656
  • Introductory Physics Homework Help
Replies
3
Views
946
  • Thermodynamics
Replies
5
Views
1K
Replies
11
Views
1K
Replies
1
Views
583
  • Thermodynamics
Replies
28
Views
1K
  • Programming and Computer Science
Replies
20
Views
1K
Replies
19
Views
1K
Back
Top