
[Sponsors] 
June 19, 2013, 17:39 
adjoint method uniformity

#1 
New Member
Andreas
Join Date: Feb 2013
Posts: 5
Rep Power: 12 
Hello I am new here and this is my first post. I am a mechanical engineering student and currently writing my master’s thesis. This is about the adjoint optimization method.
I want to change the optimization target form the current implementation in OF 2.2.0 (minimize pressurelosses) to the target of the flow uniformity at the outlet. Therefore I have tried to implement the equations for this cost function based on the papers of Othmer and Hinterberger/Olesen. A continuous adjoint formulation for the computation of topological and surface sensitivities of ducted flows (C. Othmer) Automatic Geometry Optimization of Exhaust Systems Based on Sensitivities Computed by a Continuous Adjoint CFD Method in OpenFOAM (Hinterberger, C. and Olesen, M.) According to Othmer only the code of adjointOutletPressure and adjointOutletVelocity has to be the changed. I have done this as follows: adjointOutletVelocity: Code:
const fvsPatchField<scalar>& phiap = patch().lookupPatchField<surfaceScalarField, scalar>("phia"); const fvPatchField<vector>& Up = patch().lookupPatchField<volVectorField, vector>("U"); const fvPatchField<vector>& Udp = patch().lookupPatchField<volVectorField, vector>("Ud"); scalarField Un(mag(patch().nf() & Up)); % normal component primal vel. scalarField Udn(mag(patch().nf() & Udp)); % normal component desired vel vectorField Ut(Up  patch().nf()*Un); % tangential component primal vel. vectorField Udt(Udp  patch().nf()*Udn); % tangential component desired vel. vectorField UtHat((Ut  Udt)/(Un + SMALL)); % tangential component adjoint vel. vectorField Ua(phiap*patch().Sf()/sqr(patch().magSf())); % normal component adjoint vel. vectorField::operator=(Ua  UtHat); Code:
const fvsPatchField<scalar>& phip = patch().lookupPatchField<surfaceScalarField, scalar>("phi"); const fvsPatchField<scalar>& phiap = patch().lookupPatchField<surfaceScalarField, scalar>("phia"); const fvPatchField<vector>& Up = patch().lookupPatchField<volVectorField, vector>("U"); const fvPatchField<vector>& Uap = patch().lookupPatchField<volVectorField, vector>("Ua"); const fvPatchField<vector>& Udp = patch().lookupPatchField<volVectorField, vector>("Ud"); scalarField Udn(mag(patch().nf() & Udp)); operator==((phiap/patch().magSf() + 1.0)*phip/patch().magSf() + (Up & Uap)  Udn); I have applied this code to a simple (turbulent) 2d example with one inlet and three outlets. The primal velocity at the inlet was set to 1 m/s and the desired velocity at the outlet to 0.667 m/s. The boundaries for the primal variables and the adjointpressure were set as in the tutorial case. The adjointvelocity at the inlet was set to zero as stated in the paper of Othmer. The convergence was quite good but the result is strange as you can see in the picture "3outlets". I have tried another simple example of a laminar 2d duct flow. The primal velocity and the adjoint velocity were chosen to be equal. Normally, no cells should be blocked in that case. The result is that nearly all cells are blocked. Just a small flow passage remains (picture: duct) My questions now are:  is the implementation of the equations for the optimization target right?  do I have to change something else in the code ?  according to Othmer, the difference of the primal and desired velocity would act as a source term in the outlet bc. How can this be understood?  any other notes ? Thanks a lot in advance, appreciate all answers best regards 

June 20, 2013, 09:55 

#2  
Member
Roland
Join Date: Mar 2009
Location: Netherlands
Posts: 80
Rep Power: 16 
Quote:
Welcome to the forum and the world of adjoint optimization! I have experimented with this a bit before, but I never have found the time to fully test my code, so you should probably treat the following with care. 1. My bc's are comparable to yours, although some parts I did differently. For example, I simplified the velocity boundary condition by assuming only normal desired and adjoint flow. Also, looking at the pressure bc I have +Udn, where you have Udn. (But looking at my code again, I am pretty sure the error is mine!) 2. Basically, only the bc's need to be adjusted to fit your cost function. However, for stability often other modifications are necessary; see some other posts by me about this subject. Stability is, still, an ongoing problem for me, therefore I cannot help you more on this than with what I have written before. 3. The outlet bc acts as the adjoint source as the propagation of the adjoint variables is reversed with respect to your primal flow. I hope this helps you. Good luck! regards, Sylvester 

