# 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 CyclesPlotter[source]

Bases: object

Relies on the plot method of cycle objects to build multiple subfigures.

add_label_cycle(label, cycle)[source]

Add new cycle to the plotter with label label.

combiplot(fontsize=8, **kwargs)[source]

Compare multiple cycels on a grid: one subplot per quantity, all cycles on the same subplot.

Parameters

fontsize – Legend fontsize.

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 e.g. size_kwargs=dict(w=3, h=4)

tight_layout

True to call fig.tight_layout (default: False)

ax_grid

True (False) to add (remove) grid from all axes in fig. Default: None i.e. fig is left unchanged.

ax_annotate

Add labels to subplots e.g. (a), (b). Default: False

fig_close

Close figure. Default: False.

items()[source]

To iterate over (label, cycle).

slideshow(**kwargs)[source]

Produce slides show of the different cycles. One plot per cycle.

class D2DEScfCycle(fields)[source]

Result of the Phonon self-consistent cycle.

MAGIC = 'iter 2DEtotal(Ha)'[source]
property last_etotal[source]

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)'[source]
property last_etotal[source]

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. This object is mainly used to analyze the behavior of the Scf cycles during the structural relaxation. A more powerful and detailed analysis can be obtained by using the HIST.nc file.

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[source]

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

plot(ax_list=None, fontsize=12, **kwargs)[source]

Plot relaxation history i.e. the results of the last iteration of each SCF cycle.

Parameters
• ax_list – List of axes. If None a new figure is produced.

• fontsize – legend fontsize.

• kwargs – keyword arguments are passed to ax.plot

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 e.g. size_kwargs=dict(w=3, h=4)

tight_layout

True to call fig.tight_layout (default: False)

ax_grid

True (False) to add (remove) grid from all axes in fig. Default: None i.e. fig is left unchanged.

ax_annotate

Add labels to subplots e.g. (a), (b). Default: False

fig_close

Close figure. Default: False.

slideshow(**kwargs)[source]

Uses matplotlib to plot the evolution of the structural relaxation.

Parameters

ax_list – List of axes. If None a new figure is produced.

Returns

matplotlib figure

to_string(verbose=0)[source]

String representation.

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.

property last_iteration[source]

Returns a dictionary with the values of the last iteration.

plot(ax_list=None, fontsize=12, **kwargs)[source]

Uses matplotlib to plot the evolution of the SCF cycle.

Parameters
• ax_list – List of axes. If None a new figure is produced.

• fontsize – legend fontsize.

• kwargs – keyword arguments are passed to ax.plot

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 e.g. size_kwargs=dict(w=3, h=4)

tight_layout

True to call fig.tight_layout (default: False)

ax_grid

True (False) to add (remove) grid from all axes in fig. Default: None i.e. fig is left unchanged.

ax_annotate

Add labels to subplots e.g. (a), (b). Default: False

fig_close

Close figure. Default: False.

to_string(verbose=0)[source]

String representation.

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[source]
tag[source]
text[source]
property text_notag[source]

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[source]

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]