dataset_second_atoms: [{'number': 7,
                            'displacement': [],
                            'delta_forces': []}, ...]
348757
def get_constrained_fc2(supercell,
                        dataset_second_atoms,
                        atom1,
                        reduced_site_sym,
                        symprec):
    
    lattice = supercell.get_cell().T
    positions = supercell.get_scaled_positions()
    num_atom = supercell.get_number_of_atoms()

    fc2 = np.zeros((num_atom, num_atom, 3, 3), dtype='double')
    atom_list = np.unique([x['number'] for x in dataset_second_atoms])
    for atom2 in atom_list:
        disps2 = []
        sets_of_forces = []
        for disps_second in dataset_second_atoms:
            if atom2 != disps_second['number']:
                continue
            bond_sym = get_bond_symmetry(
                reduced_site_sym,
                lattice,
                positions,
                atom1,
                atom2,
                symprec)

            disps2.append(disps_second['displacement'])
            sets_of_forces.append(disps_second['delta_forces'])

        solve_force_constants(fc2,
                              atom2,
                              disps2,
                              sets_of_forces,
                              supercell,
                              bond_sym,
                              symprec)

    # Shift positions according to set atom1 is at origin
    pos_center = positions[atom1].copy()
    positions -= pos_center
    rotations = np.array(reduced_site_sym, dtype='intc', order='C')
    translations = np.zeros((len(reduced_site_sym), 3),
                            dtype='double', order='C')
    permutations = compute_all_sg_permutations(positions,
                                               rotations,
                                               translations,
                                               lattice,
                                               symprec)
    distribute_force_constants(fc2,
                               atom_list,
                               lattice,
                               rotations,
                               permutations)
    return fc2
966250
def nearest_neighbour_delta_E( self ):
        
        delta_nn = self.final_site.nn_occupation() - self.initial_site.nn_occupation() - 1 # -1 because the hopping ion is not counted in the final site occupation number
        return ( delta_nn * self.nearest_neighbour_energy )
472203
def _approximate_unkown_bond_lengths(self):
        """"""
        dataset = self.lengths[BOND_SINGLE]
        for n1 in periodic.iter_numbers():
            for n2 in periodic.iter_numbers():
                if n1 <= n2:
                    pair = frozenset([n1, n2])
                    atom1 = periodic[n1]
                    atom2 = periodic[n2]
                    #if (pair not in dataset) and hasattr(atom1, "covalent_radius") and hasattr(atom2, "covalent_radius"):
                    if (pair not in dataset) and (atom1.covalent_radius is not None) and (atom2.covalent_radius is not None):
                        dataset[pair] = (atom1.covalent_radius + atom2.covalent_radius)
100640
def read_projected_dos( self ):
        
        pdos_list = []
        for i in range( self.number_of_atoms ):
            df = self.read_atomic_dos_as_df( i+1 )
            pdos_list.append( df )
        self.pdos = np.vstack( [ np.array( df ) for df in pdos_list ] ).reshape( 
            self.number_of_atoms, self.number_of_data_points, self.number_of_channels, self.ispin )
429316
protected void newAtomData() {
        atomCounter = 0;
        elsym = new ArrayList<String>();
        elid = new ArrayList<String>();
        eltitles = new ArrayList<String>();
        formalCharges = new ArrayList<String>();
        partialCharges = new ArrayList<String>();
        isotope = new ArrayList<String>();
        atomicNumbers = new ArrayList<String>();
        exactMasses = new ArrayList<String>();
        x3 = new ArrayList<String>();
        y3 = new ArrayList<String>();
        z3 = new ArrayList<String>();
        x2 = new ArrayList<String>();
        y2 = new ArrayList<String>();
        xfract = new ArrayList<String>();
        yfract = new ArrayList<String>();
        zfract = new ArrayList<String>();
        hCounts = new ArrayList<String>();
        atomParities = new ArrayList<String>();
        parityARef1 = new ArrayList<String>();
        parityARef2 = new ArrayList<String>();
        parityARef3 = new ArrayList<String>();
        parityARef4 = new ArrayList<String>();
        atomAromaticities = new ArrayList<String>();
        atomDictRefs = new ArrayList<String>();
        spinMultiplicities = new ArrayList<String>();
        occupancies = new ArrayList<String>();
        atomCustomProperty = new HashMap<Integer, List<String>>();
    }
