Exemplo n.º 1
0
def kChange(start, stop, step, show=False):
    k_range = np.arange(start, stop, step)

    E_list = energy2(k_range, hbar, m, sig)
    Es_list = []
    for i in k_range:
        Psi_x = gauss_init(x, i, x0=x0, d=sig)
        sch = Schrodinger(x, Psi_x, V_x, hbar=hbar, m=m, t=0)
        Es_list.append(sch.energy())

    Diff_list = [Es_list[j] - E_list[j] for j in range(len(k_range))]

    plt.figure()
    plt.plot(k_range, E_list, label="Theoretical")
    plt.plot(k_range, Es_list, label="Simulated", linestyle="--")
    plt.title("k0")
    plt.legend()
    plt.xlabel("k0")
    plt.ylabel("Energy")
    plt.savefig("k0.png")
    if show:
        plt.show()

    plt.figure()
    plt.plot(k_range, Diff_list, label="Diff")
    plt.title("k0_Diff")
    plt.legend()
    plt.xlabel("k0")
    plt.ylabel("k0_Difference")
    plt.savefig("k0_diff.png")
    if show:
        plt.show()
Exemplo n.º 2
0
def run(Ns, step, dt, acc, c):
    args = (m, omega, acc, x0, c)
    v = harmonic_potential(x, t, args=args)
    sch = Schrodinger(x, psi_x, v, k, hbar=hbar, m=m, t=0, args=args)
    for i in range(Ns):
        sch.evolve_t(N_steps=step, dt=dt)
    return sch.expectation_x()
Exemplo n.º 3
0
def T_g(V0, omeg):
    v = gaussianBarrier(x, 0, omeg, V0)
    E = scale * 10**3
    k0 = np.sqrt(2 * m * E / (hbar**2) - 1 / (4 * sig**2))
    psi_x = gauss_init(x, k0, x0, d=sig)
    sch = Schrodinger(x, psi_x, v, hbar=hbar, m=m, t=0, args=L / 2)
    return sch.impedence(E=E)
Exemplo n.º 4
0
def varyE(E_list):
    temp = []
    for e in E_list:
        print(e / 10 / bar_amp)
        cb = [cosineBarrier(i, L, bar_amp) for i in x]
        Sch = Schrodinger(x, x, cb, hbar=hbar, m=m)
        temp.append(Sch.impedence(E=e))
    return temp
Exemplo n.º 5
0
def transmissionSpectrum(min, max, points, V):
    sch = Schrodinger(x, Psi_x, V, hbar=hbar, m=m, t=0)
    energies = np.linspace(min, max, points) * bar_amp
    transmissions = []
    for e in energies:
        imp = sch.impedence(e)
        transmissions.append(imp)

    return energies, transmissions
Exemplo n.º 6
0
def T_s(V0, E, gauss=False):
    if gauss:
        v = gaussianBarrier(x, 0, w, V0)
    else:
        v = squareBarrier(x, V0, -L / 2, L / 2)

    k0 = np.sqrt(2 * m * E / (hbar**2) - 1 / (4 * sig**2))
    psi_x = gauss_init(x, k0, x0, d=sig)
    sch = Schrodinger(x, psi_x, v, hbar=hbar, m=m, t=0, args=L / 2)
    return sch.impedence(E)
Exemplo n.º 7
0
def T_t(l, V0, norm=False):
    if norm:
        v = tanhBarrierNorm(x, V0, l, w)
    else:
        v = tanhBarrier(x, V0, l, w)
    psi_x = gauss_init(x, k0, x0, d=sig)
    sch = Schrodinger(x, psi_x, v, hbar=hbar, m=m, t=0)
    # plt.plot(x,v/scale)
    # plt.show()
    return sch.impedence(E)
Exemplo n.º 8
0
def varyV(V_list, gauss=False):
    temp = []
    for v in V_list:
        print(v / bar_amp)
        if gauss:
            cb = [gaussian(i, L, v) for i in x]
        else:
            cb = [cosineBarrier(i, L, v) for i in x]
        Sch = Schrodinger(x, x, cb, hbar=hbar, m=m)
        temp.append(Sch.impedence(E=E))
    return temp
