예제 #1
0
파일: analysor.py 프로젝트: yihsuanliu/gpaw
 def abstract_d_and_v(self, tp):
     calc = tp.extended_calc
     gd = calc.gd
     if not tp.use_qzk_boundary and not tp.multi_leads:
         nt_sG = tp.gd.collect(tp.density.nt_sG)
     else:
         nt_sG = gd.collect(calc.density.nt_sG)
     vt_sG = gd.collect(calc.hamiltonian.vt_sG)
     nt = []
     vt = []
     ntx = []
     nty = []
     vtx = []
     vty = []
     if world.rank == 0:
         for s in range(tp.nspins):
             nts = aa1d(nt_sG[s])
             vts = aa1d(vt_sG[s])
             ntsx = aa2d(nt_sG[s], 0)
             vtsx = aa2d(vt_sG[s], 0)
             ntsy = aa2d(nt_sG[s], 1)
             vtsy = aa2d(vt_sG[s], 1)
             nt.append(nts)
             vt.append(vts)
             ntx.append(ntsx)
             vtx.append(vtsx)
             nty.append(ntsy)
             vty.append(vtsy)
         nt = np.array(nt)
         vt = np.array(vt)
         ntx = np.array(ntx)
         vtx = np.array(vtx)
         nty = np.array(nty)
         vty = np.array(vty)
     return nt, vt, ntx, vtx, nty, vty
예제 #2
0
파일: analysor.py 프로젝트: qsnake/gpaw
 def abstract_d_and_v(self, tp):
     calc = tp.extended_calc
     gd = calc.gd
     if not tp.use_qzk_boundary and not tp.multi_leads:
         nt_sG = tp.gd.collect(tp.density.nt_sG)
     else:
         nt_sG = gd.collect(calc.density.nt_sG)            
     vt_sG = gd.collect(calc.hamiltonian.vt_sG)
     nt = []
     vt = []
     ntx = []
     nty = []
     vtx = []
     vty = []
     if world.rank == 0:        
         for s in range(tp.nspins):
             nts = aa1d(nt_sG[s])
             vts = aa1d(vt_sG[s])
             ntsx = aa2d(nt_sG[s], 0)            
             vtsx = aa2d(vt_sG[s], 0)
             ntsy = aa2d(nt_sG[s], 1)            
             vtsy = aa2d(vt_sG[s], 1)                
             nt.append(nts)
             vt.append(vts)
             ntx.append(ntsx)
             vtx.append(vtsx)
             nty.append(ntsy)
             vty.append(vtsy)
         nt = np.array(nt)
         vt = np.array(vt)
         ntx = np.array(ntx)
         vtx = np.array(vtx)
         nty = np.array(nty)
         vty = np.array(vty)
     return nt, vt, ntx, vtx, nty, vty
