예제 #1
0
    def parser(self):
        s = System()
        s.pbc = v2lattice(self.a, self.b, self.c)
        for i in self.coords:
            # n is used to distinguish the type of data file
            n = 0
            for j in i:
                # ignore the comments
                if "#" in j:
                    break
                n += 1
            atom = Atom()
            atom.an = int(i[0])
            if n == 7:
                # n = 7 is full type
                atom.name = self.atomtypes[int(i[2]) - 1]
                atom.x[0] = float(i[4]) 
                atom.x[1] = float(i[5]) 
                atom.x[2] = float(i[6]) 
                s.atoms.append(atom)
            elif n == 5 or n == 8:
                # n = 5 is a charge type, n = 8 is a charge type generated
                # by restart2data
                atom.name = self.atomtypes[int(i[1]) - 1]
                atom.x[0] = float(i[3]) 
                atom.x[1] = float(i[4]) 
                atom.x[2] = float(i[5]) 
                s.atoms.append(atom)

        return s
예제 #2
0
파일: pdb.py 프로젝트: karthipitt/simpy
    def parser(self,):
        s = System()
        if self.name:
            s.name = self.name
        else:
            s.name = "pdbjob"
        if self.pbc:
            s.pbc = [float(i) for i in self.pbc]
        for i in self.coords:
            a = Atom()
            # note need to confirm with the standary pdb format
            a.name = i[12:17].strip()
            a.x[0] = float(i[27:39])
            a.x[1] = float(i[39:47])
            a.x[2] = float(i[47:55])
            s.atoms.append(a)

        # only storage the first half of the bond matrix
        for i in self.connect:
            tokens = i.strip().split()
            a1 = int(tokens[1])
            for j in [int(k) for k in tokens[2:]]:
                a2 = j
                if a2 > a1:
                    s.connect.append([a1, a2])
        return s
예제 #3
0
 def parser(self,):
     """ parse poscar to system
     @todo : handle coordinates acoording to Direct tag
     """
     s = System()
     scale = float(self.scale)
     a = [scale*float(i) for i in self.a]
     b = [scale*float(i) for i in self.b]
     c = [scale*float(i) for i in self.c]
     s.name = self.name
     s.pbc = v2lattice(a, b, c)
     s.geotag = "XTLGRF 200"
     for i in range(len(self.atoms)):
         if i == 0:
             prev = 0
             now = int(self.atoms[0])
         else:
             prev = now
             now += int(self.atoms[i])
         for j in range(prev, now):
             atom = Atom()
             atom.name = self.atomtypes[i]
             x = float(self.coords[j][0])
             y = float(self.coords[j][1])
             z = float(self.coords[j][2])
             atom.x[0] = a[0]*x + b[0]*y + c[0]*z
             atom.x[1] = a[1]*x + b[1]*y + c[1]*z
             atom.x[2] = a[2]*x + b[2]*y + c[2]*z
             s.atoms.append(atom)
     return s
예제 #4
0
파일: jaguar.py 프로젝트: erinshawusc/simpy
 def parser(self,):
     s = System()
     for i in self.atoms:
         a = Atom()
         a.name = i[0]
         a.x[0] = float(i[1].strip("#"))
         a.x[1] = float(i[2].strip("#"))
         a.x[2] = float(i[3].strip("#"))
         s.atoms.append(a)
     return s
예제 #5
0
파일: car.py 프로젝트: carlos-salgado/simpy
 def parser(self,):
     s = System()
     if self.pbc:
         s.pbc = [float(i) for i in self.pbc.split()[1:7]]
     for i in self.coords:
         a = Atom()
         a.name = i[:6].strip()
         a.x[0] = float(i[6:20])
         a.x[1] = float(i[20:35])
         a.x[2] = float(i[35:50])
         s.atoms.append(a)
     return s
