|
Increased Productivity Example #9
Burgers' PDE Equation &
Optimization
__________
-
Burgers' Equation, a non-linear 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 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.
- The key calculus level statements are Find
& Integrate; Find locates 'best' user parameters in order to
meet an objective. For example,
- Find Ut0, Ux0, Uxx0,
ooo to match g_all
is requesting MC to vary parameters Ut0, Ux0, Uxx0, ooo until g_all =
0.
- Integrate does exactly that for given
variables stated in ones Initiate statement. For example,
- initiate Gemini; for x_PDE; equations
Uxx/Ux, Ux/U; of x; ooo
ooo
integrate x_PDE; by Gemini
- statements are seeking to integrate the
PDE variables (Uxx, Ux, & U) over X. Another Find
statement is necessary to determine the remaining PDE unknown variables
with dependency on other independent variables such as T; e.g. Ut.
Next, integrate over time, t, and Find Vt & V.
Then the outer Find statement will vary initial
starting values (Ut0, Ux0, etc.) until U = V; i.e. g_all = 0.
- 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.)
|
|
|
Increased Productivity Example
#9 Source Code:
-
global all problem BurgersPDE C ------------------------------------------------------------------------ C --- Calculus Programming example: Burgers' 1D Equation; a PDE Initial C --- Value Problem solved using Method of Lines. C ------------------------------------------------------------------------ dynamic U, Ux, Uxx C C User parameters ... viscosit = .1 ! viscosity between .1 & .001 are of interest ipoints = 40 ! grid pts. over x-axis jpoints = 20 ! grid pts. over t-axis tFinal = 1 ! not sure when odd numeric problem surfaces C C x-parameter initial settings: x ==> i xFinal = 1: 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 call xAxis ! end ! Stmt.s not necessary in IVP, but used in BVP version model xAxis ! C ... Integrate over x-axis
C settings at x = 0 do 1 jj = 1, jpoints xPrt = jj * xPrint U(jj) = U0(xPrt): Ux(jj) = 0: Uxx(jj) = 0 10 continue
x= 0: xPrt = xPrint: dx = xPrt / 10 Initiate athena; for PDE; ~ equations Uxx/Ux, Ux/U; of x; step dx; to xPrt do while (x .lt. xFinal) Integrate PDE; by athena if( x .ge. xPrt) then print 79, x, (U( jj), jj = 1, jp) xPrt = xPrt + xPrint end if end do 79 format( 1h , a, 2x, f8.4, 3x, 10(g14.5, 2x)) end model PDE ! Partial Differential Equation C ! Method of Lines do 20 jj = 2, jpoints ! System of ODEs Uxx(jj)= (Ux(jj)*U(jj) + (U(jj)-U(jj-1))/dt) / viscosit 20 continue 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
- Visit ODEcalc for an Ordinary Differential
Equations Calculator. Try it and see the power of Calculus programming.
- Solving PDEs are another
increased productivity example do to using Calculus (level) programming.
HTML code for linking to this page:
- <a
href="http://www.digitalcalculus.com/example/burgers-pde.html"><img
align="middle" width="100"
src="http://www.digitalcalculus.com/image/fc-win-icon.gif"/>
<strong>Burgers Partial Differential Equation</strong>
</a>; Simulation to Optimization, Tweak Parameters for Optimal
Solution.
Go to top
|
|