-
-
Notifications
You must be signed in to change notification settings - Fork 35
[WIP] Better staggered implementation #285
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
[WIP] Better staggered implementation #285
Conversation
… it easier to extend/specialize on grid type
Having thought about it overnight, I think doing a simple variable transformation as described in the attached image achieves the same effect, with the benefit of having an explicit mapping between the variables. Still open to utilization of This is particularly nice because I only have to map the second-order space discrete differential to the first order forward space differential. |
…retize, but this shouldn't be necessary in general) to get spatial staggering working. very close now, just need to tease out the details of the discretized differential operators now.
…e available elsewhere
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #285 +/- ##
==========================================
- Coverage 83.02% 79.62% -3.40%
==========================================
Files 40 41 +1
Lines 1756 1944 +188
==========================================
+ Hits 1458 1548 +90
- Misses 298 396 +98 ☔ View full report in Codecov by Sentry. |
…ath forward specializing only low-level differential discretizer methods
…cmhyett/MethodOfLines.jl into better_staggered_implementation
We have wave equation looking results! I implemented my own simple leapfrog update - there is a strange bit about how the symbolic tracing modifies the There is also a preference to leftward advection; I think this must be due to an off-by-one error, and I suspect the boundary substitution to be the issue. For reference, I put the code here including all the hacks necessary to do the time staggering.
|
…to DynamicalODEProblem
@xtalax , looking in the last commit, in I want to look for all the same variables, i.e., collect all the |
…correctly and staggered data is available in DiscreteSpace object
…iscretization kwarg
…to work with revised output from discretize
In addition to the included tests, a few words about the final commits:
In the attached pictures we show stability of transparent and reflecting boundary conditions - these cases are codified in the tests. |
…cmhyett/MethodOfLines.jl into better_staggered_implementation
2 things, We need to get tests passing, and we need a docs page detailing how this is used with an example |
@xtalax , do you understand these errors? The offending lines of code (these Perhaps I clobbered an |
Somehow, you've broken the default |
Integration tests failed due to an upstream failure addressed in: @xtalax PR tests are ready to be re-run. |
const center_align=CenterAlignedGrid() | ||
const edge_align=EdgeAlignedGrid() | ||
const stagger_align=StaggeredGrid() |
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.
please make this staggered_grid
examples/waveEquation.jl
Outdated
@@ -0,0 +1,37 @@ | |||
using OrdinaryDiffEq, ModelingToolkit, MethodOfLines, DomainSets, Plots; |
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 should add these to PDESystemLibrary.jl, and tag them appropriately so that you can retrieve them, rather than in a folder here
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 you commented on an old file? This has been moved to docs/staggered.md
and it follows the same template as is found in e.g. heatss.md
Can you clarify?
end | ||
othervars = filter(v -> (length(arguments(v)) != 1) && any(isequal(x_), arguments(depvar(v, s))), othervars) | ||
|
||
depvarderivbcmaps = [(Differential(x_)^d)(u_) => central_difference(derivweights, II, s, [], (x2i(s, u, x_), x_), u, ufunc, d) for d in derivweights.orders[x_]]; |
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.
remember the depvar/derivbcmaps are different for variables on the other grid
@@ -1,7 +1,7 @@ | |||
# Steady State Heat Equation - No Time Dependence - NonlinearProblem | |||
|
|||
Occasionally, it is desirable to solve an equation that has no time evolution, such as the steady state heat equation: | |||
```@example heatss | |||
``` |
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.
need to change this back
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.
It works now?
@@ -23,7 +23,7 @@ using DomainSets | |||
end | |||
|
|||
# Laplace's Equation, same as above but with MOL discretization | |||
@testset "1D Laplace - constant solution" begin | |||
@test_skip begin #@testset "1D Laplace - constant solution" begin |
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.
change all these back
Working to solve #255. Previous work found a way to perform time staggering - now we want to perform space staggering as well. The first thing I did was encapsulate functionality to more easily identify component parts (and perhaps overwrite them if need be).
Currently,
Iaxies
&Igrid
members ofDiscreteSpace
are not utilized (at least as best as I can tell), but hold the potential to provide for a mapping between independent and dependent grids.By default, it's a bijective map, but in general it doesn't need to be. However, since they aren't currently used, it'll take a bit of work to identify correct locations to use them instead of the dependent variable axies & grids. As a basic example, suppose we have
u(x,t) => u[1](t) = u(x[1],t), u[2](t) = u(x[3],t), u[3](t) = u(x[5],t)
andv(x,t) => v[1](t) = v(x[2],t), v[2](t) = v(x[4],t), v[3](t) = v(x[6],t)
, and using centered in space finite differences to update ~du[2] = (v[2] - v[1])/(2*dx)
notice that this is actually second-order centered because of the staggering.This would change the differential operator based on the grid type.....may or may not be viable.
@xtalax @ChrisRackauckas, let me know if you forsee issues here.