Skip to content

Example Execution

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

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

Example PDE using the 1D Diffusion Equation. This example PDE is time dependent (although not all the terms are time dependent). This implies the need for an initial condition.

PDE: $\frac{df}{dt} = \frac{d^2 f}{dx^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

Consider the continuity equation in two dimensions

$\frac{df}{dt} + v_x \cdot \frac{df}{dx} + v_y \cdot \frac{df}{dy} = 0$

with analytic solution

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

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

We note that the y-axis is multiplied $\pm10^{-3}$ and therefore is 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 4"

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

Clone this wiki locally