# pymatgen.io.abinit.abiinspect module¶

This module provides objects to inspect the status of the Abinit tasks at run-time. by extracting information from the main output file (text format).

class D2DEScfCycle(fields)[source]

Result of the Phonon self-consistent cycle.

MAGIC = 'iter 2DEtotal(Ha)'
last_etotal

The 2-nd order derivative of the energy at the last iteration.

class GroundStateScfCycle(fields)[source]

Result of the Ground State self-consistent cycle.

MAGIC = 'iter Etot(hartree)'
last_etotal

The total energy at the last iteration.

class PhononScfCycle(fields)[source]

Iterations of the DFPT SCF cycle for phonons.

class Relaxation(cycles)[source]

Bases: collections.abc.Iterable

A list of GroundStateScfCycle objects.

Note

Forces, stresses and crystal structures are missing. Solving this problem would require the standardization of the Abinit output file (YAML).

classmethod from_file(filepath)[source]

Initialize the object from the Abinit main output file.

classmethod from_stream(stream)[source]

Extract data from stream. Returns None if some error occurred.

history

Dictionary of lists with the evolution of the data as function of the relaxation step.

plot(**kwargs)[source]

Uses matplotlib to plot the evolution of the structural relaxation.

Returns:
matplotlib figure

keyword arguments controlling the display of the figure:

kwargs Meaning
title Title of the plot (Default: None).
show True to show the figure (default: True).
savefig ‘abc.png’ or ‘abc.eps’ to save the figure to a file.
size_kwargs Dictionary with options passed to fig.set_size_inches example: size_kwargs=dict(w=3, h=4)
tight_layout True if to call fig.tight_layout (default: False)
class ScfCycle(fields)[source]

Bases: collections.abc.Mapping

It essentially consists of a dictionary mapping string to list of floats containing the data at the different iterations.

classmethod from_file(filepath)[source]

Read the first occurrence of ScfCycle from file.

classmethod from_stream(stream)[source]

Read the first occurrence of ScfCycle from stream.

Returns: None if no ScfCycle entry is found.
last_iteration

Returns a dictionary with the values of the last iteration.

plot(fig=None, **kwargs)[source]

Uses matplotlib to plot the evolution of the SCF cycle. Return matplotlib figure

Args:
fig: matplotlib figure. If None a new figure is produced.

keyword arguments controlling the display of the figure:

kwargs Meaning
title Title of the plot (Default: None).
show True to show the figure (default: True).
savefig ‘abc.png’ or ‘abc.eps’ to save the figure to a file.
size_kwargs Dictionary with options passed to fig.set_size_inches example: size_kwargs=dict(w=3, h=4)
tight_layout True if to call fig.tight_layout (default: False)
class YamlDoc(text, lineno, tag=None)[source]

Bases: object

Handy object that stores that YAML document, its main tag and the position inside the file.

Parameters: text – String with the YAML document. lineno – The line number where the document is located. tag – The YAML tag associate to the document.
as_dict()[source]

Use Yaml to parse the text (without the tag) and returns a dictionary.

lineno
tag
text
text_notag

Returns the YAML text without the tag. Useful if we don’t have any constructor registered for the tag (we used the tag just to locate the document).

class YamlTokenizer(filename)[source]

Bases: collections.abc.Iterator

Provides context-manager support so you can use it in a with statement.

Error

alias of YamlTokenizerError

all_docs_with_tag(doc_tag)[source]

Returns all the documents with the specified tag.

all_yaml_docs()[source]

Returns a list with all the YAML docs found in stream. Seek the stream before returning.

Warning

Assume that all the YAML docs (with the exception of the last one) are closed explicitely with the sentinel ‘...’

close()[source]
next()[source]

Returns the first YAML document in stream.

Warning

Assume that the YAML document are closed explicitely with the sentinel ‘...’

next_doc_with_tag(doc_tag)[source]

Returns the next document with the specified tag. Empty string is no doc is found.

seek(offset[, whence]) → None. Move to new file position.[source]

Argument offset is a byte count. Optional argument whence defaults to 0 (offset from start of file, offset should be >= 0); other values are 1 (move relative to current position, positive or negative), and 2 (move relative to end of file, usually negative, although many platforms allow seeking beyond the end of a file). If the file is opened in text mode, only offsets returned by tell() are legal. Use of other offsets causes undefined behavior. Note that not all file objects are seekable.

exception YamlTokenizerError[source]

Bases: Exception

Exceptions raised by YamlTokenizer.

plottable_from_outfile(filepath)[source]

Factory function that returns a plottable object by inspecting the main output file of abinit Returns None if it is not able to detect the class to instantiate.

straceback()[source]

Returns a string with the traceback.

yaml_read_irred_perts(filename, doc_tag='!IrredPerts')[source]

Read the list of irreducible perturbations from file.

yaml_read_kpoints(filename, doc_tag='!Kpoints')[source]

Read the K-points from file.