Presentation is loading. Please wait.

Presentation is loading. Please wait.

Aerodynamic Design Using VLM Gradient Generation Using ADIFOR (Automatic Differentiation in Fortran) Santosh N. Abhyankar Prof. K. Sudhakar.

Similar presentations


Presentation on theme: "Aerodynamic Design Using VLM Gradient Generation Using ADIFOR (Automatic Differentiation in Fortran) Santosh N. Abhyankar Prof. K. Sudhakar."— Presentation transcript:

1 Aerodynamic Design Using VLM Gradient Generation Using ADIFOR (Automatic Differentiation in Fortran) Santosh N. Abhyankar Prof. K. Sudhakar

2 Brief Outline Why ADIFOR ? What is ADIFOR ? Where ADIFOR has been used ? Case studies in CASDE

3 Why ADIFOR ?

4 Gradient-based Optimization Gradients calculated to give search direction Accuracy of gradients affect: –Efficiency of the optimizer –Accuracy of the optimum solution

5 Different Ways to Calculate Gradients Numerical methods –Finite difference –Complex variable method –Adjoint method Analytical methods –Manual differentiation –Automated differentiation

6 Finite Difference Vs Complex Variable CFL3D of NASA. Inviscil, Laminar, Turb., (Un)steady, Multi-blk, Accel, etc Complex 115 mts 75.2 MB FD 36 mts 37.7 MB 41 mts 37.7 MB Note : For several cases FDM required trying out several step sizes to get correct derivative. Factoring this in, it was seen that time taken on an average was more than 2 times for a single analysis.

7 Optimizer General Flowchart of an Optimization Cycle Analysis Functions Say: f(x),h(x), g(x) = any Complicated functions

8 Optimizer Gradient Calculation using Forward Difference Method Analysis Functions Say: f(x),g(x), h(x) = any Complicated function

9 Drawbacks of Numerical Gradients Approximate Round-off errors Computational requirements: requires (n+1) evaluations of function f Difficulties with noisy functions

10 Optimizer Analysis Functions Say: f(x) = Sin(x) Externally supplied Analytical Gradients: = Cos(x) Facility to provide user-supplied Gradients

11 Optimizer F(x)/g(x)/h(x): Complex Analysis Code Externally supplied Analytical Gradients: = ? Facility to provide user-supplied Gradients

12 User Supplied Gradients Complex Analysis Code in Fortran Manually extract sequence of mathematical operations Code the complex derivative evaluator in Fortran Manually differentiate mathematical functions - chain rule FORTRAN source code that can evaluate gradients

13 User Supplied Gradients Manually extract sequence of mathematical operations Use symbolic math packages to automate derivative evaluation Code the complex derivative evaluator in Fortran Complex Analysis Code in FORTARN FORTRAN source code that can evaluate gradients

14 User Supplied Gradients Parse and extract the sequence of mathematical operations Use symbolic math packages to automate derivative evaluation Code the complex derivative evaluator in Fortran Complex Analysis Code in FORTARN FORTRAN source code that can evaluate gradients

15 Gradients by ADIFOR Complex Analysis Code in FORTARN FORTRAN source code that can evaluate gradients Automated Differentiation Package

16 What is ADIFOR ?

17 Automatic DIfferentiation in FORtran {ADIFOR} by Mathematics and Computer Science Division, Argonne National Laboratories, NASA.

18 Initial Inputs to ADIFOR The top level routine which contains the functions The dependant and the independent variables The maximum number of independent variables

19 Functionality of ADIFOR Consider The derivative of is given by

20 Functionality of ADIFOR …contd. For any set of functions say: ADIFOR generates a Jacobian:

21 SUBROUTINE test(x,f) double precision x(2),f(3) f(1) = x(1)**2 + x(2)**2 f(2) = x(1)*x(2) f(3) = 2.*x(1) + 3.*x(2)**2 return end ADIFOR

22 subroutine g_test(g_p_, x, g_x, ldg_x, f, g_f, ldg_f) double precision x(2), f(3) integer g_pmax_ parameter (g_pmax_ = 2) integer g_i_, g_p_, ldg_f, ldg_x double precision d6_b, d4_v, d2_p, d1_p, d5_b, d4_b, d2_v, g_f(l *dg_f, 3), g_x(ldg_x, 2) integer g_ehfid intrinsic dble data g_ehfid /0/ C call ehsfid(g_ehfid, 'test','g_subrout5.f') C if (g_p_.gt. g_pmax_) then print *, 'Parameter g_p_ is greater than g_pmax_' stop endif

23 d2_v = x(1) * x(1) d2_p = 2.0d0 * x(1) d4_v = x(2) * x(2) d1_p = 2.0d0 * x(2) do g_i_ = 1, g_p_ g_f(g_i_, 1) = d1_p * g_x(g_i_, 2) + d2_p * g_x(g_i_, 1) enddo f(1) = d2_v + d4_v C-------- do g_i_ = 1, g_p_ g_f(g_i_, 2) = x(1) * g_x(g_i_, 2) + x(2) * g_x(g_i_, 1) enddo f(2) = x(1) * x(2) C-------- g_test contd.