예제 #3
0
파일: analysor.py 프로젝트: yihsuanliu/gpaw
    def save_ele_step(self, tp):
        if not self.matrix_foot_print:
            fd = file('matrix_sample', 'wb')
            sample = Tp_Sparse_Matrix(complex, tp.hsd.ll_index)
            sample.reset_from_others(tp.hsd.S[0],
                                     tp.hsd.H[0][0],
                                     1.,
                                     -1.j,
                                     init=True)
            cPickle.dump(sample, fd, 2)
            fd.close()
            self.matrix_foot_print = True
        #selfconsistent calculation: extended_calc ---> extended_atoms
        #non_selfconsistent calculation: extended_calc ---> original_atoms

        calc = tp.extended_calc
        gd = calc.gd
        finegd = calc.hamiltonian.finegd

        if not tp.use_qzk_boundary and not tp.multi_leads:
            nt_sG = tp.gd.collect(tp.density.nt_sG)
        else:
            nt_sG = gd.collect(calc.density.nt_sG)
        vt_sG = gd.collect(calc.hamiltonian.vt_sG)

        data = self.data
        flag = 'ele_' + str(self.n_ele_step) + '_'
        if world.rank == 0:
            nt = []
            vt = []
            for s in range(tp.nspins):
                nts = aa1d(nt_sG[s])
                vts = aa1d(vt_sG[s]) * Hartree
                if not tp.multi_leads:
                    nt1 = aa1d(tp.surround.sides['-'].boundary_nt_sG[s])
                    nt2 = aa1d(tp.surround.sides['+'].boundary_nt_sG[s])
                    nts = np.append(nt1, nts)
                    nts = np.append(nts, nt2)
                nt.append(nts)
                vt.append(vts)
            data[flag + 'nt'] = np.array(nt)
            data[flag + 'vt'] = np.array(vt)
            data[flag + 'df'] = np.diag(tp.hsd.H[0][0].recover(True))
            data[flag + 'dd'] = np.diag(tp.hsd.D[0][0].recover(True))
        else:
            nt = None
            vt = None

        if not tp.use_qzk_boundary and not tp.multi_leads:
            gd = tp.finegd
            rhot_g = gd.collect(tp.density.rhot_g)
            if world.rank == 0:
                rho1 = tp.surround.sides['-'].boundary_rhot_g_line
                rho2 = tp.surround.sides['+'].boundary_rhot_g_line
                rho = aa1d(rhot_g)
                rho = np.append(rho1, rho)
                rho = np.append(rho, rho2)
                data[flag + 'rho'] = np.array(rho)
            else:
                rho = None
        else:
            gd = calc.finegd
            rhot_g = gd.collect(calc.density.rhot_g)
            if world.rank == 0:
                rho = aa1d(rhot_g)
                data[flag + 'rho'] = np.array(rho)
            else:
                rho = None

        gd = finegd
        vHt_g = gd.collect(calc.hamiltonian.vHt_g)
        if world.rank == 0:
            vHt = aa1d(vHt_g) * Hartree
            data[flag + 'vHt'] = vHt
        else:
            vHt = None
        self.n_ele_step += 1
예제 #4
0
    def abstract_boundary(self):
        # Abtract the effective potential, hartree potential, and average density
        #out from the electrode calculation.
        map = {'-': '0', '+': '1'}
	data = self.tio.read_data(filename='Lead_' + 
	                          map[self.direction], option='Lead')
        nn = data['fine_N_c'][2]
	ns = data['nspins']
        N_c = data['N_c']
	cell_cv = data['cell_cv']
	pbc_c = data['pbc_c']
	#parsize_c = data['parsize_c']
        if type(parsize_domain) is int:
            parsize_c = None
            assert parsize_domain == self.domain_comm.size
        else:
            parsize_c = parsize_domain
        if parsize_c is None:
            parsize_c = decompose_domain(N_c, self.domain_comm.size)
        parsize_c = np.array(parsize_c)
        d1 = N_c[0] // 2
        d2 = N_c[1] // 2
       
        vHt_g = data['vHt_g']
        vt_sg = data['vt_sg']
        nt_sg = data['nt_sg']
        rhot_g = data['rhot_g']
        vt_sG = data['vt_sG']
        nt_sG = data['nt_sG']
        self.D_asp = data['D_asp']
	self.dH_asp = data['dH_asp']
        gd = GridDescriptor(N_c, cell_cv, pbc_c, self.domain_comm, parsize_c)
	finegd = gd.refine()
	
        self.boundary_vHt_g = None
        self.boundary_vHt_g1 = None
        self.boundary_vt_sg_line = None
        self.boundary_nt_sg = None
        self.boundary_rhot_g_line = None
        self.boundary_vt_sG = None
        self.boundary_nt_sG = None

        if self.tio.domain_comm.rank == 0:
            self.boundary_vHt_g = self.slice(nn, vHt_g)
            self.boundary_nt_sg = self.slice(nn, nt_sg)
            if self.direction == '-':
                other_direction= '+'
            else:
                other_direction= '-'
            h = self.h_cz / 2.0
            b_vHt_g0 = self.boundary_vHt_g.copy()
            b_vHt_g1 = self.boundary_vHt_g.copy()

            self.boundary_vHt_g = interpolate_array(b_vHt_g0,
                                                    finegd, h, 
						    self.direction)
            self.boundary_vHt_g1 = interpolate_array(b_vHt_g1,
                                                     finegd, h, 
						     other_direction)
            vt_sg = interpolate_array(vt_sg, finegd, 
	                              h, self.direction)
            self.boundary_vt_sg_line =  aa1d(vt_sg)
            self.boundary_nt_sg = interpolate_array(self.boundary_nt_sg,
                                                    finegd, h, self.direction)
            rhot_g = interpolate_array(rhot_g, finegd, h, self.direction)
            self.boundary_rhot_g_line = aa1d(rhot_g)

            nn /= 2
            h *= 2
            self.boundary_vt_sG = self.slice(nn, vt_sG)
            self.boundary_nt_sG = self.slice(nn, nt_sG)
            self.boundary_vt_sG = interpolate_array(self.boundary_vt_sG,
                                                    gd, h, self.direction)
            self.boundary_nt_sG = interpolate_array(self.boundary_nt_sG,
                                                    gd, h, self.direction)
