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 
C  Calculus Programming example: Burgers' 1D Equation; a PDE; Parameter
C  Estimation; Initial Value Problem solved using Method of Lines.
C 
dynamic U, Ut, Ut0
C
C User parameters ...
viscosit=.01 ! viscosity between .1 & .001 are of interest
ipoints=20 ! grid pts. over xaxis
tFinal= .5 ! not sure when odd numeric problem surfaces
jpoints=10*tFinal ! grid pts. over taxis
C
C xparameter initial settings: x ==> i
ip=ipoints: a=.5: pi= 4*atan(1.)
xFinal= 1: dx=xFinal/ipoints
allot U(ip), Ut(ip), Ut0(ip)
C tparameter initial settings: t ==> j
tPrint= tFinal/jpoints: dt=tPrint / 10
print 78, "viscosity=", viscosit, dt
78 format( 1x, a, f5.2, 2x, f5.3)
C
Find a in xAxis by Ajax to match error
end
model xAxis
C ... Integrate over xaxis
C settings at x=0
do 1 ii=1, ipoints
xPrt=ii * dx: call U0( xPrt)
Ut(ii)= Ut0(ii): U(ii)= U0start
1 continue
t= 0: tPrt=tPrint: dt=tPrt / 10
print 79, t, (U(ii),ii=1,ip)
! Initiate athena; for PDE;
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
print 79, t, (U(ii),ii=1,ip)
tPrt=tPrt + tPrint
if( tdt .le. 0.2 .and. 0.2 .lt. t+dt) error= (a  U(15))**2
end if
end do
79 format( 1x, f5.2, 1x, 20(1pg12.4))
end
model PDE ! Partial Differential Equation
C ! Method of Lines
Vxx=(U(3)  2*U(2)  U(1))/dx**2
Ut(1)= viscosit * Vxx  (U(2)U(1))/dx
do 20 ii=2,ipoints1 ! System of ODEs
Vxx=(U(ii+1)  2*U(ii)  U(ii1))/dx**2
Ut(ii)= viscosit * Vxx  (U(ii+1)U(ii1))/(2*dx)
20 continue
Vxx=(U(ipoints)  2*U(ipoints1)  U(ipoints2))/dx**2
Ut(ipoints)= viscosit * Vxx  (U(ipoints)U(ipoints1))/dx
end
Fmodel U0(xx) ! Initial starting values @ t = 0
if( xx .le. 0) then
U0 = 0
elseif( xx .lt. .5 ) then
U0 = (1  cos( 4 * pi * xx))/2
else
U0 = 0
endif
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.

