@@ -40,5 +40,27 @@ def test_correct_call():
4040 assert "Starting simulation using FourierSeries code" in log_contents
4141
4242
43+ def test_fd_nondefault_accuracy ():
44+ """Regression test for jwave#224: FD fields with accuracy != 8
45+ must not cause pytree mismatch in lax.scan."""
46+ from jwave import FiniteDifferences
47+ from jwave .acoustics import TimeWavePropagationSettings
48+ from jwave .geometry import circ_mask
49+
50+ domain = Domain ((64 , 64 ), (1e-3 , 1e-3 ))
51+ p0_arr = 5.0 * circ_mask (domain .N , 3 , (32 , 32 ))
52+ p0 = FiniteDifferences (
53+ jnp .expand_dims (p0_arr , - 1 ), domain , accuracy = 4 )
54+ sound_speed = FiniteDifferences (
55+ jnp .expand_dims (jnp .ones (domain .N ) * 1500.0 , - 1 ), domain , accuracy = 4 )
56+ medium = Medium (domain , sound_speed = sound_speed , pml_size = 0 )
57+ time_axis = TimeAxis .from_medium (medium , cfl = 0.1 )
58+ time_axis .t_end = 2e-6
59+ settings = TimeWavePropagationSettings (smooth_initial = False )
60+
61+ p = simulate_wave_propagation (medium , time_axis , p0 = p0 , settings = settings )
62+ assert p is not None
63+
64+
4365if __name__ == "__main__" :
4466 test_correct_call ()
0 commit comments