def Write_SimData(self, file): uf.replace_text(file, "MOFNAME", self.mof_name) uf.replace_text(file, "DDD1", self.box_0_vector1) uf.replace_text(file, "DDD2", self.box_0_vector2) uf.replace_text(file, "DDD3", self.box_0_vector3) uf.replace_text(file, "BASEFUGACITY", self.mof_name[:4] + " 0.0") self.sys.Write_Conf(file) self.sim.Write_Conf(file)
def WriteXYZ(self, top_file): ''' Writing XYZ data calculated extension. and create Topology file''' # detect the tag in cif file cif_data = topGen.TopGenerate(self.cif_file) cif_data.DetectTag() cif_data.ReadCharges() #create the topology with extension topGen.MakeTopology(cif_data, top_file, self.extend[0] * self.extend[1] * self.extend[2]) #Reading cif file reachedAtom = False molCount = 0 with open(self.output_file, 'w') as outfile: outfile.write("TOTALATOM\n") outfile.write(self.mof_name + "\n") with open(self.cif_file, 'r') as infile: for line in infile: line = re.sub(' +', ' ', line).strip() if line.startswith(cif_data.startTag): reachedAtom = True continue if (reachedAtom): if (line.startswith(cif_data.endTag)): break atom_name = line.split(' ')[cif_data.tag_symbol_indx] x = float(line.split(' ')[cif_data.tag_x_indx]) y = float(line.split(' ')[cif_data.tag_y_indx]) z = float(line.split(' ')[cif_data.tag_z_indx]) if (cif_data.hasCharge): charge = float( line.split(' ')[cif_data.tag_charge_indx]) else: charge = 0.0 atom_name = cif_data.GetAtomName(atom_name, charge) frac_coord = np.array([x, y, z]) for i in range(self.extend[0]): for j in range(self.extend[1]): for k in range(self.extend[2]): coord = self.cellBasis.Extend( frac_coord, i, j, k) to_print = "%4s %15.6f %15.6f %15.6f\n" % ( atom_name, coord[0], coord[1], coord[2]) outfile.write(to_print) molCount += 1 uf.replace_text(self.output_file, "TOTALATOM", str(molCount))
# Copy MOF cif file into MOF_base directory and set up the cell basis info and extension using # maximum(rcut and rcutcoulomb) print("Reading cell basis information in " + mof_file) uf.Copy(mof_path, "./" + mof_file) mof_cellBasis = euc.MOF_Data(mof_file, mof_name, conf.GetRcut()) conf.Print_cellData(mof_cellBasis) # Create MOF Base print("\n1. Building MOF files") uf.Copy(base_directory + "/BUILD/pack/convert_XYZ_PDB.tcl", "./convert_XYZ_PDB.tcl") uf.Copy(base_directory + "/BUILD/model/" + top_file_adsorbent, "./" + top_file_adsorbent) #Prepare the Tcl script uf.replace_text('convert_XYZ_PDB.tcl', 'MOFNAME', mof_name) uf.replace_text('convert_XYZ_PDB.tcl', 'TOPFILENAME', top_file_adsorbent) print( "\t1. Extending unit cell and generating Topology and XYZ file for MOF." ) mof_cellBasis.WriteXYZ(top_file_adsorbent) if os.path.isfile(mof_name + ".xyz"): print("\t2. Unit cell extended and XYZ file generated successfully.") else: print("\t2. ERROR: error generating supercell XYZ file.") sys.exit(-1) print("\t3. Converting XYZ file to PDB and PSF for MOF.") os.system("vmd -dispdev text < convert_XYZ_PDB.tcl" + '>> build_error.log 2>&1')
def Write_Conf(self, file): ''' Replace the keyword with value in config file''' for i in range(len(self.simData)): uf.replace_text(file, self.simData[i][1], self.simData[i][2])
def Write_Conf(self, file): uf.replace_text(file, "ADSBNAME", self.adsorbate_name) uf.replace_text(file, "FFIELD", self.model) uf.replace_text(file, "DDD0", self.reservoir_dim) uf.replace_text(file, "ADSBSET", self.adsorbate_resname)
def Write_runData(self, file, runID, dir): self.runSim.Write_Conf(file, runID) uf.replace_text("gcmc_cluster.cmd", "RUN-DIR", dir) uf.replace_text("gcmc_cluster.cmd", "MOFNAME", self.mof_name) uf.replace_text("gcmc_cluster.cmd", "ADSBNAME", self.sys.adsorbate_name) uf.replace_text("gcmc_cluster.cmd", "FFF", self.runSim.FindVal(runID, 'fugacity'))
def Write_Conf(self, file, idx): ''' Replace the keyword with value in config file''' for j in range(len(self.runSimData[idx][1])): uf.replace_text(file, self.runSimData[idx][1][j][1], self.runSimData[idx][1][j][2])