Skip to content

Commit

Permalink
Shortening some tests/demos
Browse files Browse the repository at this point in the history
  • Loading branch information
rckirby committed Feb 27, 2024
1 parent 8dcaecf commit 000e54c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
15 changes: 8 additions & 7 deletions demos/cahnhilliard/demo_cahnhilliard.py.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Boilerplate imports::
from firedrake.pyplot import tripcolor
import numpy as np
import os
from irksome import Dt, GaussLegendre, MeshConstant, TimeStepper
from irksome import Dt, RadauIIA, MeshConstant, TimeStepper

We create a directory to store some output pictures::

Expand Down Expand Up @@ -74,7 +74,9 @@ Set up the time variables and a seeded initial condition::

MC = MeshConstant(msh)
dt = MC.Constant(5.0e-6)
T = MC.Constant(5.0e-6)

One can always run for longer if desired::
T = MC.Constant(2 * 5.0e-6)
t = MC.Constant(0.0)

np.random.seed(42)
Expand All @@ -98,10 +100,9 @@ Now we define the semidiscrete variational problem::
inner(M*lmbda*dot(grad(c), n), lap(v))*ds +
inner(beta/h*M*lmbda*dot(grad(c), n), dot(grad(v), n))*ds)

Bell elements are fourth-order accurate in :math:`L^2`, so we'll use a
time-stepping scheme of comparable accuracy::
Bell elements are fourth-order accurate in :math:`L^2`, third in :math:`H^1` so we'll use a (formally) third-order time stepping scheme

butcher_tableau = GaussLegendre(2)
butcher_tableau = RadauIIA(3)

Because of the nonlinear problem, we'll need to set set some Newton
parameters as well as the linear solver::
Expand Down Expand Up @@ -140,8 +141,8 @@ Now let's set up the time stepper::
And advance the solution in time::

while float(t) < float(T):
if (float(t) + float(dt)) >= 1.0:
dt.assign(1.0 - float(t))
if (float(t) + float(dt)) >= float(T):
dt.assign(float(T) - float(t))
stepper.advance()
t.assign(float(t) + float(dt))
print(float(t), float(dt))
Expand Down
2 changes: 1 addition & 1 deletion demos/monodomain/demo_monodomain_FHN.py.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ We start with standard Firedrake/Irksome imports::

And we set up the mesh and function space. Note this demo uses serendipity elements, but could just as easily use Lagrange on quads or triangles.::
mesh = RectangleMesh(100, 100, 70, 70, quadrilateral=True)
mesh = RectangleMesh(20, 20, 70, 70, quadrilateral=True)
polyOrder = 2
V = FunctionSpace(mesh, "S", polyOrder)
Expand Down
7 changes: 4 additions & 3 deletions tests/test_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,10 @@ def Ffull(z, test):
num_its_initial=10,
num_its_per_step=4)

while (float(t) < 1.0):
if (float(t) + float(dt) > 1.0):
dt.assign(1.0 - float(t))
Tf = 0.1
while (float(t) < Tf):
if (float(t) + float(dt) > Tf):
dt.assign(Tf - float(t))
imp_stepper.advance()
imex_stepper.advance()
t.assign(float(t) + float(dt))
Expand Down

0 comments on commit 000e54c

Please sign in to comment.