# pymatgen.io.abinit.works module¶

Works for Abinit

class Work(workdir=None, manager=None)[source]

Bases: pymatgen.io.abinit.works.BaseWork, pymatgen.io.abinit.works.NodeContainer

A Work is a list of (possibly connected) tasks.

Parameters
• workdir – Path to the working directory.

• managerTaskManager object.

all_done

True if all the Task objects in the Work are done.

allocate(manager=None)[source]

This function is called once we have completed the initialization of the Work. It sets the manager of each task (if not already done) and defines the working directories of the tasks.

Parameters

managerTaskManager object or None

build(*args, **kwargs)[source]

Creates the top level directory.

check_status()[source]

Check the status of the tasks.

chroot(new_workdir)[source]
chunks(chunk_size)[source]

Yield successive chunks of tasks of lenght chunk_size.

flow

The flow containing this Work.

get_all_status(only_min=False)[source]

Returns a list with the status of the tasks in self.

Parameters

only_min – If True, the minimum of the status is returned.

isnc

True if norm-conserving calculation.

ispaw

True if PAW calculation.

move(dest, isabspath=False)[source]

Recursively move self.workdir to another location. This is similar to the Unix “mv” command. The destination path must not already exist. If the destination already exists but is not a directory, it may be overwritten depending on os.rename() semantics.

Be default, dest is located in the parent directory of self.workdir, use isabspath=True to specify an absolute path.

opath_from_ext(ext)[source]

Returns the path of the output file with extension ext. Use it when the file does not exist yet.

parse_timers()[source]

Parse the TIMER section reported in the ABINIT output files.

Returns

AbinitTimerParser object

path_in_workdir(filename)[source]

Create the absolute path of filename in the working directory.

pos[source]

The position of self in the Flow

pos_str

String representation of self.pos

processes

Return a list of objects that support the subprocess.Popen protocol.

read_etotals(unit='Ha')[source]

Reads the total energy from the GSR file produced by the task.

Return a numpy array with the total energies in Hartree The array element is set to np.inf if an exception is raised while reading the GSR file.

register(obj, deps=None, required_files=None, manager=None, task_class=None)[source]

Registers a new Task and add it to the internal list, taking into account possible dependencies.

Parameters
• objAbinitInput instance or Task object.

• deps – Dictionary specifying the dependency of this node or list of dependencies None means that this obj has no dependency.

• required_files – List of strings with the path of the files used by the task. Note that the files must exist when the task is registered. Use the standard approach based on Works, Tasks and deps if the files will be produced in the future.

• manager – The TaskManager responsible for the submission of the task. If manager is None, we use the TaskManager specified during the creation of the Work.

• task_class – Task subclass to instantiate. Default: AbinitTask

Returns

Task object

register_task(obj, deps=None, required_files=None, manager=None, task_class=None)

Registers a new Task and add it to the internal list, taking into account possible dependencies.

Parameters
• objAbinitInput instance or Task object.

• deps – Dictionary specifying the dependency of this node or list of dependencies None means that this obj has no dependency.

• required_files – List of strings with the path of the files used by the task. Note that the files must exist when the task is registered. Use the standard approach based on Works, Tasks and deps if the files will be produced in the future.

• manager – The TaskManager responsible for the submission of the task. If manager is None, we use the TaskManager specified during the creation of the Work.

• task_class – Task subclass to instantiate. Default: AbinitTask

Returns

Task object

rm_indatadir()[source]

Remove all the indata directories.

rm_outdatadir()[source]

Remove all the indata directories.

rm_tmpdatadir()[source]

Remove all the tmpdata directories.

rmtree(exclude_wildcard='')[source]

Remove all files and directories in the working directory

Parameters

exclude_wildcard – Optional string with regular expressions separated by |. Files matching one of the regular expressions will be preserved. example: exclude_wildard=”.nc|.txt” preserves all the files whose extension is in [“nc”, “txt”].

set_flow(flow)[source]

Set the flow associated to this Work.

set_manager(manager)[source]

Set the TaskManager to use to launch the Task.

set_workdir(workdir, chroot=False)[source]

Set the working directory. Cannot be set more than once unless chroot is True

