def test_init(self): c2 = NthOrderElasticTensor(self.c2.tolist()) c3 = NthOrderElasticTensor(self.c3.tolist()) c4 = NthOrderElasticTensor(np.zeros([3] * 8)) for n, c in enumerate([c2, c3, c4]): self.assertEqual(c.order, n + 2) self.assertRaises(ValueError, NthOrderElasticTensor, np.zeros([3] * 5))
def setUp(self): with open(os.path.join(test_dir, 'test_toec_data.json')) as f: self.data_dict = json.load(f) self.strains = [Strain(sm) for sm in self.data_dict['strains']] self.pk_stresses = [Stress(d) for d in self.data_dict['pk_stresses']] self.c2 = NthOrderElasticTensor.from_voigt(self.data_dict["C2_raw"]) self.c3 = NthOrderElasticTensor.from_voigt(self.data_dict["C3_raw"])
def setUp(self): with open(os.path.join(PymatgenTest.TEST_FILES_DIR, "test_toec_data.json")) as f: self.data_dict = json.load(f) self.strains = [Strain(sm) for sm in self.data_dict["strains"]] self.pk_stresses = [Stress(d) for d in self.data_dict["pk_stresses"]] self.c2 = NthOrderElasticTensor.from_voigt(self.data_dict["C2_raw"]) self.c3 = NthOrderElasticTensor.from_voigt(self.data_dict["C3_raw"])
def test_from_diff_fit(self): c3 = NthOrderElasticTensor.from_diff_fit( self.strains, self.pk_stresses, eq_stress=self.data_dict["eq_stress"], order=3, ) self.assertArrayAlmostEqual(c3.voigt, self.data_dict["C3_raw"], decimal=2)
def test_from_diff_fit(self): c3 = NthOrderElasticTensor.from_diff_fit(self.strains, self.pk_stresses, eq_stress = self.data_dict["eq_stress"], order=3) self.assertArrayAlmostEqual(c3.voigt, self.data_dict["C3_raw"], decimal=2)