def make(self, target_dir): self.get_cell() self.cell.otherdict.update(self.merge_cell.otherdict) self.cell.blocks.update(self.merge_cell.blocks) if self.usp_pot: pot.add_potentials_usp(self.cell, self.pot_type, otfg_patch=self.otfg_patch) else: potentials = pot.add_potentials_asc(self.cell, self.xc_functional, self.rel_pot) for potential in potentials: potential.link_files(target_dir) self.params.xc_functional = self.xc_functional self.params.cut_off_energy = self.cut_off_energy if self.efg_only: self.params.magres_task = "efg" else: self.params.magres_task = "nmr" if self.target_name is None: self.target_name = self.source_name cell_target = os.path.join(target_dir, "%s.cell" % self.target_name) param_target = os.path.join(target_dir, "%s.param" % self.target_name) sh_target = os.path.join(target_dir, "%s.sh" % self.target_name) submission_script = SubmissionScript(self.queue, self.num_cores, self.code, self.target_name) with open(sh_target, "w+") as sh_target_file,\ open(param_target, "w+") as param_target_file,\ open(cell_target, "w+") as cell_target_file: print >> sh_target_file, submission_script print >> param_target_file, self.params print >> cell_target_file, self.cell
def make(self, target_dir): self.get_cell() self.cell.otherdict.update(self.merge_cell.otherdict) self.cell.blocks.update(self.merge_cell.blocks) if self.usp_pot: pot.add_potentials_usp(self.cell, self.pot_type, otfg_patch=self.otfg_patch) else: potentials = pot.add_potentials_asc(self.cell, self.xc_functional, self.rel_pot) for potential in potentials: potential.link_files(target_dir) self.params.xc_functional = self.xc_functional self.params.cut_off_energy = self.cut_off_energy if self.efg_only: self.params.magres_task = "efg" else: self.params.magres_task = "nmr" if self.target_name is None: self.target_name = self.source_name cell_target = os.path.join(target_dir, "%s.cell" % self.target_name) param_target = os.path.join(target_dir, "%s.param" % self.target_name) sh_target = os.path.join(target_dir, "%s.sh" % self.target_name) submission_script = SubmissionScript(self.queue, self.num_cores, self.code, self.target_name) with open(sh_target, "w+") as sh_target_file,\ open(param_target, "w+") as param_target_file,\ open(cell_target, "w+") as cell_target_file: print >>sh_target_file, submission_script print >>param_target_file, self.params print >>cell_target_file, self.cell
def make(self, target_dir): self.get_cell() self.cell.otherdict.update(self.merge_cell.otherdict) self.cell.blocks.update(self.merge_cell.blocks) if self.usp_pot: pot.add_potentials_usp(self.cell, "kh") else: potentials = pot.add_potentials_asc(self.cell, self.xc_functional, True) for potential in potentials: potential.link_files(target_dir) add_constraints(self.cell, self.filter) self.params.xc_functional = self.xc_functional self.params.cut_off_energy = self.cut_off_energy if self.target_name is None: self.target_name = self.source_name cell_target = os.path.join(target_dir, "%s.cell" % self.target_name) param_target = os.path.join(target_dir, "%s.param" % self.target_name) sh_target = os.path.join(target_dir, "%s.sh" % self.target_name) submission_script = SubmissionScript(self.queue, self.num_cores, self.code, self.target_name) with open(sh_target, "w+") as sh_target_file,\ open(param_target, "w+") as param_target_file,\ open(cell_target, "w+") as cell_target_file: print >>sh_target_file, submission_script print >>param_target_file, self.params print >>cell_target_file, self.cell
def make(self, target_dir): self.get_cell() self.cell.otherdict.update(self.merge_cell.otherdict) self.cell.blocks.update(self.merge_cell.blocks) if self.usp_pot: pot.add_potentials_usp(self.cell, "kh") else: potentials = pot.add_potentials_asc(self.cell, self.xc_functional, True) for potential in potentials: potential.link_files(target_dir) add_constraints(self.cell, self.filter) self.params.xc_functional = self.xc_functional self.params.cut_off_energy = self.cut_off_energy if self.target_name is None: self.target_name = self.source_name cell_target = os.path.join(target_dir, "%s.cell" % self.target_name) param_target = os.path.join(target_dir, "%s.param" % self.target_name) sh_target = os.path.join(target_dir, "%s.sh" % self.target_name) submission_script = SubmissionScript(self.queue, self.num_cores, self.code, self.target_name) with open(sh_target, "w+") as sh_target_file,\ open(param_target, "w+") as param_target_file,\ open(cell_target, "w+") as cell_target_file: print >> sh_target_file, submission_script print >> param_target_file, self.params print >> cell_target_file, self.cell
def make(source, target_dir, target_name=None, num_cores=32, queue="parallel.q", xc_functional="pbe", cut_off_energy=50, ncp_pot=False, rel_pot=False, efg=False, c=None, **kwargs): source_dir, source_name = calc_from_path(source) calc = CastepCalc(source_dir, source_name) xc_functional = xc_functional.lower() if c is None: c = cell.Cell(calc.cell_file) c.other += merge_cell.other c.blocks.update(merge_cell.blocks) if ncp_pot: if xc_functional == 'pbe': _, required_files = pot.add_potentials(settings.NCP_PSPOT_PBE_DIR, None, c, rel_pot) elif xc_functional == 'lda': _, required_files = pot.add_potentials(settings.NCP_PSPOT_LDA_DIR, None, c, rel_pot) else: raise Exception("Cannot use XC functional %s with NCPs" % xc_functional) pot.link_files(required_files, target_dir) else: print rel_pot pot.add_potentials_usp(c, rel_pot) if target_name is None: target_name = source_name cell_target = os.path.join(target_dir, "%s.cell" % target_name) param_target = os.path.join(target_dir, "%s.param" % target_name) sh_target = os.path.join(target_dir, "%s.sh" % target_name) sh_context = { 'seedname': target_name, 'num_cores': num_cores, 'h_vmem': float(num_cores) / 8 * 23, 'queue': queue, 'CASTEPY_ROOT': settings.CASTEPY_ROOT, 'USER_EMAIL': settings.USER_EMAIL, } sh_source = open(os.path.join(nmr_path, "nmr.sh")).read() sh_target_file = open(sh_target, "w+") param_target_file = open(param_target, "w+") params.xc_functional[0] = xc_functional params.cut_off_energy[0] = cut_off_energy if efg: params.magres_task = "efg" else: params.magres_task = "nmr" print >> sh_target_file, sh_source % sh_context print >> param_target_file, params cell_out = open(cell_target, "w+") print >> cell_out, c sh_target_file.close()
def make( source, target_dir, target_name=None, num_cores=32, queue="parallel.q", xc_functional="pbe", cut_off_energy=50, ncp_pot=False, rel_pot=False, efg=False, c=None, **kwargs ): source_dir, source_name = calc_from_path(source) calc = CastepCalc(source_dir, source_name) xc_functional = xc_functional.lower() if c is None: c = cell.Cell(calc.cell_file) c.other += merge_cell.other c.blocks.update(merge_cell.blocks) if ncp_pot: if xc_functional == "pbe": _, required_files = pot.add_potentials(settings.NCP_PSPOT_PBE_DIR, None, c, rel_pot) elif xc_functional == "lda": _, required_files = pot.add_potentials(settings.NCP_PSPOT_LDA_DIR, None, c, rel_pot) else: raise Exception("Cannot use XC functional %s with NCPs" % xc_functional) pot.link_files(required_files, target_dir) else: print rel_pot pot.add_potentials_usp(c, rel_pot) if target_name is None: target_name = source_name cell_target = os.path.join(target_dir, "%s.cell" % target_name) param_target = os.path.join(target_dir, "%s.param" % target_name) sh_target = os.path.join(target_dir, "%s.sh" % target_name) sh_context = { "seedname": target_name, "num_cores": num_cores, "h_vmem": float(num_cores) / 8 * 23, "queue": queue, "CASTEPY_ROOT": settings.CASTEPY_ROOT, "USER_EMAIL": settings.USER_EMAIL, } sh_source = open(os.path.join(nmr_path, "nmr.sh")).read() sh_target_file = open(sh_target, "w+") param_target_file = open(param_target, "w+") params.xc_functional[0] = xc_functional params.cut_off_energy[0] = cut_off_energy if efg: params.magres_task = "efg" else: params.magres_task = "nmr" print >> sh_target_file, sh_source % sh_context print >> param_target_file, params cell_out = open(cell_target, "w+") print >> cell_out, c sh_target_file.close()
def make(self, target_dir): """ Write the calculation to the specified target directory. """ self.get_cell() # Get the J-coupling site if we don't have it already if self.jc_s is None: self.get_jcoupling_site(target_dir) # Set up the site in the cell if self.jc_s is not None: try: jc_ion = cell.ions.species(self.jc_s)[self.jc_i-1] except IndexError: raise SiteNotPresent("Site {:s} {:d} not present".format(self.jc_s, self.jc_i)) cell.otherdict['jcoupling_site'] = "{:s} {:d}".format(self.jc_s, self.jc_i) # Remove extraneous kpoints and add in default cell setup if 'KPOINTS_LIST' in cell.blocks: del cell.blocks['KPOINTS_LIST'] self.cell.otherdict.update(self.merge_cell.otherdict) # Sort out .param file self.params.xc_functional = self.xc_functional self.params.cut_off_energy = self.cut_off_energy # Add pseudopotentials if self.usp_pot: pot.add_potentials_usp(cell, self.rel_pot) else: potentials = pot.add_potentials_asc(cell, self.xc_functional, self.rel_pot) for potential in potentials: potential.link_files(target_dir) # Generate submission script and write all the files out target_name = source_name cell_target = os.path.join(target_dir, "%s.cell" % target_name) param_target = os.path.join(target_dir, "%s.param" % target_name) sh_target = os.path.join(target_dir, "%s.sh" % target_name) submission_script = SubmissionScript(self.queue, self.num_cores, self.code, target_name) sh_target_file = open(sh_target, "w+") param_target_file = open(param_target, "w+") cell_target_file = open(cell_target, "w+") print >>sh_target_file, submission_script print >>param_target_file, self.params print >>cell_target_file, cell sh_target_file.close() param_target_file.close() cell_target_file.close()