예제 #5
0
    def abstract_boundary(self):
        # Abtract the effective potential, hartree potential, and average density
        #out from the electrode calculation.
        map = {'-': '0', '+': '1'}
        data = self.tio.read_data(filename='Lead_' + map[self.direction],
                                  option='Lead')
        nn = data['fine_N_c'][2]
        ns = data['nspins']
        N_c = data['N_c']
        cell_cv = data['cell_cv']
        pbc_c = data['pbc_c']
        #parsize_c = data['parsize_c']
        if type(parsize_domain) is int:
            parsize_c = None
            assert parsize_domain == self.domain_comm.size
        else:
            parsize_c = parsize_domain
        if parsize_c is None:
            parsize_c = decompose_domain(N_c, self.domain_comm.size)
        parsize_c = np.array(parsize_c)
        d1 = N_c[0] // 2
        d2 = N_c[1] // 2

        vHt_g = data['vHt_g']
        vt_sg = data['vt_sg']
        nt_sg = data['nt_sg']
        rhot_g = data['rhot_g']
        vt_sG = data['vt_sG']
        nt_sG = data['nt_sG']
        self.D_asp = data['D_asp']
        self.dH_asp = data['dH_asp']
        gd = GridDescriptor(N_c, cell_cv, pbc_c, self.domain_comm, parsize_c)
        finegd = gd.refine()

        self.boundary_vHt_g = None
        self.boundary_vHt_g1 = None
        self.boundary_vt_sg_line = None
        self.boundary_nt_sg = None
        self.boundary_rhot_g_line = None
        self.boundary_vt_sG = None
        self.boundary_nt_sG = None

        if self.tio.domain_comm.rank == 0:
            self.boundary_vHt_g = self.slice(nn, vHt_g)
            self.boundary_nt_sg = self.slice(nn, nt_sg)
            if self.direction == '-':
                other_direction = '+'
            else:
                other_direction = '-'
            h = self.h_cz / 2.0
            b_vHt_g0 = self.boundary_vHt_g.copy()
            b_vHt_g1 = self.boundary_vHt_g.copy()

            self.boundary_vHt_g = interpolate_array(b_vHt_g0, finegd, h,
                                                    self.direction)
            self.boundary_vHt_g1 = interpolate_array(b_vHt_g1, finegd, h,
                                                     other_direction)
            vt_sg = interpolate_array(vt_sg, finegd, h, self.direction)
            self.boundary_vt_sg_line = aa1d(vt_sg)
            self.boundary_nt_sg = interpolate_array(self.boundary_nt_sg,
                                                    finegd, h, self.direction)
            rhot_g = interpolate_array(rhot_g, finegd, h, self.direction)
            self.boundary_rhot_g_line = aa1d(rhot_g)

            nn /= 2
            h *= 2
            self.boundary_vt_sG = self.slice(nn, vt_sG)
            self.boundary_nt_sG = self.slice(nn, nt_sG)
            self.boundary_vt_sG = interpolate_array(self.boundary_vt_sG, gd, h,
                                                    self.direction)
            self.boundary_nt_sG = interpolate_array(self.boundary_nt_sG, gd, h,
                                                    self.direction)