Exemplo n.º 9
0
 def runAll(self, N_step=1):
     psi_comb = np.zeros((self.n, len(self.x)), dtype=complex)
     for initial in self.initarray:
         x0, v0, a0, g0 = initial
         psi_x = self.hellerPacket(x0, v0, a0, g0)
         sch = Schrodinger(self.x, psi_x, self.v, hbar=self.hbar, m=self.m)
         for i in range(self.n):
             if i != 0:
                 sch.evolve_t(N_step, self.dt)
             psi_sol = sch.psi_x
             psi_comb[i] += psi_sol / np.sqrt(self.N_packet)
     self.psi_comb = psi_comb
     return psi_comb
Exemplo n.º 10
0
def run(acc):
    t = 0
    psi_x = gauss_init(x, k_initial, x0=0, d=d)
    V_x = gaussbox(x, w, L, x0=xb, A=Amp, a=acc)
    sch = Schrodinger(x, psi_x, V_x, k, hbar=hbar, m=m, t=t)

    t_list = []
    x_list = []

    for i in range(Ns):
        sch.evolve_t(N_steps=step, dt=dt)
        t_list.append(sch.t)
        x_list.append(sch.expectation_x())

    dat = list(zip(t_list, x_list))
    # np.savetxt("GBox_{}.txt".format(a), dat)
    return dat
Exemplo n.º 11
0
def Nchange(nrange, show=False):
    E_ = energy2(k0, hbar, m, sig)
    Es_list = []
    for i in nrange:
        N = 2**i
        x = np.array([i * dx for i in range(N)])
        x = x - max(x) / 2

        Psi_x = gauss_init(x, k0, x0=x0, d=sig)
        V_x = np.zeros(N)

        sch = Schrodinger(x, Psi_x, V_x, hbar=hbar, m=m)
        Es_list.append(sch.energy())

    Diff_list = [Es_list[j] - E_ for j in range(len(nrange))]

    plt.figure()
    plt.plot(nrange, [E_ for i in nrange], label="Theoretical")
    plt.plot(nrange, Es_list, label="Simulated", linestyle="--")
    plt.title("N")
    plt.legend()
    plt.xlabel("N")
    plt.ylabel("Energy")
    plt.savefig("N.png")
    if show:
        plt.show()

    plt.figure()
    plt.ylim()
    plt.plot(nrange, Diff_list, label="Diff")
    plt.title("N_Diff")
    plt.legend()
    plt.xlabel("N")
    plt.ylabel("Energy_Difference")
    plt.savefig("N_diff.png")
    if show:
        plt.show()

    Rel_list = [Diff_list[j] / E_ for j in range(len(nrange))]
    plt.figure()
    plt.plot(nrange, Rel_list, label="Relative Difference")
    plt.title("N Relative Difference")
    plt.legend()
    plt.xlabel("N")
    plt.ylabel("Relative_Energy_Difference")
    plt.savefig("N_rel.png")
Exemplo n.º 12
0
def mChange(start, stop, step, show=False):
    m_range = np.arange(start, stop, step)

    E_list = energy2(k0, hbar, m_range, sig)
    Es_list = []
    for i in m_range:
        Psi_x = gauss_init(x, k0, x0=x0, d=sig)
        sch = Schrodinger(x, Psi_x, V_x, hbar=hbar, m=i, t=0)
        Es_list.append(sch.energy())

    Diff_list = [Es_list[j] - E_list[j] for j in range(len(m_range))]

    plt.figure()
    plt.plot(m_range, E_list, label="Theoretical")
    plt.plot(m_range, Es_list, label="Simulated", linestyle="--")
    plt.title("M")
    plt.legend()
    plt.xlabel("M")
    plt.ylabel("Energy")
    plt.savefig("M.png")
    if show:
        plt.show()

    plt.figure()
    plt.plot(m_range, Diff_list, label="Diff")
    plt.title("M_Diff")
    plt.legend()
    plt.xlabel("M")
    plt.ylabel("Energy_Difference")
    plt.savefig("M_diff.png")
    if show:
        plt.show()

    Rel_list = [Diff_list[j] / E_list[j] for j in range(len(m_range))]
    av = np.mean(Rel_list)
    plt.figure()
    plt.ylim(av - 0.1, av + 0.1)
    plt.plot(m_range, Rel_list, label="Average.{}".format(round(av, 5)))
    plt.title("M Relative Difference")
    plt.legend()
    plt.xlabel("M")
    plt.ylabel("Relative_Energy_Difference")
    plt.savefig("M_rel.png")
    if show:
        plt.show()
