# ES Interface

Each of the interfaces uses subclass of the DFTCoordinates class to parse the output.

Note

The interfaces are in beta stage. Please let us know if you encounter any errors.

## Quantum Espresso

class PWCoordinates(filename, pwtype=None, to_angstrom=False)

Coordinates of the system from the PW data of Quantum Espresso. Subclass of the DFTCoordinates.

With initiallization reads either output or input of PW module of QE.

Parameters
• filename (str) – name of the PW input or output.

• pwfile (str) – Name of PW input or output file. If the file doesn’t have proper extension, parameter pw_type should indicate the type.

• pwtype (str) – Type of the coord_f. if not listed, will be inferred from extension of pwfile.

• to_angstrom (bool) – True if automatically convert the units of cell and coordinates to Angstrom.

parse_output(filename, to_angstrom=False)

Method to read coordinates of atoms from PW output into the PWCoordinates instance.

Parameters
• filename (str) – the name of the output file.

• to_angstrom (bool) – True if automatically convert the units of cell and coordinates to Angstrom.

Returns

None

parse_input(filename, to_angstrom=False)

Method to read coordinates of atoms from PW input into the PWCoordinates instance.

Parameters
• filename (str) – the name of the output file.

• to_angstrom (bool) – True if automatically convert the units of cell and coordinates to Angstrom.

cell_from_system(sdict)

Function to obtain cell from namelist SYSTEM read from PW input.

Parameters

sdict (dict) – Dictinary generated from namelist SYSTEM of PW input.

Returns

Cell is 3x3 matrix with entries:

[[a_x b_x c_x]
[a_y b_y c_y]
[a_z b_z c_z]],


where a, b, c are crystallographic vectors, and x, y, z are their coordinates in the cartesian reference frame.

Return type

ndarray with shape (3,3)

celldms_from_abc(ibrav, abc_list)

Obtain celldms from ibrav value and a, b, c, cosab, cosac, cosbc parameters.

Using ibrav value and abc parameters from PW input generate celldm array, necessary to construct cell parameters. For details about abc and ibrav values see PW input documentation.

Parameters
• ibrav (int) – ibrav parameter of PW input.

• abc_list (list) – List, of 6 parameters: a, b, c, cosab, cosac, cosbc

Returns

list of 6 values, from which cell can be generated.

Return type

celldm (list)

Helper function to read GIPAW tensors from the list of lines.

Parameters
• lines (list of str) – List of strings contraining lines from the file. Output of open(file).readlines().

• keyword (str) – Keyword in the line which indicates the beginning of the tensor data block.

• start (int) – Index of the line which indicates the beginning of the tensor data block.

• conversion (float) – Conversion factor from GIPAW units to the ones, used in this package.

Returns

Array of tensors.

Return type

ndarray with shape (n, 3, 3)

Function to read hyperfine couplings from GIPAW output.

Parameters
• filename (str) – Name of the GIPAW hyperfine output.

• spin (float) – Spin of the central spin. Default 1.

Returns

Tuple containing:

• ndarray with shape (n,): Array of Fermi contact terms.

• ndarray with shape (n, 3,3): Array of spin dipolar hyperfine tensors.

Return type

tuple

Parameters

filename (str) – Name of the GIPAW EFG-containing output.

Returns

Array of EFG tensors.

Return type

ndarray with shape (n, 3,3)

Read Fortran-like namelists from the large string.

Parameters

input_string (str) – String representation of the QE input file.

Returns

Dictionary, containing dicts for each namelist found in the input string.

Return type

dict

get_ctype(lin)

Get coordinates type from the line of QE input/output.

Parameters

str – Line from QE input/output containing string with coordinates type.

Returns

type of the coordinates.

Return type

str

## ORCA

class ORCACoordinates(orca_output)

Coordinates of the system from the ORCA output. Subclass of the DFTCoordinates.

With initialization reads output of the ORCA.

Parameters

orca_output (str or list of str) – either name of the output file or list of lines read from that file.

alat

The lattice parameter in angstrom.

Type

float

cell

cell is 3x3 matrix with entries:

$\begin{split}[&[a_x\ b_x\ c_x]\\ &[a_y\ b_y\ c_y]\\ &[a_z\ b_z\ c_z]]\end{split}$

where a, b, c are crystallographic vectors, and x, y, z are their coordinates in the cartesian reference frame.

Type

ndarray with shape (3, 3)

coordinates

