Skip to content

Commit f9fe61f

Browse files
committed
Update benchmarks
1 parent 5991f27 commit f9fe61f

5 files changed

Lines changed: 175 additions & 4 deletions

File tree

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# The `meta` group contains top level attributes that govern the
2+
# behaviour of the MPM Solver.
3+
#
4+
# Attributes:
5+
# title: The title of the experiment. This is just for the user's
6+
# reference.
7+
# type: The type of simulation to be used. Allowed values are
8+
# {"MPMExplicit"}
9+
# scheme: The MPM Scheme used for simulation. Allowed values are
10+
# {"usl", "usf"}
11+
# dt: Timestep used in the simulation.
12+
# nsteps: Number of steps to run the simulation for.
13+
[meta]
14+
title = "uniaxial-nodal-forces"
15+
type = "MPMExplicit"
16+
dimension = 2
17+
scheme = "usf"
18+
dt = 0.001
19+
nsteps = 1000
20+
velocity_update = true
21+
22+
[output]
23+
format = "npz"
24+
folder = "results/"
25+
step_frequency = 10
26+
27+
[mesh]
28+
# type = "file"
29+
# file = "mesh-1d.txt"
30+
# boundary_nodes = "boundary-1d.txt"
31+
# particle_element_ids = "particles-elements.txt"
32+
type = "generator"
33+
nelements = [3, 1]
34+
element_length = [0.1, 0.1]
35+
particle_element_ids = [0]
36+
element = "Quadrilateral4Node"
37+
38+
[[mesh.constraints]]
39+
node_ids = [0, 4]
40+
dir = 0
41+
velocity = 0.0
42+
43+
[[materials]]
44+
id = 0
45+
density = 1000
46+
poisson_ratio = 0
47+
youngs_modulus = 1000000
48+
type = "LinearElastic"
49+
50+
[[particles]]
51+
file = "particles-2d-nodal-force.json"
52+
material_id = 0
53+
init_velocity = 0.0
54+
55+
[external_loading]
56+
gravity = [0, 0]
57+
58+
[[external_loading.concentrated_nodal_forces]]
59+
node_ids = [3, 7]
60+
math_function_id = 0
61+
dir = 0
62+
force = 0.05
63+
64+
[[math_functions]]
65+
type = "Linear"
66+
xvalues = [0.0, 0.5, 1.0]
67+
fxvalues = [0.0, 1.0, 1.0]
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
[
2+
[
3+
[
4+
0.025,
5+
0.025
6+
]
7+
],
8+
[
9+
[
10+
0.075,
11+
0.025
12+
]
13+
],
14+
[
15+
[
16+
0.125,
17+
0.025
18+
]
19+
],
20+
[
21+
[
22+
0.175,
23+
0.025
24+
]
25+
],
26+
[
27+
[
28+
0.225,
29+
0.025
30+
]
31+
],
32+
[
33+
[
34+
0.275,
35+
0.025
36+
]
37+
],
38+
[
39+
[
40+
0.025,
41+
0.075
42+
]
43+
],
44+
[
45+
[
46+
0.075,
47+
0.075
48+
]
49+
],
50+
[
51+
[
52+
0.125,
53+
0.075
54+
]
55+
],
56+
[
57+
[
58+
0.175,
59+
0.075
60+
]
61+
],
62+
[
63+
[
64+
0.225,
65+
0.075
66+
]
67+
],
68+
[
69+
[
70+
0.275,
71+
0.075
72+
]
73+
]
74+
]
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import os
2+
from pathlib import Path
3+
import jax.numpy as jnp
4+
from diffmpm.solver import MPM
5+
6+
curr_filepath = Path(__file__).absolute()
7+
curr_dir = curr_filepath.parent
8+
os.chdir(curr_dir)
9+
mpm = MPM("mpm-nodal-forces.toml")
10+
mpm.solve()
11+
12+
result = jnp.load("results/uniaxial-nodal-forces/particles_0300.npz")
13+
## Step 300
14+
assert jnp.round(result["stress"][0, :, 0].min() - 0.5925210678182377, 6) == 0.0
15+
assert jnp.round(result["stress"][0, :, 0].max() - 0.5974539476363379, 6) == 0.0
16+
17+
## Step 510
18+
result = jnp.load("results/uniaxial-nodal-forces/particles_0510.npz")
19+
assert jnp.round(result["stress"][0, :, 0].min() - 1.0026665338366039, 5) == 0.0
20+
assert jnp.round(result["stress"][0, :, 0].max() - 1.0112231542459431, 5) == 0.0
21+
22+
## Step 750
23+
result = jnp.load("results/uniaxial-nodal-forces/particles_0750.npz")
24+
assert jnp.round(result["stress"][0, :, 0].min() - 1.0000053000532143, 5) == 0.0
25+
assert jnp.round(result["stress"][0, :, 0].max() - 1.0000225119807862, 5) == 0.0
26+
27+
## Step 990
28+
result = jnp.load("results/uniaxial-nodal-forces/particles_0990.npz")
29+
assert jnp.round(result["stress"][0, :, 0].min() - 0.9999990078443788, 5) == 0.0
30+
assert jnp.round(result["stress"][0, :, 0].max() - 0.9999990292713694, 5) == 0.0

benchmarks/2d/uniaxial_stress/mpm-uniaxial-stress.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ velocity_update = false
2222
[output]
2323
format = "npz"
2424
folder = "results/"
25-
step_frequency = 5
25+
step_frequency = 1
2626

2727
[mesh]
2828
type = "generator"

benchmarks/2d/uniaxial_stress/test_benchmark.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
mpm = MPM("mpm-uniaxial-stress.toml")
1010
mpm.solve()
1111

12-
result = jnp.load("results/uniaxial-stress-usf/particles_10.npz")
12+
result = jnp.load("results/uniaxial-stress-usf/particles_09.npz")
1313
true_stress_yy = -1.0
1414
true_stress_xx = 0.0
1515

16-
assert jnp.round(result["stress"][:, 1].max() - true_stress_yy, 8) == 0.0
17-
assert jnp.round(result["stress"][:, 0].max() - true_stress_xx, 8) == 0.0
16+
assert jnp.round(result["stress"][0, :, 1].max() - true_stress_yy, 8) == 0.0
17+
assert jnp.round(result["stress"][0, :, 0].max() - true_stress_xx, 8) == 0.0

0 commit comments

Comments
 (0)