Increased Productivity Example #9
Burgers' PDE Equation & Parameter Estimation
__________
Burgers' Equation, a nonlinear PDE, occurs as a model for a number of physical problems (e.g. Fluids, Heat, Traffic, Shock Waves, etc.). The equation is Ut + Ux U = v Uxx, where U = U(x,t), Ux = Partial of U w.r.t. X, & v = viscosity.
Using a calculus level language, we'll show how to solve such a PDE in a minimum of time while tweaking parameter(s) to meet user's requirements. 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.
The key calculus level statements are Find & Integrate; Find locates 'best' user parameters in order to meet an objective. For example,
Find a, Ut0 ooo to match error is requesting to vary parameters a & Ut0 ooo until error = 0.
Integrate does exactly that for given variables stated in ones Initiate statement. For example,
initiate Gemini for PDE equations Ut/U of T ooo
ooo
integrate PDE; by Gemini
Optimization is next once satisfied with solving a PDE or system of PDEs. Code wise, converting to
optimization just requires another Find statement wrapped '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.)

Increased Productivity Example #9 Source Code:
global all
problem BurgersPDE
C I'm new to Method of Lines (MOL) and PDEs, so please check my work!
C Internet shows solutions to Burgers Equation that differ greatly!!!
C Are the solutions different types; e.g. Steady State vs. zzz?
C 
C  Calculus Programming example: Burgers' 1D Equation; a PDE Initial
C  Value Problem solved using Method of Lines.
C 
C ... Warning ... a numerical problem exists when 'dt' or 'viscosit' values
C ... are too small.
C 
dynamic U, Ut, error
C
C User parameters ...
viscosit = 1 ! viscosity between .1 & .001 are of interest
tFinal = .5 ! not sure when odd numeric problem surfaces
jpoints = 10*tFinal ! grid pts. over taxis
C
C xparameter initial settings: x ==> i
xFinal= 1
dx = .1
ipoints = xFinal/dx + 1.99 ! grid pts. over xaxis
allot U( ipoints), Ut( ipoints), error( ipoints)
C tparameter initial settings: t ==> j
dt = .005: tPrint= dt*jpoints: pts = ipoints
print 78, "viscosity, dt, dx, ipoints =", viscosit,dt,dx,pts
78 format( 1x, a, f5.3, 20(2x, f8.4))
C
call xAxis
end
model xAxis
C ... Integrate over xaxis ... for a steady state solution
last = 5 ! number of iterations for Steady State solution
do 10 i = 1, last
t= 0: tPrt = tPrint: dt = tPrt / 10
‹error› = ‹U›
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) .and. (i .eq. 1)) then
print 79, t, (U( j), j = 1, ipoints)
tPrt = tPrt + tPrint
elseif((t .ge. tPrt) .and. (i .eq. last)) then
print 79, t, (U( j), j = 1, ipoints)
tPrt = tPrt + tPrint
elseif(t .ge. tPrt) then
print 78, "", i
print 78, " "
tPrt = tPrt + tPrint
endif
end do
10 continue
‹error› = ‹U›  ‹error›
print 78, " "
print 78, "i & 'error' array follows = ", i
print 79, t, (error( j), j = 1, ipoints)
print 78, ""
print 78, " "
78 format( 1x, a, i8)
79 format( 1x, f4.3, 20(1x, f8.5))
end
model PDE ! Partial Differential Equation
C ! Method of Lines
C Boundary Conditions for Burgers' Equation
U(1) = 1/(1 + Exp(t/(4*viscosit))
U(ipoints) = 1/(1 + Exp((2t)/(4*viscosit))
do 20 jj = 2, ipoints1 ! System of ODEs ... Method of Lines
Ut(jj) = U(jj) * (U(jj+1)U(jj1))/(2*dx)
Ut(jj) = Ut(jj) + viscosit*(U(jj+1)2*U(jj)+U(jj1))/(dx*dx)
20 continue
end
Solving PDEs are another increased productivity example do to using Calculus (level) Programming.
HTML code for linking to this page:
<a
href="http://fortranCalculus.info/example/burgerspde.html"><img
style="float:left; width:100px"
src="http://fortranCalculus.info/image/fccompilericon.png"/>
<strong>Burgers Partial Differential Equation</strong>
</a>; Simulation to Optimization, Tweak Parameters for Optimal
Solution.

