ppcodes Package

ppcodes Package

base_parser Module

Base class for parsers

exception abipy.ppcodes.base_parser.ParserError[source]

Bases: Exception

Exceptions raised by Parser objects.

class abipy.ppcodes.base_parser.BaseParser(filepath: str)[source]

Bases: object

Abstract class defining the interface that must be provided by the parsers used to extract results from the output file of a pseudopotential generator a.k.a. ppgen

errors

List of strings with errors reported by the pp generator

warnings

List of strings with the warnings reported by the pp generator.

Error

alias of ParserError

property errors: list[str]

List of strings with possible errors reported by the generator at run-time.

property warnings: list[str]

List of strings with possible errors reported by the generator at run-time.

abstract get_results() dict[source]

Return the most important results in a dictionary.

abstract get_input_str() str[source]

Returns a string with the input file.

oncv_parser Module

Classes and functions for parsing the ONCVPSP output file and plotting the results.

class abipy.ppcodes.oncv_parser.GrepResults(data, start, stop)

Bases: tuple

data

Alias for field number 0

start

Alias for field number 1

stop

Alias for field number 2

class abipy.ppcodes.oncv_parser.AePsNamedTuple(ae, ps)

Bases: tuple

ae

Alias for field number 0

ps

Alias for field number 1

class abipy.ppcodes.oncv_parser.ConvData(l, energies, values)

Bases: tuple

energies

Alias for field number 1

l

Alias for field number 0

values

Alias for field number 2

class abipy.ppcodes.oncv_parser.AtanLogDer(l, energies, values)

Bases: tuple

energies

Alias for field number 1

l

Alias for field number 0

values

Alias for field number 2

class abipy.ppcodes.oncv_parser.AtomicLevel(nlk: NlkState, eig: float, occ: float, is_valence: bool)[source]

Bases: object

Stores the energy levels of the AE isolated atom.

nlk: NlkState
eig: float
occ: float
is_valence: bool
class abipy.ppcodes.oncv_parser.OncvParser(filepath: str)[source]

Bases: BaseParser

Object to read and extract data from the output file of oncvpsp.

atsym
Z
nc
nv
iexc
psfile

Example

parser = OncvParser(filename).scan()

# To access data: parser.radial_wavefunctions

# To plot data with matplotlib. p = parser.get_plotter() p.plot_atanlogder_econv()

scan(verbose: int = 0) OncvParser[source]

Scan the output file, set run_completed attribute.

Raises: self.Error if invalid file.

property is_metapsp: bool
property is_oncvpsp: bool
min_ghost_empty_ha()[source]
lmax()[source]
to_string(verbose: int = 0) str[source]

String representation.

property relativistic: bool

True if fully-relativistic calculation.

rc_l()[source]

Core radii as a function of l extracted from the output file.

kinerr_nlk()[source]

Dictionary with the error on the kinetic energy indexed by nlk.

potentials()[source]

Dict with radial functions with the non-local and local potentials indexed by l. l = -1 corresponds to the local part (if present).

densities()[source]

Dictionary with charge densities on the radial mesh.

kin_densities()[source]

Dictionary with Kinetic energy densities on the radial mesh.

vtaus()[source]

Dictionary with Vtau ptotentials on the radial mesh.

radial_wfs()[source]

Read and set the radial wavefunctions for the bound states.

Usage:

ae_wfs, ps_wfs = self.radial_wfs.ae, self.radial_wfs.ps

for nlk, ae_wf in ae_wfs.items():

ps_wf, l, k = ps_wfs[nlk], nlk.l, nlk.k

property has_scattering_wfs: bool

True if pp generation included scattering states.

scattering_wfs()[source]

Read and set the scattering wavefunctions.

projectors()[source]

Dict with projector wave functions indexed by nlk.

atan_logders()[source]

Atan of the log derivatives for different l-values.

kene_vs_ecut()[source]

Dict with the convergence of the kinetic energy versus ecut for different l-values.

hints()[source]

Hints for the cutoff energy as provided by oncvpsp.

get_results() AttrDict[source]

Return the most important results extracted from the output file.

find_string(s: str) int[source]

Returns the index of the first line containing string s. Raises self.Error if s cannot be found.

get_input_str() str[source]

String with the ONCVPSP input file.

get_psp8_str() str | None[source]

Return string with the pseudopotential data in psp8 format. Return None if field is not present.

get_upf_str() str | None[source]

Return string with the pseudopotential data in upf format. Return None if field is not present.

get_plotter()[source]

Return an instance of OncvPlotter or None

gnuplot() None[source]

