CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   SU2 Shape Design (https://www.cfd-online.com/Forums/su2-shape-design/)
-   -   KeyError for OPT_OBJECTIVE option (https://www.cfd-online.com/Forums/su2-shape-design/224984-keyerror-opt_objective-option.html)

Nicoruiz March 10, 2020 13:45

KeyError for OPT_OBJECTIVE option
 
1 Attachment(s)
Hi everyone,

I am working on the shape optimization of a cooling channel using SU2 v.7.0.2.
The flow studied is a steady incompressible turbulent water flow.

For the optimization, I use a 3D FFD box for the design variables, and a weigthed sum for the objective function with the options SURFACE_TOTAL_PRESSURE and TOTAL_HEATFLUX.

Code:

% ---------------- ADJOINT-FLOW NUMERICAL METHOD DEFINITION -------------------%
%
% Convective numerical method (JST, LAX-FRIEDRICH, ROE)
CONV_NUM_METHOD_ADJFLOW= ROE
%
% Monotonic Upwind Scheme for Conservation Laws (TVD) in the adjoint flow equations.
%          Required for 2nd order upwind schemes (NO, YES)
MUSCL_ADJFLOW= YES
%
% Slope limiter (NONE, VENKATAKRISHNAN, BARTH_JESPERSEN, VAN_ALBADA_EDGE,
%                SHARP_EDGES, WALL_DISTANCE)
SLOPE_LIMITER_ADJFLOW= NONE
%
% 2nd, and 4th order artificial dissipation coefficients
ADJ_JST_SENSOR_COEFF= ( 0.5, 0.02 )
%
% Time discretization (RUNGE-KUTTA_EXPLICIT, EULER_IMPLICIT)
TIME_DISCRE_ADJFLOW= EULER_IMPLICIT
%
% Relaxation coefficient
RELAXATION_FACTOR_ADJFLOW= 1.0
%
% Reduction factor of the CFL coefficient in the adjoint problem
CFL_REDUCTION_ADJFLOW= 0.8
%
% Limit value for the adjoint variable
LIMIT_ADJFLOW= 1E15
%
% Multigrid adjoint problem (NO, YES)
MG_ADJFLOW= NO
%
% Objective function in gradient evaluation  (DRAG, LIFT, SIDEFORCE, MOMENT_X, MOMENT_Y, MOMENT_Z, EFFICIENCY, EQUIVALENT_AREA, NEARFIELD_PRESSURE, FORCE_X, FORCE_Y, FORCE_Z, THRUST, TORQUE, FREE_SURFACE,                                                      TOTAL_HEATFLUX, MAXIMUM_HEATFLUX, INVERSE_DESIGN_PRESSURE, INVERSE_DESIGN_HEATFLUX, SURFACE_TOTAL_PRESSURE,  SURFACE_MASSFLOW)
% For a weighted sum of objectives: separate by commas, add OBJECTIVE_WEIGHT and MARKER_MONITORING in matching order.
OBJECTIVE_FUNCTION = SURFACE_TOTAL_PRESSURE, TOTAL_HEATFLUX
%
% List of weighting values when using more than one OBJECTIVE_FUNCTION. Separate by commas and match with MARKER_MONITORING.
OBJECTIVE_WEIGHT= 0.5,0.5
%
% Marker(s) of the surface where the functional (Cd, Cl, etc.) will be evaluated
MARKER_MONITORING= (OUTLET, INTERFACE_WJ_HOUSING)
%
% Marker on which to track one-dimensionalized quantities
MARKER_ANALYZE  = (OUTLET)
%
% Method to compute the average value in MARKER_ANALYZE (AREA, MASSFLUX).
MARKER_ANALYZE_AVERAGE = AREA
%
%
%
% --------------------- OPTIMAL SHAPE DESIGN DEFINITION -----------------------%
%
% Optimization objective function with scaling factor, separated by semicolons.
% To include quadratic penalty function: use OPT_CONSTRAINT option syntax within the OPT_OBJECTIVE list.
% ex= Objective * Scale
OPT_OBJECTIVE= SURFACE_TOTAL_PRESSURE; TOTAL_HEATFLUX
%
% Use combined objective within gradient evaluation: may reduce cost to compute gradients when using the adjoint formulation.
OPT_COMBINE_OBJECTIVE = YES
%
% Optimization constraint functions with scaling factors, separated by semicolons : ex= (Objective = Value ) * Scale, use '>','<','='
OPT_CONSTRAINT= NONE
%
% Factor to reduce the norm of the gradient (affects the objective function and gradient in the python scripts)
% In general, a norm of the gradient ~1E-6 is desired.
OPT_GRADIENT_FACTOR= 1E-5
%
% Factor to relax or accelerate the optimizer convergence (affects the line search in SU2_DEF)
% In general, surface deformations of 0.01'' or 0.0001m are desirable
OPT_RELAX_FACTOR= 1E3
%
% Maximum number of iterations
OPT_ITERATIONS= 100
%
% Requested accuracy
OPT_ACCURACY= 1E-10
%
% Upper bound for each design variable
OPT_BOUND_UPPER= 1000
%
% Lower bound for each design variable
OPT_BOUND_LOWER= -1000
%
% Optimization design variables, separated by semicolons
DEFINITION_DV= ( 11, 1.0 | INTERFACE_WJ_HOUSING | BOX, 0, 0, 0, 1.0, 0.0, 0.0 ); ......

But when I try to run the simulation using shape_optimization.py, I get the following error :
Code:

Traceback (most recent call last):
  File "/app/su2/7.0.2/bin/shape_optimization.py", line 166, in <module>
    main()
  File "/app/su2/7.0.2/bin/shape_optimization.py", line 98, in main
    options.nzones      )
  File "/app/su2/7.0.2/bin/shape_optimization.py", line 138, in shape_optimization
    project = SU2.opt.Project(config,state)
  File "/app/su2/7.0.2/bin/SU2/opt/project.py", line 129, in __init__
    group = historyOutFields[this_obj]['GROUP']
KeyError: 'SURFACE_TOTAL_PRESSURE'


I also have the same error with the files from the tutorial "Shape Design With Multiple Objectives and Penalty Functions" in which OPT_OBJECTIVE=SURFACE_TOTAL_PRESSURE*-1E-4; (DRAG = 0.05)*1E6.

It seems like SURFACE_TOTAL_PRESSURE and TOTAL_HEATFLUX are not defined for OPT_OBJECTIVE, because when I try with DRAG for instance, I don't have this error.

Does anyone have an idea on how to solve this problem ?

You can find my configuration file attached.

Thanks,
Nicolas.

aman_baig March 20, 2020 20:49

I have an issue open on GitHub for the same reason. I am looking into it currently.
https://github.com/su2code/SU2/issues/889

oklf April 21, 2020 10:43

Hi,
I had the same problem, and I finally found what the issue was. See here.

Umuteng March 4, 2021 15:53

Were u able to solve?.I am having same problem for SURFACE_TOTAL_PRESSURE, could not solve it yet.


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