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
131 stars 55 forks source link

Sensitivities discrepancies with `rotType=7` #74

Open marcomangano opened 3 years ago

marcomangano commented 3 years ago

Description

In some corner parametrization cases we have observed that when swtiching to rotType=7 (instead of using rotType=0), the total derivatives become unusable, despite the geometry deformations being consistent and the FD test showing negligible changes in value.

Posting to make the user base aware of potential issues with this setting, I apologize for posting such a general statement here.

Steps to reproduce issue

This is actually the hardest part of the issue.. this has been only observed on some wind turbine sensitivity studies I carried out for this dev PR using another (at the time of writing) unmerged ADflow bugfix. Unfortunately I do not have the bandwidth and the necessary implementation understanding to figure out where this error is coming from, but I am leaving this here for reference. There is probably some non-linearity or "non-commutativeness" coming from the operations within rotType=7 that was exacerbated by my sensitivity studies. Hope to come back on this some time soon.

Current behavior

An example of how off the derivatives can be:

FD derivative - step 1e-2: 115540.23375306278
adjoint derivative (optimization-safe): 119087.22965122
adjoint derivative (rotType=7): 196336.67968909

Expected behavior

The derivatives should be consistent with the reference values!!

Code versions

pyGeo v 1.4.0

sseraj commented 1 year ago

Commenting here for documentation purposes. I tested the rotType=7 derivatives with just rot_theta for my case, and they match finite difference to 6 digits. The issue could be related to using multiple rotations or something else that my case does not cover.