Exemplo n.º 13
0
def sigChange(start, stop, step, show=False):
    sig_range = np.arange(start, stop, step)

    E_ = energy2(k0, hbar, m, sig_range)
    Es_list = []
    for i in sig_range:
        Psi_x = gauss_init(x, k0, x0=x0, d=i)
        sch = Schrodinger(x, Psi_x, V_x, hbar=hbar, m=m, t=0)
        Es_list.append(sch.energy())

    Diff_list = [Es_list[j] - E_[j] for j in range(len(sig_range))]

    plt.figure()
    plt.plot(sig_range, E_, label="Theoretical")
    plt.plot(sig_range, Es_list, label="Simulated", linestyle="--")
    plt.title("Sigma")
    plt.legend()
    plt.xlabel("Sigma")
    plt.ylabel("Energy")
    plt.savefig("Sigma.png")
    if show:
        plt.show()

    plt.figure()
    plt.plot(sig_range, Diff_list, label="Diff")
    plt.title("Sigma_Diff")
    plt.legend()
    plt.xlabel("Sigma")
    plt.ylabel("Energy_Difference")
    plt.savefig("Sigma_diff.png")
    if show:
        plt.show()

    Rel_list = [Diff_list[j] / E_[j] for j in range(len(sig_range))]
    plt.figure()
    plt.plot(sig_range, Rel_list, label="Relative Difference")
    plt.title("Sigma Relative Difference")
    plt.legend()
    plt.xlabel("Sigma")
    plt.ylabel("Relative_Energy_Difference")
    plt.savefig("Sig_rel.png")
    if show:
        plt.show()
Exemplo n.º 14
0
def run(x2, time=False):
    V_x = barrier(x, A, x1, x2)
    psi_init = gauss_init(x, k_init, x0=x0, d=sig)

    sch = Schrodinger(x, psi_init, V_x, k, hbar=hbar, m=m, t=0, args=x2)

    dat = []
    t_list = []
    for i in range(0, Ns):
        sch.evolve_t(step, dt)
        dat.append(sch.barrier_transmition())
        t_list.append(sch.t)

    # plt.plot(sch.k, abs(sch.psi_k))
    # plt.show()

    if time:
        return dat, t_list
    else:
        return dat
Exemplo n.º 15
0
def run(A, choen=False):
    V_x = barrier(x, A, x1, x2)
    sch = Schrodinger(x, Psi_x, V_x, hbar=hbar, m=m, args=x2, t=0)
    I = sch.impedencePacket()
    while sch.t < finalt:
        print("Height :{h} Time:{t}".format(h=A, t=sch.t))
        sch.evolve_t(step, dt)
    T = sch.barrier_transmition()
    return T, I
Exemplo n.º 16
0
def run_A(A):
    Psi_x = gauss_init(x, k0, x0=x0, d=sig)
    V_x = gauss_barrier(x, A, x1, omeg)
    sch = Schrodinger(x, Psi_x, V_x, hbar=hbar, m=m, t=0, args=x1)

    imp = sch.impedencePacket(tol=10**-11)
    time_list = []
    Trans_list = []
    while sch.t < t_final:
        sch.evolve_t(N_steps=step, dt=dt)
        time_list.append(sch.t)
        Trans_list.append(sch.barrier_transmition())
        print("Height {v}, Time {t}".format(v=A / scale, t=sch.t))

    return sch.barrier_transmition(), imp
