[docs]defsetUp(self):self.kappa=100.0self.mu=10.0self.Jm=4.0# pick large enough to avoid singularity in testsproperties={"bulk modulus":self.kappa,"shear modulus":self.mu,"Jm parameter":self.Jm}self.material=Gent.create_material_functions(properties)self.props=Gent.create_material_properties(properties)self.internalVariables=self.material.compute_initial_state()self.dt=0.0
[docs]deftest_frame_indifference(self):# generate a random displacement gradientkey=jax.random.PRNGKey(1)dispGrad=jax.random.uniform(key,(3,3))W=self.material.compute_energy_density(dispGrad,self.internalVariables,self.props,self.dt)foriinrange(10):Q=Rotation.random(random_state=i).as_matrix()dispGradTransformed=Q@(dispGrad+np.identity(3))-np.identity(3)WStar=self.material.compute_energy_density(dispGradTransformed,self.internalVariables,self.props,self.dt)self.assertAlmostEqual(W,WStar,12)
[docs]deftest_finite_extensibility(self):# incompressible uniaxial extension# find stretch such that the strain energy just reaches the singularity.lockStretchCandidates=onp.roots([1.0,0.0,-(self.Jm+3),2.0])lockStretch=onp.max(lockStretchCandidates)stretch=lockStretch*(1+1e-6)# account for finite precision of root finderI1=stretch**2+2/stretchself.assertGreater(I1-3,self.Jm)# Check that energy is indeed infinite# (actually nan, since it produces a negative argument to a logarithm)F=np.diag(np.array([stretch,1/np.sqrt(stretch),1/np.sqrt(stretch)]))W=self.material.compute_energy_density(F-np.identity(3),self.internalVariables,self.props,self.dt)self.assertTrue(np.isnan(W))stretch=lockStretch*(1-1e-6)F=np.diag(np.array([stretch,1/np.sqrt(stretch),1/np.sqrt(stretch)]))W=self.material.compute_energy_density(F-np.identity(3),self.internalVariables,self.props,self.dt)self.assertFalse(np.isnan(W))