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

Define a new design variable

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 20, 2021, 10:20
Post Define a new design variable
  #1
Member
 
Zhen ZHANG
Join Date: Jun 2018
Location: Beijing, China
Posts: 56
Rep Power: 7
Zhen ZHANG is on a distinguished road
Hi all,
I want to define a new design variable, which is the turbulence Prandtl number. There are several questions:
1, Is it possible to define such a DV, which is not related to the geometry? Maybe it is not needed to call the SU2_DOT(_AD) to get the sensitivity.
2, What is the basic process to define a DV and use the discrete adjoint solver to get the sensitivity? Are there any codes to learn from?
3, Is it possible to extend the DV to be the field distribution of the turbulence Pr number? For example, the point-wise distribution among all mesh points.

Thank you!
zhen
Zhen ZHANG is offline   Reply With Quote

Old   May 20, 2021, 11:00
Default
  #2
pcg
Senior Member
 
Pedro Gomes
Join Date: Dec 2017
Posts: 460
Rep Power: 13
pcg is on a distinguished road
Hi,
1 - It is possible, we already do it for some, like AoA.
2 - For Prandtl number you would need some modifications like these https://github.com/su2code/SU2/issues/679
3 - Everything is possible but it would require significant refactoring to make the entire code aware of a locally defined Pr number.
pcg is offline   Reply With Quote

Old   May 21, 2021, 05:04
Default
  #3
Member
 
Zhen ZHANG
Join Date: Jun 2018
Location: Beijing, China
Posts: 56
Rep Power: 7
Zhen ZHANG is on a distinguished road
Hi,
Thank you for the reply!
I am working on it.

Zhen
Zhen ZHANG is offline   Reply With Quote

Old   May 24, 2021, 09:29
Default
  #4
Member
 
Zhen ZHANG
Join Date: Jun 2018
Location: Beijing, China
Posts: 56
Rep Power: 7
Zhen ZHANG is on a distinguished road
Hi,
I am following the modifications in https://github.com/su2code/SU2/issues/679 to define the turbulence Prandtl number as a design variable.
I have defined a variable member named Prandtl_Turb in CFVMFlowSolverBase class, in CNumerics class, and in CDiscAdjSolver class. I registered the CDiscAdjSolver.Prandtl_Turb in CDiscAdjSolver::RegisterVariables. The next step is to set the Prandtl_Turb in direct-solver and numerics classes. I wrote all the inline virtual Get and Set functions. Here are my questions:

1. In CDiscAdjSolver::RegisterVariables, I set the Prandtl_Turb to the direct solver just as the temperature and the pressure. Is it correct?
2. To set the Prandtl_Turb in numerics class, how to determine which solver to get and which numerics to set?
3. When setting the Prandtl_Turb, I used the Get function that returns by value and the Set function that receives by value. Is that correct? Does it maintain the recording process?

If my understanding is not correct, please also point it out.
Thanks in advance!
zhen
Zhen ZHANG is offline   Reply With Quote

Old   May 24, 2021, 11:05
Default
  #5
pcg
Senior Member
 
Pedro Gomes
Join Date: Dec 2017
Posts: 460
Rep Power: 13
pcg is on a distinguished road
Hi,

Yes temperature and pressure are good examples.
Set it in every solver and every numerics that is not "nullptr".
Passing by value is not a problem, but you need to make sure that the target values (in solver and numerics) are not overwritten after you set them equal to the variable you registered.
pcg is offline   Reply With Quote

Old   June 9, 2021, 10:26
Default
  #6
Member
 
Zhen ZHANG
Join Date: Jun 2018
Location: Beijing, China
Posts: 56
Rep Power: 7
Zhen ZHANG is on a distinguished road
Hi Pedro,

I modified the code as what was done in issue679 to define the turbulence Prandtl number as a design variable. I defined a data member in the discrete adjoint solver, registered it, and set it to numerics and the fluid model. However, after returning a small value, the solver returns zero in the iteration.

Could you please have a quick look at the code and give me some advice? Thank you a lot!

https://github.com/zhangzhen117/mySU...e801dfd6884a99