Exemplo n.º 17
0
    def onePacket(self, vkick, init):
        nhalf = int(self.n / 2)
        psi_arr = np.zeros((self.n, len(self.x)), dtype=complex)

        x0, v0, a0, g0 = init
        psi_init = self.hellerPacket(x0, v0, a0, g0)
        tempsch = Schrodinger(self.x,
                              psi_init,
                              self.v,
                              hbar=self.hbar,
                              m=self.m)
        for i in range(nhalf):
            tempsch.evolve_t(1, dt=self.dt)
            psi_arr[i] = tempsch.psi_x

        tempsch.momentum_kick(self.m * vkick / self.hbar)
        for i in range(nhalf):
            tempsch.evolve_t(1, dt=self.dt)
            psi_arr[i + nhalf] = tempsch.psi_x
        return psi_arr
Exemplo n.º 18
0
dt = 10**-7
dk = 2 * np.pi / (N * dx)

k_lim = np.pi / dx
k1 = -k_lim + (dk) * np.arange(N)

# x = np.array([i * dx for i in range(N)])
x = np.arange(-lim, lim, dx)

x0 = -1 * 10**-5
x1 = x[int(N / 2)]
x2 = x1 + Len

sig = 1 * 10**-6
k0 = 5 * 10**6

E = (hbar**2 / 2 * m) * (k0**2 + 1 / (4 * sig**2))
print(E)

Psi_x = gauss_init(x, k0, x0=x0, d=sig)
V_x = barrier(x, 10**-30, x1, x2)

sch = Schrodinger(x, Psi_x, V_x, hbar=hbar, m=m, args=x1)

# plt.plot(x, sch.psi_squared)
plt.plot(x, V_x)
plt.show()

a = Animate(sch, V_x, 1000, dt, lim1=((-lim, lim), (0, max(sch.psi_squared))))
a.make_fig()
Exemplo n.º 19
0
    ks = fftshift(k)

    # Defining time steps
    t = 0
    dt = 0.01
    step = 1
    Ns = 1000
    print("Final time", dt * step * Ns)

    hbar = 1
    m = 1

    args = (m, hbar)

    p0 = k_initial * hbar
    a0 = 1j * hbar / (4 * d**2)
    g0 = (1j * hbar / 4) * np.log(2 * np.pi * d**2)
    init = [x0, p0 / m, a0, g0]

    psi_x = hellerPacket(x, x0, p0 / m, a0, g0)

    sch = Schrodinger(x, psi_x, V_x, k, hbar=hbar, m=m)

    hel = Heller(Ns, dt, init, derivs)

    comp = SplitComp(sch, hel)
    comp.packetComparisson(args)

    # comp.comparrisonKick(args, kick=0)
    # comp.comparrisonKick(args, kick=-2 * p0)
Exemplo n.º 20
0
dx = 0.02
x_length = N * dx
x = np.linspace(0, x_length, N)
x1 = x[int(N / 4)]
x2 = x[int(3 * N / 4)]

# Defining Psi and V
k_initial = 4

psi_x = two_gauss(x, x1, x2, k_initial, -k_initial, d=1)
V_x = np.zeros(N)

# Defining K range
dk = dx / (2 * np.pi)
k = fftfreq(N, dk)
ks = fftshift(k)

# Defining time steps
t = 0
dt = 0.01
step = 2

sch = Schrodinger(x, psi_x, V_x, k)

# plt.plot(sch.x, sch.mod_square_x(True))
# plt.show()

a = Animate(sch, V_x, step, dt, lim1=((0, x_length), (0, max(np.real(psi_x)+0.2))),
            lim2=((-2*k_initial, 2*k_initial), (0, abs(max(sch.psi_k)))), title='Two Packet Interferance')
a.make_fig()
Exemplo n.º 21
0
# Barrier Definitions
A = 1
x1 = int(0.5 * N) * dx
W = 1
sig = 0.1
mu = 1
args = (A, W, x1, sig, mu)

k0 = 4
x0 = x[int(N / 4)]
sig = 4
k_init = 5

Psi_x = gauss_init(x, k0, x0=x0, d=sig)

sch = Schrodinger(x, Psi_x, noisyBarrier, hbar=hbar, m=m, args=args)
print("Width :", sig)
print(sch.x_width())
# print(sch.impedence())

