Higher-order implicit Runge-Kutta methods for the partitioned heat equation#415
Conversation
Previously, there were cases, where an empty dictionary was returned by the function. Additionally, runtime errors which occured when using single step methods are now fixed, as sub() was not defined for the Function space which is used for ssm
…oned-heat-conduction/fenics
…e time derivative!
With the change, the function shouldn't get into trouble if it created a BSpline with a degree >3
Refactoring: Avoid special treatment for single stage
WIP: Import from FEniCS and simplify code.
The time of the i-th stage was computed incomprehensible. This was changed by just setting the time to t+c[i]*dt
BenjaminRodenberg
left a comment
There was a problem hiding this comment.
Couldn't resist taking a look at the PR 😏 Generally looks good. I did not check the actual results, but this is something you are doing in much more detail than I can do it here. Therefore, I was mainly focusing on code style.
We should also try to directly move some minor changes to develop, but this is something I can do.
| import dolfin | ||
| from dolfin import FacetNormal, dot | ||
| from dolfin import FacetNormal, dot, project |
There was a problem hiding this comment.
Why do we use dolfin here? Let's stick to from fenics import .... I think FacetNormal is not needed, is it?
There was a problem hiding this comment.
project is provided by dolfin. And as the imports were already there, I used them.
Actually, also regarding the current implementation of heat.py, all imports from dolfin can be deleted, because dot is already imported above from fencis, and, as you said, FacetNormal is not used.
There was a problem hiding this comment.
But you can also use from fenics import project. I would suggest: Let's remove all dolfin imports here. We can then cherry-pick this change to develop, because you are of course right that it is not 100% the point of this PR to clean up the imports and therefore we should also not mix this up.
|
I just cleaned up the unnecessary dolfin imports via 71f8daa. Please merge |
…e B-Spline interpolation
BenjaminRodenberg
left a comment
There was a problem hiding this comment.
Minor readability comments. If this means that you have to start with all your testing from the beginning: You can also ignore these suggestions and we just apply this refactoring after this PR is merged.
| for i in range(num_stages): | ||
| uhelp = initial_condition | ||
| for j in range(num_stages): | ||
| uhelp = uhelp + tsm.A[i][j] * dt * ks[j] | ||
| u[i] = uhelp |
There was a problem hiding this comment.
| for i in range(num_stages): | |
| uhelp = initial_condition | |
| for j in range(num_stages): | |
| uhelp = uhelp + tsm.A[i][j] * dt * ks[j] | |
| u[i] = uhelp | |
| for i in range(num_stages): | |
| u[i] = initial_condition | |
| for j in range(num_stages): | |
| u[i] += tsm.A[i][j] * dt * ks[j] |
| rh = 0 | ||
| for i in range(num_stages): | ||
| rh = rh + f[i] * vs[i] * dx | ||
|
|
||
| # Assemble weak form from lhs and rhs | ||
| F = 0 | ||
| for i in range(num_stages): | ||
| # cf. https://doi.org/10.1145/3466168 p.5 equation 14 | ||
| F = F + weak_lhs(v=vs[i], u=u[i], k=ks[i]) | ||
| F = F - rh | ||
| return F |
There was a problem hiding this comment.
| rh = 0 | |
| for i in range(num_stages): | |
| rh = rh + f[i] * vs[i] * dx | |
| # Assemble weak form from lhs and rhs | |
| F = 0 | |
| for i in range(num_stages): | |
| # cf. https://doi.org/10.1145/3466168 p.5 equation 14 | |
| F = F + weak_lhs(v=vs[i], u=u[i], k=ks[i]) | |
| F = F - rh | |
| return F | |
| # Assemble weak form | |
| F = 0 | |
| for i in range(num_stages): | |
| # cf. https://doi.org/10.1145/3466168 p.5 equation 14 | |
| F += inner(ks[i], vs[i]) * dx + inner(grad(u[i]), grad(vs[i])) * dx - f[i] * vs[i] * dx | |
| return F |
I don't really see a good reason for introduction weak_lhs here. Currently, the whole script does not generalize that well, if you want to solve a different equation anyway, because the f comes from "the outside". But this is also ok here.
If you want to get rid of the index, you can also try:
for u, v, k, f in zip(us, vs, ks, fs):
F += inner(k, v) * dx + inner(grad(u), grad(v)) * dx - f * v * dx
btw: Renaming the u from above to us and the f to fs I think would not harm. Currently, it's a bit odd that you say vs, but not us.
|
I think we should definitely try to get this merged into the tutorials, because it is an important test for waveforms in preCICE. But I'm still a bit unsure how we should continue here: For the sake of the review it was very useful to modify So there are the following three options:
Then, there is, of course, also the option to move this case into an entirely new folder |
| The implementation of the higher-order implicit Runge-Kutta methods was mostly taken from: | ||
| https://github.com/NikoWul/FenicsIrksome |
There was a problem hiding this comment.
FYI, the original repository has no license. I understand that @BenjaminRodenberg was related to (supervised?) that project, but it would be best to make this clear.
Definitely! No good work should see slow decay in unmerged PRs.
My main argument here would be consistency: We have invested a lot of effort in having all solver options of each tutorial behave in similar ways and give similar results. By merging this as-is, it means that FEniCS will be doing something different than the rest of the solver options.
That would be the breaking case, so for me, this is a clear "no".
This changes the default behavior, and hence the consistency with the rest, so also "no" for me.
This sounds like the easiest, least intrusive option. How easy would it be to merge the two and make the implicit solver a special case, configurable at runtime? That could prevent some duplication.
We typically do this when we need a different My recommendation: Leave |
…tation to a new file and reset heat.py to state of the dev branch
BenjaminRodenberg
left a comment
There was a problem hiding this comment.
Looks good to me 👍 Will merge this now and apply some final changes directly on develop.
With this implementation, you could compute the partitioned heat equation with any implicit RK method, which is provided
by ButcherTableaux.py file.
You just need to change the time stepping scheme
tsmto the IRK you want to use.The weak form is obtained algorithmically and does not need to be changed by the user.