---
# System prepended metadata

title: A Spectral Method for GAMER

---

# A Spectral Method for GAMER

## The problem 

![](https://i.imgur.com/cbyO2vN.png)
![](https://i.imgur.com/OoKEie6.png)

## Solution through hybrid scheme?

### Run with only one level using the wave scheme
![](https://i.imgur.com/uO4TOqU.png)

### Run with two levels using the wave scheme
![](https://i.imgur.com/UrBp4va.png)

# Goal 
- Find a better algorithm to evolve the Schrödinger equation 
- Finite Difference, Finite Element, Spectral methods

## Spectral methods
- Expand solutions in terms of a basis of orthogonal functions
- Fourier: trigonometric polynomials
- Chebyshev: Chebyshev polynomials 

### Can we use Fourier in each patch? Gibbs phenomenon!

![](https://i.imgur.com/7CYZxfG.png)

### Can we use a polynomial reconstruction in each patch? Runge phenomenon!

![](https://i.imgur.com/Aj3Wymk.png)

### Chebyshev is the solution?!

![](https://i.imgur.com/2dqzSYX.png)


## I want to keep using a uniform grid!
- Polynomial subtraction
- Inverse polynomial reconstruction 
- Gegenbauer method
- Polynomial least squares
- Fourier-Padé methods
- Filters and Mollifiers
- etc. 

## My method of choice: Gram-Fourier extension


### Step 1: Fourier extensions

![](https://i.imgur.com/3fnmrPK.png)
![](https://i.imgur.com/nzEipUm.png)

### Step 2: Approximation at the boundary with orthogonal polynomials

![](https://i.imgur.com/CFEYGFf.png)
![](https://i.imgur.com/3dSXsCQ.png)

## Step 3: Apply extension to orthogonal polynomials

![](https://i.imgur.com/jmMszJZ.png)
![](https://i.imgur.com/IehRrLc.png)


### The algorithm
1. Expand real and imaginary part in polynomial basis at boundaries
    - The boundaries are not the same as GAMER's ghost boundaries 
3. Continue polynomials using precomputed periodic extensions
    - The information in the extension is unphysical
    - We do not use information from neighbouring patches
4. Use FFT on extended domain to evolve wave function
    - Wave function is periodic on extended domain
    - We largely avoid the Gibb's phenomenon because the extension is very smooth 
5. Discard extended domain 

### Computational cost
- Small matrix ( 10x10 ) 
## Problem: Spectral blocking leads to instabilities!

![](https://i.imgur.com/IBrBHks.png)

## The restriction mismatch test

### The finite-difference wave scheme

![](https://i.imgur.com/upOdeqn.png)
![](https://i.imgur.com/44vdYFX.png)

### Finite-difference + Base-level spectral 

![](https://i.imgur.com/eVkzjm2.png)
![](https://i.imgur.com/MTLbiYk.png)

### Gram-FE + Base-level spectral 

![](https://i.imgur.com/lDZxbNe.png)
![](https://i.imgur.com/HCuMEjR.png)

## Accuracy tests

### Vortex pair test

![](https://i.imgur.com/OSv18oh.jpg)
![](https://i.imgur.com/4ACvrjL.jpg)

#### A nice animation

![](https://i.imgur.com/zADuuyU.gif)

### Gaussian wave test

![](https://i.imgur.com/qt1IQYU.png)
![](https://i.imgur.com/T8PERDD.png)


#### A nice animation

![](https://i.imgur.com/sbiUADD.gif)

## Comparison with base-level spectral solver 

![](https://i.imgur.com/mdO0WUc.png)

- Convergence for FFT-based base-level solver with 2 points per wavelength
- Gram FC reaches same accuracy only with roughly 15 points per wavelength
- FD needs many more
- error of 1e-3 for 6 points per wavelength 

## Soliton 

### Finite-difference scheme with two refinement levels (inbuilt test case)

#### No minimum density

![](https://i.imgur.com/TahU9Kt.png)

![](https://i.imgur.com/sYJnXbS.png)

#### With minimum density

![](https://i.imgur.com/VdjQxBU.png)

### Gram-Fourier extension (with minimum density) 

![](https://i.imgur.com/FvV46mT.png)

![](https://i.imgur.com/2IOUkrg.png)

### Gram-Fourier extension only base-level (with minimum density) 

![](https://i.imgur.com/x6qcrhi.png)
![](https://i.imgur.com/LwZQh54.png)


## Cosmological simulation
### Hybrid spectral fluid scheme

![](https://i.imgur.com/IZ4yogU.png)

### Problem: Pure spectral scheme still suffers from artifacts

![](https://i.imgur.com/B6NnRb2.png)


### Why? Lohner criterion does not enforce 5 - 6 points per wavelength

![](https://i.imgur.com/zVD7W1K.png)
