Get an element from an atomic number.

        Args:
            z (int): Atomic number

        Returns:
            Element with atomic number z.
353855
def from_Z(z: int):
        
        for sym, data in _pt_data.items():
            if data["Atomic no"] == z:
                return Element(sym)
        raise ValueError("No element with this atomic number %s" % z)
1283605
def get_element_by_id(self, ident):
        """"""
        for group in list(self.toc.keys()):
            for name in list(self.toc[group].keys()):
                if self.toc[group][name].ident == ident:
                    return self.toc[group][name]
        return None
439543
def get_chemical_formula(atoms, mode='metal'):
    
    try:
        return atoms.get_chemical_formula(mode=mode)
    except ValueError:
        return atoms.get_chemical_formula(mode='hill')
845481
def element(self, inp=None):
        
        for set in self.sets:
            try:
                return set.element(inp)
            except NotImplementedError:
                pass
        raise NotImplementedError('`element` not implemented for any of the '
                                  'subsets')
153907
def atoms(lines):
    
    # Convert sdf style charge to actual charge
    conv_charge_table = {0: 0, 1: 3, 2: 2, 3: 1, 4: 0, 5: -1, 6: -2, 7: -3}
    results = {}
    for i, line in enumerate(lines):
        symbol = line[31:34].rstrip()
        try:
            atom = Atom(symbol)
        except KeyError:
            raise ValueError(symbol)
        xpos = float(line[0:10])
        ypos = float(line[10:20])
        zpos = float(line[20:30])
        atom.coords = (xpos, ypos, zpos)
        atom.mass_diff = int(line[34:37])
        old_sdf_charge = int(line[37:40])
        atom.charge = conv_charge_table[old_sdf_charge]
        if old_sdf_charge == 4:
            atom.radical = 1
        # atom.stereo_flag = int(line[40:43])  # Not used
        # valence = int(line[46:49])
        # if valence:
        #     atom.valence = valence
        results[i + 1] = {"atom": atom}
    return results
1238580
def element_data_str(z, eldata):
    '''
    '''

    sym = lut.element_sym_from_Z(z, True)

    cs = contraction_string(eldata)
    if cs == '':
        cs = '(no electron shells)'
    s = '\nElement: {} : {}\n'.format(sym, cs)

    if 'electron_shells' in eldata:
        for shellidx, shell in enumerate(eldata['electron_shells']):
            s += electron_shell_str(shell, shellidx) + '\n'

    if 'ecp_potentials' in eldata:
        s += 'ECP: Element: {}   Number of electrons: {}\n'.format(sym, eldata['ecp_electrons'])

        for pot in eldata['ecp_potentials']:
            s += ecp_pot_str(pot) + '\n'

    return s
756606
def element_abund_marco(i_decay, stable_isotope_list,
                        stable_isotope_identifier,
                        mass_fractions_array_not_decayed,
                        mass_fractions_array_decayed):
    '''
    

    '''


    # this way is done in a really simple way. May be done better for sure, in a couple of loops.
    # I keep this, since I have only to copy over old script. Falk will probably redo it.

    #import numpy as np
    #from NuGridPy import utils as u

    global elem_abund
    elem_abund = np.zeros(z_bismuth)
    global elem_abund_decayed
    elem_abund_decayed = np.zeros(z_bismuth)
    global elem_prod_fac
    elem_prod_fac = np.zeros(z_bismuth)
    global elem_prod_fac_decayed
    elem_prod_fac_decayed = np.zeros(z_bismuth)


    # notice that elem_abund include all contribution, both from stables and unstables in
    # that moment.
    for i in range(z_bismuth):
        dummy = 0.
        for j in range(len(spe)):
            if znum_int[j] == i+1 and stable_isotope_identifier[j] > 0.5:
                dummy = dummy + float(mass_fractions_array_not_decayed[j])
        elem_abund[i] = dummy


    for i in range(z_bismuth):
        if index_stable[i] == 1:
            elem_prod_fac[i] = float(old_div(elem_abund[i],solar_elem_abund[i]))
        elif index_stable[i] == 0:
            elem_prod_fac[i] = 0.


    if i_decay == 2:
        for i in range(z_bismuth):
            dummy = 0.
            for j in range(len(mass_fractions_array_decayed)):
                if znum_int[cl[stable_isotope_list[j].capitalize()]] == i+1:
                #print znum_int[cl[stable[j].capitalize()]],cl[stable[j].capitalize()],stable[j]
                    dummy = dummy + float(mass_fractions_array_decayed[j])
            elem_abund_decayed[i] = dummy


        for i in range(z_bismuth):
            if index_stable[i] == 1:
                elem_prod_fac_decayed[i] = float(old_div(elem_abund_decayed[i],solar_elem_abund[i]))
            elif index_stable[i] == 0:
                elem_prod_fac_decayed[i] = 0.
