bohr_radius = 5.29e-11  # m

# plot S vs C3

C3 = np.linspace(0.1, 1.5, 20)
S_max = np.zeros(C3.size)
S_kd = np.zeros(C3.size)

s_result_kd = cs.calc_sensitivity_kd(npv.I_inc_nom, npv.L_nom, npv.v_nom, npv.d_nom)

for i in range(C3.size):

    result = cs.calc_sensitivity_vdw(
        npv.I_inc_nom, npv.l_nom, npv.L_nom, npv.v_nom, C3[i] * hartree * bohr_radius ** 3, npv.d_nom
    )
    S_max[i] = result[0]
    S_kd[i] = s_result_kd
    print result


l1, l2 = plt.plot(C3, S_max, "b-", C3, S_kd, "r-")
plt.xlabel("C3 (atomic units)")
plt.ylabel("sensitivity (rad/s / sqrt(Hz))")
l1_str = "material gratings, optimal open fraction = " + str(cs.f_max(npv.d_nom))
plt.legend(
    (l1, l2),
    ("material gratings, optimal open fraction", "Kapitza-Dirac gratings (open fraction = 0.5)"),
    loc="upper right",
)
plt.show()
import time
import numpy as np
import matplotlib.pyplot as plt
import calc_sensitivity as cs
import nominal_param_values as npv


v = 50.0 # m/s

d = np.linspace(80.0e-9,400.0e-9,30)
d_plot = d*1.0e9
S_vdw = np.zeros(d.size, dtype=np.float)
S_kd = np.zeros(d.size, dtype=np.float)
f1 = np.zeros(d.size, dtype=np.float)
f2 = np.zeros(d.size, dtype=np.float)
f_max = cs.f_max(d)
for i in range(d.size):
    print d[i]

    result = cs.calc_sensitivity_vdw(npv.I_inc_nom, npv.l_nom, npv.L_nom, npv.v_nom, npv.C3_nom, d[i])
    S_vdw[i] = result[0]
    f1[i] = result[2]
    f2[i] = result[3]
    S_kd[i] = cs.calc_sensitivity_kd(npv.I_inc_nom, npv.L_nom, npv.v_nom, d[i])

plt.figure(figsize=plt.figaspect(1.4))

plt.subplot(211)
l1, l2 = plt.plot(d_plot, S_vdw, 'b-', d_plot, S_kd, 'r-')
plt.xlabel('grating period (nm)')
plt.ylabel('sensitivity (rad/s / sqrt(Hz))')