-
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
Free stream change correction improvements #264
Conversation
…ge_correction_mods
Codecov Report
@@ Coverage Diff @@
## main #264 +/- ##
==========================================
- Coverage 40.87% 40.86% -0.02%
==========================================
Files 13 13
Lines 3892 3901 +9
==========================================
+ Hits 1591 1594 +3
- Misses 2301 2307 +6
... and 5 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
This is ready to go because it seems like my last fix fixed the issues with the tests. |
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.
A few comments to discuss before I approve this PR:
- Should we abstract away the rotation matrix as a separate routine? This would let us use this as a general utility in the future.
- Does it make sense to add a test for the case where the change in the states is below the tolerance? I think we might want to test that capability.
I addressed both of the changes, @lamkina |
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.
I think this is ready to go.
It looks good to me, I have a question on the |
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.
I only checked the docs
@ArshSaja, I added a bit more explanation in the options docs for how the tolerance should be picked. |
Purpose
This PR adds a new way to compute a free stream correction update.
When the free stream conditions are modified for a given aeroProblem compared to the last time it was run, ADflow computes a simple correction to the states that adds the offset from the change to each cell's state. The goal here is to perturb the states enough so that the residual increases throughout the volume. If this correction is not performed, the residuals only increase near the cells that are 2 layers within the farfield BCs. As a result, the Newton-based solvers struggle to get over these transients because the residuals initially go up as the changes are propagated throughout the domain. This offset also aims to put the volume cells in a better position for convergence. The cells that have a state that is similar to the farfield conditions will be very close to their final state with the correction. This behavior is controlled with the option
infChangeCorrection
.In this PR, I add a new method to perform this correction update. In my formulation, instead of adding the delta between the new and the old free stream conditions, I actually rotate the velocity vectors at each cell by how much the free stream velocity has rotated. This change results in a slightly better restart when the inflow angle is changed. I do not need to keep track of alpha and beta because the update is based on the directions of the old and new free stream velocities. The rotation is performed on the plane that is orthogonal to these vectors. On top of the rotation, I also add the changes to the density and energy throughout like the original method because these changes can become important with changes to altitude and Mach number.
There are now 3 options that control the correction update:
"infChangeCorrection": [bool, True],
this option enables or disables this correction"infChangeCorrectionTol": [float, 1e-12],
this tolerance determines when we may not want to run the correction update. If the norm of the change in the state is less than this tolerance, we dont run the update. This is useful when the state does not change, so we avoid messing stuff up by running a correction. For the offset method this is not too problematic, but the rotation needs to compute an orthogonal vector, and if the two free stream vectors are parallel, it can't and would get a nan. This tolerance prevents this from happening. The tolerance was a hard coded parameter before this PR so the PR maintains the old behavior exactly."infChangeCorrectionType": [str, ["offset", "rotate"]],
pretty self explanatory; offset does the original method, rotate rotates the velocities and offsets the density and energy.Expected time until merged
1-2 weeks. I want to use this feature a bit to see if it works. I also will add a test for this.
Type of change
Testing
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