|
1 | 1 | import os |
2 | 2 | from pathlib import Path |
3 | 3 | import jax.numpy as jnp |
4 | | -from diffmpm.solver import MPM |
| 4 | +from diffmpm import MPM |
5 | 5 |
|
6 | | -curr_filepath = Path(__file__).absolute() |
7 | | -curr_dir = curr_filepath.parent |
8 | | -os.chdir(curr_dir) |
9 | | -mpm = MPM("mpm-particle-traction.toml") |
10 | | -mpm.solve() |
11 | | -result = jnp.load("results/uniaxial-particle-traction/particles_0300.npz") |
12 | | -## Step 300 |
13 | | -assert jnp.round(result["stress"][0, :, 0].min() - 0.4450086768966724, 5) == 0.0 |
14 | | -assert jnp.round(result["stress"][0, :, 0].max() - 0.5966527842046769, 5) == 0.0 |
15 | 6 |
|
16 | | -## Step 510 |
17 | | -result = jnp.load("results/uniaxial-particle-traction/particles_0510.npz") |
18 | | -assert jnp.round(result["stress"][0, :, 0].min() - 0.7528092313640623, 5) == 0.0 |
19 | | -assert jnp.round(result["stress"][0, :, 0].max() - 1.0109599915279937, 5) == 0.0 |
| 7 | +def test_benchmarks(): |
| 8 | + curr_filepath = Path(__file__).absolute() |
| 9 | + curr_dir = curr_filepath.parent |
| 10 | + os.chdir(curr_dir) |
| 11 | + mpm = MPM("mpm-particle-traction.toml") |
| 12 | + mpm.solve() |
| 13 | + result = jnp.load("results/uniaxial-particle-traction/particles_0300.npz") |
| 14 | + ## Step 300 |
| 15 | + assert jnp.round(result["stress"][0, :, 0].min() - 0.4450086768966724, 5) == 0.0 |
| 16 | + assert jnp.round(result["stress"][0, :, 0].max() - 0.5966527842046769, 5) == 0.0 |
20 | 17 |
|
21 | | -## Step 750 |
22 | | -result = jnp.load("results/uniaxial-particle-traction/particles_0750.npz") |
23 | | -assert jnp.round(result["stress"][0, :, 0].min() - 0.7500090055681591, 5) == 0.0 |
24 | | -assert jnp.round(result["stress"][0, :, 0].max() - 1.0000224746314728, 5) == 0.0 |
| 18 | + ## Step 510 |
| 19 | + result = jnp.load("results/uniaxial-particle-traction/particles_0510.npz") |
| 20 | + assert jnp.round(result["stress"][0, :, 0].min() - 0.7528092313640623, 5) == 0.0 |
| 21 | + assert jnp.round(result["stress"][0, :, 0].max() - 1.0109599915279937, 5) == 0.0 |
25 | 22 |
|
26 | | -## Step 990 |
27 | | -result = jnp.load("results/uniaxial-particle-traction/particles_0990.npz") |
28 | | -assert jnp.round(result["stress"][0, :, 0].min() - 0.750002924022295, 5) == 0.0 |
29 | | -assert jnp.round(result["stress"][0, :, 0].max() - 0.9999997782938734, 5) == 0.0 |
| 23 | + ## Step 750 |
| 24 | + result = jnp.load("results/uniaxial-particle-traction/particles_0750.npz") |
| 25 | + assert jnp.round(result["stress"][0, :, 0].min() - 0.7500090055681591, 5) == 0.0 |
| 26 | + assert jnp.round(result["stress"][0, :, 0].max() - 1.0000224746314728, 5) == 0.0 |
| 27 | + |
| 28 | + ## Step 990 |
| 29 | + result = jnp.load("results/uniaxial-particle-traction/particles_0990.npz") |
| 30 | + assert jnp.round(result["stress"][0, :, 0].min() - 0.750002924022295, 5) == 0.0 |
| 31 | + assert jnp.round(result["stress"][0, :, 0].max() - 0.9999997782938734, 5) == 0.0 |
0 commit comments