Miscellaneous

Constants, status bars, parsing, etc.

elphmod.misc.Ha = 27.211386245988

Hartree energy (eV).

elphmod.misc.NA = 6.02214076e+23

Avogadro constant (1/mol).

elphmod.misc.Ry = 13.605693122994

Rydberg energy (eV) [2018 CODATA].

class elphmod.misc.StatusBar(count, width=60, title='progress')[source]

Progress bar that does without carriage return or backspace.

Parameters:
countint

Number of times the progress bar will be updated.

widthint, default 60

Number of text columns the progress bar will span.

titlestr, default ‘progress’

Title line of the progress bar. Should be shorter than width.

Attributes:
in_progressStatusBar

Instance of the active progress bar or False for the first process; always True for the other processes. Used to ensure that only one progress bar is output at a time.

update()[source]

Update progress bar.

elphmod.misc.a0 = 0.529177210903

Bohr radius (AA) [2018 CODATA].

elphmod.misc.cSI = 299792458.0

Speed of light (m/s).

elphmod.misc.cmm1 = 0.00012398419843320026

“Inverse cm” (eV).

elphmod.misc.colors = {'Ac': (112, 171, 250), 'Ag': (192, 192, 192), 'Al': (191, 166, 166), 'Am': (84, 92, 242), 'Ar': (128, 209, 227), 'As': (189, 128, 227), 'At': (117, 79, 69), 'Au': (255, 209, 35), 'B': (255, 181, 181), 'Ba': (0, 201, 0), 'Be': (194, 255, 0), 'Bh': (224, 0, 56), 'Bi': (158, 79, 181), 'Bk': (138, 79, 227), 'Br': (166, 41, 41), 'C': (144, 144, 144), 'Ca': (61, 255, 0), 'Cd': (255, 217, 143), 'Ce': (255, 255, 199), 'Cf': (161, 54, 212), 'Cl': (31, 240, 31), 'Cm': (120, 92, 227), 'Co': (240, 144, 160), 'Cr': (138, 153, 199), 'Cs': (87, 23, 143), 'Cu': (200, 128, 51), 'Db': (209, 0, 79), 'Dy': (31, 255, 199), 'Er': (0, 230, 117), 'Es': (179, 31, 212), 'Eu': (97, 255, 199), 'F': (144, 224, 80), 'Fe': (224, 102, 51), 'Fm': (179, 31, 186), 'Fr': (66, 0, 102), 'Ga': (194, 143, 143), 'Gd': (69, 255, 199), 'Ge': (102, 143, 143), 'H': (255, 255, 255), 'He': (217, 255, 255), 'Hf': (77, 194, 255), 'Hg': (184, 184, 208), 'Ho': (0, 255, 156), 'Hs': (230, 0, 46), 'I': (148, 0, 148), 'In': (166, 117, 115), 'Ir': (23, 84, 135), 'K': (143, 64, 212), 'Kr': (92, 184, 209), 'La': (112, 212, 255), 'Li': (204, 128, 255), 'Lr': (199, 0, 102), 'Lu': (0, 171, 36), 'Md': (179, 13, 166), 'Mg': (138, 255, 0), 'Mn': (156, 122, 199), 'Mo': (84, 181, 181), 'Mt': (235, 0, 38), 'N': (48, 80, 248), 'Na': (171, 92, 242), 'Nb': (115, 194, 201), 'Nd': (199, 255, 199), 'Ne': (179, 227, 245), 'Ni': (80, 208, 80), 'No': (189, 13, 135), 'Np': (0, 128, 255), 'O': (255, 13, 13), 'Os': (38, 102, 150), 'P': (255, 128, 0), 'Pa': (0, 161, 255), 'Pb': (87, 89, 97), 'Pd': (0, 105, 133), 'Pm': (163, 255, 199), 'Po': (171, 92, 0), 'Pr': (217, 255, 199), 'Pt': (208, 208, 224), 'Pu': (0, 107, 255), 'Ra': (0, 125, 0), 'Rb': (112, 46, 176), 'Re': (38, 125, 171), 'Rf': (204, 0, 89), 'Rh': (10, 125, 140), 'Rn': (66, 130, 150), 'Ru': (36, 143, 143), 'S': (255, 255, 48), 'Sb': (158, 99, 181), 'Sc': (230, 230, 230), 'Se': (255, 161, 0), 'Sg': (217, 0, 69), 'Si': (240, 200, 160), 'Sm': (143, 255, 199), 'Sn': (102, 128, 128), 'Sr': (0, 255, 0), 'Ta': (77, 166, 255), 'Tb': (48, 255, 199), 'Tc': (59, 158, 158), 'Te': (212, 122, 0), 'Th': (0, 186, 255), 'Ti': (191, 194, 199), 'Tl': (166, 84, 77), 'Tm': (0, 212, 82), 'U': (0, 143, 255), 'V': (166, 166, 171), 'W': (33, 148, 214), 'Xe': (66, 158, 176), 'Y': (148, 255, 255), 'Yb': (0, 191, 56), 'Zn': (125, 128, 176), 'Zr': (148, 224, 224)}

Jmol’s element color scheme from http://jmol.sourceforge.net/jscolors/.

elphmod.misc.eVSI = 1.602176634e-19

Electronvolt (J).