969452
def multiplicity(self):
        
        sga = SpacegroupAnalyzer(self.bulk_structure)
        periodic_struc = sga.get_symmetrized_structure()
        poss_deflist = sorted(
            periodic_struc.get_sites_in_sphere(self.site.coords, 2, include_index=True), key=lambda x: x[1])
        defindex = poss_deflist[0][2]

        equivalent_sites = periodic_struc.find_equivalent_sites(self.bulk_structure[defindex])
        return len(equivalent_sites)
752624
def data(self) -> Sequence[Tuple[int, float]]:
        
        return [(num, prob) for num, prob in zip(self._num_cfds_seq,
                                                 self._gnd_state_probs)]
1342934
def formula(self, atom_sequence):
        '''
        
        '''
        labels = {}
        types = []
        y = 0
        for k, atomi in enumerate(atom_sequence):
            lbl = re.sub("[0-9]+", "", atomi).capitalize()
            if lbl not in labels:
                labels[lbl] = y
                types.append([k+1])
                y += 1
            else:
                types[ labels[lbl] ].append(k+1)
        atoms = list(labels.keys())
        atoms = [x for x in self.formula_sequence if x in atoms] + [x for x in atoms if x not in self.formula_sequence] # accordingly
        formula = ''
        for atom in atoms:
            n = len(types[labels[atom]])
            if n==1: n = ''
            else: n = str(n)
            formula += atom + n
        return formula
446713
def __get_sigmas(self):
        """"""
        stack_sigma = {}
        _stack = self.stack

        _file_path = os.path.abspath(os.path.dirname(__file__))
        _database_folder = os.path.join(_file_path, 'reference_data', self.database)

        _list_compounds = _stack.keys()
        for _compound in _list_compounds:
            _list_element = _stack[_compound]['elements']
            stack_sigma[_compound] = {}

            for _element in _list_element:
                stack_sigma[_compound][_element] = {}
                _list_isotopes = _stack[_compound][_element]['isotopes']['list']
                _list_file_names = _stack[_compound][_element]['isotopes']['file_names']
                _list_isotopic_ratio = _stack[_compound][_element]['isotopes']['isotopic_ratio']
                _iso_file_ratio = zip(_list_isotopes, _list_file_names, _list_isotopic_ratio)
                stack_sigma[_compound][_element]['isotopic_ratio'] = _list_isotopic_ratio

                # _dict_sigma_isotopes_sum = {}
                _sigma_all_isotopes = 0
                _energy_all_isotpes = 0

                for _iso, _file, _ratio in _iso_file_ratio:
                    stack_sigma[_compound][_element][_iso] = {}
                    _file = os.path.join(_database_folder, _file)
                    _dict = _utilities.get_sigma(database_file_name=_file,
                                                 e_min=self.energy_min,
                                                 e_max=self.energy_max,
                                                 e_step=self.energy_step)
                    stack_sigma[_compound][_element][_iso]['energy_eV'] = _dict['energy_eV']
                    stack_sigma[_compound][_element][_iso]['sigma_b'] = _dict['sigma_b'] * _ratio
                    stack_sigma[_compound][_element][_iso]['sigma_b_raw'] = _dict['sigma_b']

                    # sigma for all isotopes with their isotopic ratio
                    _sigma_all_isotopes += _dict['sigma_b'] * _ratio
                    _energy_all_isotpes += _dict['energy_eV']

                # energy axis (x-axis) is averaged to take into account differences between x-axis of isotopes
                _mean_energy_all_isotopes = _energy_all_isotpes / len(_list_isotopes)
                stack_sigma[_compound][_element]['energy_eV'] = _mean_energy_all_isotopes
                stack_sigma[_compound][_element]['sigma_b'] = _sigma_all_isotopes

        self.stack_sigma = stack_sigma
