In [1]:
%matplotlib inline
%load_ext autoreload
%autoreload 2
In [2]:
import numpy as np
from pic1d2v import *
import matplotlib.pyplot as plt
from matplotlib import animation
from collections import namedtuple
I am doing this by taking a look at the potential and corresponding electric fields. For the FD solver, where $\phi_0=\phi_L=0$ we expect to see that $\phi$ is linear on each side of the point particle. For the FFT solver we expect the potential to be linear close to the point particle. Interactions with periodic neighboors will cause a curve.
In [3]:
fac = 1
nx = int(512*fac)
L = 2*np.pi*fac
dx = L/nx
x_vals = np.linspace(0, L, nx+1)[:-1]
e_loc = L*1/4
i_loc = L*3/4
electron = Species(-1., 1., 1,
np.array((e_loc,)),
np.zeros(1), np.zeros(1))
ion = Species( 1., 1., 1,
np.array((i_loc,)),
np.zeros(1), np.zeros(1))
In [4]:
q_vals = np.zeros(2)
q_vals[0] = electron.q
q_vals[1] = ion.q
x = np.array((electron.x0, ion.x0))
wx = weight(x, q_vals, nx, L, method="CIC")
phi_fft = poisson_solve_fft(wx, dx)
phi_fd = poisson_solve_fd(wx, dx)
plt.subplot(1,2,1)
plt.plot(phi_fft); plt.plot(phi_fd);
plt.subplot(1,2,2)
plt.plot(calc_E(phi_fft, dx)); plt.plot(calc_E(phi_fd, dx));
In [5]:
plt.plot(wx)
Out[5]:
In [5]: