SU2 icon indicating copy to clipboard operation
SU2 copied to clipboard

Issue with Multipoint Optimization in SU2 Using SST Turbulence Model

Open EngJamal2023 opened this issue 1 year ago • 8 comments

I am facing an issue when performing compressible flow simulations with SST turbulence modeling for multipoint optimization. The optimization works fine for single-point or different control points, but when I attempt multipoint optimization, I encounter the following error consistently:


Error Message:

KeyError: 'AIRFOIL_AREA'

This error occurs when I run the optimization script using the following command:

python3 /usr/local/bin/shape_optimization.py -n 4 -f SST_FFA_W3_comp.cfg log.txt

I’ve provided a snippet of the error traceback below:

Traceback (most recent call last):
  File "/usr/local/bin/shape_optimization.py", line 314, in <module>
    main()
  File "/usr/local/bin/shape_optimization.py", line 184, in main
    shape_optimization(options.filename, options.nzones)
  ...
  File "/usr/local/bin/SU2/eval/functions.py", line 731, in multipoint
    func[i + 1] = aerodynamics(konfig, ztate)
  File "/usr/local/bin/SU2/eval/functions.py", line 334, in aerodynamics
    funcs[key] = state["FUNCTIONS"][key]
KeyError: 'AIRFOIL_AREA'

Configuration and Problem Setup:

  • Solver: RANS
  • Turbulence Model: SST
  • Multipoint Optimization Configuration: The optimization setup is defined with multiple Mach numbers, angles of attack (AOA), and Reynolds numbers for each point.

Multipoint Setup Example:

MULTIPOINT_MACH_NUMBER= ( 0.1, 0.2)
MULTIPOINT_WEIGHT= ( 0.5, 0.50 )
MULTIPOINT_AOA= ( 5.0, 8.0)
MULTIPOINT_TARGET_CL= ( 0.912, 1.255)
MULTIPOINT_REYNOLDS_NUMBER= ( 1.5E6, 2.54E6 )

Error Analysis:

  • The error suggests that during the evaluation of the multipoint function, SU2 is unable to find the key 'AIRFOIL_AREA' in the state["FUNCTIONS"] dictionary. This might be because the necessary airfoil area function or value isn't being computed or passed correctly when switching to multipoint mode.
  • I’ve tested the code for single-point optimization, and it works without issues. The problem only arises when attempting multipoint optimization.

Potential Fixes I’ve Tried:

  1. Ensured the mesh is well-defined and valid, and it works fine for single-point optimizations.
  2. Attempted different configurations of the multipoint optimization setup, including adjusting the Mach number, Reynolds number, and other parameters.
  3. Tried to define additional output functions for the multipoint optimization setup to ensure all necessary parameters are computed correctly.

Despite these efforts, the error persists, and I am unable to proceed with multipoint optimization.

Request: I would greatly appreciate any suggestions or recommendations on:

  • How to resolve this 'AIRFOIL_AREA' key error when running multipoint optimization.
  • Any adjustments to the configuration file or the multipoint optimization setup that I may have missed.
  • Possible fixes related to the calculation of airfoil area or additional parameters required for multipoint evaluation.

Thank you for your time and support. I look forward to your guidance on resolving this issue.

multiplepoint.zip

EngJamal2023 avatar Nov 12 '25 10:11 EngJamal2023

Along with the issue I mentioned in my previous message regarding the multipoint optimization in compressible flow using the SST turbulence model, I also have a follow-up question about the possibility of applying multipoint optimization for incompressible flow cases in SU2.

Additional Question:

In the current setup for compressible flow, I have defined Mach number in the multipoint optimization configuration. However, when working with incompressible flow, Mach number is not defined since it is irrelevant in incompressible flow simulations.

My question is: Is it possible to use multipoint optimization for incompressible flow, and if so, how would the setup change? Specifically, how would I modify the configuration file for incompressible flow optimization (i.e., using inlet velocity or other appropriate parameters) in place of the Mach number?

Request for Guidance:

  1. Multipoint Optimization for Incompressible Flow: Can I set up multipoint optimization for incompressible flows in SU2? If so, I would appreciate a brief explanation or example on how to define this for incompressible flow cases (perhaps using other parameters like inlet velocity or Reynolds number).

  2. Tutorial or Example Configuration: If you have any example tutorials, configurations, or sample meshes for incompressible multipoint optimization, either with a typical airfoil or any simple geometry, I would appreciate if you could share those resources. This would help me better understand the steps and avoid errors when transitioning between compressible and incompressible flow cases for multipoint optimization.

  3. Error Debugging: If there are any known issues or pitfalls when setting up multipoint optimization for both compressible and incompressible flow cases in SU2, I would greatly appreciate any recommendations or guidance to avoid the errors I’ve encountered.

I hope these clarifications and additional details will help you better understand the context of my problem and provide recommendations for moving forward. I look forward to your insights and support.

EngJamal2023 avatar Nov 12 '25 10:11 EngJamal2023

