示例#1
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")
示例#2
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
示例#3
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
示例#4
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")
示例#5
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")
示例#6
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")