Esempio n. 1
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)
Esempio n. 2
0
    def __init__(self,
                 pfile,
                 mode,
                 atom1,
                 atom2,
                 box,
                 pdr,
                 pstep,
                 No_Windows=False):

        # This class aim is to calculate the Radial Distrubution Function
        # the parameters are :
        #    - mode = 0 for normal RDF, 1 for its deconvolution
        #    - pfile  is the output file (ascii/netcdf)
        #    - 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)

        inc = pstep  # incrementation

        acell = file.getAcell()  # acell
        a = acell[:, 0]
        b = acell[:, 1]
        c = acell[:, 2]
        a_max = max(acell[:, 0])
        b_max = max(acell[:, 1])
        c_max = max(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]

        rho = 1 / file.getVol()  # density

        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

        if mode == 0:

            self.g = topo.pair_distribution(nbtime, pos, rprim, f, inc, a, b,
                                            c, deltaR, rho, indexAtom1,
                                            indexAtom2, self.r)

            self.r += deltaR / 2.

        else:  #mode == 1

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

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

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