コード例 #1
0
ファイル: testmoments.py プロジェクト: cclib/cclib
    def test_results_storing(self, mock):
        mock.configure_mock(**self.linear_dipole_attrs)
        mock.atomcharges.update({'lowdin': [-0.5, 0.5]})

        m = Moments(mock)
        m.calculate(population='mulliken')
        m.calculate(population='lowdin')

        a, b = m.results['mulliken'][1], m.results['lowdin'][1]
        self.assertFalse(np.array_equal(a, b))
コード例 #2
0
    def test_origin_at_center_of_nuclear_charge(self, mock):
        mock.configure_mock(**self.linear_dipole_attrs)

        x = Moments(mock).calculate()[0]
        assert_equal(x, [0, 0, 0])
コード例 #3
0
    def test_origin_at_center_of_mass(self, mock):
        mock.configure_mock(**self.linear_dipole_attrs)
        mock.atommasses = np.ones(mock.atomcoords.shape[1])

        x = Moments(mock).calculate(origin='mass')[0]
        assert_equal(x, [0, 0, 0])
コード例 #4
0
    def test_invariant_to_origin_dislacement(self, mock):
        mock.configure_mock(**self.linear_dipole_attrs)

        x = Moments(mock).calculate(origin=[0, 0, 0])[1]
        y = Moments(mock).calculate(origin=[1, 1, 1])[1]
        assert_equal(x, y)
コード例 #5
0
    def test_dipole_moment(self, mock):
        mock.configure_mock(**self.linear_dipole_attrs)

        x = Moments(mock).calculate()[1]
        assert_almost_equal(x / 4.80320425, [2, 0, 0])
コード例 #6
0
 def test_not_providing_masses(self, mock):
     mock.configure_mock(**self.linear_dipole_attrs)
     # Replace with the refex version when Python2 is dropped.
     # with self.assertRaisesRegex(ValueError, 'masses'):
     with self.assertRaises(ValueError):
         Moments(mock).calculate(origin='mass')
コード例 #7
0
    def test_user_provided_masses(self, mock):
        mock.configure_mock(**self.linear_dipole_attrs)

        x = Moments(mock).calculate(masses=[1, 3], origin='mass')
        assert_almost_equal(x[0], [0.5, 0, 0])
コード例 #8
0
    def test_user_provided_origin(self, mock):
        mock.configure_mock(**self.linear_dipole_attrs)

        x = Moments(mock).calculate(origin=[1, 1, 1])
        assert_almost_equal(x[0], [1, 1, 1])