adjoint method uniformity
2 Attachment(s)
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 = Code:
const fvsPatchField<scalar>& phip = 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 
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 
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 
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? 
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)); Code:
vectorField::operator=(phiap*patch().Sf()/sqr(patch().magSf()) + UtHat); pressure: Code:
operator==() Code:
vectorField::operator=() Best regards Envolly 
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? 
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 
so they aren't real pressure and velocity,right?

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.. 
All times are GMT 4. The time now is 20:28. 