예제 #6
0
파일: geo.py 프로젝트: carlos-salgado/simpy
 def parser(self,):
     """ parse geo file into System
     """
     s = System()
     s.name = self.name
     s.pbc = [float(i) for i in self.pbc]
     s.geotag = self.type
     for i in self.coords:
         a = Atom()
         a.name= i[13:16]
         a.x[0] = float(i[31:41])
         a.x[1] = float(i[41:51])
         a.x[2] = float(i[51:61])
         s.atoms.append(a)
     return s
예제 #7
0
파일: xyz.py 프로젝트: carlos-salgado/simpy
 def parser(self,):
     s = System()
     if self.name:
         s.name = self.name
     else:
         s.name = "xyzjob"
     for i in self.coords:
         tokens = i.strip().split()
         a = Atom()
         a.name = tokens[0]
         a.x[0] = float(tokens[1])
         a.x[1] = float(tokens[2])
         a.x[2] = float(tokens[3])
         s.atoms.append(a)
     return s
예제 #8
0
파일: g03.py 프로젝트: erinshawusc/simpy
 def parser(self,):
     s = System()
     s.name = self.name
     s.methods = self.__parse_keyword()
     s.spin = self.spin
     s.charge = self.charge
     for i in self.redundant:
         s.redundant.append(i.strip().split())
     for i in self.atoms:
         a = Atom()
         a.name = ELEMENT[int(i[1])]
         a.x[0] = float(i[3])
         a.x[1] = float(i[4])
         a.x[2] = float(i[5])
         s.atoms.append(a)
     return s
예제 #9
0
 def parser(self, ):
     """ parse poscar to system
     @todo : handle coordinates acoording to Direct tag
     """
     s = System()
     scale = float(self.scale)
     a = [scale * float(i) for i in self.a]
     b = [scale * float(i) for i in self.b]
     c = [scale * float(i) for i in self.c]
     s.name = self.name
     s.pbc = v2lattice(a, b, c)
     s.natoms = self.natoms
     s.atomtypes = self.atomtypes
     s.scaleFactor = self.scale
     s.geotag = "XTLGRF 200"
     for i in range(len(self.natoms)):
         if i == 0:
             prev = 0
             now = int(self.natoms[0])
         else:
             prev = now
             now += int(self.natoms[i])
         for j in range(prev, now):
             atom = Atom()
             #print self.atomtypes, i
             atom.name = self.atomtypes[i]
             x = float(self.coords[j][0])
             y = float(self.coords[j][1])
             z = float(self.coords[j][2])
             atom.xFrac = [x, y, z]
             atom.x[0] = a[0] * x + b[0] * y + c[0] * z
             atom.x[1] = a[1] * x + b[1] * y + c[1] * z
             atom.x[2] = a[2] * x + b[2] * y + c[2] * z
             if len(self.coords[j]) == 6 and self.sd == 1:
                 xr = self.coords[j][3]
                 yr = self.coords[j][4]
                 zr = self.coords[j][5]
                 if xr == "F":
                     atom.xr[0] = 1
                 if yr == "F":
                     atom.xr[1] = 1
                 if zr == "F":
                     atom.xr[2] = 1
             s.atoms.append(atom)
     return s
예제 #10
0
파일: g03.py 프로젝트: erinshawusc/simpy
 def parser(self,):
     s = System()
     s.options = self.options
     s.methods = self.methods
     for i in self.redundant:
         s.redundant.append(i.strip().split())
     s.connect = self.connect
     s.spin = self.spin
     s.charge = self.charge
     s.name = self.title.strip()
     for i in self.atoms:
         a = Atom()
         a.name = i[0]
         a.x[0] = float(i[1])
         a.x[1] = float(i[2])
         a.x[2] = float(i[3])
         s.atoms.append(a)
     return s
