Esempio n. 1
0
    def __init__(self, pfile, n, atom1, atom2, data, box, pdr, step, No_Windows=False):

        # This class aim is to calculate the Deconvolution of the RDF
        # the parameters are :
        #    - pfile  is the output file (ascii/netcdf)
        #    - n = is the neibhor number
        #    - atom1/2 give the number of the atom in typat
        #    - box : give the number of box wide for the calculculation of g(r)
        #    - pdr   : give the radial precision of the calculation
        #    - pstep : give the self.increment for the step loop

        file = pfile

        pos = file.getXCart()            # position of atom (cartesian)

        nei = n

        inc = step                    #incrementation

        acell = file.getAcell()        #acell
        a_max = max(acell[:,0])
        b_max = max(acell[:,1])
        c_max = max(acell[:,2])

        if box >= 0:

            f = (1/2.+ box)           # factor of maximum radius

        else: # box < 0
            
            f = 3**0.5/2.

        rmax = f*min(a_max,b_max,c_max)

        deltaR = pdr                           # delta r  (Bohr)

        maxbin = int((rmax/deltaR))            # number of iteration

        typat = file.getTypat()              # Type of particule

        if atom1 == 0:
            indexAtom1 = array([i for i,x in enumerate(typat) if x == 1 and 2],dtype=int) + 1
        else:
            indexAtom1 = array([i for i,x in enumerate(typat) if x == atom1],dtype=int) + 1 #get list of the index of typat1 (+1 for fortran)

            
        if atom2 == 0:
            indexAtom2 = array([i for i,x in enumerate(typat) if x == 1 and 2 ],dtype=int) + 1
        else:
            indexAtom2 = array([i for i,x in enumerate(typat) if x == atom2],dtype=int) + 1 #get list of the index of typat2 (+1 for fortran)
                
        nbtime =  len(pos)                    # final step

        self.r = arange(maxbin)*deltaR

        self.n = topo.n_distribution(nei,nbtime,data,inc,deltaR,indexAtom1,indexAtom2,0,self.r)        
Esempio n. 2
0
    def __init__(self, nei, pfile, atom1, atom2, pdr, pstep, No_Windows=False):

        # This class aim is to calculate the Neighbor Distrubution Function
        # the parameters are :
        #    - nei gives the neith neibours we consider.
        #    - pfile  is the output file (ascii/netcdf)
        #    - atom1 give the number of the atom in typat
        #    - pdt   : give the dtheta for the calculation
        #    - pstep : give the self.increment for the step loop

        file = pfile

        pos = file.getXCart()  # position of atom (cartesian)

        inc = pstep  #incrementation

        acell = file.getAcell()  #acell
        a = acell[:, 0]
        b = acell[:, 1]
        c = acell[:, 2]

        rprim = zeros((3, 3))  # primitives vectors of the cell
        rprim[0] = file.getRPrim()[0, 0]
        rprim[1] = file.getRPrim()[0, 1]
        rprim[2] = file.getRPrim()[0, 2]

        deltaR = pdr

        typat = file.getTypat()  # Type of particule

        if atom1 == 0:
            indexAtom1 = array(
                [i
                 for i, x in enumerate(typat) if x == 1 and 2], dtype=int) + 1
        else:
            indexAtom1 = array(
                [i for i, x in enumerate(typat) if x == atom1], dtype=int
            ) + 1  #get list of the index of typat1 (+1 for fortran)

        if atom2 == 0:
            indexAtom2 = array(
                [i
                 for i, x in enumerate(typat) if x == 1 and 2], dtype=int) + 1
        else:
            indexAtom2 = array(
                [i for i, x in enumerate(typat) if x == atom2], dtype=int
            ) + 1  #get list of the index of typat2 (+1 for fortran)

        nbtime = len(pos)  # final step

        nba = len(pos[0])  # number of atom

        it = (int(nbtime / inc) + 1) * nba * (nba - 1)

        self.m = topo.m_distribution(nei, nbtime, pos, rprim, inc, it, a, b, c,
                                     indexAtom1, indexAtom2)

        maxi = self.m[0]

        mini = self.m[1]

        data = self.m[2]

        self.r = []

        for i in range(int(mini * 1000), int(maxi * 1000 + 1),
                       int(deltaR * 1000)):

            i = i / 1000.

            self.r.append(i)

        self.n = topo.n_distribution(nei, nbtime, data, inc, deltaR,
                                     indexAtom1, indexAtom2, mini, self.r)