Adjoint thermo optimization - FOAMacademy...Table of contents Motivation Adjoints in a Nutshell...

25
Adjoint thermo optimization Thorsten Grahs, 29. September 2016 Institute of Scientific Computing/move-csc

Transcript of Adjoint thermo optimization - FOAMacademy...Table of contents Motivation Adjoints in a Nutshell...

Page 1: Adjoint thermo optimization - FOAMacademy...Table of contents Motivation Adjoints in a Nutshell Adjoint Heat System OpenFOAM Perspectives 29. September 2016 Thorsten Grahs Adjoint

Adjoint thermo optimization

Thorsten Grahs, 29. September 2016

Institute of Scientific Computing/move-csc

Page 2: Adjoint thermo optimization - FOAMacademy...Table of contents Motivation Adjoints in a Nutshell Adjoint Heat System OpenFOAM Perspectives 29. September 2016 Thorsten Grahs Adjoint

Table of contents

Motivation

Adjoints in a Nutshell

Adjoint Heat System

OpenFOAM

Perspectives

29. September 2016 Thorsten Grahs Adjoint thermo optimization Seite 2

Page 3: Adjoint thermo optimization - FOAMacademy...Table of contents Motivation Adjoints in a Nutshell Adjoint Heat System OpenFOAM Perspectives 29. September 2016 Thorsten Grahs Adjoint

Optimal shape design

MotivationFind the optimal design, i.e.

shapevolume(surface mesh/volume mesh)

which minimizes/maximizes a certain cost functional, e.g.dragnoisepressure lossstrainweightswirl

29. September 2016 Thorsten Grahs Adjoint thermo optimization Seite 3

Page 4: Adjoint thermo optimization - FOAMacademy...Table of contents Motivation Adjoints in a Nutshell Adjoint Heat System OpenFOAM Perspectives 29. September 2016 Thorsten Grahs Adjoint

Different optimization tasks

Topology optimizationVolume optimization – starting point maximal design spaceDesign variable αi (porosity/virtual sand)

Borrvall, Petterson: Topology optimization of fluids in Stokes flow, Num.Meth.Fluids. 41, 2003

Shape optimizationSurface optimizationstarting point topology optimizationDesign variable βi (surface normal displacement)

29. September 2016 Thorsten Grahs Adjoint thermo optimization Seite 4

Page 5: Adjoint thermo optimization - FOAMacademy...Table of contents Motivation Adjoints in a Nutshell Adjoint Heat System OpenFOAM Perspectives 29. September 2016 Thorsten Grahs Adjoint

Example | Duct optimization

T. T. Robinson, C. G. Armstrong, H. S. Chua, C. Othmer, Th. G.Optimizing Parameterized CAD Geometries Using Sensitivities Based on Adjoint Functions

Computer-Aided Design and Applications 9(3):253-268, 2012.29. September 2016 Thorsten Grahs Adjoint thermo optimization Seite 5

Page 6: Adjoint thermo optimization - FOAMacademy...Table of contents Motivation Adjoints in a Nutshell Adjoint Heat System OpenFOAM Perspectives 29. September 2016 Thorsten Grahs Adjoint

Examples | Topology & shape optimization

Othmer et al.(2006 - today)VW Research

29. September 2016 Thorsten Grahs Adjoint thermo optimization Seite 6

Page 7: Adjoint thermo optimization - FOAMacademy...Table of contents Motivation Adjoints in a Nutshell Adjoint Heat System OpenFOAM Perspectives 29. September 2016 Thorsten Grahs Adjoint

References

General approach stems from control theoryIntroduction into PDEs

Lions (1971) Optimal Control of Systems Governed by PDEs

Pironneau (1984) Optimal shape design for elliptic systems

Introduction into CFD

Jameson (1988) Aerodynamic design via control theory

Giles (1997) Design optimisation for complex geometries

Löhner (2003) An adjoint-based design methodology for CFD optimizationproblems

Topology optimization for CFD

Borrvall/Petersson (2003) Topology optimization of fluids in Stokes flows

Othmer/Grahs (2005) Approaches to fluid dynamic optimization in the cardevelopment process

Othmer (2006-today) Surface & topo optimization in industrial context

Othmer (2008) A continuous adjoint formulation for the computation of topologicaland surface sensitivities of ducted flows, Int. J. Numer. Methods Fluids 58.

29. September 2016 Thorsten Grahs Adjoint thermo optimization Seite 7

Page 8: Adjoint thermo optimization - FOAMacademy...Table of contents Motivation Adjoints in a Nutshell Adjoint Heat System OpenFOAM Perspectives 29. September 2016 Thorsten Grahs Adjoint

