Exemple #1
0
 def test_triclinic_cell(self):
     cell = UnitCell(35.996, 41.601, 45.756, 67.40, 66.90, 74.85)
     pos = Position(-15, -17, 190)
     frac = cell.fractionalize(pos)
     pos2 = cell.orthogonalize(frac)
     self.assertAlmostEqual(pos.x, pos2.x, delta=1e-12)
     self.assertAlmostEqual(pos.y, pos2.y, delta=1e-12)
     self.assertAlmostEqual(pos.z, pos2.z, delta=1e-12)
     # tested against values from uctbx:
     #  from cctbx import uctbx
     #  uc = uctbx.unit_cell((35.996, 41.601, 45.756, 67.40, 66.90, 74.85))
     #  uc.d_star_sq((-3, -2, 1))
     #  uc.d((3, 4, 5))
     self.assertAlmostEqual(cell.calculate_1_d2([-3, -2, 1]),
                            0.0128229081865688, delta=1e-17)
     self.assertAlmostEqual(cell.calculate_d([3, 4, 5]),
                            7.7319559244298, delta=1e-13)
     #  uc.metrical_matrix()
     cctbx_mm = [1295.712016, 1730.643201, 2093.611536,
                 391.3591013825865, 646.1921687548228, 731.5043620154578]
     mt = cell.metric_tensor()
     for a, b in zip(mt.elements(), cctbx_mm):
         self.assertAlmostEqual(a, b, delta=1e-12)
     #  uc.reciprocal_metrical_matrix()
     cctbx_rmm = [0.00092792089082916, 0.000689632633981, 0.0006277651322979,
                  -0.000104162588996, -0.000250008091601, -0.000208806754807]
     rmt = cell.reciprocal_metric_tensor()
     for a, b in zip(rmt.elements(), cctbx_rmm):
         self.assertAlmostEqual(a, b, delta=1e-15)
Exemple #2
0
 def test_triclinic_cell(self):
     cell = UnitCell(35.996, 41.601, 45.756, 67.40, 66.90, 74.85)
     pos = Position(-15, -17, 190)
     frac = cell.fractionalize(pos)
     pos2 = cell.orthogonalize(frac)
     self.assertAlmostEqual(pos.x, pos2.x, delta=1e-12)
     self.assertAlmostEqual(pos.y, pos2.y, delta=1e-12)
     self.assertAlmostEqual(pos.z, pos2.z, delta=1e-12)
     # tested against values from uctbx:
     #  from cctbx import uctbx
     #  uc = uctbx.unit_cell((35.996, 41.601, 45.756, 67.40, 66.90, 74.85))
     #  uc.d_star_sq((-3, -2, 1))
     #  uc.d((3, 4, 5))
     self.assertAlmostEqual(cell.calculate_1_d2(-3, -2, 1),
                            0.0128229081865688,
                            delta=1e-17)
     self.assertAlmostEqual(cell.calculate_d(3, 4, 5),
                            7.7319559244298,
                            delta=1e-13)
Exemple #3
0
 def test_triclinic_cell(self):
     cell = UnitCell(35.996, 41.601, 45.756, 67.40, 66.90, 74.85)
     # this would give syntax error with Python < 3.5
     #o_f = cell.orthogonalization_matrix @ cell.fractionalization_matrix
     o_f = cell.orthogonalization_matrix.multiply(
         cell.fractionalization_matrix)
     self.assertTrue(o_f.approx(gemmi.Mat33(), 1e-15))
     pos = Position(-15, -17, 190)
     frac = cell.fractionalize(pos)
     pos2 = cell.orthogonalize(frac)
     self.assertAlmostEqual(pos.x, pos2.x, delta=1e-12)
     self.assertAlmostEqual(pos.y, pos2.y, delta=1e-12)
     self.assertAlmostEqual(pos.z, pos2.z, delta=1e-12)
     # tested against values from uctbx:
     #  from cctbx import uctbx
     #  uc = uctbx.unit_cell((35.996, 41.601, 45.756, 67.40, 66.90, 74.85))
     #  uc.d_star_sq((-3, -2, 1))
     #  uc.d((3, 4, 5))
     self.assertAlmostEqual(cell.calculate_1_d2([-3, -2, 1]),
                            0.0128229081865688,
                            delta=1e-17)
     self.assertAlmostEqual(cell.calculate_d([3, 4, 5]),
                            7.7319559244298,
                            delta=1e-13)
     #  uc.metrical_matrix()
     cctbx_mm = [
         1295.712016, 1730.643201, 2093.611536, 391.3591013825865,
         646.1921687548228, 731.5043620154578
     ]
     mt = cell.metric_tensor()
     assert_almost_equal_seq(self, mt.elements_pdb(), cctbx_mm, delta=1e-12)
     #  uc.reciprocal_metrical_matrix()
     cctbx_rmm = [
         0.00092792089082916, 0.000689632633981, 0.0006277651322979,
         -0.000104162588996, -0.000250008091601, -0.000208806754807
     ]
     rmt = cell.reciprocal_metric_tensor()
     assert_almost_equal_seq(self,
                             rmt.elements_pdb(),
                             cctbx_rmm,
                             delta=1e-15)