54809
def read_atoms(fn, cycfn=None, pos_only=False, conv=1.0):
    
    f = paropen(fn, "r")

    l = f.readline().lstrip()
    while len(l) > 0 and ( l[0] == '#' or l[0] == '<' ):
        l = f.readline().lstrip()

    n_atoms = int(l)

    l = f.readline().lstrip()
    while len(l) > 0 and ( l[0] == '#' or l[0] == '<' ):
        l = f.readline().lstrip()

    l = f.readline().lstrip()
    while len(l) > 0 and ( l[0] == '#' or l[0] == '<' ):
        l = f.readline().lstrip()

    #
    # Read positions
    #

    forces = np.zeros( [ n_atoms, 3 ] )
    groups = np.zeros( [ n_atoms ] )
    gamma  = np.zeros( [ n_atoms ] )
    T      = np.zeros( [ n_atoms ] )

    ats = [ ]
    for i in range(n_atoms):
        s = l.split()
        #      type   x            y            z
        sym = None
        try:
            Z    = int(s[0])
            sym  = ase.data.chemical_symbols[Z]
        except:
            sym  = s[0]
        a = ase.Atom(sym, ( float(s[2])*conv, float(s[3])*conv, float(s[4])*conv ) )
        groups[i] = int(s[5])
        gamma[i]  = float(s[6])
        T[i]      = float(s[7])

        ats += [ a ]
        l = f.readline()
    this = ase.Atoms(ats, pbc=True)

    if not pos_only:
        while l and l == "":
            l = f.readline().strip()

        while l:
            key = l.strip(" <-#\r\n")

            if key.upper() == "VELOCITIES":
                for i in range(n_atoms):
                    s = f.readline().split()
                    m = this[i].mass
                    if m is None:
                        m = ase.data.atomic_masses[ase.data.chemical_symbols.index(this[i].symbol)]
                    this[i].momentum = ( m*float(s[0]), m*float(s[1]), m*float(s[2]) )

                l = None

            elif key.upper() == "FORCES":
                for i in range(n_atoms):
                    s = f.readline().split()
                    forces[i] =  np.array( [ float(s[0]), float(s[1]), float(s[2]) ] )

                l = None

            elif key.upper() == "CHARGES":
                for i in this:
                    l = f.readline()
                    if l and len(l.split()) == 1:
                        i.charge = float(l)

                l = None

            elif key.upper() == "CELL" or key.upper().split()[0:2] == ("BOX", "VECTORS" ):
                l1 = f.readline()
                l2 = f.readline()
                l3 = f.readline()

                this.set_cell( [ [float(x) for x in l1.split()],
                                 [float(x) for x in l2.split()],
                                 [float(x) for x in l3.split()] ] )

                l = None

            else:
                aux = [ ]
                l = f.readline().strip()
                while l and l[0] not in [ '<', '#' ]:
                    s = l.split()

                    aux += [ [float(x) for x in s] ]

                    l = f.readline().strip()

                if len(aux) == n_atoms:
                    this.set_array(key, np.asarray(aux))
                else:
                    print("Warning: Encountered field '%s' which does not seem to be per-atom data." % key)

            if l is None:
                l = f.readline().strip()
            while l and l == "":
                l = f.readline().strip()


    f.close()

    this.set_array("forces", forces)
    this.set_array("groups", groups)
    this.set_array("gamma", gamma)
    this.set_array("T", T)

    if cycfn:
        read_cyc(this, cycfn, conv=conv)

    return this
141318
def get_bonds(input_group):
    """"""
    out_list = []
    for i in range(len(input_group.bond_order_list)):
        out_list.append((input_group.bond_atom_list[i * 2], input_group.bond_atom_list[i * 2 + 1],))
    return out_list
1175133
def from_rdkit_molecule(data):
    
    m = MoleculeContainer()
    atoms, mapping = [], []
    for a in data.GetAtoms():
        atom = {'element': a.GetSymbol(), 'charge': a.GetFormalCharge()}
        atoms.append(atom)
        mapping.append(a.GetAtomMapNum())

        isotope = a.GetIsotope()
        if isotope:
            atom['isotope'] = isotope
        radical = a.GetNumRadicalElectrons()
        if radical:
            atom['multiplicity'] = radical + 1

    conformers = data.GetConformers()
    if conformers:
        for atom, (x, y, z) in zip(atoms, conformers[0].GetPositions()):
            atom['x'] = x
            atom['y'] = y
            atom['z'] = z

    for atom, mapping in zip(atoms, mapping):
        a = m.add_atom(atom)
        if mapping:
            m.atom(a)._parsed_mapping = mapping

    for bond in data.GetBonds():
        m.add_bond(bond.GetBeginAtomIdx() + 1, bond.GetEndAtomIdx() + 1, _rdkit_bond_map[bond.GetBondType()])

    return m
725103
public static MultiDataSet toMultiDataSet(DataSet dataSet) {
        INDArray f = dataSet.getFeatures();
        INDArray l = dataSet.getLabels();
        INDArray fMask = dataSet.getFeaturesMaskArray();
        INDArray lMask = dataSet.getLabelsMaskArray();

        INDArray[] fNew = f == null ? null : new INDArray[] {f};
        INDArray[] lNew = l == null ? null : new INDArray[] {l};
        INDArray[] fMaskNew = (fMask != null ? new INDArray[] {fMask} : null);
        INDArray[] lMaskNew = (lMask != null ? new INDArray[] {lMask} : null);

        return new org.nd4j.linalg.dataset.MultiDataSet(fNew, lNew, fMaskNew, lMaskNew);
    }