Plot the results with gnuplot. Based on the replot.sh script provided by the oncvpsp code.

get_atomic_levels_df() DataFrame[source]

Return pandas dataframe with the atomic levels. Columns: (n, l, k, eig, occ, is_valence)

get_peaks_df() DataFrame[source]

Return pandas dataframe with the position of the last peak.

oncv_plotter Module

Classes and functions for parsing the ONCVPSP output file and plotting the results.

class abipy.ppcodes.oncv_plotter.OncvPlotter(parser: OncvParser)[source]

Bases: NotebookWriter

Plots the results produced by a pseudopotential generator.

linewidth = 2
markersize = 2
linestyle_aeps = {'ae': 'solid', 'ps': 'dashed'}
markers_aeps = {'ae': '.', 'ps': 'o'}
color_l = {-3: 'yellow', -2: 'cyan', -1: 'magenta', 0: 'black', 1: 'red', 2: 'blue', 3: 'orange'}
classmethod from_file(filepath: str) OncvPlotter[source]

Build the plotter from an output file.

static decorate_ax(ax, xlabel=None, ylabel=None, title=None, fontsize=8)[source]

Decorate a matplotlib Axis adding xlabel, ylabel, title, grid and legend

plot_atan_logders(ax=None, with_xlabel=True, fontsize: int = 8, **kwargs) Any[source]

Plot arctan of logder on axis ax.

Parameters:

axmatplotlib.axes.Axes or None if a new figure should be created.

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.

plotly

Try to convert mpl figure to plotly.

plot_radial_wfs(ax=None, what='bound_states', fontsize: int = 8, **kwargs) Any[source]

Plot AE and PS radial wavefunctions on axis ax.

Parameters:
  • axmatplotlib.axes.Axes or None if a new figure should be created.

  • what – “bound_states” or “scattering_states”.

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.

plotly

Try to convert mpl figure to plotly.

plot_projectors(ax=None, fontsize: int = 8, **kwargs) Any[source]

Plot projectors on axis ax.

Parameters:

axmatplotlib.axes.Axes or None if a new figure should be created.

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.

plotly

Try to convert mpl figure to plotly.

plot_densities(ax=None, timesr2=False, fontsize: int = 8, **kwargs) Any[source]

Plot AE, PS and model densities on axis ax.

Parameters:

axmatplotlib.axes.Axes or None if a new figure should be created.

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.

plotly

Try to convert mpl figure to plotly.

plot_der_densities(ax=None, order=1, acc=4, fontsize=8, **kwargs) Any[source]

Plot the radial derivatives of the densities on axis ax. Used to analyze possible discontinuities or strong oscillations in r-space.

Parameters:

axmatplotlib.axes.Axes or None if a new figure should be created.

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.

plotly

Try to convert mpl figure to plotly.

plot_potentials(ax=None, fontsize: int = 8, **kwargs) Any[source]

Plot v_l and v_loc potentials on axis ax.

Parameters:

axmatplotlib.axes.Axes or None if a new figure should be created.

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.

plotly

Try to convert mpl figure to plotly.

plot_vtau(xscale='log', ax=None, fontsize: int = 8, **kwargs) Any[source]

Plot v_tau and v_tau(model+pseudo) potentials on axis ax.

Parameters:
  • xscale – “log” to plot vtau in log scale or “linear”. For other options see matplotlib.

  • axmatplotlib.axes.Axes or None if a new figure should be created.

plot_tau(ax=None, yscale='log', fontsize: int = 8, **kwargs) Any[source]

Plot kinetic energy densities tauPS and tau(M+PS) on axis ax.

Parameters:
  • yscale – “log” to plot tau in log scale or “linear”. For other options see matplotlib.

  • axmatplotlib.axes.Axes or None if a new figure should be created.

plot_der_potentials(ax=None, order=1, acc=4, fontsize: int = 8, **kwargs) Any[source]

Plot the derivatives of vl and vloc potentials on axis ax. Used to analyze the derivative discontinuity introduced by the RRKJ method at rc.

Parameters:

axmatplotlib.axes.Axes or None if a new figure should be created.

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.

plotly

Try to convert mpl figure to plotly.

plot_kene_vs_ecut(ax=None, fontsize: int = 8, **kwargs) Any[source]

Plot the convergence of the kinetic energy wrt ecut on axis ax.

Parameters:

axmatplotlib.axes.Axes or None if a new figure should be created.

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.

plotly

Try to convert mpl figure to plotly.

plot_atanlogder_econv(ax_list=None, fontsize: int = 6, **kwargs) Any[source]

