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/)
-   -   Error in Tutorial-Optimal Shape Design of a Fixed Wing (https://www.cfd-online.com/Forums/su2-shape-design/112157-error-tutorial-optimal-shape-design-fixed-wing.html)

cfdbooks2008 January 23, 2013 01:42

Error in Tutorial-Optimal Shape Design of a Fixed Wing
 
I have installed the serial source version of SU2 on Ubuntu 12.10(64bit) and tried to run the Tutorial-Optimal Shape Design of a Fixed Wing. I tried the following steps:

$ SU2_MDC inv_ONERAM6.cfg
$ mv mesh_out.su2 mesh_ONERAM6_inv_FFD.su2
change the name of the mesh input file in inv_ONERAM6.cfg
instead of MESH_FILENAME= mesh_ONERAM6_inv.su2
use MESH_FILENAME= mesh_ONERAM6_inv_FFD.su2
$ python shape_optimization.py -f inv_ONERAM6.cfg


Iter Time(s) Res[Rho] Res[RhoE] CLift(Total) CDrag(Total)
100 11.104851 -4.086491 -3.563917 0.285536 0.012296
101 11.098431 -4.098954 -3.568896 0.285536 0.012296
102 11.092136 -4.109356 -3.567447 0.285536 0.012296

------------------------- Exit Success (SU2_CFD) ------------------------

Traceback (most recent call last):
File "shape_optimization.py", line 676, in <module>
acc=1e-12, iprint=2, full_output=1, epsilon=1.0e-10)
File "/usr/lib/python2.7/dist-packages/scipy/optimize/slsqp.py", line 319, in fmin_slsqp
g = append(fprime(x),0.0)
File "/usr/lib/python2.7/dist-packages/scipy/optimize/optimize.py", line 176, in function_wrapper
return function(x, *args)
File "shape_optimization.py", line 319, in df
for key,value in Gradient_Dict.iteritems():
UnboundLocalError: local variable 'Gradient_Dict' referenced before assignment

After running SU2_CFD, the procedure stopped. It seems something wrong in shape_optimization.py. I'm sorry I don't know python. Could anybody help me? Thanks in advance.

fpalacios January 27, 2013 19:44

Hi,
Could you please tell us what it the version of the Python, Numpy and SciPy that you are using?

Just in case, could you please also post the config file that you are using and the shape_optimization.py (we have different version of this script), and a file with all the screen output.

Best,
Francisco

cfdbooks2008 January 27, 2013 22:34

1 Attachment(s)
Quote:

Originally Posted by fpalacios (Post 404405)
Hi,
Could you please tell us what it the version of the Python, Numpy and SciPy that you are using?

Just in case, could you please also post the config file that you are using and the shape_optimization.py (we have different version of this script), and a file with all the screen output.

Best,
Francisco

Dear Francisco,
Thank you for your reply. The version of the Python is 2.7.3, Numpy is 1.6.2 and SciPy is 0.10.1+dfsg1-4. All these packages were installed using "sudo apt-get install" command. The files you need are in the attachment.

Regards!

rktchip January 28, 2013 02:04

Hello,

Have you set your SU2_HOME and SU2_RUN variables? (an example here)

Thanks!
- Trent

cfdbooks2008 January 28, 2013 02:28

Quote:

Originally Posted by rktchip (Post 404437)
Hello,

Have you set your SU2_HOME and SU2_RUN variables? (an example here)

Thanks!
- Trent

Yes. I have set the SU2_HOME and SU2_RUN variables as required.

rktchip January 28, 2013 14:48

In you config file it looks like you set RESTART_SOL = YES. This assumes that you have all preconverged solutions for your problem. For shape_optimization.py, this means you need a direct solution file (solution_flow.dat) and adjoint solution files (solution_adj_*.dat) for each objective and constraint function (drag and lift in this case).

So could you try to set RESTART_SOL=NO and make sure it works in this simpler case?

If this still doesn't work please upload the full and verbose command line output one more time and we'll keep sorting it out.

Thanks,
-Trent

cfdbooks2008 January 29, 2013 00:45

1 Attachment(s)
Quote:

Originally Posted by rktchip (Post 404606)
In you config file it looks like you set RESTART_SOL = YES. This assumes that you have all preconverged solutions for your problem. For shape_optimization.py, this means you need a direct solution file (solution_flow.dat) and adjoint solution files (solution_adj_*.dat) for each objective and constraint function (drag and lift in this case).

So could you try to set RESTART_SOL=NO and make sure it works in this simpler case?

If this still doesn't work please upload the full and verbose command line output one more time and we'll keep sorting it out.

Thanks,
-Trent

Dear Trent

It still doesn't work. I tried the following steps:

$ SU2_MDC inv_ONERAM6.cfg
$ mv mesh_out.su2 mesh_ONERAM6_inv_FFD.su2
change the name of the mesh input file in inv_ONERAM6.cfg
instead of MESH_FILENAME= mesh_ONERAM6_inv.su2
use MESH_FILENAME= mesh_ONERAM6_inv_FFD.su2
$ python shape_optimization.py -f inv_ONERAM6.cfg -g 1.0

The files you need are in the attachment.
Thanks.

rktchip January 29, 2013 03:24

For shape_optimization.py, the option -g takes either 'Adjoint' or 'FinDiff'. I think you might mean -p 1 since you are running it in serial. Try running this command -

python shape_optimization.py -f inv_ONERAM6.cfg -p 1

Best,
-Trent

cfdbooks2008 January 29, 2013 06:23

Quote:

Originally Posted by rktchip (Post 404720)
For shape_optimization.py, the option -g takes either 'Adjoint' or 'FinDiff'. I think you might mean -p 1 since you are running it in serial. Try running this command -

python shape_optimization.py -f inv_ONERAM6.cfg -p 1

Best,
-Trent

-g GRADIENT SCALE,- g 1.0 means GRADIENT SCALE is 1.0. The tutorial uses the same command. I will try your command later and tell you the result. Thanks.

cfdbooks2008 January 29, 2013 09:05

Hi, Trent,
The command( python shape_optimization.py -f inv_ONERAM6.cfg -p 1) worked. Thanks. Whether shoud I chage the item MATH_PROBLE from DIRECT to ADJOINT for this case?

rktchip January 29, 2013 09:10

great! i'm not sure where there was a gradient scale setting, but you can always check the python script inputs by asking for option -h

shape_optimization.py will take care of setting the mathproblem for you and it won't matter what it's set at before you start.

regards,
-trent

edit: ah -g was an old option we phased out. the tutorial has changed since to reflect this.


All times are GMT -4. The time now is 19:52.