Skip to content

Commit 4524aa1

Browse files
committed
Necessary changes done
1 parent cbd582f commit 4524aa1

1 file changed

Lines changed: 17 additions & 63 deletions

File tree

tests/test_bingham.py

Lines changed: 17 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,8 @@
66
from diffmpm.constraint import Constraint
77
from diffmpm.node import Nodes
88

9-
material_dstrain_particles_state_vars_element_targets_dt = [
9+
particles_element_targets = [
1010
(
11-
Bingham(
12-
{
13-
"density": 1000,
14-
"youngs_modulus": 1.0e7,
15-
"poisson_ratio": 0.3,
16-
"tau0": 771.8,
17-
"mu": 0.0451,
18-
"critical_shear_rate": 0.2,
19-
"ndim": 2,
20-
}
21-
),
22-
None,
2311
Particles(
2412
jnp.array([[0.5, 0.5]]).reshape(1, 1, 2),
2513
(
@@ -37,7 +25,6 @@
3725
),
3826
jnp.array([0]),
3927
),
40-
{"pressure": jnp.zeros(1)},
4128
Quadrilateral4Node(
4229
(1, 1),
4330
1,
@@ -46,21 +33,8 @@
4633
Nodes(4, jnp.array([-2, -2, 2, -2, -2, 2, 2, 2]).reshape((4, 1, 2))),
4734
),
4835
jnp.array([0.0, 0.0, 0.0, 0.0, 0.0, 0.0]).reshape((6, 1)),
49-
1.0,
5036
),
5137
(
52-
Bingham(
53-
{
54-
"density": 1000,
55-
"youngs_modulus": 1.0e7,
56-
"poisson_ratio": 0.3,
57-
"tau0": 771.8,
58-
"mu": 0.0451,
59-
"critical_shear_rate": 0.2,
60-
"ndim": 2,
61-
}
62-
),
63-
None,
6438
Particles(
6539
jnp.array([[0.5, 0.5]]).reshape(1, 1, 2),
6640
(
@@ -78,7 +52,6 @@
7852
),
7953
jnp.array([0]),
8054
),
81-
{"pressure": jnp.zeros(1)},
8255
Quadrilateral4Node(
8356
(1, 1),
8457
1,
@@ -89,21 +62,8 @@
8962
jnp.array([-52083.3333333333, -52083.3333333333, 0.0, 0.0, 0.0, 0.0]).reshape(
9063
(6, 1)
9164
),
92-
1.0,
9365
),
9466
(
95-
Bingham(
96-
{
97-
"density": 1000,
98-
"youngs_modulus": 1.0e7,
99-
"poisson_ratio": 0.3,
100-
"tau0": 200.0,
101-
"mu": 200.0,
102-
"critical_shear_rate": 0.2,
103-
"ndim": 2,
104-
}
105-
),
106-
None,
10767
Particles(
10868
jnp.array([[0.5, 0.5]]).reshape(1, 1, 2),
10969
(
@@ -121,7 +81,6 @@
12181
),
12282
jnp.array([0]),
12383
),
124-
{"pressure": jnp.zeros(1)},
12584
Quadrilateral4Node(
12685
(1, 1),
12786
1,
@@ -132,22 +91,8 @@
13291
jnp.array(
13392
[-5208520.35574006, -5208613.86694342, 0.0, -233.778008402801, 0.0, 0.0]
13493
).reshape((6, 1)),
135-
1.0,
13694
),
13795
(
138-
Bingham(
139-
{
140-
"density": 1000,
141-
"youngs_modulus": 1.0e7,
142-
"poisson_ratio": 0.3,
143-
"tau0": 200.0,
144-
"mu": 200.0,
145-
"critical_shear_rate": 0.2,
146-
"ndim": 2,
147-
"incompressible": True,
148-
}
149-
),
150-
None,
15196
Particles(
15297
jnp.array([[0.5, 0.5]]).reshape(1, 1, 2),
15398
(
@@ -166,7 +111,6 @@
166111
),
167112
jnp.array([0]),
168113
),
169-
{"pressure": jnp.zeros(1)},
170114
Quadrilateral4Node(
171115
(1, 1),
172116
1,
@@ -177,18 +121,28 @@
177121
jnp.array(
178122
[-187.0224067222, -280.5336100834, 0.0, -233.778008402801, 0.0, 0.0]
179123
).reshape((6, 1)),
180-
1.0,
181124
),
182125
]
183126

184127

128+
@pytest.fixture
129+
def state_vars():
130+
return {"pressure": jnp.zeros(1)}
131+
132+
133+
@pytest.fixture
134+
def dt():
135+
return 1.0
136+
137+
185138
@pytest.mark.parametrize(
186-
"material, dstrain, particles, state_vars, element, target, dt",
187-
material_dstrain_particles_state_vars_element_targets_dt,
139+
"particles, element, target",
140+
particles_element_targets,
188141
)
189-
def test_compute_stress(material, dstrain, particles, state_vars, element, target, dt):
190-
if element.constraints != []:
142+
def test_compute_stress(particles, state_vars, element, target, dt):
143+
particles.update_natural_coords(element)
144+
if element.constraints:
191145
element.apply_boundary_constraints()
192146
particles.compute_strain(element, dt)
193-
stress = material.compute_stress(dstrain, particles, state_vars)
147+
stress = particles.material.compute_stress(None, particles, state_vars)
194148
assert jnp.allclose(stress, target)

0 commit comments

Comments
 (0)