CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > SU2

Optimization using averaged & last-step drag

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By bigfootedrockmidget

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 7, 2025, 20:25
Default Optimization using averaged & last-step drag
  #1
New Member
 
Qi Wang
Join Date: Oct 2024
Posts: 7
Rep Power: 2
QiWang is on a distinguished road
Dear SU2-ers,
I'm performing adjoint-based optimization for a last-step objective function (say, the -drag). I'm not sure whether the current framework is for time-averaged outputs or just the objective at the last time step. Where should I find that information and how can I make the objective function only at the last time step?
QiWang is offline   Reply With Quote

Old   January 8, 2025, 05:01
Default
  #2
Senior Member
 
bigfoot
Join Date: Dec 2011
Location: Netherlands
Posts: 718
Rep Power: 21
bigfootedrockmidget is on a distinguished road
Are you referring to this tutorial?


https://su2code.github.io/tutorials/..._Opt_NACA0012/


What do you want to change compared to this tutorial?
QiWang likes this.
bigfootedrockmidget is offline   Reply With Quote

Old   January 8, 2025, 07:06
Default
  #3
New Member
 
Qi Wang
Join Date: Oct 2024
Posts: 7
Rep Power: 2
QiWang is on a distinguished road
Quote:
Originally Posted by bigfootedrockmidget View Post
Are you referring to this tutorial?


https://su2code.github.io/tutorials/..._Opt_NACA0012/


What do you want to change compared to this tutorial?
I want to perform optimization based on the last time step output only (say the last step drag)

One way I'm thinking about is to change the window function so that only the last time step has weight 1, and 0 for all other time steps.
In CWindowingTools.cpp there is a function

Code:
su2double CWindowingTools::GetWndWeight(WINDOW_FUNCTION windowId, unsigned long curTimeIter, unsigned long endTimeIter) {
  switch (windowId) {
    case WINDOW_FUNCTION::HANN:        return HannWindow(curTimeIter, endTimeIter);
    case WINDOW_FUNCTION::HANN_SQUARE: return HannSquaredWindow(curTimeIter, endTimeIter);
    case WINDOW_FUNCTION::BUMP:        return BumpWindow(curTimeIter, endTimeIter);
    case WINDOW_FUNCTION::SQUARE:      return 1.0;
  }
  return 1.0;
}
I could add a line
Code:
case WINDOW_FUNCTION::LAST_ONLY:   return (curTimeIter == endTimeIter) ? 1.0 : 0.0;
However, in the first step of adjoint (which correspond to the last step of the direct solver, curTimeIter is 0 while endTimeIter is nTimeIter). I'm confused about how the time indexing is done between direct and adjoint computations.

Another way is to change the averaging length.
In Cconfig.cpp, line 5337,
Code:
      if (Iter_Avg_Objective == 0.0) {
        Iter_Avg_Objective = nTimeIter;
      }
The default value of Iter_Avg_Objective is nTimeIter, and the objective function is averaged over the whole time domain.
I'm wondering whether changing this line to Iter_Avg_Objective = 1 would make the program perform optimization for objectives only at the last time step.
Of course this is a very dirty fix. I'm new to SU2 and having been learning for two weeks. I'm looking for professional users that could advise me with better options.
QiWang is offline   Reply With Quote

Old   January 9, 2025, 10:17
Default
  #4
Senior Member
 
bigfoot
Join Date: Dec 2011
Location: Netherlands
Posts: 718
Rep Power: 21
bigfootedrockmidget is on a distinguished road
Quote:
One way I'm thinking about is to change the window function so that only the last time step has weight 1, and 0 for all other time steps.
How is this different from using a window with only one timestep or the averaging?
I still don't see how your setup differs from the tutorial, besides changing some numbers.
bigfootedrockmidget is offline   Reply With Quote

Reply

Tags
adjoint solver, adjointoptimisation, design optimization, su2

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
RANS shape optimization all gradients are zero cfd-jg SU2 Shape Design 0 April 24, 2024 10:52
courant number increases to rather large values 6863523 OpenFOAM Running, Solving & CFD 22 July 6, 2023 00:48
time step continuity problem in VAWT simulation lpz_michele OpenFOAM Running, Solving & CFD 5 February 22, 2018 20:50
How to write k and epsilon before the abnormal end xiuying OpenFOAM Running, Solving & CFD 8 August 27, 2013 16:33
Upgraded from Karmic Koala 9.10 to Lucid Lynx10.04.3 bookie56 OpenFOAM Installation 8 August 13, 2011 05:03


All times are GMT -4. The time now is 09:40.