diff --git a/benchmarks/2d/plate_with_hole/testing.ipynb b/benchmarks/2d/plate_with_hole/testing.ipynb new file mode 100644 index 0000000..126132f --- /dev/null +++ b/benchmarks/2d/plate_with_hole/testing.ipynb @@ -0,0 +1,72 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "ename": "ModuleNotFoundError", + "evalue": "No module named 'diffmpm'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[1], line 4\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mpathlib\u001b[39;00m \u001b[39mimport\u001b[39;00m Path\n\u001b[1;32m 3\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39mjax\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mnumpy\u001b[39;00m \u001b[39mas\u001b[39;00m \u001b[39mjnp\u001b[39;00m\n\u001b[0;32m----> 4\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mdiffmpm\u001b[39;00m \u001b[39mimport\u001b[39;00m MPM\n\u001b[1;32m 7\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mtest_benchmarks\u001b[39m():\n\u001b[1;32m 8\u001b[0m curr_filepath \u001b[39m=\u001b[39m Path(\u001b[39m__file__\u001b[39m)\u001b[39m.\u001b[39mabsolute()\n", + "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'diffmpm'" + ] + } + ], + "source": [ + "import os\n", + "from pathlib import Path\n", + "import jax.numpy as jnp\n", + "from diffmpm import MPM\n", + "\n", + "\n", + "def test_benchmarks():\n", + " curr_filepath = Path(__file__).absolute()\n", + " curr_dir = curr_filepath.parent\n", + " os.chdir(curr_dir)\n", + " mpm = MPM(\"plate-with-hole.toml\")\n", + " mpm.solve()\n", + "\n", + " result = jnp.load(\"results/plate-with-a-hole/particles_299999.npz\")\n", + " true_stress_yy = -1.11\n", + " true_stress_xx = 0.0\n", + "\n", + " assert jnp.round(result[\"stress\"][0, :, 1].max() - true_stress_yy, 8) == 0.0\n", + " assert jnp.round(result[\"stress\"][0, :, 0].max() - true_stress_xx, 8) == 0.0\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "env3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.4" + }, + "orig_nbformat": 4 + }, + "nbformat": 4, + "nbformat_minor": 2 +}