Пример #1
0
    def __init__(self, type, direction, kpt_comm, domain_comm, h):
        # Direction: '-' for the left electrode, '+' for the right electrode

        self.type = type
        self.direction = direction
        self.kpt_comm = kpt_comm
        self.domain_comm = domain_comm
        self.tio = Transport_IO(kpt_comm, domain_comm)
        self.h_cz = h
Пример #2
0
    def __init__(self, type, direction, kpt_comm, domain_comm, h):
        # Direction: '-' for the left electrode, '+' for the right electrode

        self.type = type
        self.direction = direction
	self.kpt_comm = kpt_comm
	self.domain_comm = domain_comm
	self.tio = Transport_IO(kpt_comm, domain_comm)
	self.h_cz = h
Пример #3
0
class Side:
    #Describe the electrode boundary
    def __init__(self, type, direction, kpt_comm, domain_comm, h):
        # Direction: '-' for the left electrode, '+' for the right electrode

        self.type = type
        self.direction = direction
	self.kpt_comm = kpt_comm
	self.domain_comm = domain_comm
	self.tio = Transport_IO(kpt_comm, domain_comm)
	self.h_cz = h

    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)

    def slice(self, nn, in_array):
        if self.type == 'LR':
            seq1 = np.arange(nn)
            seq2 = np.arange(nn)
            di = len(in_array.shape) - 1
            if self.direction == '-':
                slice_array = np.take(in_array, seq1, axis=di)
            else:
                slice_array = np.take(in_array, seq2, axis=di)
        return slice_array
Пример #4
0
class Side:
    #Describe the electrode boundary
    def __init__(self, type, direction, kpt_comm, domain_comm, h):
        # Direction: '-' for the left electrode, '+' for the right electrode

        self.type = type
        self.direction = direction
        self.kpt_comm = kpt_comm
        self.domain_comm = domain_comm
        self.tio = Transport_IO(kpt_comm, domain_comm)
        self.h_cz = h

    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)

    def slice(self, nn, in_array):
        if self.type == 'LR':
            seq1 = np.arange(nn)
            seq2 = np.arange(nn)
            di = len(in_array.shape) - 1
            if self.direction == '-':
                slice_array = np.take(in_array, seq1, axis=di)
            else:
                slice_array = np.take(in_array, seq2, axis=di)
        return slice_array