Skip to content

Commit

Permalink
Conservative KS should use conservative convection (#50)
Browse files Browse the repository at this point in the history
* Conservative KS should use conservative convection

* Adapt tests
  • Loading branch information
Ceyron authored Oct 22, 2024
1 parent ec4854d commit ad869e4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion exponax/stepper/_kuramoto_sivashinsky.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def __init__(
second_order_diffusivity: float = 1.0,
fourth_order_diffusivity: float = 1.0,
single_channel: bool = False,
conservative: bool = False,
conservative: bool = True,
dealiasing_fraction: float = 2 / 3,
order: int = 2,
num_circle_points: int = 16,
Expand Down
12 changes: 11 additions & 1 deletion tests/test_builtin_solvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,48 +117,55 @@ def test_specific_stepper_to_general_linear_stepper(


@pytest.mark.parametrize(
"specific_stepper,general_stepper_scale,general_stepper_coefficients",
"specific_stepper,general_stepper_scale,general_stepper_coefficients,conservative",
[
# Linear problems
(
ex.stepper.Advection(1, 3.0, 50, 0.1, velocity=1.0),
0.0,
[0.0, -1.0],
False,
),
(
ex.stepper.Diffusion(1, 3.0, 50, 0.1, diffusivity=0.01),
0.0,
[0.0, 0.0, 0.01],
False,
),
(
ex.stepper.AdvectionDiffusion(
1, 3.0, 50, 0.1, velocity=1.0, diffusivity=0.01
),
0.0,
[0.0, -1.0, 0.01],
False,
),
(
ex.stepper.Dispersion(1, 3.0, 50, 0.1, dispersivity=0.0001),
0.0,
[0.0, 0.0, 0.0, 0.0001],
False,
),
(
ex.stepper.HyperDiffusion(1, 3.0, 50, 0.1, hyper_diffusivity=0.00001),
0.0,
[0.0, 0.0, 0.0, 0.0, -0.00001],
False,
),
# nonlinear problems
(
ex.stepper.Burgers(1, 3.0, 50, 0.1, diffusivity=0.05, convection_scale=1.0),
1.0,
[0.0, 0.0, 0.05],
False,
),
(
ex.stepper.KortewegDeVries(
1, 3.0, 50, 0.1, dispersivity=1.0, convection_scale=-6.0
),
-6.0,
[0.0, 0.0, 0.0, -1.0, -0.01],
False,
),
(
ex.stepper.KuramotoSivashinskyConservative(
Expand All @@ -172,13 +179,15 @@ def test_specific_stepper_to_general_linear_stepper(
),
1.0,
[0.0, 0.0, -1.0, 0.0, -1.0],
True,
),
],
)
def test_specific_stepper_to_general_convection_stepper(
specific_stepper,
general_stepper_scale,
general_stepper_coefficients,
conservative,
):
num_spatial_dims = specific_stepper.num_spatial_dims
domain_extent = specific_stepper.domain_extent
Expand All @@ -197,6 +206,7 @@ def test_specific_stepper_to_general_convection_stepper(
dt,
coefficients=general_stepper_coefficients,
convection_scale=general_stepper_scale,
conservative=conservative,
)

specific_pred = specific_stepper(u_0)
Expand Down

0 comments on commit ad869e4

Please sign in to comment.