Exemple #1
0
class TestSymmetryN2O(TestCase):
    def setUp(self):
        nitrogen_1 = MagicMock(element='NITROGEN',
                               charge=7,
                               mass=14,
                               coordinates=(0.0000000000, 0.0000000000,
                                            -2.2684205883))
        nitrogen_2 = MagicMock(element='NITROGEN',
                               charge=7,
                               mass=14,
                               coordinates=(0.0000000000, 0.0000000000,
                                            -0.1349300877))
        oxygen_1 = MagicMock(element='OXYGEN',
                             charge=8,
                             mass=16,
                             coordinates=(0.0000000000, 0.0000000000,
                                          2.1042369647))

        self.nuclei_array_n2o = [nitrogen_1, nitrogen_2, oxygen_1]
        self.molecule_factory = MoleculeFactory(symmetry=True)
        self.symmetry_factory = SymmetryFactory()

    def test_check_linear_returns_true(self):
        nuclei_array = self.molecule_factory.center_molecule(
            self.nuclei_array_n2o)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(
            nuclei_array)
        self.molecule_factory.standard_orientation(nuclei_array, rotation,
                                                   reflection)
        boolean = self.molecule_factory.check_linear(nuclei_array)
        self.assertEqual(boolean, True)

    def test_point_group_returns_c_inf_v_symmetry_for_nitrous_oxide(self):
        symmetry = self.molecule_factory.create(self.nuclei_array_n2o)[1].label
        testing.assert_equal(symmetry, 'C_{4v}')
class TestSymmetryN2(TestCase):
    def setUp(self):
        nitrogen_1 = MagicMock(element='NITROGEN',
                               charge=7,
                               mass=14,
                               coordinates=(0.0000000000, 0.0000000000,
                                            1.0399092291))
        nitrogen_2 = MagicMock(element='NITROGEN',
                               charge=7,
                               mass=14,
                               coordinates=(0.0000000000, 0.0000000000,
                                            -1.0399092291))

        self.nuclei_array_n2 = [nitrogen_1, nitrogen_2]
        self.molecule_factory = MoleculeFactory(symmetry=True)
        self.symmetry_factory = SymmetryFactory()

    def test_check_linear_returns_true(self):
        nuclei_array = self.molecule_factory.center_molecule(
            self.nuclei_array_n2)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(
            nuclei_array)
        self.molecule_factory.standard_orientation(nuclei_array, rotation,
                                                   reflection)
        boolean = self.molecule_factory.check_linear(nuclei_array)
        self.assertEqual(boolean, True)

    # D_{4h} because D_{inf h} is not useful for reducing integrals
    def test_point_group_returns_d_4_h_symmetry_for_nitrogen(self):
        symmetry = self.molecule_factory.create(self.nuclei_array_n2)[1].label
        testing.assert_equal(symmetry, 'D_{4h}')
 def setUp(self):
     carbon_1 = MagicMock(element='CARBON',
                          charge=6,
                          mass=12,
                          coordinates=(-0.98781, 0.41551, 0.00000))
     hydrogen_1 = MagicMock(element='HYDROGEN',
                            charge=1,
                            mass=1,
                            coordinates=(0.08219, 0.41551, 0.00000))
     hydrogen_2 = MagicMock(element='HYDROGEN',
                            charge=1,
                            mass=1,
                            coordinates=(-1.34447, 0.70319, -0.96692))
     hydrogen_3 = MagicMock(element='HYDROGEN',
                            charge=1,
                            mass=1,
                            coordinates=(-1.34448, 1.10904, 0.73260))
     hydrogen_4 = MagicMock(element='HYDROGEN',
                            charge=1,
                            mass=1,
                            coordinates=(-1.34448, -0.56571, 0.23432))
     self.nuclei_array_ch4 = [
         carbon_1, hydrogen_1, hydrogen_2, hydrogen_3, hydrogen_4
     ]
     self.molecule_factory = MoleculeFactory(symmetry=True)
     self.symmetry_factory = SymmetryFactory()
 def setUp(self):
     helium_1 = MagicMock(element='HELIUM',
                          charge=2,
                          mass=4,
                          coordinates=(-0.98781, 0.41551, 0.00000))
     self.nuclei_array_he = [helium_1]
     self.molecule_factory = MoleculeFactory(symmetry=True)
    def setUp(self):
        nitrogen_1 = MagicMock(element='NITROGEN',
                               charge=7,
                               mass=14,
                               coordinates=(0.0000000000, 0.0000000000,
                                            1.0399092291))
        nitrogen_2 = MagicMock(element='NITROGEN',
                               charge=7,
                               mass=14,
                               coordinates=(0.0000000000, 0.0000000000,
                                            -1.0399092291))

        self.nuclei_array_n2 = [nitrogen_1, nitrogen_2]
        self.molecule_factory = MoleculeFactory(symmetry=True)
        self.symmetry_factory = SymmetryFactory()
