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
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.
  • deps – Dictionary specifying the dependency of this node. 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.
  • deps – Dictionary specifying the dependency of this node. 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]

Bases: pymatgen.io.abinit.works.Work

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]

Bases: pymatgen.io.abinit.works.Work

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

Return matplotlib figure or None if hist file is not found.

plot_ioncell_relaxation(**kwargs)[source]

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

Return matplotlib figure or None if hist file is not found.

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

Bases: pymatgen.io.abinit.works.Work

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:AbinitInput`for 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]

Bases: pymatgen.io.abinit.works.Work

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]

Bases: pymatgen.io.abinit.works.Work

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]

Bases: pymatgen.io.abinit.works.Work

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 usually consists of one GS + nirred Phonon tasks where nirred is the number of irreducible perturbations for a given q-point. 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_input(scf_input, qpoints, tolerance=None, manager=None)[source]

Similar to from_scf_task, the difference is that this method requires an input for SCF calculation instead of a ScfTask. All the tasks (Scf + Phonon) are packed in a single Work whereas in the previous case we usually have multiple works.

classmethod from_scf_task(scf_task, qpoints, 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 scf_task.

Parameters:
  • scf_task – ScfTask object.
  • qpoints – q-points in reduced coordinates. Accepts single q-point or list of q-points
  • tolerance – dict {varname: value} with the tolerance to be used in the DFPT run. Defaults to {“tolvrs”: 1.0e-10}.
  • managerTaskManager object.
merge_pot1_files()[source]

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

Returns:path to the output DVDB file. None if not DFPT POT file is found.
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.