2674
def n_atom(self, node):
        
        length = len(node)
        if length == 1:
            self.preorder(node[0])
            node.value = node[0].value
            self.prune()
        elif length == 3:
            self.preorder(node[1])
            node.value = node[1].value
            self.prune()
        else:
            assert False, "Expecting atom to have length 1 or 3"
1161202
def element_from_span(span: List[int],
                      span_type: str) -> Element:
    
    return Element(span_type,
                   [span[0].idx,
                    span[-1].idx + len(span[-1])],
                   ' '.join(map(str, span)))
1267122
private int getAtomPosition(IAtom atom, IAtomContainer container) {
        for (int i = 0; i < container.getAtomCount(); i++) {
            if (atom.equals(container.getAtom(i))) {
                return i;
            }
        }
        return -1;
    }
1255957
def get_number_of_atoms(self):
        
        strc = self.get_output_structure()
        if not strc:
            return None
        return Property(scalars=[Scalar(value=len(strc))], units="/unit cell")
287502
def renumber_atoms(lines):
    '''
    
    '''
    new_lines = []
    current_number = 1
    for line in lines:
        if line.startswith('ATOM') or line.startswith('HETATM'):
            new_lines.append(
                line[:6] + string.rjust('%d' % current_number, 5) + line[11:]
            )
            current_number += 1
        else:
            if line.startswith('TER'):
                current_number += 1
            new_lines.append(line)
    return new_lines
344895
def get_structure(atoms, cls=None):
        
        symbols = atoms.get_chemical_symbols()
        positions = atoms.get_positions()
        lattice = atoms.get_cell()

        cls = Structure if cls is None else cls
        return cls(lattice, symbols, positions,
                   coords_are_cartesian=True)
968792
def getAtomLine(self, chain, resid):
        ''''''
        for line in self.lines:
            fieldtype = line[0:6].strip()
            assert(fieldtype == "ATOM" or fieldtype == "HETATM")
            if line[21:22] == chain and resid == line[22:27]:
                return line
        raise Exception("Could not find the ATOM/HETATM line corresponding to chain '%(chain)s' and residue '%(resid)s'." % vars())
1372287
def element(self):
        """"""
        #We assume here that the entire operation is associated with a single
        #code element. Since the sequence matcher groups operations by contiguous
        #lines of code to change, this is a safe assumption.
        if self._element is None:
            line = self.icached[0]
            #If we are inserting a new line, the location at the start of the line
            #that used to be there interferes with the element finder.
            if self.mode == "insert":
                line -= 1
            self._element = self.context.module.get_element(line, 0)

        return self._element
1042621
def parse_atoms(self, pdb):
    """"""
    
    atomre = re.compile("ATOM")
    
    atomlines = [line for line in pdb.lines if atomre.match(line)]
    
    chainresnums = {}
    
    for line in atomlines:
      chain = line[21]
      resname = line[17:20]
      resnum = line[22:27]
      #print resnum
      chainresnums.setdefault(chain, [])
      
      if resnum in chainresnums[chain]:
        assert self[chain][chainresnums[chain].index(resnum)] == resname
      else:
        if resnum[-1] == ' ':
          self.setdefault(chain, [])
          self[chain] += [resname]
          chainresnums[chain] += [resnum]
    
    return chainresnums
505180
public List<Integer> getOrbit(int element) {
        List<Integer> orbit = new ArrayList<Integer>();
        orbit.add(element);
        int i = values[element];
        while (i != element && orbit.size() < values.length) {
            orbit.add(i);
            i = values[i];
        }
        return orbit;
    }