schrodinger.application.matsci.espresso.utils module

Copyright Schrodinger, LLC. All rights reserved.

schrodinger.application.matsci.espresso.utils.get_shell_runner(check_only=False, write_orig=False)

Get path to the shell runner script.

Parameters:
  • check_only (bool) – If True, only check if runner exists and return
  • write_orig (bool) – If True, create original shell runner even if runner exists
Return type:

(str, bool)

Returns:

Path to shell runner and True if shell runner has been just created, otherwise False

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)

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
Return type:tuple(float, float)
Returns:Tuple of starting magnetization and HUbbard U parameter
schrodinger.application.matsci.espresso.utils.set_mag_hubbu(atom, mag, hubbu)

Set starting magnetization and Hubbard U parameters in atom property.

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()

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_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
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.

CDATA_CONTENT_ELEMENTS = ('script', 'style')
__class__

alias of builtins.type

__delattr__

Implement delattr(self, name).

__dict__ = mappingproxy({'__module__': 'schrodinger.application.matsci.espresso.utils', '__doc__': '\n Parse and store pp_header tag attributes.\n ', 'PP_HEADER_TAG': 'pp_header', '__init__': <function PPHeaderHTMLParser.__init__>, 'handle_starttag': <function PPHeaderHTMLParser.handle_starttag>})
__dir__() → list

default dir() implementation

__eq__

Return self==value.

__format__()

default object formatter

__ge__

Return self>=value.

__getattribute__

Return getattr(self, name).

__gt__

Return self>value.

__hash__

Return hash(self).

__init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

__le__

Return self<=value.

__lt__

Return self<value.

__module__ = 'schrodinger.application.matsci.espresso.utils'
__ne__

Return self!=value.

__new__()

Create and return a new object. See help(type) for accurate signature.

__reduce__()

helper for pickle

__reduce_ex__()

helper for pickle

__repr__

Return repr(self).

__setattr__

Implement setattr(self, name, value).

__sizeof__() → int

size of object in memory, in bytes

__str__

Return str(self).

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

__weakref__

list of weak references to the object (if defined)

check_for_whole_start_tag(i)
clear_cdata_mode()
close()

Handle any buffered data.

error(message)
feed(data)

Feed data to the parser.

Call this as often as you want, with as little or as much text as you want (may include ‘n’).

get_starttag_text()

Return full source of start tag: ‘<…>’.

getpos()

Return current line number and offset.

goahead(end)
handle_charref(name)
handle_comment(data)
handle_data(data)
handle_decl(decl)
handle_endtag(tag)
handle_entityref(name)
handle_pi(data)
handle_startendtag(tag, attrs)
parse_bogus_comment(i, report=1)
parse_comment(i, report=1)
parse_declaration(i)
parse_endtag(i)
parse_html_declaration(i)
parse_marked_section(i, report=1)
parse_pi(i)
parse_starttag(i)
reset()

Reset this instance. Loses all unprocessed data.

set_cdata_mode(elem)
unescape(s)
unknown_decl(data)
updatepos(i, j)
class schrodinger.application.matsci.espresso.utils.UPFParser(path)

Bases: object

Class that handles UPF parsing.

PP_TYPE_PAW = 'PAW'
PP_TYPES = ('1/r', 'US', 'NC', 'PAW')
FULLY_REL = 'full'
__init__(path)

Initialize UPFParser.

Parameters:path (str) – Path to the UPF file
__class__

alias of builtins.type

__delattr__

Implement delattr(self, name).

__dict__ = mappingproxy({'__module__': 'schrodinger.application.matsci.espresso.utils', '__doc__': '\n Class that handles UPF parsing.\n ', 'PP_TYPE_PAW': 'PAW', 'PP_TYPES': ('1/r', 'US', 'NC', 'PAW'), 'FULLY_REL': 'full', '__init__': <function UPFParser.__init__>, '_parseUPF2Prop': <function UPFParser._parseUPF2Prop>, '_parseUPF2': <function UPFParser._parseUPF2>, '_parseUPFProp': <function UPFParser._parseUPFProp>, '_parseUPFAddInfo': <function UPFParser._parseUPFAddInfo>, '_parseUPF': <function UPFParser._parseUPF>, '_checkElement': <function UPFParser._checkElement>, '_checkType': <function UPFParser._checkType>, '_checkRelativistic': <function UPFParser._checkRelativistic>, '_getFunctional': <function UPFParser._getFunctional>, '__dict__': <attribute '__dict__' of 'UPFParser' objects>, '__weakref__': <attribute '__weakref__' of 'UPFParser' objects>})
__dir__() → list

default dir() implementation

__eq__

Return self==value.

__format__()

default object formatter

__ge__

Return self>=value.

__getattribute__

Return getattr(self, name).

__gt__

Return self>value.

__hash__

Return hash(self).

__init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

__le__

Return self<=value.

__lt__

Return self<value.

__module__ = 'schrodinger.application.matsci.espresso.utils'
__ne__

Return self!=value.