예제 #11
0
    def parser(self):
        s = System()
        s.pbc = v2lattice(self.a, self.b, self.c)
        s.atomtypes = self.atomtypes
        s.n_atoms = self.n_atoms
        s.n_bonds = self.n_bonds
        s.n_angles = self.n_angles
        s.n_dihedrals = self.n_dihedrals
        s.n_impropers = self.n_impropers
        s.n_atomtypes = self.n_atomtypes
        s.n_bondtypes = self.n_bondtypes
        s.n_angletypes = self.n_angletypes
        s.n_dihedraltypes = self.n_dihedraltypes
        s.n_impropertypes = self.n_impropertypes
        s.bonds = self.bonds
        s.angles = self.angles
        s.dihedrals = self.dihedrals
        s.ffparams = self.ffparams

        for i in self.coords:
            # n is used to distinguish the type of data file
            n = 0
            for j in i:
                # ignore the comments
                if "#" in j:
                    break
                n += 1
            atom = Atom()
            atom.an = int(i[0])
            if n == 7:
                # n = 7 is full type
                atom.resn = int(i[1])
                atom.name = self.elements[int(i[2]) - 1]
                atom.element = self.elements[int(i[2]) - 1]
                atom.type2 = int(i[2])
                atom.charge = float(i[3])
                atom.x[0] = float(i[4]) 
                atom.x[1] = float(i[5]) 
                atom.x[2] = float(i[6]) 
                s.atoms.append(atom)
        return s
예제 #12
0
파일: add.py 프로젝트: erinshawusc/simpy
def add_h(b, centers, cn):
    dx = DELTA_X
    zl = b.pbc[2]
    b1 = copy.deepcopy(b)
    n_cut = 10
    for i in range(len(cn)):
        n = int(cn[i])
        print "processing %d"%(n*1.0/8183*100)
        if n < n_cut:
            a = Atom()
            a.name = "H"
            a.element = "H"
            x0 = b.atoms[i].x[0]
            y0 = b.atoms[i].x[1]
            z0 = b.atoms[i].x[2]
            z0 = z0 - int(z0/zl)*zl
            n_sl = int(z0/dx)
            x1 = centers[n_sl][0]
            y1 = centers[n_sl][1]
            z1 = centers[n_sl][2]
            r2 = (x0-x1)*(x0-x1)
            r2 += (y0-y1)*(y0-y1)
            r2 += (z0-z1)*(z0-z1)
            r1 = math.sqrt(r2)
            r = r1 + 1.5
            s = r/r1
            x = s*(x0-x1) + x1
            y = s*(y0-y1) + y1
            z = s*(z0-z1) + z1
            a.x[0] = x 
            a.x[1] = y
            a.x[2] = z
            b1.atoms.append(a)
    toPdb(b1, "add_h.pdb")
예제 #13
0
파일: pdb.py 프로젝트: tarbaig/simpy
    def parser(self, ):
        s = System()
        if self.name:
            s.name = self.name
        else:
            s.name = "pdbjob"
        if self.pbc:
            s.pbc = [float(i) for i in self.pbc]
        for i in self.coords:
            a = Atom()
            # note need to confirm with the standary pdb format
            a.name = i[12:17].strip()
            a.x[0] = float(i[27:38])
            a.x[1] = float(i[38:46])
            a.x[2] = float(i[46:55])
            s.atoms.append(a)

        # only storage the first half of the bond matrix
        for i in self.connect:
            tokens = i.strip().split()
            a1 = int(tokens[1])
            for j in [int(k) for k in tokens[2:]]:
                a2 = j
                if a2 > a1:
                    s.connect.append([a1, a2])
        return s
