Fix adjoint for streamwise periodic massflow + General handling of adjoints of additional solution variables#1536
Merged
TobiKattmann merged 47 commits intodevelopfrom Feb 26, 2022
Hidden character warning
The head ref may contain hidden characters: "feature_StreamPer_massflow_PlzW\u00f6rkDisTime"
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Dear reader,
Let me give a little bit background first:
When a massflow is prescribed for periodic flow (
KIND_STREAMWISE_PERIODIC= MASSFLOW), then a pressure drop is iterated(/adapted in each iteration) to fulfill that massflow requirement. In the Volume Source term only this pressure drop is used. The initial value at solver start is the value given inSTREAMWISE_PERIODIC_PRESSURE_DROP= ??and for restarted/adjoint simulations theSTREAMWISE_PERIODIC_PRESSURE_DROPfromflow.metais taken.Now this PR:
Until now, the update of the pressure drop, based on the difference between current and prescribed massflow, was done in the Flow solver Preprocessing. That causes some trouble as that routine is called multiple times during normal starts, restarts and even twice(!) for every normal iteration. So do not put any iterated quantities in those like I did. I now did put the update right in front of where it is used -> in the Source_Residual. Like so there shoulnd't be that much trouble of correct taping in that one iteration for the adjoint and it makes the logic of
Inner_iter/outer_iter==0etc unnecessary.I am not sure the changes up until now are necessary but I am not sure whether they are enough tbh. I will update this description accordingly:
Update: So to give you an idea of the current state of gradient validation. My setup is the good'ol 2D periodic Pin case (fluid-only) with the Design variables being FFD-parameters only around the middle pin (so no Periodic Interface shenanigans up to now) and I have 4 OF: Avg_Temp and Drag on the middle-Pin Surface as well as the Pressure-drop between In/outlet plus massflow through in- OR outlet (which is the same in value but maybe not for the gradient 🤔 ):
For Massflow and pressure drop the gradients are off by quite a bit but not too shabby (a good optimizer certainly could make good use of those gradients). Of course the Pressure-drop gradient should be 0 but there are prob some numerical gains to be made. The Pressure-drop gradient is O(1e-5) where the others are O(1 - 1e4) so I consider that to be ok
For massflow OF I get wrongly reported gradients by the adjoints, both before and after this PR
and pressure drop OF
Two other aspects.
Le fin
Related Work
#773 initial implementation
#1527 first step in getting a consistent restart for massflow prescribed flow by storing the pressure drop in massflow-meta file
PR Checklist