Adjoint Optimization

108 views
Skip to first unread message

Mike Novikov

unread,
Jan 18, 2026, 5:54:54 AM (10 days ago) Jan 18
to OpenVSP
I have a rect wing. Design variable: wingspan. I want to reduce CD.
I used that video to update .vspaero file
https://www.youtube.com/watch?v=SIQZ_AkxZoY
I attached 1.vspaero and log_file (log from the terminal)
There is no optimization file to update geometry yet.

But the problem that concerns me is that after 1st forward run and 1st adjoint, I got this in the log (I don't use CS at all):

Working on quad tree: 1
Direction, Value: 2 0.000000
Inserted: 3 points
Setting Optimization_Lambda_1_ for CL to: 0.000000
Setting Optimization_Lambda_2_ for CD to: 81.487528
Setting Optimization_Lambda_3_ for CS to: -nan(ind)
Setting Optimization_Lambda_4_ for CL to: 0.000000
Setting Optimization_Lambda_5_ for CM to: 0.000000
Setting Optimization_Lambda_6_ for CN to: 0.000000
WakeAngle_: 0.994522 -0.000000 0.104528
Xmax_ - Xmin_: 1.000000
Ymax_ - Ymin_: 12.000000
Zmax_ - Zmin_: 0.000000

The wake FarDist set to: 12.000000
Updating wake grids...
SigmaAvg_: nan
Creating interaction lists...

Could someone help me with this issue? Is it a big problem? At the second forward run, I got "nan" errors everywhere. 
It's also interesting to me to find out how and based on what values to update the design variable after the 1st adjoint run.
Sorry for such a big question.
1.vspaero

Lukman Kohler

unread,
Jan 19, 2026, 1:27:56 AM (9 days ago) Jan 19
to OpenVSP
I had a similar issue a while ago. its the OptimizationUsingWakeForces = 1 option that breaks things. I'm not sure exactly why, but I think it's because it tries to calculate derivative w.r.t. wake nodes, so if you are going to use that option you have to set the 
ImplicitWake flag to 1? If it was fixed wake, I think the derivatives would make sense since it linked to the geometry. Regardless, using the surface forces should fix it (I Think) 

Mike Novikov

unread,
Jan 19, 2026, 1:53:00 AM (9 days ago) Jan 19
to OpenVSP
To be honest, Lukman, I don't understand your answer. Could you please clarify? What should I use?
I used the setup from the video above, and it appears to work. Please check the attachment.


понедельник, 19 января 2026 г. в 10:27:56 UTC+4, Lukman Kohler:
opt1.JPG

Lukman Kohler

unread,
Jan 19, 2026, 7:11:29 AM (9 days ago) Jan 19
to OpenVSP
Hi sorry. I must admit I don't really know what I'm talking about when it comes to the "why." But after rereading your original question, I see a huge issue which might be causing your pain.

The optimization problem you have passed to the optimizer is not well posed. minimizing drag on a rectangular wing with only the span as the design variable will quickly shrink the span to zero. try minimizing drag using taper ratio for an outboard section as the design variable. If you get that working you can try twist or chord lengths in your .des file. 

But, the reason for my earlier message was a result of  my earlier struggles with vspaero_opt. I was passing the optimizer a well posed problem, but was getting NaNs on the first iteration (for side force just like you, even though it wasnt used). After arguing with ChatGPT I found that setting  OptimizationUsingWakeForces = 0 (instead of one) was the solution. However, I currently lack the insight to explain why this is the case. Hopefully Dr. McDonald can shed some light on this.
 But, my hunch is that it has to do with some denominator somewhere in the solver becoming zero because there is no wake developed yet. Regardless, I am 98% sure that trying to minimize drag of a hershey bar wing (rectangle)
using only span will converge to the zero-lift & zero-span solution.

Perhaps you can help me now with something I'm struggling with. Have you ever used -unsteady in the command line for vspaero? Im trying to do a case of a wing rolling about the x axis. I can see the wing rolling in the viewer, but there is no solution aerodynamics wise (nans for everything on the first iteration). I asked chat GPT, and it suggested that I should use -save and -restart, but those flags dont seem to be recognized by the program, yet my terminal log looks like this....


.
.
.

Setting NumberOfTimeSteps to: 100
Setting TimeStep_ to: 0.010000
Unknown option argv[1]: -save
VSPAERO v.7.2.2 --- Compiled on: Jan  5 2026 at 00:55:19 PST




Usage: vspaero [options] <FileName>


Options:
 -omp <N>                           Use 'N' processes.
 -stab                              Calculate stability derivatives.

 -pstab                             Calculate unsteady roll  rate stability derivative analysis.
 -qstab                             Calculate unsteady pitch rate stability derivative analysis.
 -rstab                             Calculate unsteady yaw   rate stability derivative analysis.

 -fs <M> END <A> END <B> END        Set/Override freestream Mach, Alpha, and Beta. note: M, A, and B are space delimited lists.
 -save                              Save restart file.
 -restart                           Restart analysis.
 -geom                              Process and write geometry without solving.
 -fem                               Load in FEM deformation file.
 -write2dfem                        Write out 2D FEM load file.
 -groundheight <H>                  Do ground effects analysis with cg set to <H> height above the ground.
 -rotor <RPM>                       Do a rotor analysis, with specified rotor RPM.
 -unsteady                          Run an unsteady analysis, assumes .groups file is setup!



 -interrogate                       Reload an existing solution, and interrogate the data using survey points list.
 -interrogate -unsteady             Reload an existing unsteady solution, and interrogate the data using survey points list.


Lukman Kohler

unread,
Jan 19, 2026, 7:11:38 AM (9 days ago) Jan 19
to OpenVSP
p.s. if you like i can give you a .des file and vspaero file that worked for me if you would like.

Mike Novikov

unread,
Jan 19, 2026, 8:01:04 AM (9 days ago) Jan 19
to OpenVSP
Sorry, I have no Idea about usteady.  However, if you are interested in props, you can try using the steady-state approach for rotation. Check the VSP installation folder (/vspaero_ex)
  * [Steady Rotating Frame](./Isolated_Rotor/Steady_Rotating_Frame/)
  * [Unsteady Rotating Blades](./Isolated_Rotor/Unsteady_Rotating_Blades/)

понедельник, 19 января 2026 г. в 16:11:29 UTC+4, Lukman Kohler:

Mike Novikov

unread,
Jan 19, 2026, 8:02:17 AM (9 days ago) Jan 19
to OpenVSP

It would help me a lot if it is possible!
понедельник, 19 января 2026 г. в 16:11:38 UTC+4, Lukman Kohler:

Mike Novikov

unread,
Jan 21, 2026, 9:57:40 AM (7 days ago) Jan 21
to OpenVSP
Lukman, just a gentle reminder!

понедельник, 19 января 2026 г. в 17:02:17 UTC+4, Mike Novikov:

Steven Zhu

unread,
Jan 21, 2026, 12:45:26 PM (7 days ago) Jan 21
to OpenVSP
Hi. I was trying to use optimization and adjoint function of vspaero, but I am strugging to run the case after watching the video you posted. 

I am using vsp 3.41.2, VSPAERO v.6.4.8 on windows and called vspaero in terminal. I created a vspaero file with simple straight wing without CS. I used 
vspaero -opt -optfunction 0 opttest_DegenGeom 

and it works all right. But when I run 
vspaero  -opt -adjoint   -optfunction 0 opttest_DegenGeom
I got nan results, like the following, and the calculation stops. 

SigmaAvg_: 0.025769
There are:          1 Vortex Sheets
Creating vortex sheet data...
There are:         40 kutta nodes for vortex sheet:          1
Done creating vortex sheet data...
NumberOfTimeSteps_: 1
TimeStep_: 1.000000
Time step: 1 of 1
        0   0.00100   1.00000   0.00000   0.00000   0.00000   0.00000   0.00000   0.00000   0.00000   0.00000   0.00000 -nan(ind)   0.00000   0.00000   0.00000   0.00000   0.00000   0.00000   0.00000
-nan(ind)   0.00000   0.00000   0.00000   0.00000   0.00000   0.00000   0.00000

Are we facing the similiar problem? Or I messed up the process? 
Also I noticed for vsp 3.46.0, the vspaero -opt -optfunction 0 doesn't seem to work. Which version are you using?

Thank you for your help. 

Best
Steven

Mike Novikov

unread,
Jan 23, 2026, 3:22:10 AM (5 days ago) Jan 23
to OpenVSP
Steven, thank you for your answer.
I use OpenVSP 3.46. 
I am starting VSPAero via cmd with
vspaero_opt 1
And I got the results that I showed before.


среда, 21 января 2026 г. в 21:45:26 UTC+4, Steven Zhu:
Reply all
Reply to author
Forward
0 new messages