def _check_topology(self): ''' Check wether all topology information (bonds, bends, dihedrals, out-of-plane patterns and neighborlist) is present and complete if necessary. ''' assert self.numbers is not None if self.bonds is None: molecule = Molecule(self.numbers, coordinates=self.ref.coords) graph = MolecularGraph.from_geometry(molecule) psf = PSFFile() psf.add_molecule(molecule) self.bonds = np.array(psf.bonds) self.bends = np.array(psf.bends) self.diheds = np.array(psf.dihedrals) self.opdists = find_opdist_patterns(graph) self.nlist = graph.neighbors else: graph = MolecularGraph(self.bonds, self.numbers) psf = PSFFile() psf.add_molecular_graph(graph) if self.bends is None: self.bends = np.array(psf.bends) if self.diheds is None: self.diheds = np.array(psf.dihedrals) if self.opdists is None: self.opdists = find_opdist_patterns(graph) if self.nlist is None: self.nlist = graph.neighbors
def test_tetra(self): molecule = Molecule.from_file("input/tetra.xyz") psf = PSFFile() psf.add_molecule(molecule) self.assert_(psf.bonds.shape[0] == 4) self.assert_(psf.bends.shape[0] == 6) psf.write_to_file("output/tetra.psf")
def test_tetra(self): molecule = XYZFile("input/tetra.xyz").get_molecule() psf = PSFFile() psf.add_molecule(molecule) self.assert_(psf.bonds.shape[0] == 4) self.assert_(psf.bends.shape[0] == 6) psf.write_to_file("output/tetra.psf")
def test_many_separate(self): psf = PSFFile() molecule = Molecule.from_file("input/ethene.xyz") psf.add_molecule(molecule) psf.add_molecule(molecule) molecule = Molecule.from_file("input/tea.xyz") psf.add_molecule(molecule) psf.write_to_file("output/many_separate.psf")
def test_many_separate(self): psf = PSFFile() molecule = XYZFile("input/ethene.xyz").get_molecule() psf.add_molecule(molecule) psf.add_molecule(molecule) molecule = XYZFile("input/tea.xyz").get_molecule() psf.add_molecule(molecule) psf.write_to_file("output/many_separate.psf")
def test_improper(self): molecule = Molecule.from_file("input/formol.xyz") psf = PSFFile() psf.add_molecule(molecule) self.assertEqual(psf.impropers.shape, (3,4)) test_block = set([(row[0], row[1]) for row in psf.impropers]) self.assert_((0,1) in test_block) self.assert_((0,2) in test_block) self.assert_((0,3) in test_block) psf.write_to_file("output/tmp_impropers.psf") psf2 = PSFFile("output/tmp_impropers.psf") self.assertArraysEqual(psf.impropers, psf2.impropers)
def test_dump(self): m = Molecule.from_file("input/thf.xyz") psf = PSFFile() psf.add_molecule(m) psf.write_to_file("output/thf.psf")
def test_dump(self): m = XYZFile("input/thf.xyz").get_molecule() psf = PSFFile() psf.add_molecule(m) psf.write_to_file("output/thf.psf")