Plot atan(logder) and the convergence of kinetic energy on the same figure.

Return: 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.

plotly

Try to convert mpl figure to plotly.

plot_den_formfact(ecut=120, ax=None, fontsize: int = 8, **kwargs) Any[source]

Plot the density form factor as a function of ecut in Ha.

Parameters:

axmatplotlib.axes.Axes or None if a new figure should be created.

Return: 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.

plotly

Try to convert mpl figure to plotly.

plot_atomic_levels(ax=None, fontsize: int = 0, **kwargs) Any[source]

Plot atomic levels in Ha.

Parameters:

axmatplotlib.axes.Axes or None if a new figure should be created.

Return: 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.

plotly

Try to convert mpl figure to plotly.

yield_figs(**kwargs)[source]

Generate a predefined list of matplotlib figures with minimal input from the user.

write_notebook(nbpath=None)[source]

Write a jupyter notebook to nbpath. If nbpath is None, a temporay file is created. Return path to the notebook. A typical template:

# Preable.
nbformat, nbv, nb = self.get_nbformat_nbv_nb(title=None)

#####################
# Put your code here
nb.cells.extend([
    nbv.new_markdown_cell("# This is a markdown cell"),
    nbv.new_code_cell("a = 1"),
])
#####################

# Call _write_nb_nbpath
return self._write_nb_nbpath(nb, nbpath)
abipy.ppcodes.oncv_plotter.oncv_make_open_notebook(outpath: str, foreground: bool = False, classic_notebook: bool = False, no_browser: bool = False) int[source]

Generate an ipython notebook and open it in the browser.

Parameters:
  • foreground – By default, jupyter is executed in background and stdout, stderr are redirected to devnull. Use foreground to run the process in foreground

  • classic_notebook – True to use the classic notebook instead of jupyter-lab (default)

  • no_browser – Start the jupyter server to serve the notebook but don’t open the notebook in the browser. Use this option to connect remotely from localhost to the machine running the kernel

Return: system exit code.

Raise: RuntimeError if jupyter executable is not in $PATH

abipy.ppcodes.oncv_plotter.oncv_write_notebook(outpath: str, nbpath: str | None = None) str[source]

Write an ipython notebook to nbpath If nbpath is None, a temporay file is created. Return path to the notebook.

class abipy.ppcodes.oncv_plotter.MultiOncvPlotter[source]

Bases: NotebookWriter

Object for comparing and plotting multiple pseudos.

Usage example:

plotter = MultiOncvPlotter.from_files(filepaths)
plotter.plot_atan_logders()
classmethod from_files(files: list[str]) MultiOncvPlotter[source]

Create an instance from a list of oncvpsp output files.

add_file(label: str, filepath: str) None[source]

Add a oncvps output file to the plotter with label

property plotters: list[OncvPlotter]

“List of registered Plotters.

property labels: list[str]

List of labels.

items()[source]

List of plotters.

plot_atan_logders(ax_list=None, with_xlabel=True, xlims=None, ylims=None, fontsize: int = 8, **kwargs) Any[source]

Plot arctan of logder on ax_list for all pseudos.

Parameters:

ax_list – List of matplotlib.axes.Axes or None if a new figure should be created.

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.

plotly

Try to convert mpl figure to plotly.

plot_radial_wfs(ax_list=None, what='bound_states', fontsize: int = 8, **kwargs) Any[source]

Plot AE and PS radial wavefunctions of ax_list for all pseudos.

Parameters:
  • ax_list – List of matplotlib.axes.Axes or None if a new figure should be created.

  • what – “bound_states” or “scattering_states”.

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.

plotly

Try to convert mpl figure to plotly.

plot_projectors(ax_list=None, fontsize: int = 8, **kwargs) Any[source]

Plot projectors on ax_list for all pseudos.

Parameters:

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.

plotly

Try to convert mpl figure to plotly.

plot_densities(ax_list=None, timesr2=False, fontsize: int = 8, **kwargs) Any[source]

Plot AE, PS and model densities on ax_list for all pseudos.

Parameters:

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.

plotly

Try to convert mpl figure to plotly.

plot_der_densities(ax_list=None, order=1, acc=4, fontsize=8, **kwargs) Any[source]

Plot the radial derivatives of the densities on ax_list for all pseudos. Used to analyze possible discontinuities or strong oscillations in r-space.

Parameters:

ax_list – List of matplotlib.axes.Axes or None if a new figure should be created.

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.

plotly

Try to convert mpl figure to plotly.

plot_potentials(ax_list=None, fontsize: int = 8, **kwargs) Any[source]