Adjoint heat shape optimization

Apply the shape optimization process(adjoint approach) to heat depended problems

TasksAugment governing equations (Navier-Stokes) with heat/temperatureDerive adjoint systemChoose desired optimization goal (cost function)Derive boundary conditions w.r.t. cost functionSolve primal-adjoint systemUpdate surface (normal displacement)by means of sensitivity information from primal-adjoint system

29. September 2016 Thorsten Grahs Adjoint thermo optimization Seite 8

Page 9: Adjoint thermo optimization - FOAMacademy...Table of contents Motivation Adjoints in a Nutshell Adjoint Heat System OpenFOAM Perspectives 29. September 2016 Thorsten Grahs Adjoint

Applications

Heat transfer on dimpledsurfaces

Uniformity at HVAC outlets

. . .

Joined work with Johan Turnow, Uni Rostock

29. September 2016 Thorsten Grahs Adjoint thermo optimization Seite 9

Page 10: Adjoint thermo optimization - FOAMacademy...Table of contents Motivation Adjoints in a Nutshell Adjoint Heat System OpenFOAM Perspectives 29. September 2016 Thorsten Grahs Adjoint

Formulation

Let I be a specific cost function

Ω ⊂ RN an admissible domain with boundary Γ

Typically, the form has to satisfy a set of given constraints R = 0mostly defined as PDEs with state variables U.

The form is parametrized by of set of design variables β

We can formulate the problem by

min /maxβ

I(s,α) subject to r(s,β) = 0 on Ω

29. September 2016 Thorsten Grahs Adjoint thermo optimization Seite 10

Page 11: Adjoint thermo optimization - FOAMacademy...Table of contents Motivation Adjoints in a Nutshell Adjoint Heat System OpenFOAM Perspectives 29. September 2016 Thorsten Grahs Adjoint

Sensitivity

We look for the sensitivity of the cost function wrt. the designvariables, i.e.

dIdβ

=∂I∂s

dsdβ

+∂I∂β

with constraint∂r∂s

dsdβ

+∂r∂β

= 0

By defining

gT :=∂I∂s

, u :=∂s∂β

, A :=∂r∂s

, f := −∂r∂β

we can convert this in standard form

dIdβ

= gT u +∂I∂β

subjected to Au = f

One can evaluate gT u by solving Au = f

29. September 2016 Thorsten Grahs Adjoint thermo optimization Seite 11

Page 12: Adjoint thermo optimization - FOAMacademy...Table of contents Motivation Adjoints in a Nutshell Adjoint Heat System OpenFOAM Perspectives 29. September 2016 Thorsten Grahs Adjoint

Shifting to the dual problem

ProblemFor multiple design variable βi (f.i. surface nodes)each has different f := − ∂r

∂β

⇒ As many primal solution u as design variables required

RemedyShift to the dual or adjoint system A?v = gSolve once for v and can evaluate

gT u ≡ vT f

This holds since we have

vT f = vT Au = (A?v)T u = gT u

29. September 2016 Thorsten Grahs Adjoint thermo optimization Seite 12

Page 13: Adjoint thermo optimization - FOAMacademy...Table of contents Motivation Adjoints in a Nutshell Adjoint Heat System OpenFOAM Perspectives 29. September 2016 Thorsten Grahs Adjoint

Alternative Lagrange viewpoint

We introduce Lagrange function/multipliers and transform into anunconstrained optimization problem:

L(s,β) = I(s,β) − λT r(s,β)

Considering general variation δs and δβ gives

δL =

(∂I∂s

− λT ∂r∂s

)δs +

(∂I∂β

− λT ∂r∂β

)δβ

If λT is chosen to satisfy the adjoint equation

∂I∂s

− λT ∂r∂s

= 0 ⇒(∂r∂s

)T

λ =

(∂I∂s

)T

we obtain

δL =

(∂I∂β

− λT ∂r∂β

)δβ

29. September 2016 Thorsten Grahs Adjoint thermo optimization Seite 13

Page 14: Adjoint thermo optimization - FOAMacademy...Table of contents Motivation Adjoints in a Nutshell Adjoint Heat System OpenFOAM Perspectives 29. September 2016 Thorsten Grahs Adjoint

Governing equations

We start from the incompressible Navier-Stokes equations:

∂t(ρu) + (u · ∇)u = −∇p +∇ · [2νD(u)]

∂tρ+∇ · u = 0

with

p pressure, u = (u1, . . . , u3)T velocity, T Temperature

D(u) = 12 [∇u + (∇u)T ] stress tensor

