xs, ys = [], []
    for N in Nlst:
        subpath = path + "N_%d" % N
        t_MMST, p2_MMST = get_popu_data("%s/traj_MultiEh.txt" % subpath, N)
        xs.append(t_MMST)
        ys.append(p2_MMST)
    return xs, ys


Nlst = [1, 7, 35]
labels = ["N = %d" % N for N in Nlst]

axes = clp.initialize(col=2,
                      row=1,
                      width=4.3,
                      height=4.3 * 0.618 * 2,
                      fontsize=12,
                      LaTeX=True,
                      labelthem=True,
                      labelthemPosition=[0.04, 0.96])

xs, ys = gather_data(Nlst)

clp.plotone([x / kFGR for x in xs],
            ys,
            axes[0],
            labels=labels,
            colors=["r--", "c", "b"],
            xlabel="time ($t$)",
            ylabel="Avg. excited state popu. $\\bar{\\rho}_{ee}(t)$",
            lw=2,
            alphaspacing=0.02)
Example #2
0
    t, p1, p2 = data[:-1,0], data[:-1, 1], data[:-1, 2]
    return t, p1, p2

t_QM, p1_QM, p2_QM = get_popu_data(path+"traj_QM.txt")

t_MMST, p1_MMST, p2_MMST = get_popu_data(path+"traj_MultiEh.txt")

xs = [t_MMST /np.pi, t_QM / np.pi]
y1s = [p1_MMST, p1_QM]
y2s = [p2_MMST, p2_QM]

labels = ["MMST", "QM"]
colors1 = ["r--", "k--"]
colors2 = ["r", "k"]

ax = clp.initialize(col=1, row=1, width=4.3, fontsize=12, LaTeX=True)

clp.plotone(xs, y1s, ax, colors=colors1, alphaspacing=0.0, lw=2)
clp.plotone(xs, y2s, ax, labels=labels, colors=colors2, xlabel="time ($t$)",
            ylabel="Electronic population", alphaspacing=0.0, lw=2)

# Plot x-axis as a function of PI
def format_func(value, tick_number):
    # find number of multiples of pi/2
    N = value
    if N == 0:
        return "0"
    else:
        return r"${0}\pi$".format(N)

ax.xaxis.set_major_formatter(FuncFormatter(format_func))
t_sed, p1_sed, p2_sed = get_popu_data(path + "traj_StochasticED.txt")

xs = [t_p / np.pi, t_sed / np.pi, t_MMST / np.pi, t_QM / np.pi]
y1s = [p1_p, p1_sed, p1_MMST, p1_QM]
y2s = [p2_p, p2_sed, p2_MMST, p2_QM]

labels = [
    "Sampling electronic ZPE (self-interaction)",
    "Sampling photonic ZPE (vacuum fluctuations)", "Sampling both (MMST)", "QM"
]
colors1 = ["b--", "g--", "r--", 'k--']
colors2 = ["b--", "g-.", "r", 'k--']

ax = clp.initialize(col=1,
                    row=1,
                    width=4.6,
                    fontsize=12,
                    LaTeX=True,
                    sharex=True)

clp.plotone(xs,
            y2s,
            ax,
            labels=labels,
            colors=colors2,
            xlabel="time (t)",
            ylabel="Excited state population",
            alphaspacing=0.0,
            lw=2,
            ylim=[-0.51, 2.0])

    return xnew, ynew

def calc_analytical(xs, ys, Nlst):
    xnew, ynew = xs, []
    for i in range(len(xs)):
        x, y = xs[i], ys[i]
        N = Nlst[i]
        td = x[np.argmax(y)]
        y_analytical = kFGR * N / 4.0 * np.cosh(kFGR*N / 2.0 * (x - td))**(-2)
        ynew.append(y_analytical)
    return xnew, ynew

Nlst = [7, 35]
labels = ["MMST N = %d" %N for N in Nlst]

ax = clp.initialize(col=1, row=1, width=4.3, height=4.3*0.618, fontsize=12, LaTeX=True)

xs, ys = gather_data(Nlst)
xnew, dydt = calculate_derivative(xs,ys)

clp.plotone(xnew, dydt, ax, labels=labels, colors=["c", "b"], xlabel="time ($t$)", ylabel="$d\\bar{\\rho}_{ee}/dt$", lw=2, xlim=[-0.005, 0.2])

xnew, dydt = calc_analytical(xnew,dydt, Nlst)
labels = ["mean-field N = %d" %N for N in Nlst]
clp.plotone(xnew, dydt, ax, labels=labels, colors=["k-.", "k--"], xlabel="time ($t$)",  lw=2, xlim=[-0.005, 0.2], ylim=[-2, 30])



# output figure
clp.adjust(tight_layout=True, savefile="SE_Dicke_delay_time.pdf")
    return np.convolve(x, np.ones((N, )) / N, mode='valid')


data_QM = get_data(path + "Ez2_QM.txt")
data_EhR = get_data(path + "Ez2_MultiEh.txt")

n = 11
Lcavity = 2.0 * np.pi

