Skip to content

Commit 2e4d5ae

Browse files
committed
Add tests
1 parent 04c111b commit 2e4d5ae

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

tests/test_element.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,11 @@ def test_compute_internal_force(self, elements, particles):
202202
def test_compute_volume(self, elements):
203203
elements.compute_volume()
204204
assert jnp.allclose(elements.volume, jnp.array([1]).reshape(1, 1, 1))
205+
206+
def test_apply_particle_traction_forces(self, elements, particles):
207+
particles.traction += jnp.array([1, 0])
208+
elements.apply_particle_traction_forces(particles)
209+
assert jnp.allclose(
210+
elements.nodes.f_ext,
211+
jnp.array([[0.5, 0], [0.5, 0], [0.5, 0], [0.5, 0]]).reshape(4, 1, 2),
212+
)

tests/test_particle.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,15 @@ def test_compute_strain(self, elements, particles):
4747
def test_compute_volume(self, elements, particles):
4848
particles.compute_volume(elements, elements.total_elements)
4949
assert jnp.allclose(particles.volume, jnp.array([0.5, 0.5]).reshape(2, 1, 1))
50+
51+
def test_assign_traction(self, elements, particles):
52+
particles.compute_volume(elements, elements.total_elements)
53+
particles.assign_traction(jnp.array([0]), 1, 10)
54+
assert jnp.allclose(
55+
particles.traction, jnp.array([[0, 7.071068], [0, 0]]).reshape(2, 1, 2)
56+
)
57+
58+
def test_zero_traction(self, particles):
59+
particles.traction += 1
60+
particles.zero_traction()
61+
assert jnp.all(particles.traction == 0)

0 commit comments

Comments
 (0)