Fortran Fortran: heat transfer program quick help

AI Thread Summary
The discussion focuses on modeling heat transfer in a solid block material subjected to a laser heating one corner to 200 degrees while initially at 70 degrees. Participants are working on a Fortran program to simulate this process, using two arrays to track temperature changes over time. The key challenge is determining when the system reaches steady state, defined as when no temperature changes exceed 0.1 degrees between iterations. One participant suggests using the maximum absolute difference between the two temperature arrays to signal steady state, proposing a conditional statement to stop the iteration when this condition is met. Another contributor raises questions about the implementation of the temperature update formula, specifically the need for symmetry in averaging neighboring cell temperatures. They recommend modifying the temperature calculation to ensure accurate spatial averaging and provide a structured loop to continuously update temperatures until the steady state condition is satisfied. The discussion emphasizes the importance of correctly implementing the algorithm to ensure accurate modeling of heat transfer dynamics.
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.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...

Similar threads

Back
Top