FC Coding is One step from 1st Principles to Solution!

User's Heat Equation
Heat Equation
_________
α ∇^{2} U = U_{t}
Wikipedia comments: "The heat equation is of fundamental importance in diverse scientific fields. In mathematics, it is the prototypical parabolic partial differential equation. In probability theory, the heat equation is connected with the study of Brownian motion via the FokkerPlanck equation. In financial mathematics it is used to solve the BlackScholes partial differential equation. The diffusion equation, a more general version of the heat equation, arises in connection with the study of chemical diffusion and other related processes."
Do you have a Heat equation to solve? Or any other math equations? For the next few months of 2014, we are willing to help you solve them using Calculuslevel programming. To start, copy and modify the source code below in a file we'll call it {abc}{123}.fc where {abc} = your initials and {123} = any number or id; 8 characters max. for filename. Edit your {abc}{123}.fc file, especially lines starting with a "!" character.
Email us your {abc}{123}.fc file. We will compile & execute it and send you the output file. Try compiling you own code with our FCCompiler program. Download and install FCCompiler with more [~60] example problems to choose from. Learn how easy it works.
Next, you may modify a copy of this web page and send it to us for viewing. If accepted, we will post your webpage showing your problem with solution. If you want people to be able to contact you, please include your email address on this web page.
Please mention our fortranCalculus.info website to others. Thanks!



User's Heat Equation Source Code:
For 1Dimensional Heat Equation use following:
global all
problem HeatPDE
C 
C  Calculus Programming example: Heat Equation; a PDE Initial
C  Value Problem solved using Method of Lines.
C 
dynamic U, U0, Ut, Ut0
C
C User parameters ...
alpha = 2.e5 ! thermal diffusion coefficienct
ipoints = 21 ! grid pts. over xaxis
tFinal = 600 ! not sure when odd numeric problem surfaces
C
C xparameter initial settings: x ==> i
ip = ipoints: xFinal=1: dx=xFinal/(ipoints1)
allot U(ip), U0(ip), Ut(ip), Ut0(ip)
C
C tparameter initial settings: t ==> j
tPrint = tFinal / 20
Ua = .01: U00=.1: prnt = 0
do 10 i = 1, ipoints
U0(i) = U00
10 continue
C
call tAxis !
end ! Stmt.s not necessary in IVP, but used in BVP versions
model tAxis !
C ... Integrate over xaxis !
C !
do 10 ii = 1, ipoints ! Stmt.s not necessary in IVP, but used in BVP versions
U(ii) = U0(ii) !
10 continue !
error = 0: tPrt = tPrint: dt = tPrt / 20: t = 0
print *, U00, dt, dx, tPrint
C
C ... Integrate over taxis
Initiate ISIS; for PDE;
~ equations Ut/U; of t; step dt; to tPrt
do while (t .lt. tFinal)
Integrate PDE; by ISIS
if( t .ge. tPrt) then
if(prnt.eq.1) print 79, t,error,(U(ii),ii=1,ip)
tPrt = tPrt + tPrint
end if
end do
79 format( 1h , g10.4, 1x, 20(g11.5, 1x))
end
model PDE ! Partial Differential Equation
C ! Method of Lines
! error = error + (U(1)  Ua)**2 ! BC1: U(1)=Ua @ x=0, for all t
do 20 ij = 2, ipoints  1 ! System of ODEs
Uxx = (U(ij+1)  2*U(ij) + U(ij1)) / (dx*dx) ! using central difference
Ut(ij)= alpha * Uxx
20 continue ! BC2: partial(U, x)=0, @ x=L, for all t
! error = error + ((U(ip)U(ip1))/dx)**2
end
Go to top
