pymatgen.io.abinit.tasks module

This module provides functions and classes related to Task objects.

class TaskManager(**kwargs)[source]

Bases: monty.json.MSONable

A TaskManager is responsible for the generation of the job script and the submission of the task, as well as for the specification of the parameters passed to the resource manager (e.g. Slurm, PBS ...) and/or the run-time specification of the ABINIT variables governing the parallel execution. A TaskManager delegates the generation of the submission script and the submission of the task to the QueueAdapter. A TaskManager has a TaskPolicy that governs the specification of the parameters for the parallel executions. Ideally, the TaskManager should be the main entry point used by the task to deal with job submission/optimization

Parameters:
  • policy – None
  • qadapters – List of qadapters in YAML format
  • db_connector – Dictionary with data used to connect to the database (optional)
ENTRIES = {'db_connector', 'batch_adapter', 'qadapters', 'policy'}
USER_CONFIG_DIR = '/Users/shyuep/.abinit/abipy'
YAML_FILE = 'manager.yml'
as_dict()[source]
classmethod as_manager(obj)[source]

Convert obj into TaskManager instance. Accepts string, filepath, dictionary, TaskManager object. If obj is None, the manager is initialized from the user config file.

classmethod autodoc()[source]
cancel(job_id)[source]

Cancel the job. Returns exit status.

deepcopy()[source]

Deep copy of self.

exclude_nodes(nodes)[source]
classmethod from_dict(d)[source]

Create an instance from a dictionary.

classmethod from_file(filename)[source]

Read the configuration parameters from the Yaml file filename.

classmethod from_string(s)[source]

Create an instance from string s containing a YAML dictionary.

classmethod from_user_config()[source]

Initialize the TaskManager from the YAML file ‘manager.yaml’. Search first in the working directory and then in the abipy configuration directory.

Raises:RuntimeError if file is not found.
get_collection(**kwargs)[source]

Return the MongoDB collection used to store the results.

get_njobs_in_queue(username=None)[source]

returns the number of jobs in the queue, returns None when the number of jobs cannot be determined.

Parameters:username – (str) the username of the jobs to count (default is to autodetect)
has_db

True if we are using MongoDB database

has_omp

True if we are using OpenMP parallelization.

has_queue

True if we are submitting jobs via a queue manager.

increase_mem()[source]
increase_ncpus()[source]

increase the number of cpus, first ask the current quadapter, if that one raises a QadapterIncreaseError switch to the next qadapter. If all fail raise an ManagerIncreaseError

increase_resources()[source]
increase_time()[source]
launch(task, **kwargs)[source]

Build the input files and submit the task via the Qadapter

Parameters:taskTaskObject
Returns:Process object.
max_cores

Maximum number of cores that can be used. This value is mainly used in the autoparal part to get the list of possible configurations.

mem_per_proc

Memory per MPI process.

mpi_procs

Number of MPI processes.

new_with_fixed_mpi_omp(mpi_procs, omp_threads)[source]

Return a new TaskManager in which autoparal has been disabled. The jobs will be executed with mpi_procs MPI processes and omp_threads OpenMP threads. Useful for generating input files for benchmarks.

num_cores

Total number of CPUs used to run the task.

omp_threads

Number of OpenMP threads

qadapter

The qadapter used to submit jobs.

qads

List of QueueAdapter objects sorted according to priorities (highest comes first)

select_qadapter(pconfs)[source]

Given a list of parallel configurations, pconfs, this method select an optimal configuration according to some criterion as well as the QueueAdapter to use.

Parameters:pconfsParalHints object with the list of parallel configurations
Returns:ParallelConf object with the optimal configuration.
set_mem_per_proc(mem_mb)[source]

Set the memory (in Megabytes) per CPU.

set_mpi_procs(mpi_procs)[source]

Set the number of MPI processes to use.

set_omp_threads(omp_threads)[source]

Set the number of OpenMp threads to use.

to_shell_manager(mpi_procs=1)[source]

Returns a new TaskManager with the same parameters as self but replace the QueueAdapter with a ShellAdapter with mpi_procs so that we can submit the job without passing through the queue.

write_jobfile(task, **kwargs)[source]

Write the submission script. Return the path of the script

kwargs Meaning
exec_args List of arguments passed to task.executable. Default: no arguments.
class AbinitBuild(workdir=None, manager=None)[source]

Bases: object

This object stores information on the options used to build Abinit

info
String with build information as produced by `abinit -b`
version
Abinit version number e.g 8.0.1 (string)
has_netcdf
True if netcdf is enabled.
has_etsfio
True if etsf-io is enabled.
has_omp
True if OpenMP is enabled.
has_mpi
True if MPI is enabled.
has_mpiio
True if MPI-IO is supported.
class ParalHintsParser[source]

Bases: object

Error

alias of ParalHintsError

add_error(errmsg)[source]
parse(filename)[source]

Read the AutoParal section (YAML format) from filename. Assumes the file contains only one section.

class ScfTask(input, workdir=None, manager=None, deps=None)[source]

