Problem with restart solution in shape_optimization.py
1 Attachment(s)
Hello SU2 developers,
I'm trying to perform a NACA0012 subsonic constrained shape optimization. I performed direct and two adjoint (the first with J=DRAG, the second with J=LIFT) simulations. My objective function is DRAG and the constraint is on the LIFT force. My problem arises when I execute shape_optimization.py with restart solutions, everything seems to be ok, but, when the second adjoint simulation starts (the one on the LIFT), the solver can't reach the solution and residuals go to infinity, although the solution_adj_cl comes from a converged solution. Actually I used the same convergence criteria for all the three simulations (CAUCHY with CAUCHY_EPS=1E6). If I instead execute SU2_CFD with MATH_PROBLEM= ADJOINT and the same restart solution, the required convergence is reached. I attach below the configuration file and the two log files. Cheers, Roberto 
Dear Roberto,
Could you please provide your mesh as well as your restart files for this case? Regards, Aniket 
Thank you for the reply.
Here the mesh and restart files: https://dl.dropboxusercontent.com/u/...26solution.zip 
I tried to perform shape optimization without restart, but the tool takes a lot of time in executing SU2_MDC (1000 min); it seems that a first deformation is executed, but the direct simulation doesn't converge. Then another deformation starts, but it doesn't converge. Maybe there is something wrong with the scale factor of objective function, but I don't understand how to set that value. Here is the log file: https://dl.dropboxusercontent.com/u/...logSU2v2.0.txt
I also downloaded and compiled SU2v2.0.3; with the new version of the code, the shape optimization seems to stop after the first adjoint simulation with this error: Code:
Traceback (most recent call last): Best regards, Roberto 
Hi Roberto,
The mesh deformation procedure should not take this long. Could you please visualize the deformation by setting the option VISUALIZE_DEFORMATION in your config file to YES? Regards, Aniket 
Hi Roberto,
I'm having trouble running your configuration file, and it seems strange that you are able to run this config with 2.0.3. It looks like the optimization options need to be updated, please see this post  here also, i'm not able to run su2_ddc without adding a MARKER_EULER= (AIRFOIL). i think this is a bug we need to work out yet. i'm sure this is unlikely the issue, but just in case, can you please confirm that your path and environment variables point to the new version? finally, one thing to note in 2.0.3 is to use restarts for an optimization you should set RESTART_SOL=YES in the config file. lots of things to try out, maybe one will stick? best, trent 
@aniketaranake:
Quote:
@rktchip: Quote:
Quote:
Quote:
Quote:

Hi Roberto,
So it sounds like you've run a couple different scenarios in different versions, but the core problem you're facing is that the adjoint problem for a subsonic pseudoincompressible turbulent naca0012 is not converging, correct? please keep in mind that the subsonic pseudoincompressible turbulent problem you're exploring is very much outside of the original intent of that test case, which is very cool! But that might mean some solver development will be needed in this area. At any rate, would you please test/comment on this troubleshooting tree with 2.0.3? no need to rerun a step you've already done of course. we'll know where to look based on which of these fail. 1. naca 0012 standard test case optimization (euler, transonic) 2. one naca 0012 turbulent evaluation with parallel_computation 3. naca0012 turbulent optimization with small number of external iterations (this is to test the the optimization framework is behaving) 4. your optimization test case. thanks,  trent 
Hi trent,
thank you for the reply. The adjoint solution seems to be ok either with drag or lift objective function. The problem is the shape optimization that, with the 2.0.3 version, stops with the error posted above. However I am setting the "troubleshooting tree". 1. I have to use the same config file in test cases on my mesh and I run it in serial, is it right? 2. Should this case be transonic or subsonic? I already have some results in subsonic Mach range: https://dl.dropboxusercontent.com/u/...bsonicTurb.zip 3. What do you mean for small number of external iterations? Is it the maximum number of iteration of the optimization? Best regards, Roberto 
Hi Roberto,
Great. As you mentioned parallel will be much faster, so I would try to sort out why that isn't working first (which may be another thread in itself). Your config will be the same for steps 24, but not for step 1, which you should get from the original naca0012 euler test case. small number of iterations is a trick we use to test that the optimizer is working. you can set EXT_ITER=9 for example. this separates out the solver in some sense. So if you see that it works with small number of iterations, but fails when fully converging the solution, that tells you something. we can explore this when you get your results. sorry there isn't an easy answer for this one. this troubleshooting is basically what i would be doing, but unfortunately i'm in the middle of writing a paper, so i only have time to guide you through finding the solution. best,  trent 
I am facing some troubles with adjoint euler on my NACA0012 mesh. The file configuration is the same in your test cases.
Concerning about my case, the problem is not related to parallel (actually with the version 2.0.3 it seems to be ok because the test case on cylinder converges, differently from version 2.0), but with shape optimization. The error (also posted above) is: Code:
Traceback (most recent call last): However I am also working to make euler adjoint converge. Quote:
@Aniket: shape optimization stops during SU2_MDC, as you requested I set to YES the option VISUALIZE_DEFORMATION. Do you need deformed_surface_grid.vtk and deformed_volumetric_grid.vtk? files are here: https://dl.dropboxusercontent.com/u/...etric_grid.vtk https://dl.dropboxusercontent.com/u/...rface_grid.vtk But the mesh doesn't seem to be deformed. 
do you get this error when you run continuous_adjoint.py?
trent 
No, I don't. It runs without any problem.
Roberto 
strange. so let me make sure i'm synced with your status  you've compiled serially correct? with autoconf? and for the naca0012 test case shape optimization fails on the first iteration with restart?
if you're running serially, can you try using a p 0 (zero) option for shape optimization. it this doesnt work, please zip up the design folder that fails and post it. thanks dude,  trent 
5 Attachment(s)
I'll try to explain my situation more clearly.
Using version 2.0 of the software, direct and adjoint simulations converge. The next step would be shape optimization, but python routine stops during mesh deformation (after 1000 mins it doesn't converge). Remind that I can't use parallel computation because the cylinder test case gives different results if run in parallel or serial, therefore I discarded parallel computation. The restart of the solution with shape optimization is also a problem, actually adjoint simulation starts but it diverges after some tens of iterations (while if I run SU2_CFD from a previous solution it converges without any problem). Concerning version 2.0.3, parallel seems to work, but problems with restart solution remain. Recently I faced with the error posted above. Today I discovered that it is related to the way SU2_CFD save data in history.csv (or .plt); actually in column 11, related to Res_AdjTurb[0], there is a symbol (as you can see from picture attached below). I solved the problem adding these lines in tools.py after line 114: Code:
for i,x in enumerate(line_data): Code:
!!! Error: NaNs detected in solution. Now exiting... !!! Concerning the troubleshooting tree, I get the same error in step number 3, for which I set EXT_ITER= 9. 
Hi Roberto,
It does indeed look like your problem involves the mesh deformation (at least this is the first issue :) ). Before attempting any optimization, can you please try running SU2_MDC with your mesh and the following options: % Grid deformation technique (SPRING, TORSIONAL_SPRING, ALGEBRAIC) GRID_DEFORM_METHOD= TORSIONAL_SPRING % % Maximum error in the grid deformation GRID_DEFORM_ERROR= 1E10 It looks like you are using a structured mesh, and we have found that the torsional spring method works a little better in this situation. Lowering the error tolerance should also help a little too with convergence. Once you have a deformed mesh, please check that the deformation was successful (no inverted cells, should be a smooth deformation near the airfoil) and try to run a simulation with the new mesh to make sure there are no quality issues. Hope this helps! Tom 
3 Attachment(s)
Thank you Tom for the reply.
I followed your advice. Now, with torsional spring method, the deformation is more regular near the profile; surface and mesh have been deformed using SU2_MDC with the following options: DV_KIND= HICKS_HENNE DV_PARAM= (1, 0.05) DV_VALUE_NEW= 0.0001 The deformation is good and there aren't topology errors, direct simulation also converges. Unfortunately, when I simulate the flow around the airfoil deformed following shape sensitivity, calculated by adjoint method, I am not able to reach convergence. @trent: About point 1 of troubleshooting: Direct simulation, as you can see from figures, converges without any problem. However I have problem involving adjoint, actually Residuals diverge. Configuration file is attached below, while the mesh is the same of some post before (post number 425040) 
@trent
Concernin point 3  naca0012 turbulent optimization with small number of external iterations (this is to test the the optimization framework is behaving)  this is the history.plt after 12 iterations (DRAG is the function to minimize): VARIABLES="EVALUATION","LIFT","DRAG","SIDEFORCE"," MOMENT_X","MOMENT_Y","MOMENT_Z","FORCE_X","FORCE_Y ","FORCE_Z","EFFICIENCY","DIRECT","ADJOINT_DRAG"," ADJOINT_LIFT" 1, 1.0829666056, 0.0141155287, 0.0, 0.0, 0.0, 0.0325941642, 0.1741540955, 1.0689650453, 0.0, 76.7216468778, 8.0, 8.0, 8.0 2, 1.0834360561, 0.0145389486, 0.0, 0.0, 0.0, 0.0332726955, 0.1738186274, 1.0695008899, 0.0, 74.5195600929, 8.0, 0.0, 0.0 3, 1.0835383216, 0.0144136617, 0.0, 0.0, 0.0, 0.0334454807, 0.1739597692, 1.0695798459, 0.0, 75.1743968871, 8.0, 0.0, 0.0 4, 1.0835485479, 0.0144011433, 0.0, 0.0, 0.0, 0.0334627603, 0.1739738732, 1.0695877431, 0.0, 75.2404533776, 8.0, 0.0, 0.0 5, 1.0835495706, 0.0143998915, 0.0, 0.0, 0.0, 0.0334644883, 0.1739752835, 1.0695885328, 0.0, 75.2470648046, 8.0, 0.0, 0.0 6, 1.0835496728, 0.0143997663, 0.0, 0.0, 0.0, 0.0334646611, 0.1739754246, 1.0695886118, 0.0, 75.2477260051, 8.0, 0.0, 0.0 7, 1.0835496831, 0.0143997538, 0.0, 0.0, 0.0, 0.0334646783, 0.1739754387, 1.0695886197, 0.0, 75.2477921257, 8.0, 0.0, 0.0 8, 1.0835496841, 0.0143997526, 0.0, 0.0, 0.0, 0.0334646801, 0.1739754401, 1.0695886204, 0.0, 75.2477987377, 8.0, 0.0, 0.0 9, 1.0835496842, 0.0143997525, 0.0, 0.0, 0.0, 0.0334646802, 0.1739754402, 1.0695886205, 0.0, 75.247799399, 8.0, 0.0, 0.0 10, 1.0835496842, 0.0143997524, 0.0, 0.0, 0.0, 0.0334646803, 0.1739754402, 1.0695886205, 0.0, 75.2477994653, 8.0, 0.0, 0.0 11, 1.0835496842, 0.0143997524, 0.0, 0.0, 0.0, 0.0334646803, 0.1739754402, 1.0695886205, 0.0, 75.2477994717, 8.0, 0.0, 0.0 12, 1.0835496842, 0.0143997524, 0.0, 0.0, 0.0, 0.0334646803, 0.1739754402, 1.0695886205, 0.0, 75.2477994724, 8.0, 0.0, 0.0 The number of external iterations is 9 and optimization started from a converged solution. 
Hey Roberto,
Great, it looks like you're making some progress. If you've been able to run the naca0012 euler optimization then we can say the optimization framework is working for you. (this is nice for me to hear because it's still a it new) the adjoint is indeed a tricky thing to simulate for this case, but i believe the new version has been updated to address this. so see if you could try to run an adjoint solution with 2.0.4  trent 
Thank you Trent.
Problems concerning shape optimization are related to adjoint solutions, actually I think that shape sensitivities are wrong. I compiled the new SU2v2.0.4, but MARKER_NS is no more defined in SU2_CFD code. Have you changed the syntax to impose NavierStokes wall conditions? Best regards. 
All times are GMT 4. The time now is 00:23. 