Exemple #1
0
    def take_step(self):

        # first half of potential phase rotation
        for j in range(self.N):
            self.psi[j] *= self.V_exp_factor[j]

        # FFT to momentum space
        self.psi = cpt.fft(self.psi)

        # kinetic phase rotation
        for j in range(self.N):
            self.psi[j] *= self.T_exp_factor[j]

        # FFT back to position space
        do_inverse = True
        self.psi = cpt.fft(self.psi, do_inverse)

        # second half of potential phase rotation
        for j in range(self.N):
            self.psi[j] *= self.V_exp_factor[j]

        self.t += self.dt
Exemple #2
0
    def take_step(self):

        # first half of potential phase rotation
        for j in range(self.N):
            self.psi[j] *= self.V_exp_factor[j]

        # FFT to momentum space
        self.psi = cpt.fft(self.psi)

        # kinetic phase rotation
        for j in range(self.N):
            self.psi[j] *= self.T_exp_factor[j]

        # FFT back to position space
        do_inverse = True
        self.psi = cpt.fft(self.psi, do_inverse)

        # second half of potential phase rotation
        for j in range(self.N):
            self.psi[j] *= self.V_exp_factor[j]

        self.t += self.dt
Exemple #3
0
q = 10.0                        # point charge
jq = kq = int(N / 2)            # at center of lattice
rho = cpt.Matrix(N, N)
for j in range(N):
    for k in range(N):
        if j == jq and k == kq:
            rho[j][k] = q / h**2
        else:
            rho[j][k] = 0.0

# FFT rows of rho
f = [ 0.0 ] * N                 # to store rows and columns
for j in range(N):
    for k in range(N):
        f[k] = rho[j][k]
    f = cpt.fft(f)
    for k in range(N):
        rho[j][k] = f[k]

# FFT columns of rho
for k in range(N):
    for j in range(N):
        f[j] = rho[j][k]
    f = cpt.fft(f)
    for j in range(N):
        rho[j][k] = f[j]

# Solve equation in Fourier space
V = cpt.Matrix(N, N)
W = cmath.exp(1.0j * 2 * math.pi / N)
Wm = Wn = 1.0 + 0.0j