933648
int[][] findNeighborIndices() {

		// looking at a typical protein case, number of neighbours are from ~10 to ~50, with an average of ~30
		int initialCapacity = 60;

		int[][] nbsIndices = new int[atomCoords.length][];

		for (int k=0; k<atomCoords.length; k++) {
			double radius = radii[k] + probe + probe;

			List<Integer> thisNbIndices = new ArrayList<>(initialCapacity);

			for (int i = 0; i < atomCoords.length; i++) {
				if (i == k) continue;

				double dist = atomCoords[i].distance(atomCoords[k]);

				if (dist < radius + radii[i]) {
					thisNbIndices.add(i);
				}
			}

			int[] indicesArray = new int[thisNbIndices.size()];
			for (int i=0;i<thisNbIndices.size();i++) indicesArray[i] = thisNbIndices.get(i);
			nbsIndices[k] = indicesArray;
		}
		return nbsIndices;
	}
699713
def second_params_two(test, two):
    
    if request.method == 'POST':
        return [test, two, request.data]
    return {'result': [test, two]}
1218145
def as_phononwebsite(self):
        
        d = {}

        #define the lattice
        d["lattice"] = self.structure.lattice._matrix.tolist()
      
        #define atoms
        atom_pos_car = []
        atom_pos_red = []
        atom_types = []
        for site in self.structure.sites:
            atom_pos_car.append(site.coords.tolist())
            atom_pos_red.append(site.frac_coords.tolist())
            atom_types.append(site.species_string)

        #default for now
        d["repetitions"] = get_reasonable_repetitions(len(atom_pos_car))
    
        d["natoms"] = len(atom_pos_car)
        d["atom_pos_car"] = atom_pos_car
        d["atom_pos_red"] = atom_pos_red
        d["atom_types"] = atom_types
        d["atom_numbers"] = self.structure.atomic_numbers
        d["formula"] = self.structure.formula
        d["name"] = self.structure.formula

        #get qpoints
        qpoints = []
        for q in self.qpoints:
            qpoints.append(list(q.frac_coords))
        d["qpoints"] = qpoints

        # get labels
        hsq_dict = collections.OrderedDict()
        for nq,q in enumerate(self.qpoints):
            if q.label is not None:
                hsq_dict[nq] = q.label

        #get distances
        dist = 0
        nqstart = 0
        distances = [dist]
        line_breaks = []
        for nq in range(1,len(qpoints)):
            q1 = np.array(qpoints[nq])
            q2 = np.array(qpoints[nq-1])
            #detect jumps
            if ((nq in hsq_dict) and (nq-1 in hsq_dict)):
                if (hsq_dict[nq] != hsq_dict[nq-1]):
                    hsq_dict[nq-1] += "|"+hsq_dict[nq]
                del hsq_dict[nq]
                line_breaks.append((nqstart,nq))
                nqstart = nq
            else:
                dist += np.linalg.norm(q1-q2)
            distances.append(dist)
        line_breaks.append((nqstart,len(qpoints)))
        d["distances"] = distances
        d["line_breaks"] = line_breaks
        d["highsym_qpts"] = list(hsq_dict.items())

        #eigenvalues
        thz2cm1 = 33.35641
        bands = self.bands.copy()*thz2cm1
        d["eigenvalues"] = bands.T.tolist()

        #eigenvectors
        eigenvectors = self.eigendisplacements.copy()
        eigenvectors /= np.linalg.norm(eigenvectors[0,0])
        eigenvectors = eigenvectors.swapaxes(0,1)
        eigenvectors = np.array([eigenvectors.real, eigenvectors.imag])
        eigenvectors = np.rollaxis(eigenvectors,0,5)
        d["vectors"] = eigenvectors.tolist()
 
        return d
325784
def sampleset(self):
        """"""
        x1, x4 = self.bounding_box
        dw = self.width * 0.5
        x2 = self.x_0 - dw
        x3 = self.x_0 + dw

        if self._n_models == 1:
            w = [x1, x2, x3, x4]
        else:
            w = list(zip(x1, x2, x3, x4))

        return np.asarray(w)