예제 #6
0
파일: surrounding.py 프로젝트: qsnake/gpaw
    def abstract_boundary(self):
    #abtract the effective potential, hartree potential, and average density
    #out from the electrode calculation.
        calc = self.atoms.calc
        gd = calc.gd
        finegd = calc.finegd
        nn = finegd.N_c[2]
        ns = calc.wfs.nspins

        dim = gd.N_c
        d1 = dim[0] // 2
        d2 = dim[1] // 2

        vHt_g = finegd.collect(calc.hamiltonian.vHt_g)
        vt_sg = finegd.collect(calc.hamiltonian.vt_sg)
        nt_sg = finegd.collect(calc.density.nt_sg)
        rhot_g = finegd.collect(calc.density.rhot_g)
        vt_sG = gd.collect(calc.hamiltonian.vt_sG)
        nt_sG = gd.collect(calc.density.nt_sG)

        self.boundary_vHt_g = None
        self.boundary_vHt_g1 = None
        self.boundary_vt_sg_line = None
        self.boundary_nt_sg = None
        self.boundary_rhot_g_line = None
        self.boundary_vt_sG = None
        self.boundary_nt_sG = None

        if gd.comm.rank == 0:
            self.boundary_vHt_g = self.slice(nn, vHt_g)
            self.boundary_nt_sg = self.slice(nn, nt_sg)
            if self.direction == '-':
                other_direction= '+'
            else:
                other_direction= '-'
            h = self.h_cz / 2.0
            b_vHt_g0 = self.boundary_vHt_g.copy()
            b_vHt_g1 = self.boundary_vHt_g.copy()

            self.boundary_vHt_g = interpolate_array(b_vHt_g0,
                                                    finegd, h, self.direction)
            self.boundary_vHt_g1 = interpolate_array(b_vHt_g1,
                                                   finegd, h, other_direction)

            vt_sg = interpolate_array(vt_sg, finegd, h, self.direction)
            self.boundary_vt_sg_line =  aa1d(vt_sg)
            self.boundary_nt_sg = interpolate_array(self.boundary_nt_sg,
                                                    finegd, h, self.direction)
            rhot_g = interpolate_array(rhot_g, finegd, h, self.direction)
            self.boundary_rhot_g_line = aa1d(rhot_g)

            nn /= 2
            h *= 2
            self.boundary_vt_sG = self.slice(nn, vt_sG)
            self.boundary_nt_sG = self.slice(nn, nt_sG)
            self.boundary_vt_sG = interpolate_array(self.boundary_vt_sG,
                                                    gd, h, self.direction)
            self.boundary_nt_sG = interpolate_array(self.boundary_nt_sG,
                                                    gd, h, self.direction)

        den, ham = calc.density, calc.hamiltonian
        self.D_asp = collect_atomic_matrices(den.D_asp, den.setups,
                                             den.nspins, den.gd.comm,
                                             den.rank_a)
        self.dH_asp = collect_atomic_matrices(ham.dH_asp, ham.setups,
                                              ham.nspins, ham.gd.comm,
                                              ham.rank_a)

        del self.atoms
예제 #7
0
파일: analysor.py 프로젝트: qsnake/gpaw
    def save_ele_step(self, tp):
        if not self.matrix_foot_print:
            fd = file('matrix_sample', 'wb')
            sample = Tp_Sparse_Matrix(complex, tp.hsd.ll_index)
            sample.reset_from_others(tp.hsd.S[0], tp.hsd.H[0][0], 1.,
                                                      -1.j, init=True)
            cPickle.dump(sample, fd, 2)
            fd.close()
            self.matrix_foot_print = True
        #selfconsistent calculation: extended_calc ---> extended_atoms
        #non_selfconsistent calculation: extended_calc ---> original_atoms        
        
        calc = tp.extended_calc
        gd = calc.gd
        finegd = calc.hamiltonian.finegd

        if not tp.use_qzk_boundary and not tp.multi_leads:
            nt_sG = tp.gd.collect(tp.density.nt_sG)
        else:
            nt_sG = gd.collect(calc.density.nt_sG)            
        vt_sG = gd.collect(calc.hamiltonian.vt_sG)
        
        data = self.data
        flag = 'ele_' + str(self.n_ele_step) + '_'
        if world.rank == 0:
            nt = []
            vt = []
            for s in range(tp.nspins): 
                nts = aa1d(nt_sG[s]) 
                vts = aa1d(vt_sG[s]) * Hartree
                if not tp.multi_leads:
                    nt1 = aa1d(tp.surround.sides['-'].boundary_nt_sG[s])
                    nt2 = aa1d(tp.surround.sides['+'].boundary_nt_sG[s])
                    nts = np.append(nt1, nts)
                    nts = np.append(nts, nt2)
                nt.append(nts)
                vt.append(vts)
            data[flag + 'nt'] = np.array(nt)
            data[flag + 'vt'] = np.array(vt)
            data[flag + 'df'] = np.diag(tp.hsd.H[0][0].recover(True))
            data[flag + 'dd'] = np.diag(tp.hsd.D[0][0].recover(True))            
        else:
            nt = None
            vt = None
        
        if not tp.use_qzk_boundary and not tp.multi_leads: 
            gd = tp.finegd
            rhot_g = gd.collect(tp.density.rhot_g)
            if world.rank == 0:
                rho1 = tp.surround.sides['-'].boundary_rhot_g_line
                rho2 = tp.surround.sides['+'].boundary_rhot_g_line
                rho = aa1d(rhot_g)
                rho = np.append(rho1, rho)
                rho = np.append(rho, rho2)
                data[flag + 'rho'] = np.array(rho)
            else:
                rho = None
        else:
            gd = calc.finegd
            rhot_g = gd.collect(calc.density.rhot_g)            
            if world.rank == 0:
                rho = aa1d(rhot_g)                
                data[flag + 'rho'] = np.array(rho)
            else:
                rho = None
            
        gd = finegd
        vHt_g = gd.collect(calc.hamiltonian.vHt_g)
        if world.rank == 0:
            vHt = aa1d(vHt_g) * Hartree
            data[flag + 'vHt'] = vHt
        else:
            vHt = None
        self.n_ele_step += 1