setup(*args, **kwargs)[source]

Method called before running the calculations. The default implementation is empty.

start(*args, **kwargs)[source]

Start the work. Calls build and _setup first, then submit the tasks. Non-blocking call unless wait is set to True

status

Returns the status of the work i.e. the minimum of the status of the tasks.

status_counter

Returns a Counter object that counts the number of task with given status (use the string representation of the status as key).

submit_tasks(wait=False)[source]

Submits the task in self and wait. TODO: change name.

class BandStructureWork(scf_input, nscf_input, dos_inputs=None, workdir=None, manager=None)[source]

Work for band structure calculations.

Parameters
• scf_input – Input for the SCF run

• nscf_input – Input for the NSCF run defining the band structure calculation.

• dos_inputs – Input(s) for the DOS. DOS is computed only if dos_inputs is not None.

• workdir – Working directory.

• managerTaskManager object.

plot_ebands(**kwargs)[source]

Plot the band structure. kwargs are passed to the plot method of ElectronBands.

Returns

matplotlib figure

plot_ebands_with_edos(dos_pos=0, method='gaussian', step=0.01, width=0.1, **kwargs)[source]

Plot the band structure and the DOS.

Parameters
• dos_pos – Index of the task from which the DOS should be obtained (note: 0 refers to the first DOS task).

• method – String defining the method for the computation of the DOS.

• step – Energy step (eV) of the linear mesh.

• width – Standard deviation (eV) of the gaussian.

• kwargs – Keyword arguments passed to plot_with_edos method to customize the plot.

Returns

matplotlib figure.

plot_edoses(dos_pos=None, method='gaussian', step=0.01, width=0.1, **kwargs)[source]

Plot the band structure and the DOS.

Parameters
• dos_pos – Index of the task from which the DOS should be obtained. None is all DOSes should be displayed. Accepts integer or list of integers.

• method – String defining the method for the computation of the DOS.

• step – Energy step (eV) of the linear mesh.

• width – Standard deviation (eV) of the gaussian.

• kwargs – Keyword arguments passed to plot method to customize the plot.

Returns

matplotlib figure.

class RelaxWork(ion_input, ioncell_input, workdir=None, manager=None, target_dilatmx=None)[source]

Work for structural relaxations. The first task relaxes the atomic position while keeping the unit cell parameters fixed. The second task uses the final structure to perform a structural relaxation in which both the atomic positions and the lattice parameters are optimized.

Parameters
• ion_input – Input for the relaxation of the ions (cell is fixed)

• ioncell_input – Input for the relaxation of the ions and the unit cell.

• workdir – Working directory.

• managerTaskManager object.

on_ok(sender)[source]

This callback is called when one task reaches status S_OK. If sender == self.ion_task, we update the initial structure used by self.ioncell_task and we unlock it so that the job can be submitted.

plot_ion_relaxation(**kwargs)[source]

Plot the history of the ion-cell relaxation. kwargs are passed to the plot method of HistFile

plot_ioncell_relaxation(**kwargs)[source]

Plot the history of the ion-cell relaxation. kwargs are passed to the plot method of HistFile

class G0W0Work(scf_inputs, nscf_inputs, scr_inputs, sigma_inputs, workdir=None, manager=None)[source]

Work for general G0W0 calculations. All input can be either single inputs or lists of inputs

Parameters
• scf_inputs – Input(s) for the SCF run, if it is a list add all but only link to the last input (used for convergence studies on the KS band gap)

• nscf_inputs – Input(s) for the NSCF run, if it is a list add all but only link to the last (i.e. addditiona DOS and BANDS)

• scr_inputs – Input for the screening run

• sigma_inputs – List of :class:AbinitInputfor the self-energy run. if scr and sigma are lists of the same length, every sigma gets its own screening. if there is only one screening all sigma inputs are linked to this one

• workdir – Working directory of the calculation.

• managerTaskManager object.

class QptdmWork(workdir=None, manager=None)[source]

This work parallelizes the calculation of the q-points of the screening. It also provides the callback on_all_ok that calls mrgscr to merge all the partial screening files produced.

Parameters
• workdir – Path to the working directory.

• managerTaskManager object.

