-
Notifications
You must be signed in to change notification settings - Fork 11
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
Split timestepper #537
Split timestepper #537
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.
Looks good Tim. My comments are mainly about overflowing lines
@@ -130,4 +130,4 @@ def test_boussinesq(tmpdir, compressible): | |||
|
|||
# Slack values chosen to be robust to different platforms | |||
assert error < 1e-10, f'Values for {variable} in ' + \ | |||
'Incompressible test do not match KGO values' | |||
'{compressible} test do not match KGO values' |
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.
'{compressible} test do not match KGO values' | |
f'{compressible} test do not match KGO values' |
# If we have physics schemes, extract these. | ||
if 'physics' in term_splitting: | ||
if physics_schemes is None: | ||
raise ValueError('Physics schemes need to be specified when applying a physics splitting in the SplitTimestepper') |
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.
Could this be split over multiple lines?
if term == 'physics': | ||
count += weights[idx] | ||
if count != 1: | ||
raise ValueError('Incorrect weights are specified for the physics schemes in the split timestepper.') |
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.
Ditto!
|
||
# Multilevel schemes are currently not supported for the dynamics terms. | ||
for label, scheme in self.dynamics_schemes.items(): | ||
assert scheme.nlevels == 1, "Multilevel schemes are not currently implemented in the split timestepper" |
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.
And here, maybe by doing:
assert scheme.nlevels == 1, "Multilevel schemes are not currently implemented in the split timestepper" | |
assert scheme.nlevels == 1, \ | |
"Multilevel schemes are not currently implemented in the split timestepper" |
# dynamics scheme | ||
for term in self.term_splitting: | ||
if term != 'physics': | ||
assert term in self.dynamics_schemes, f"The {term} terms do not have a specified scheme in the split timestepper" |
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.
and here ... e.g.
assert term in self.dynamics_schemes, f"The {term} terms do not have a specified scheme in the split timestepper" | |
assert term in self.dynamics_schemes, \ | |
f"The {term} terms do not have a specified scheme in the split timestepper" |
dynamics_schemes = {'transport': ImplicitMidpoint(domain), | ||
'diffusion': ForwardEuler(domain)} | ||
term_splitting = ['transport', 'diffusion', 'physics'] | ||
stepper = SplitTimestepper(equation, term_splitting, dynamics_schemes, io, spatial_methods=spatial_methods, physics_schemes=physics_schemes) |
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.
can we also split this line?
'diffusion': ForwardEuler(domain)} | ||
term_splitting = ['diffusion', 'transport', 'physics', 'transport'] | ||
weights = [1., 0.6, 1., 0.4] | ||
stepper = SplitTimestepper(equation, term_splitting, dynamics_schemes, io, weights=weights, spatial_methods=spatial_methods, physics_schemes=physics_schemes) |
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.
and this one!
dynamics_schemes = {'transport': SSPRK3(domain), | ||
'diffusion': SSPRK3(domain)} | ||
term_splitting = ['physics', 'transport', 'diffusion', 'physics'] | ||
weights = [1./3., 1, 1, 2./3.] |
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.
this is cool
'diffusion': SSPRK3(domain)} | ||
term_splitting = ['physics', 'transport', 'diffusion', 'physics'] | ||
weights = [1./3., 1, 1, 2./3.] | ||
stepper = SplitTimestepper(equation, term_splitting, dynamics_schemes, io, weights=weights, spatial_methods=spatial_methods, physics_schemes=physics_schemes) |
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.
and split this line!
term_splitting (list): a list of labels specifying the terms that should | ||
be solved separately and the order to do so. | ||
dynamics_schemes: (:class:`TimeDiscretisation`) A list of time | ||
discretisations for the dynamics schemes. A scheme must be |
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.
these continuation comments need indenting -- the pattern should be:
Args:
variable_name (variable_type): description ....
... continued description ...
... more continued description ...
next_variable (next_type): etc ...
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.
Great, thanks Tim!
Adds a general SplitTimestepper class that allows different terms to be timestepped separately using a defined time discretisation. A 'term_splitting' list specifies the order that the terms are solved, e.g ['transport', 'physics', 'diffusion']. A timestepping scheme for each non-physics term is specified in the 'dynamics_schemes' dictionary.
Furthermore, substepping can be used for a term by defining weights. For example, we can Strang-split the transport between diffusion with term_splitting=['transport','diffusion','transport'], weights=[0.5,1,0.5].
A test is added to integration_tests/model/test_split_timestepper.py. This tests three different splittings of the advection-diffusion equation with source physics.