-
Notifications
You must be signed in to change notification settings - Fork 1
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
Fix gradient in turbine example #38
Conversation
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 added a comment flagging some remaining Constant
usages. Otherwise, the code ran successfully for me this time.
demos/turbine/setup.py
Outdated
# NOTE: negative because we want maximum | ||
|
||
# Add a regularisation term for constraining the control | ||
area = assemble(Constant(1.0) * ufl.dx(domain=mesh)) | ||
alpha = 1.0 / area | ||
alpha = Constant(1.0 / area) |
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.
You have changed all the other Constant
terms to be in terms of R space
except here and line 157. Just flagging with a comment in case this was unintentional.
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.
Thanks for pointing this out. I've updated it to use Thetis' new domain_constant
in df4692e.
Okay it seems to be working now! The key fix was for the regularisation term - the sign was wrong and y2 and y3 were the wrong way round. |
Closes #37.
While #36 re-enables the turbines in the turbine example, there's still something not right because the optimisation progress is non-monotonic and the control turbine area occasionally goes to zero.
I added a Taylor test and found that the gradient of the QoI wasn't being computed correctly with the existing setup. I tracked the problem down to the$\mathbb{P}1_{DG}$ space, the Taylor test passed.
turbine_density
expression, which includes several terms. By projecting this expression intoIn addition, this PR overhauls the plotting functionality.