create_tasks(wfk_file, scr_input)[source]

Create the SCR tasks and register them in self.

Parameters
• wfk_file – Path to the ABINIT WFK file to use for the computation of the screening.

• scr_input – Input for the screening calculation.

merge_scrfiles(remove_scrfiles=True)[source]

This method is called when all the q-points have been computed. It runs mrgscr in sequential on the local machine to produce the final SCR file in the outdir of the Work. If remove_scrfiles is True, the partial SCR files are removed after the merge.

on_all_ok()[source]

This method is called when all the q-points have been computed. It runs mrgscr in sequential on the local machine to produce the final SCR file in the outdir of the Work.

class SigmaConvWork(wfk_node, scr_node, sigma_inputs, workdir=None, manager=None)[source]

Work for self-energy convergence studies.

Parameters
• wfk_node – The node who has produced the WFK file or filepath pointing to the WFK file.

• scr_node – The node who has produced the SCR file or filepath pointing to the SCR file.

• sigma_inputs – List of AbinitInput for the self-energy runs.

• workdir – Working directory of the calculation.

• managerTaskManager object.

class BseMdfWork(scf_input, nscf_input, bse_inputs, workdir=None, manager=None)[source]

Work for simple BSE calculations in which the self-energy corrections are approximated by the scissors operator and the screening is modeled with the model dielectric function.

Parameters
• scf_input – Input for the SCF run.

• nscf_input – Input for the NSCF run.

• bse_inputs – List of Inputs for the BSE run.

• workdir – Working directory of the calculation.

• managerTaskManager.

get_mdf_robot()[source]

Builds and returns a MdfRobot for analyzing the results in the MDF files.

class PhononWork(workdir=None, manager=None)[source]

Bases: pymatgen.io.abinit.works.Work, pymatgen.io.abinit.works.MergeDdb

This work consists of nirred Phonon tasks where nirred is the number of irreducible atomic perturbations for a given set of q-points. It provides the callback method (on_all_ok) that calls mrgddb (mrgdv) to merge all the partial DDB (POT) files produced. The two files are available in the output directory of the Work.

Parameters
• workdir – Path to the working directory.

• managerTaskManager object.

classmethod from_scf_input(scf_input, qpoints, is_ngqpt=False, tolerance=None, with_becs=False, ddk_tolerance=None, manager=None)[source]

Similar to from_scf_task, the difference is that this method requires an input for SCF calculation. A new ScfTask is created and added to the Work. This API should be used if the DDB of the GS task should be merged.

classmethod from_scf_task(scf_task, qpoints, is_ngqpt=False, tolerance=None, with_becs=False, ddk_tolerance=None, manager=None)[source]

Construct a PhononWork from a ScfTask object. The input file for phonons is automatically generated from the input of the ScfTask. Each phonon task depends on the WFK file produced by the scf_task.

Parameters

• qpoints – q-points in reduced coordinates. Accepts single q-point, list of q-points or three integers defining the q-mesh if is_ngqpt.

• is_ngqpt – True if qpoints should be interpreted as divisions instead of q-points.

• tolerance – dict {“varname”: value} with the tolerance to be used in the phonon run. None to use AbiPy default.

• with_becs – Activate calculation of Electric field and Born effective charges.

• ddk_tolerance – dict {“varname”: value} with the tolerance used in the DDK run if with_becs. None to use AbiPy default.

• managerTaskManager object.

on_all_ok()[source]

This method is called when all the q-points have been computed. Ir runs mrgddb in sequential on the local machine to produce the final DDB file in the outdir of the Work.

class PhononWfkqWork(workdir=None, manager=None)[source]

Bases: pymatgen.io.abinit.works.Work, pymatgen.io.abinit.works.MergeDdb

This work computes phonons with DFPT on an arbitrary q-mesh (usually denser than the k-mesh for electrons) by computing WKQ files for each q-point. The number of irreducible atomic perturbations for each q-point are taken into account. It provides the callback method (on_all_ok) that calls mrgddb (mrgdv) to merge all the partial DDB (POT) files produced. The two files are available in the output directory of the Work. The WKQ files are removed at runtime.

Parameters
• workdir – Path to the working directory.

