def test_fixes(self): flow = Flow(workdir=test_dir, manager=TaskManager.from_file( os.path.join(test_dir, "taskmanager.yml"))) inp = {} flow.register_task(input=inp) flow.allocate()
def __init__(self, code='vasp', system_id='mp-149', kpar=False, **kwargs): """ system_id is to be a mp-id to take a base structure from the mp-database kwarg can be used to personalize all lists code specifies the name of the code to be tested, it is assumed that an executable with this name is present in the current work dir to generate the job scripts a taskmanager.yml file is needed in the current work dir #todo add example list of paralelizaions """ self.code = code self.subject = os.path.join(os.getcwd(), code) self.manager = TaskManager.from_user_config() self.script_list = [] self.system_id = system_id self.kpar = kpar self.kpden = None mp_key = os.environ['MP_KEY'] with MPRester(mp_key) as mp_database: self.structure = mp_database.get_structure_by_material_id(system_id, final=True) self.name = str(self.structure.composition.reduced_formula) + "_" + str(self.system_id) self.np_list = [1, 4, 9, 16, 25, 36, 64, 100, 144] #self.np_list = [1, 8, 27, 64, 125, 216, 343] self.sizes = [1, 2, 3] self.parameter_lists = None if self.code == 'vasp': self.parameter_lists = {'NPAR': [0, 0.5, 1]} self.reset_bar() self.inpset = BenchVaspInputSet() self.inpset.set_input()
def __init__(self, workdir, name=None, flows=None, manager=None, timelimit=None): """ Args: workdir: Working directory name: Name assigned to the `BatchLauncher`. flows: List of `Flow` objects. manager: :class:`TaskManager` object responsible for the submission of the jobs. If manager is None, the object is initialized from the yaml file located either in the working directory or in the user configuration dir. timelimit: Time limit (int with seconds or string with time given with the slurm convention: "days-hours:minutes:seconds". If timelimit is None, the default value specified in the `batch_adapter` is taken. """ self.workdir = os.path.abspath(workdir) if not os.path.exists(self.workdir): os.makedirs(self.workdir) else: pass # raise RuntimeError("Directory %s already exists. Use BatchLauncher.pickle_load()" % self.workdir) self.name = os.path.basename(self.workdir) if name is None else name self.script_file = File(os.path.join(self.workdir, "run.sh")) self.qerr_file = File(os.path.join(self.workdir, "queue.qerr")) self.qout_file = File(os.path.join(self.workdir, "queue.qout")) self.log_file = File(os.path.join(self.workdir, "run.log")) self.batch_pidfile = File(os.path.join(self.workdir, "batch.pid")) from .tasks import TaskManager manager = TaskManager.as_manager(manager) # Extract the qadapater to be used for the batch script. try: self.qadapter = qad = manager.batch_adapter except AttributeError: raise RuntimeError("Your manager.yml file does not define an entry for the batch_adapter") if qad is None: raise RuntimeError("Your manager.yml file does not define an entry for the batch_adapter") # Set mpi_procs to 1 just to be on the safe side # Then allow the user to change the timelimit via __init__ qad.set_mpi_procs(1) if timelimit is not None: self.set_timelimit(timelimit) # FIXME: Remove me! self.set_timelimit(36000) # Initialize list of flows. if flows is None: flows = [] if not isinstance(flows, (list, tuple)): flows = [flows] self.flows = flows
def load_flow(inp, runpath): pickle_file = os.path.join(runpath,'__AbinitFlow__.pickle') try: flow = pickle.Unpickler(open(pickle_file)).load() except IOError as e: manager = TaskManager.from_user_config() flow = PhononFlow(runpath, manager, inp, ngqpt=[2,2,2], do_nscf = False) flow.ph_tolvrs = 1.e-2 flow.build_tasks() flow = flow.allocate() return flow
def __init__(self, workdir=None, manager=None, trials=ALL_TRIALS, accuracies=ALL_ACCURACIES): """ Args: workdir: Working directory. manager: :class:`TaskManager` object that will handle the sumbmission of the jobs. """ self.workdir = os.path.abspath(workdir) if workdir is not None else os.path.join(os.getcwd(), "DOJO") self.manager = TaskManager.from_user_config() if manager is None else manager self.trials, self.accuracies = trials, accuracies # List of pseudos analyzed by the Dojo and corresponding flows. self.pseudos, self.flows = [], []
def calc_phbands_and_dos(self, ngqpt=None, ndivsm=20, nqsmall=10, asr=2, chneut=1, dipdip=1, dos_method="tetra", workdir=None, manager=None, verbose=0, plot=True, ret_task=False): """ Execute anaddb to compute the phonon band structure and the phonon DOS Args: ngqpt: Number of divisions for the q-mesh in the DDB file. Auto-detected if None (default) asr, chneut, dipdp: Anaddb input variable. See official documentation. workdir: Working directory. If None, a temporary directory is created. manager: :class:`TaskManager` object. If None, the object is initialized from the configuration file verbose: verbosity level. Set it to a value > 0 to get more information """ if ngqpt is None: ngqpt = self.guessed_ngqpt inp = AnaddbInput.phbands_and_dos( self.structure, ngqpt=ngqpt, ndivsm=ndivsm, nqsmall=nqsmall, q1shft=(0,0,0), qptbounds=None, asr=asr, chneut=chneut, dipdip=dipdip, dos_method=dos_method) if manager is None: manager = TaskManager.from_user_config() if workdir is None: workdir = tempfile.mkdtemp() if verbose: print("workdir:", workdir) print("ANADDB INPUT:\n", inp) task = AnaddbTask(inp, self.filepath, workdir=workdir, manager=manager.to_shell_manager(mpi_procs=1)) if ret_task: return task # Run the task here. task.start_and_wait(autoparal=False) report = task.get_event_report() if not report.run_completed: raise TaskException(task=task, report=report) with task.open_phbst() as phbst_ncfile, task.open_phdos() as phdos_ncfile: phbands, phdos = phbst_ncfile.phbands, phdos_ncfile.phdos if plot: phbands.plot_with_phdos(phdos, title="Phonon bands and DOS of %s" % self.structure.formula) return phbands, phdos
def calc_phmodes_at_qpoint(self, qpoint=None, asr=2, chneut=1, dipdip=1, workdir=None, manager=None, verbose=0, ret_task=False): """ Execute anaddb to compute phonon modes at the given q-point. Args: qpoint: Reduced coordinates of the qpoint where phonon modes are computed asr, chneut, dipdp: Anaddb input variable. See official documentation. workdir: Working directory. If None, a temporary directory is created. manager: :class:`TaskManager` object. If None, the object is initialized from the configuration file verbose: verbosity level. Set it to a value > 0 to get more information """ if qpoint is None: qpoint = self.qpoints[0] if len(self.qpoints) != 1: raise ValueError("%s contains %s qpoints and the choice is ambiguous.\n" "Please specify the qpoint in calc_phmodes_at_qpoint" % (self, len(self.qpoints))) inp = AnaddbInput.modes_at_qpoint(self.structure, qpoint, asr=asr, chneut=chneut, dipdip=dipdip) if manager is None: manager = TaskManager.from_user_config() if workdir is None: workdir = tempfile.mkdtemp() if verbose: print("workdir:", workdir) print("ANADDB INPUT:\n", inp) task = AnaddbTask(inp, self.filepath, workdir=workdir, manager=manager.to_shell_manager(mpi_procs=1)) if ret_task: return task # Run the task here task.start_and_wait(autoparal=False) report = task.get_event_report() if not report.run_completed: raise TaskException(task=task, report=report) with task.open_phbst() as ncfile: return ncfile.phbands
def __init__(self, code='vasp', system_id='mp-149', kpar=False, **kwargs): """ system_id is to be a mp-id to take a base structure from the mp-database kwarg can be used to personalize all lists code specifies the name of the code to be tested, it is assumed that an executable with this name is present in the current work dir to generate the job scripts a taskmanager.yml file is needed in the current work dir #todo add example list of paralelizaions """ self.code = code self.subject = os.path.join(os.getcwd(), code) self.manager = TaskManager.from_user_config() self.script_list = [] self.system_id = system_id self.kpar = kpar self.kpden = None mp_key = os.environ['MP_KEY'] with MPRester(mp_key) as mp_database: self.structure = mp_database.get_structure_by_material_id( system_id, final=True) self.name = str( self.structure.composition.reduced_formula) + "_" + str( self.system_id) self.np_list = [1, 4, 9, 16, 25, 36, 64, 100, 144] #self.np_list = [1, 8, 27, 64, 125, 216, 343] self.sizes = [1, 2, 3] self.parameter_lists = None if self.code == 'vasp': self.parameter_lists = {'NPAR': [0, 0.5, 1]} self.reset_bar() self.inpset = BenchVaspInputSet() self.inpset.set_input()
def _setup_faketask(name, manager=None, workdir="."): tmp_dir = os.path.join(workdir, "__" + str(name) + "_run__") if manager is None: manager = TaskManager.from_user_config() manager = manager.to_shell_manager() return Work(workdir=tmp_dir, manager=manager)
from pymatgen.io.abinitio.workflows import Workflow from pymatgen.io.abinitio.tasks import TaskManager, ScfTask, NscfTask from pymatgen.io.abinitio.flows import AbinitFlow from pymatgen.symmetry.bandstructure import HighSymmKpath from abipy.htc.input import AbiInput from abipy.core.constants import Energy from myscripts.pseudos import get_psp from myscripts.structure import HalfHeusler scratchdir = '/p/lscratchd/damewood' basename = os.path.dirname(os.path.abspath(__file__)).split(os.path.sep)[-1] workdir = os.path.join(scratchdir,basename) logging.basicConfig() manager = TaskManager.from_user_config() acell_opt = { 'N': { 'alpha': 4.961, 'beta' : 4.912, 'gamma': 5.139, }, 'P': { 'alpha': 5.600, 'beta' : 5.717, 'gamma': 5.715, }, 'Si': { 'alpha': 5.629, 'beta' : 5.778,
def _runem_all(self): """ This function checks the status of all tasks, tries to fix tasks that went unconverged, abicritical, or queuecritical and tries to run all the tasks that can be submitted.+ """ excs = [] flow = self.flow # Allow to change the manager at run-time if self.use_dynamic_manager: from pymatgen.io.abinitio.tasks import TaskManager new_manager = TaskManager.from_user_config() for work in flow: work.set_manager(new_manager) nqjobs = 0 if self.contact_resource_manager: # This call is expensive and therefore it's optional nqjobs = flow.get_njobs_in_queue() if nqjobs is None: nqjobs = 0 if flow.manager.has_queue: logger.warning('Cannot get njobs_inqueue') if nqjobs >= self.max_njobs_inqueue: logger.info("Too many jobs in the queue, returning") return if self.max_nlaunches == -1: max_nlaunch = self.max_njobs_inqueue - nqjobs else: max_nlaunch = min(self.max_njobs_inqueue - nqjobs, self.max_nlaunches) # check status and print it. flow.check_status(show=False) # fix problems # Try to restart the unconverged tasks # todo donot fire here but prepare for fireing in rapidfire for task in self.flow.unconverged_tasks: try: logger.info("Flow will try restart task %s" % task) fired = task.restart() if fired: self.nlaunch += 1 max_nlaunch -= 1 if max_nlaunch == 0: logger.info("Restart: too many jobs in the queue, returning") flow.pickle_dump() return except task.RestartError: excs.append(straceback()) # move here from withing rapid fire ... # fix only prepares for restarting, and sets to ready nfixed = flow.fix_abi_critical() if nfixed: print("Fixed %d AbiCritical errors" % nfixed) # Temporarily disable by MG because I don't know if fix_critical works after the # introduction of the new qadapters if False: nfixed = flow.fix_queue_critical() if nfixed: print("Fixed %d QueueCritical errors" % nfixed) # update database flow.pickle_dump() # Submit the tasks that are ready. try: nlaunch = PyLauncher(flow).rapidfire(max_nlaunch=max_nlaunch, sleep_time=10) self.nlaunch += nlaunch if nlaunch: print("[%s] Number of launches: %d" % (time.asctime(), nlaunch)) except Exception: excs.append(straceback()) flow.show_status() if excs: logger.critical("*** Scheduler exceptions:\n *** %s" % "\n".join(excs)) self.exceptions.extend(excs)
def create(self): """ create single abinit G0W0 flow """ manager = 'slurm' if 'ceci' in self.spec['mode'] else 'shell' # an AbiStructure object has an overwritten version of get_sorted_structure that sorts according to Z # this could also be pulled into the constructor of Abistructure #abi_structure = self.structure.get_sorted_structure() from abipy import abilab item = copy.copy(self.structure.item) self.structure.__class__ = abilab.Structure self.structure = self.structure.get_sorted_structure_z() self.structure.item = item abi_structure = self.structure manager = TaskManager.from_user_config() # Initialize the flow. flow = Flow(self.work_dir, manager, pickle_protocol=0) # flow = Flow(self.work_dir, manager) # kpoint grid defined over density 40 > ~ 3 3 3 if self.spec['converge'] and not self.all_converged: # (2x2x2) gamma centered mesh for the convergence test on nbands and ecuteps # if kp_in is present in the specs a kp_in X kp_in x kp_in mesh is used for the convergence studie if 'kp_in' in self.spec.keys(): if self.spec['kp_in'] > 9: print('WARNING:\nkp_in should be < 10 to generate an n x n x n mesh\nfor larger values a grid with ' 'density kp_in will be generated') scf_kppa = self.spec['kp_in'] else: scf_kppa = 2 else: # use the specified density for the final calculation with the converged nbands and ecuteps of other # stand alone calculations scf_kppa = self.spec['kp_grid_dens'] gamma = True # 'standard' parameters for stand alone calculation nb = self.get_bands(self.structure) nscf_nband = [10 * nb] nksmall = None ecuteps = [8] ecutsigx = 44 extra_abivars = dict( paral_kgb=1, inclvkb=2, ecut=44, pawecutdg=88, gwmem='10', getden=-1, istwfk="*1", timopt=-1, nbdbuf=8 ) # read user defined extra abivars from file 'extra_abivars' should be dictionary extra_abivars.update(read_extra_abivars()) #self.bands_fac = 0.5 if 'gwcomp' in extra_abivars.keys() else 1 #self.convs['nscf_nbands']['test_range'] = tuple([self.bands_fac*x for x in self.convs['nscf_nbands']['test_range']]) response_models = ['godby'] if 'ppmodel' in extra_abivars.keys(): response_models = [extra_abivars.pop('ppmodel')] if self.option is not None: for k in self.option.keys(): if k in ['ecuteps', 'nscf_nbands']: pass else: extra_abivars.update({k: self.option[k]}) if k == 'ecut': extra_abivars.update({'pawecutdg': self.option[k]*2}) try: grid = read_grid_from_file(s_name(self.structure)+".full_res")['grid'] all_done = read_grid_from_file(s_name(self.structure)+".full_res")['all_done'] workdir = os.path.join(s_name(self.structure), 'w'+str(grid)) except (IOError, OSError): grid = 0 all_done = False workdir = None if not all_done: if (self.spec['test'] or self.spec['converge']) and not self.all_converged: if self.spec['test']: print('| setting test calculation') tests = SingleAbinitGWWork(self.structure, self.spec).tests response_models = [] else: if grid == 0: print('| setting convergence calculations for grid 0') #tests = SingleAbinitGWWorkFlow(self.structure, self.spec).convs tests = self.convs else: print('| extending grid') #tests = expand(SingleAbinitGWWorkFlow(self.structure, self.spec).convs, grid) tests = expand(self.convs, grid) ecuteps = [] nscf_nband = [] for test in tests: if tests[test]['level'] == 'scf': if self.option is None: extra_abivars.update({test + '_s': tests[test]['test_range']}) elif test in self.option: extra_abivars.update({test: self.option[test]}) else: extra_abivars.update({test + '_s': tests[test]['test_range']}) else: for value in tests[test]['test_range']: if test == 'nscf_nbands': nscf_nband.append(value * self.get_bands(self.structure)) #scr_nband takes nscf_nbands if not specified #sigma_nband takes scr_nbands if not specified if test == 'ecuteps': ecuteps.append(value) if test == 'response_model': response_models.append(value) elif self.all_converged: print('| setting up for testing the converged values at the high kp grid ') # add a bandstructure and dos calculation nksmall = 30 # in this case a convergence study has already been performed. # The resulting parameters are passed as option ecuteps = [self.option['ecuteps'], self.option['ecuteps'] + self.convs['ecuteps']['test_range'][1] - self.convs['ecuteps']['test_range'][0]] nscf_nband = [self.option['nscf_nbands'], self.option['nscf_nbands'] + self.convs['nscf_nbands'][ 'test_range'][1] - self.convs['nscf_nbands']['test_range'][0]] # for option in self.option: # if option not in ['ecuteps', 'nscf_nband']: # extra_abivars.update({option + '_s': self.option[option]}) else: print('| all is done for this material') return logger.info('ecuteps : ', ecuteps) logger.info('extra : ', extra_abivars) logger.info('nscf_nb : ', nscf_nband) work = g0w0_extended(abi_structure, self.pseudo_table, scf_kppa, nscf_nband, ecuteps, ecutsigx, accuracy="normal", spin_mode="unpolarized", smearing=None, response_models=response_models, charge=0.0, sigma_nband=None, scr_nband=None, gamma=gamma, nksmall=nksmall, **extra_abivars) flow.register_work(work, workdir=workdir) return flow.allocate()
def _runem_all(self): """ This function checks the status of all tasks, tries to fix tasks that went unconverged, abicritical, or queuecritical and tries to run all the tasks that can be submitted.+ """ excs = [] flow = self.flow # Allow to change the manager at run-time if self.use_dynamic_manager: from pymatgen.io.abinitio.tasks import TaskManager new_manager = TaskManager.from_user_config() for work in flow: work.set_manager(new_manager) nqjobs = flow.get_njobs_in_queue() if nqjobs is None: nqjobs = 0 print('Cannot get njobs_inqueue') if nqjobs >= self.max_njobs_inqueue: print("Too many jobs in the queue, returning") return if self.max_nlaunch == -1: max_nlaunch = self.max_njobs_inqueue - nqjobs else: max_nlaunch = min(self.max_njobs_inqueue - nqjobs, self.max_nlaunch) # check status flow.check_status() flow.show_status() # fix problems # Try to restart the unconverged tasks # todo donot fire here but prepare for fireing in rapidfire for task in self.flow.unconverged_tasks: try: logger.info("AbinitFlow will try restart task %s" % task) fired = task.restart() if fired: self.nlaunch += 1 max_nlaunch -= 1 if max_nlaunch == 0: print("Restart: too many jobs in the queue, returning") flow.pickle_dump() return except Exception: excs.append(straceback()) # move here from withing rapid fire ... # fix only prepares for restarting, and sets to ready flow.fix_critical() # update database flow.pickle_dump() #if self.num_restarts == self.max_num_restarts: # info_msg = "Reached maximum number of restarts. Cannot restart anymore Returning" # logger.info(info_msg) # self.history.append(info_msg) # return 1 # Submit the tasks that are ready. try: nlaunch = PyLauncher(flow).rapidfire(max_nlaunch=max_nlaunch, sleep_time=10) self.nlaunch += nlaunch if nlaunch: print("[%s] Number of launches: %d" % (time.asctime(), nlaunch)) except Exception: excs.append(straceback()) flow.show_status() if excs: logger.critical("*** Scheduler exceptions:\n *** %s" % "\n".join(excs)) self.exceptions.extend(excs)
def _runem_all(self): """ This function checks the status of all tasks, tries to fix tasks that went unconverged, abicritical, or queuecritical and tries to run all the tasks that can be submitted.+ """ excs = [] flow = self.flow # Allow to change the manager at run-time if self.use_dynamic_manager: from pymatgen.io.abinitio.tasks import TaskManager new_manager = TaskManager.from_user_config() for work in flow: work.set_manager(new_manager) nqjobs = flow.get_njobs_in_queue() if nqjobs is None: nqjobs = 0 print('Cannot get njobs_inqueue') if nqjobs >= self.max_njobs_inqueue: print("Too many jobs in the queue, returning") return if self.max_nlaunch == -1: max_nlaunch = self.max_njobs_inqueue - nqjobs else: max_nlaunch = min(self.max_njobs_inqueue - nqjobs, self.max_nlaunch) # check status flow.check_status() flow.show_status() # fix problems # Try to restart the unconverged tasks # todo donot fire here but prepare for fireing in rapidfire for task in self.flow.unconverged_tasks: try: logger.info("Flow will try restart task %s" % task) fired = task.restart() if fired: self.nlaunch += 1 max_nlaunch -= 1 if max_nlaunch == 0: print("Restart: too many jobs in the queue, returning") flow.pickle_dump() return except Exception: excs.append(straceback()) # move here from withing rapid fire ... # fix only prepares for restarting, and sets to ready flow.fix_critical() # update database flow.pickle_dump() #if self.num_restarts == self.max_num_restarts: # info_msg = "Reached maximum number of restarts. Cannot restart anymore Returning" # logger.info(info_msg) # self.history.append(info_msg) # return 1 # Submit the tasks that are ready. try: nlaunch = PyLauncher(flow).rapidfire(max_nlaunch=max_nlaunch, sleep_time=10) self.nlaunch += nlaunch if nlaunch: print("[%s] Number of launches: %d" % (time.asctime(), nlaunch)) except Exception: excs.append(straceback()) flow.show_status() if excs: logger.critical("*** Scheduler exceptions:\n *** %s" % "\n".join(excs)) self.exceptions.extend(excs)
def _runem_all(self): """ This function checks the status of all tasks, tries to fix tasks that went unconverged, abicritical, or queuecritical and tries to run all the tasks that can be submitted.+ """ excs = [] flow = self.flow # Allow to change the manager at run-time if self.use_dynamic_manager: from pymatgen.io.abinitio.tasks import TaskManager new_manager = TaskManager.from_user_config() for work in flow: work.set_manager(new_manager) nqjobs = 0 if self.contact_resource_manager: # This call is expensive and therefore it's optional nqjobs = flow.get_njobs_in_queue() if nqjobs is None: nqjobs = 0 if flow.manager.has_queue: logger.warning("Cannot get njobs_inqueue") if nqjobs >= self.max_njobs_inqueue: print("Too many jobs in the queue: %s, returning" % nqjobs) return if self.max_nlaunches == -1: max_nlaunch = self.max_njobs_inqueue - nqjobs else: max_nlaunch = min(self.max_njobs_inqueue - nqjobs, self.max_nlaunches) # check status. flow.check_status(show=False) # This check is not perfect, we should make a list of tasks to sumbit # and select only the subset so that we don't exceeed mac_ncores_used # Many sections of this code should be rewritten. # if self.max_ncores_used is not None and flow.ncores_used > self.max_ncores_used: if self.max_ncores_used is not None and flow.ncores_allocated > self.max_ncores_used: print("Cannot exceed max_ncores_used %s" % self.max_ncores_used) logger.info("Cannot exceed max_ncores_used %s" % self.max_ncores_used) return # Try to restart the unconverged tasks # TODO: do not fire here but prepare for fireing in rapidfire for task in self.flow.unconverged_tasks: try: logger.info("Flow will try restart task %s" % task) fired = task.restart() if fired: self.nlaunch += 1 max_nlaunch -= 1 if max_nlaunch == 0: logger.info("Restart: too many jobs in the queue, returning") flow.pickle_dump() return except task.RestartError: excs.append(straceback()) # Temporarily disable by MG because I don't know if fix_critical works after the # introduction of the new qadapters # reenabled by MsS disable things that do not work at low level # fix only prepares for restarting, and sets to ready if self.fix_qcritical: nfixed = flow.fix_queue_critical() if nfixed: print("Fixed %d QCritical error(s)" % nfixed) nfixed = flow.fix_abicritical() if nfixed: print("Fixed %d AbiCritical error(s)" % nfixed) # update database flow.pickle_dump() # Submit the tasks that are ready. try: nlaunch = PyLauncher(flow).rapidfire(max_nlaunch=max_nlaunch, sleep_time=10) self.nlaunch += nlaunch if nlaunch: print("[%s] Number of launches: %d" % (time.asctime(), nlaunch)) except Exception: excs.append(straceback()) # check status. # flow.check_status(show=True) flow.show_status() if excs: logger.critical("*** Scheduler exceptions:\n *** %s" % "\n".join(excs)) self.exceptions.extend(excs)
def test_fixes(self): flow = Flow(workdir=test_dir, manager=TaskManager.from_file(os.path.join(test_dir, "taskmanager.yml"))) inp = {} flow.register_task(input=inp) flow.allocate()
def create(self): """ create single abinit G0W0 flow """ manager = 'slurm' if 'ceci' in self.spec['mode'] else 'shell' # an AbiStructure object has an overwritten version of get_sorted_structure that sorts according to Z # this could also be pulled into the constructor of Abistructure #abi_structure = self.structure.get_sorted_structure() from abipy import abilab item = copy.copy(self.structure.item) self.structure.__class__ = abilab.Structure self.structure = self.structure.get_sorted_structure_z() self.structure.item = item abi_structure = self.structure manager = TaskManager.from_user_config() # Initialize the flow. flow = Flow(self.work_dir, manager, pickle_protocol=0) # flow = Flow(self.work_dir, manager) # kpoint grid defined over density 40 > ~ 3 3 3 if self.spec['converge'] and not self.all_converged: # (2x2x2) gamma centered mesh for the convergence test on nbands and ecuteps # if kp_in is present in the specs a kp_in X kp_in x kp_in mesh is used for the convergence studie if 'kp_in' in self.spec.keys(): if self.spec['kp_in'] > 9: print( 'WARNING:\nkp_in should be < 10 to generate an n x n x n mesh\nfor larger values a grid with ' 'density kp_in will be generated') scf_kppa = self.spec['kp_in'] else: scf_kppa = 2 else: # use the specified density for the final calculation with the converged nbands and ecuteps of other # stand alone calculations scf_kppa = self.spec['kp_grid_dens'] gamma = True # 'standard' parameters for stand alone calculation scf_nband = self.get_bands(self.structure) nscf_nband = [10 * scf_nband] nksmall = None ecuteps = [8] ecutsigx = 44 extra_abivars = dict(paral_kgb=1, inclvkb=2, ecut=44, pawecutdg=88, gwmem='10', getden=-1, istwfk="*1", timopt=-1, nbdbuf=8, prtsuscep=0) # read user defined extra abivars from file 'extra_abivars' should be dictionary extra_abivars.update(read_extra_abivars()) #self.bands_fac = 0.5 if 'gwcomp' in extra_abivars.keys() else 1 #self.convs['nscf_nbands']['test_range'] = tuple([self.bands_fac*x for x in self.convs['nscf_nbands']['test_range']]) response_models = ['godby'] if 'ppmodel' in extra_abivars.keys(): response_models = [extra_abivars.pop('ppmodel')] if self.option is not None: for k in self.option.keys(): if k in ['ecuteps', 'nscf_nbands']: pass else: extra_abivars.update({k: self.option[k]}) if k == 'ecut': extra_abivars.update({'pawecutdg': self.option[k] * 2}) try: grid = read_grid_from_file(s_name(self.structure) + ".full_res")['grid'] all_done = read_grid_from_file( s_name(self.structure) + ".full_res")['all_done'] workdir = os.path.join(s_name(self.structure), 'w' + str(grid)) except (IOError, OSError): grid = 0 all_done = False workdir = None if not all_done: if (self.spec['test'] or self.spec['converge']) and not self.all_converged: if self.spec['test']: print('| setting test calculation') tests = SingleAbinitGWWork(self.structure, self.spec).tests response_models = [] else: if grid == 0: print('| setting convergence calculations for grid 0') #tests = SingleAbinitGWWorkFlow(self.structure, self.spec).convs tests = self.convs else: print('| extending grid') #tests = expand(SingleAbinitGWWorkFlow(self.structure, self.spec).convs, grid) tests = expand(self.convs, grid) ecuteps = [] nscf_nband = [] for test in tests: if tests[test]['level'] == 'scf': if self.option is None: extra_abivars.update( {test + '_s': tests[test]['test_range']}) elif test in self.option: extra_abivars.update({test: self.option[test]}) else: extra_abivars.update( {test + '_s': tests[test]['test_range']}) else: for value in tests[test]['test_range']: if test == 'nscf_nbands': nscf_nband.append( value * self.get_bands(self.structure)) #scr_nband takes nscf_nbands if not specified #sigma_nband takes scr_nbands if not specified if test == 'ecuteps': ecuteps.append(value) if test == 'response_model': response_models.append(value) elif self.all_converged: print( '| setting up for testing the converged values at the high kp grid ' ) # add a bandstructure and dos calculation if os.path.isfile('bands'): nksmall = -30 #negative value > only bandstructure else: nksmall = 30 # in this case a convergence study has already been performed. # The resulting parameters are passed as option ecuteps = [ self.option['ecuteps'], self.option['ecuteps'] + self.convs['ecuteps']['test_range'][1] - self.convs['ecuteps']['test_range'][0] ] nscf_nband = [ self.option['nscf_nbands'], self.option['nscf_nbands'] + self.convs['nscf_nbands']['test_range'][1] - self.convs['nscf_nbands']['test_range'][0] ] # for option in self.option: # if option not in ['ecuteps', 'nscf_nband']: # extra_abivars.update({option + '_s': self.option[option]}) else: print('| all is done for this material') return logger.info('ecuteps : ', ecuteps) logger.info('extra : ', extra_abivars) logger.info('nscf_nb : ', nscf_nband) work = g0w0_extended_work(abi_structure, self.pseudo_table, scf_kppa, nscf_nband, ecuteps, ecutsigx, scf_nband, accuracy="normal", spin_mode="unpolarized", smearing=None, response_models=response_models, charge=0.0, sigma_nband=None, scr_nband=None, gamma=gamma, nksmall=nksmall, **extra_abivars) flow.register_work(work, workdir=workdir) return flow.allocate()