I do not use the built-in multipoint optimization, but there is an example for incompressible flow here: https://github.com/su2code/SU2/blob/master/TestCases/disc_adj_incomp_navierstokes/cylinder/heated_cylinder.cfg It still uses the Mach number keyword, I did not look at it in detail but I guess you just have to compute the Mach number from the velocities that you have in your incompressible setup and use that.

bigfooted avatar Nov 12 '25 10:11 bigfooted

I do not use the built-in multipoint optimization, but there is an example for incompressible flow here: https://github.com/su2code/SU2/blob/master/TestCases/disc_adj_incomp_navierstokes/cylinder/heated_cylinder.cfg It still uses the Mach number keyword, I did not look at it in detail but I guess you just have to compute the Mach number from the velocities that you have in your incompressible setup and use that.

Thank you very much for your fast reply. I appreciate your guidance. I followed the same approach and re-coded the setup, and it’s working now.

Regarding the compressible case I mentioned earlier, I am still getting an error when I run it. If possible, could you please share a similar tutorial or reference example for the compressible setup as well? It would really help me understand how to configure it correctly.

Thank you again for your support and helpful explanations.

EngJamal2023 avatar Nov 13 '25 09:11 EngJamal2023

My Question: Is there something I’m missing in the configuration for a compressible multipoint shape optimization with a geometry constraint? For single-point optimizations, I’ve used the thickness constraint without issues. In this multipoint case, do I need to enable or calculate the airfoil area explicitly to avoid the KeyError? For example:

Is there a known bug or limitation in SU2 when using geometry-based constraints (like thickness or area) in multipoint optimizations?

Do I need to add a specific option to compute AIRFOIL_AREA, or otherwise modify the constraint definition so that the code recognizes all necessary geometry functions? (I noticed the error only arises when a geometry constraint is present; purely aerodynamic constraints work fine.)

Request: If possible, could you please point me to a tutorial or example configuration for compressible multipoint optimization (especially one that includes a geometry constraint such as thickness or area)? The incompressible example you provided was very useful, and a similar example for a compressible case would help me debug this issue. Perhaps there's a test case (like an inviscid or RANS airfoil multipoint optimization) or some best-practice guidelines for setting up multipoint objectives with constraints.

EngJamal2023 avatar Nov 13 '25 10:11 EngJamal2023

I would just open the SU2 folder in vscode and search for keywords like MULTIPOINT and CONSTRAINT and see what is available. Maybe not that many actual testcases in the TestCases repository, but looking in the python files of the multipoint implementation gives an idea of what is available. The python files are also relatively easy to modify.

bigfooted avatar Nov 13 '25 17:11 bigfooted

Probably the best way to handle a multipoint optimisation is to construct the problem using an external python wrapper such as FADO and solve the individual points in SU2, rather than try and handle all the multi objs and constraints within SU2 natively. This is something I have done before, it also may be worthwhile to reformat your objective function using the penalty function method to reduce the computational cost of your problem. Further to this I have noticed that if your geometric constraint only depends on a small section of the geometry (think area through a con-di nozzle for example) it can be difficult to appropriately scale the sensitivities as the constraint effectively only depends on a small number of elements in the mesh.

joshkellyjak avatar Nov 14 '25 14:11 joshkellyjak

Probably the best way to handle a multipoint optimisation is to construct the problem using an external python wrapper such as FADO and solve the individual points in SU2, rather than try and handle all the multi objs and constraints within SU2 natively. This is something I have done before, it also may be worthwhile to reformat your objective function using the penalty function method to reduce the computational cost of your problem. Further to this I have noticed that if your geometric constraint only depends on a small section of the geometry (think area through a con-di nozzle for example) it can be difficult to appropriately scale the sensitivities as the constraint effectively only depends on a small number of elements in the mesh.

Thank you very much for your detailed explanation and helpful suggestions. I really appreciate your guidance regarding multipoint optimization and the use of an external Python wrapper such as FADO.

If possible, I would be very grateful if you could also share a sample configuration file together with the mesh that I can use as a reference for my case. I am working on airfoil shape optimization for both incompressible and compressible flows, and having an example would help me apply the correct setup and avoid errors.

Thank you again for all your support and cooperation. It is truly appreciated.

EngJamal2023 avatar Nov 15 '25 08:11 EngJamal2023

I tried to reproduce this on develop by calling SU2.eval.functions.multipoint with a state that already contains AIRFOIL_AREA from a geometry constraint (with the SU2 runs mocked), and it completes without the KeyError, also when the state is pickled and loaded again as the optimizer does. The line numbers in your traceback (functions.py 731 and 334) do not match SU2/eval/functions.py in any release from v7.0.0 to v8.5.0, so the installed scripts may be modified or come from a different version. Could you post the SU2 version you are using and check whether SU2/eval/functions.py was changed?

ManasBagul23 avatar Sep 16 '26 19:09 ManasBagul23