def select_pseudos(pseudos, structure, ret_table=True): """ Given a list of pseudos and a pymatgen structure, extract the pseudopotentials for the calculation (useful when we receive an entire periodic table). Raises: ValueError if no pseudo is found or multiple occurrences are found. """ table = PseudoTable.astable(pseudos) pseudos = [] for symbol in structure.types_of_specie: # Get the list of pseudopotentials in table from atom symbol. pseudos_for_type = table.pseudos_with_symbol(symbol) if not pseudos_for_type: raise ValueError("Cannot find pseudo for symbol %s" % symbol) if len(pseudos_for_type) > 1: raise ValueError("Find multiple pseudos for symbol %s" % symbol) pseudos.append(pseudos_for_type[0]) if ret_table: return PseudoTable(pseudos) else: return pseudos
def num_valence_electrons(pseudos, structure): """ Compute the number of valence electrons from a list of pseudopotentials and the crystalline structure. Args: pseudos: List of strings, list of of pseudos or `PseudoTable` instance. structure: Pymatgen structure. Raises: ValueError if cannot find a pseudo in the input pseudos or if the input list contains more than one pseudo for the chemical symbols appearing in structure. """ table = PseudoTable.astable(pseudos) valence = 0.0 for site in structure: entries = table.pseudos_with_symbol(site.specie.symbol) if len(entries) != 1: raise ValueError("Found %d entries for symbol %s" % (len(entries), site.specie.symbol)) valence += entries[0].Z_val return valence
def select_pseudos(pseudos, structure, ret_table=True): """ Given a list of pseudos and a pymatgen structure, extract the pseudopotentials for the calculation (useful when we receive an entire periodic table). Raises: ValueError if no pseudo is found or multiple occurrences are found. """ table = PseudoTable.astable(pseudos) pseudos = [] for symbol in structure.types_of_specie: # Get the list of pseudopotentials in table from atom symbol. pseudos_for_type = table.pseudos_with_symbol(symbol) if not pseudos_for_type: raise ValueError("Cannot find pseudo for symbol %s" % symbol) if len(pseudos_for_type) > 1: raise ValueError("Find multiple pseudos for symbol %s" % symbol) pseudos.append(pseudos_for_type[0]) if ret_table: return PseudoTable(pseudos) else: return pseudos
def num_valence_electrons(pseudos, structure): """ Compute the number of valence electrons from a list of pseudopotentials and the crystalline structure. Args: pseudos: List of strings, list of of pseudos or `PseudoTable` instance. structure: Pymatgen structure. Raises: ValueError if cannot find a pseudo in the input pseudos or if the input list contains more than one pseudo for the chemical symbols appearing in structure. """ table = PseudoTable.astable(pseudos) valence = 0.0 for site in structure: entries = table.pseudos_with_symbol(site.specie.symbol) if len(entries) != 1: raise ValueError("Found %d entries for symbol %s" % (len(entries), site.specie.symbol)) valence += entries[0].Z_val return valence
def calc_nvalence(self, pseudos): """ Returns the number of valence electrons. Args: pseudos: List of `Pseudo` objects or list of pseudopotential filenames. """ table = PseudoTable.astable(pseudos) nval = 0 for site in self: symbol = site.species_string pseudos = table.pseudos_with_symbol(symbol) assert len(pseudos) == 1 nval += pseudos[0].Z_val return nval
def select_pseudos(pseudos, structure): """ Given a list of pseudos and a pymatgen structure, extract the pseudopotentials for the calculation (useful when we receive an entire periodic table). Raises: ValueError if no pseudo is found or multiple occurrences are found. """ table = PseudoTable.astable(pseudos) pseudos = [] for typ in structure.types_of_specie: # Get the list of pseudopotentials in table from atom symbol. pseudos_for_type = table.pseudos_with_symbol(typ) if pseudos_for_type is None or len(pseudos_for_type) != 1: raise ValueError("Cannot find unique pseudo for type %s" % typ) pseudos.append(pseudos_for_type[0]) return PseudoTable(pseudos)