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

FIXED FFD POINTS FOR AN OPTIMIZATION #220

Closed sarapuccia1 closed 11 months ago

sarapuccia1 commented 11 months ago

Hi, I would like to use pygeo for the parameterization of my geometry which is an airfoil. My optimization problem is optimizing a morphing airfoil vertically but I need to put a local contraints on 4 FFD point of my box and impose that they will not move during the optimization. Is it possible do it with pygeo? Searching in the documentation I have not understand if there is a DVconstraints that adress this requirment

Thanks in advanced

sseraj commented 11 months ago

Yes, this is possible using the pointSelect argument in addLocalDV. Please see the documentation here: https://mdolab-pygeo.readthedocs-hosted.com/en/latest/DVGeometry.html#pygeo.parameterization.DVGeo.DVGeometry.addLocalDV

sarapuccia1 commented 11 months ago

Thaks for the answer. Just a quick detail. I understand that I need to put the coordinates of the variable in get.utils.PointSelect. I have already created the FFD box as it is suggested in the tutorial file https://mdolab-mach-aero.readthedocs-hosted.com/en/latest/machAeroTutorials/airfoilopt_ffd.html. To call for example if I want to call specific coordinate of the FFD box how can I do it? For now I have done like this but it returns the error below

  PS = geo_utils.PointSelect(type = 'y', pt1= [2.21666667e-01, -9.85961709e-02,  0.00000000e+00], pt2= [2.21666667e-01,  9.85961683e-02,  0.00000000e+00])

TypeError: __init__() missing 1 required positional argument: 'psType'
sseraj commented 11 months ago

That example is outdated, unfortunately. Use psType instead of type. Here are the PointSelect docs that describe the different ways of selecting points: https://github.com/mdolab/pygeo/blob/6908fd341937da193d239e45f091a76866fbd332/pygeo/geo_utils/pointselect.py#L6-L39

sarapuccia1 commented 11 months ago
# ======================================================================

#         Geometric Design Variable Set-up

# ======================================================================

# rst dvgeo (beg)

# Create DVGeometry object

FFDFile = "ffd.xyz"

DVGeo = DVGeometry(FFDFile)

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

PS = geo_utils.PointSelect(psType = 'y', pt1= [2.21666667e-01, -9.85961709e-02,  0.00000000e+00], pt2= [2.21666667e-01,  9.85961683e-02,  0.00000000e+00])

nVar = DVGeo.addLocalDV('shape_vars', lower=0, upper=0, pointSelect=PS)

` This is an example of how I tried to implement the constrain. Is it correct? For pt1 and pt2 I have considered the specific coordinates of the ffd box along the same x coordinate and on the same surface since I'm dealing with an extruded airfoil. I count to do the same for other 3 x coordinate in order to have a fixed box

gawng commented 11 months ago

continued in #222