Exemple #1
0
 def convertToS(self, mol, activeS):
     # First get S
     S = ct.getDistMatrix(mol, activeS)
     if self.sInd == 0:
         self.sInd = S[1]
         self.reac = S[0]
     try:
         Snorm, project, node, dist = ct.projectPointOnPath(
             S[0], self.path, self.pathType,
             self.boxList[self.box].lower.norm,
             self.boxList[self.box].lower.D, self.reac, self.pathNode,
             self.reverse)
     except:
         Snorm = 0
         project = 0
         node = False
         dist = 0
     return S[0], Snorm, project, node, dist
Exemple #2
0
def run(gl):
    #Read reactant definition
    if gl.StartType == 'file':
        Reac = read(gl.Start)
    elif gl.StartType == 'Smile':
        Reac = tl.getMolFromSmile(gl.Start)
    #Read product definition
    if gl.EndType == 'file':
        Prod= read(gl.End)
    elif gl.EndType == 'Smile':
        Prod = tl.getMolFromSmile(gl.End)

    #Set calculatiors
    #Reac = tl.setCalc(Reac,"DOS/", gl.trajMethod, gl.atomTypes)
    if gl.trajMethod == "openMM":
        Reac = tl.setCalc(Reac,"GenBXD/", gl.trajMethod, gl)
    else:
        Reac = tl.setCalc(Reac,"GenBXD/", gl.trajMethod, gl.trajLevel)
        Prod = tl.setCalc(Prod,"GenBXD/", gl.trajMethod, gl.trajLevel)
    # Partially minimise both reactant and product
    if gl.GenBXDrelax:
        min = BFGS(Reac)
        try:
            min.run(fmax=0.1, steps=20)
        except:
            min.run(fmax=0.1, steps=20)
        min2 = BFGS(Prod)
        try:
            min2.run(fmax=0.1, steps=20)
        except:
            min2.run(fmax=0.1, steps=20)

    # Get important interatomic distances
    if gl.CollectiveVarType == "changedBonds":
        cbs = ct.getChangedBonds2(Reac, Prod)
    elif gl.CollectiveVarType == "all":
        cbs = ct.getChangedBonds2(Reac, Prod)
    elif gl.CollectiveVarType == "specified":
        cbs = gl.CollectiveVar
    elif gl.CollectiveVarType == "file":
        cbs = gl.principalCoordinates

    #Get path to project along
    distPath = []
    totalPathLength = 0
    if gl.PathType == 'curve' or gl.PathType == 'gates':
        if gl.PathFile == 'none':
            Path = getPath(Reac,Prod,gl)
        else:
            Path = read(gl.PathFile,index=('::'+str(gl.pathStride)))

        distPath.append((ct.getDistMatrix(Path[0],cbs)[0],0))
        for i in range(1,len(Path)):
            l = np.linalg.norm(ct.getDistMatrix(Path[i],cbs)[0] - ct.getDistMatrix(Path[i-1], cbs)[0])
            totalPathLength += l
            distPath.append((ct.getDistMatrix(Path[i],cbs)[0],totalPathLength))
    elif gl.PathType == 'linear':
        distPath = ct.getDistMatrix(Prod,cbs)[0] - ct.getDistMatrix(Reac, cbs)[0]

    if gl.PathType == 'curve' or gl.PathType == 'gates':
        pathFile = open('reducedPath.txt','w')
        for p in distPath:
            pathFile.write('s = ' + str(p[0]) + '\n')
        pathFile.close()



    # initialise then run trajectory
    t = Trajectory.Trajectory(Reac,gl,os.getcwd(),0,False)
    t.runGenBXD(Reac,Prod,gl.maxHits,gl.maxAdapSteps,gl.PathType,distPath, cbs, gl.decorrelationSteps, gl.histogramBins,totalPathLength, gl.fixToPath, gl.pathDistCutOff,gl.epsilon)