mdolab / pygeo

pyGeo provides geometric design variables and constraints suitable for gradient-based optimization.
https://mdolab-pygeo.readthedocs-hosted.com/en/latest/?badge=latest
Apache License 2.0
122 stars 54 forks source link

issue using addLocalDV #222

Closed sarapuccia1 closed 11 months ago

sarapuccia1 commented 11 months ago

Hi, few days ago I have created an issue to understand how to fix some point of my FFD box since I want to optimize a morphing airfoil and I need to fix a "box" as a constrain. To do it I opted for geo_utils.PointSelect as following: `

FFDFile = "ffd.xyz"

DVGeo = DVGeometry(FFDFile)

MY MODIFICATION

pts= DVGeo.getLocalIndex(0)

indexList = pts[:,:,:].flatten() #all the FFD nodes of the box pre-defined

fixed = [] for i in np.array([2,7]): for j in np.array([0,1]): for k in np.array([0,1]):

for visualization purposes

      fixed.append(DVGeo.getLocalIndex(0)[i, j, k])

moved = [ix for ix in indexList if ix not in fixed]

PS_fixed = geo_utils.PointSelect('list', fixed) PS_moved = geo_utils.PointSelect('list', moved) PS_total = geo_utils.PointSelect('list', indexList)

DVGeo.addLocalDV("shape", lower=-0.05, upper=0.05, axis="y", scale=1.0, pointSelect = PS_moved)

DVGeo.addLocalDV("fix", lower=1, upper=1, axis = 'y', scale=1.0, pointSelect = PS_fixed)`

Than I added the same constraints of the airfoil optimization tutorial https://mdolab-mach-aero.readthedocs-hosted.com/en/latest/machAeroTutorials/airfoilopt_singlepoint.html Therefore I run the code but it return the following error:

------------------------------------------------------------------------------+ | pyOptSparse Error: The 'lower' argument to addCon or addConGroup is | | invalid. It must be None, a scalar, or a list/array or length nCon=16. | +------------------------------------------------------------------------------+

In my opinion the error is in the definition of addLocalDV. How can I fix it?

gawng commented 11 months ago

Try changing 1 to 1.0.I think this is a dataType error message.

sarapuccia1 commented 11 months ago

Nope, unfortunately it returns the same error. maybe I cannot split the FFD points?

gawng commented 11 months ago

Hm, I see. Another alternative is dont add thosefixed ffds as a variable to begin with. If it is not in the problem, then it wouldnt need to be constrained

sarapuccia1 commented 11 months ago

Hi I tried to do it differently. I attached the zip file with the code and the plot of the aerofoil deformed and undeformed.

when I plot the aerofoil the FFD points that should be fixed are still moved of an offset and I'm not able to understand why. I used the method of:

  1. getValues()
  2. setDesignVariables
  3. update The plot of the aerofoil is the following deformed_aerofoil

aerofoil_parameterization.zip

Is there something wrong in the code?

gawng commented 11 months ago

Please see my previous suggestion of not adding the FFDs you want fixed. Did that work?

Also, I will not look at your hyperlinked code for security reasons.

sarapuccia1 commented 11 months ago

I totally managed the problem. Thanks all of you

r-quadros commented 10 months ago

@sarapuccia1 Can you please tell me how did you manage this problem? I am facing the same issue but unable to resolve it

S5331107 commented 9 months ago

@sarapuccia1 Could you please share the steps you did to manage the problem? Thanks