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