schrodinger.application.matsci.espresso.utils module

Copyright Schrodinger, LLC. All rights reserved.

class schrodinger.application.matsci.espresso.utils.MagElement(mag, hubb_u, hubb_j0, zval)

Bases: tuple

hubb_j0

Alias for field number 2

hubb_u

Alias for field number 1

mag

Alias for field number 0

zval

Alias for field number 3

schrodinger.application.matsci.espresso.utils.get_null_mag_element()
class schrodinger.application.matsci.espresso.utils.PseudoData(element, ecutwfc, ecutrho, zval, nwfc, nbeta, pp_type, is_fully_rel, dft_functional, has_gipaw)

Bases: tuple

dft_functional

Alias for field number 8

ecutrho

Alias for field number 2

ecutwfc

Alias for field number 1

element

Alias for field number 0

has_gipaw

Alias for field number 9

is_fully_rel

Alias for field number 7

nbeta

Alias for field number 5

nwfc

Alias for field number 4

pp_type

Alias for field number 6

zval

Alias for field number 3

class schrodinger.application.matsci.espresso.utils.PPSpecies(ecutwfc, ecutrho, zval, basepath)

Bases: tuple

basepath

Alias for field number 3

ecutrho

Alias for field number 1

ecutwfc

Alias for field number 0

zval

Alias for field number 2

schrodinger.application.matsci.espresso.utils.get_shell_runner()

Get path to the shell runner script.

Return type

bool, str

Returns

Whether runner has been found. If true, path to the runner otherwise error message

class schrodinger.application.matsci.espresso.utils.ArgumentParserNoExit(prog=None, usage=None, description=None, epilog=None, parents=[], formatter_class=<class 'argparse.HelpFormatter'>, prefix_chars='-', fromfile_prefix_chars=None, argument_default=None, conflict_handler='error', add_help=True, allow_abbrev=True, exit_on_error=True)

Bases: argparse.ArgumentParser

Subclass that raises instead of exiting on error.

error(message)

From python docs: If you override this in a subclass, it should not return – it should either exit or raise an exception.

schrodinger.application.matsci.espresso.utils.add_qe_parallel_parser_arguments(parser)

Add QE parallel arguments to the parser.

Parameters

parser (argparse.ArgumentParser) – The parser to add arguments to

schrodinger.application.matsci.espresso.utils.get_pkeywords(options, ncpus)

Validate and get string of parallel keywords for QE binaries (pw.x, etc.).

Parameters
  • options (argparse Namespace object) – The input options

  • ncpus (int) – Number of total requested CPUs

Return type

bool, str or list

Returns

If converted successfully, True and a list of [keyword, value] are returned, otherwise, False and error message are returned

schrodinger.application.matsci.espresso.utils.get_mag_hubbu(atom, decimals=10)

Get starting magnetization and Hubbard U parameters from atom property. If not present, return the default.

Parameters
  • atom (schrodinger.structure._StructureAtom) – Atom from which values are taken

  • decimals (int) – Number of decimals to round to

Return type

MagElement namedtuple

Returns

Tuple of starting magnetization and Hubbard parameters

schrodinger.application.matsci.espresso.utils.has_hubbard(struct)

Check if input structure has at least one atom with Hubbard U set.

Parameters

struct (structure.Structure) – Input structure

Return bool

Whether at least one atom has Hubbard U set

schrodinger.application.matsci.espresso.utils.set_mag_hubbu(atom, mag_element)

Set starting magnetization and Hubbard U parameters in atom property.

Parameters
  • atom (schrodinger.structure._StructureAtom) – Atom for which values are set

  • mag_element (MagElement namedtuple) – Tuple of starting magnetization and Hubbard parameters

schrodinger.application.matsci.espresso.utils.sync_pbc(struct, lattice_params=None, chorus_params=None, prioritize_cparams=False)

Sync PBC properties in place (without creating a new structure) for struct. If all PBC properties are absent (both chorus and PDB) return False. It is possible to provide new lattice or chorus parameters and to prioritize one of the sets.

Type

schrodinger.structure.Structure

Param

Structure to be modified