dt = 0.001
step = 100

finalt = 40

c = Constants(A, dt, dx, k0)

a = Animate(sch, noisyBarrier, step, dt)
a.make_fig()
Exemplo n.º 22
0
hbar = 1.0545718 * 10 ** -34
m = 1.44316072 * 10 ** -25
omegax = 80 * np.pi
sigma = 1 * 10 ** -6

t = 0

psi_init = wave_init(x, sigma, -x0)
V = harmonic_potential(x, m=m, w=omegax)
print(V[0])

plt.plot(x, psi_init)
plt.plot(x, V)
plt.show()

sch = Schrodinger(x, psi_init, V, hbar=hbar, m=m, t=0)


# a = Animate(sch, V, 1, dt,lim1=((-xmax, xmax), (0, max(sch.psi_squared))))
# a.make_fig()

simx = []
tl = []
El = []

temp = 0
while temp < Nt:
    sch.evolve_t(1, dt=dt)
    temp += 1
    if (temp % nsave) == 0:
        simx.append(sch.expectation_x())
Exemplo n.º 23
0
# Defining K range
dk = dx / (2 * np.pi)
k = fftfreq(N, dk)
ks = fftshift(k)

# Defining time steps
t = 0
dt = 0.01
step = 5
Ns = 350
print(Ns * step * dt)
sch = Schrodinger(x,
                  psi_x,
                  harmonic_potential_t,
                  k,
                  hbar=hbar,
                  m=m,
                  t=t,
                  args=args)

# plt.plot(x, sch.mod_square_x(True))
# plt.plot(x, V_x)
# plt.ylim(0, max(np.real(psi_x)))
# plt.show()
#
# t_list = []
#
# expec_x = []
#
# for i in range(Ns):
#     if i != 0:
Exemplo n.º 24
0
sig = 4
k_init = 5
psi_init = gauss_init(x, k_init, x0=x0, d=sig)

#
dk = dx / (2 * np.pi)
k = fftfreq(N, dk)
ks = fftshift(k)

t = 0
dt = 0.01
step = 5
Ns = 600

print(dt * Ns * step)
sch = Schrodinger(x, psi_init, V_x, k, hbar=hbar, m=m, t=t)

################### Testing
# t_list = []
# for i in range(0, Ns):
#     t += dt * step
#     t_list.append(t)
# t = 0
#
# L_list = np.linspace(1, 6, 10)
# Tunnel_Val = []
#
# figure = plt.figure()
# ax = figure.add_subplot(1, 1, 1)
# ax.set_title("Tunneled Packet vs Time")
# ax.set_xlabel("Time")
Exemplo n.º 25
0
         ((K**3 / (k1 * k2) + k1 * k2 / K) * np.sin(2 * K * a) - 1j * K *
          (k1 / k2 + k2 / k1) * np.cos(2 * K * a)) * np.sinh(k2 * delta) *
         np.sinh(k1 * delta))

    if A == 0:
        A = 10**-99

    return 1 - abs(B / A)**2


Psi_x = gauss_init(x, k0, x0=x0, d=sig)

V_x = doubleBarrier(x, bar_amp, x1, wid, sep)
# V_x = np.zeros(len(x))

sch = Schrodinger(x, Psi_x, V_x, hbar=hbar, m=m, t=0)

######## Initial Plot
# plt.plot(x / 10 ** -6, sch.psi_squared)
# plt.plot(x / 10 ** -6, V_x / scale)
# plt.show()

######## Animate
# a = Animate(sch, V_x, step, dt, lim1=((x[0], x[-1]), (0, max(np.real(sch.psi_squared)))),
#             lim2=((sch.k[0], sch.k[-1]), (0, max(np.real(sch.psi_k)))))
# a.make_fig()

#############Ashby Tunneling Test
a = sep / 2
b = sep / 2 + wid
min = 0
Exemplo n.º 26
0
    return 1 - coeff


e = bar_amp
l = np.sqrt(hbar ** 2 / (2 * m * bar_amp))
L = 10 * l

