Exemplo n.º 1
0
def fun1(x):
    um_scale = 1.0
    # conversion factor for eV to 1/um [=1/hc]
    eV_um_scale = um_scale/1.23984193
    Au_plasma_frq = x[0]*eV_um_scale

    Au_f0 = x[1]
    Au_frq0 = 1e-10
    Au_gam0 = x[2]*eV_um_scale
    Au_sig0 = Au_f0*Au_plasma_frq**2/Au_frq0**2

    Au_f1 = x[3]
    Au_frq1 = x[4]    # 0.42 um
    Au_gam1 = x[5]*eV_um_scale
    Au_sig1 = Au_f1*Au_plasma_frq**2/Au_frq1**2

    Au_f2 = x[6]
    Au_frq2 = x[7]  # 0.42 um
    Au_gam2 = x[8]*eV_um_scale
    Au_sig2 = Au_f2*Au_plasma_frq**2/Au_frq2**2

    fx = x[9] + calcdrude(frequency=f, frequencyn=Au_frq0,
                          sigma=Au_sig0, gamma=Au_gam0)
    fx = fx + calclorentizan(frequency=f, frequencyn=Au_frq1,
                             gamma=Au_gam1, sigma=Au_sig1)
    fx = fx + calclorentizan(frequency=f, frequencyn=Au_frq2,
                             gamma=Au_gam2, sigma=Au_sig2)

    last = auorj-fx  # fx burada üreittiğimiz değerşler mix1 ise ulaşmaya çalıştığımız değerler

    return np.sum(abs(last))
def fun1(x):
    um_scale = 1.0
    # conversion factor for eV to 1/um [=1/hc]
    eV_um_scale = um_scale / 1.23984193
    Au_plasma_frq = x[0] * eV_um_scale

    Au_f0 = x[1]
    Au_frq0 = 1e-10
    Au_gam0 = x[2] * eV_um_scale
    Au_sig0 = Au_f0 * Au_plasma_frq**2 / Au_frq0**2

    Au_f1 = x[3]
    Au_frq1 = x[4]  # 0.42 um
    Au_gam1 = x[5] * eV_um_scale
    Au_sig1 = Au_f1 * Au_plasma_frq**2 / Au_frq1**2

    Au_f2 = x[6]
    Au_frq2 = x[7]  # 0.42 um
    Au_gam2 = x[8] * eV_um_scale
    Au_sig2 = Au_f2 * Au_plasma_frq**2 / Au_frq2**2
    Au_f3 = x[9]
    Au_frq3 = x[10] * eV_um_scale  # 0.418 um
    Au_gam3 = x[11] * eV_um_scale
    Au_sig3 = Au_f3 * Au_plasma_frq**2 / Au_frq3**2
    Au_f4 = x[12]
    Au_frq4 = x[13] * eV_um_scale  # 0.288 um
    Au_gam4 = x[14] * eV_um_scale
    Au_sig4 = Au_f4 * Au_plasma_frq**2 / Au_frq4**2
    Au_f5 = x[15]
    Au_frq5 = x[16] * eV_um_scale  # 0.093 um
    Au_gam5 = x[17] * eV_um_scale
    Au_sig5 = Au_f5 * Au_plasma_frq**2 / Au_frq5**2
    fx = x[18] + calcdrude(
        frequency=f, frequencyn=Au_frq0, sigma=Au_sig0, gamma=Au_gam0)
    fx = fx + calclorentizan(
        frequency=f, frequencyn=Au_frq1, gamma=Au_gam1, sigma=Au_sig1)
    fx = fx + calclorentizan(
        frequency=f, frequencyn=Au_frq2, gamma=Au_gam2, sigma=Au_sig2)
    fx = fx + calclorentizan(
        frequency=f, frequencyn=Au_frq3, gamma=Au_gam3, sigma=Au_sig3)
    fx = fx + calclorentizan(
        frequency=f, frequencyn=Au_frq4, gamma=Au_gam4, sigma=Au_sig4)
    fx = fx + calclorentizan(
        frequency=f, frequencyn=Au_frq5, gamma=Au_gam5, sigma=Au_sig5)

    last = mix1 - fx  # fx burada üreittiğimiz değerşler mix1 ise ulaşmaya çalıştığımız değerler
    # lasti = np.corrcoef(np.real(mix1),np.real(fx))[1][0]
    # lastr = np.corrcoef(np.imag(mix1),np.imag(fx))[1][0]
    # # https://en.wikipedia.org/wiki/Reduced_chi-squared_statistic
    # print ((np.sum((np.real(last)**2)+(np.imag(last)**2))+40-(20*lasti)-(20*lastr)) )
    x = ((np.sum(np.real(last)**2) / (0.001)) +
         (np.sum(np.imag(last)**2) / 0.001)) / (len(mix1) - 1)
    # x burada fitting için kullandığımız ve azaltmaya çalıştığımız parametre
    # print(x)
    # return (np.sum((np.real(last)**2)+(np.imag(last)**2))+40-(20*lasti)-(20*lastr))
    assert x != np.nan, f'{x} is problematic'
    print(x)
    return x