Parameters
  • lattice_params (list or numpy.array or None) – contains the a, b, c, alpha, beta, and gamma lattice parameters or None. These will be used instead of ones possibly obtained from the struct

  • chorus_params (list or numpy.array or None) – contains the nine chorus properties, i.e. ax, ay, az, bx, …, cz or None. These will be used instead of ones possibly obtained from the struct

Param

Prioritize chorus params over lattice params if True. If False, lattice params have priority

Return type

bool

Returns

True on syncing success, False if both sets were not provided or empty

schrodinger.application.matsci.espresso.utils.get_mpircores(from_environ_only=False)

Get -MPICORES flag value from SCHRODINGER_COMMANDLINE environment variable. If not found, return 1.

Return type

int

Returns

MPICORES value or 1 (if not defined)

schrodinger.application.matsci.espresso.utils.get_gpu_qarg()

Get QE GPU QARG from the environment.

Return type

str

Returns

QE GPU QARG. Empty string if not set

schrodinger.application.matsci.espresso.utils.get_element(element)

Get element name with the removed digits from atom type. Those might be present to due starting magnetization.

Parameters

element (str) – Element

Return type

str

Returns

Element without digits

schrodinger.application.matsci.espresso.utils.copy_atom_constr(src_atom, dest_atom)

Copy Cartesian atomic constraints (if any) from source atom to destination atom.

Parameters
  • src_atom (structure._StructureAtom) – Source atom

  • dest_atom (structure._StructureAtom) – Destination atom

schrodinger.application.matsci.espresso.utils.set_atom_cart_constr(atom, constr)
schrodinger.application.matsci.espresso.utils.set_job_builder_opts(job_builder, cfg_fn=None, add_pps=False)

Set options to job builder.

Parameters
schrodinger.application.matsci.espresso.utils.struct2spglib(struct)

Given a structure, return a spglib cell.

Parameters

struct (structure.Structure) – Input structure

Return type

numpy.array, numpy.array, list

Returns

Lattice vectors, fractional coordinates, atomic numbers

class schrodinger.application.matsci.espresso.utils.PPHeaderHTMLParser(*args, **kwargs)

Bases: html.parser.HTMLParser

Parse and store pp_header tag attributes.

PP_HEADER_TAG = 'pp_header'
__init__(*args, **kwargs)

Initialize object. See parent class for documentation.

handle_starttag(tag, attrs)

Save PP_HEADER attributes in dictionary.

class schrodinger.application.matsci.espresso.utils.UPFParser(path, file_fh=None, binary=False)

Bases: object

Class that handles UPF parsing.

PP_TYPE_NC = 'NC'
PP_TYPE_PAW = 'PAW'
PP_TYPES = ('1/r', 'US', 'NC', 'PAW')
FULLY_REL = 'full'
UPF2_TRUE = ['T']
__init__(path, file_fh=None, binary=False)

Initialize UPFParser.

Parameters

path (str) – Path to the UPF file

getPseudo()

Return a copy of the pseudo data.

class schrodinger.application.matsci.espresso.utils.HighSymmetryKPath(spg_symbol, pbc, is_2d=False)

Bases: object

Based on symmetry/bandstructure.py :: HighSymmKpath (MIT license)

This class looks for path along high symmetry lines in the Brillouin Zone. It is based on Setyawan, W., & Curtarolo, S. (2010). High-throughput electronic band structure calculations: Challenges and tools. Computational Materials Science, 49(2), 299-312. doi:10.1016/j.commatsci.2010.05.010

TWOD = '_2D'
__init__(spg_symbol, pbc, is_2d=False)

Initialize kpath class. self.kpath will contain ‘edge’ points.

Parameters
  • spg_symbol (str) – Space group symbol

  • pbc (infrastructure.PBC) – PBC object

  • struct (structure.Structure) – Structure that has space group or unit cell data

  • is_2d (bool) – Whether to build K-point path for 2D/ESM calcs

cubic()

Generate ‘edge’ k-points for the cubic lattice.

Return type

dict

Returns

keys: ‘kpoints’ is a dict with labels as keys and coordinates as values, ‘path’ is a list of labels from the ‘kpoints’ dict.

fcc()

Generate ‘edge’ k-points for the FCC cubic lattice.

Return type

dict

Returns