The SU2_CFD_AD returns
Code:
+--------------------------------------+
|  Inner_Iter|  rms[A_Rho]|    Sens_Prt|
+--------------------------------------+
|           0|  -11.792377| -2.1225e-19|
|           1|  -11.706523|  0.0000e+00|
|           2|  -11.623393|  0.0000e+00|
|           3|  -11.531036|  0.0000e+00|
|           4|  -11.440695|  0.0000e+00|
|           5|  -11.356140|  0.0000e+00|
|           6|  -11.278596|  0.0000e+00|
|           7|  -11.208591|  0.0000e+00|
|           8|  -11.146480|  0.0000e+00|
|           9|  -11.092506|  0.0000e+00|
Zhen ZHANG is offline   Reply With Quote

Old   June 10, 2021, 06:17
Default
  #7
pcg
Senior Member
 
Pedro Gomes
Join Date: Dec 2017
Posts: 460
Rep Power: 13
pcg is on a distinguished road
What you have done is correct.
Make sure that you are reading the derivative value in the same order as you register the variable.
This is a pitfall we fixed recently.
The other common cause for 0 derivatives is that something is not captured in the SetDependencies, for example maybe something needs to be recomputed to capture the influence of the Prandtl number on other quantities.

We have developer meetings every Wednesday at 3pm UK https://meet.jit.si/SU2_DevMeeting
It is easier to talk about code problems there.
pcg is offline   Reply With Quote

Old   June 10, 2021, 22:43
Default
  #8
Member
 
Zhen ZHANG
Join Date: Jun 2018
Location: Beijing, China
Posts: 56
Rep Power: 7
Zhen ZHANG is on a distinguished road
Hi,
Thank you for your reply! I will check the points you mentioned.
Zhen ZHANG is offline   Reply With Quote

Old   June 10, 2021, 22:54
Default
  #9
Member
 
Zhen ZHANG
Join Date: Jun 2018
Location: Beijing, China
Posts: 56
Rep Power: 7
Zhen ZHANG is on a distinguished road
Hi,
I have another question when I check the code. What is numerics_simd, and what is the difference between numerics and numeircs_simd?
Thanks!
Zhen ZHANG is offline   Reply With Quote

Old   June 11, 2021, 04:16
Default
  #10
pcg
Senior Member
 
Pedro Gomes
Join Date: Dec 2017
Posts: 460
Rep Power: 13
pcg is on a distinguished road
Oh right I forgot about those.
They are special versions of some numerical schemes that use vectorization (to be faster, and save some memory in the adjoint).
Currently they are available for the compressible solver, always used for JST and used for Roe if USE_VECTORIZATION=YES.
The solver has a member variable called "edgeNumerics" and you will have to set the Pr number in there as well.
pcg is offline   Reply With Quote

Old   June 13, 2021, 05:51
Default
  #11
Member
 
Zhen ZHANG
Join Date: Jun 2018
Location: Beijing, China
Posts: 56
Rep Power: 7
Zhen ZHANG is on a distinguished road
Hi,
I set the Prt to the edgeNumerics, and it returns the right order of magnitude (~e3).
Code:
+--------------------------------------+
|  Inner_Iter|  rms[A_Rho]|    Sens_Prt|
+--------------------------------------+
|           0|  -11.046790| -3.8419e+03|
|           1|  -11.009328|  0.0000e+00|
|           2|  -10.980025|  0.0000e+00|
|           3|  -10.958730|  0.0000e+00|
|           4|  -10.945269|  0.0000e+00|
|           5|  -10.939468|  0.0000e+00|
|           6|  -10.941165|  0.0000e+00|
|           7|  -10.950207|  0.0000e+00|
|           8|  -10.966425|  0.0000e+00|
|           9|  -10.989582|  0.0000e+00|
However, it gets zero after the first step. I will go on checking it, and do you have any advice? I think the recording step has finished when the iteration starts, but why the derivative goes zero after one step of iteration?
Thanks!
Zhen ZHANG is offline   Reply With Quote

Reply

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
Hydrogen storage by metal hydride longbk FLUENT 12 August 1, 2023 21:13
How to define value of a variable at a cell face in terms of neighbouring cell face wavefunction OpenFOAM Programming & Development 4 April 18, 2018 05:48
Define a new variable ata OpenFOAM 2 July 16, 2010 01:47
Free surface boudary conditions with SOLA-VOF Fan Main CFD Forum 10 September 9, 2006 13:24
UDF FOR UNSTEADY TIME STEP mayur FLUENT 3 August 9, 2006 11:19


All times are GMT -4. The time now is 05:41.