Exemple #6
0
    def setUp(self):
        carbon_1 = MagicMock(element='CARBON', charge=6, mass=12, coordinates=(-0.5297, 0.0100, -0.5606))
        carbon_2 = MagicMock(element='CARBON', charge=6, mass=12, coordinates=(0.5297, -0.0100, 0.5606))
        hydrogen_1 = MagicMock(element='HYDROGEN', charge=1, mass=1, coordinates=(-0.1452, 0.5058, -1.4448))
        hydrogen_2 = MagicMock(element='HYDROGEN', charge=1, mass=1, coordinates=(-1.4207, 0.5374, -0.2390))
        hydrogen_3 = MagicMock(element='HYDROGEN', charge=1, mass=1, coordinates=(-0.8163, -0.9984, -0.8374))
        hydrogen_4 = MagicMock(element='HYDROGEN', charge=1, mass=1, coordinates=(0.1452, -0.5058, 1.4448))
        hydrogen_5 = MagicMock(element='HYDROGEN', charge=1, mass=1, coordinates=(0.8163, 0.9984, 0.8374))
        hydrogen_6 = MagicMock(element='HYDROGEN', charge=1, mass=1, coordinates=(1.4207, -0.5374, 0.2390))

        self.nuclei_array_c2h6 = [
            carbon_1, carbon_2, hydrogen_1, hydrogen_2, hydrogen_3, hydrogen_4, hydrogen_5, hydrogen_6
        ]
        self.molecule_factory = MoleculeFactory(symmetry=True)
        self.symmetry_factory = SymmetryFactory()
Exemple #7
0
def start(mol_file,
          basis_file,
          method,
          processors,
          symmetry=False,
          geometry_optimization=None):
    np.set_printoptions(linewidth=100000, threshold=np.inf)
    start_time = time.clock()

    nuclei_list, electrons, multiplicity = read_mol_file(mol_file)
    energy_object = Energy(electrons, multiplicity, processors, method)

    print(
        '\n*************************************************************************************************'
    )
    print('\nA BASIC QUANTUM CHEMICAL PROGRAM IN PYTHON\n\n\n{}'.format(
        [x.element for x in nuclei_list]))

    if geometry_optimization is not None:
        nelder_mead = NelderMead(basis_file, energy_object, nuclei_list)
        energy = nelder_mead.optimize()
    else:
        nuclei_list, point_group = MoleculeFactory(symmetry).create(
            nuclei_list)
        basis_set = read_basis_set_file(basis_file, nuclei_list)
        energy_object.symmetry_object = Symmetry(point_group, basis_set)
        energy = energy_object.calculate_energy(nuclei_list, basis_set)

    print(
        '\n*************************************************************************************************'
    )
    print('\nTIME TAKEN: ' + str(time.clock() - start_time) + 's')
    print("\nWhat I cannot create I cannot understand - Richard Feynman\n")

    return energy
class TestSymmetryHe(TestCase):
    def setUp(self):
        helium_1 = MagicMock(element='HELIUM',
                             charge=2,
                             mass=4,
                             coordinates=(-0.98781, 0.41551, 0.00000))
        self.nuclei_array_he = [helium_1]
        self.molecule_factory = MoleculeFactory(symmetry=True)

    def test_move_nuclei_to_the_origin(self):
        helium = self.molecule_factory.create(self.nuclei_array_he)[0][0]
        testing.assert_array_equal(helium.coordinates, (0.0, 0.0, 0.0))

    # O_{h} to speed up integral evaluation
    def test_point_group_returns_D_4h_symmetry_for_helium(self):
        symmetry = self.molecule_factory.create(self.nuclei_array_he)[1].label
        testing.assert_equal(symmetry, 'O_{h}')
 def setUp(self):
     particle_1 = MagicMock(element='HYDROGEN',
                            charge=1,
                            mass=1,
                            coordinates=(0.4391356726, 0.1106588251,
                                         -0.4635601962))
     particle_2 = MagicMock(element='HYDROGEN',
                            charge=1,
                            mass=1,
                            coordinates=(-0.5185079933, 0.3850176090,
                                         0.0537084789))
     particle_3 = MagicMock(element='HYDROGEN',
                            charge=1,
                            mass=1,
                            coordinates=(0.0793723207, -0.4956764341,
                                         0.4098517173))
     self.nuclei_array = [particle_1, particle_2, particle_3]
     self.molecule_factory = MoleculeFactory(symmetry=True)
     self.symmetry_factory = SymmetryFactory()
Exemple #10
0
    def setUp(self):
        oxygen_1 = MagicMock(element='OXYGEN',
                             charge=8,
                             mass=16,
                             coordinates=(0.0000000000, 0.0000000000,
                                          -0.1363928482))
        hydrogen_1 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(0.0000000000, 1.4236595095,
                                            0.9813433754))
        hydrogen_2 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(0.0000000000, -1.4236595095,
                                            0.9813433754))

        self.nuclei_array_h2o = [oxygen_1, hydrogen_1, hydrogen_2]
        self.molecule_factory = MoleculeFactory(symmetry=True)
        self.symmetry_factory = SymmetryFactory()
Exemple #11
0
    def setUp(self):
        nitrogen_1 = MagicMock(element='NITROGEN',
                               charge=7,
                               mass=14,
                               coordinates=(0.0000000000, 0.0000000000,
                                            -2.2684205883))
        nitrogen_2 = MagicMock(element='NITROGEN',
                               charge=7,
                               mass=14,
                               coordinates=(0.0000000000, 0.0000000000,
                                            -0.1349300877))
        oxygen_1 = MagicMock(element='OXYGEN',
                             charge=8,
                             mass=16,
                             coordinates=(0.0000000000, 0.0000000000,
                                          2.1042369647))

        self.nuclei_array_n2o = [nitrogen_1, nitrogen_2, oxygen_1]
        self.molecule_factory = MoleculeFactory(symmetry=True)
        self.symmetry_factory = SymmetryFactory()
    def setUp(self):
        oxygen_1 = MagicMock(element='OXYGEN',
                             charge=8,
                             mass=16,
                             coordinates=(-1.4186923158, 0.1090030362,
                                          0.0000000000))
        hydrogen_1 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(-1.7313653816, -1.6895740638,
                                            0.0000000000))
        fluorine_1 = MagicMock(element='FLUORINE',
                               charge=9,
                               mass=19,
                               coordinates=(1.2899273141, 0.0031592817,
                                            0.0000000000))

        self.nuclei_array_hof = [oxygen_1, hydrogen_1, fluorine_1]
        self.molecule_factory = MoleculeFactory(symmetry=True)
        self.symmetry_factory = SymmetryFactory()
    def setUp(self):
        carbon_1 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(0.7516, -0.0225, -0.0209))
        carbon_2 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(-0.7516, 0.0225, 0.0209))
        hydrogen_1 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(1.1851, -0.0039, 0.9875))
        hydrogen_2 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(1.1669, 0.8330, -0.5693))
        hydrogen_3 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(1.1155, -0.9329, -0.5145))
        hydrogen_4 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(-1.1669, -0.8334, 0.5687))
        hydrogen_5 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(-1.1157, 0.9326, 0.5151))
        hydrogen_6 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(-1.1850, 0.0044, -0.9875))

        self.nuclei_array_c2h6 = [
            carbon_1, carbon_2, hydrogen_1, hydrogen_2, hydrogen_3, hydrogen_4,
            hydrogen_5, hydrogen_6
        ]
        self.molecule_factory = MoleculeFactory(symmetry=True)
        self.symmetry_factory = SymmetryFactory()
    def setUp(self):
        carbon_1 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(0.0000000000, 1.2594652672,
                                          0.0000000000))
        carbon_2 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(0.0000000000, -1.2594652672,
                                          0.0000000000))
        hydrogen_1 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(1.7400646600, 2.3216269636,
                                            0.0000000000))
        hydrogen_2 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(-1.7400646600, 2.3216269636,
                                            0.0000000000))
        hydrogen_3 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(1.7400646600, -2.3216269636,
                                            0.0000000000))
        hydrogen_4 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(-1.7400646600, -2.3216269636,
                                            0.0000000000))

        self.nuclei_array_c2h4 = [
            carbon_1, carbon_2, hydrogen_1, hydrogen_2, hydrogen_3, hydrogen_4
        ]
        self.molecule_factory = MoleculeFactory(symmetry=True)
        self.symmetry_factory = SymmetryFactory()
class TestSymmetryD3H(TestCase):
    def setUp(self):
        particle_1 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(0.4391356726, 0.1106588251,
                                            -0.4635601962))
        particle_2 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(-0.5185079933, 0.3850176090,
                                            0.0537084789))
        particle_3 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(0.0793723207, -0.4956764341,
                                            0.4098517173))
        self.nuclei_array = [particle_1, particle_2, particle_3]
        self.molecule_factory = MoleculeFactory(symmetry=True)
        self.symmetry_factory = SymmetryFactory()

    def test_point_group_returns_d_3h_symmetry_for_system(self):
        symmetry = self.molecule_factory.create(self.nuclei_array)[1].label
        testing.assert_equal(symmetry, 'D_{3h}')
Exemple #16
0
class TestSymmetryH2O(TestCase):
    def setUp(self):
        oxygen_1 = MagicMock(element='OXYGEN',
                             charge=8,
                             mass=16,
                             coordinates=(0.0000000000, 0.0000000000,
                                          -0.1363928482))
        hydrogen_1 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(0.0000000000, 1.4236595095,
                                            0.9813433754))
        hydrogen_2 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(0.0000000000, -1.4236595095,
                                            0.9813433754))

        self.nuclei_array_h2o = [oxygen_1, hydrogen_1, hydrogen_2]
        self.molecule_factory = MoleculeFactory(symmetry=True)
        self.symmetry_factory = SymmetryFactory()

    def test_brute_force_rotation_symmetry_returns_list_of_one_axis_of_rotations(
            self):
        nuclei_array = self.molecule_factory.center_molecule(
            self.nuclei_array_h2o)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(
            nuclei_array)
        self.assertEqual(len(rotation), 1)

    def test_brute_force_rotation_symmetry_returns_axis_of_rotation_of_two_fold_symmetry(
            self):
        nuclei_array = self.molecule_factory.center_molecule(
            self.nuclei_array_h2o)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(
            nuclei_array)
        self.assertEqual(rotation[0].fold, 2)

    def test_brute_force_reflection_symmetry_returns_list_of_two_reflection_planes(
            self):
        nuclei_array = self.molecule_factory.center_molecule(
            self.nuclei_array_h2o)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(
            nuclei_array)
        self.assertEqual(len(reflection), 2)

    def test_check_linear_returns_false(self):
        nuclei_array = self.molecule_factory.center_molecule(
            self.nuclei_array_h2o)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(
            nuclei_array)
        self.molecule_factory.standard_orientation(nuclei_array, rotation,
                                                   reflection)
        boolean = self.molecule_factory.check_linear(nuclei_array)
        self.assertEqual(boolean, False)

    def test_check_high_symmetry_returns_false(self):
        nuclei_array = self.molecule_factory.center_molecule(
            self.nuclei_array_h2o)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(
            nuclei_array)
        self.molecule_factory.standard_orientation(nuclei_array, rotation,
                                                   reflection)
        boolean = self.molecule_factory.check_high_symmetry(rotation)
        self.assertEqual(boolean, False)

    def test_get_n_fold_returns_two(self):
        nuclei_array = self.molecule_factory.center_molecule(
            self.nuclei_array_h2o)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(
            nuclei_array)
        self.molecule_factory.standard_orientation(nuclei_array, rotation,
                                                   reflection)
        n = self.molecule_factory.return_principal_axis(rotation).fold
        self.assertEqual(n, 2)

    def test_check_n_two_fold_rotation_perpendicular_to_n_fold_returns_false(
            self):
        nuclei_array = self.molecule_factory.center_molecule(
            self.nuclei_array_h2o)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(
            nuclei_array)
        self.molecule_factory.standard_orientation(nuclei_array, rotation,
                                                   reflection)
        boolean = self.molecule_factory.check_n_two_fold_perpendicular_to_n_fold(
            rotation)
        self.assertEqual(boolean, False)

    def test_check_sigma_h_returns_false(self):
        nuclei_array = self.molecule_factory.center_molecule(
            self.nuclei_array_h2o)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(
            nuclei_array)
        self.molecule_factory.standard_orientation(nuclei_array, rotation,
                                                   reflection)
        boolean = self.molecule_factory.check_sigma_h(reflection)
        self.assertEqual(boolean, False)

    def test_check_n_sigma_v_returns_true(self):
        nuclei_array = self.molecule_factory.center_molecule(
            self.nuclei_array_h2o)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(
            nuclei_array)
        self.molecule_factory.standard_orientation(nuclei_array, rotation,
                                                   reflection)
        boolean = self.molecule_factory.check_n_sigma_v(2, reflection)
        self.assertEqual(boolean, True)

    def test_point_group_returns_c_2v_symmetry_for_water(self):
        symmetry = self.molecule_factory.create(self.nuclei_array_h2o)[1].label
        testing.assert_equal(symmetry, 'C_{2v}')
