Hi all,
I'm new to the forum and couldn't find any good tips for speeding up my program, but I'm hoping there's someone who can help. I'm writing this for a school project in my Heat Transfer class. m and n are coordinates, m range from 1 to 31, n range from 1 to 41 and I need to output a temperature (Tnode) for every (m,n) coordinate. Tau, Time, and Tstep are user inputted, but they can be .225, 20, and .2, respectively. I'm running Excel07/Win7/4GB ram/2.4GHz duo if that matters.
<m<31, 1<n<41="" and="" i="" need="" to="" output="" a="" temperature="" (tnode)="" for="" every="" (m,n)="" coordinate.="" tau,="" time,="" tstep="" are="" user="" inputted,="" but="" they="" can="" be="" .225,="" 20,="" .2,="" respectively.="" i'm="" running="" excel07="" win7="" 4gb="" ram="" 2.4ghz="" duo="" if="" that="" matters.
<m<31, 1<n<41="" and="" i="" need="" to="" output="" a="" temperature="" (tnode)="" for="" every="" (m,n)="" coordinate.="" tau,="" time,="" tstep="" are="" user="" inputted,="" but="" they="" can="" be="" .225,="" 20,="" .2,="" respectively.="" i'm="" running="" excel07="" win7="" 4gb="" ram="" 2.4ghz="" duo="" if="" that="" matters.
Option Explicit
Function Contour_Plot2(m, n, Tau, Time, Tstep)
Dim i, j, Tnode(1 To 31, 1 To 41), a, x, y, g, TV
For i = 1 To 31
Tnode(i, 1) = 10
Tnode(i, 41) = 40
Next i
For j = 1 To 41
Tnode(1, j) = 0
Tnode(31, j) = 0
Next j
For a = 1 To (Time / Tstep)
For x = 2 To 30
For y = 2 To 40
g = Tnode(x, y)
Tnode(x, y) = Tau * (Tnode(x + 1, y) + Tnode(x, y + 1) + Tnode(x - 1, y) + Tnode(x, y - 1)) + (1 - 4 * Tau) * Tnode(x, y)
TV = TV + Abs(Tnode(x, y) - g)
Next y
Next x
If TV < 0.01 Then
Exit For
End If
Next a
Contour_Plot2 = Tnode(m, n)
End Function
___________________________________
Thank you!<m<31, 1<n<41="" and="" i="" need="" to="" output="" a="" temperature="" (tnode)="" for="" every="" (m,n)="" coordinate.="" tau,="" time,="" tstep="" are="" user="" inputted,="" but="" they="" can="" be="" .225,="" 20,="" .2,="" respectively.="" i'm="" running="" excel07="" win7="" 4gb="" ram="" 2.4ghz="" duo="" if="" that="" matters.
</m<31,></m<31,></m<31,>
I'm new to the forum and couldn't find any good tips for speeding up my program, but I'm hoping there's someone who can help. I'm writing this for a school project in my Heat Transfer class. m and n are coordinates, m range from 1 to 31, n range from 1 to 41 and I need to output a temperature (Tnode) for every (m,n) coordinate. Tau, Time, and Tstep are user inputted, but they can be .225, 20, and .2, respectively. I'm running Excel07/Win7/4GB ram/2.4GHz duo if that matters.
<m<31, 1<n<41="" and="" i="" need="" to="" output="" a="" temperature="" (tnode)="" for="" every="" (m,n)="" coordinate.="" tau,="" time,="" tstep="" are="" user="" inputted,="" but="" they="" can="" be="" .225,="" 20,="" .2,="" respectively.="" i'm="" running="" excel07="" win7="" 4gb="" ram="" 2.4ghz="" duo="" if="" that="" matters.
<m<31, 1<n<41="" and="" i="" need="" to="" output="" a="" temperature="" (tnode)="" for="" every="" (m,n)="" coordinate.="" tau,="" time,="" tstep="" are="" user="" inputted,="" but="" they="" can="" be="" .225,="" 20,="" .2,="" respectively.="" i'm="" running="" excel07="" win7="" 4gb="" ram="" 2.4ghz="" duo="" if="" that="" matters.
Option Explicit
Function Contour_Plot2(m, n, Tau, Time, Tstep)
Dim i, j, Tnode(1 To 31, 1 To 41), a, x, y, g, TV
For i = 1 To 31
Tnode(i, 1) = 10
Tnode(i, 41) = 40
Next i
For j = 1 To 41
Tnode(1, j) = 0
Tnode(31, j) = 0
Next j
For a = 1 To (Time / Tstep)
For x = 2 To 30
For y = 2 To 40
g = Tnode(x, y)
Tnode(x, y) = Tau * (Tnode(x + 1, y) + Tnode(x, y + 1) + Tnode(x - 1, y) + Tnode(x, y - 1)) + (1 - 4 * Tau) * Tnode(x, y)
TV = TV + Abs(Tnode(x, y) - g)
Next y
Next x
If TV < 0.01 Then
Exit For
End If
Next a
Contour_Plot2 = Tnode(m, n)
End Function
___________________________________
Thank you!<m<31, 1<n<41="" and="" i="" need="" to="" output="" a="" temperature="" (tnode)="" for="" every="" (m,n)="" coordinate.="" tau,="" time,="" tstep="" are="" user="" inputted,="" but="" they="" can="" be="" .225,="" 20,="" .2,="" respectively.="" i'm="" running="" excel07="" win7="" 4gb="" ram="" 2.4ghz="" duo="" if="" that="" matters.
</m<31,></m<31,></m<31,>
Last edited: