예제 #1
0
파일: lsimu.py 프로젝트: oeway/cpolymer
    def generate_interactions_o(self,
                                interaction_name,
                                bond="harmonic",
                                SPB=False,
                                radius=10,
                                cutoff=1.15,
                                reducedv_factor=1,
                                khun=1.):

        if bond == "harmonic":
            temp1 = "bond_style      harmonic\n"
            temp2 = "bond_coeff %i %.2f %.2f"
            ene = 350
        if bond == "fene":
            if SPB:
                temp1 = "bond_style hybrid harmonic fene\n"
                temp2 = "bond_coeff %i fene %.2f %.2f %.2f %.2f"
            else:
                temp1 = "bond_style fene\n"

                temp2 = "bond_coeff %i %.2f %.2f %.2f %.2f"
            ene = 30 * 1
        Bond = [temp1]
        if bond == "fene":
            Bond.append("special_bonds fene\n")
        ene_ratio = 1  #.35
        #Bond.append("special_bonds 0.0 1.0 1.0\n")
        if SPB and False:
            #print radius
            Pair = [
                "pair_style  hybrid lj/cut 3.0 gauss/cut  %.2f \n" %
                (2 * radius) + "pair_modify shift yes\n"
            ]
        else:
            Pair = ["pair_style   lj/cut 1.4 \n" + "pair_modify shift yes\n"]
        Angle = ["angle_style cosine/delta\n"]
        Angle = ["angle_style harmonic\n"]
        keyl = range(1, len(self.natom) + 1)
        for t1 in keyl:
            for t2 in keyl:
                if t2 >= t1:
                    if not self.liaison.has_key("%s-%s" % (t1, t2)):
                        print "Warning liaison between {0} and {1} not defined".format(
                            t1, t2)
                    dist, tybe_b = self.liaison["%s-%s" % (t1, t2)]
                    if cutoff is not None:
                        cut = dist * cutoff
                    else:
                        cut = dist * pow(2., 1 / 6.)
                    odist = copy.deepcopy(dist)
                    #dist=1
                    if bond == "fene":
                        Bond.append(
                            temp2 %
                            (tybe_b, ene_ratio * ene /
                             (dist * dist), 1.5 * dist, ene_ratio, dist) +
                            "\n")
                    else:
                        Bond.append(temp2 % (tybe_b, ene, dist) + "\n")
                    dist = odist
                    precise = ""
                    if SPB and False:
                        precise = "lj/cut"
                    reduced = 1
                    if t1 == t2 and t1 == 3:
                        reduced = 1
                    else:
                        reduced = reducedv_factor

                    Pair.append("""pair_coeff	 %s %s %s %.1f %.2f  %.2f\n""" %
                                (t1, t2, precise, ene_ratio, dist * reduced,
                                 cut * reduced))
                    if self.angle_def is not None and self.Angle != []:
                        for t3 in keyl:
                            if t3 >= t2:
                                dist, tybe_b = self.angle_def["%s-%s-%s" %
                                                              (t1, t2, t3)]
                                k = khun / 2. * dist  # dist = 1 if no ribo involved else 0
                                Angle.append("angle_coeff %i %.3f 180.0\n" %
                                             (tybe_b, k))
        if SPB:
            if bond == "fene":
                Bond.append("bond_coeff %i harmonic 0 0 \n" %
                            (self.liaison["spb"][1]))
                spbond = "bond_coeff %i harmonic %.1f %.1f\n" % (
                    self.liaison["spb"][1], 10, microtubule / realsigma)
            else:
                Bond.append("bond_coeff %i  0 0 \n" % (self.liaison["spb"][1]))
                spbond = "bond_coeff %i %.1f %.1f\n" % (
                    self.liaison["spb"][1], 10, microtubule / realsigma)
            n_i = len(diameter) / 2
            for t1 in range(len(diameter)):
                Pair.append("""pair_coeff	 %i %i %s 0. %.2f  %.2f\n""" %
                            (t1 + 1, num_particle["spb"], precise, dist, cut))

            Pair.append(
                """pair_coeff	 %i %i %s 0. %.2f  %.2f\n""" %
                (num_particle["spb"], num_particle["spb"], precise, dist, cut))

        g = open(interaction_name, "w")
        g.write("".join(Bond) + "\n")
        g.write("".join(Pair) + "\n")
        if self.Angle != []:
            g.write("".join(Angle))
예제 #2
0
파일: lsimu.py 프로젝트: oeway/cpolymer
    def generate_interactions_o(self,interaction_name,bond="harmonic",SPB=False,radius=10,cutoff=1.15,reducedv_factor=1,khun=1.):

        if bond == "harmonic" :
            temp1 = "bond_style      harmonic\n"
            temp2 = "bond_coeff %i %.2f %.2f"
            ene = 350
        if bond == "fene":
            if SPB:
                temp1 = "bond_style hybrid harmonic fene\n"
                temp2 = "bond_coeff %i fene %.2f %.2f %.2f %.2f"
            else:
                temp1 = "bond_style fene\n"
            
                temp2 = "bond_coeff %i %.2f %.2f %.2f %.2f"
            ene = 30 * 1
        Bond = [temp1]
        if bond == "fene":
            Bond.append("special_bonds fene\n")
        ene_ratio=1#.35
        #Bond.append("special_bonds 0.0 1.0 1.0\n")
        if SPB and False:
            #print radius
            Pair = ["pair_style  hybrid lj/cut 3.0 gauss/cut  %.2f \n"%(2*radius) + "pair_modify shift yes\n"]
        else:
            Pair = ["pair_style   lj/cut 1.4 \n" + "pair_modify shift yes\n"]
        Angle = ["angle_style cosine/delta\n"] 
        Angle = ["angle_style harmonic\n"]
        keyl = range(1,len(self.natom)+1)
        for t1 in keyl:
            for t2 in keyl:
                if t2 >= t1:
                    if not self.liaison.has_key("%s-%s"%(t1,t2)):
                        print "Warning liaison between {0} and {1} not defined".format(t1,t2)
                    dist,tybe_b = self.liaison["%s-%s"%(t1,t2)]
                    if  cutoff is not None:                   
                        cut = dist*cutoff
                    else:
                        cut = dist*pow(2.,1/6.) 
                    odist = copy.deepcopy(dist)
                    #dist=1
                    if bond == "fene":
                        Bond.append(temp2 % (tybe_b,ene_ratio * ene/(dist*dist),1.5*dist,ene_ratio,dist) +"\n")
                    else:
                        Bond.append(temp2 % (tybe_b, ene,dist) +"\n")
                    dist = odist
                    precise =""
                    if SPB and False:
                        precise = "lj/cut" 
                    reduced = 1
                    if t1 == t2 and t1 == 3:
                        reduced = 1
                    else:
                        reduced = reducedv_factor 
                        
            
                    Pair.append("""pair_coeff	 %s %s %s %.1f %.2f  %.2f\n"""%(t1,t2,precise,ene_ratio,dist*reduced,cut*reduced))
                    if self.angle_def is not None and self.Angle != []:
                        for t3 in keyl:
                            if t3 >= t2:
                                dist,tybe_b = self.angle_def["%s-%s-%s"%(t1,t2,t3)]
                                k=khun/2. * dist # dist = 1 if no ribo involved else 0
                                Angle.append("angle_coeff %i %.3f 180.0\n"%(tybe_b,k))
        if SPB:
            if bond == "fene":
                Bond.append("bond_coeff %i harmonic 0 0 \n"%(self.liaison["spb"][1]))
                spbond = "bond_coeff %i harmonic %.1f %.1f\n"%(self.liaison["spb"][1],10,microtubule/realsigma)
            else:
                Bond.append("bond_coeff %i  0 0 \n"%(self.liaison["spb"][1]))
                spbond = "bond_coeff %i %.1f %.1f\n"%(self.liaison["spb"][1],10,microtubule/realsigma)
            n_i = len(diameter)/2
            for t1 in range(len(diameter) ):
                Pair.append("""pair_coeff	 %i %i %s 0. %.2f  %.2f\n"""%(t1+1,num_particle["spb"],precise,dist,cut))
              
            Pair.append("""pair_coeff	 %i %i %s 0. %.2f  %.2f\n"""%(num_particle["spb"],num_particle["spb"],precise,dist,cut))
        
        g = open(interaction_name,"w")
        g.write("".join(Bond)+"\n")
        g.write("".join(Pair)+"\n")
        if self.Angle != []:
            g.write("".join(Angle))