• managerTaskManager object.

classmethod from_scf_task(scf_task, ngqpt, ph_tolerance=None, tolwfr=1e-22, nband=None, with_becs=False, ddk_tolerance=None, shiftq=(0, 0, 0), is_ngqpt=True, remove_wfkq=True, manager=None)[source]

Construct a PhononWfkqWork from a ScfTask object. The input files for WFQ and phonons are automatically generated from the input of the ScfTask. Each phonon task depends on the WFK file produced by scf_task and the associated WFQ file.

Parameters

• ngqpt – three integers defining the q-mesh

• with_becs – Activate calculation of Electric field and Born effective charges.

• ph_tolerance – dict {“varname”: value} with the tolerance for the phonon run. None to use AbiPy default.

• tolwfr – tolerance used to compute WFQ.

• ddk_tolerance – dict {“varname”: value} with the tolerance used in the DDK run if with_becs. None to use AbiPy default.

• shiftq – Q-mesh shift. Multiple shifts are not supported.

• is_ngqpt – the ngqpt is interpreted as a set of integers defining the q-mesh, otherwise is an explicit list of q-points

• remove_wfkq – Remove WKQ files when the children are completed.

• managerTaskManager object.

on_all_ok()[source]

This method is called when all the q-points have been computed. Ir runs mrgddb in sequential on the local machine to produce the final DDB file in the outdir of the Work.

on_ok(sender)[source]

This callback is called when one task reaches status S_OK. It removes the WFKQ file if all its children have reached S_OK.

class GKKPWork(workdir=None, manager=None)[source]

This work computes electron-phonon matrix elements for all the q-points present in a DVDB and DDB file

Parameters
• workdir – Path to the working directory.

• managerTaskManager object.

classmethod from_den_ddb_dvdb(inp, den_path, ddb_path, dvdb_path, mpiprocs=1, remove_wfkq=True, qpath=None, with_ddk=True, expand=True, manager=None)[source]

Construct a PhononWfkqWork from a DDB and DVDB file. For each q found, a WFQ task and an EPH task computing the matrix elements are created.

classmethod from_phononwfkq_work(phononwfkq_work, nscf_vars={}, remove_wfkq=True, with_ddk=True, manager=None)[source]

Construct a GKKPWork from a PhononWfkqWork object. The WFQ are the ones used for PhononWfkqWork so in principle have only valence bands

on_ok(sender)[source]

This callback is called when one task reaches status S_OK. It removes the WFKQ file if all its children have reached S_OK.

class BecWork(workdir=None, manager=None)[source]

Bases: pymatgen.io.abinit.works.Work, pymatgen.io.abinit.works.MergeDdb

Work for the computation of the Born effective charges.

This work consists of DDK tasks and phonon + electric field perturbation It provides the callback method (on_all_ok) that calls mrgddb to merge the partial DDB files produced by the work.

Parameters
• workdir – Path to the working directory.

• managerTaskManager object.

classmethod from_scf_task(scf_task, ddk_tolerance=None, ph_tolerance=None, manager=None)[source]

Build tasks for the computation of Born effective charges from a ground-state task.

Parameters

• ddk_tolerance – tolerance used in the DDK run if with_becs. None to use AbiPy default.

• ph_tolerance – dict {“varname”: value} with the tolerance used in the phonon run. None to use AbiPy default.

• managerTaskManager object.

on_all_ok()[source]

This method is called when all tasks reach S_OK Ir runs mrgddb in sequential on the local machine to produce the final DDB file in the outdir of the Work.

class DteWork(workdir=None, manager=None)[source]

Bases: pymatgen.io.abinit.works.Work, pymatgen.io.abinit.works.MergeDdb

Work for the computation of the third derivative of the energy.

This work consists of DDK tasks and electric field perturbation. It provides the callback method (on_all_ok) that calls mrgddb to merge the partial DDB files produced

Parameters
• workdir – Path to the working directory.

• managerTaskManager object.

classmethod from_scf_task(scf_task, ddk_tolerance=None, manager=None)[source]

Build a DteWork from a ground-state task.

Parameters
• managerTaskManager object.
on_all_ok`()[source]