array with the coordinates of atoms in the cell.

Type

ndarray with shape (n, 3)

names

array with the names of atoms in the cell.

Type

ndarray with shape (n,)

cell_units

Units of cell coordinates: ‘bohr’, ‘angstrom’, ‘alat’.

Type

str

coordinates_units

Units of atom coordinates: ‘crystal’, ‘bohr’, ‘angstrom’, ‘alat’.

Type

str

Method to read coordinates of atoms from ORCA output into the ORCACoordinates instance.

Parameters

orca_output (str or list of str) – either name of the output file or list of lines read from that file.

## Base class

class DFTCoordinates

Abstract class of a container of the DFT output coordinates.

alat

The lattice parameter in angstrom.

Type

float

cell

cell is 3x3 matrix with entries:

$\begin{split}[&[a_x\ b_x\ c_x]\\ &[a_y\ b_y\ c_y]\\ &[a_z\ b_z\ c_z]]\end{split}$

where a, b, c are crystallographic vectors and x, y, z are their coordinates in the cartesian reference frame.

Type

ndarray with shape (3, 3)

coordinates

Array with the coordinates of atoms in the cell.

Type

ndarray with shape (n, 3)

names

Array with the names of atoms in the cell.

Type

ndarray with shape (n,)

cell_units

Units of cell coordinates: ‘bohr’, ‘angstrom’, ‘alat’.

Type

str

coordinates_units

Units of atom coordinates: ‘crystal’, ‘bohr’, ‘angstrom’, ‘alat’.

Type

str

to_angstrom(inplace=False)

Method to transform cell and coordinates units to angstroms.

Parameters

inplace (bool) – if True changes attributes inplace. Otherwise returns copy.

Returns

Instance of the subclass with units of coordinates and cell of Angstroms.

Return type

DFTCoordinates or subclass

get_angstrom(coordinate, units)

Change given coordinates to angstrom.

Parameters
• coordinates (ndarray with shape (n, 3) or (3,)) – Coordinates to change.

• units (str) – Initial units of the coordinates.

Returns

Coordinates in angstrom.

Return type

ndarray (n, 3)

change_to_angstrom(coordinates, units, alat=None, cell=None)

Change coordinates to angstrom.

Parameters
• coordinates (ndarray with shape (n, 3) or (3,)) – Coordinates to change.

• units (str) – Initial units of the coordinates.

• alat (float) – The lattice parameter in angstrom.

• cell (ndarray with shape (3,3)) –

cell is 3x3 matrix with entries:

$\begin{split}[&[a_x\ b_x\ c_x]\\ &[a_y\ b_y\ c_y]\\ &[a_z\ b_z\ c_z]]\end{split}$

where a, b, c are crystallographic vectors, and x, y, z are their coordinates in the cartesian reference frame.

Returns

Coordinates in angstrom.

Return type

ndarray with shape (n, 3)

fortran_value(value)

Get value from Fortran-type variable.

Parameters

value (str) – Value read from Fortran-type input.

Returns

value in Python format.

Return type

value (bool, str, float)

yield_index(word, lines, start=0, case_sensitive=False)

Generator which yields indexes of the lines containing specific word.

Parameters
• word (str) – Word to find in the line.

• lines (list of str) – List of strings contraining lines from the file. Output of open(file).readlines().

• start (int) – First index from which to start search.

• case_sensitive (bool) – If True looks for the exact match. Otherwise the search is case insensitive.

Yields

i (int) – Index of the line containing word.

find_first_index(word, lines, start=0, case_sensitive=False)

Function to find first appearance of the index in the list of lines.

Parameters
• word (str) – Word to find in the line.

• lines (list of str) – List of strings contraining lines from the file. Output of open(file).readlines().

• start (int) – First index from which to start search.

• case_sensitive (bool) – If True looks for the exact match. Otherwise the search is case insensitive.

Returns

Index of the first line from the start containing word.

Return type

i (int)

set_isotopes(array, isotopes=None, inplace=True, spin_types=None)

Function to set the most common isotopes for the array containing DFT output. If some other isotope is specified, the A tensors are scaled accordingly.

Parameters
• array (BathArray) – Array with DFT spins.

• isotopes (dict) – Dictionary with chosen isotopes.

• inplace (bool) – True if change the array inplace.

• spin_types (SpinDict) – If provided, allows for custom defined SpinType instances.

Returns

Array with DFT spins with correct isotopes.

Return type

array (BathArray)