@@ -146,3 +146,72 @@ def test_compute_stress(particles, state_vars, element, target, dt):
146146 particles .compute_strain (element , dt )
147147 stress = particles .material .compute_stress (None , particles , state_vars )
148148 assert jnp .allclose (stress , target )
149+
150+
151+ def test_key_not_present_in_material_properties ():
152+ with pytest .raises (KeyError ):
153+ material = Bingham (
154+ {
155+ "density" : 1000 ,
156+ "youngs_modulus" : 1.0e7 ,
157+ "poisson_ratio" : 0.3 ,
158+ "tau0" : 771.8 ,
159+ "critical_shear_rate" : 0.2 ,
160+ "ndim" : 2 ,
161+ }
162+ )
163+
164+
165+ @pytest .mark .parametrize (
166+ "particles, element, target, state_vars" ,
167+ [
168+ (Particles (
169+ jnp .array ([[0.5 , 0.5 , 0.5 , 0.5 ]]).reshape (2 , 1 , 2 ),
170+ (
171+ Bingham (
172+ {
173+ "density" : 1000 ,
174+ "youngs_modulus" : 1.0e7 ,
175+ "poisson_ratio" : 0.3 ,
176+ "tau0" : 200.0 ,
177+ "mu" : 200.0 ,
178+ "critical_shear_rate" : 0.2 ,
179+ "ndim" : 2 ,
180+ }
181+ )
182+ ),
183+ jnp .array ([0 ,0 ]),
184+ ),
185+ Quadrilateral4Node (
186+ (1 , 1 ),
187+ 1 ,
188+ (4.0 , 4.0 ),
189+ [(0 , Constraint (0 , 2.0 )), (0 , Constraint (1 , 3.0 ))],
190+ Nodes (4 , jnp .array ([- 2 , - 2 , 2 , - 2 , - 2 , 2 , 2 , 2 ]).reshape ((4 , 1 , 2 ))),
191+ ),
192+ jnp .array (
193+ [
194+ - 5208520.35574006 ,
195+ - 5208613.86694342 ,
196+ 0.0 ,
197+ - 233.778008402801 ,
198+ 0.0 ,
199+ 0.0 ,
200+ - 5208520.35574006 ,
201+ - 5208613.86694342 ,
202+ 0.0 ,
203+ - 233.778008402801 ,
204+ 0.0 ,
205+ 0.0 ,
206+ ]
207+ ).reshape ((2 , 6 , 1 )),
208+ {"pressure" : jnp .zeros ((2 , 1 ))}),
209+ ],
210+ )
211+ def test_compute_stress_two_particles (particles , state_vars , element , target , dt ):
212+ particles .update_natural_coords (element )
213+ if element .constraints :
214+ element .apply_boundary_constraints ()
215+ particles .compute_strain (element , dt )
216+ stress = particles .material .compute_stress (None , particles , state_vars )
217+ assert jnp .allclose (stress , target )
0 commit comments