x = np.linspace(-20, 20, 1000) * l
dx = x[1] - x[0]

v_sq = squareBarrier(x, bar_amp, -L / 2, L / 2)
v_tanh = tanhBarrier(x, bar_amp, L, 10 ** -8)

psi_x = gauss_init(x, k0, x0, d=sig)

sch = Schrodinger(x, psi_x, v_sq, hbar=hbar, m=m, t=0, args=L / 2)

ys = tanhBarrierNoNorm(x, bar_amp, L, 10 ** -6)

# ppot, pcov = curve_fit(gaussian, x, ys, p0=(0, 2*10 ** -6, bar_amp))
# plt.plot(x / 10 ** -6, ys / scale * 10 ** -3, label="Tanh")
# plt.plot(x / 10 ** -6, gaussian(x, ppot[0], ppot[1], ppot[2]) / scale * 10 ** -3, label="Fit")
# plt.legend()
# plt.xlim(-10, 10)
# plt.ylabel("V (kHz)")
# plt.xlabel("x (micrometers)")
# plt.title("Tanh and Gaussian Comparison")
# plt.savefig("Gaussian Comparison No Norm")
# plt.show()

# w_list = np.logspace(-6, -8, 5)
Exemplo n.º 27
0
    imp = sch.impedencePacket(tol=10**-11)
    time_list = []
    Trans_list = []
    while sch.t < t_final:
        sch.evolve_t(N_steps=step, dt=dt)
        time_list.append(sch.t)
        Trans_list.append(sch.barrier_transmition())
        print("Height {v}, Time {t}".format(v=A / scale, t=sch.t))

    return sch.barrier_transmition(), imp


Psi_x = gauss_init(x, k0, x0=x0, d=sig)
V_x = gauss_barrier(x, bar_amp, x1, omeg)

sch = Schrodinger(x, Psi_x, V_x, hbar=hbar, m=m, t=0, args=x1)
# print("Energy", sch.energy())
# print("Imp",sch.impedencePacket(tol=10**-11))

# plt.plot(sch.k, sch.mod_square_k(r=True))
# plt.plot(x, np.asarray(V_x)/scale)
# plt.show()

# a = Animate(sch, V_x, step, dt, lim1=((x[0], x[-1]), (0, max(np.real(sch.psi_squared)))),
#             lim2=((sch.k[0], sch.k[-1]), (0, max(np.real(sch.psi_k)))))
# a.make_fig()

# v_list = np.arange(0.5, 5, 0.1)

################ Changing V
# v_list = np.linspace(0.1, 3, 50) * bar_amp
Exemplo n.º 28
0
def tunnelingSpectra(V, E_list):
    sch = Schrodinger(x, psi_x, V, hbar=hbar, m=m, t=0, args=L / 2)
    T_list = []
    for e in E_list:
        T_list.append(sch.impedence(e))
    return T_list
Exemplo n.º 29
0
# Defining K range
dk = dx / (2 * np.pi)
k = fftfreq(N, dk)
ks = fftshift(k)

# Defining time steps
t = 0
dt = 0.01
step = 10
Ns = 100
print("Final time", dt * step * Ns)

hbar = 1
m = 1

sch = Schrodinger(x, psi_x, V_x, k, hbar=hbar, m=m)

print("Numerical Energy :", sch.energy())
print("Theoretical Energy", (hbar**2 * k_initial**2) / (2 * m))

print("Difference :", sch.energy() - (hbar**2 * k_initial**2) / (2 * m))

psi_init2 = gauss_init(x, k_initial, x0=x0, d=d)
psis2 = np.real(psi_init2 * np.conj(psi_init2))

# plt.plot(x, sch.mod_square_x(True))
# plt.plot(x, V_x)
# plt.ylim(0, max(np.real(psi_x)))
# plt.show()

a = Animate(sch,
Exemplo n.º 30
0
def T_s(l, V0):
    v = squareBarrier(x, V0, -l / 2, l / 2)
    psi_x = gauss_init(x, k0, x0, d=sig)
    sch = Schrodinger(x, psi_x, v, hbar=hbar, m=m, t=0)
    return sch.impedence(E)