def test_init(self): with self.assertRaises(TypeError): LocalFields('a',2,None) with self.assertRaises(ValueError): LocalFields(np.zeros(2),np.zeros(3),np.zeros(3)) with self.assertRaises(ValueError): LocalFields(np.array(['a','a']),np.array(['a','a']),np.array(['a','a'])) lf = LocalFields(np.zeros(3),np.ones(3),2.*np.ones(3)) np.testing.assert_array_equal(lf._BLor,2.*np.ones(3)) np.testing.assert_array_equal(lf._BCont,0.*np.ones(3)) np.testing.assert_array_equal(lf._BDip,np.ones(3)) with self.assertRaises(TypeError): lf.bubu = 1
def test_init(self): with self.assertRaises(TypeError): LocalFields('a', 2, None) with self.assertRaises(ValueError): LocalFields(np.zeros(2), np.zeros(3), np.zeros(3)) with self.assertRaises(ValueError): LocalFields(np.array(['a', 'a']), np.array(['a', 'a']), np.array(['a', 'a'])) lf = LocalFields(np.zeros(3), np.ones(3), 2. * np.ones(3)) np.testing.assert_array_equal(lf._BLor, 2. * np.ones(3)) np.testing.assert_array_equal(lf._BCont, 0. * np.ones(3)) np.testing.assert_array_equal(lf._BDip, np.ones(3)) with self.assertRaises(TypeError): lf.bubu = 1
def test_ACont(self): lf = LocalFields(np.ones(3), 2. * np.ones(3), 3. * np.ones(3)) lf.ACont = -5. self.assertEqual(lf.ACont, -5.) np.testing.assert_array_equal(lf.Total, 0. * np.ones(3)) np.testing.assert_array_equal(lf.C, -5. * np.ones(3))
def test_Total(self): lf = LocalFields(np.ones(3), 2. * np.ones(3), 3. * np.ones(3)) lf.ACont = 3 np.testing.assert_array_equal(lf.Total, 8. * np.ones(3))
def test_T(self): lf = LocalFields(np.ones(3), 2. * np.ones(3), 3. * np.ones(3)) np.testing.assert_array_equal(lf.T, 5. * np.ones(3)) lf.ACont = 2 np.testing.assert_array_equal(lf.T, 7. * np.ones(3))
def test_Lorentz(self): lf = LocalFields(np.ones(3), 2. * np.ones(3), 3. * np.ones(3)) np.testing.assert_array_equal(lf.Lorentz, 3. * np.ones(3))
def test_Contact(self): lf = LocalFields(np.ones(3), 2. * np.ones(3), 3. * np.ones(3)) np.testing.assert_array_equal(lf.Contact, 0. * np.ones(3)) lf.ACont = 1. np.testing.assert_array_equal(lf.Contact, 1. * np.ones(3))
def test_Dipolar(self): lf = LocalFields(np.ones(3), 2. * np.ones(3), 3. * np.ones(3)) np.testing.assert_array_equal(lf.Dipolar, 2. * np.ones(3))
def test_ACont(self): lf = LocalFields(np.ones(3),2.*np.ones(3),3.*np.ones(3)) lf.ACont = -5. self.assertEqual(lf.ACont,-5.) np.testing.assert_array_equal(lf.Total,0.*np.ones(3)) np.testing.assert_array_equal(lf.C,-5.*np.ones(3))
def test_Total(self): lf = LocalFields(np.ones(3),2.*np.ones(3),3.*np.ones(3)) lf.ACont = 3 np.testing.assert_array_equal(lf.Total,8.*np.ones(3))
def test_T(self): lf = LocalFields(np.ones(3),2.*np.ones(3),3.*np.ones(3)) np.testing.assert_array_equal(lf.T,5.*np.ones(3)) lf.ACont = 2 np.testing.assert_array_equal(lf.T,7.*np.ones(3))
def test_Contact(self): lf = LocalFields(np.ones(3),2.*np.ones(3),3.*np.ones(3)) np.testing.assert_array_equal(lf.Contact,0.*np.ones(3)) lf.ACont=1. np.testing.assert_array_equal(lf.Contact,1.*np.ones(3))