July 1, 2013, 04:01 

#3  
New Member
Andreas
Join Date: Feb 2013
Posts: 5
Rep Power: 12 
Hi Sylvester,
thanks für your reply. To 1: Quote:
I have chosen a desired velocity which has only a normal component, too. If I simply the bc for the adjoint velocity it look like: Code:
vectorField ::operator=(Ua) Unfortunately I get similar strange results like before. To 2: Quote:
Quote:
1. To start from a converged primal solution 2. Update the alphafield after the adjoint field has roughly converged 3. Mesh quality 4. Pseudo staggered approach To 3: The mesh quality in my case is not the problem 4: Is that much programming effort ? 1+2: I have already tried to start from a converged primal solution without a positive effect. I will try to start the adjoint method on a converged primal solution without updating the alpha field to get a converged adjoint field. However, when I look at the boundaries I have some doubts how the adjoint flow field should arise or look like (see attachment). The conditions for Ua at the inlet is (accoriding to Othmer) a fixedValue (Ua =0 ) and the the one at the outlet acts as a fixedValue, or ? The vector plot (3outlets) of my first case shows what I mean. The adjoint flow enters the domain at the first outlet and leaves it trough the others. Could, or should that be right ? Best regards Envolly 

July 2, 2013, 04:55 

#4 
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 25 
hi
I'm unfamiliar with adjoint method but a question occurred to me. Are you implementing a fixedValue of velocity on the output instead of fixedValue pressure? Does it seem right?
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King. To Be or Not To Be,Thats the Question! The Only Stupid Question Is the One that Goes Unasked. 

July 2, 2013, 06:49 

#5 
New Member
Andreas
Join Date: Feb 2013
Posts: 5
Rep Power: 12 
Hi immortality,
as far as I could determine the type of boundaries for the adjoint variables ( my c++ knowledge is not so good), both are fixedValues. Have a look in the adjointOutletPressure.C and adjointOutletVelocity.C. You will find for the pressure: Code:
operator==((phiap/patch().magSf()  1.0)*phip/patch().magSf() + (Up & Uap)); fixedValueFvPatchScalarField::updateCoeffs(); Code:
vectorField::operator=(phiap*patch().Sf()/sqr(patch().magSf()) + UtHat); //vectorField::operator=(Uan + UtHat); fixedValueFvPatchVectorField::updateCoeffs(); pressure: Code:
operator==() Code:
vectorField::operator=() Best regards Envolly 

July 2, 2013, 07:21 

#6 
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 25 
then U and p are set on outlet.why it has be done in this manner?
and what means that formula in mathematical form?where they come from?do you know?
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King. To Be or Not To Be,Thats the Question! The Only Stupid Question Is the One that Goes Unasked. 

July 3, 2013, 05:28 

#7  
New Member
Andreas
Join Date: Feb 2013
Posts: 5
Rep Power: 12 
For detailed description I would refer you to the papers which I have quoted in my first post:
Quote:
short answer: Ua and Pa (adjoint vel. and adjoint pressure) are the Lagrange multipliers. The adjointmethod uses a Lagrange function because it is a constrained optimization problem. The optimization target (total pressure losses, energy dissipation, flow uniformity) is defined in the boundary conditions. That´s why they are so important. regards Envolly 

July 3, 2013, 09:34 

#8 
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 25 
so they aren't real pressure and velocity,right?
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King. To Be or Not To Be,Thats the Question! The Only Stupid Question Is the One that Goes Unasked. 

July 9, 2013, 02:29 

#9 
New Member
Andreas
Join Date: Feb 2013
Posts: 5
Rep Power: 12 
from my point of view, they have no real physical meaning. the adjoint velocity is needed to calculate the sensitivity.
But if I'm wrong please anybody correct me.. 

Tags 
adjoint, uniformity 
Thread Tools  Search this Thread 
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Help for learning about Adjoint Method in optimization  EmadTandis  Main CFD Forum  0  March 15, 2013 05:55 
Question about Continuous Adjoint Method  fumiya  Main CFD Forum  6  November 1, 2011 11:09 
Method for solving the adjoint equations  fumiya  Main CFD Forum  1  June 13, 2011 01:18 
Adjoint method  Jens  OpenFOAM Running, Solving & CFD  14  June 12, 2011 22:09 
A question about discrete adjoint method  Thomas  Main CFD Forum  3  August 9, 2006 13:37 