24 d4_v = x(2) * x(2) d1_p = 2.0d0 * x(2) d4_b = dble(3.) d5_b = d4_b * d1_p d6_b = dble(2.) do g_i_ = 1, g_p_ g_f(g_i_, 3) = d5_b * g_x(g_i_, 2) + d6_b * g_x(g_i_, 1) enddo f(3) = dble(2.) * x(1) + dble(3.) * d4_v C-------- return end g_test contd.

25 ADIFOR Where ??

26 Applications of ADIFOR and ADIC ADIFOR and ADIC have been applied to application codes from various domains of science and engineering. Atmospheric Chemistry On-Chip Interconnect Modeling Mesoscale Weather Modeling CFD Analysis of the High-Speed Civil Transport Rotorcraft Flight 3-D Groundwater Contaminant Transport 3-D Grid Generation for the High-Speed Civil Transport A Numerically Complicated Statistical Function -- the Log-Likelihood for log-F distribution (LLDRLF).

27 Mesoscale Weather Modeling : Temperature sensitivity as computed by Divided Difference using a second-order forward-difference formula

28 Mesoscale Weather Modeling: Temperature sensitivity as computed by ADIFOR

29 Case Study at CASDE

30 Optimization Problem Minimize : induced drag (C di ) Subject to: C L = 0.2 Design variables: jig-twist(  ) and angle of attack at root (     has a linear variation from zero at root to  at tip.   is constant over the entire wing semi-span. crcr ctct 

31 The VLM Code 600 lines (approx) SUBROUTINE vlm(amach, cr, ct, bby2, sweep,twist,alp0,isym, ni_gr, nj_gr, cl, cd, cm) CALL mesh(cr, ct, bby2, sweep, …,ni_gr, nj_gr) CALL matinv(aic, np_max, index, np) CALL setalp(r_p, beta, twist, bby2, alp0, alp, np) CALL mataxb(aic, alp, gama, np_max, np_max, np, np, 1) CALL mataxb(aiw, gama, w, np_max, np_max, np, np, 1) CALL loads(…,gama, w, str_lift, alift, cl, cd, cm)

32 The ADIFOR-generated derivative of VLM subroutine g_vlm(g_p_, …, twist, g_twist,ldg_twist, alp0, g_alp0, ldg_alp0, isym, ni_gr, nj_gr, cl, g_cl,ldg_cl, cd, g_cd, ldg_cd, cm) call mesh(cr, ct, bby2, sweep, …, ni_gr, nj_gr) call matinv(aic, np_max, index, np) call g_setalp(g_p_, r_p, beta, twist, g_twist, ldg_twist, bby2, alp0, g_alp0, ldg_alp0, alp, g_alp, g_pmax_, np) call g_mataxb(g_p_, aic, alp, g_alp, g_pmax_, gama, g_gama, g_pmax_, np_max, np_max, np, np, 1) call g_mataxb(g_p_, aiw, gama, g_gama, g_pmax_, w, g_w, g_pmax_, np_max, np_max, np, np, 1) call g_loads(g_p_, …, ni_gr, nj_gr, np, …, gama, g_gama, g_pmax_, w, g_w, g_pmax_, str_lift, alift, g_alift, g_pmax_, cl, g_cl, ldg_cl, cd, g_cd, ldg_cd, cm)

33 Optimization Results Jig-twist  CLCL C Di Starting Values 2.05.40.45220.01104 Values at Optimum (FD) -2.274393.7822710.20.00191156 Values at Optimum (ADIFOR) -2.299103.7931760.20.00191155

34 Optimization Results Jig-twist  CLCL C Di Starting Values 2.0 -6.0 5.4 1.9 0.4522 -0.0538 0.01104 0.00121 Values at Optimum (FD) -2.27439 3.782271 0.2 0.00191156 Values at Optimum (ADIFOR) -2.29910 3.793176 0.2 0.00191155

35 Comparison of Time Taken for Optimization With Finite Difference With ADIFOR No. of function Evaluations 2515 Total time in Seconds 35.4121.45

36 Codes with CASDE Inviscid 3D Code for arbitrary configurations. Tried on ONERA M6. Optimised for memory and CPU time. –total subroutines: 93 –total source lines : 5077 Viscous laminar, 2D, Cartesian for simple configurations. Not optimized. More easily readable. Research code. –total subroutines : 35 –total source lines : 2316

37 Limitations Strict ANSI Fortran 77 code.

38 Thank You


Download ppt "Aerodynamic Design Using VLM Gradient Generation Using ADIFOR (Automatic Differentiation in Fortran) Santosh N. Abhyankar Prof. K. Sudhakar."

Similar presentations


Ads by Google