Skip to content

Commit

Permalink
Add a test for the new repeated stepper
Browse files Browse the repository at this point in the history
  • Loading branch information
Ceyron committed Sep 3, 2024
1 parent 4389ac2 commit cbb1ebd
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/test_repeated_stepper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import jax
import pytest

import exponax as ex


def test_repeated_stepper():
DOMAIN_EXTENT = 1.0
NUM_POINTS = 81
DT = 0.1
NUM_REPEATS = 10

burgers_stepper = ex.stepper.Burgers(1, DOMAIN_EXTENT, NUM_POINTS, DT)

burgers_stepper_repeated = ex.RepeatedStepper(burgers_stepper, NUM_REPEATS)

burgers_stepper_repeated_manually = ex.repeat(burgers_stepper, NUM_REPEATS)

u_0 = ex.ic.RandomTruncatedFourierSeries(1, max_one=True)(
NUM_POINTS, key=jax.random.PRNGKey(0)
)

u_final = burgers_stepper_repeated(u_0)
u_final_manually = burgers_stepper_repeated_manually(u_0)

# Need a looser rel tolerance because Burgers is a decaying phenomenon,
# hence the expected/reference state has low magnitude after 10 steps.
assert u_final == pytest.approx(u_final_manually, rel=1e-3)

0 comments on commit cbb1ebd

Please sign in to comment.