diff --git a/docs/sphinx/ChollaExamples/1D-123-Test/overview.md b/docs/sphinx/ChollaExamples/1D-123-Test/overview.md index af2987a8f..87df3df59 100644 --- a/docs/sphinx/ChollaExamples/1D-123-Test/overview.md +++ b/docs/sphinx/ChollaExamples/1D-123-Test/overview.md @@ -11,8 +11,6 @@ Full initial conditions can be found in {repository-file}`src/grid/initial_condi ## Parameter file: -This file has been modified from {repository-file}`examples/1D/123.txt` to include y and z boundary conditions = 0 - :::{literalinclude} input.txt ::: @@ -20,7 +18,7 @@ This file has been modified from {repository-file}`examples/1D/123.txt` to inclu Upon completion, you should obtain 2 output files. The initial and final density, pressure, and velocity (in code units) of the solution is shown below (pink dots) plotted over the exact solution (purple line). -Examples of how to extract and plot data can be found in {repository-file}`python/examples/plot_sod.py`. +Examples of how to extract and plot data can be found in the [General 1D Plotting Example](../../PythonExamples/1D-plotting.md). . :::{figure} 1d123-6panel-density-pressure.png ::: diff --git a/docs/sphinx/ChollaExamples/1D-Shu-Osher/overview.md b/docs/sphinx/ChollaExamples/1D-Shu-Osher/overview.md new file mode 100644 index 000000000..cc6f7f9bc --- /dev/null +++ b/docs/sphinx/ChollaExamples/1D-Shu-Osher/overview.md @@ -0,0 +1,26 @@ +# 1D Shu and Osher test +This test (Shu & Osher, 1989) highlights the ability of a code to resolve small scale smooth flow and shocks simultaneously. Further, it shows how lower resolution solutions can cut off some of the amplitude of maxima due to the slope limiters. Parameters are from Stone et al., 2008, Section 8.1. The test consists of left and right states separated at x = -0.8. On the left, density is set to 3.857143, pressure to 10.33333, and velocity to 2.629369. On the right, density is sinusoidally varying: $\rho(x)$ = 1.0 + 0.2 $\sin(5.0\pi x)$. Pressure is set to 1.0 and the velocity is 0.0. Gamma is set to 1.4. This test is performed with the hydro build (`cholla/builds/make.type.hydro`). Full initial conditions can be found in `cholla/src/grid/initial_conditions.cpp`under `Shu_Osher()`. + +**Important:** This test must be run with diode boundaries [disabled](https://github.com/alwinm/cholla/tree/main-diode) in order to perform as expected (thank you @alwinm!). This branch also uses the Van Leer integrator. + +The parameter file can be found at {repository-file}`examples/1D/Shu_Osher.txt` + + +## Parameter file + +:::{literalinclude} parameter-file.txt +::: + +Upon completion, you should obtain 2 output files. The initial and final density, pressure, and velocity (in code units) of the solution is shown below. Examples of how to extract and plot data can be found in the [General 1D Plotting Example](../../PythonExamples/1D-plotting.md). + +:::{figure} shu-osher.png + + +With the diode disabled, this solution does match that of Schneider and Robertson 2015 and Stone et al. 2008, shown below: + +:::{figure} schneider-robertson-2015.png +:width: 500px +:align: center +::: + + diff --git a/docs/sphinx/ChollaExamples/1D-Shu-Osher/parameter-file.txt b/docs/sphinx/ChollaExamples/1D-Shu-Osher/parameter-file.txt new file mode 100644 index 000000000..06b8f5960 --- /dev/null +++ b/docs/sphinx/ChollaExamples/1D-Shu-Osher/parameter-file.txt @@ -0,0 +1,36 @@ +# +# Parameter File for the Shu-Osher shock tube test, originally from +# Shu & Osher, 1989. These parameters are from Stone et al., 2008, Section 8.1 +# + +###################################### +# number of grid cells in the x dimension +nx=200 +# number of grid cells in the y dimension +ny=1 +# number of grid cells in the z dimension +nz=1 +# final output time +tout=0.47 +# time interval for output +outstep=0.47 +# value of gamma +gamma=1.4 +# name of initial conditions +init=Shu_Osher +# domain properties +xmin=-1.0 +ymin=0.0 +zmin=0.0 +xlen=2.0 +ylen=1.0 +zlen=1.0 +# type of boundary conditions +xl_bcnd=3 +xu_bcnd=3 +yl_bcnd=0 +yu_bcnd=0 +zl_bcnd=0 +zu_bcnd=0 +# path to output directory +outdir=./ diff --git a/docs/sphinx/ChollaExamples/1D-Shu-Osher/schneider-robertson-2015.png b/docs/sphinx/ChollaExamples/1D-Shu-Osher/schneider-robertson-2015.png new file mode 100644 index 000000000..e9c19b26e Binary files /dev/null and b/docs/sphinx/ChollaExamples/1D-Shu-Osher/schneider-robertson-2015.png differ diff --git a/docs/sphinx/ChollaExamples/1D-Shu-Osher/shu-osher.png b/docs/sphinx/ChollaExamples/1D-Shu-Osher/shu-osher.png new file mode 100644 index 000000000..3f27e506e Binary files /dev/null and b/docs/sphinx/ChollaExamples/1D-Shu-Osher/shu-osher.png differ diff --git a/docs/sphinx/ChollaExamples/1D-Sod/overview.md b/docs/sphinx/ChollaExamples/1D-Sod/overview.md new file mode 100644 index 000000000..cb8e91821 --- /dev/null +++ b/docs/sphinx/ChollaExamples/1D-Sod/overview.md @@ -0,0 +1,71 @@ +# 1D Sod Shock Tube +This test highlights the ability of a code to resolve shocks and contact discontinuities over a narrow region. Parameters from Sod (1978). The setup consists of a density and pressure of 1.0 for x \< 0 and 0.1 for x \> 0.5. Gamma is set to 1.4. This test was performed with the hydro build (`cholla/builds/make.type.hydro`) and Van Leer integrator. Full initial conditions can be found in `cholla/src/grid/initial_conditions.cpp`under `Riemann()`. + + +The parameter file can be found at {repository-file}`examples/1D/sod.txt` + +## Parameter File: +``` +# +# Parameter File for 1D Sod Shock tube +# + +################################################ +# number of grid cells in the x dimension +nx=100 +# number of grid cells in the y dimension +ny=1 +# number of grid cells in the z dimension +nz=1 +# final output time +tout=0.2 +# time interval for output +outstep=0.2 +# name of initial conditions +init=Riemann +# domain properties +xmin=0.0 +ymin=0.0 +zmin=0.0 +xlen=1.0 +ylen=1.0 +zlen=1.0 +# type of boundary conditions +xl_bcnd=3 +xu_bcnd=3 +yl_bcnd=0 +yu_bcnd=0 +zl_bcnd=0 +zu_bcnd=0 +# path to output directory +outdir=./ + +################################################# +# Parameters for 1D Riemann problems +# density of left state +rho_l=1.0 +# velocity of left state +vx_l=0.0 +vy_l=0.0 +vz_l=0.0 +# pressure of left state +P_l=1.0 +# density of right state +rho_r=0.1 +# velocity of right state +vx_r=0.0 +vy_r=0.0 +vz_r=0.0 +# pressure of right state +P_r=0.1 +# location of initial discontinuity +diaph=0.5 +# value of gamma +gamma=1.4 +``` +Upon completion, you should obtain two output files.The initial and final density, pressure, and velocity (in code units) of the solution is shown below. Examples of how to extract and plot data can be found in the [General 1D Plotting Example](../../PythonExamples/1D-plotting.md). + +:::{figure} sod-initial-final.png +::: + +We see a rarefaction wave propagating away from the initial discontinuity, a contact discontinuity at x = 0.7, and a shock at x =0.9. diff --git a/docs/sphinx/ChollaExamples/1D-Sod/sod-initial-final.png b/docs/sphinx/ChollaExamples/1D-Sod/sod-initial-final.png new file mode 100644 index 000000000..ff97473f4 Binary files /dev/null and b/docs/sphinx/ChollaExamples/1D-Sod/sod-initial-final.png differ diff --git a/docs/sphinx/ChollaExamples/1D-Sound-Wave/new_soundwave_2.mp4 b/docs/sphinx/ChollaExamples/1D-Sound-Wave/new_soundwave_2.mp4 new file mode 100644 index 000000000..862453810 Binary files /dev/null and b/docs/sphinx/ChollaExamples/1D-Sound-Wave/new_soundwave_2.mp4 differ diff --git a/docs/sphinx/ChollaExamples/1D-Sound-Wave/overview.md b/docs/sphinx/ChollaExamples/1D-Sound-Wave/overview.md new file mode 100644 index 000000000..83894347c --- /dev/null +++ b/docs/sphinx/ChollaExamples/1D-Sound-Wave/overview.md @@ -0,0 +1,68 @@ +# 1D Sound Wave +This test initializes a compression/rarefaction wave across the grid. The setup consists of an initial density and pressure of 1.0 and 0.6, respectively. A sound wave is initialized as a sinusoidal wave with amplitude 1e-4 and wavelength of 1.0. Gamma is set to 1.666666666666667. This test was performed with the hydro build (`cholla/builds/make.type.hydro`) and Van Leer integrator. Full initial conditions can be found in `cholla/src/grid/initial_conditions.cpp`under `Sound_Wave()`. + +The parameter file can be found at: {repository-file}`examples/1D/sound_wave.txt` + +## Parameter file: +``` +# +# Parameter File for sound wave test +# + +################################################ +# number of grid cells in the x dimension +nx=128 +# number of grid cells in the y dimension +ny=1 +# number of grid cells in the z dimension +nz=1 +# final output time +tout=0.05 +# time interval for output +outstep=0.01 +# name of initial conditions +init=Sound_Wave +# size of domain +xmin=0.0 +ymin=0.0 +zmin=0.0 +xlen=1.0 +ylen=1.0 +zlen=1.0 +# type of boundary conditions +xl_bcnd=1 +xu_bcnd=1 +yl_bcnd=0 +yu_bcnd=0 +zl_bcnd=0 +zu_bcnd=0 +# path to output directory +outdir=./sowvout + +################################################# +# Parameters for linear wave problems +# initial density +rho=1.0 +# velocity in the x direction +vx=0 +# velocity in the y direction +vy=0 +# velocity in the z direction +vz=0 +# initial pressure +P=0.6 +# amplitude of perturbing oscillations +A=1e-4 +# value of gamma +gamma=1.666666666666667 + +``` +Upon completion, you should obtain five output files. By changing the outstep to 1, we can obtain the evolution of the density, pressure, and velocity. Examples of how to extract and plot data can be found in the [General 1D Plotting Example](../../PythonExamples/1D-plotting.md). + +:::{video} new_soundwave_2.mp4 + :width: 700 + :height: 500 + :align: center + :autoplay: + :loop: +::: diff --git a/docs/sphinx/ChollaExamples/1D-Sound-Wave/soundwave-new.mp4 b/docs/sphinx/ChollaExamples/1D-Sound-Wave/soundwave-new.mp4 new file mode 100644 index 000000000..6b7bbc76a Binary files /dev/null and b/docs/sphinx/ChollaExamples/1D-Sound-Wave/soundwave-new.mp4 differ diff --git a/docs/sphinx/ChollaExamples/1D-Square-Wave/overview.md b/docs/sphinx/ChollaExamples/1D-Square-Wave/overview.md new file mode 100644 index 000000000..9087b6360 --- /dev/null +++ b/docs/sphinx/ChollaExamples/1D-Square-Wave/overview.md @@ -0,0 +1,78 @@ +# 1D Square Wave +This test initializes a square wave density pertubation. The setup consists of an initial density and pressure of 1.0 and 0.01, respectively. A square wave is initialized with amplitude 1.5. Gamma is set to 1.666666666666667. This test was performed with the hydro build (`cholla/builds/make.type.hydro`) and Van Leer integrator. Full initial conditions can be found in `cholla/src/grid/initial_conditions.cpp`under `Square_Wave()`. + +The parameter file can be found at: {repository-file}`examples/1D/square_wave.txt` + +## Parameter file: +``` +# +# Parameter File for square wave test +# + +################################################ +# number of grid cells in the x dimension +nx=100 +# number of grid cells in the y dimension +ny=1 +# number of grid cells in the z dimension +nz=1 +# final output time +tout=1.0 +# time interval for output +outstep=0.01 +n_hydro=1 +# name of initial conditions +init=Square_Wave +# size of domain +xmin=0.0 +ymin=0.0 +zmin=0.0 +xlen=1.0 +ylen=1.0 +zlen=1.0 +# type of boundary conditions +xl_bcnd=1 +xu_bcnd=1 +yl_bcnd=0 +yu_bcnd=0 +zl_bcnd=0 +zu_bcnd=0 +# path to output directory +outdir=./ + +################################################# +# Parameters for square wave +# initial density +rho=1.0 +# velocity in the x direction +vx=1.0 +# velocity in the y direction +vy=0 +# velocity in the z direction +vz=0 +# initial pressure +P=0.01 +# relative amplitude of overdense region +A=1.5 +# value of gamma +gamma=1.666666666666667 +``` +Upon completion, you should obtain 101 output files. The evolution of the density is shown below. Pressure is constant to the $10^{-14}$ level. Examples of how to extract and plot data can be found in the [General 1D Plotting Example](../../PythonExamples/1D-plotting.md). + + +:::{video} square-docs.mp4 + :width: 640 + :height: 480 + :autoplay: + :loop: + :align: center +::: + +We see a square waveform of amplitude 1.5 propagating rightwards. + +If the wave is left to propagate for an extended period of time, we observe a rapid breakdown in the structure. This breakdown is much faster with the Van Leer integrator than with the Simple integrator: + +Van Leer: + + + diff --git a/docs/sphinx/ChollaExamples/1D-Square-Wave/square-docs.mp4 b/docs/sphinx/ChollaExamples/1D-Square-Wave/square-docs.mp4 new file mode 100644 index 000000000..9e35e20cb Binary files /dev/null and b/docs/sphinx/ChollaExamples/1D-Square-Wave/square-docs.mp4 differ diff --git a/docs/sphinx/ChollaExamples/1D-Strong-Shock/overview.md b/docs/sphinx/ChollaExamples/1D-Strong-Shock/overview.md new file mode 100644 index 000000000..426dc5d6e --- /dev/null +++ b/docs/sphinx/ChollaExamples/1D-Strong-Shock/overview.md @@ -0,0 +1,70 @@ +# 1D Strong Shock +This test is similar to the Sod shock tube but has higher initial pressure and density differences. This shows the ability of a code to limit oscillatory behavior in areas of high density and pressure contrasts. The setup consists of a density and pressure of 10.0 and 100.0, respectively, for 0 \< x \< 0.5 and density= pressure = 1.0 for 0.5 \< x \< 1.0. Gamma is set to 1.4. This test was performed with the hydro build (`cholla/builds/make.type.hydro`) and Van Leer integrator. Full initial conditions can be found in `cholla/src/grid/initial_conditions.cpp`under `Riemann()`. + +The parameter file can be found at: {repository-file}`examples/1D/strong_shock.txt` + +## Parameter file: +``` +# +# Parameter File for 1D strong shock test +# + +################################################ +# number of grid cells in the x dimension +nx=100 +# number of grid cells in the y dimension +ny=1 +# number of grid cells in the z dimension +nz=1 +# final output time +tout=0.07 +# time interval for output +outstep=0.07 +# name of initial conditions +init=Riemann +# domain properties +xmin=0.0 +ymin=0.0 +zmin=0.0 +xlen=1.0 +ylen=1.0 +zlen=1.0 +# type of boundary conditions +xl_bcnd=3 +xu_bcnd=3 +yl_bcnd=0 +yu_bcnd=0 +zl_bcnd=0 +zu_bcnd=0 +# path to output directory +outdir=./ + +################################################# +# Parameters for 1D Riemann problems +# density of left state +rho_l=10.0 +# velocity of left state +vx_l=0.0 +vy_l=0.0 +vz_l=0.0 +# pressure of left state +P_l=100.0 +# density of right state +rho_r=1.0 +# velocity of right state +vx_r=0.0 +vy_r=0.0 +vz_r=0.0 +# pressure of right state +P_r=1.0 +# location of initial discontinuity +diaph=0.5 +# value of gamma +gamma=1.4 +``` +Upon completion, you should obtain two output files. The initial and final density, velocity, and pressure (in code units) of the solution is shown below. Examples of how to extract and plot data can be found in the [General 1D Plotting Example](../../PythonExamples/1D-plotting.md). + +:::{figure} snapshots_strongshock.png + + +We see a rarefaction expanding from just after the initial discontinuity, followed by a contact discontinuity at x =0.75 and a shock at x = 0.85. There is very slight oscillatory behavior around x = 0.7 but it is limited. diff --git a/docs/sphinx/ChollaExamples/1D-Strong-Shock/snapshots_strongshock.png b/docs/sphinx/ChollaExamples/1D-Strong-Shock/snapshots_strongshock.png new file mode 100644 index 000000000..523b06a06 Binary files /dev/null and b/docs/sphinx/ChollaExamples/1D-Strong-Shock/snapshots_strongshock.png differ diff --git a/docs/sphinx/ChollaExamples/1D-Two-Shocks/original-two-shocks.png b/docs/sphinx/ChollaExamples/1D-Two-Shocks/original-two-shocks.png new file mode 100644 index 000000000..cfca69506 Binary files /dev/null and b/docs/sphinx/ChollaExamples/1D-Two-Shocks/original-two-shocks.png differ diff --git a/docs/sphinx/ChollaExamples/1D-Two-Shocks/overview.md b/docs/sphinx/ChollaExamples/1D-Two-Shocks/overview.md new file mode 100644 index 000000000..31cc4bb3f --- /dev/null +++ b/docs/sphinx/ChollaExamples/1D-Two-Shocks/overview.md @@ -0,0 +1,79 @@ +# 1D Two Shocks +This test highlights a collision between two shocks. This test is from Toro's *Riemann solvers and numerical methods for fluid dynamics* Sec. 6.4, test 4.The test consists of left and right states separated at x = 0.4 with velocities 19.5975 and -6.19633, respectively. Density of the left side is 5.99924 and pressure is 460.894. For the right side, density is 5.99242 while pressure is 46.095. Gamma is set to 1.4. This test is performed with the hydro build (`cholla/builds/make.type.hydro`). Full initial conditions can be found in `cholla/src/grid/initial_conditions.cpp`under `Riemann()`. + +The parameter file can be found at: {repository-file}`examples/1D/two_shocks.txt` + +## Parameter file: +``` +# +# Parameter File for Toro test 4, a collision of two shocks. +# Parameters derived from Toro, Sec. 6.4.4, test 4 +# + +################################################ +# number of grid cells in the x dimension +nx=100 +# number of grid cells in the y dimension +ny=1 +# number of grid cells in the z dimension +nz=1 +# final output time +tout=0.035 +# time interval for output +outstep=0.035 +# name of initial conditions +init=Riemann +# domain properties +xmin=0.0 +ymin=0.0 +zmin=0.0 +xlen=1.0 +ylen=1.0 +zlen=1.0 +# type of boundary conditions +xl_bcnd=3 +xu_bcnd=3 +yl_bcnd=0 +yu_bcnd=0 +zl_bcnd=0 +zu_bcnd=0 +# path to output directory +outdir=./ + +################################################# +# Parameters for 1D Riemann problems +# density of left state +rho_l=5.99924 +# velocity of left state +vx_l=19.5975 +vy_l=0.0 +vz_l=0.0 + +# pressure of left state +P_l=460.894 +# density of right state +rho_r=5.99242 +# velocity of right state +vx_r=-6.19633 +vy_r=0.0 +vz_r=0.0 +# pressure of right state +P_r=46.095 +# location of initial discontinuity +diaph=0.4 +# value of gamma +gamma=1.4 +``` +Upon completion, you should obtain 2 output files. The initial and final density, pressure, velocity, and internal energy (in code units) of the solution is shown below. Examples of how to extract and plot data can be found in the [General 1D Plotting Example](../../PythonExamples/1D-plotting.md). + +:::{figure} original-two-shocks.png +::: + +We see a shock, contact discontinuity, and a shock, which is in agreement with Toro's solution and can be seen below: + +:::{figure} toro-solution.png +:align: center +:width: 600 +:height: 400 +::: + diff --git a/docs/sphinx/ChollaExamples/1D-Two-Shocks/snapshots_twoshocks_v2.png b/docs/sphinx/ChollaExamples/1D-Two-Shocks/snapshots_twoshocks_v2.png new file mode 100644 index 000000000..d66a81627 Binary files /dev/null and b/docs/sphinx/ChollaExamples/1D-Two-Shocks/snapshots_twoshocks_v2.png differ diff --git a/docs/sphinx/ChollaExamples/1D-Two-Shocks/toro-solution.png b/docs/sphinx/ChollaExamples/1D-Two-Shocks/toro-solution.png new file mode 100644 index 000000000..c1003fc28 Binary files /dev/null and b/docs/sphinx/ChollaExamples/1D-Two-Shocks/toro-solution.png differ diff --git a/docs/sphinx/ChollaExamples/1d-blast/0.png b/docs/sphinx/ChollaExamples/1d-blast/0.png new file mode 100644 index 000000000..018c47135 Binary files /dev/null and b/docs/sphinx/ChollaExamples/1d-blast/0.png differ diff --git a/docs/sphinx/ChollaExamples/1d-blast/99.png b/docs/sphinx/ChollaExamples/1d-blast/99.png new file mode 100644 index 000000000..336e7dc9a Binary files /dev/null and b/docs/sphinx/ChollaExamples/1d-blast/99.png differ diff --git a/docs/sphinx/ChollaExamples/1d-blast/blast.png b/docs/sphinx/ChollaExamples/1d-blast/blast.png new file mode 100644 index 000000000..718ff4519 Binary files /dev/null and b/docs/sphinx/ChollaExamples/1d-blast/blast.png differ diff --git a/docs/sphinx/ChollaExamples/1d-blast/docs-blast.mp4 b/docs/sphinx/ChollaExamples/1d-blast/docs-blast.mp4 new file mode 100644 index 000000000..9bb5a18d7 Binary files /dev/null and b/docs/sphinx/ChollaExamples/1d-blast/docs-blast.mp4 differ diff --git a/docs/sphinx/ChollaExamples/1d-blast/overview.md b/docs/sphinx/ChollaExamples/1d-blast/overview.md new file mode 100644 index 000000000..b3b371835 --- /dev/null +++ b/docs/sphinx/ChollaExamples/1d-blast/overview.md @@ -0,0 +1,60 @@ +# 1D Blast Wave +This test is designed to assess the performance of a code near strong shocks and contact discontinuities. Parameters are derived from Woodward & Collela, 1984. The test consists of three regions. For x < 0.1, pressure is set to 1000.0. For x > 0.9, pressure is set to 100. Everywhere else, pressure is set to 0.01. Density is set to 1.0 everywhere and velocity everywhere is zero. Gamma is set to 1.4. This test is performed with the hydro build (`cholla/builds/make.type.hydro`) and Van Leer integrator. Full initial conditions can be found in `cholla/src/grid/initial_conditions.cpp`under `Blast_1D()`. + +The parameter file can be found at {repository-file}`examples/1D/blast_1D.txt` + +## Parameter File +``` +# +# Parameter File for the 1D interacting blast wave test from +# Woodward & Collela, 1984. See also Stone et al., 2008, Section 8.1 +# + +###################################### +# number of grid cells in the x dimension +nx=400 +# number of grid cells in the y dimension +ny=1 +# number of grid cells in the z dimension +nz=1 +# final output time +tout=0.038 +# time interval for output +outstep=0.00038 +# value of gamma +gamma=1.4 +# name of initial conditions +init=Blast_1D +# domain properties +xmin=0.0 +ymin=0.0 +zmin=0.0 +xlen=1.0 +ylen=1.0 +zlen=1.0 +# type of boundary conditions +xl_bcnd=2 +xu_bcnd=2 +yl_bcnd=0 +yu_bcnd=0 +zl_bcnd=0 +zu_bcnd=0 +# path to output directory +outdir=./ +``` +Upon completion, you should obtain 101 output files. The initial and final density, pressure, and velocity (in code units) of the solution is shown below. Examples of how to extract and plot data can be found in the [General 1D Plotting Example](../../PythonExamples/1D-plotting.md). + +We see a contact discontinuity around x = 0.6 followed by a shock at x = 0.65 and a rarefaction fan. We have a contact discontinuity just past x = 0.75 cells and a shock at x = 0.85. + +:::{figure} blast.png +::: + +We can also obtain the evolution: + +:::{video} docs-blast.mp4 + :width: 700 + :height: 500 + :align: center + :autoplay: + :loop: +::: diff --git a/docs/sphinx/ChollaExamples/2D-Disk/disk-docs.mp4 b/docs/sphinx/ChollaExamples/2D-Disk/disk-docs.mp4 new file mode 100644 index 000000000..33a8ddebf Binary files /dev/null and b/docs/sphinx/ChollaExamples/2D-Disk/disk-docs.mp4 differ diff --git a/docs/sphinx/ChollaExamples/2D-Disk/overview.md b/docs/sphinx/ChollaExamples/2D-Disk/overview.md new file mode 100644 index 000000000..d12d8fe56 --- /dev/null +++ b/docs/sphinx/ChollaExamples/2D-Disk/overview.md @@ -0,0 +1,56 @@ +# 2D Disk +This models the Milky Way's stellar disk following a Kuzmin profile. Gamma is set to 1.001. Full initial conditions can be found in `cholla/src/grid/initial_conditions.cpp`under `Disk_2D()`. This test is performed with the static gravity build (`cholla/builds/make.type.static_grav`) and Van Leer integrator. + +The parameter file can be found at: {repository-file}`examples/2D/disk.txt` + +## Parameter file: +``` +# +# Parameter File for a 2D disk in keplerian rotation. +# + +###################################### +# number of grid cells in the x dimension +nx=512 +# number of grid cells in the y dimension +ny=512 +# number of grid cells in the z dimension +nz=1 +# final output time +tout=1092950 +# time interval for output +outstep=2185.9 +# value of gamma +gamma=1.001 +# name of initial conditions +init=Disk_2D +# static gravity flag +custom_grav=4 +# domain properties +xmin=-20 +ymin=-20 +zmin=-20 +xlen=40 +ylen=40 +zlen=40 +# type of boundary conditions +xl_bcnd=3 +xu_bcnd=3 +yl_bcnd=3 +yu_bcnd=3 +zl_bcnd=3 +zu_bcnd=3 +# path to output directory +outdir=./ +``` +While the parameter file claims to be for a 2D disk in keplerian rotation (custom_grav = 3), the initial condition Disk_2D matches the ICs of custom_grav = 4. + +Upon completion, you should obtain 501 output files. (Note: when running with the Simple integrator, there is a thread crash. However, the Van Leer integrator is able to run the simulation to completion.) An evolution of the density is shown below. Examples of how to plot projections and slices can be found in the [General 2D plotting example](../../PythonExamples/2D-plotting.md). + +:::{video} disk-docs.mp4 + :width: 700 + :height: 500 + :align: center + :autoplay: + :loop: +::: \ No newline at end of file diff --git a/docs/sphinx/ChollaExamples/2D-Implosion/imp-docs.mp4 b/docs/sphinx/ChollaExamples/2D-Implosion/imp-docs.mp4 new file mode 100644 index 000000000..504fed8b3 Binary files /dev/null and b/docs/sphinx/ChollaExamples/2D-Implosion/imp-docs.mp4 differ diff --git a/docs/sphinx/ChollaExamples/2D-Implosion/liska-wendroff.png b/docs/sphinx/ChollaExamples/2D-Implosion/liska-wendroff.png new file mode 100644 index 000000000..3b3cd4a8e Binary files /dev/null and b/docs/sphinx/ChollaExamples/2D-Implosion/liska-wendroff.png differ diff --git a/docs/sphinx/ChollaExamples/2D-Implosion/overview.md b/docs/sphinx/ChollaExamples/2D-Implosion/overview.md new file mode 100644 index 000000000..6750c018a --- /dev/null +++ b/docs/sphinx/ChollaExamples/2D-Implosion/overview.md @@ -0,0 +1,64 @@ +# 2D Implosion +This tests a code's ability to resolve contact discontinuities for a non-grid aligned shock tube and can determine the symmetry of a code. It consists of a diamond region of density = 0.125 and pressure = 0.14 inside a square region of both density and pressure of 1. Parameters from Liska and Wendroff 2003. Gamma is set to 1.4. Full initial conditions can be found in `cholla/src/grid/initial_conditions.cpp`under `Implosion_2D()`.This test is performed with the default hydro build (`cholla/builds/make.type.hydro`). + +The parameter file can be found at: {repository-file}`examples/2D/Implosion_2D.txt` + +## Parameter file: +``` +# +# Parameter File for the 2D implosion test described in Liska, 2003. +# + +###################################### +# number of grid cells in the x dimension +nx=400 +# number of grid cells in the y dimension +ny=400 +# number of grid cells in the z dimension +nz=1 +# output time +tout=2.5 +# how often to output +outstep=0.01 +n_hydro=1 +# value of gamma +gamma=1.4 +# name of initial conditions +init=Implosion_2D +# domain properties +xmin=0.0 +ymin=0.0 +zmin=0.0 +xlen=0.3 +ylen=0.3 +zlen=0.3 +# type of boundary conditions +xl_bcnd=2 +xu_bcnd=2 +yl_bcnd=2 +yu_bcnd=2 +zl_bcnd=0 +zu_bcnd=0 +# path to output directory +outdir=./ +``` +Upon completion, you should obtain 251 output files. An evolution of the pressure overlaid with density contours is seen here at 10 fps. Examples of how to plot projections and slices can be found in the [General 2D plotting example](../../PythonExamples/2D-plotting.md). + +We see that a jet has appeared in the solution due to the high symmetry preservation of Cholla. We can quantify the perservation of symmetry in density over time by taking the sum over the full grid of the absolute value of $d_{ij}-d_{ji}$ across the line y = x. + +While the density remains highly symmetric through t = 1, symmetry drastically decreases with time. + +:::{video} imp-docs.mp4 + :width: 700 + :height: 500 + :align: center + :autoplay: + :loop: +::: + +We can compare this to the results of Liska and Wendroff (2003). Non-symmetry perserving codes, often employing Strang splitting, fail to produce the jet: + +:::{figure} liska-wendroff.png +::: + + diff --git a/docs/sphinx/ChollaExamples/2D-Kelvin-Helmholtz-Discontinuous/athena-khd.png b/docs/sphinx/ChollaExamples/2D-Kelvin-Helmholtz-Discontinuous/athena-khd.png new file mode 100644 index 000000000..954a30f66 Binary files /dev/null and b/docs/sphinx/ChollaExamples/2D-Kelvin-Helmholtz-Discontinuous/athena-khd.png differ diff --git a/docs/sphinx/ChollaExamples/2D-Kelvin-Helmholtz-Discontinuous/khd-plmc.mp4 b/docs/sphinx/ChollaExamples/2D-Kelvin-Helmholtz-Discontinuous/khd-plmc.mp4 new file mode 100644 index 000000000..d0cf2c5a5 Binary files /dev/null and b/docs/sphinx/ChollaExamples/2D-Kelvin-Helmholtz-Discontinuous/khd-plmc.mp4 differ diff --git a/docs/sphinx/ChollaExamples/2D-Kelvin-Helmholtz-Discontinuous/overview.md b/docs/sphinx/ChollaExamples/2D-Kelvin-Helmholtz-Discontinuous/overview.md new file mode 100644 index 000000000..83e199e3f --- /dev/null +++ b/docs/sphinx/ChollaExamples/2D-Kelvin-Helmholtz-Discontinuous/overview.md @@ -0,0 +1,62 @@ +# 2D Discontinuous Kelvin-Helmholtz Test +This test highlights the ability of a code to resolve mixing caused by shear flows, emphasizing the importance of an efficient, high order reconstuction method and a fast code. The level of mixing increases with the resolution. See Chandrasekhar 1961. It consists of a high density region (density = 1 and x velocity = 0.5) in the middle third of the grid sandwiched between two low density regions (density = 1 and x velocity = -0.5). Y-velocities are perturbed by a sine wave of amplitude 0.1. Pressure is 2.5 everywhere and gamma is set to 1.666667. Full initial conditions can be found in `cholla/src/grid/initial_conditions.cpp`under `KH()`.This test is performed with the default hydro build (`cholla/builds/make.type.hydro`) and Van Leer integrator. + +The parameter file can be found at: {repository-file}`examples/2D/KH_discontinuous_2D.txt` + +## Parameter file: +``` +# +# Parameter File for the 2D discontinuous Kelvin-Helmholtz test. +# + +###################################### +# number of grid cells in the x dimension +nx=256 +# number of grid cells in the y dimension +ny=256 +# number of grid cells in the z dimension +nz=1 +# final output time +tout=2.0 +# time interval for output +outstep=0.01 +n_hydro=1 +# value of gamma +gamma=1.666667 +# name of initial conditions +init=KH +# domain properties +xmin=0.0 +ymin=0.0 +zmin=0.0 +xlen=1.0 +ylen=1.0 +zlen=1.0 +# type of boundary conditions +xl_bcnd=1 +xu_bcnd=1 +yl_bcnd=1 +yu_bcnd=1 +zl_bcnd=0 +zu_bcnd=0 +# path to output directory +outdir=./ +``` +Upon completion, you should obtain 201 output files. The initial and final density (in code units) is shown below. Examples of how to plot projections and slices can be found in the [General 2D plotting example](../../PythonExamples/2D-plotting.md). +Density: +:::{figure} snapshots_khd.png +::: + +We see even on a relatively low resolution grid, significant shear mixing has occured. An evolution of the density at 10 fps is seen below: + +:::{video} khd-plmc.mp4 + :width: 700 + :height: 500 + :align: center + :autoplay: + :loop: +::: + + + + diff --git a/docs/sphinx/ChollaExamples/2D-Kelvin-Helmholtz-Discontinuous/snapshots_khd.png b/docs/sphinx/ChollaExamples/2D-Kelvin-Helmholtz-Discontinuous/snapshots_khd.png new file mode 100644 index 000000000..6251cd782 Binary files /dev/null and b/docs/sphinx/ChollaExamples/2D-Kelvin-Helmholtz-Discontinuous/snapshots_khd.png differ diff --git a/docs/sphinx/ChollaExamples/2D-Kelvin-Helmholtz-Resolution-Independent/khri_128.mp4 b/docs/sphinx/ChollaExamples/2D-Kelvin-Helmholtz-Resolution-Independent/khri_128.mp4 new file mode 100644 index 000000000..a58265892 Binary files /dev/null and b/docs/sphinx/ChollaExamples/2D-Kelvin-Helmholtz-Resolution-Independent/khri_128.mp4 differ diff --git a/docs/sphinx/ChollaExamples/2D-Kelvin-Helmholtz-Resolution-Independent/khri_256.mp4 b/docs/sphinx/ChollaExamples/2D-Kelvin-Helmholtz-Resolution-Independent/khri_256.mp4 new file mode 100644 index 000000000..a97d841c1 Binary files /dev/null and b/docs/sphinx/ChollaExamples/2D-Kelvin-Helmholtz-Resolution-Independent/khri_256.mp4 differ diff --git a/docs/sphinx/ChollaExamples/2D-Kelvin-Helmholtz-Resolution-Independent/overview.md b/docs/sphinx/ChollaExamples/2D-Kelvin-Helmholtz-Resolution-Independent/overview.md new file mode 100644 index 000000000..aa8531b9f --- /dev/null +++ b/docs/sphinx/ChollaExamples/2D-Kelvin-Helmholtz-Resolution-Independent/overview.md @@ -0,0 +1,73 @@ +# 2D Resolution Independent Kelvin-Helmholtz Test +This test highlights the ability of a code to resolve mixing caused by shear flows, emphasizing the importance of an efficient, high order reconstuction method and a fast code. In general, the level of mixing would increase with the resolution; however, this is a resolution independent version inspired by the test presented in Robertson et al. 2010. The test consists of a region of higher density (100) sandwiched between two regions of lower density (1.0). The high density layer has a velocity of 10.5 and the low density layers have a velocity of 9.5. Pressure is set to 2.5 and a 1% pertubation (amplitude of 0.1) is added to the high density layer to provoke the instability. Gamma is set to 1.6666666666666667. This test is performed with the default hydro build (`cholla/builds/make.type.hydro`) and Van Leer integrator. Full initial conditions can be found in `cholla/src/grid/initial_conditions.cpp`under `KH_res_ind()`. + +This parameter file can be found at: ({repository-file}`examples/2D/KKH_res_ind_2D.txt`) + +## Parameter File: +``` +# +# Parameter File for the 2D resolution independent Kelvin-Helmholtz test. +# + +###################################### +# number of grid cells in the x dimension +nx=128 +# number of grid cells in the y dimension +ny=128 +# number of grid cells in the z dimension +nz=1 +# final output time +tout=2.0 +# time interval for output +outstep=0.01 +# value of gamma +gamma=1.6666666666666667 +# name of initial conditions +init=KH_res_ind +# domain properties +xmin=0.0 +ymin=0.0 +zmin=0.0 +xlen=1.0 +ylen=1.0 +zlen=1.0 +# type of boundary conditions +xl_bcnd=1 +xu_bcnd=1 +yl_bcnd=1 +yu_bcnd=1 +zl_bcnd=0 +zu_bcnd=0 +# path to output directory +outdir=./ +``` + +Upon completion, you should obtain 201 output files. The initial and final densities for two different resolutions (in code units) of a slice along the y-midplane is shown below. Default resolution (128x128) is compared to a high-res version (256x256). Examples of how to plot projections and slices can be found in the [General 2D plotting example](../../PythonExamples/2D-plotting.md). + +:::{figure} snapshots_khri_128.png +::: + +:::{figure} snapshots_khri_256.png +::: + +The solution does appear to be independent of resolution. We can also compare the time evolution of the density at the above resolutions. + +128X128 +:::{video} khri_128.mp4 + :width: 700 + :height: 500 + :align: center + :autoplay: + :loop: +::: + +256X256 +:::{video} khri_256.mp4 + :width: 700 + :height: 500 + :align: center + :autoplay: + :loop: +::: + +The evolutions are almost identical during the linear regime. diff --git a/docs/sphinx/ChollaExamples/2D-Kelvin-Helmholtz-Resolution-Independent/snapshots_khri_128.png b/docs/sphinx/ChollaExamples/2D-Kelvin-Helmholtz-Resolution-Independent/snapshots_khri_128.png new file mode 100644 index 000000000..094ef2c91 Binary files /dev/null and b/docs/sphinx/ChollaExamples/2D-Kelvin-Helmholtz-Resolution-Independent/snapshots_khri_128.png differ diff --git a/docs/sphinx/ChollaExamples/2D-Kelvin-Helmholtz-Resolution-Independent/snapshots_khri_256.png b/docs/sphinx/ChollaExamples/2D-Kelvin-Helmholtz-Resolution-Independent/snapshots_khri_256.png new file mode 100644 index 000000000..c5b4554e4 Binary files /dev/null and b/docs/sphinx/ChollaExamples/2D-Kelvin-Helmholtz-Resolution-Independent/snapshots_khri_256.png differ diff --git a/docs/sphinx/ChollaExamples/2D-NOH/fyris-alpha.png b/docs/sphinx/ChollaExamples/2D-NOH/fyris-alpha.png new file mode 100644 index 000000000..b28c70d00 Binary files /dev/null and b/docs/sphinx/ChollaExamples/2D-NOH/fyris-alpha.png differ diff --git a/docs/sphinx/ChollaExamples/2D-NOH/noh-docs.mp4 b/docs/sphinx/ChollaExamples/2D-NOH/noh-docs.mp4 new file mode 100644 index 000000000..1f0d51329 Binary files /dev/null and b/docs/sphinx/ChollaExamples/2D-NOH/noh-docs.mp4 differ diff --git a/docs/sphinx/ChollaExamples/2D-NOH/overview.md b/docs/sphinx/ChollaExamples/2D-NOH/overview.md new file mode 100644 index 000000000..f2b921f9b --- /dev/null +++ b/docs/sphinx/ChollaExamples/2D-NOH/overview.md @@ -0,0 +1,59 @@ +# 2D Noh Strong Shock +This test highlights the ability of a code to track a high Mach number shock. Parameters from Liska and Wendroff 2003. The test consists of an infinitely strong circular shock radiating from the origin. There is initially a constant density of 1.0 across the grid and a velocity of 1.0 towards the center everywhere. Pressure is set to $10^{-6}$ everywhere. Gamma is set to 1.66666667. This test is performed with the default hydro build (`cholla/builds/make.type.hydro`) and Van Leer integrator. Full initial conditions can be found in `cholla/src/grid/initial_conditions.cpp`under `Noh_2D()`. + +The parameter file can be found at: {repository-file}`examples/2D/Noh_2D.txt` + +## Parameter file: + +``` +# +# Parameter File for the 2D Noh problem described in Liska, 2003. +# + +###################################### +# number of grid cells in the x dimension +nx=200 +# number of grid cells in the y dimension +ny=200 +# number of grid cells in the z dimension +nz=1 +# output time +tout=2.0 +# how often to output +outstep=0.01 +# value of gamma +gamma=1.66666667 +# name of initial conditions +init=Noh_2D +# domain properties +xmin=0.0 +ymin=0.0 +zmin=0.0 +xlen=1.0 +ylen=1.0 +zlen=1.0 +# type of boundary conditions +xl_bcnd=2 +xu_bcnd=4 +yl_bcnd=2 +yu_bcnd=4 +zl_bcnd=0 +zu_bcnd=0 +custom_bcnd=noh +# path to output directory +outdir=./ +``` +Upon completion, you should obtain 201 output files. The evolution of the density is shown below. Examples of how to plot projections and slices can be found in the [General 2D plotting example](../../PythonExamples/2D-plotting.md). + +:::{video} noh-docs.mp4 + :width: 700 + :height: 500 + :align: center + :autoplay: + :loop: +::: + +We can compare to the [Fyris Alpha code](https://www.mso.anu.edu.au/fyris/lw2dnoh.html): + +:::{figure} fyris-alpha.png +::: diff --git a/docs/sphinx/ChollaExamples/2D-Rayleigh-Taylor/2D-Rayleigh-Taylor.md b/docs/sphinx/ChollaExamples/2D-Rayleigh-Taylor/2D-Rayleigh-Taylor.md index 8746cd86e..e0eb2e623 100644 --- a/docs/sphinx/ChollaExamples/2D-Rayleigh-Taylor/2D-Rayleigh-Taylor.md +++ b/docs/sphinx/ChollaExamples/2D-Rayleigh-Taylor/2D-Rayleigh-Taylor.md @@ -3,9 +3,11 @@ This test demonstrates the mixing resulting from a dense fluid placed on top of a less dense fluid. The bottom half of the grid is given of density of 1.0 while the top has a value of 2.0. Y velocities across the grid are set as a small pertubation tapering off from the center. For both halves, pressure is initialized as decreasing with increasing y position. Gamma is set to 1.4. This test is performed with the static gravity build (`cholla/builds/make.type.static_grav`) and Van Leer integrator. Full initial conditions can be found in `cholla/src/grid/initial_conditions.cpp`under `Rayleigh_Taylor()`. +The parameter file can be found at: {repository-file}`examples/2D/Rayleigh_Taylor.txt` + ## Parameter file: -This parameter file can be found in [examples/2D/Rayleigh_Taylor.txt](https://github.com/cholla-hydro/cholla/blob/main/examples/2D/Rayleigh_Taylor.txt) on the `dev` branch. +Parameter file can be found on the `dev` branch. ``` # # Parameter File for the 2D Rayleigh-Taylor test. @@ -53,7 +55,7 @@ You must add the following lines to `src/gravity/static_grav.h` under the functi ``` Any other values assigned to `*gx` and `*gy` should be commented out. -Upon completion, you should obtain 101 output files. The initial, intermediate, and final density and pressure (in code units) is shown below. Examples of how to plot projections and slices can be found in `cholla/python_scripts/Projection_Slice_Tutorial.ipynb`. +Upon completion, you should obtain 101 output files. The initial, intermediate, and final density and pressure (in code units) is shown below. Examples of how to plot projections and slices can be found in the [General 2D plotting example](../../PythonExamples/2D-plotting.md). :::{figure} rayleigh_taylor_2D_xy.png Rayleigh-Taylor test solution from Cholla. ::: diff --git a/docs/sphinx/ChollaExamples/3D-Adiabatic-Expansion/3D-Adiabatic-Expansion.md b/docs/sphinx/ChollaExamples/3D-Adiabatic-Expansion/3D-Adiabatic-Expansion.md index 4e8cd1c63..cd57adcd0 100644 --- a/docs/sphinx/ChollaExamples/3D-Adiabatic-Expansion/3D-Adiabatic-Expansion.md +++ b/docs/sphinx/ChollaExamples/3D-Adiabatic-Expansion/3D-Adiabatic-Expansion.md @@ -54,7 +54,7 @@ indir=ics/ outdir=./ ``` -Upon completion, you should obtain two output files. The final density, velocity, and temperature in physical units are shown below. +Upon completion, you should obtain two output files. The final density, velocity, and temperature in physical units are shown below. Examples of how to plot projections and slices can be found in the [General 2D plotting example](../../PythonExamples/2D-plotting.md). :::{figure} adiabatic_expansion.png Adiabatic Expansion test solution from Cholla. ::: \ No newline at end of file diff --git a/docs/sphinx/ChollaExamples/Reconstruction-Methods/2D-KHD-figure.png b/docs/sphinx/ChollaExamples/Reconstruction-Methods/2D-KHD-figure.png new file mode 100644 index 000000000..e663a56bb Binary files /dev/null and b/docs/sphinx/ChollaExamples/Reconstruction-Methods/2D-KHD-figure.png differ diff --git a/docs/sphinx/ChollaExamples/Reconstruction-Methods/KHD-PLMP-PPMP.png b/docs/sphinx/ChollaExamples/Reconstruction-Methods/KHD-PLMP-PPMP.png new file mode 100644 index 000000000..0f8cba738 Binary files /dev/null and b/docs/sphinx/ChollaExamples/Reconstruction-Methods/KHD-PLMP-PPMP.png differ diff --git a/docs/sphinx/ChollaExamples/Reconstruction-Methods/comp-square-cp.mp4 b/docs/sphinx/ChollaExamples/Reconstruction-Methods/comp-square-cp.mp4 new file mode 100644 index 000000000..b536fed28 Binary files /dev/null and b/docs/sphinx/ChollaExamples/Reconstruction-Methods/comp-square-cp.mp4 differ diff --git a/docs/sphinx/ChollaExamples/Reconstruction-Methods/overview.md b/docs/sphinx/ChollaExamples/Reconstruction-Methods/overview.md new file mode 100644 index 000000000..584124097 --- /dev/null +++ b/docs/sphinx/ChollaExamples/Reconstruction-Methods/overview.md @@ -0,0 +1,54 @@ +# Reconstruction Methods + +Cholla utilizes finite volume methods (FVM) to solve the partial differential equations related to various hydrodynamics problems. In FVMs, the average values of each conserved quantity (i.e. density, momentum, energy) are stored in each cell. However, the cell-average quantities are updated in time using fluxes, which are calculated at cell interfaces. The reconstruction method determines what the input values for solving the Riemann problem at cell interfaces should be. + +This section will evaluate two piecewise linear methods (PLM) and one piecewise parabolic method (PPM). PLM is a second order reconstruction that models the shape of the fluid linearly, and thus and thus represents the fluid more accurately than a first-order method using the cell average values. PPM is a third order reconstruction method that models the fluids parabolically and can be useful in problems where PLM proves to be too diffusive. + +Cholla models the Euler equations for fluid dynamics. These equations can be represented by both primitive and characteristic variables. Primitive variables describe the physical state of the fluid: density, pressure, velocity. This is useful for initial value and boundary problems and is also easily applied to FVMs and is computationally less expensive. Characteristic variables can be derived from diagonalizing the Jacobian matrix of the flux function. The characteristic variables represent the amplitude of waves moving at speeds defined by the eigenvalues (wave strength). This process decouples the Euler equations and allows for more accuracy when simulating shocks and instabilities as you are able to obtain information regarding left and right moving waves. + +Below are comparisons of the piecewise linear method using primitive variables (PLMP) with the charactristic variables (PLMC) as well as the piecewise parabolic method (PPMP). + + +**PLMC vs PLMP** + +1D Example: + +:::{video} comp-square-cp.mp4 + :width: 700 + :height: 500 + :align: center + :autoplay: + :loop: +::: + +This movie shows the evolution of the square wave test with both the PLMC and PLMP results plotted in the same set of axes. We can see here that there are no significant differences between these two methods and that they give essentially the same results. The evaluated differences were shown to be on the order of 10e-15. + +2D Example: +:::{figure} 2D-KHD-figure.png +:align: center +::: + +In this example, we are comparing the final snapshot of the Kelvin-Helmholtz Discontinuous tests using both PLMC and PLMP. We see that while the PLMP reconstruction is slightly more diffusive than the PLMC as the PLMC method has a higher accuracy for instabilities. The overall result, however, differs only minorly and an accurate result can be achieved with the PLMP reconstruction. + + +**PLMP vs PPMP** + +1D Example: + +:::{video} square-comp-pp.mp4 + :width: 700 + :height: 500 + :align: center + :autoplay: + :loop: +::: + +This movie shows the evolution of the square wave test with both the PLMP and PPMP reconstructions. As opposed to the initial comparison of the PLMP and PLMC reconstructions, there is a more significant difference in these simulations. The PPMP simulation maintains steeper edges of the curve whereas the PLMP falls off more gradually at the edges. + +2D Example: + +:::{figure} KHD-PLMP-PPMP.png +:align: center +::: + +In this example, we are comparing the final snapshot of the Kelvin-Helmholtz Discontinuous tests using both PLMP and PPMP. The difference between these two methods is much more apparent than what is observed between the PLMC and PLMP methods. For this instability, although the general shape of the fluids remain the same, the PPMP result is more evolved within the same time constraint. \ No newline at end of file diff --git a/docs/sphinx/ChollaExamples/Reconstruction-Methods/square-comp-pp.mp4 b/docs/sphinx/ChollaExamples/Reconstruction-Methods/square-comp-pp.mp4 new file mode 100644 index 000000000..438b70ce0 Binary files /dev/null and b/docs/sphinx/ChollaExamples/Reconstruction-Methods/square-comp-pp.mp4 differ diff --git a/docs/sphinx/ChollaExamples/index.md b/docs/sphinx/ChollaExamples/index.md index 81758c04d..923ca313e 100644 --- a/docs/sphinx/ChollaExamples/index.md +++ b/docs/sphinx/ChollaExamples/index.md @@ -8,7 +8,19 @@ Continue porting me from the [wiki](https://github.com/cholla-hydro/cholla/wiki/ :maxdepth: 1 1D-123-Test/overview +1D-Sod/overview +1d-blast/overview +1D-Shu-Osher/overview +1D-Square-Wave/overview +1D-Sound-Wave/overview +1D-Strong-Shock/overview +1D-Two-Shocks/overview +2D-Disk/overview +2D-NOH/overview +2D-Implosion/overview 2D-Rayleigh-Taylor/2D-Rayleigh-Taylor +2D-Kelvin-Helmholtz-Discontinuous/overview +2D-Kelvin-Helmholtz-Resolution-Independent/overview 3D-Adiabatic-Expansion/3D-Adiabatic-Expansion.md +Reconstruction-Methods/overview ::: - diff --git a/docs/sphinx/PythonExamples/1D-plotting.md b/docs/sphinx/PythonExamples/1D-plotting.md new file mode 100644 index 000000000..e7c624e6a --- /dev/null +++ b/docs/sphinx/PythonExamples/1D-plotting.md @@ -0,0 +1,55 @@ +# General 1D Plotting Example + +Here is an example python script for making plots of a 1D simulation. + +```python +import h5py +import numpy as np +import matplotlib +matplotlib.rcParams['mathtext.default']='regular' +matplotlib.rcParams['xtick.direction']='in' +matplotlib.rcParams['ytick.direction']='in' +matplotlib.rcParams['xtick.top']=True +matplotlib.rcParams['ytick.right']=True +import matplotlib.pyplot as plt + +dnamein='./output/' #input data file +dnameout='./pngs/' #where your image will be stored + +DE = 0 # dual energy flag - 1 if the test was run with dual energy +i = 1 # output file number + +#iterate through each output simulation file +for i in range(0,100): + f = h5py.File(dnamein+str(i)+'/'+str(i)+'.h5.0', 'r') + head = f.attrs + nx = head['dims'][0] + gamma = head['gamma'][0] + d = np.array(f['density']) # mass density + mx = np.array(f['momentum_x']) # x-momentum + my = np.array(f['momentum_y']) # y-momentum + mz = np.array(f['momentum_z']) # z-momentum + E = np.array(f['Energy']) # total energy density + vx = mx/d + vy = my/d + vz = mz/d + + time = head['t'][0] + + p = (E - 0.5*d*(vx*vx + vy*vy + vz*vz)) * (gamma - 1.0) + ge = p/d/(gamma - 1.0) + + #plotting + fig = plt.figure(figsize=(10,6)) + plt.axis([0, nx, 0,2]) + plt.plot(d, 'o', markersize=2, color='black') + plt.ylabel('Density') + plt.xlabel('Position') + + plt.tight_layout(rect=[0,0,1,0.95]) + + plt.suptitle(f't = {time:.2f}', fontsize=12) + + #save each png to your image file + plt.savefig(dnameout+str(i)+".png", dpi=300); + plt.close(fig) diff --git a/docs/sphinx/PythonExamples/2D-plotting.md b/docs/sphinx/PythonExamples/2D-plotting.md new file mode 100644 index 000000000..0b47602e9 --- /dev/null +++ b/docs/sphinx/PythonExamples/2D-plotting.md @@ -0,0 +1,60 @@ +# General 2D plotting example + +Here is an example python script for making a 2D density plot. + +```python +import numpy as np +import matplotlib +import matplotlib.pyplot as plt +import h5py +from mpl_toolkits.axes_grid1 import make_axes_locatable + +dnamein='./output/' # directory where the file is located +dnameout='./pngs/' # directory where the plot will be saved + +DE = 0 +i = 0 + +mp = 1.672622e-24 # mass of hydrogen atom, in grams +kb = 1.380658e-16 # Boltzmann constant in ergs/K + +for i in range(0, 200): + f = h5py.File(dnamein + str(i) + '/' + str(i) + '.h5.0', 'r') + head = f.attrs + + gamma = head['gamma'] # ratio of specific heats + t = head['t'] # time of this snapshot, in kyr + nx = head['dims'][0] # number of cells in the x direction + ny = head['dims'][1] # number of cells in the y direction + nz = head['dims'][2] # number of cells in the z direction + dx = head['dx'][0] # width of cell in x direction + dy = head['dx'][1] # width of cell in y direction + dz = head['dx'][2] # width of cell in z direction + l_c = head['length_unit'] + t_c = head['time_unit'] + m_c = head['mass_unit'] + d_c = head['density_unit'] + v_c = head['velocity_unit'] + e_c = head['energy_unit'] + p_c = e_c # pressure uses same unit as energy density + + d = f['density'][:] + p = f['pressure'][:] + + time = head['t'][0] + + mu = 1.0 # mean molecular weight + + # n = number density (particles/cm^3) + n = d / (mu * mp) + + #vmin and vmax depend on the simulation. reference the documented examples + + image = plt.imshow(d.T, origin='lower', cmap='viridis', vmin=1.8, vmax=2.8) + + cb = plt.colorbar(image, ticks=np.arange(1.8, 2.8, 0.2), label='density') + + plt.suptitle(f't={time:.2f}', fontsize=12) + + plt.savefig(dnameout + str(i) + ".png", dpi=300) + plt.close() diff --git a/docs/sphinx/PythonExamples/KHD-plot.md b/docs/sphinx/PythonExamples/KHD-plot.md new file mode 100644 index 000000000..a39383e81 --- /dev/null +++ b/docs/sphinx/PythonExamples/KHD-plot.md @@ -0,0 +1,62 @@ +# KHD Plotting Script + +The output of this script should be 199 pngs. + +```python +import numpy as np +import matplotlib +import matplotlib.pyplot as plt +import h5py +from mpl_toolkits.axes_grid1 import make_axes_locatable + +dnamein='./directory_name/' # directory where the file is located +dnameout='./png_output_directory/' # directory where the plot will be saved + +DE = 0 +i = 0 + +mp = 1.672622e-24 # mass of hydrogren atom, in grams +kb = 1.380658e-16 # boltzmann constant in ergs/K + +for i in range(0,200): + f = h5py.File(dnamein+str(i)+'/'+str(i)+'.h5.0', 'r') + head = f.attrs + + + gamma = head['gamma'] # ratio of specific heats + t = head['t'] # time of this snapshot, in kyr + nx = head['dims'][0] # number of cells in the x direction + ny = head['dims'][1] # number of cells in the y direction + nz = head['dims'][2] # number of cells in the z direction + dx = head['dx'][0] # width of cell in x direction + dy = head['dx'][1] # width of cell in y direction + dz = head['dx'][2] # width of cell in z direction + l_c = head['length_unit'] + t_c = head['time_unit'] + m_c = head['mass_unit'] + d_c = head['density_unit'] + v_c = head['velocity_unit'] + e_c = head['energy_unit'] + p_c = e_c # pressure units are the same as energy density units, density*velocity^2/length^3 + + d = f['density'][:] + p = f['pressure'][:] + + time = head['t'][0] + + mu = 1.0 # mean molecular weight (mu) of 1 + + # d = d*d_c # to convert from code units to cgs, multiply by the code unit for that variable + + n = d/(mu*mp) # number density, particles per cm^3 + + + image = plt.imshow(p.T,origin='lower',cmap='viridis', vmin=1.8, vmax=2.8) + + cb = plt.colorbar(image, ticks=np.arange(1.8,2.8,0.2),label='pressure') + + plt.suptitle(f't={time:.2f}',fontsize=12) + + plt.savefig(dnameout + str(i)+".png", dpi=300) # You can adjust the dpi for quality + plt.close() + \ No newline at end of file diff --git a/docs/sphinx/PythonExamples/Square-Wave-plot.md b/docs/sphinx/PythonExamples/Square-Wave-plot.md new file mode 100644 index 000000000..bbb281e0d --- /dev/null +++ b/docs/sphinx/PythonExamples/Square-Wave-plot.md @@ -0,0 +1,56 @@ +# Square Wave Plotting Script + +The output of this script should be 99 pngs. + +```python +import h5py +import numpy as np +import matplotlib +matplotlib.rcParams['mathtext.default']='regular' +matplotlib.rcParams['xtick.direction']='in' +matplotlib.rcParams['ytick.direction']='in' +matplotlib.rcParams['xtick.top']=True +matplotlib.rcParams['ytick.right']=True +import matplotlib.pyplot as plt + +dnamein='./output/' +dnameout='./pngs/' + +DE = 0 # dual energy flag - 1 if the test was run with dual energy +i = 1 # output file number + +for i in range(0,100): + f = h5py.File(dnamein+str(i)+'/'+str(i)+'.h5.0', 'r') + head = f.attrs + nx = head['dims'][0] + gamma = head['gamma'][0] + d = np.array(f['density']) # mass density + mx = np.array(f['momentum_x']) # x-momentum + my = np.array(f['momentum_y']) # y-momentum + mz = np.array(f['momentum_z']) # z-momentum + E = np.array(f['Energy']) # total energy density + vx = mx/d + vy = my/d + vz = mz/d + + time = head['t'][0] + + + + p = (E - 0.5*d*(vx*vx + vy*vy + vz*vz)) * (gamma - 1.0) + ge = p/d/(gamma - 1.0) + + fig = plt.figure(figsize=(6,4)) + plt.axis([0, nx, 0.8,1.8]) + plt.plot(d, 'o', markersize=3, color='blueviolet') + plt.ylabel('Density') + plt.xlabel('Position') + + plt.tight_layout(rect=[0,0,1,0.95]) + + plt.suptitle(f't = {time:.2f}', fontsize=12) + + plt.savefig(dnameout+str(i)+".png", dpi=300); + plt.close(fig) + + diff --git a/docs/sphinx/PythonExamples/index.md b/docs/sphinx/PythonExamples/index.md index eaacb5532..194ff5711 100644 --- a/docs/sphinx/PythonExamples/index.md +++ b/docs/sphinx/PythonExamples/index.md @@ -8,5 +8,9 @@ If we just want a single tutorial, then maybe we should remove this page and lin :::{toctree} :maxdepth: 1 +1D Plotting <1D-plotting.md> +2D Plotting <2D-plotting.md> Basic Tutorial +Kelvin-Helmholtz Discontinuous Plotting +Square Wave Plotting ::: diff --git a/docs/sphinx/conf.py b/docs/sphinx/conf.py index 81a3bfbc1..97652d888 100644 --- a/docs/sphinx/conf.py +++ b/docs/sphinx/conf.py @@ -35,6 +35,7 @@ extensions = [ 'myst_parser', 'nbsphinx', + 'sphinxcontrib.video', 'sphinx.ext.autodoc', 'sphinx.ext.autosummary', 'sphinx.ext.napoleon', @@ -55,6 +56,8 @@ "cli_help", ] + + source_suffix = [".rst", ".md"] # Add any paths that contain templates here, relative to this directory. diff --git a/pyproject.toml b/pyproject.toml index de200612d..143299ba6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,7 +31,8 @@ docs = [ 'nbsphinx', 'sphinx', 'sphinx-inline-tabs', - 'sphinx-autodoc-typehints' + 'sphinx-autodoc-typehints', + 'sphinxcontrib.video' ] test = ['pytest'] dev = [