spacing_y = np.max(np.max(data_QM[1:-1, :])) * 1.15

fig, ax = clp.initialize(col=1,
                         row=1,
                         width=4.3,
                         height=6.8,
                         sharex=True,
                         return_fig_args=True,
                         sharey=True,
                         fontsize=12,
                         LaTeX=True)

N = 50  #average over 50 points
for i in range(n):
    X = [data_EhR[:, 0], data_QM[:, 0]]
    X = [x / np.pi for x in X]
    Y = [data_EhR[:, i + 1], data_QM[:, i + 1]]
    Y = [(y + spacing_y * i) / spacing_y for y in Y]
    X_avg = [X[0][int(N / 2) - 1:-int(N / 2)]]
    Y_avg = [running_mean(Y[0], N)]
    X = X + X_avg
    Y = Y + Y_avg
    t_QM, p1_QM, p2_QM = get_popu_data("%s/traj_QM.txt" % path)
    t_MMST, p1_MMST, p2_MMST = get_popu_data("%s/traj_MultiEh.txt" % path)
    xs = [t_MMST / kFGR, t_QM / kFGR, t_QM / kFGR]
    #y1s = [p1_MMST, p1_QM]
    y2s = [p2_MMST, p2_QM, p2_QM[0] * np.exp(-kFGR * t_QM)]
    return xs, y2s


labels = ["MMST", "QM", "free space decay"]
colors2 = ["r", "k", "0.7"]

axes = clp.initialize(col=1,
                      row=3,
                      width=4.3 * 2,
                      height=4.3 * 0.618,
                      fontsize=12,
                      LaTeX=True,
                      sharey=True,
                      labelthem=True,
                      labelthemPosition=[0.13, 0.95])

xs, y2s = gather_data("SE_101TLS_FDTD_dx_25")
clp.plotone(xs,
            y2s,
            axes[0],
            labels=labels,
            colors=colors2,
            xlabel="time ($t$)",
            ylabel="Excited state population",
            alphaspacing=0.1,
            lw=2)

def format_func_small(value, tick_number):
    # find number of multiples of pi/2
    N = value
    if N == 0:
        return "0"
    else:
        return r"${0}\pi$".format(int(1000 * N) / 1000.0)


fig, axes = clp.initialize(col=2,
                           row=4,
                           width=4.3 * 3,
                           height=6.3 * 2,
                           return_fig_args=True,
                           sharey=True,
                           fontsize=12,
                           LaTeX=True,
                           labelthem=True,
                           labelthemPosition=[0.08, 0.98])

N = 50  #average over 50 points

paths = [
    "EM_FDTD_Full/", "EM_FDTD_Truncated/", "EM_MODE_Full/",
    "EM_MODE_Truncated/"
]
methods = ["FDTD 400 modes", "FDTD 100 modes", "XP 400 modes", "XP 100 modes"]

for j in range(4):
    data_QM = get_data(paths[j] + "Ez2_QM.txt")
    values = np.vstack([m1, m2])
    kernel = stats.gaussian_kde(values)
    Z = np.reshape(kernel(positions).T, X.shape)
    return X, Y, Z


n = 3

NSTART = 0

fig, axes = clp.initialize(col=3,
                           row=n,
                           width=6,
                           height=6,
                           sharex=True,
                           sharey=True,
                           commonX=[0.5, 0.00, "ground state popu."],
                           commonY=[0.01, 0.5, "excited state popu."],
                           return_fig_args=True,
                           LaTeX=True,
                           labelthem=True,
                           labelthemPosition=[0.95, 0.95])
Zgood = 0

for k in range(3):
    if k == 0:
        data_tot = np.loadtxt(path + "ElectronicDist_MultiEh.txt")
    elif k == 1:
        data_tot = np.loadtxt(path + "ElectronicDist_PreBinSQC.txt")
    else:
        data_tot = np.loadtxt(path + "ElectronicDist_StochasticED.txt")
    for i in range(n):
def gather_data(path):
    t_QM, p1_QM, p2_QM = get_popu_data("%s/traj_QM.txt" % path)
    t_MMST, p1_MMST, p2_MMST = get_popu_data("%s/traj_MultiEh.txt" % path)
    xs = [t_MMST / kFGR, t_QM / kFGR, t_QM / kFGR]
    #y1s = [p1_MMST, p1_QM]
    y2s = [p2_MMST, p2_QM, p2_QM[0] * np.exp(-kFGR * t_QM)]
    return xs, y2s


labels = ["MMST", "QM", "free space decay"]
colors2 = ["r", "k--", "0.7"]

axes = clp.initialize(col=1,
                      row=2,
                      width=4.3 * 1.5,
                      height=4.3 * 0.618,
                      fontsize=12,
                      LaTeX=True,
                      sharey=True)

xs, y2s = gather_data("SE_1TLS_FDTD_near_mirror/dx_25")
clp.plotone(xs,
            y2s,
            axes[0],
            labels=labels,
            colors=colors2,
            xlabel="time ($t$)",
            ylabel="Excited state population",
            alphaspacing=0.1,
            lw=2,
            xlim=[0, 1.0])