pymatgen.io.abinit.tasks module¶
This module provides functions and classes related to Task objects.
-
class
TaskManager(**kwargs)[source]¶ Bases:
monty.json.MSONableA 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
TaskPolicythat 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= {'batch_adapter', 'db_connector', 'policy', 'qadapters'}¶
-
USER_CONFIG_DIR= '/Users/matt/.abinit/abipy'¶
-
YAML_FILE= 'manager.yml'¶
-
abinit_build[source]¶ AbinitBuildobject with Abinit version and options used to build the code
-
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
from_file(filename)[source]¶ Read the configuration parameters from the Yaml file filename.
-
classmethod
from_user_config()[source]¶ Initialize the
TaskManagerfrom 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_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)
-
property
has_db¶ True if we are using MongoDB database
-
property
has_omp¶ True if we are using OpenMP parallelization.
-
property
has_queue¶ True if we are submitting jobs via a queue manager.
-
increase_ncpus()[source]¶ increase the number of cpus, first ask the current qadapter, if that one raises a QadapterIncreaseError switch to the next qadapter. If all fail raise an ManagerIncreaseError
-
launch(task, **kwargs)[source]¶ Build the input files and submit the task via the
Qadapter- Parameters
task –
TaskObject- Returns
Process object.
-
property
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.
-
property
mem_per_proc¶ Memory per MPI process.
-
property
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.
-
property
num_cores¶ Total number of CPUs used to run the task.
-
property
omp_threads¶ Number of OpenMP threads
-
property
qadapter¶ The qadapter used to submit jobs.
-
property
qads¶ List of
QueueAdapterobjects 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
QueueAdapterto use.- Parameters
pconfs –
ParalHintsobject with the list of parallel configurations- Returns
ParallelConfobject with the optimal configuration.
- A TaskManager has a
-
class
AbinitBuild(workdir=None, manager=None)[source]¶ Bases:
objectThis object stores information on the options used to build Abinit
-
class
ParalHints(info, confs)[source]¶ Bases:
collections.abc.IterableIterable with the hints for the parallel execution reported by ABINIT.
-
Error¶ alias of
ParalHintsError
-
classmethod
from_mpi_omp_lists(mpi_procs, omp_threads)[source]¶ Build a list of Parallel configurations from two lists containing the number of MPI processes and the number of OpenMP threads i.e. product(mpi_procs, omp_threads). The configuration have parallel efficiency set to 1.0 and no input variables. Mainly used for preparing benchmarks.
-
get_ordered_with_policy(policy, max_ncpus)[source]¶ Sort and return a new list of configurations ordered according to the
TaskPolicypolicy.
-
select_with_condition(condition, key=None)[source]¶ Remove all the configurations that do not satisfy the given condition.
- Args:
condition: dict or
Conditionobject with operators expressed with a Mongodb-like syntax key: Selects the sub-dictionary on which condition is applied, e.g. key=”vars”if we have to filter the configurations depending on the values in vars
-
sort_by_efficiency(reverse=True)[source]¶ Sort the configurations in place. items with highest efficiency come first
-
-
class
AbinitTask(input, workdir=None, manager=None, deps=None)[source]¶ Bases:
pymatgen.io.abinit.tasks.TaskBase class defining an ABINIT calculation
- Parameters
input –
AbinitInputobject.workdir – Path to the working directory.
manager –
TaskManagerobject.deps – Dictionary specifying the dependency of this node. None means that this Task has no dependency.
-
Results¶ alias of
TaskResults
-
autoparal_run()[source]¶ Find an optimal set of parameters for the execution of the task This method can change the ABINIT input variables and/or the submission parameters e.g. the number of CPUs for MPI and OpenMp.
- Set:
self.pconfs where pconfs is a
ParalHintsobject with the configuration reported by autoparal and optimal is the optimal configuration selected. Returns 0 if success
-
cycle_class[source]¶ Return the subclass of ScfCycle associated to the task or None if no SCF algorithm if associated to the task.
-
property
executable¶ Path to the executable required for running the Task.
-
property
filesfile_string¶ String with the list of files and prefixes needed to execute ABINIT.
-
fix_abicritical()[source]¶ method to fix crashes/error caused by abinit
- Returns
1 if task has been fixed else 0.
-
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.
-
classmethod
from_input(input, workdir=None, manager=None)[source]¶ Create an instance of AbinitTask from an ABINIT input.
- Parameters
ainput – AbinitInput object.
workdir – Path to the working directory.
manager –
TaskManagerobject.
-
property
is_dfpt_task¶ True if task is a DftpTask subclass.
-
property
is_gs_task¶ True if task is GsTask subclass.
-
property
isnc¶ True if norm-conserving calculation.
-
property
ispaw¶ True if PAW calculation
-
parse_timing()[source]¶ Parse the timer data in the main output file of Abinit. Requires timopt /= 0 in the input file (usually timopt = -1)
Return:
AbinitTimerParserinstance, None if error.
-
property
pconfs¶ List of autoparal configurations.
-
property
pseudos¶ List of pseudos used in the calculation.
-
reset_from_scratch()[source]¶ Restart from scratch, this is to be used if a job is restarted with more resources after a crash
Move output files produced in workdir to _reset otherwise check_status continues to see the task as crashed even if the job did not run
-
select_files(what='o')[source]¶ Helper function used to select the files of a task.
- Parameters
what –
string with the list of characters selecting the file type Possible choices:
i ==> input_file, o ==> output_file, f ==> files_file, j ==> job_file, l ==> log_file, e ==> stderr_file, q ==> qout_file, all ==> all files.
-
setup()[source]¶ Abinit has the very bad habit of changing the file extension by appending the characters in [A,B …, Z] to the output file, and this breaks a lot of code that relies of the use of a unique file extension. Here we fix this issue by renaming run.abo to run.abo_[number] if the output file “run.abo” already exists. A few lines of code in python, a lot of problems if you try to implement this trick in Fortran90.
-
classmethod
temp_shell_task(inp, mpi_procs=1, workdir=None, manager=None)[source]¶ Build a Task with a temporary workdir. The task is executed via the shell with 1 MPI proc. Mainly used for invoking Abinit to get important parameters needed to prepare the real task.
- Parameters
mpi_procs – Number of MPI processes to use.
-
class
ScfTask(input, workdir=None, manager=None, deps=None)[source]¶ Bases:
pymatgen.io.abinit.tasks.GsTaskSelf-consistent ground-state calculations. Provide support for in-place restart via (WFK|DEN) files
- Parameters
input –
AbinitInputobject.workdir – Path to the working directory.
manager –
TaskManagerobject.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]¶ Returns
NodeResultsinstance. Subclasses should extend this method (if needed) by adding specialized code that performs some kind of post-processing.
-
class
NscfTask(input, workdir=None, manager=None, deps=None)[source]¶ Bases:
pymatgen.io.abinit.tasks.GsTaskNon-Self-consistent GS calculation. Provide in-place restart via WFK files
- Parameters
input –
AbinitInputobject.workdir – Path to the working directory.
manager –
TaskManagerobject.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([0.78431373, 0.31372549, 0.39215686])¶
-
class
RelaxTask(input, workdir=None, manager=None, deps=None)[source]¶ Bases:
pymatgen.io.abinit.tasks.GsTask,pymatgen.io.abinit.tasks.ProduceHistTask for structural optimizations.
- Parameters
input –
AbinitInputobject.workdir – Path to the working directory.
manager –
TaskManagerobject.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_results(**kwargs)[source]¶ Returns
NodeResultsinstance. Subclasses should extend this method (if needed) by adding specialized code that performs some kind of post-processing.
-
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.
-
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.DfptTaskTask for DDK calculations.
- Parameters
input –
AbinitInputobject.workdir – Path to the working directory.
manager –
TaskManagerobject.deps – Dictionary specifying the dependency of this node. None means that this Task has no dependency.
-
color_rgb= array([0. , 0.8, 0.8])¶
-
class
PhononTask(input, workdir=None, manager=None, deps=None)[source]¶ Bases:
pymatgen.io.abinit.tasks.DfptTaskDFPT calculations for a single atomic perturbation. Provide support for in-place restart via (1WF|1DEN) files
- Parameters
input –
AbinitInputobject.workdir – Path to the working directory.
manager –
TaskManagerobject.deps – Dictionary specifying the dependency of this node. None means that this Task has no dependency.
-
color_rgb= array([0. , 0.58823529, 0.98039216])¶
-
class
ElasticTask(input, workdir=None, manager=None, deps=None)[source]¶ Bases:
pymatgen.io.abinit.tasks.DfptTaskDFPT calculations for a single strain perturbation (uniaxial or shear strain). Provide support for in-place restart via (1WF|1DEN) files
- Parameters
input –
AbinitInputobject.workdir – Path to the working directory.
manager –
TaskManagerobject.deps – Dictionary specifying the dependency of this node. None means that this Task has no dependency.
-
color_rgb= array([1. , 0.8, 1. ])¶
-
class
SigmaTask(input, workdir=None, manager=None, deps=None)[source]¶ Bases:
pymatgen.io.abinit.tasks.ManyBodyTaskTasks for SIGMA calculations. Provides support for in-place restart via QPS files
- Parameters
input –
AbinitInputobject.workdir – Path to the working directory.
manager –
TaskManagerobject.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]¶ Returns
NodeResultsinstance. Subclasses should extend this method (if needed) by adding specialized code that performs some kind of post-processing.
-
get_scissors_builder()[source]¶ Returns an instance of
ScissorsBuilderfrom 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
SigresFileobject, None if file could not be found or file is not readable.
-
property
sigres_path¶ Absolute path of the SIGRES file. Empty string if file is not present.
-
class
EphTask(input, workdir=None, manager=None, deps=None)[source]¶ Bases:
pymatgen.io.abinit.tasks.AbinitTaskClass for electron-phonon calculations.
- Parameters
input –
AbinitInputobject.workdir – Path to the working directory.
manager –
TaskManagerobject.deps – Dictionary specifying the dependency of this node. None means that this Task has no dependency.
-
color_rgb= array([1. , 0.50196078, 0. ])¶
-
class
OpticTask(optic_input, nscf_node, ddk_nodes, use_ddknc=False, workdir=None, manager=None)[source]¶ Bases:
pymatgen.io.abinit.tasks.TaskTask 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
OpticTaskfrom an string containing the input.- Parameters
optic_input –
OpticInputobject with optic variables.nscf_node – The task that will produce the WFK file with the KS energies or path to the WFK file.
ddk_nodes – List of
DdkTasknodes that will produce the DDK files or list of DDK filepaths. Order (x, y, z)workdir – Path to the working directory.
manager –
TaskManagerobject.
-
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])¶
-
property
ddk_filepaths¶ Returns (at runtime) the absolute path of the DDK files produced by the DDK runs.
-
property
filesfile_string¶ String with the list of files and prefixes needed to execute ABINIT.
-
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]¶ Returns
NodeResultsinstance. Subclasses should extend this method (if needed) by adding specialized code that performs some kind of post-processing.
-
make_links()[source]¶ 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
-
property
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.TaskTask for Anaddb runs (post-processing of DFPT calculations).
Create an instance of
AnaddbTaskfrom 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,Workor filepath.gkk_node – The node that will produce the GKK file (optional). Accept
Task,Workor 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).
manager –
TaskManagerobject (optional).
-
color_rgb= array([0.8, 0.4, 1. ])¶
-
property
ddb_filepath¶ Returns (at runtime) the absolute path of the input DDB file.
-
property
ddk_filepath¶ Returns (at runtime) the absolute path of the input DKK file.
-
property
executable¶ Path to the executable required for running the
AnaddbTask.
-
property
filesfile_string¶ String with the list of files and prefixes needed to execute ABINIT.
-
get_results(**kwargs)[source]¶ Returns
NodeResultsinstance. Subclasses should extend this method (if needed) by adding specialized code that performs some kind of post-processing.
-
property
gkk_filepath¶ Returns (at runtime) the absolute path of the input GKK file.
-
make_links()[source]¶ Anaddb allows the user to specify the paths of the input file. hence we don’t need to create symbolic links.
-
property
md_filepath¶ Returns (at runtime) the absolute path of the input MD file.
-
classmethod
temp_shell_task(inp, ddb_node, mpi_procs=1, gkk_node=None, md_node=None, ddk_node=None, workdir=None, manager=None)[source]¶ Build a
AnaddbTaskwith a temporary workdir. The task is executed via the shell with 1 MPI proc. Mainly used for post-processing the DDB files.- Parameters
mpi_procs – Number of MPI processes to use.
anaddb_input – string with the anaddb variables.
ddb_node – The node that will produce the DDB file. Accept
Task,Workor filepath.
See AnaddbInit for the meaning of the other arguments.