Burgers' PDE Equation occurs as a model for a number of physical problems (e.g. Fluids, Heat, Traffic, Shock Waves, etc.). The equation is Ut + Ux U = vis Uxx, where U = U(x,t), Ux = Partial of U w.r.t. X, & vis = viscosity.
Using a calculus level language, such as Fortran Calculus (FC), We'll show how to solve such a PDE in a minimum of time while improving a solutions accuracy. Most math models with PDEs and/or ODEs may be solved in a week. Solution accuracy improves due to the behind the scene use of Automatic Differentiation (AD). For a mental picture of what's going on, think of AD as taking symbolic derivatives of the equations involved in your model and evaluating these derivatives at given points. Derivative accuracy is thus as accurate as your computer allows.
At present, PDEs must be reduced to a system of ODEs in order to solve them with the Fortran Calculus compiler. The Method of Lines (MOL) is used to solve Burgers' 1D PDE as an example (code below or see PDE-ivp.fc source file). We hope to remove this restriction once enough interest in solving PDEs with Fortran Calculus is shown.
The key calculus level statements are Find & Integrate;
Find locates 'best' user parameters in order to meet an objective.
For example,
find Ux0, Uxx0 ooo to minimize gx
is requesting FC to vary parameters Ux0 & Uxx0 until gx is minimized.
Integrate does exactly that for given variables stated in ones Initiate statement. For example,
initiate Isis; for xAxis; Equations Uxx/Ux, Ux/U; of x; step dx; to xP
ooo
integrate xAxis; by Isis
statements are seeking to integrate the PDE variables (U, Ux, & Uxx) over x. Then the outer find statement will vary initial starting values (Ux0 & Uxx0) until gx is minimized.
Optimization is next once satisfied with solving a PDE or system of PDEs. The hardest part is often deciding on what are the primary objective goals. Code wise, converting to optimization just requires another Find statement put 'around' the present code.
An example optimization problem with Burgers' Equation is found in Optimal Control for fluid flow. The problem is to determine the most inexpensive control that will produce a flow to match a given target. Solution: Add 1) the user parameters that can be varied in your model, 2) objective function & 3) outer find statement. Then you are ready to solve your optimization problem. Now tweak, tweak, tweak until experience corrects your math model and objective function for your problem. (I'm speaking from experience; one job/problem took some two years to solve! Our math model and objective function had to be modified and modified and modified.)
FC code for Burgers' 1D Equation
global all
problem BurgersPDE
C ------------------------------------------------------------------------
C --- FORTRAN CALCULUS Application: Burgers' 1D Equation; a PDE Initial
C --- Value Problem.
C
C ... Warning ... a numerical problem exists with this code when 'dt' or
C ... 'viscosit' values are too small.
C ------------------------------------------------------------------------
dynamic U, Ux, Uxx
C User parameters ...
viscosit = .1 ! viscosity between .1 & .001 are of interest
iPoints = 100 ! grid pts. over x-axis
jPoints = 10 ! grid pts. over t-axis
tFinal = 1 ! not sure when odd numeric problem surfaces
C x-parameter initial settings: x ==> i
xFinal = 1: ip = ipoints
xPrint = xFinal/ipoints : dx = xPrint / 10
C t-parameter initial settings: t ==> j
pi= 4*atan(1): jp = jpoints: dt = tFinal/jpoints
allot U( jp), Ux( jp), Uxx( jp)
C settings/guesses at t = 0
do 10 jj = 1, jpoints
U(jj) = 0: Ux(jj) = 0: Uxx(jj) = 0
10 continue
call plotit
call xAxis
close( 31)
end
C ... Integrate over x-axis
model xAxis
15 format( 1x, 1Pg12.6, 2x, 10(G16.8, 2x))
79 format( 1h , a, 2x, f8.4, 3x, f8.4, 3x, (9g14.5, 3x))
initiate ISIS; for PDE;
~ equations Uxx/Ux, Ux/U; of x; step dx; to xp
x= 0
Do 10 ii = 1, ipoints
xp = ii * xPrint
integrate PDE; by ISIS
write(31,15) x, (U( jj), jj = 1, jp)
print 79, "x,U's= ", x, (U( jj), jj = 1, jp)
10 continue
end
model PDE ! Partial Differential Equation
Uxx(1) = U0ivp(x) ! Method of Lines
do 20 jj = 2, jpoints ! System of ODEs
Uxx(jj)= ((U(jj) - U(jj-1))/dt + U(jj) * Ux(jj))/viscosit
20 continue
end
Fmodel U0ivp(xx) ! Initial starting value for t-axis integration
if( xx .lt. 0) then
U0ivp = 0
elseif( xx .le. .5) then
U0ivp = (1 - cos( 4 * pi * xx))/2
else
U0ivp = 0
endif
end
procedure plotit
character*8 date, time, string*80
11 format( 3X, 2f11.6, 5x, a)
call getdate( date, time)
open( 1, file='CON') ! Output to CONSOLE
write(1,*) 'Enter a viscosity value: '
read *, viscosit
open( 31, FILE='~4plot3d.dat', Status='unknown')
write(6,11) dt, viscosit, ' = dt & viscosity'
string = "Burgers' 1D PDE Solution on " // date // " @ "
string = charnb( string) // time
write(31, *) string
write(31,11) dt, viscosit, ' = dt & viscosity'
write(31, *) iPoints, jPoints, ' iPoints & jPoints'
write(31, *) " PDE: Ut = -U Ux + viscosit Uxx"
write(31, *) " -------------------------------"
write(31, *) " "
write(31, *) " Solved PDE using 'Method of Lines'"
end
subroutine getdate( date1, time1)
character*8 date1, time1
call date( date1)
call time( time1)
return
end
|