Skip to content

Commit c6291cc

Browse files
authored
Merge pull request #8 from chahak13/benchmarks
Benchmarks
2 parents af8bf08 + f9fe61f commit c6291cc

21 files changed

Lines changed: 530 additions & 1777 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ build/**
66
examples/**
77
**__pycache__**
88
**.egg-info
9+
**.npz
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
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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-stress-usf"
15+
type = "MPMExplicit"
16+
dimension = 2
17+
scheme = "usf"
18+
dt = 0.01
19+
nsteps = 10
20+
velocity_update = false
21+
22+
[output]
23+
format = "npz"
24+
folder = "results/"
25+
step_frequency = 1
26+
27+
[mesh]
28+
type = "generator"
29+
nelements = [1, 1]
30+
element_length = [1, 1]
31+
particle_element_ids = [0]
32+
element = "Quadrilateral4Node"
33+
34+
[[mesh.constraints]]
35+
node_ids = [0, 1]
36+
dir = 1
37+
velocity = 0.0
38+
39+
[[mesh.constraints]]
40+
node_ids = [2, 3]
41+
dir = 1
42+
velocity = -0.01
43+
44+
[[materials]]
45+
id = 0
46+
density = 1
47+
poisson_ratio = 0
48+
youngs_modulus = 1000
49+
type = "LinearElastic"
50+
51+
[[particles]]
52+
file = "particles-2d-uniaxial-stress.json"
53+
material_id = 0
54+
init_velocity = [1.0, 0.0]
55+
56+
[external_loading]
57+
gravity = [0, 0]
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[
2+
[
3+
[
4+
0.25,
5+
0.25
6+
]
7+
],
8+
[
9+
[
10+
0.75,
11+
0.25
12+
]
13+
],
14+
[
15+
[
16+
0.75,
17+
0.75
18+
]
19+
],
20+
[
21+
[
22+
0.25,
23+
0.75
24+
]
25+
]
26+
]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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-uniaxial-stress.toml")
10+
mpm.solve()
11+
12+
result = jnp.load("results/uniaxial-stress-usf/particles_09.npz")
13+
true_stress_yy = -1.0
14+
true_stress_xx = 0.0
15+
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)