Plot v_l and v_loc potentials on ax_list for all pseudos.

Parameters:

ax_list – List of matplotlib.axes.Axes or None if a new figure should be created.

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.

plotly

Try to convert mpl figure to plotly.

plot_der_potentials(ax_list=None, order=1, acc=4, fontsize: int = 8, **kwargs) Any[source]

Plot the derivatives of vl and vloc potentials on ax_list for all pseudos. Used to analyze the derivative discontinuity introduced by the RRKJ method at rc.

Parameters:

ax_list – List of matplotlib.axes.Axes or None if a new figure should be created.

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.

plotly

Try to convert mpl figure to plotly.

plot_kene_vs_ecut(ax_list=None, fontsize: int = 8, **kwargs) Any[source]

Plot the convergence of the kinetic energy wrt ecut on ax_list for all pseudos.

Parameters:

ax_list – List of matplotlib.axes.Axes or None if a new figure should be created.

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.

plotly

Try to convert mpl figure to plotly.

plot_atanlogder_econv(ax_mat=None, fontsize: int = 6, **kwargs) Any[source]

Plot atan(logder) and converge of kinetic energy on the same figure for all pseudos. Return: 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.

plotly

Try to convert mpl figure to plotly.

plot_den_formfact(ecut=120, ax_list=None, fontsize: int = 8, **kwargs) Any[source]

Plot the density form factor as a function of ecut in Ha on ax_list for all pseudos.

Parameters:

ax_list – List of matplotlib.axes.Axes or None if a new figure should be created.

Return: 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.

plotly

Try to convert mpl figure to plotly.

plot_atomic_levels(ax_list=None, fontsize: int = 8, **kwargs) Any[source]

Plot atomic levels in Ha for all pseudos.

Parameters:

ax_list – List of matplotlib.axes.Axes or None if a new figure should be created.

Return: 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.

plotly

Try to convert mpl figure to plotly.

yield_figs(**kwargs)[source]

Generate a predefined list of matplotlib figures with minimal input from the user.

write_notebook(nbpath=None)[source]

Write a jupyter notebook to nbpath. If nbpath is None, a temporay file is created. Return path to the notebook. A typical template:

# Preable.
nbformat, nbv, nb = self.get_nbformat_nbv_nb(title=None)

#####################
# Put your code here
nb.cells.extend([
    nbv.new_markdown_cell("# This is a markdown cell"),
    nbv.new_code_cell("a = 1"),
])
#####################

# Call _write_nb_nbpath
return self._write_nb_nbpath(nb, nbpath)
abipy.ppcodes.oncv_plotter.psp8_get_densities(path, fc_file=None, ae_file=None, plot=False)[source]

Extract AE-core, AE-valence and PS-valence from a psp8 file. Optionally write .fc and .AE file in format suitable for AIM and cut3d Hirshfeld code.

Parameters:
  • path – path of the psp8 file

  • fc_file – File-like object to .fc. and .AE file Set to None if files are now wanted.

  • ae_file – File-like object to .fc. and .AE file Set to None if files are now wanted.

  • plot – If true, call matplotlib to plot densities.

Returns:

(rmesh, psval, aeval, aecore)

Densities are multiplied by 4 pi i.e. int aecore * r**2 dr ~= N_core

Return type:

namedtuple with numpy arrays

Warning

The densities do not integrate exactly to the number of core/valence electrons. in particular the valence charge in elements with large Z as valence electrons are more delocalized and the finite radial mesh does not capture the contribution due to the tail. Client code is responsible for extrapolating the valence charge if needed. The error in the integral of the core charge is usually much smaller and should be ok for qualitative analysis.

ppgen Module

Interface for pseudopotential generators.

class abipy.ppcodes.ppgen.Status[source]

Bases: int

An integer representing the status of the ‘PseudoGenerator`.

classmethod as_status(obj: Status | str) Status[source]

Convert obj into Status.

classmethod from_string(s: str) Status[source]

Return an instance from its string representation.

class abipy.ppcodes.ppgen.OncvGenerator(input_str: str, calc_type: str, use_mgga: bool, workdir: str | None = None)[source]

Bases: _PseudoGenerator

This object receives an input file for oncvpsp, a string that defines the type of calculation (scalar-relativistic, …) runs the code in a temporary directory and provides methods to validate/analyze/plot the final results.

retcode

Retcode of oncvpsp

classmethod from_file(path: str, calc_type: str, use_mgga: bool, workdir: str | None = None) OncvGenerator[source]

Build the object from a file containing the input parameters.

check_status()[source]

Check the status of the run, set and return self.status attribute.