Au_frq3 = val[10] * eV_um_scale  # 0.418 um
Au_gam3 = val[11] * eV_um_scale
Au_sig3 = Au_f3 * Au_plasma_frq**2 / Au_frq3**2

Au_f4 = val[12]
Au_frq4 = val[13] * eV_um_scale  # 0.288 um
Au_gam4 = val[14] * eV_um_scale
Au_sig4 = Au_f4 * Au_plasma_frq**2 / Au_frq4**2
Au_f5 = val[15]
Au_frq5 = val[16] * eV_um_scale  # 0.093 um
Au_gam5 = val[17] * eV_um_scale
Au_sig5 = Au_f5 * Au_plasma_frq**2 / Au_frq5**2

fx = val[18] + calcdrude(
    frequency=f, frequencyn=Au_frq0, sigma=Au_sig0, gamma=Au_gam0)
fx = fx + calclorentizan(
    frequency=f, frequencyn=Au_frq1, gamma=Au_gam1, sigma=Au_sig1)
fx = fx + calclorentizan(
    frequency=f, frequencyn=Au_frq2, gamma=Au_gam2, sigma=Au_sig2)
fx = fx + calclorentizan(
    frequency=f, frequencyn=Au_frq3, gamma=Au_gam3, sigma=Au_sig3)
fx = fx + calclorentizan(
    frequency=f, frequencyn=Au_frq4, gamma=Au_gam4, sigma=Au_sig4)
fx = fx + calclorentizan(
    frequency=f, frequencyn=Au_frq5, gamma=Au_gam5, sigma=Au_sig5)
# plt.figure(2)
# plt.subplot(121)
# plt.plot(1/f,np.real(fx),color = 'C1', label= 'changed real')
# plt.plot(1/f,np.imag(fx),color = 'C2' ,label= 'changed imaginery')
# plt.plot(1/f,np.real(au),color = 'C3', label= 'orjinal real')
# plt.plot(1/f,np.imag(au),color = 'C4' ,label= 'orjinal imaginery')
# plt.ylim(-14,6)
Exemplo n.º 4
0
Au_f0 = x[1]
Au_frq0 = 1e-10
Au_gam0 = x[2]*eV_um_scale
Au_sig0 = Au_f0*Au_plasma_frq**2/Au_frq0**2

Au_f1 = x[3]
Au_frq1 = x[4]    # 0.42 um
Au_gam1 = x[5]*eV_um_scale
Au_sig1 = Au_f1*Au_plasma_frq**2/Au_frq1**2

Au_f2 = x[6]
Au_frq2 = x[7]  # 0.42 um
Au_gam2 = x[8]*eV_um_scale
Au_sig2 = Au_f2*Au_plasma_frq**2/Au_frq2**2

fx = x[9] + calcdrude(frequency=f, frequencyn=Au_frq0,
                      sigma=Au_sig0, gamma=Au_gam0)
fx = fx + calclorentizan(frequency=f, frequencyn=Au_frq1,
                         gamma=Au_gam1, sigma=Au_sig1)
fx = fx + calclorentizan(frequency=f, frequencyn=Au_frq2,
                         gamma=Au_gam2, sigma=Au_sig2)


plt.plot(w, fx.real, label="fx real")
plt.plot(w, fx.imag, label="fx imag")
plt.plot(w, auorj.real, label="cdse real")
plt.plot(w, auorj.imag, label="cdse imag")
plt.legend()
plt.show()