def compute(self, f):
        fn = "t_{}/r_{}/output_job_0"
        current, mobility, field, conductivity = np.zeros(self.n_r), np.zeros(
            self.n_r), np.zeros(self.n_r), np.zeros(self.n_r)
        for i_t in range(0, self.n_t):
            for i_r in range(0, self.n_r):
                print("read-in i_t = {}, i_r = {}".format(i_t, i_r))
                current[i_r] = extract.extract_e(fn.format(i_t, i_r),
                                                 "final current density: ")
                mobility[i_r] = extract.extract_e(fn.format(i_t, i_r),
                                                  "final mobility: ")
                field[i_r] = f
                conductivity[i_r] = current[i_r] / field[i_r]
            self.current[i_t] = gmean(current)
            self.mobility[i_t] = gmean(mobility)
            self.conductivity[i_t] = gmean(conductivity)

            #self.current[i_t] = np.mean(current)
            #self.mobility[i_t] = np.mean(mobility)g
            #self.conductivity[i_t] = np.mean(conductivity)
            self.std_err_cu[i_t] = np.std(current) / self.n_r
            self.std_err_mo[i_t] = np.std(mobility) / self.n_r
            self.std_err_co[i_t] = np.std(conductivity) / self.n_r

        np.savetxt('postprocessing/current.dat', self.current)
        np.savetxt('postprocessing/mobility.dat', self.mobility)
        np.savetxt('postprocessing/conductivity.dat', self.conductivity)
        np.savetxt('postprocessing/std_err_cu.dat', self.std_err_cu)
        np.savetxt('postprocessing/std_err_mo.dat', self.std_err_mo)
        np.savetxt('postprocessing/std_err_co.dat', self.std_err_co)
Exemple #2
0
    def compute(self, f):
        fn = "dop_{}/r_{}/output_job_0"
        current, mobility, field, conductivity = np.zeros(self.n_r), np.zeros(self.n_r), np.zeros(self.n_r), np.zeros(self.n_r)
        for i_d in range(0, self.n_d):
            for i_r in range(0, self.n_r):
                current[i_r] = extract.extract_e(fn.format(i_d, i_r), "final current density: ")
                mobility[i_r] = extract.extract_e(fn.format(i_d, i_r), "final mobility: ")
                #field[i_r] = extract.extract_float(fn.format(i_d, i_r),"applying field of [ ")  #in V/nm
                field[i_r] = f
                conductivity[i_r] = current[i_r]/field[i_r]
            self.current[i_d] = gmean(current)
            self.mobility[i_d] = gmean(mobility)
            self.conductivity[i_d] = gmean(conductivity)

            #self.current[i_d] = np.mean(current)
            #self.mobility[i_d] = np.mean(mobility)
            #self.conductivity[i_d] = np.mean(conductivity)
            self.std_err_cu[i_d] = np.std(current)/self.n_r
            self.std_err_mo[i_d] = np.std(mobility)/self.n_r
            self.std_err_co[i_d] = np.std(conductivity)/self.n_r

        np.savetxt('postprocessing/current.dat', self.current)
        np.savetxt('postprocessing/mobility.dat', self.mobility)
        np.savetxt('postprocessing/conductivity.dat', self.conductivity)
        np.savetxt('postprocessing/std_err_cu.dat', self.std_err_cu)
        np.savetxt('postprocessing/std_err_mo.dat', self.std_err_mo)
        np.savetxt('postprocessing/std_err_co.dat', self.std_err_co)
EA_plus_0_0 = np.zeros([nr,NE])
EAEA_plus_0_0 = np.zeros(NE)

EA_1_0 = np.zeros([nr,NE])
EAEA_1_0 = np.zeros(NE)

IP_minus_1_0 = np.zeros([nr,NE])
IPIP_minus_1_0 = np.zeros(NE)


for i_r in range(0,nr):
    fn = 'jobs/r_{}/output_job_0'.format(i_r)
    print(fn)
    J[i_r] = extract.extract_float(fn, "Ionized dopant fraction: ")
    if np.log(J[i_r])>=0:
        J[i_r] = extract.extract_e(fn, "Ionized dopant fraction: ")    
    IP_0_0[i_r,:] = np.loadtxt("jobs/r_{}/experiments/tmp/IP_0_0.dat".format(i_r))
    EA_1_0[i_r,:] = np.loadtxt("jobs/r_{}/experiments/tmp/EA_1_0.dat".format(i_r))
    EA_plus_0_0[i_r,:] = np.loadtxt("jobs/r_{}/experiments/tmp/EA_plus_0_0.dat".format(i_r))
    IP_minus_1_0[i_r,:] = np.loadtxt("jobs/r_{}/experiments/tmp/IP_minus_1_0.dat".format(i_r))
    JJ 		= np.mean(J[:])
    IPIP_0_0[:]= np.mean(IP_0_0[:,:], 0)
    EAEA_1_0[:]= np.mean(EA_1_0[:,:], 0)
    EAEA_plus_0_0[:]= np.mean(EA_plus_0_0[:,:], 0)
    IPIP_minus_1_0[:]= np.mean(IP_minus_1_0[:,:], 0)
print("Av. ionized dopant fraction: {}".format(JJ))

# Plot DOS vs. Energy to see if smooth enough
PlotDOSPreview(IPIP_0_0,EAEA_plus_0_0,IPIP_minus_1_0,EAEA_1_0,Energy,figname)

#-----------------------------------
# extract Ion. dop. frac.
if not os.path.exists('ion_dop_frac.txt'):
    n_offset = int(np.loadtxt('s4s.txt')[0])
    n_replica = int(np.loadtxt('s4s.txt')[1])

    ion_dop_frac_av = np.zeros(n_offset)
    for i_off in range(n_offset):
        ion_dop_frac_r = np.zeros(n_replica)
        for i_r in range(0, n_replica):
            fn = 'jobs/off_{}/r_{}/output_job_0'.format(i_off, i_r)
            print(fn)
            ion_dop_frac_r[i_r] = extract.extract_float(
                fn, "Ionized dopant fraction: ")
            if np.log(ion_dop_frac_r[i_r]) > 0:
                ion_dop_frac_r[i_r] = extract.extract_e(
                    fn, "Ionized dopant fraction: ")
        ion_dop_frac_av[i_off] = np.mean(ion_dop_frac_r)
        print(ion_dop_frac_r)
        print("Av. ionized dopant fraction: {}".format(ion_dop_frac_av[i_off]))

    # save DOS data
    with open('ion_dop_frac.txt', 'w') as f:
        f.write('# Ionized dopant fraction\n')
        for i_off in range(n_offset):
            f.write('{}\n'.format(ion_dop_frac_av[i_off]))
    f.close()

# plor Ion. dop. frac. vs. Offset and get simulation points
offset = np.loadtxt('offset.txt')
ion_dop_frac = np.loadtxt('ion_dop_frac.txt')