ν kinematic viscosity

We equip the system with an thermal diffusion equation, i.e.

∂T∂t

+ (u · ∇)T = ∇(α · ∇T )

with α thermal diffusivity.

29. September 2016 Thorsten Grahs Adjoint thermo optimization Seite 14

Page 15: Adjoint thermo optimization - FOAMacademy...Table of contents Motivation Adjoints in a Nutshell Adjoint Heat System OpenFOAM Perspectives 29. September 2016 Thorsten Grahs Adjoint

Residual form of the N.-S. system

We are interested in a steady-state solution,⇒ omit the time-derivatives

Rewrite the system in residual form, i.e.

r(s) =

(r1, r2, r3)T

r4

r5

=

(u · ∇)u +∇p −∇ · [2νD(u)]−∇ · u

(u · ∇)T −∇(α · ∇T )

with state vector s = (u, p,T )T

29. September 2016 Thorsten Grahs Adjoint thermo optimization Seite 15

Page 16: Adjoint thermo optimization - FOAMacademy...Table of contents Motivation Adjoints in a Nutshell Adjoint Heat System OpenFOAM Perspectives 29. September 2016 Thorsten Grahs Adjoint

Deriving the adjoint system

Starting point: vanishing variation of the Lagrange function:

δsL =∑

i

∫Ω

∂IΩ∂si

δsi dΩ+

∫Γ

∂IΓ∂siδsi dΓ

+∑

i,j

∫Ω

si∂rj

∂siδsi dΩ

=

∫Ω

∂IΩ∂uδu dΩ+

∫Γ

∂IΓ∂uδu dΓ +

∫Ω

s · δur dΩ

+

∫Ω

∂IΩ∂pδp dΩ+

∫Γ

∂IΓ∂pδp dΓ +

∫Ω

s · δpr dΩ

+

∫Ω

∂IΩ∂T

δT dΩ+

∫Γ

∂IΓ∂TδT dΓ +

∫Ω

s · δT r dΩ ≡ 0.

with s = (u, p, T )T adjoint state variables (Lagrange multiplier)

29. September 2016 Thorsten Grahs Adjoint thermo optimization Seite 16

Page 17: Adjoint thermo optimization - FOAMacademy...Table of contents Motivation Adjoints in a Nutshell Adjoint Heat System OpenFOAM Perspectives 29. September 2016 Thorsten Grahs Adjoint

Variation of the residual form

The variation of the residual form with respect to the flow field is

δsr = δur + δpr + δT r

=

(δu · ∇)u + (u · ∇)δu −∇ · [2νD(u)]−∇ · δu

+(δu · ∇)T

+

∇δp00

+

00

(u · ∇)δT −∇ · (α∇δT )

29. September 2016 Thorsten Grahs Adjoint thermo optimization Seite 17

Page 18: Adjoint thermo optimization - FOAMacademy...Table of contents Motivation Adjoints in a Nutshell Adjoint Heat System OpenFOAM Perspectives 29. September 2016 Thorsten Grahs Adjoint

Variation of the residual form

After several basic transformation

δsL =

∫Ω

δuδpδT

·−∇u · u − (u · ∇)u −∇ · (2νD(u)) +∇p − T∇T +∂IΩ

∂u−∇ · δu +∂IΩ

∂p

(δu · ∇)T +∂IΩ∂T

+

∫Γ

δuδpδT

