def start_from_beginning(maindir,srclmp,lmp_execdir,destdir,\ data_fname,temp,polywtperc,rcut,blist,\ alist,k_phi,wlccheck,anglstyl,nchains,\ polydens,graftMW,initcom,nmonval,\ graftval,epsval,graftopt,geninp_list,\ begin_fresh,key_epsval,epsval_pg): if begin_fresh == -1: list_of_files = glob.glob('*') if list_of_files != []: for f in list_of_files: if not os.path.isdir(f): os.remove(f) for fylcnt in range(len(geninp_list)): cpy_main_files(maindir, destdir, geninp_list[fylcnt]) # Manipulate Files os.chdir(destdir) print("Manipulating input parameter file..") launch_fyl = 'params_input.dat' fr = open('params_input_var.dat', 'r') fw = open(launch_fyl, 'w') fid = fr.read().replace("py_inputname",str(data_fname)).\ replace("py_graftstyle",str(int(graftopt))).\ replace("py_nchains_bb",str(nchains)).\ replace("py_nmons_bb",str(nmonval)).\ replace("py_graftperc",str(graftval)).\ replace("py_polydens",str(polydens)).\ replace("py_graftmons",str(graftMW)).\ replace("py_comdist", str(initcom)).\ replace("py_polyperc",str(polywtperc)) fw.write(fid) fw.close() fr.close() # Generate Required Files for LAMMPS print("Running FORTRAN script for generating Datafile") subprocess.call(["ifort","-r8","-qopenmp","-mkl",\ "ran_numbers.f90","lmp_params.f90",\ "lammps_inp2.f90","-o","lmpinp.o"]) subprocess.call(["./lmpinp.o", "params_input.dat"]) datafind = 1 if not os.path.exists(data_fname): print(data_fname, "not found - check input code") datafind = -1 if datafind == 1: cpy_lammps_files(maindir,srclmp,lmp_execdir,destdir,graftopt,\ data_fname,nmonval,graftval,anglstyl) create_infile(maindir,srclmp,destdir,nmonval,epsval,graftopt,\ temp,graftval,polywtperc,rcut,blist,alist,k_phi,\ wlccheck,anglstyl,graftval,key_epsval,epsval_pg) generate_backup(maindir, srclmp, lmp_execdir, destdir)
if not os.path.isdir(workdir_subpdi): print("ERROR: ", workdir_subpdi, " not found") continue os.chdir(workdir_subpdi) destdir = os.getcwd() print( "Starting analysis for case ", ncases_pdi[casenum], "in ",\ free_chains[ifree],dirstr) #---Copying files------ print("Current Dir ", destdir) print("Copying Files") for fyllist in range(len(ana_files)): cpy_main_files(maindir, destdir, ana_files[fyllist]) for fyllist in range(len(job_files)): cpy_main_files(jobdir, destdir, job_files[fyllist]) dataname = find_datafyle(free_chains[ifree],fylstr,\ ncases_pdi[casenum],destdir) if dataname == 'ERROR': print("ERROR: No restart files found") continue #latest_traj = find_latest_trajfyle(traj_pref,destdir) #if latest_traj == 'ERROR': # print("ERROR: No trajectory files found") # continue
smd_workdir = traj_workdir + '/smd_main' if not os.path.isdir(smd_workdir): os.mkdir(smd_workdir) #------All copying/manipulations----------------------- print("Finding latest archived restart file..") refyle = find_recent_file(traj_workdir, res_prefix) if refyle == "nil": print("no restart file found in ", traj_workdir) continue else: os.chdir(smd_workdir) print("Creating datafile..") cpy_main_files(traj_workdir, smd_workdir, refyle) lmp_execfile = lmp_execdir + '/' + lmp_fylename create_datafyle(lmp_execfile, refyle, smd_fylename) for fylcnt in range(len(fyls_main)): cpy_main_files(srclmpdir, smd_workdir, fyls_main[fylcnt]) cpy_main_files(lmp_execdir, smd_workdir, lmp_fylename) create_infile(maindir, srclmpdir, smd_workdir, nmons[bblen], epsarr_pg[eps], graftopt, temp) gen_launch_fyl(smd_workdir, 'jobsmd_var.sh', 'jobsmd.sh', graftarr[glen], epsarr_pg[eps]) subprocess.call(['qsub', 'jobsmd.sh']) cleanup_files(umbdir, "f90")
print("Archive files found: RESTARTING from archives") if archive_flag == 0: os.chdir(workdir_subpdi) destdir = os.getcwd() print( "Starting case", ncases_pdi[caselen], "for ",\ free_chains[ifree],dirstr) #---Copying files------ print("Current Dir ", destdir) print("Copying Files") for fyllist in range(len(f90_files)): cpy_main_files(maindir, destdir, f90_files[fyllist]) for fyllist in range(len(lmp_files)): cpy_main_files(lmpdir, destdir, lmp_files[fyllist]) srcfyl = '/home/dorfmank/vsethura/mylammps/src/lmp_mesabi' desfyl = destdir + '/lmp_mesabi' shutil.copy2(srcfyl, desfyl) #----Run PDI code------ print("Running PDI calculation file") tot_chains = free_chains[ifree] + graft_chains init_pdi_write(pdi_free,free_avg_mw,free_chains[ifree],\ pdi_graft,graft_avg_mw,graft_chains,destdir) compile_and_run_pdi(destdir)
print( "EpsValue_polymer_graft: ", epsarr_pg[eps]) workdir3 = workdir1 + '/epsval_' + str(epsarr_pg[eps]) if not os.path.isdir(workdir3): print(workdir3, " does not exist") continue #------All copying/manipulations------------------------------------- os.chdir(workdir3) destdir = os.getcwd() print( "Copying Files..") for fylcnt in range(len(fyl_list)): cpy_main_files(maindir, destdir, fyl_list[fylcnt]) print("Creating/finding Datafile..") if int(graftopt) == 3: [datafyle,flag] = find_datafyl(destdir, epsarr_ps[eps],epsarr_sg[eps],epsarr_pg[eps],wlccheck) else: [datafyle,flag] = find_datafyl_mc(destdir, epsarr_pg[eps]) if flag == -1: print("datafile not found in ", destdir) continue if allana == 0: #Only analyzing the latest trajectory
data_fname = "input_" + str(epsarr_pg[eps]) + ".dat" print("EpsValue_polymer_graft: ", epsarr_pg[eps]) workdir3 = workdir1 + '/epsval_' + str(epsarr_pg[eps]) if not os.path.isdir(workdir3): os.mkdir(workdir3) os.chdir(workdir3) destdir = os.getcwd() if restart == 0: for fylcnt in range(len(geninp_list)): cpy_main_files(maindir, destdir, geninp_list[fylcnt]) # Manipulate Files os.chdir(destdir) print("Manipulating input parameter file..") launch_fyl = 'params_input.dat' fr = open('params_input_var.dat', 'r') fw = open(launch_fyl, 'w') fid = fr.read().replace("py_inputname",str(data_fname)).\ replace("py_graftstyle",str(int(graftopt))).\ replace("py_nchains_bb",str(nchains)).\ replace("py_nmons_bb",str(nmons[bblen])).\ replace("py_graftperc",str(graftarr[glen])).\ replace("py_polydens",str(polydens)).\ replace("py_graftmons",str(graftMW)).\