Skip to content
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

Conservative KS should use conservative convection #50

Merged
merged 2 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading