-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add note * Add 2d and 3d advection * Add diffusion analytical solution in 2D * Add diffusion test in 3D * Ensure all presets are working * Employ a fix for single facets * Use Exponax viz routines * Also employ fix for faceted animations * Fix defaults for Kolmogorov * Change to exponax viz routines * Add 3D dynamics * Add hint on where to find the reference qualitative rollouts * Re-Execute Notebook * Re-Execute Notebook * Re-Execute notebook * Start with a validation notebook for KdV * Test if KdV without convection is purely linear * Finished KdV soliton comparison * Faster way to compute the spectrum binning in higher dimensions * Improved version of kolmogorov comparison
- Loading branch information
Showing
12 changed files
with
1,184 additions
and
339 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import jax | ||
import pytest | ||
|
||
import exponax as ex | ||
|
||
|
||
@pytest.mark.parametrize("num_spatial_dims", [1, 2, 3]) | ||
def test_kdv(num_spatial_dims: int): | ||
DOMAIN_EXTENT = 5.0 | ||
NUM_POINTS = 48 | ||
DT = 0.01 | ||
DIFFUSIVITY = 0.1 | ||
DISPERSIVITY = 0.001 | ||
HYPER_DIFFUSIVITY = 0.0001 | ||
|
||
u_0 = ex.ic.RandomTruncatedFourierSeries( | ||
num_spatial_dims=num_spatial_dims, max_one=True | ||
)(NUM_POINTS, key=jax.random.PRNGKey(0)) | ||
|
||
kdv_stepper_only_viscous = ex.stepper.KortewegDeVries( | ||
num_spatial_dims=num_spatial_dims, | ||
domain_extent=DOMAIN_EXTENT, | ||
num_points=NUM_POINTS, | ||
dt=DT, | ||
convection_scale=0.0, | ||
diffusivity=DIFFUSIVITY, | ||
dispersivity=0.0, | ||
hyper_diffusivity=0.0, | ||
advect_over_diffuse=False, | ||
diffuse_over_diffuse=False, | ||
single_channel=True, | ||
) | ||
diffusion_stepper = ex.stepper.Diffusion( | ||
num_spatial_dims=num_spatial_dims, | ||
domain_extent=DOMAIN_EXTENT, | ||
num_points=NUM_POINTS, | ||
dt=DT, | ||
diffusivity=DIFFUSIVITY, | ||
) | ||
|
||
assert kdv_stepper_only_viscous(u_0) == pytest.approx( | ||
diffusion_stepper(u_0), abs=1e-6 | ||
) | ||
|
||
kdv_stepper_only_dispersion = ex.stepper.KortewegDeVries( | ||
num_spatial_dims=num_spatial_dims, | ||
domain_extent=DOMAIN_EXTENT, | ||
num_points=NUM_POINTS, | ||
dt=DT, | ||
convection_scale=0.0, | ||
diffusivity=0.0, | ||
dispersivity=-DISPERSIVITY, | ||
hyper_diffusivity=0.0, | ||
advect_over_diffuse=False, | ||
diffuse_over_diffuse=False, | ||
single_channel=True, | ||
) | ||
dispersion_stepper = ex.stepper.Dispersion( | ||
num_spatial_dims=num_spatial_dims, | ||
domain_extent=DOMAIN_EXTENT, | ||
num_points=NUM_POINTS, | ||
dt=DT, | ||
dispersivity=DISPERSIVITY, | ||
) | ||
|
||
assert kdv_stepper_only_dispersion(u_0) == pytest.approx( | ||
dispersion_stepper(u_0), abs=1e-6 | ||
) | ||
|
||
kdv_stepper_only_hyper_diffusion = ex.stepper.KortewegDeVries( | ||
num_spatial_dims=num_spatial_dims, | ||
domain_extent=DOMAIN_EXTENT, | ||
num_points=NUM_POINTS, | ||
dt=DT, | ||
convection_scale=0.0, | ||
diffusivity=0.0, | ||
dispersivity=0.0, | ||
hyper_diffusivity=HYPER_DIFFUSIVITY, | ||
advect_over_diffuse=False, | ||
diffuse_over_diffuse=False, | ||
single_channel=True, | ||
) | ||
hyper_diffusion_stepper = ex.stepper.HyperDiffusion( | ||
num_spatial_dims=num_spatial_dims, | ||
domain_extent=DOMAIN_EXTENT, | ||
num_points=NUM_POINTS, | ||
dt=DT, | ||
hyper_diffusivity=HYPER_DIFFUSIVITY, | ||
) | ||
|
||
assert kdv_stepper_only_hyper_diffusion(u_0) == pytest.approx( | ||
hyper_diffusion_stepper(u_0), abs=1e-6 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Validation | ||
|
||
Since Fourier-pseudo spectral ETDRK methods are exact for linear bandlimited | ||
problems (on periodic domains), this can be automatically validated to machine precision and is done in `tests/test_validation.py`. This folder contains additional validation notebooks for specific problems. | ||
|
||
Additionally, run the script `qualitative rollouts` to produce a set | ||
visualizations (1D -> spatio-temporal, 2D & 3D -> animations) of the | ||
trajectories of the pre-built solvers. References to this can be found at: | ||
https://github.com/Ceyron/exponax_qualitative_rollouts |
Oops, something went wrong.