Skip to content

Example Execution

Steven Hahn edited this page Mar 21, 2024 · 35 revisions

Build ASGarD with -DASGARD_USE_MATLAB=ON or no output will be displayed!

Example PDE using the 1D Diffusion Equation with a manufactured solution.

PDE: $\frac{df}{dt} = \frac{d^2 f}{dx^2} -\frac{\pi^2}{4}\exp(-\frac{\pi^2}{2})\cos(\frac{\pi x}{2})$

Analytic solution: $\cos(\frac{\pi \cdot x}{2}) \exp(-\frac{\pi^2 \cdot t}{2})$

First, run ASGarD selecting the diffusion_1 PDE, implicit time advance, 1 time step, and real-space output every 1 time step.

./asgard -p diffusion_1 -i -n 1 --plot_freq 1

This matches the analytic solution at t=0. $f(0,0) = 1$ and $f(1,0) = 0$.

diffusion_1

Next, run for 1000 time-steps. After each calculation the figure will be updated.

./asgard -p diffusion_1 -i -n 1000 --plot_freq 10

diffusion_1_1000

The final figure shows $f(0,t)$ decreasing with time, matching the analytic solution.

Lastly, let's increase the precision of this calculation. Increasing the number of legendre basis polynomials (-d) and the starting (-l) and maximum (-m) hierarchical levels (resolution) results in a denser grid.

./asgard -p diffusion_1 -n 1 -d 3 -l 4 -m 4 --plot_freq 1

diffusion_1_d3_l4

./asgard -p diffusion_1 -n 1000 -d 3 -l 4 -m 4 --plot_freq 10

diffusion_1_d3_l4_1000

Lastly, let's enable adaptivity with the --adapt option and set --thresh 1e-4.

 ./asgard -p diffusion_1 -n 1 -d 3 -l 5 -m 10 --adapt --thresh 1e-4 --plot_freq 1

diffusion_1_adaptivity

The refined grid contains 12 elems or 36 DOF. Compared with the full grid solution

 ./asgard -p diffusion_1 -n 1 -d 3 -l 5 -m 10 -f --plot_freq 1

diffusion_1_fg

DOF / FG DOF = 36/96 = 0.375

  • 2D Continuity Equation

  • the plotted result may be transposed. See issue #675

Consider the continuity equation in two dimensions

$\frac{\partial f}{\partial t} + \frac{\partial f}{\partial x} + \frac{\partial f}{\partial y} = 2 \sin(2 \pi x) \cos(2t) + \cos(\pi y) \sin(2 t)$

with analytic solution

$f(x,y,t) = \cos(\pi x)\cos(2 \pi y)\sin(2t)$

Note that this solution is a function in $(x,y)$ that is scaled in time.

Use the -p continuity_2 option to select the 2D continuity equation. Let's start with a higher precision calculation. Notice that in 2 dimensions and the starting (-l) hierarchical levels (resolution) takes a string containing two values.

First, start with -n 1 to get the initial values at t=0.

./asgard -p continuity_2 -n 1 -d 3 -l "4 4" -m 4 --plot_freq 1

continuity_2d_min

Note we are in agreement with of analytic solution of 0.

Next, we run for 627 time steps, which should display the greatest amplitude.

./asgard -p continuity_2 -n 627 -d 3 -l "4 4" -m 4 --plot_freq 1

The slices are slightly offset from 0. At $y=0.125$, we see the amplitude matches $\cos(2 \cdot \pi \cdot 0.125) = 0.707$ At $x=0.0625$, we see the amplitude matches $\cos(\pi \cdot 0.0625) = 0.981$.

continuity_2d_max

Comparing sparse grid and full grid (-f) solutions, we observe 432 vs 2304 degrees of freedom. The relative difference between the numeric and analytic solution is 1.055% and 0.065%, respectively.

  • 6D Continuity Equation $f = f(x,y,z,v_x,v_y,v_z)$ where

$\frac{\partial f}{\partial t} + \frac{\partial f}{\partial x} + \frac{\partial f}{\partial y} + 3\frac{\partial f}{\partial z} + 4\frac{\partial f}{\partial v_x} + 3\frac{\partial f}{\partial v_y} + 2\frac{\partial f}{\partial v_z} = S$

and

$$ \begin{aligned} S = & 2 \cos(\pi x)\sin(\frac{pi y}{2})\cos(\frac{\pi z}{3})\cos(\frac{\pi vx}{10})\cos(\frac{\pi vy}{20})\cos(\frac{\pi vz}{30})\cos(2t) + \\ & \frac{\pi}{2}\cos(\pi x)\cos(\frac{pi y}{2})\cos(\frac{\pi z}{3})\cos(\frac{\pi vx}{10})\sin(\frac{\pi vy}{20})\cos(\frac{\pi vz}{30})\sin(2t) - \\ &\pi \sin(\pi x)\sin(\frac{pi y}{2})\cos(\frac{\pi z}{3})\cos(\frac{\pi vx}{10})\sin(\frac{\pi vy}{20})\cos(\frac{\pi vz}{30})\sin(2t) - \\ &\pi \cos(\pi x)\sin(\frac{pi y}{2})\sin(\frac{\pi z}{3})\cos(\frac{\pi vx}{10})\sin(\frac{\pi vy}{20})\cos(\frac{\pi vz}{30})\sin(2t) + \\ &\frac{3\pi}{20}\cos(\pi x)\sin(\frac{pi y}{2})\cos(\frac{\pi z}{3})\cos(\frac{\pi vx}{10})\cos(\frac{\pi vy}{20})\cos(\frac{\pi vz}{30})\sin(2t) - \\ &\frac{2 \pi}{5}\cos(\pi x)\sin(\frac{pi y}{2})\cos(\frac{\pi z}{3})\sin(\frac{\pi vx}{10})\sin(\frac{\pi vy}{20})\cos(\frac{\pi vz}{30})\sin(2t) - \\ &\frac{\pi}{15}\cos(\pi x)\sin(\frac{pi y}{2})\cos(\frac{\pi z}{3})\cos(\frac{\pi vx}{10})\sin(\frac{\pi vy}{20})\sin(\frac{\pi vz}{30})\sin(2t) \end{aligned} $$

This can be solved for 60 timesteps, degree 3 with the following command-line arguments

./asgard -p continuity_6 -n 60 -d 3 

The corresponding full-grid calculation can be solved with the following command-line arguments

./asgard -p continuity_6 -n 60 -d 3 -f

Comparing sparse and full grid solutions, we use 24786 and 2985984 DOF. The relative difference between the numeric andanalytic solution is 0.159% and 0.003%, respectively.

  • Vlasov Problem

  • this currently fails to converge with KRON_MODE_GLOBAL=ON

  • the plotted result may be transposed. See issue #675

We now solve the Sod Shock Tube example of the Vlasov-Lenard-Bernstein Equation

$\frac{\partial f}{\partial t} + v \frac{\partial f}{\partial x} = \nu \frac{\partial}{\partial v}( (v-u_f) f + \theta_f \frac{\partial f}{\partial v}) $

where $u_f$ and $\theta_f$ are the bulk-velocity and temperature of the distribution $f(x,v,t)$ and $\nu>0$ is the collision frequency.

./asgard -p vlasov -d 3 -l "6 5" -x -t 8e-4 -n 125 -m 6 --kron-mode dense --wave_freq 25 --inner_it 50 --tol 1e-6 --adapt --max_adapt_levels "6 5" --thresh 1e-4

vlasov

Clone this wiki locally