su2code/SU2

Fails to calculate function for Adjoint calculation

Closed this issue · 5 comments

For an inverse design problem, SU2 fails to calculate INVERSE_DESIGN_PRESSURE for adjoint calculation. SU2_CFD runs without any errors, while the solver enters the adjoint calculation design phase using the shape_optimization.py script it exhibits the following key error:

File "C:\SU2\bin\SU2\eval\functions.py", line 118, in function func_out = state['FUNCTIONS'][func_name] KeyError: 'INVERSE_DESIGN_PRESSURE'

I have attached the files used for the simulation. Any help is appreciated.

Thanks.

inverse_design.zip

Hi, I think the "aerodynamics" calculation does not start, because in line 91 of functions.py
if su2io.historyOutFields[func_name]['TYPE'] == 'COEFFICIENT' or su2io.historyOutFields[func_name]['TYPE'] == 'D_COEFFICIENT':
and the su2io.historyOutFields[INVERSE_DESIGN_PRESSURE]['TYPE']='DEFAULT'. I think modifying the historyMap.py may fix this error.
Hope this helps.

zhen

@zhangzhen117

Thank you so much for your input. I really appreciate your time and help.

I made the following changes in the historyMap.py as suggested:

'INVERSE_DESIGN_PRESSURE': {'DESCRIPTION': 'Cp difference for inverse design',
                             'GROUP': 'CP_DIFF',
                             'HEADER': 'Cp_Diff',
                             'TYPE': `'DEFAULT'}`

to


'INVERSE_DESIGN_PRESSURE': {'DESCRIPTION': 'Cp difference for inverse design',
                             'GROUP': 'CP_DIFF',
                             'HEADER': 'Cp_Diff',
                             'TYPE': 'COEFFICIENT'}

Now the solver enters the adjoint calculation and works fine. Thanks a lot.

Nice to hear that! You are welcome. @AbhijithMoni

I'm sorry but I have to say, this is why the code never evolves, you open an issue, get a solution for your problem, then close the issue without there being a pull request that actually fixes the problem for everyone else.

@pcarruscag, my sincere apologies for not redirecting it to a pull request. I will make sure to redirect to pull request if something comes up in future. Thanks for your help. Sorry again.