Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cp, cf, x, y arrays in the available functions for optimization #25

Open
lucaerosBGD opened this issue Nov 9, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@lucaerosBGD
Copy link

Description of feature

Add the following slice data in the available function for optimization :
# "cp_visc_upper": viscous CP on the airfoil's upper surface
# "cp_invisc_upper": inviscid CP on the airfoil's upper surface
# "x_upper": x coordinates of the upper surface CP data
# "y_upper": y coordinates of the upper surface CP data
# "cp_visc_lower": viscous CP on the airfoil's lower surface
# "cp_invisc_lower": inviscid CP on the airfoil's lower surface
# "x_lower": x coordinates of the lower surface CP data
# "y_lower": y coordinates of the lower surface CP data
# "cf_upper": skin friction coefficient on the upper surface
# "x_cf_upper": x coordinates of upper surface skin friction coefficient
# "y_cf_upper": y coordinates of upper surface skin friction coefficient
# "cf_lower": skin friction coefficient on the lower surface
# "x_cf_lower": x coordinates of lower surface skin friction coefficient
# "y_cf_lower": y coordinates of lower surface skin friction coefficient
Thus we could optimize and constraint parameters available in this list (max pressure gradients for example)

Potential solution

@eytanadler eytanadler added the enhancement New feature or request label Nov 9, 2023
@A-CGray A-CGray added the good first issue Good for newcomers label Nov 9, 2023
@A-CGray
Copy link
Member

A-CGray commented Nov 9, 2023

Hey @lucaerosBGD , this shouldn't be too hard to add, you just need to return the values from the real/complex slice data dictionaries in the same way we already do from the real/complex funcs dictionaries,

Here's where we do that in the function evaluation:

for f in evalFuncs:
# If it's not in the list of available functions
if f not in self.functionList:
# Either throw an error (if requested) or skip it
if not ignoreMissing:
raise ValueError(f'Supplied function "{f}" is not in the available functions {self.functionList}.')
else:
returnFuncs[aeroProblem.name + "_" + f] = self.funcs[aeroProblem.name][f]
funcs.update(returnFuncs)

And here's where we do that in the derivative calculation:

self.__call__(self.curAP, useComplex=mode == "CS", deriv=True)
# Compute the Jacobian vector products
jacVecProd = {}
for f in self.functionList:
if mode == "FD":
jacVecProd[f] = (self.funcs[self.curAP.name][f] - orig_funcs[f]) / h
else:
jacVecProd[f] = np.imag(self.funcsComplex[self.curAP.name][f]) / np.imag(h)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants