def buildGraph(whamLog, compileScript, method, basis, structures, sourceDir, graphDir, dftTime, minRC, maxRC): jobGraph = nx.DiGraph() # currentDir = getcwd() data = parseFDynamoCompileScript(compileScript) definedAtoms = data["definedAtoms"] gaussianFlexibleSele = rewriteFlexibleSeleFile( join(sourceDir, data["flexiblePart"]) ) ########## ROOT NODE ########################### rootNode = FDynamoNode(None, graphDir) rootNode.status = "finished" if not isdir(graphDir): makedirs(graphDir) rootNode.fDynamoPath = data["fDynamoPath"] rootNode.charge = data["charge"] rootNode.method = data["method"] rootNode.forceField = data["forceField"] copyfile( join(sourceDir, data["forceField"]), join(graphDir, rootNode.forceField) ) rootNode.flexiblePart = data["flexiblePart"] copyfile( join(sourceDir, data["flexiblePart"]), join(graphDir, rootNode.flexiblePart) ) rootNode.sequence = data["sequence"] copyfile( join(sourceDir, data["sequence"]), join(graphDir, rootNode.sequence) ) rootNode.qmSele = data["qmSele"] rootNode.additionalKeywords["definedAtoms"] = definedAtoms jobGraph.add_node(graphDir, data = rootNode) ########### SPLINE NODE #################### splineDir = join( graphDir, "spline" ) splineNode = SplineNode(None, splineDir, whamLog ) jobGraph.add_node( splineDir, data= splineNode ) ################## SP DFT + SP SEMIEMPIRICAL ##################################### RCstructList = [] for struct in structures: RC = rootNode.measureRC(struct) print(struct, RC) if RC < minRC or RC > maxRC: continue RCstructList.append( (RC, struct) ) RCstructList.sort() for i, rcStruct in enumerate(RCstructList): struct = rcStruct[1] dirNo = str(i) dirname = join( graphDir, dirNo ) dftDir = join(dirname, method) semiEmpDir = join(dirname, data["method"]) if not isdir(dftDir): makedirs(dftDir) if not isdir(semiEmpDir): makedirs(semiEmpDir) dftNode = FDynamoNode("DFT-SP-"+dirNo, dftDir) dftNode.verification = ["SP"] dftNode.templateKey = "QMMM_sp_gaussian" dftNode.fDynamoPath = "/net/people/plgglanow/fortranPackages/AMBER-g09/AMBER-dynamo/makefile" # if structNo >= 35: # dftNode.additionalKeywords = { "method" : method, "basis" : basis , "multiplicity" : 1 , "definedAtoms" : data["definedAtoms"] , "otherOptions" : "SCF=(QC,direct,conver=6)" } # else: dftNode.additionalKeywords = { "method" : method, "basis" : basis , "multiplicity" : 1 , "definedAtoms" : data["definedAtoms"] , "otherOptions" : "SCF=(direct)" } # dftNode.additionalKeywords = { "method" : method, "basis" : basis , "multiplicity" : 1 , "definedAtoms" : data["definedAtoms"] , "otherOptions" : "SCF=direct" } dftNode.coordsIn = "coordsStart.crd" copyfile(struct, join( dftNode.path, dftNode.coordsIn )) dftNode.coordsOut = "coordsDone.crd" dftNode.flexiblePart = basename(gaussianFlexibleSele) copyfile( gaussianFlexibleSele, join(dftDir, dftNode.flexiblePart) ) dftNode.processors = 24 dftNode.moduleAddLines = "module add plgrid/apps/gaussian/g16.B.01" dftNode.partition = "plgrid" dftNode.time = dftTime dftNode.getCoordsFromParent = False jobGraph.add_node(dftDir, data = dftNode) jobGraph.add_edge(graphDir, dftDir) semiNode = FDynamoNode("SemiEmp-SP-"+dirNo, semiEmpDir) semiNode.verification = ["SP"] semiNode.templateKey = "QMMM_sp" semiNode.coordsIn = "coordsStart.crd" semiNode.coordsOut = "coordsDone.crd" copyfile(struct, join( semiNode.path, semiNode.coordsIn )) semiNode.partition = "plgrid-short" semiNode.time = "0:10:00" semiNode.getCoordsFromParent = False jobGraph.add_node(semiEmpDir, data = semiNode) jobGraph.add_edge( graphDir, semiEmpDir ) splineDiff = SplineDiffNode("diff", dirname) jobGraph.add_node(dirname, data = splineDiff) jobGraph.add_edge( dftDir, dirname ) jobGraph.add_edge( semiEmpDir, dirname ) jobGraph.add_edge( dirname, splineDir ) return jobGraph
def addTSsearch(jobGraph, rootDir, currentDir, baseData, initialGeom, index, method, basis, gaussianFelxSele): newNode = FDynamoNode("tsSearch.f90", currentDir) newNode.verification = ["Opt", "Freq"] newNode.noOfExcpectedImaginaryFrequetions = 1 newNode.templateKey = "QMMM_opt_mopac" newNode.additionalKeywords = {"ts_search": "true"} newNode.coordsIn = "coordsIn.crd" gaussianTime = "72:00:00" if not isdir(currentDir): makedirs(currentDir) saveCrdFromDCD(join(currentDir, "coordsIn.crd"), initialGeom) newNode.coordsOut = "coordsDone.crd" newNode.getCoordsFromParent = False newNode.fDynamoPath = baseData["fDynamoPath"] newNode.charge = baseData["charge"] newNode.method = baseData["method"] newNode.forceField = data["forceField"] copyfile(join(baseData["filesDir"], baseData["forceField"]), join(currentDir, newNode.forceField)) newNode.flexiblePart = data["flexiblePart"] copyfile(join(baseData["filesDir"], baseData["flexiblePart"]), join(currentDir, newNode.flexiblePart)) newNode.sequence = data["sequence"] copyfile(join(baseData["filesDir"], baseData["sequence"]), join(currentDir, newNode.sequence)) newNode.qmSele = data["qmSele"] jobGraph.add_node(currentDir, data=newNode) jobGraph.add_edge(rootDir, currentDir) am1Dir = currentDir ######################################################## currentDir = join(currentDir, "ts_gaussian") if not isdir(currentDir): makedirs(currentDir) newNode = FDynamoNode("tsSearch", currentDir) newNode.verification = ["Opt", "Freq"] newNode.noOfExcpectedImaginaryFrequetions = 1 newNode.templateKey = "QMMM_opt_gaussian" newNode.fDynamoPath = "/net/people/plgglanow/fortranPackages/AMBER-g09/AMBER-dynamo/makefile" newNode.additionalKeywords = { "ts_search": "true", "method": method, "basis": basis, "multiplicity": 1, "otherOptions": "" } newNode.coordsIn = "coordsStart.crd" newNode.coordsOut = "coordsDone.crd" newNode.flexiblePart = basename(gaussianFelxSele) copyfile(gaussianFelxSele, join(currentDir, newNode.flexiblePart)) newNode.processors = 24 newNode.moduleAddLines = "module add plgrid/apps/gaussian/g16.B.01" newNode.partition = "plgrid" newNode.time = gaussianTime jobGraph.add_node(currentDir, data=newNode) jobGraph.add_edge(am1Dir, currentDir) ######################################################## newDir = join(am1Dir, "irc_reverse") newNode = FDynamoNode("irc_reverse.f90", newDir) newNode.verification = ["SP"] newNode.templateKey = "QMMM_irc_mopac" newNode.additionalKeywords = {"IRC_dir": "-1"} newNode.coordsIn = "coordsStart.crd" newNode.coordsOut = "coordsDone.crd" jobGraph.add_node(newDir, data=newNode) jobGraph.add_edge(am1Dir, newDir) ######################################################## optDir = join(newDir, "opt") newNode = FDynamoNode("opt.f90", optDir) newNode.verification = ["Opt", "Freq"] newNode.noOfExcpectedImaginaryFrequetions = 0 newNode.templateKey = "QMMM_opt_mopac" newNode.additionalKeywords = { "ts_search": "false", "definedAtoms": baseData["definedAtoms"] } newNode.coordsIn = "coordsStart.crd" newNode.coordsOut = "coordsDone" + str(index) + ".crd" newNode.measureRCinOutput = True jobGraph.add_node(optDir, data=newNode) jobGraph.add_edge(newDir, optDir) ######################################################## optDirGaussian = join(newDir, "optGaussian") if not isdir(optDirGaussian): makedirs(optDirGaussian) newNode = FDynamoNode("opt.f90", optDirGaussian) newNode.verification = ["Opt", "Freq"] newNode.noOfExcpectedImaginaryFrequetions = 0 newNode.templateKey = "QMMM_opt_gaussian" newNode.fDynamoPath = "/net/people/plgglanow/fortranPackages/AMBER-g09/AMBER-dynamo/makefile" newNode.additionalKeywords = { "ts_search": "false", "definedAtoms": baseData["definedAtoms"], "method": method, "basis": basis, "multiplicity": 1, "otherOptions": "" } newNode.coordsIn = "coordsStart.crd" newNode.coordsOut = "coordsDone" + str(index) + ".crd" newNode.flexiblePart = basename(gaussianFelxSele) copyfile(gaussianFelxSele, join(optDirGaussian, newNode.flexiblePart)) newNode.measureRCinOutput = True newNode.processors = 24 newNode.moduleAddLines = "module add plgrid/apps/gaussian/g16.B.01" newNode.partition = "plgrid" newNode.time = gaussianTime jobGraph.add_node(optDirGaussian, data=newNode) jobGraph.add_edge(optDir, optDirGaussian) ######################################################## newDir = join(am1Dir, "irc_forward") newNode = FDynamoNode("irc_forward.f90", newDir) newNode.verification = ["SP"] newNode.templateKey = "QMMM_irc_mopac" newNode.additionalKeywords = {"IRC_dir": "1"} newNode.coordsIn = "coordsStart.crd" newNode.coordsOut = "coordsDone.crd" jobGraph.add_node(newDir, data=newNode) jobGraph.add_edge(am1Dir, newDir) ######################################################## optDir = join(newDir, "opt") newNode = FDynamoNode("opt.f90", optDir) newNode.verification = ["Opt", "Freq"] newNode.noOfExcpectedImaginaryFrequetions = 0 newNode.templateKey = "QMMM_opt_mopac" newNode.additionalKeywords = { "ts_search": "false", "definedAtoms": baseData["definedAtoms"] } newNode.coordsIn = "coordsStart.crd" newNode.coordsOut = "coordsDone" + str(index) + ".crd" newNode.measureRCinOutput = True jobGraph.add_node(optDir, data=newNode) jobGraph.add_edge(newDir, optDir) ######################################################## optDirGaussian = join(optDir, "optGaussian") if not isdir(optDirGaussian): makedirs(optDirGaussian) newNode = FDynamoNode("opt.f90", optDirGaussian) newNode.verification = ["Opt", "Freq"] newNode.noOfExcpectedImaginaryFrequetions = 0 newNode.templateKey = "QMMM_opt_gaussian" newNode.fDynamoPath = "/net/people/plgglanow/fortranPackages/AMBER-g09/AMBER-dynamo/makefile" newNode.additionalKeywords = { "ts_search": "false", "definedAtoms": baseData["definedAtoms"], "method": method, "basis": basis, "multiplicity": 1, "otherOptions": "" } newNode.coordsIn = "coordsStart.crd" newNode.coordsOut = "coordsDone" + str(index) + ".crd" newNode.measureRCinOutput = True newNode.processors = 24 newNode.flexiblePart = basename(gaussianFelxSele) copyfile(gaussianFelxSele, join(optDirGaussian, newNode.flexiblePart)) newNode.moduleAddLines = "module add plgrid/apps/gaussian/g16.B.01" newNode.partition = "plgrid" newNode.time = gaussianTime jobGraph.add_node(optDirGaussian, data=newNode) jobGraph.add_edge(optDir, optDirGaussian)
def addTSsearch (jobGraph, rootDir, currentDir, baseData, initialGeom, index): newNode = FDynamoNode("tsSearch.f90", currentDir) newNode.verification = ["Opt" , "Freq"] newNode.noOfExcpectedImaginaryFrequetions = 1 newNode.templateKey = "QMMM_opt_mopac" newNode.additionalKeywords = { "ts_search" : "true" } newNode.coordsIn = "coordsIn.crd" makedirs(currentDir) saveCrdFromDCD( join(currentDir, "coordsIn.crd"), initialGeom ) newNode.coordsOut = "coordsDone.crd" newNode.getCoordsFromParent = False newNode.fDynamoPath = baseData["fDynamoPath"] newNode.charge = baseData["charge"] newNode.method = baseData["method"] newNode.forceField = data["forceField"] copyfile( join(baseData["filesDir"], baseData["forceField"]), join(currentDir, newNode.forceField) ) newNode.flexiblePart = data["flexiblePart"] copyfile( join(baseData["filesDir"], baseData["flexiblePart"]), join(currentDir, newNode.flexiblePart) ) newNode.sequence = data["sequence"] copyfile( join(baseData["filesDir"], baseData["sequence"]), join(currentDir, newNode.sequence) ) newNode.qmSele = data["qmSele"] jobGraph.add_node(currentDir, data = newNode) jobGraph.add_edge(rootDir, currentDir) newDir = join(currentDir, "irc_reverse") newNode = FDynamoNode("irc_reverse.f90", newDir) newNode.verification = ["SP"] newNode.templateKey = "QMMM_irc_mopac" newNode.additionalKeywords = { "IRC_dir" : "-1" } newNode.coordsIn = "coordsStart.crd" newNode.coordsOut = "coordsDone.crd" jobGraph.add_node(newDir, data = newNode) jobGraph.add_edge(currentDir, newDir) optDir = join(newDir, "opt") newNode = FDynamoNode("opt.f90", optDir) newNode.verification = ["Opt", "Freq"] newNode.noOfExcpectedImaginaryFrequetions = 0 newNode.templateKey = "QMMM_opt_mopac" newNode.additionalKeywords = { "ts_search" : "false" , "definedAtoms" : baseData["definedAtoms"]} newNode.coordsIn = "coordsStart.crd" newNode.coordsOut = "coordsDone"+str(index)+".crd" newNode.measureRCinOutput = True jobGraph.add_node(optDir, data = newNode) jobGraph.add_edge( newDir, optDir) newDir = join(currentDir, "irc_forward") newNode = FDynamoNode("irc_forward.f90", newDir) newNode.verification = ["SP"] newNode.templateKey = "QMMM_irc_mopac" newNode.additionalKeywords = { "IRC_dir" : "1" } newNode.coordsIn = "coordsStart.crd" newNode.coordsOut = "coordsDone.crd" jobGraph.add_node(newDir, data = newNode) jobGraph.add_edge(currentDir, newDir) optDir = join(newDir, "opt") newNode = FDynamoNode("opt.f90", optDir) newNode.verification = ["Opt", "Freq"] newNode.noOfExcpectedImaginaryFrequetions = 0 newNode.templateKey = "QMMM_opt_mopac" newNode.additionalKeywords = { "ts_search" : "false" , "definedAtoms" : baseData["definedAtoms"]} newNode.coordsIn = "coordsStart.crd" newNode.coordsOut = "coordsDone"+str(index)+".crd" newNode.measureRCinOutput = True jobGraph.add_node(optDir, data = newNode) jobGraph.add_edge( newDir, optDir) if len(sys.argv) < 4: print("Usage: graphTSsearchWHAM wham.log/RC compileScanScript.sh numberOfTS2find addName") else: whamLog = sys.argv[1] compileScript = sys.argv[2] TSno = int(sys.argv[3]) addName = "" if len(sys.argv) > 4: addName = sys.argv[4] if isfile(whamLog): tsReactionCoord = getTScoords(whamLog) else: tsReactionCoord = float(whamLog) print("Found reaction coordinate: ", tsReactionCoord) data = parseFDynamoCompileScript(compileScript) definedAtoms = data["definedAtoms"] atoms = atomsFromAtomSelection( definedAtoms) currentDir = abspath(dirname(compileScript)) graphDir = join( getcwd(), "multiTSsearch"+addName ) sm = GraphManager() graph = sm.isGraphHere(graphDir) if not graph: newGraph = jobGraph = buildGraph(tsReactionCoord, atoms, graphDir, data, currentDir, TSno) result = sm.addGraph(newGraph, graphDir) if result: sm.buildGraphDirectories(newGraph) sm.saveGraphs() print("Created new graph") else: print("Cannot create more than one graph in the same directory")