-
Notifications
You must be signed in to change notification settings - Fork 99
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
Fixing initial state values in MPhys #321
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #321 +/- ##
==========================================
- Coverage 41.13% 41.02% -0.11%
==========================================
Files 13 13
Lines 4108 4119 +11
==========================================
Hits 1690 1690
- Misses 2418 2429 +11 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adflow/mphys/mphys_adflow.py
Outdated
self.solver.setOption("printIterations", True) | ||
self.solver.adflow.inputiteration.printbcwarnings = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I'm not sure how I did this, but nonetheless I'll get it fixed.
adflow/pyADflow.py
Outdated
# This is a flag not exposed to the user as an option that controls | ||
# printing the boundary condition warnings. This should only | ||
# be used in the MPhys layer when we make multiple calls to | ||
# updateBCAllLevels. | ||
self.adflow.inputiteration.printbcwarnings = True | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lamkina do you have any suggestions on how I should test this? |
I would check out the main branch and run the tutorial wing case. Print the initial state vector before ADflow runs the first analysis and you'll see it's an array of all ones. Then switch to this branch and run the same case and you should see the initial state vector is the correct one from ADflow. You can confirm the state vector is correct by running the case with MACH only and printing the initial state vector to compare. |
I'm confused, if I add code printing out the state on the line in Andrew's branch
Main branch
~8e6 seems like a pretty reasonable initial residual, so my best guess is that there is something in ADflow's |
Huh, I was not seeing this behavior in my initial testing. It's concerning that ADflow is overwriting a state vector internally that should be coming from OpenMDAO. This isn't happening other than the initialization, but still weird. |
@lamkina I think we should just merge this PR, regardless of the reason that the initial state seemed to be being set correctly before by the ADflow, explicitly defining the actual correct initial states in OpenMDAO seems like a more correct approach. |
@anilyil can you take a quick look? Should be an easy review. |
Purpose
This PR fixes a bug where the initial ADflow states were being set to a vector of all ones when running with MPhys. This occurred because OpenMDAO defaults the initial value of output vectors to all ones.
To fix this issue, I overwrote the
_set_vectors()
method of the ADflowSolver component to update the initial value of the output vector.This PR should be merged after PRs #307 and #308 because it includes changes from both to control the print outs in the
_set_vectors()
method and to ensure the adjoint works during mesh warping.Expected time until merged
A week or two, depending on PRs #307 and #308
Type of change
Testing
We don't have testing for MPhys, but I tested this change on a handful of local test cases including BC and geometric design variables. Reviewers should test this with their own MPhys cases if possible.
Checklist
flake8
andblack
to make sure the Python code adheres to PEP-8 and is consistently formattedfprettify
or C/C++ code withclang-format
as applicable