·n(u · u + u(u · n) + 2νn · D(u) + TTn − pn +∂IΓ

∂uu · n +∂IΓ

∂p

νn · ∇T + T (u · n) +∂IΓ∂T

dΓ (1)

+

∫Γ

upT

·−2νn · D(δu)

0−νn · (δT )

dΓ (2)

=

∫Ω

δs ·(

r +∂I∂s

)dΩ+

∫Γ

δs · bc1 dΓ +∫Γ

s · bc2 dΓ (3)

≡ 029. September 2016 Thorsten Grahs Adjoint thermo optimization Seite 18

Page 19: Adjoint thermo optimization - FOAMacademy...Table of contents Motivation Adjoints in a Nutshell Adjoint Heat System OpenFOAM Perspectives 29. September 2016 Thorsten Grahs Adjoint

Adjoint system

The corresponding inhomogeneous adjoint system(Time-independent incompressible adjoint N.-S. with heat diffusion)to the optimization problem is r = ∂I

∂si.e.

D(u)u +∇ · (2νD(u)) +∇p − T∇T =∂IΩ∂u

∇ · u =∂IΩ∂p

u · ∇T +∇ · (ν∇T ) =∂IΩ∂T

29. September 2016 Thorsten Grahs Adjoint thermo optimization Seite 19

Page 20: Adjoint thermo optimization - FOAMacademy...Table of contents Motivation Adjoints in a Nutshell Adjoint Heat System OpenFOAM Perspectives 29. September 2016 Thorsten Grahs Adjoint

Adjoint Boundary conditions

For the boundary integrals we have to fulfil the following expression:

0 ≡ δs · bc1 + s · bc2

=

δuδpδT

·n(u · u + u(u · n) + 2νn · D(u) + TTn − pn+∂I`

∂uu · n +∂I`

∂p

νn · ∇T + T (u · n) +∂I`∂T

+

upT

·−2νn · D(δu)

0−νn · (δT )

, ∀δs, s.

Thus, BCs depend on objective function

29. September 2016 Thorsten Grahs Adjoint thermo optimization Seite 20

Page 21: Adjoint thermo optimization - FOAMacademy...Table of contents Motivation Adjoints in a Nutshell Adjoint Heat System OpenFOAM Perspectives 29. September 2016 Thorsten Grahs Adjoint

Objective functions

Heat conduction on the wall

Ihc =12

∫wall

(∂T∂n

)2

d Γ

Uniformity (outlet)

Iu =12

∫wall

(T −

Ainlet

AoutletTinlet

)2

d Γ

Depending on theobjective functionprimal boundary conditions

the adjoint boundary conditions changes.

I.e. for each objective function own boundary conditions

29. September 2016 Thorsten Grahs Adjoint thermo optimization Seite 21

Page 22: Adjoint thermo optimization - FOAMacademy...Table of contents Motivation Adjoints in a Nutshell Adjoint Heat System OpenFOAM Perspectives 29. September 2016 Thorsten Grahs Adjoint

Implementation in OpenFOAM

Base solversimpleFoam

Adjoint solver (for minimizing pressure loss).adjointShapeOptimizationFoamOpenFOAM 4.0 release

based on

C. Othmer, E. de Villiers, H.G. WellerImplementation of a continuous adjoint for topology optimizati-on of ducted flows, 18th AIAA Computational Fluid DynamicsConference Miami, Florida, AIAA-2007-3947

29. September 2016 Thorsten Grahs Adjoint thermo optimization Seite 22

Page 23: Adjoint thermo optimization - FOAMacademy...Table of contents Motivation Adjoints in a Nutshell Adjoint Heat System OpenFOAM Perspectives 29. September 2016 Thorsten Grahs Adjoint

Extensions (carried our so far)

primal/adjoint heat diffusion, i.e.

fvScalarMatrix TaEqn( fvm::div(-phi, Ta) == fvm::laplacian(nuEff, Ta));

derivation of the BCs according to the chosen cost functionimplementation of the BCs in OpenFOAM:

adjointOutletTemperatureHeatfluxadjointOutletPressureHeatfluxadjointOutletVelocityHeatfluxadjointWallTemperatureHeatfluxadjointOutletTemperatureUniformity...

further improvements (e.g. stabilization of adjoint convection)derivation/implementation of the sensitivity vector field

29. September 2016 Thorsten Grahs Adjoint thermo optimization Seite 23

Page 24: Adjoint thermo optimization - FOAMacademy...Table of contents Motivation Adjoints in a Nutshell Adjoint Heat System OpenFOAM Perspectives 29. September 2016 Thorsten Grahs Adjoint

Mesh deformation

Mesh deformation1. Smoothing sensitivity vector field2. Mapping on the mesh/surface3. Mesh deformation

(Mesh motion solver in OpenFOAM)

Test caseDimpled surfaceOptimization due to different/combined cost functions

Report (in progress)Th. Grahs, J. Turnow Adjoint-based heat transfer optimization fordimpled surfaces, Informatikberichte, Institute of Scientific Computing,TU Braunschweig. (hopefully finished before semester starts...)

29. September 2016 Thorsten Grahs Adjoint thermo optimization Seite 24

Page 25: Adjoint thermo optimization - FOAMacademy...Table of contents Motivation Adjoints in a Nutshell Adjoint Heat System OpenFOAM Perspectives 29. September 2016 Thorsten Grahs Adjoint

Next steps

Comparison of morphing strategies

Mesh motion solver in OpenFOAM

ANSA (commercial tool)

Free Form Deformation (FFD)techniques

Further application

HVAC

Thermal management

Thermal comfort

MethodologyAdjoint thermal wall functionsCombined topology&surface optimization (Immersed boundarymeth.)

29. September 2016 Thorsten Grahs Adjoint thermo optimization Seite 25