Bases: pymatgen.io.abinit.tasks.GsTask

Self-consistent ground-state calculations. Provide support for in-place restart via (WFK|DEN) files

Parameters:
  • inputAbinitInput object.
  • workdir – Path to the working directory.
  • managerTaskManager object.
  • deps – Dictionary specifying the dependency of this node. None means that this Task has no dependency.
CRITICAL_EVENTS = [<class 'pymatgen.io.abinit.events.ScfConvergenceWarning'>]
color_rgb = array([ 1., 0., 0.])
get_results(**kwargs)[source]
inspect(**kwargs)[source]

Plot the SCF cycle results with matplotlib.

Returns
matplotlib figure, None if some error occurred.
restart()[source]

SCF calculations can be restarted if we have either the WFK file or the DEN file.

class NscfTask(input, workdir=None, manager=None, deps=None)[source]

Bases: pymatgen.io.abinit.tasks.GsTask

Non-Self-consistent GS calculation. Provide in-place restart via WFK files

Parameters:
  • inputAbinitInput object.
  • workdir – Path to the working directory.
  • managerTaskManager object.
  • deps – Dictionary specifying the dependency of this node. None means that this Task has no dependency.
CRITICAL_EVENTS = [<class 'pymatgen.io.abinit.events.NscfConvergenceWarning'>]
color_rgb = array([ 1. , 0.47843137, 0.47843137])
get_results(**kwargs)[source]
restart()[source]

NSCF calculations can be restarted only if we have the WFK file.

class RelaxTask(input, workdir=None, manager=None, deps=None)[source]

Bases: pymatgen.io.abinit.tasks.GsTask, pymatgen.io.abinit.tasks.ProduceHist

Task for structural optimizations.

Parameters:
  • inputAbinitInput object.
  • workdir – Path to the working directory.
  • managerTaskManager object.
  • deps – Dictionary specifying the dependency of this node. None means that this Task has no dependency.
CRITICAL_EVENTS = [<class 'pymatgen.io.abinit.events.RelaxConvergenceWarning'>]
color_rgb = array([ 1. , 0.23921569, 1. ])
fix_ofiles()[source]

Note that ABINIT produces lots of out_TIM1_DEN files for each step. Here we list all TIM*_DEN files, we select the last one and we rename it in out_DEN

This change is needed so that we can specify dependencies with the syntax {node: “DEN”} without having to know the number of iterations needed to converge the run in node!

get_final_structure()[source]

Read the final structure from the GSR file.

get_results(**kwargs)[source]
inspect(**kwargs)[source]

Plot the evolution of the structural relaxation with matplotlib.

Parameters:what – Either “hist” or “scf”. The first option (default) extracts data from the HIST file and plot the evolution of the structural parameters, forces, pressures and energies. The second option, extracts data from the main output file and plot the evolution of the SCF cycles (etotal, residuals, etc).
Returns:matplotlib figure, None if some error occurred.
reduce_dilatmx(target=1.01)[source]
restart()[source]

Restart the structural relaxation.

Structure relaxations can be restarted only if we have the WFK file or the DEN or the GSR file. from which we can read the last structure (mandatory) and the wavefunctions (not mandatory but useful). Prefer WFK over other files since we can reuse the wavefunctions.

Note

The problem in the present approach is that some parameters in the input are computed from the initial structure and may not be consistent with the modification of the structure done during the structure relaxation.

class DdkTask(input, workdir=None, manager=None, deps=None)[source]

Bases: pymatgen.io.abinit.tasks.DfptTask

Task for DDK calculations.

Parameters:
  • inputAbinitInput object.
  • workdir – Path to the working directory.
  • managerTaskManager object.
  • deps – Dictionary specifying the dependency of this node. None means that this Task has no dependency.
color_rgb = array([ 0.23921569, 0.61960784, 1. ])
get_results(**kwargs)[source]
class PhononTask(input, workdir=None, manager=None, deps=None)[source]

Bases: pymatgen.io.abinit.tasks.DfptTask

DFPT calculations for a single atomic perturbation. Provide support for in-place restart via (1WF|1DEN) files

Parameters:
  • inputAbinitInput object.
  • workdir – Path to the working directory.
  • managerTaskManager object.
  • deps – Dictionary specifying the dependency of this node. None means that this Task has no dependency.
CRITICAL_EVENTS = [<class 'pymatgen.io.abinit.events.ScfConvergenceWarning'>]
color_rgb = array([ 0., 0., 1.])
get_results(**kwargs)[source]
inspect(**kwargs)[source]

Plot the Phonon SCF cycle results with matplotlib.

Returns:matplotlib figure, None if some error occurred.
restart()[source]

Phonon calculations can be restarted only if we have the 1WF file or the 1DEN file. from which we can read the first-order wavefunctions or the first order density. Prefer 1WF over 1DEN since we can reuse the wavefunctions.

class SigmaTask(input, workdir=None, manager=None, deps=None)[source]

Bases: pymatgen.io.abinit.tasks.ManyBodyTask

Tasks for SIGMA calculations. Provides support for in-place restart via QPS files

Parameters:
  • inputAbinitInput object.
  • workdir – Path to the working directory.
  • managerTaskManager object.
  • deps – Dictionary specifying the dependency of this node. None means that this Task has no dependency.
CRITICAL_EVENTS = [<class 'pymatgen.io.abinit.events.QPSConvergenceWarning'>]
color_rgb = array([ 0., 1., 0.])
get_results(**kwargs)[source]
get_scissors_builder()[source]

Returns an instance of ScissorsBuilder from the SIGRES file.

Raise:
RuntimeError if SIGRES file is not found.
open_sigres()[source]

Open the SIGRES file located in the in self.outdir. Returns SigresFile object, None if file could not be found or file is not readable.

restart()[source]
sigres_path

Absolute path of the SIGRES file. Empty string if file is not present.

class OpticTask(optic_input, nscf_node, ddk_nodes, workdir=None, manager=None)[source]

Bases: pymatgen.io.abinit.tasks.Task

Task for the computation of optical spectra with optic i.e. RPA without local-field effects and velocity operator computed from DDK files.

Create an instance of OpticTask from an string containing the input.

Parameters:
  • optic_input – string with the optic variables (filepaths will be added at run time).
  • nscf_node – The NSCF task that will produce thw WFK file or string with the path of the WFK file.
  • ddk_nodes – List of DdkTask nodes that will produce the DDK files or list of DDF paths.
  • workdir – Path to the working directory.
  • managerTaskManager object.
autoparal_run()[source]

Find an optimal set of parameters for the execution of the Optic task This method can change the submission parameters e.g. the number of CPUs for MPI and OpenMp.

Returns 0 if success

color_rgb = array([ 1. , 0.8, 0.4])
ddk_filepaths

Returns (at runtime) the absolute path of the DDK files produced by the DDK runs.

executable

Path to the executable required for running the OpticTask.

filesfile_string

String with the list of files and prefixes needed to execute ABINIT.

fix_abicritical()[source]

Cannot fix abicritical errors for optic

fix_queue_critical()[source]

This function tries to fix critical events originating from the queue submission system.

General strategy, first try to increase resources in order to fix the problem, if this is not possible, call a task specific method to attempt to decrease the demands.

Returns:1 if task has been fixed else 0.
get_results(**kwargs)[source]
make_input()[source]

Construct and write the input file of the calculation.

Optic allows the user to specify the paths of the input file. hence we don’t need to create symbolic links.

reset_from_scratch()[source]

restart from scratch, this is to be used if a job is restarted with more resources after a crash

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

Optic does not use get or ird variables hence we should never try to change the input when we connect this task

set_workdir(workdir, chroot=False)[source]

Set the working directory of the task.

setup()[source]

Public method called before submitting the task.

wfk_filepath

Returns (at runtime) the absolute path of the WFK file produced by the NSCF run.

class AnaddbTask(anaddb_input, ddb_node, gkk_node=None, md_node=None, ddk_node=None, workdir=None, manager=None)[source]

Bases: pymatgen.io.abinit.tasks.Task

Task for Anaddb runs (post-processing of DFPT calculations).

Create an instance of AnaddbTask from a string containing the input.

Parameters:
  • anaddb_input – string with the anaddb variables.
  • ddb_node – The node that will produce the DDB file. Accept Task, Work or filepath.
  • gkk_node – The node that will produce the GKK file (optional). Accept Task, Work or filepath.
  • md_node – The node that will produce the MD file (optional). Accept Task, Work or filepath.
  • gkk_node – The node that will produce the GKK file (optional). Accept Task, Work or filepath.
  • workdir – Path to the working directory (optional).
  • managerTaskManager object (optional).
color_rgb = array([ 0.8, 0.4, 1. ])
ddb_filepath

Returns (at runtime) the absolute path of the input DDB file.

ddk_filepath

Returns (at runtime) the absolute path of the input DKK file.

executable

Path to the executable required for running the AnaddbTask.

filesfile_string

String with the list of files and prefixes needed to execute ABINIT.

get_results(**kwargs)[source]
gkk_filepath

Returns (at runtime) the absolute path of the input GKK file.

Anaddb allows the user to specify the paths of the input file. hence we don’t need to create symbolic links.

md_filepath

Returns (at runtime) the absolute path of the input MD file.

open_phbst()[source]

Open PHBST file produced by Anaddb and returns PhbstFile object.

open_phdos()[source]

Open PHDOS file produced by Anaddb and returns PhdosFile object.

setup()[source]

Public method called before submitting the task.

classmethod temp_shell_task(inp, ddb_node, gkk_node=None, md_node=None, ddk_node=None, workdir=None, manager=None)[source]

Build a AnaddbTask with a temporary workdir. The task is executed via the shell with 1 MPI proc. Mainly used for post-processing the DDB files.

Parameters:
  • anaddb_input – string with the anaddb variables.
  • ddb_node – The node that will produce the DDB file. Accept Task, Work or filepath.

See AnaddbInit for the meaning of the other arguments.