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

__contains__(key, /)

Return key in self.

__len__()

Return len(self).

count(value, /)

Return number of occurrences of value.

hubb_j0

Alias for field number 2

hubb_u

Alias for field number 1

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

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

__contains__(key, /)

Return key in self.

__len__()

Return len(self).

count(value, /)

Return number of occurrences of value.

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

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

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

schrodinger.application.matsci.espresso.utils.get_shell_runner(check_only=False, write_orig=False, log=None)[source]

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

  • log (function or None) – A function to log info about shell runner existence. Should take a single str argument.

Return type

(str, bool)

Returns

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

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)[source]

Bases: argparse.ArgumentParser

Subclass that raises instead of exiting on error.

error(message)[source]

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

__init__(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)
add_argument(dest, ..., name=value, ...)
add_argument(option_string, option_string, ..., name=value, ...) None
add_argument_group(*args, **kwargs)
add_mutually_exclusive_group(**kwargs)
add_subparsers(**kwargs)
convert_arg_line_to_args(arg_line)
exit(status=0, message=None)
format_help()
format_usage()
get_default(dest)
parse_args(args=None, namespace=None)
parse_intermixed_args(args=None, namespace=None)
parse_known_args(args=None, namespace=None)
parse_known_intermixed_args(args=None, namespace=None)
print_help(file=None)
print_usage(file=None)
register(registry_name, value, object)
set_defaults(**kwargs)
schrodinger.application.matsci.espresso.utils.add_qe_parallel_parser_arguments(parser)[source]

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, npools=None)[source]

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

  • npools (int) – npools value, None for default passed in options

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)[source]

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

Parameters
Return type

MagElement namedtuple

Returns

Tuple of starting magnetization and Hubbard parameters

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

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)[source]

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()[source]

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)[source]

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.set_job_builder_opts(job_builder, cfg_fn=None, add_pps=False)[source]

Set options to job builder.

Parameters
class schrodinger.application.matsci.espresso.utils.PPHeaderHTMLParser(*args, **kwargs)[source]

Bases: html.parser.HTMLParser

Parse and store pp_header tag attributes.

PP_HEADER_TAG = 'pp_header'
__init__(*args, **kwargs)[source]

Initialize object. See parent class for documentation.

handle_starttag(tag, attrs)[source]

Save PP_HEADER attributes in dictionary.

CDATA_CONTENT_ELEMENTS = ('script', 'style')
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, file_fh=None, binary=False)[source]

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)[source]

Initialize UPFParser.

Parameters

path (str) – Path to the UPF file

getPseudo()[source]

Return a copy of the pseudo data.

class schrodinger.application.matsci.espresso.utils.HighSymmetryKPath(struct)[source]

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)[source]

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

Parameters

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

cubic()[source]

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()[source]

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()[source]

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()[source]

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)[source]

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)[source]

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()[source]

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)[source]

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)[source]

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)[source]

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)[source]

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)[source]

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()[source]

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)[source]

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)[source]

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)[source]

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)[source]

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()[source]
class schrodinger.application.matsci.espresso.utils.MemoryEstimator(vecs, ecutwfc, ecutrho, nproc, nks, nspin, nbnd, ntyp, nmix, lscf)[source]

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)[source]

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)[source]

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)[source]

Get a good FFT dimension.

Parameters

fft_dim (int) – FFT dimension

Return type

int

Returns

Good FFT dimension, if exists

isGoodDim(fft_dim)[source]

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)[source]

Bases: object

Class that defines species with starting magnetization.

__init__(struct=None)[source]

Initialize MagSpecies class.

createUniqueElement(element, mag_element)[source]

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)[source]

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)[source]

Set data from the structure.

Parameters

struct (structure.Structure) – Input structure