keys: ‘kpoints’ is a dict with labels as keys and coordinates as values, ‘path’ is a list of labels from the ‘kpoints’ dict.

bcc()

Generate ‘edge’ k-points for the BCC cubic lattice.

Return type

dict

Returns

keys: ‘kpoints’ is a dict with labels as keys and coordinates as values, ‘path’ is a list of labels from the ‘kpoints’ dict.

tet()

Generate ‘edge’ k-points for the tetrahedral lattice.

Return type

dict

Returns

keys: ‘kpoints’ is a dict with labels as keys and coordinates as values, ‘path’ is a list of labels from the ‘kpoints’ dict.

bctet1(c, a)

Generate ‘edge’ k-points for the tetrahedral lattice with I setting.

Parameters
  • c (float) – C length

  • a (float) – A length

Return type

dict

Returns

keys: ‘kpoints’ is a dict with labels as keys and coordinates as values, ‘path’ is a list of labels from the ‘kpoints’ dict.

bctet2(c, a)

Generate ‘edge’ k-points for the tetrahedral lattice with I setting.

Parameters
  • c (float) – C length

  • a (float) – A length

Return type

dict

Returns

keys: ‘kpoints’ is a dict with labels as keys and coordinates as values, ‘path’ is a list of labels from the ‘kpoints’ dict.

orc()

Generate ‘edge’ k-points for the orthorhombic lattice.

Return type

dict

Returns

keys: ‘kpoints’ is a dict with labels as keys and coordinates as values, ‘path’ is a list of labels from the ‘kpoints’ dict.

orcf1(a, b, c)

Generate ‘edge’ k-points for the orthorhombic lattice with F setting.

Parameters
  • a (float) – A length

  • b (float) – B length

  • c (float) – C length

Return type

dict

Returns

keys: ‘kpoints’ is a dict with labels as keys and coordinates as values, ‘path’ is a list of labels from the ‘kpoints’ dict.

orcf2(a, b, c)

Generate ‘edge’ k-points for the orthorhombic lattice with F setting.

Parameters
  • a (float) – A length

  • b (float) – B length

  • c (float) – C length

Return type

dict

Returns

keys: ‘kpoints’ is a dict with labels as keys and coordinates as values, ‘path’ is a list of labels from the ‘kpoints’ dict.

orcf3(a, b, c)

Generate ‘edge’ k-points for the orthorhombic lattice with F setting.

Parameters
  • a (float) – A length

  • b (float) – B length

  • c (float) – C length

Return type

dict

Returns

keys: ‘kpoints’ is a dict with labels as keys and coordinates as values, ‘path’ is a list of labels from the ‘kpoints’ dict.

orci(a, b, c)

Generate ‘edge’ k-points for the orthorhombic lattice with I setting.

Parameters
  • a (float) – A length

  • b (float) – B length

  • c (float) – C length

Return type

dict

Returns

keys: ‘kpoints’ is a dict with labels as keys and coordinates as values, ‘path’ is a list of labels from the ‘kpoints’ dict.

orcc(a, b, c)

Generate ‘edge’ k-points for the orthorhombic lattice with C setting.

Parameters
  • a (float) – A length

  • b (float) – B length

  • c (float) – C length

Return type

dict

Returns

keys: ‘kpoints’ is a dict with labels as keys and coordinates as values, ‘path’ is a list of labels from the ‘kpoints’ dict.

hex(is_2d=False)

Generate ‘edge’ k-points for the hexagonal lattice.

Parameters

is_2d (bool) – Whether to return 2D path

Return type

dict

Returns

keys: ‘kpoints’ is a dict with labels as keys and coordinates as values, ‘path’ - a list of labels from the ‘kpoints’.

rhl1(alpha)

Generate ‘edge’ k-points for the rhombohedral lattice with alpha < 90.

Parameters

alpha (float) – Alpha cell angle in radians

Return type

dict

Returns

keys: ‘kpoints’ is a dict with labels as keys and coordinates as values, ‘path’ is a list of labels from the ‘kpoints’ dict.

rhl2(alpha)

Generate ‘edge’ k-points for the rhombohedral lattice with alpha > 90.

Parameters

alpha (float) – Alpha cell angle in radians

Return type

dict

Returns

