Пример #1
0
    def test_distance(self):
        frame = Frame()
        frame.cell = UnitCell(3.0, 4.0, 5.0)
        frame.add_atom(Atom(""), (0, 0, 0))
        frame.add_atom(Atom(""), (1, 2, 6))

        self.assertEqual(frame.distance(0, 1), math.sqrt(6.0))
Пример #2
0
    def test_distance(self):
        frame = Frame()
        frame.cell = UnitCell(3.0, 4.0, 5.0)
        frame.add_atom(Atom(""), (0, 0, 0))
        frame.add_atom(Atom(""), (1, 2, 6))

        self.assertEqual(frame.distance(0, 1), math.sqrt(6.0))
Пример #3
0
    def test_cell(self):
        frame = Frame()
        frame.cell = UnitCell(1, 2, 4)
        self.assertEqual(frame.cell.lengths, (1, 2, 4))
        self.assertEqual(frame.cell.angles, (90, 90, 90))
        self.assertEqual(frame.cell.shape, CellShape.Orthorhombic)

        frame.cell.lengths = (3, 4, 5)
        self.assertEqual(frame.cell.lengths, (3, 4, 5))
Пример #4
0
    def test_cell(self):
        frame = Frame()
        frame.cell = UnitCell(1, 2, 4)
        self.assertEqual(frame.cell.lengths, (1, 2, 4))
        self.assertEqual(frame.cell.angles, (90, 90, 90))
        self.assertEqual(frame.cell.shape, CellShape.Orthorhombic)

        frame.cell.lengths = (3, 4, 5)
        self.assertEqual(frame.cell.lengths, (3, 4, 5))
Пример #5
0
#!/usr/bin/env python
import numpy as np
from chemfiles import Topology, Frame, Atom, UnitCell, Trajectory

topology = Topology()
topology.atoms.append(Atom("H"))
topology.atoms.append(Atom("O"))
topology.atoms.append(Atom("H"))

topology.add_bond(0, 1)
topology.add_bond(2, 1)

frame = Frame()
frame.resize(3)
frame.topology = topology

frame.positions[0, :] = np.array([1.0, 0.0, 0.0])
frame.positions[1, :] = np.array([0.0, 0.0, 0.0])
frame.positions[2, :] = np.array([0.0, 1.0, 0.0])

frame.add_atom(Atom("O"), [5.0, 0.0, 0.0])
frame.add_atom(Atom("C"), [6.0, 0.0, 0.0])
frame.add_atom(Atom("O"), [7.0, 0.0, 0.0])
frame.add_bond(3, 4)
frame.add_bond(4, 5)

frame.cell = UnitCell(10, 10, 10)

with Trajectory("water-co2.pdb", 'w') as trajectory:
    trajectory.write(frame)