class TestSymmetryC2H4(TestCase):
    def setUp(self):
        carbon_1 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(0.0000000000, 1.2594652672,
                                          0.0000000000))
        carbon_2 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(0.0000000000, -1.2594652672,
                                          0.0000000000))
        hydrogen_1 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(1.7400646600, 2.3216269636,
                                            0.0000000000))
        hydrogen_2 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(-1.7400646600, 2.3216269636,
                                            0.0000000000))
        hydrogen_3 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(1.7400646600, -2.3216269636,
                                            0.0000000000))
        hydrogen_4 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(-1.7400646600, -2.3216269636,
                                            0.0000000000))

        self.nuclei_array_c2h4 = [
            carbon_1, carbon_2, hydrogen_1, hydrogen_2, hydrogen_3, hydrogen_4
        ]
        self.molecule_factory = MoleculeFactory(symmetry=True)
        self.symmetry_factory = SymmetryFactory()

    def test_brute_force_rotation_symmetry_returns_list_of_three_axis_of_rotations(
            self):
        nuclei_array = self.molecule_factory.center_molecule(
            self.nuclei_array_c2h4)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(
            nuclei_array)
        self.assertEqual(len(rotation), 3)

    def test_brute_force_reflection_symmetry_returns_list_of_three_reflection_planes(
            self):
        nuclei_array = self.molecule_factory.center_molecule(
            self.nuclei_array_c2h4)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(
            nuclei_array)
        self.assertEqual(len(reflection), 3)

    def test_check_linear_returns_false(self):
        nuclei_array = self.molecule_factory.center_molecule(
            self.nuclei_array_c2h4)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(
            nuclei_array)
        self.molecule_factory.standard_orientation(nuclei_array, rotation,
                                                   reflection)
        boolean = self.molecule_factory.check_linear(nuclei_array)
        self.assertEqual(boolean, False)

    def test_check_high_symmetry_returns_false(self):
        nuclei_array = self.molecule_factory.center_molecule(
            self.nuclei_array_c2h4)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(
            nuclei_array)
        self.molecule_factory.standard_orientation(nuclei_array, rotation,
                                                   reflection)
        boolean = self.molecule_factory.check_high_symmetry(rotation)
        self.assertEqual(boolean, False)

    def test_check_n_two_fold_rotation_perpendicular_to_n_fold_returns_true(
            self):
        nuclei_array = self.molecule_factory.center_molecule(
            self.nuclei_array_c2h4)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(
            nuclei_array)
        self.molecule_factory.standard_orientation(nuclei_array, rotation,
                                                   reflection)
        boolean = self.molecule_factory.check_n_two_fold_perpendicular_to_n_fold(
            rotation)
        self.assertEqual(boolean, True)

    def test_check_sigma_h_returns_true(self):
        nuclei_array = self.molecule_factory.center_molecule(
            self.nuclei_array_c2h4)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(
            nuclei_array)
        self.molecule_factory.standard_orientation(nuclei_array, rotation,
                                                   reflection)
        boolean = self.molecule_factory.check_sigma_h(reflection)
        self.assertEqual(boolean, True)

    def test_point_group_returns_d_2h_symmetry_for_ethene(self):
        symmetry = self.molecule_factory.create(
            self.nuclei_array_c2h4)[1].label
        testing.assert_equal(symmetry, 'D_{2h}')
    def setUp(self):
        carbon_1 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(1.2455, 0.5367, -0.0729))
        carbon_2 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(0.9239, -0.9952, 0.0237))
        carbon_3 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(-0.1226, -0.7041, 1.1548))
        carbon_4 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(0.1989, 0.8277, 1.0582))
        carbon_5 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(0.1226, 0.7042, -1.1548))
        carbon_6 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(-0.9239, 0.9952, -0.0237))
        carbon_7 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(-1.2454, -0.5367, 0.0729))
        carbon_8 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(-0.1989, -0.8277, -1.0582))
        hydrogen_1 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(2.2431, 0.9666, -0.1313))
        hydrogen_2 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(1.6638, -1.7924, 0.0426))
        hydrogen_3 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(-0.2209, -1.2683, 2.0797))
        hydrogen_4 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(0.3583, 1.4907, 1.9059))
        hydrogen_5 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(0.2208, 1.2681, -2.0799))
        hydrogen_6 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(-1.6640, 1.7922, -0.0427))
        hydrogen_7 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(-2.2430, -0.9665, 0.1313))
        hydrogen_8 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(-0.3583, -1.4906, -1.9058))

        self.nuclei_array_c8h8 = [
            carbon_1, carbon_2, carbon_3, carbon_4, carbon_5, carbon_6,
            carbon_7, carbon_8, hydrogen_1, hydrogen_2, hydrogen_3, hydrogen_4,
            hydrogen_5, hydrogen_6, hydrogen_7, hydrogen_8
        ]
        self.molecule_factory = MoleculeFactory(symmetry=True)
        self.symmetry_factory = SymmetryFactory()
        self.inversion_symmetry = InversionSymmetry()
class TestSymmetryC8H8(TestCase):
    def setUp(self):
        carbon_1 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(1.2455, 0.5367, -0.0729))
        carbon_2 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(0.9239, -0.9952, 0.0237))
        carbon_3 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(-0.1226, -0.7041, 1.1548))
        carbon_4 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(0.1989, 0.8277, 1.0582))
        carbon_5 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(0.1226, 0.7042, -1.1548))
        carbon_6 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(-0.9239, 0.9952, -0.0237))
        carbon_7 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(-1.2454, -0.5367, 0.0729))
        carbon_8 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(-0.1989, -0.8277, -1.0582))
        hydrogen_1 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(2.2431, 0.9666, -0.1313))
        hydrogen_2 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(1.6638, -1.7924, 0.0426))
        hydrogen_3 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(-0.2209, -1.2683, 2.0797))
        hydrogen_4 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(0.3583, 1.4907, 1.9059))
        hydrogen_5 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(0.2208, 1.2681, -2.0799))
        hydrogen_6 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(-1.6640, 1.7922, -0.0427))
        hydrogen_7 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(-2.2430, -0.9665, 0.1313))
        hydrogen_8 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(-0.3583, -1.4906, -1.9058))

        self.nuclei_array_c8h8 = [
            carbon_1, carbon_2, carbon_3, carbon_4, carbon_5, carbon_6,
            carbon_7, carbon_8, hydrogen_1, hydrogen_2, hydrogen_3, hydrogen_4,
            hydrogen_5, hydrogen_6, hydrogen_7, hydrogen_8
        ]
        self.molecule_factory = MoleculeFactory(symmetry=True)
        self.symmetry_factory = SymmetryFactory()
        self.inversion_symmetry = InversionSymmetry()

    def test_check_linear_returns_false(self):
        nuclei_array = self.molecule_factory.center_molecule(
            self.nuclei_array_c8h8)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(
            nuclei_array)
        self.molecule_factory.standard_orientation(nuclei_array, rotation,
                                                   reflection)
        boolean = self.molecule_factory.check_linear(nuclei_array)
        self.assertEqual(boolean, False)

    def test_check_high_symmetry_returns_true(self):
        nuclei_array = self.molecule_factory.center_molecule(
            self.nuclei_array_c8h8)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(
            nuclei_array)
        self.molecule_factory.standard_orientation(nuclei_array, rotation,
                                                   reflection)
        boolean = self.molecule_factory.check_high_symmetry(rotation)
        self.assertEqual(boolean, True)

    def test_point_group_returns_o_h_symmetry_for_cubane(self):
        symmetry = self.molecule_factory.create(
            self.nuclei_array_c8h8)[1].label
        testing.assert_equal(symmetry, 'O_{h}')
class TestSymmetryCH4(TestCase):
    def setUp(self):
        carbon_1 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(-0.98781, 0.41551, 0.00000))
        hydrogen_1 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(0.08219, 0.41551, 0.00000))
        hydrogen_2 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(-1.34447, 0.70319, -0.96692))
        hydrogen_3 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(-1.34448, 1.10904, 0.73260))
        hydrogen_4 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(-1.34448, -0.56571, 0.23432))
        self.nuclei_array_ch4 = [
            carbon_1, hydrogen_1, hydrogen_2, hydrogen_3, hydrogen_4
        ]
        self.molecule_factory = MoleculeFactory(symmetry=True)
        self.symmetry_factory = SymmetryFactory()

    def test_center_molecule_changes_to_carbon_1_at_origin(self):
        carbon_1 = self.molecule_factory.center_molecule(
            self.nuclei_array_ch4)[0]
        testing.assert_array_almost_equal(carbon_1.coordinates,
                                          (0.0, 0.0, 0.0), 6)

    def test_center_molecule_changes_to_hydrogen_1(self):
        hydrogen_1 = self.molecule_factory.center_molecule(
            self.nuclei_array_ch4)[1]
        testing.assert_array_almost_equal(hydrogen_1.coordinates,
                                          (1.07, 0.0, 0.0), 6)

    def test_center_molecule_changes_to_hydrogen_2(self):
        hydrogen_2 = self.molecule_factory.center_molecule(
            self.nuclei_array_ch4)[2]
        testing.assert_array_almost_equal(hydrogen_2.coordinates,
                                          (-0.35666, 0.28768, -0.96692), 6)

    def test_center_molecule_changes_to_hydrogen_3(self):
        hydrogen_3 = self.molecule_factory.center_molecule(
            self.nuclei_array_ch4)[3]
        testing.assert_array_almost_equal(hydrogen_3.coordinates,
                                          (-0.35667, 0.69353, 0.73260), 6)

    def test_center_molecule_changes_to_hydrogen_4(self):
        hydrogen_4 = self.molecule_factory.center_molecule(
            self.nuclei_array_ch4)[4]
        testing.assert_array_almost_equal(hydrogen_4.coordinates,
                                          (-0.35667, -0.98122, 0.23432), 6)

    def test_brute_force_rotation_symmetry_returns_list_of_seven_axis_of_rotations(
            self):
        nuclei_array = self.molecule_factory.center_molecule(
            self.nuclei_array_ch4)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(
            nuclei_array)
        self.assertEqual(len(rotation), 7)

    def test_brute_force_rotation_symmetry_returns_list_of_four_axis_of_rotations_with_n_three(
            self):
        nuclei_array = self.molecule_factory.center_molecule(
            self.nuclei_array_ch4)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(
            nuclei_array)
        self.assertEqual([symmetry.fold for symmetry in rotation].count(3), 4)

    def test_brute_force_rotation_symmetry_returns_list_of_four_axis_of_rotations_with_n_two(
            self):
        nuclei_array = self.molecule_factory.center_molecule(
            self.nuclei_array_ch4)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(
            nuclei_array)
        self.assertEqual([symmetry.fold for symmetry in rotation].count(2), 3)

    def test_brute_force_reflection_symmetry_returns_a_list_of_six_reflection_planes(
            self):
        nuclei_array = self.molecule_factory.center_molecule(
            self.nuclei_array_ch4)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(
            nuclei_array)
        self.assertEqual(len(reflection), 6)

    def test_check_linear_returns_false(self):
        nuclei_array = self.molecule_factory.center_molecule(
            self.nuclei_array_ch4)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(
            nuclei_array)
        self.molecule_factory.standard_orientation(nuclei_array, rotation,
                                                   reflection)
        boolean = self.molecule_factory.check_linear(nuclei_array)
        self.assertEqual(boolean, False)

    def test_check_high_symmetry_returns_true(self):
        nuclei_array = self.molecule_factory.center_molecule(
            self.nuclei_array_ch4)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(
            nuclei_array)
        self.molecule_factory.standard_orientation(nuclei_array, rotation,
                                                   reflection)
        boolean = self.molecule_factory.check_high_symmetry(rotation)
        self.assertEqual(boolean, True)

    def test_point_group_returns_t_d_symmetry_for_methane(self):
        symmetry = self.molecule_factory.create(self.nuclei_array_ch4)[1].label
        testing.assert_equal(symmetry, 'T_{d}')
class TestSymmetryHOF(TestCase):
    def setUp(self):
        oxygen_1 = MagicMock(element='OXYGEN',
                             charge=8,
                             mass=16,
                             coordinates=(-1.4186923158, 0.1090030362,
                                          0.0000000000))
        hydrogen_1 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(-1.7313653816, -1.6895740638,
                                            0.0000000000))
        fluorine_1 = MagicMock(element='FLUORINE',
                               charge=9,
                               mass=19,
                               coordinates=(1.2899273141, 0.0031592817,
                                            0.0000000000))

        self.nuclei_array_hof = [oxygen_1, hydrogen_1, fluorine_1]
        self.molecule_factory = MoleculeFactory(symmetry=True)
        self.symmetry_factory = SymmetryFactory()

    def test_brute_force_rotation_symmetry_returns_list_of_zero_axis_of_rotations(
            self):
        nuclei_array = self.molecule_factory.center_molecule(
            self.nuclei_array_hof)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(
            nuclei_array)
        self.assertEqual(len(rotation), 0)

    def test_brute_force_reflection_symmetry_returns_list_of_one_reflection_planes(
            self):
        nuclei_array = self.molecule_factory.center_molecule(
            self.nuclei_array_hof)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(
            nuclei_array)
        self.assertEqual(len(reflection), 1)

    def test_check_linear_returns_false(self):
        nuclei_array = self.molecule_factory.center_molecule(
            self.nuclei_array_hof)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(
            nuclei_array)
        self.molecule_factory.standard_orientation(nuclei_array, rotation,
                                                   reflection)
        boolean = self.molecule_factory.check_linear(nuclei_array)
        self.assertEqual(boolean, False)

    def test_check_high_symmetry_returns_false(self):
        nuclei_array = self.molecule_factory.center_molecule(
            self.nuclei_array_hof)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(
            nuclei_array)
        self.molecule_factory.standard_orientation(nuclei_array, rotation,
                                                   reflection)
        boolean = self.molecule_factory.check_high_symmetry(rotation)
        self.assertEqual(boolean, False)

    def test_check_sigma_h_returns_true(self):
        nuclei_array = self.molecule_factory.center_molecule(
            self.nuclei_array_hof)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(
            nuclei_array)
        self.molecule_factory.standard_orientation(nuclei_array, rotation,
                                                   reflection)
        boolean = self.molecule_factory.check_sigma_h(reflection)
        self.assertEqual(boolean, True)

    def test_point_group_returns_c_s_symmetry_for_hypofluorous_acid(self):
        symmetry = self.molecule_factory.create(self.nuclei_array_hof)[1].label
        testing.assert_equal(symmetry, 'C_{s}')
Exemple #22
0
class TestSymmetryFerrocene(TestCase):
    def setUp(self):
        carbon_1 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(0.99234, 0.72098, -1.73785))
        carbon_2 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(0.99234, -0.72098, -1.73785))
        carbon_3 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(-0.37904, -1.16657, -1.73785))
        carbon_4 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(-1.22660, 0.00000, -1.73785))
        carbon_5 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(-0.37904, 1.16657, -1.73785))
        hydrogen_1 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(1.86677, 1.35629, -1.73016))
        hydrogen_2 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(1.86677, -1.35629, -1.73016))
        hydrogen_3 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(-0.71304, -2.19452, -1.73016))
        hydrogen_4 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(-2.30745, 0.00000, -1.73016))
        hydrogen_5 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(-0.71304, 2.19452, -1.73016))
        iron_1 = MagicMock(element='IRON',
                           charge=26,
                           mass=56,
                           coordinates=(-0.00000, -0.00000, -0.00000))
        carbon_6 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(-0.99234, -0.72098, 1.73785))
        carbon_7 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(-0.99234, 0.72098, 1.73785))
        carbon_8 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(0.37904, 1.16657, 1.73785))
        carbon_9 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(1.22660, -0.00000, 1.73785))
        carbon_10 = MagicMock(element='CARBON',
                              charge=6,
                              mass=12,
                              coordinates=(0.37904, -1.16657, 1.73785))
        hydrogen_6 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(-1.86677, -1.35629, 1.73016))
        hydrogen_7 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(-1.86677, 1.35629, 1.73016))
        hydrogen_8 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(0.71304, 2.19452, 1.73016))
        hydrogen_9 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(2.30745, -0.00000, 1.73016))
        hydrogen_10 = MagicMock(element='HYDROGEN',
                                charge=1,
                                mass=1,
                                coordinates=(0.71304, -2.19452, 1.73016))

        self.nuclei_array_ferrocene = [
            carbon_1, carbon_2, carbon_3, carbon_4, carbon_5, carbon_6,
            carbon_7, carbon_8, carbon_9, carbon_10, hydrogen_1, hydrogen_2,
            hydrogen_3, hydrogen_4, hydrogen_5, hydrogen_6, hydrogen_7,
            hydrogen_8, hydrogen_9, hydrogen_10, iron_1
        ]
        self.molecule_factory = MoleculeFactory(symmetry=True)

    def test_point_group_returns_d_5d_symmetry_for_cubane(self):
        symmetry = self.molecule_factory.create(
            self.nuclei_array_ferrocene)[1].label
        testing.assert_equal(symmetry, 'D_{5d}')
Exemple #23
0
class TestSymmetryC2H6(TestCase):

    def setUp(self):
        carbon_1 = MagicMock(element='CARBON', charge=6, mass=12, coordinates=(-0.5297, 0.0100, -0.5606))
        carbon_2 = MagicMock(element='CARBON', charge=6, mass=12, coordinates=(0.5297, -0.0100, 0.5606))
        hydrogen_1 = MagicMock(element='HYDROGEN', charge=1, mass=1, coordinates=(-0.1452, 0.5058, -1.4448))
        hydrogen_2 = MagicMock(element='HYDROGEN', charge=1, mass=1, coordinates=(-1.4207, 0.5374, -0.2390))
        hydrogen_3 = MagicMock(element='HYDROGEN', charge=1, mass=1, coordinates=(-0.8163, -0.9984, -0.8374))
        hydrogen_4 = MagicMock(element='HYDROGEN', charge=1, mass=1, coordinates=(0.1452, -0.5058, 1.4448))
        hydrogen_5 = MagicMock(element='HYDROGEN', charge=1, mass=1, coordinates=(0.8163, 0.9984, 0.8374))
        hydrogen_6 = MagicMock(element='HYDROGEN', charge=1, mass=1, coordinates=(1.4207, -0.5374, 0.2390))

        self.nuclei_array_c2h6 = [
            carbon_1, carbon_2, hydrogen_1, hydrogen_2, hydrogen_3, hydrogen_4, hydrogen_5, hydrogen_6
        ]
        self.molecule_factory = MoleculeFactory(symmetry=True)
        self.symmetry_factory = SymmetryFactory()

    def test_check_linear_returns_false(self):
        nuclei_array = self.molecule_factory.center_molecule(self.nuclei_array_c2h6)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(nuclei_array)
        self.molecule_factory.standard_orientation(nuclei_array, rotation, reflection)
        boolean = self.molecule_factory.check_linear(nuclei_array)
        self.assertEqual(boolean, False)

    def test_check_high_symmetry_returns_false(self):
        nuclei_array = self.molecule_factory.center_molecule(self.nuclei_array_c2h6)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(nuclei_array)
        self.molecule_factory.standard_orientation(nuclei_array, rotation, reflection)
        boolean = self.molecule_factory.check_high_symmetry(rotation)
        self.assertEqual(boolean, False)

    def test_check_n_two_fold_rotation_perpendicular_to_n_fold_returns_true(self):
        nuclei_array = self.molecule_factory.center_molecule(self.nuclei_array_c2h6)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(nuclei_array)
        self.molecule_factory.standard_orientation(nuclei_array, rotation, reflection)
        boolean = self.molecule_factory.check_n_two_fold_perpendicular_to_n_fold(rotation)
        self.assertEqual(boolean, True)

    def test_check_sigma_h_returns_false(self):
        nuclei_array = self.molecule_factory.center_molecule(self.nuclei_array_c2h6)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(nuclei_array)
        self.molecule_factory.standard_orientation(nuclei_array, rotation, reflection)
        boolean = self.molecule_factory.check_sigma_h(reflection)
        self.assertEqual(boolean, False)

    def test_check_n_sigma_v_returns_true(self):
        nuclei_array = self.molecule_factory.center_molecule(self.nuclei_array_c2h6)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(nuclei_array)
        self.molecule_factory.standard_orientation(nuclei_array, rotation, reflection)
        boolean = self.molecule_factory.check_n_sigma_v(3, reflection)
        self.assertEqual(boolean, True)

    def test_point_group_returns_d_3d_symmetry_for_cubane(self):
        symmetry = self.molecule_factory.create(self.nuclei_array_c2h6)[1].label
        testing.assert_equal(symmetry, 'D_{3d}')
Exemple #24
0
    def setUp(self):
        carbon_1 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(0.99234, 0.72098, -1.73785))
        carbon_2 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(0.99234, -0.72098, -1.73785))
        carbon_3 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(-0.37904, -1.16657, -1.73785))
        carbon_4 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(-1.22660, 0.00000, -1.73785))
        carbon_5 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(-0.37904, 1.16657, -1.73785))
        hydrogen_1 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(1.86677, 1.35629, -1.73016))
        hydrogen_2 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(1.86677, -1.35629, -1.73016))
        hydrogen_3 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(-0.71304, -2.19452, -1.73016))
        hydrogen_4 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(-2.30745, 0.00000, -1.73016))
        hydrogen_5 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(-0.71304, 2.19452, -1.73016))
        iron_1 = MagicMock(element='IRON',
                           charge=26,
                           mass=56,
                           coordinates=(-0.00000, -0.00000, -0.00000))
        carbon_6 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(-0.99234, -0.72098, 1.73785))
        carbon_7 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(-0.99234, 0.72098, 1.73785))
        carbon_8 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(0.37904, 1.16657, 1.73785))
        carbon_9 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(1.22660, -0.00000, 1.73785))
        carbon_10 = MagicMock(element='CARBON',
                              charge=6,
                              mass=12,
                              coordinates=(0.37904, -1.16657, 1.73785))
        hydrogen_6 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(-1.86677, -1.35629, 1.73016))
        hydrogen_7 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(-1.86677, 1.35629, 1.73016))
        hydrogen_8 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(0.71304, 2.19452, 1.73016))
        hydrogen_9 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(2.30745, -0.00000, 1.73016))
        hydrogen_10 = MagicMock(element='HYDROGEN',
                                charge=1,
                                mass=1,
                                coordinates=(0.71304, -2.19452, 1.73016))

        self.nuclei_array_ferrocene = [
            carbon_1, carbon_2, carbon_3, carbon_4, carbon_5, carbon_6,
            carbon_7, carbon_8, carbon_9, carbon_10, hydrogen_1, hydrogen_2,
            hydrogen_3, hydrogen_4, hydrogen_5, hydrogen_6, hydrogen_7,
            hydrogen_8, hydrogen_9, hydrogen_10, iron_1
        ]
        self.molecule_factory = MoleculeFactory(symmetry=True)
class TestSymmetryC2H6(TestCase):
    def setUp(self):
        carbon_1 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(0.7516, -0.0225, -0.0209))
        carbon_2 = MagicMock(element='CARBON',
                             charge=6,
                             mass=12,
                             coordinates=(-0.7516, 0.0225, 0.0209))
        hydrogen_1 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(1.1851, -0.0039, 0.9875))
        hydrogen_2 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(1.1669, 0.8330, -0.5693))
        hydrogen_3 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(1.1155, -0.9329, -0.5145))
        hydrogen_4 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(-1.1669, -0.8334, 0.5687))
        hydrogen_5 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(-1.1157, 0.9326, 0.5151))
        hydrogen_6 = MagicMock(element='HYDROGEN',
                               charge=1,
                               mass=1,
                               coordinates=(-1.1850, 0.0044, -0.9875))

        self.nuclei_array_c2h6 = [
            carbon_1, carbon_2, hydrogen_1, hydrogen_2, hydrogen_3, hydrogen_4,
            hydrogen_5, hydrogen_6
        ]
        self.molecule_factory = MoleculeFactory(symmetry=True)
        self.symmetry_factory = SymmetryFactory()

    def test_check_linear_returns_false(self):
        nuclei_array = self.molecule_factory.center_molecule(
            self.nuclei_array_c2h6)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(
            nuclei_array)
        self.molecule_factory.standard_orientation(nuclei_array, rotation,
                                                   reflection)
        boolean = self.molecule_factory.check_linear(nuclei_array)
        self.assertEqual(boolean, False)

    def test_check_high_symmetry_returns_false(self):
        nuclei_array = self.molecule_factory.center_molecule(
            self.nuclei_array_c2h6)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(
            nuclei_array)
        self.molecule_factory.standard_orientation(nuclei_array, rotation,
                                                   reflection)
        boolean = self.molecule_factory.check_high_symmetry(rotation)
        self.assertEqual(boolean, False)

    def test_check_n_two_fold_rotation_perpendicular_to_n_fold_returns_true(
            self):
        nuclei_array = self.molecule_factory.center_molecule(
            self.nuclei_array_c2h6)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(
            nuclei_array)
        self.molecule_factory.standard_orientation(nuclei_array, rotation,
                                                   reflection)
        boolean = self.molecule_factory.check_n_two_fold_perpendicular_to_n_fold(
            rotation)
        self.assertEqual(boolean, True)

    def test_check_sigma_h_returns_false(self):
        nuclei_array = self.molecule_factory.center_molecule(
            self.nuclei_array_c2h6)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(
            nuclei_array)
        self.molecule_factory.standard_orientation(nuclei_array, rotation,
                                                   reflection)
        boolean = self.molecule_factory.check_sigma_h(reflection)
        self.assertEqual(boolean, False)

    def test_check_n_sigma_v_returns_true(self):
        nuclei_array = self.molecule_factory.center_molecule(
            self.nuclei_array_c2h6)
        rotation, reflection, improper, inversion = self.symmetry_factory.brute_force_symmetry(
            nuclei_array)
        self.molecule_factory.standard_orientation(nuclei_array, rotation,
                                                   reflection)
        boolean = self.molecule_factory.check_n_sigma_v(3, reflection)
        self.assertEqual(boolean, True)

    def test_point_group_returns_d_3d_symmetry_for_cubane(self):
        symmetry = self.molecule_factory.create(
            self.nuclei_array_c2h6)[1].label
        testing.assert_equal(symmetry, 'D_{3d}')