Add possibility to constraint the aspect ratio
For non planar wing configurations (arc wing for example), if one tries to optimize the twist, the optimizer will converge to a wing geometry where the AR is higher than the baseline. Is it possible to add a constraint on the AR so that the optimizer optimizes the twist distribution while keeping the aspect ratio constant ? Also, is it possible to add a constraint on the projected span and/or span ?
Following plots : Result of a twist optimization on arc wing at constant Cl and evolution of the AR throughout the iterations. In this case, the Cd is reduced due to the increase of the AR and not because the twist distribution is optimized.


Aspect ratio is not computed for the meshes. However, you can certainly compute it with existing quantities in the model by making an OpenMDAO component and use the result as a constraint in the optimization.
To do this, create a new OpenMDAO ExplicitComponent that takes in the mesh and the wing area and outputs aspect ratio. The span can be extracted from the mesh as (the absolute value of) the y-coordinate at the tip of the wing multiplied by 2 (assuming the wing is symmetrical). If your mesh is set up the same way as the CRM example, the y-coordinate of the leading edge at the left wingtip is at index [0, 0, 1] (you'll have to take the absolute value since the left wing has negative y values). Then compute the aspect ratio with the span squared divided by the wing area. For the best results, declare your partial derivatives for this new component analytically. Instead of taking in the whole mesh and extracting the single value, it would also probably be easier to just take in the y-coordinate at the wing tip as the span using src_indices option in OpenMDAO's connect function.
If your model is set up the same way as the CRM aerodynamic example, you can find the mesh as the "wing.mesh" variable, and the computed wing area as "aero_point_0.wing.S_ref". Connect these two variables to your new aspect ratio component and you have an output value you can use as an aspect ratio constraint in your optimization!
Note that if you want the aspect ratio properly computed with the projected wing area (as opposed to the wetted wing area) you'll need to ensure that the "S_ref_type" key in the surface dictionary is set to "projected" and not "wetted".
All considered, the optimizer's choice to increase the effective aspect ratio by adjusting twist may be a reasonable result. Constraining the aspect ratio may limit the design space more than is necessary. Obviously I don't know much about your problem, so you'll have to decide for your application.
Hope this helps!