elphmod.misc.eps0 = 8.8541878128e-12

Vacuum permittivity (F/m) [2018 CODATA].

elphmod.misc.get_sparse_array()[source]

Try to import sparse array or matrix.

elphmod.misc.group(points, eps=1e-07)[source]

Group points into neighborhoods.

Parameters:
pointsndarray

Points to be grouped.

epsfloat

Maximal distance between points in the same group.

Returns:
list of lists

Groups of indices.

elphmod.misc.hSI = 6.62607015e-34

Planck constant (J s).

elphmod.misc.hbarSI = 1.0545718176461565e-34

reduced Planck constant (J s).

elphmod.misc.kB = 8.617333262145179e-05

Boltzmann constant (eV/K).

elphmod.misc.kBSI = 1.380649e-23

Boltzmann constant (J/K).

elphmod.misc.meSI = 9.1093837015e-31

Electron mass (kg) [2018 CODATA].

elphmod.misc.minimum(*args)[source]

Find extremum of parabola through given points.

Parameters:
*args

Coordinates of three points. Can also be provided as command arguments.

Returns:
float

x coordinates of extremum.

elphmod.misc.ohmRy = 0.00012170674028939735

Resistance unit ohm (Rydberg atomic units).

elphmod.misc.ohmmRy = 2299924.066679179

Resistivity unit ohm metre (Rydberg atomic units).

elphmod.misc.read_cube(cube, only_header=False, comm=<elphmod.MPI.Communicator object>)[source]

Read Gaussian cube file.

Parameters:
cubestr

Name of Gaussian cube file.

only_headerbool, default False

Skip reading data?

Returns:
r0ndarray

Origin of the data grid.

andarray

Spanning vectors of the data grid.

Xlist of str

Atomic numbers.

taundarray

Cartesian atomic coordinates.

datandarray

Data-grid values or, if only_header, shape of data grid.

See also

read_xsf

Equivalent function for XCrySDen format.

elphmod.misc.read_dat_mat(filename)[source]

Read matrix elements from RESPACK (dat.Wmat, dat.h_mat_r).

Parameters:
filenamestr

Name of the file.

Returns:
ndarray

Lattice vectors.

ndarray

Direct (screened) Coulomb or hoppling matrix elements, depending on the input file.

elphmod.misc.read_input_data(filename, broadcast=True)[source]

Read Quantum ESPRESSO input data.

Parameters:
filenamestr

Name of input file.

broadcastbool

Broadcast result from rank 0 to all processes?

Returns:
dict

Input data.

elphmod.misc.read_namelists(filename)[source]

Extract all Fortran namelists from file.

Parameters:
filenamestr

Name of file with namelists.

Returns:
dict of dict

Namelist data.

elphmod.misc.read_xsf(xsf, only_header=False, comm=<elphmod.MPI.Communicator object>)[source]

Read file in XCrySDen format.

Parameters:
xsfstr

Name of XCrySDen file.

only_headerbool, default False

Skip reading data?

Returns:
r0ndarray

Origin of the data grid.

andarray

Spanning vectors of the data grid.

Xlist of str

Atomic numbers or symbols.

taundarray

Cartesian atomic coordinates.

datandarray

Data-grid values or, if only_header, shape of data grid.

See also

read_cube

Equivalent function for Gaussian cube format.

write_xsf

Write file in XCrySDen format.

elphmod.misc.real_space_grid(shape, r0, a, shared_memory=False)[source]

Sample real-space grid.

Parameters:
shapetuple of int

Shape of the 3D real-space grid.

r0ndarray

Origin of the real-space grid.

andarray

Cartesian spanning vectors of the real-space grid.

shared_memorybool, default False

Store real-space grid in shared memory?

Returns:
ndarray

Cartesian coordinates for all grid points.

elphmod.misc.split(expr, sd=',', od='{', cd='}')[source]

Split expression with separators and brackets using distributive law.

Parameters:
exprstr

Expression to be expanded and split.

sdstr

Separating delimiter.

odstr

Opening delimiter.

cdstr

Closing delimiter.

Returns:
generator

Separated elements of expression.

elphmod.misc.uRy = 911.4442434236321

Atomic mass constant (2 me).

elphmod.misc.uSI = 1.6605390671738466e-27

Atomic mass constant (kg).

elphmod.misc.vector_index(vectors, vector)[source]

Find index of vector in list of vectors.

Parameters:
vectorsndarray

List of vectors.

vectorndarray

Vector.

Returns:
int

Index of vector in list of vectors.

elphmod.misc.verbosity = 3

Level of verbosity.

  • 0: Suppress all output.

  • 1: Only print warnings.

  • 2: Print info messages.

  • 3: Display status bars.

elphmod.misc.write_xsf(xsf, r0, a, X, tau, data, only_header=False, comm=<elphmod.MPI.Communicator object>)[source]

Write file in XCrySDen format.

Parameters:
xsfstr

Name of XCrySDen file.

r0ndarray

Origin of the data grid.

andarray

Spanning vectors of the data grid.

Xlist of str

Atomic numbers or symbols.

taundarray

Cartesian atomic coordinates.

datandarray

Data-grid values or, if only_header, shape of data grid.

only_headerbool, default False

Skip writing data?

See also

read_xsf

Read file in XCrySDen format.