def setUp(self): mu, kappa, rho = sp.rand(3) A10 = mu / 2 A01 = 0 F = sp.rand(3, 3) self.E = 1 / 2 * (F.T @ F - sp.eye(3)) self.mooney = MooneyRivlin(A10, A01, kappa, rho) self.neo = NeoHookean(mu, kappa, rho)
def setUp(self): F = sp.zeros((3, 3)) F[:2, :2] = sp.rand(2, 2) F[2, 2] = 1 self.E = 1 / 2 * (F.T @ F - sp.eye(3)) A10, A01, kappa, rho = sp.rand(4) mu = A10 * 2 self.mooney = MooneyRivlin(A10, A01, kappa, rho, plane_stress=False) self.neo = NeoHookean(mu, kappa, rho, plane_stress=False)
def create_material(material_type='Kirchhoff', **kwargs): if kwargs is None: print( 'No material-parameters were given. I am setting them to default.') else: if material_type is 'Kirchhoff': if 'E' in kwargs: E = kwargs['E'] else: E = 210E9 if 'nu' in kwargs: nu = kwargs['nu'] else: nu = 0.3 if 'rho' in kwargs: rho = kwargs['rho'] else: rho = 7.85E3 if 'plane_stress' in kwargs: plane_stress = kwargs['plane_stress'] else: plane_stress = True if 'thickness' in kwargs: thickness = kwargs['thickness'] else: thickness = 1.0 return KirchhoffMaterial(E, nu, rho, plane_stress, thickness) elif material_type is 'MooneyRivlin': if 'A10' in kwargs: A10 = kwargs['A10'] else: A10 = 0.4E3 if 'A01' in kwargs: A01 = kwargs['A01'] else: A01 = 0.1E3 if 'kappa' in kwargs: kappa = kwargs['kappa'] else: kappa = 1E5 if 'rho' in kwargs: rho = kwargs['rho'] else: rho = 0.94E3 if 'plane_stress' in kwargs: plane_stress = kwargs['plane_stress'] else: plane_stress = True if 'thickness' in kwargs: thickness = kwargs['thickness'] else: thickness = 1.0 return MooneyRivlin(A10, A01, kappa, rho, plane_stress, thickness) else: raise ValueError( 'Unknown material-type given. Please use one of these supported types: \n ', 'Kirchhoff\n', 'MooneyRivlin\n')
class MaterialTest2dPlaneStress(unittest.TestCase): def setUp(self): F = sp.zeros((3, 3)) F[:2, :2] = sp.rand(2, 2) F[2, 2] = 1 self.E = 1 / 2 * (F.T @ F - sp.eye(3)) A10, A01, kappa, rho = sp.rand(4) mu = A10 * 2 self.mooney = MooneyRivlin(A10, A01, kappa, rho, plane_stress=False) self.neo = NeoHookean(mu, kappa, rho, plane_stress=False) def test_mooney_2d(self): E = self.E S, S_v, C = self.mooney.S_Sv_and_C(E) S2d, S_v2d, C2d = self.mooney.S_Sv_and_C_2d(E[:2, :2]) np.testing.assert_allclose(S[:2, :2], S2d) np.testing.assert_allclose(C[np.ix_([0, 1, -1], [0, 1, -1])], C2d) def test_neo_2d(self): E = self.E S, S_v, C = self.neo.S_Sv_and_C(E) S2d, S_v2d, C2d = self.neo.S_Sv_and_C_2d(E[:2, :2]) np.testing.assert_allclose(S[:2, :2], S2d) np.testing.assert_allclose(C[np.ix_([0, 1, -1], [0, 1, -1])], C2d)
class MaterialTest(unittest.TestCase): def setUp(self): mu, kappa, rho = sp.rand(3) A10 = mu / 2 A01 = 0 F = sp.rand(3, 3) self.E = 1 / 2 * (F.T @ F - sp.eye(3)) self.mooney = MooneyRivlin(A10, A01, kappa, rho) self.neo = NeoHookean(mu, kappa, rho) def test_Neo_vs_Mooney_S(self): S_mooney, Sv_mooney, C_mooney = self.mooney.S_Sv_and_C(self.E) S_neo, Sv_neo, C_neo = self.neo.S_Sv_and_C(self.E) np.testing.assert_allclose(S_mooney, S_neo) def test_Neo_vs_Mooney_Sv(self): S_mooney, Sv_mooney, C_mooney = self.mooney.S_Sv_and_C(self.E) S_neo, Sv_neo, C_neo = self.neo.S_Sv_and_C(self.E) np.testing.assert_allclose(Sv_mooney, Sv_neo) def test_Neo_vs_Mooney_C(self): S_mooney, Sv_mooney, C_mooney = self.mooney.S_Sv_and_C(self.E) S_neo, Sv_neo, C_neo = self.neo.S_Sv_and_C(self.E) np.testing.assert_allclose(C_mooney, C_neo)
def test_Mooney(self): A10, A01, kappa, rho = sp.rand(4) * 1E3 + 100 my_material = MooneyRivlin(A10, A01, kappa, rho) self.my_element.material = my_material self.jacobi_test_element(rtol=5E-4)
def test_Mooney(self): A10, A01, kappa, rho = sp.rand(4) * 1E3 + 100 print('Material parameters A10, A01 and kappa:', A10, A01, kappa) my_material = MooneyRivlin(A10, A01, kappa, rho) self.my_element.material = my_material self.jacobi_test_element(rtol=1E-3)