__new__()

Create and return a new object. See help(type) for accurate signature.

__reduce__()

helper for pickle

__reduce_ex__()

helper for pickle

__repr__

Return repr(self).

__setattr__

Implement setattr(self, name, value).

__sizeof__() → int

size of object in memory, in bytes

__str__

Return str(self).

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

__weakref__

list of weak references to the object (if defined)

class schrodinger.application.matsci.espresso.utils.HighSymmetryKPath(struct)

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

__init__(struct)

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

Parameters:struct (structure.Structure) – Structure that has space group / unit cell data
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()

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

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()
__class__

alias of builtins.type

__delattr__

Implement delattr(self, name).

__dict__ = mappingproxy({'__module__': 'schrodinger.application.matsci.espresso.utils', '__doc__': '\n Based on symmetry/bandstructure.py :: HighSymmKpath (MIT license)\n\n This class looks for path along high symmetry lines in\n the Brillouin Zone.\n It is based on Setyawan, W., & Curtarolo, S. (2010).\n High-throughput electronic band structure calculations:\n Challenges and tools. Computational Materials Science,\n 49(2), 299-312. doi:10.1016/j.commatsci.2010.05.010\n ', '__init__': <function HighSymmetryKPath.__init__>, 'cubic': <function HighSymmetryKPath.cubic>, 'fcc': <function HighSymmetryKPath.fcc>, 'bcc': <function HighSymmetryKPath.bcc>, 'tet': <function HighSymmetryKPath.tet>, 'bctet1': <function HighSymmetryKPath.bctet1>, 'bctet2': <function HighSymmetryKPath.bctet2>, 'orc': <function HighSymmetryKPath.orc>, 'orcf1': <function HighSymmetryKPath.orcf1>, 'orcf2': <function HighSymmetryKPath.orcf2>, 'orcf3': <function HighSymmetryKPath.orcf3>, 'orci': <function HighSymmetryKPath.orci>, 'orcc': <function HighSymmetryKPath.orcc>, 'hex': <function HighSymmetryKPath.hex>, 'rhl1': <function HighSymmetryKPath.rhl1>, 'rhl2': <function HighSymmetryKPath.rhl2>, 'mcl': <function HighSymmetryKPath.mcl>, 'mclc1': <function HighSymmetryKPath.mclc1>, 'tria': <function HighSymmetryKPath.tria>, '__dict__': <attribute '__dict__' of 'HighSymmetryKPath' objects>, '__weakref__': <attribute '__weakref__' of 'HighSymmetryKPath' objects>})
__dir__() → list

default dir() implementation

__eq__

Return self==value.

__format__()

default object formatter

__ge__

Return self>=value.

__getattribute__

Return getattr(self, name).

__gt__

Return self>value.

__hash__

Return hash(self).

__init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

__le__

Return self<=value.

__lt__

Return self<value.

__module__ = 'schrodinger.application.matsci.espresso.utils'
__ne__

Return self!=value.

__new__()

Create and return a new object. See help(type) for accurate signature.

__reduce__()

helper for pickle

__reduce_ex__()

helper for pickle

__repr__

Return repr(self).

__setattr__

Implement setattr(self, name, value).

__sizeof__() → int

size of object in memory, in bytes

__str__

Return str(self).

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

__weakref__

list of weak references to the object (if defined)

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

__class__

alias of builtins.type

__delattr__

Implement delattr(self, name).

__dict__ = mappingproxy({'__module__': 'schrodinger.application.matsci.espresso.utils', '__doc__': '\n Class to estimate RAM memory for a PW (QE) job.\n ', 'COMPLEX_SIZE': 16.0, 'REAL_SIZE': 8.0, 'INT_SIZE': 4.0, 'MBYTE': 1048576.0, 'NFFTX': 2049, '__init__': <function MemoryEstimator.__init__>, 'realSpaceGridInit': <function MemoryEstimator.realSpaceGridInit>, 'getGoodFFTDim': <function MemoryEstimator.getGoodFFTDim>, 'isGoodDim': <function MemoryEstimator.isGoodDim>, '__dict__': <attribute '__dict__' of 'MemoryEstimator' objects>, '__weakref__': <attribute '__weakref__' of 'MemoryEstimator' objects>})
__dir__() → list

default dir() implementation

__eq__

Return self==value.

__format__()

default object formatter

__ge__

Return self>=value.

__getattribute__

Return getattr(self, name).

__gt__

Return self>value.

__hash__

Return hash(self).

__init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

__le__

Return self<=value.

__lt__

Return self<value.

__module__ = 'schrodinger.application.matsci.espresso.utils'
__ne__

Return self!=value.

__new__()

Create and return a new object. See help(type) for accurate signature.

__reduce__()

helper for pickle

__reduce_ex__()

helper for pickle

__repr__

Return repr(self).

__setattr__

Implement setattr(self, name, value).

__sizeof__() → int

size of object in memory, in bytes

__str__

Return str(self).

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

__weakref__

list of weak references to the object (if defined)

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