예제 #14
0
 def parser(self,):
     """ parse poscar to system
     @todo : handle coordinates acoording to Direct tag
     """
     s = System()
     scale = float(self.scale)
     a = [scale*float(i) for i in self.a]
     b = [scale*float(i) for i in self.b]
     c = [scale*float(i) for i in self.c]
     s.name = self.name
     s.pbc = v2lattice(a, b, c)
     s.natoms = self.natoms
     s.atomtypes = self.atomtypes
     s.scaleFactor = self.scale
     s.geotag = "XTLGRF 200"
     for i in range(len(self.natoms)):
         if i == 0:
             prev = 0
             now = int(self.natoms[0])
         else:
             prev = now
             now += int(self.natoms[i])
         for j in range(prev, now):
             atom = Atom()
             #print self.atomtypes, i
             atom.name = self.atomtypes[i]
             x = float(self.coords[j][0])
             y = float(self.coords[j][1])
             z = float(self.coords[j][2])
             atom.xFrac = [x, y, z]
             atom.x[0] = a[0]*x + b[0]*y + c[0]*z
             atom.x[1] = a[1]*x + b[1]*y + c[1]*z
             atom.x[2] = a[2]*x + b[2]*y + c[2]*z
             if len(self.coords[j]) == 6 and self.sd == 1:
                 xr = self.coords[j][3]
                 yr = self.coords[j][4]
                 zr = self.coords[j][5]
                 if xr == "F":
                     atom.xr[0] = 1
                 if yr == "F":
                     atom.xr[1] = 1
                 if zr == "F":
                     atom.xr[2] = 1
             s.atoms.append(atom)
     return s
예제 #15
0
파일: jaguar.py 프로젝트: tarbaig/simpy
 def parser(self, ):
     s = System()
     for i in self.atoms:
         a = Atom()
         a.name = i[0]
         a.x[0] = float(i[1].strip("#"))
         a.x[1] = float(i[2].strip("#"))
         a.x[2] = float(i[3].strip("#"))
         s.atoms.append(a)
     return s
예제 #16
0
파일: car.py 프로젝트: tarbaig/simpy
 def parser(self, ):
     s = System()
     if self.pbc:
         s.pbc = [float(i) for i in self.pbc.split()[1:7]]
     for i in self.coords:
         a = Atom()
         a.name = i[:6].strip()
         a.x[0] = float(i[6:20])
         a.x[1] = float(i[20:35])
         a.x[2] = float(i[35:50])
         s.atoms.append(a)
     return s
예제 #17
0
 def parser(self, ):
     """ parse geo file into System
     """
     s = System()
     s.name = self.name
     s.pbc = [float(i) for i in self.pbc]
     s.geotag = self.type
     for i in self.coords:
         a = Atom()
         a.name = i[13:16]
         a.x[0] = float(i[31:41])
         a.x[1] = float(i[41:51])
         a.x[2] = float(i[51:61])
         s.atoms.append(a)
     return s
예제 #18
0
파일: xyz.py 프로젝트: tarbaig/simpy
 def parser(self, ):
     s = System()
     if self.name:
         s.name = self.name
     else:
         s.name = "xyzjob"
     for i in self.coords:
         tokens = i.strip().split()
         a = Atom()
         a.name = tokens[0]
         a.x[0] = float(tokens[1])
         a.x[1] = float(tokens[2])
         a.x[2] = float(tokens[3])
         s.atoms.append(a)
     return s
예제 #19
0
 def parser(self, ):
     s = System()
     s.name = self.name
     s.methods = self.__parse_keyword()
     s.spin = self.spin
     s.charge = self.charge
     for i in self.redundant:
         s.redundant.append(i.strip().split())
     for i in self.atoms:
         a = Atom()
         a.name = ELEMENT[int(i[1])]
         a.x[0] = float(i[3])
         a.x[1] = float(i[4])
         a.x[2] = float(i[5])
         s.atoms.append(a)
     return s
예제 #20
0
 def parser(self,):
     """ parse cfg to system
     """
     s = System()
     s.pbc = v2lattice(a, b, c)
     s.natoms = self.natoms
     for i in range(s.natoms):
         atom = Atom()
         atom.name = self.coords[i][1][0]
         x = float(self.coords[i][2][0])
         y = float(self.coords[i][2][1])
         z = float(self.coords[i][2][2])
         atom.x[0] = a[0]*x + b[0]*y + c[0]*z
         atom.x[1] = a[1]*x + b[1]*y + c[1]*z
         atom.x[2] = a[2]*x + b[2]*y + c[2]*z
         s.atoms.append(atom)
예제 #21
0
 def parser(self, ):
     s = System()
     s.options = self.options
     s.methods = self.methods
     for i in self.redundant:
         s.redundant.append(i.strip().split())
     s.connect = self.connect
     s.spin = self.spin
     s.charge = self.charge
     s.name = self.title.strip()
     for i in self.atoms:
         a = Atom()
         a.name = i[0]
         a.x[0] = float(i[1])
         a.x[1] = float(i[2])
         a.x[2] = float(i[3])
         s.atoms.append(a)
     return s
예제 #22
0
파일: add.py 프로젝트: tarbaig/simpy
def add_o(b, centers, cn):
    """add o
    """
    dx = DELTA_X
    zl = b.pbc[2]
    b1 = copy.deepcopy(b)
    n_cut = 10
    for i in range(len(cn)):
        print "processing %d"%(i*1.0/8183*100)
        n = int(cn[i])
        token = random.random()
        if n < n_cut and token > 0.9:
            a = Atom()
            a.name = "O"
            a.element = "O"
            x0 = b.atoms[i].x[0]
            y0 = b.atoms[i].x[1]
            z0 = b.atoms[i].x[2]
            z0 = z0 - int(z0/zl)*zl
            n_sl = int(z0/dx)
            x1 = centers[n_sl][0]
            y1 = centers[n_sl][1]
            z1 = centers[n_sl][2]
            r2 = (x0-x1)*(x0-x1)
            r2 += (y0-y1)*(y0-y1)
            r2 += (z0-z1)*(z0-z1)
            r1 = math.sqrt(r2)
            r = r1 + 2.0
            s = r/r1
            x = s*(x0-x1) + x1 + 1.0
            y = s*(y0-y1) + y1 + 1.0
            z = s*(z0-z1) + z1
            a.x[0] = x 
            a.x[1] = y
            a.x[2] = z
            b1.atoms.append(a)
    toPdb(b1, "add_o.pdb")
예제 #23
0
파일: add.py 프로젝트: tarbaig/simpy
def add_oh(b, centers, cn, n_ignore, ndx):
    """add oh
    """
    dx = DELTA_X
    zl = b.pbc[2]
    b1 = copy.deepcopy(b)
    b2 = copy.deepcopy(b)
    
    a = Atom()
    a.name = "O"
    a.element = "O"
    b2.atoms.append(a)
    a = Atom()
    a.name = "H"
    a.element = "H"
    b2.atoms.append(a)
    
    n_cut = 10
    r_pt_oh = 2.0
    r_oh = 1.0
    for i in range(len(cn)):
        #print "processing %d"%(i*1.0/len(cn)*100)
        token = random.random()
        n = int(cn[i])
        if n < n_cut and token >= 0.0:
            a1 = Atom()
            a1.name = "O"
            a1.element = "O"
            x0 = b.atoms[i].x[0]
            y0 = b.atoms[i].x[1]
            z0 = b.atoms[i].x[2]
            z0 = z0 - int(z0/zl)*zl
            n_sl = int(z0/dx)
            x1 = centers[n_sl][0]
            y1 = centers[n_sl][1]
            z1 = centers[n_sl][2]
            r2 = (x0-x1)*(x0-x1)
            r2 += (y0-y1)*(y0-y1)
            r2 += (z0-z1)*(z0-z1)
            r1 = math.sqrt(r2)
            r = r1 + r_pt_oh
            s = r/r1
            x = s*(x0-x1) + x1 
            y = s*(y0-y1) + y1 
            z = s*(z0-z1) + z1
            a1.x[0] = x 
            a1.x[1] = y
            a1.x[2] = z
            b1.atoms.append(a1)
            b2.atoms[-2].x[0] = x
            b2.atoms[-2].x[1] = y
            b2.atoms[-2].x[2] = z

            a2 = Atom()
            a2.name = "H"
            a2.element = "H"
            r = r1 + r_pt_oh + r_oh
            s = r/r1
            x = s*(x0-x1) + x1 
            y = s*(y0-y1) + y1 
            z = s*(z0-z1) + z1
            a2.x[0] = x 
            a2.x[1] = y
            a2.x[2] = z
            b1.atoms.append(a2)
            b2.atoms[-1].x[0] = x
            b2.atoms[-1].x[1] = y
            b2.atoms[-1].x[2] = z
            if i >= n_ignore - 1:
                toPdb(b2, "%05d_%05d.pdb"%(i, ndx[i]))

    toPdb(b1, "add_oh.pdb")
예제 #24
0
    def parser(self, ):
        """ parse dump file into System
        """
        s = System()
        s.name = self.name

        # transform a, b, c to [xx, xy, yz]
        # [yx, yy, yz] and [zx, zy, zz]
        # caution! A hard coded code for specified dump file
        a = []
        # some dump file only have xl and xh. Normalize to three terms
        if len(self.a) == 2:
            self.a.append(0.0)
        if len(self.b) == 2:
            self.b.append(0.0)
        if len(self.c) == 2:
            self.c.append(0.0)
        #a.append(float(self.a[1]) - float(self.a[0]))
        #@ref: http://lammps.sandia.gov/doc/Section_howto.html#howto_12
        xlo = float(self.a[0]) - min(0.0, float(self.a[2]), float(self.b[2]),\
              float(self.a[2]) + float(self.c[2]))
        xhi = float(self.a[1]) - max(0.0, float(self.a[2]), float(self.b[2]),\
              float(self.a[2]) + float(self.c[2]))
        a.append(xhi - xlo)
        a.append(0.0)
        a.append(0.0)
        #print a
        b = []
        b.append(float(self.a[2]))
        ylo = float(self.b[0]) - min(0.0, float(self.c[2]))
        yhi = float(self.b[1]) - max(0.0, float(self.c[2]))
        b.append(yhi - ylo)
        b.append(0.0)
        #print b
        c = []
        c.append(float(self.b[2]))
        c.append(float(self.c[2]))
        c.append(float(self.c[1]) - float(self.c[0]))
        s.pbc = v2lattice(a, b, c)
        #print c
        # begin to parse atoms
        flag = 0
        if os.path.exists("inp"):
            flag = 1
            n2a = self.parseInp()
        counter = 0
        for i in self.coords:
            atom = Atom()
            if flag:
                atom.name = n2a[int(i[1])]
            else:
                atom.name = i[1]
            """
            atom.x[0] = float(i[3])
            atom.x[1] = float(i[4])
            atom.x[2] = float(i[5])
            """
            atom.an = counter + 1
            atom.x[0] = float(i[2])
            atom.x[1] = float(i[3])
            atom.x[2] = float(i[4])
            s.atoms.append(atom)
            counter += 1
        return s
예제 #25
0
파일: add.py 프로젝트: erinshawusc/simpy
def add_oh(b, centers, cn, n_ignore, ndx):
    dx = DELTA_X
    zl = b.pbc[2]
    b1 = copy.deepcopy(b)
    b2 = copy.deepcopy(b)
    
    a = Atom()
    a.name = "O"
    a.element = "O"
    b2.atoms.append(a)
    a = Atom()
    a.name = "H"
    a.element = "H"
    b2.atoms.append(a)
    
    n_cut = 10
    r_pt_oh = 2.0
    r_oh = 1.0
    for i in range(len(cn)):
        #print "processing %d"%(i*1.0/len(cn)*100)
        token = random.random()
        n = int(cn[i])
        if n < n_cut and token >= 0.0:
            a1 = Atom()
            a1.name = "O"
            a1.element = "O"
            x0 = b.atoms[i].x[0]
            y0 = b.atoms[i].x[1]
            z0 = b.atoms[i].x[2]
            z0 = z0 - int(z0/zl)*zl
            n_sl = int(z0/dx)
            x1 = centers[n_sl][0]
            y1 = centers[n_sl][1]
            z1 = centers[n_sl][2]
            r2 = (x0-x1)*(x0-x1)
            r2 += (y0-y1)*(y0-y1)
            r2 += (z0-z1)*(z0-z1)
            r1 = math.sqrt(r2)
            r = r1 + r_pt_oh
            s = r/r1
            x = s*(x0-x1) + x1 
            y = s*(y0-y1) + y1 
            z = s*(z0-z1) + z1
            a1.x[0] = x 
            a1.x[1] = y
            a1.x[2] = z
            b1.atoms.append(a1)
            b2.atoms[-2].x[0] = x
            b2.atoms[-2].x[1] = y
            b2.atoms[-2].x[2] = z

            a2 = Atom()
            a2.name = "H"
            a2.element = "H"
            r = r1 + r_pt_oh + r_oh
            s = r/r1
            x = s*(x0-x1) + x1 
            y = s*(y0-y1) + y1 
            z = s*(z0-z1) + z1
            a2.x[0] = x 
            a2.x[1] = y
            a2.x[2] = z
            b1.atoms.append(a2)
            b2.atoms[-1].x[0] = x
            b2.atoms[-1].x[1] = y
            b2.atoms[-1].x[2] = z
            if i >= n_ignore - 1:
                toPdb(b2, "%05d_%05d.pdb"%(i, ndx[i]))

    toPdb(b1, "add_oh.pdb")
예제 #26
0
파일: msd.py 프로젝트: karthipitt/simpy
 def __lineToAtom(self, line):
     """put each coordinate line into atom class"""
     ai = Atom()
     tokens = line.strip().split()
     ai.number = int(tokens[0])
     ai.name = tokens[1]
     ai.an = tokens[2]
     ai.type1 = tokens[3]
     ai.type2 = tokens[4]
     ai.charge = float(tokens[5])
     ai.x[0] = float(tokens[6])
     ai.x[1] = float(tokens[7])
     ai.x[2] = float(tokens[8])
     ai.resn = int(tokens[9])
     ai.resname = tokens[10]
     ai.cg = int(tokens[11])
     return ai
예제 #27
0
    def parser(self):
        s = System()
        s.pbc = v2lattice(self.a, self.b, self.c)
        for i in self.coords:
            # n is used to distinguish the type of data file
            n = 0
            for j in i:
                # ignore the comments
                if "#" in j:
                    break
                n += 1
            atom = Atom()
            atom.an = int(i[0])
            if n == 7:
                # n = 7 is full type
                atom.name = self.atomtypes[int(i[2]) - 1]
                atom.x[0] = float(i[4])
                atom.x[1] = float(i[5])
                atom.x[2] = float(i[6])
                s.atoms.append(atom)
            elif n == 6 or n == 9:
                # n = 5 is a charge type, n = 8 is a charge type generated
                # by restart2data
                atom.name = self.atomtypes[int(i[1]) - 1]
                atom.x[0] = float(i[3])
                atom.x[1] = float(i[4])
                atom.x[2] = float(i[5])
                s.atoms.append(atom)

        return s
예제 #28
0
    def parser(self):
        s = System()
        s.pbc = v2lattice(self.a, self.b, self.c)
        s.atomtypes = self.atomtypes
        s.n_atoms = self.n_atoms
        s.n_bonds = self.n_bonds
        s.n_angles = self.n_angles
        s.n_dihedrals = self.n_dihedrals
        s.n_impropers = self.n_impropers
        s.n_atomtypes = self.n_atomtypes
        s.n_bondtypes = self.n_bondtypes
        s.n_angletypes = self.n_angletypes
        s.n_dihedraltypes = self.n_dihedraltypes
        s.n_impropertypes = self.n_impropertypes
        s.bonds = self.bonds
        s.angles = self.angles
        s.dihedrals = self.dihedrals
        s.ffparams = self.ffparams

        for i in self.coords:
            # n is used to distinguish the type of data file
            n = 0
            for j in i:
                # ignore the comments
                if "#" in j:
                    break
                n += 1
            atom = Atom()
            atom.an = int(i[0])
            if n == 7:
                # n = 7 is full type
                atom.resn = int(i[1])
                atom.name = self.elements[int(i[2]) - 1]
                atom.element = self.elements[int(i[2]) - 1]
                atom.type2 = int(i[2])
                atom.charge = float(i[3])
                atom.x[0] = float(i[4])
                atom.x[1] = float(i[5])
                atom.x[2] = float(i[6])
                s.atoms.append(atom)
        return s
예제 #29
0
파일: msd.py 프로젝트: tarbaig/simpy
 def __lineToAtom(self, line):
     """put each coordinate line into atom class"""
     ai = Atom()
     tokens = line.strip().split()
     ai.number = int(tokens[0])
     ai.name = tokens[1]
     ai.an = tokens[2]
     ai.type1 = tokens[3]
     ai.type2 = tokens[4]
     ai.charge = float(tokens[5])
     ai.x[0] = float(tokens[6])
     ai.x[1] = float(tokens[7])
     ai.x[2] = float(tokens[8])
     ai.resn = int(tokens[9])
     ai.resname = tokens[10]
     ai.cg = int(tokens[11])
     return ai
예제 #30
0
파일: dump.py 프로젝트: erinshawusc/simpy
    def parser(self,):
        """ parse dump file into System
        """
        s = System()
        s.name = self.name

        # transform a, b, c to [xx, xy, yz]
        # [yx, yy, yz] and [zx, zy, zz]
        # caution! A hard coded code for specified dump file
        a = []
        # some dump file only have xl and xh. Normalize to three terms
        if len(self.a) == 2:
            self.a.append(0.0)
        if len(self.b) == 2:
            self.b.append(0.0)
        if len(self.c) == 2:
            self.c.append(0.0)
        #a.append(float(self.a[1]) - float(self.a[0]))
        #@ref: http://lammps.sandia.gov/doc/Section_howto.html#howto_12
        xlo = float(self.a[0]) - min(0.0, float(self.a[2]), float(self.b[2]),\
              float(self.a[2]) + float(self.c[2])) 
        xhi = float(self.a[1]) - max(0.0, float(self.a[2]), float(self.b[2]),\
              float(self.a[2]) + float(self.c[2]))
        a.append(xhi - xlo)
        a.append(0.0)
        a.append(0.0)
        #print a
        b = []
        b.append(float(self.a[2]))
        ylo = float(self.b[0]) - min(0.0, float(self.c[2]))
        yhi = float(self.b[1]) - max(0.0, float(self.c[2]))
        b.append(yhi - ylo)
        b.append(0.0)
        #print b
        c = []
        c.append(float(self.b[2]))
        c.append(float(self.c[2]))
        c.append(float(self.c[1]) - float(self.c[0]))
        s.pbc = v2lattice(a, b, c)
        #print c
        # begin to parse atoms
        flag = 0
        if os.path.exists("inp"):
            flag = 1
            n2a = self.parseInp()
        counter = 0
        for i in self.coords:
            atom = Atom()
            if flag:
                atom.name = n2a[int(i[1])]
            else:
                atom.name = i[1]
            """
            atom.x[0] = float(i[3])
            atom.x[1] = float(i[4])
            atom.x[2] = float(i[5])
            """
            atom.an = counter + 1
            atom.x[0] = float(i[2])
            atom.x[1] = float(i[3])
            atom.x[2] = float(i[4])
            s.atoms.append(atom)
            counter += 1
        return s