예제 #8
0
    def abstract_boundary(self):
        #abtract the effective potential, hartree potential, and average density
        #out from the electrode calculation.
        calc = self.atoms.calc
        gd = calc.gd
        finegd = calc.finegd
        nn = finegd.N_c[2]
        ns = calc.wfs.nspins

        dim = gd.N_c
        d1 = dim[0] // 2
        d2 = dim[1] // 2

        vHt_g = finegd.collect(calc.hamiltonian.vHt_g)
        vt_sg = finegd.collect(calc.hamiltonian.vt_sg)
        nt_sg = finegd.collect(calc.density.nt_sg)
        rhot_g = finegd.collect(calc.density.rhot_g)
        vt_sG = gd.collect(calc.hamiltonian.vt_sG)
        nt_sG = gd.collect(calc.density.nt_sG)

        self.boundary_vHt_g = None
        self.boundary_vHt_g1 = None
        self.boundary_vt_sg_line = None
        self.boundary_nt_sg = None
        self.boundary_rhot_g_line = None
        self.boundary_vt_sG = None
        self.boundary_nt_sG = None

        if gd.comm.rank == 0:
            self.boundary_vHt_g = self.slice(nn, vHt_g)
            self.boundary_nt_sg = self.slice(nn, nt_sg)
            if self.direction == '-':
                other_direction = '+'
            else:
                other_direction = '-'
            h = self.h_cz / 2.0
            b_vHt_g0 = self.boundary_vHt_g.copy()
            b_vHt_g1 = self.boundary_vHt_g.copy()

            self.boundary_vHt_g = interpolate_array(b_vHt_g0, finegd, h,
                                                    self.direction)
            self.boundary_vHt_g1 = interpolate_array(b_vHt_g1, finegd, h,
                                                     other_direction)

            vt_sg = interpolate_array(vt_sg, finegd, h, self.direction)
            self.boundary_vt_sg_line = aa1d(vt_sg)
            self.boundary_nt_sg = interpolate_array(self.boundary_nt_sg,
                                                    finegd, h, self.direction)
            rhot_g = interpolate_array(rhot_g, finegd, h, self.direction)
            self.boundary_rhot_g_line = aa1d(rhot_g)

            nn /= 2
            h *= 2
            self.boundary_vt_sG = self.slice(nn, vt_sG)
            self.boundary_nt_sG = self.slice(nn, nt_sG)
            self.boundary_vt_sG = interpolate_array(self.boundary_vt_sG, gd, h,
                                                    self.direction)
            self.boundary_nt_sG = interpolate_array(self.boundary_nt_sG, gd, h,
                                                    self.direction)

        den, ham = calc.density, calc.hamiltonian
        self.D_asp = collect_atomic_matrices(den.D_asp, den.setups, den.nspins,
                                             den.gd.comm, den.rank_a)
        self.dH_asp = collect_atomic_matrices(ham.dH_asp, ham.setups,
                                              ham.nspins, ham.gd.comm,
                                              ham.rank_a)

        del self.atoms