keys: ‘kpoints’ is a dict with labels as keys and coordinates as values, ‘path’ is a list of labels from the ‘kpoints’ dict.

mcl(b, c, beta)

Generate ‘edge’ k-points for the monoclinic lattice.

Parameters
  • b (float) – B length

  • c (float) – C length

  • beta (float) – Beta cell angle in radians

Return type

dict

Returns

keys: ‘kpoints’ is a dict with labels as keys and coordinates as values, ‘path’ is a list of labels from the ‘kpoints’ dict.

mclc1(a, b, c, alpha)

Generate ‘edge’ k-points for the monoclinic lattice with C setting.

Parameters
  • a (float) – A length

  • b (float) – B length

  • c (float) – C length

  • alpha (float) – Alpha cell angle in radians

Return type

dict

Returns

keys: ‘kpoints’ is a dict with labels as keys and coordinates as values, ‘path’ is a list of labels from the ‘kpoints’ dict.

tria(is_2d)
class schrodinger.application.matsci.espresso.utils.MemoryEstimator(vecs, ecutwfc, ecutrho, nproc, nks, nspin, nbnd, ntyp, nmix, lscf)

Bases: object

Class to estimate RAM memory for a PW (QE) job.

COMPLEX_SIZE = 16.0
REAL_SIZE = 8.0
INT_SIZE = 4.0
MBYTE = 1048576.0
NFFTX = 2049
__init__(vecs, ecutwfc, ecutrho, nproc, nks, nspin, nbnd, ntyp, nmix, lscf)

Initialize MemoryEstimator object and set several attributes.

Parameters
  • vecs (3 list of 3 floats) – Lattice vectors

  • ecutwfc (float) – Wavefunction cutoff (Ry)

  • ecutrho (float) – Density cutoff (Ry)

  • nproc (int) – Number of processors

  • nks (int) – Number of k-points

  • nspin (int) – 1 for closed-shell, 2 for spin-polarized

  • nbnd (int) – Number of bands

  • ntyp (int) – Number of atom types

  • nmix (int) – Beta mixing

  • lscf (bool) – True if the calculation is scf/relax, False if it is nscf

realSpaceGridInit(at_vecs, bg_vecs, gcutm)

Gets minimal 3D real-space FFT grid.

Parameters
  • at_vecs (3 x 3 table of floats) – Lattice vectors in the units of alat

  • bg_vecs (3 x 3 table of floats) – Reciprocal lattice vectors in the units of 1/alat

  • gctum – Radius of the sphere to fit the FFT grid

Return type

list of 3 floats

Returns

FFT grid sizes

getGoodFFTDim(fft_dim)

Get a good FFT dimension.

Parameters

fft_dim (int) – FFT dimension

Return type

int

Returns

Good FFT dimension, if exists

isGoodDim(fft_dim)

Check if FFT dimension is good.

Parameters

fft_dim (int) – FFT dimension

:rtype bool :return: True, if FFT dimension is good, False otherwise

class schrodinger.application.matsci.espresso.utils.MagSpecies(struct=None)

Bases: object

Class that defines species with starting magnetization.

__init__(struct=None)

Initialize MagSpecies class.

createUniqueElement(element, mag_element)

Fill self.data dict. Keys of the self.data are elements. Values are dicts with magnetization as key and unique element as value. Unique element is just the atomic symbol plus (if element has more than one magnetization value) a unique integer. Example: {‘C’: {0.0: ‘C’}, ‘H’: {0.0: ‘H’, 0.1: ‘H1’}}

self.species is a dict where unique elements are keys and elements are values. Example (based on the example above): {‘C’: ‘C’, ‘H’: ‘H’, ‘H1’: ‘H’}

Parameters
  • element (str) – Element

  • mag (float) – Starting magnetization

  • hubb_u (float) – Hubbard U parameter

Return type

str

Returns

Unique element

getMag(element, unique_element)

Get magnetization given element and unique element values.

Parameters
  • element (str) – Element

  • unique_element (str) – Unique element

Return type

tuple

Returns

Starting magnetization and Hubbard U

Raises

ValueError – If element, unique_element combination is not found

fromStructure(struct)

Set data from the structure.

Parameters

struct (structure.Structure) – Input structure