def test_ethanol_basic(self): """ Check basic bond parser is working for example of ethanol. """ parsed_bonds = parse_bonds(open(self.calc1_path + ".castep").read()).next() # Make sure we parse all the bonds self.assertEqual(len(parsed_bonds), 32)
def load_bonds(self, castep_file, pop_tol=0.2): from castepy.output.bonds import parse_bonds from collections import Counter bonds = parse_bonds(castep_file) bonded_dict = {(atom.species,atom.index): [] for atom in self} for idx1, idx2, pop, length in bonds: if pop >= pop_tol: bonded_dict[idx1].append(idx2) bonded_dict[idx2].append(idx1) for idx1, idx2s in bonded_dict.items(): atom1 = self.get_species(*idx1) bonded_atoms = [] for idx2 in idx2s: atom2 = self.get_species(*idx2) bonded_atoms.append(atom2) atom1.bonded = MagresAtomsView(list(bonded_atoms), self.lattice)
def load_bonds(self, castep_file, pop_tol=0.2): from castepy.output.bonds import parse_bonds from collections import Counter bonds = next(parse_bonds(castep_file)) bonded_dict = dict([((atom.species, atom.index), []) for atom in self]) for idx1, idx2, pop, length in bonds: if pop >= pop_tol: bonded_dict[idx1].append(idx2) bonded_dict[idx2].append(idx1) for idx1, idx2s in list(bonded_dict.items()): atom1 = self.get(*idx1) bonded_atoms = [] for idx2 in idx2s: atom2 = self.get(*idx2) bonded_atoms.append(atom2) atom1.bonded = MagresAtomsView(list(bonded_atoms), self.lattice)