Skip to content

Commit

Permalink
Remove temp files
Browse files Browse the repository at this point in the history
  • Loading branch information
TLCFEM committed Dec 30, 2024
1 parent 831ac3c commit e178cad
Showing 1 changed file with 52 additions and 35 deletions.
87 changes: 52 additions & 35 deletions docs/Library/Element/Beam/B31OS.BENCHMARK.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,18 @@
}
],
"source": [
"import os\n",
"import shutil\n",
"from subprocess import run\n",
"\n",
"from sectionproperties.post.fibre import to_fibre_section\n",
"from sectionproperties.pre import Geometry\n",
"\n",
"temp_dir = \"b31os_temp\"\n",
"\n",
"os.mkdir(temp_dir)\n",
"os.chdir(temp_dir)\n",
"\n",
"b = 51\n",
"t = 6.5\n",
"a = 76\n",
Expand All @@ -68,7 +74,7 @@
"geom.create_mesh(mesh_sizes=2)\n",
"geom.plot_geometry()\n",
"\n",
"to_fibre_section(geom, save_to='angle.sp', material_mapping={'default': 1})\n",
"to_fibre_section(geom, save_to=\"angle.sp\", material_mapping={\"default\": 1})\n",
"\n",
"pass"
]
Expand Down Expand Up @@ -110,7 +116,7 @@
"from matplotlib import pyplot as plt\n",
"from h5py import File\n",
"\n",
"model = '''# cantilever beam with angle section\n",
"model = \"\"\"# cantilever beam with angle section\n",
"node 1 0 0 0\n",
"node 2 350 0 0\n",
"node 3 700 0 0\n",
Expand Down Expand Up @@ -145,32 +151,32 @@
"save recorder 1\n",
"\n",
"exit\n",
"'''\n",
"\"\"\"\n",
"\n",
"with open('angle.analysis.sp', 'w') as f:\n",
"with open(\"angle.analysis.sp\", \"w\") as f:\n",
" f.write(model)\n",
"\n",
"executable = ['suanPan', 'suanPan.exe', 'suanpan']\n",
"executable = [\"suanPan\", \"suanPan.exe\", \"suanpan\"]\n",
"is_run = False\n",
"\n",
"for exe in executable:\n",
" if shutil.which(exe):\n",
" run([exe, '-nu', '-np', '-f', 'angle.analysis.sp'])\n",
" run([exe, \"-nu\", \"-np\", \"-f\", \"angle.analysis.sp\"])\n",
" is_run = True\n",
" break\n",
"\n",
"if is_run:\n",
" with File('R1-U.h5', 'r') as f:\n",
" data = f['R1-U/R1-U5']\n",
" with File(\"R1-U.h5\", \"r\") as f:\n",
" data = f[\"R1-U/R1-U5\"]\n",
" U1 = -data[:, 1]\n",
" U2 = data[:, 2]\n",
" U3 = -data[:, 3]\n",
" LOAD = data[:, 0] * 60\n",
" plt.plot(U1, LOAD, label='|U1|')\n",
" plt.plot(U2, LOAD, label='|U2|')\n",
" plt.plot(U3, LOAD, label='|U3|')\n",
" plt.xlabel('displacement magnitude')\n",
" plt.ylabel('axial load')\n",
" plt.plot(U1, LOAD, label=\"|U1|\")\n",
" plt.plot(U2, LOAD, label=\"|U2|\")\n",
" plt.plot(U3, LOAD, label=\"|U3|\")\n",
" plt.xlabel(\"displacement magnitude\")\n",
" plt.ylabel(\"axial load\")\n",
" plt.legend()\n",
" plt.show()"
]
Expand Down Expand Up @@ -213,11 +219,11 @@
"source": [
"from sectionproperties.pre.library import rectangular_section\n",
"\n",
"geom = rectangular_section(d=30, b=.6).shift_section(-.3, -15)\n",
"geom.create_mesh(mesh_sizes=.05)\n",
"geom = rectangular_section(d=30, b=0.6).shift_section(-0.3, -15)\n",
"geom.create_mesh(mesh_sizes=0.05)\n",
"geom.plot_geometry()\n",
"\n",
"to_fibre_section(geom, save_to='flat.sp', material_mapping={'default': 1})\n",
"to_fibre_section(geom, save_to=\"flat.sp\", material_mapping={\"default\": 1})\n",
"\n",
"pass"
]
Expand Down Expand Up @@ -256,7 +262,7 @@
}
],
"source": [
"model = '''# cantilever beam with angle section\n",
"model = \"\"\"# cantilever beam with angle section\n",
"node 1 0 0 0\n",
"node 2 60 0 0\n",
"node 3 120 0 0\n",
Expand Down Expand Up @@ -293,27 +299,27 @@
"save recorder 1\n",
"\n",
"exit\n",
"'''\n",
"\"\"\"\n",
"\n",
"with open('flat.analysis.sp', 'w') as f:\n",
"with open(\"flat.analysis.sp\", \"w\") as f:\n",
" f.write(model)\n",
"\n",
"is_run = False\n",
"\n",
"for exe in executable:\n",
" if shutil.which(exe):\n",
" run([exe, '-nu', '-np', '-f', 'flat.analysis.sp'])\n",
" run([exe, \"-nu\", \"-np\", \"-f\", \"flat.analysis.sp\"])\n",
" is_run = True\n",
" break\n",
"\n",
"if is_run:\n",
" with File('R1-U.h5', 'r') as f:\n",
" data = f['R1-U/R1-U5']\n",
" with File(\"R1-U.h5\", \"r\") as f:\n",
" data = f[\"R1-U/R1-U5\"]\n",
" U2 = data[:, 2]\n",
" LOAD = data[:, 0] * .001 # reference load\n",
" plt.plot(U2, LOAD, label='U2')\n",
" plt.xlabel('displacement magnitude')\n",
" plt.ylabel('transverse load')\n",
" LOAD = data[:, 0] * 0.001 # reference load\n",
" plt.plot(U2, LOAD, label=\"U2\")\n",
" plt.xlabel(\"displacement magnitude\")\n",
" plt.ylabel(\"transverse load\")\n",
" plt.legend()\n",
" plt.show()"
]
Expand Down Expand Up @@ -356,7 +362,7 @@
"geom.create_mesh(mesh_sizes=2)\n",
"geom.plot_geometry()\n",
"\n",
"to_fibre_section(geom, save_to='flat2.sp', material_mapping={'default': 1})\n",
"to_fibre_section(geom, save_to=\"flat2.sp\", material_mapping={\"default\": 1})\n",
"\n",
"pass"
]
Expand Down Expand Up @@ -385,7 +391,7 @@
}
],
"source": [
"model = '''# cantilever beam with angle section\n",
"model = \"\"\"# cantilever beam with angle section\n",
"node 1 0 0 0\n",
"node 2 250 0 0\n",
"node 3 500 0 0\n",
Expand Down Expand Up @@ -420,29 +426,40 @@
"save recorder 1\n",
"\n",
"exit\n",
"'''\n",
"\"\"\"\n",
"\n",
"with open('flat2.analysis.sp', 'w') as f:\n",
"with open(\"flat2.analysis.sp\", \"w\") as f:\n",
" f.write(model)\n",
"\n",
"is_run = False\n",
"\n",
"for exe in executable:\n",
" if shutil.which(exe):\n",
" run([exe, '-nu', '-np', '-f', 'flat2.analysis.sp'])\n",
" run([exe, \"-nu\", \"-np\", \"-f\", \"flat2.analysis.sp\"])\n",
" is_run = True\n",
" break\n",
"\n",
"if is_run:\n",
" with File('R1-RF.h5', 'r') as f:\n",
" data = f['R1-RF/R1-RF5']\n",
" with File(\"R1-RF.h5\", \"r\") as f:\n",
" data = f[\"R1-RF/R1-RF5\"]\n",
" torque = data[:, 4]\n",
" twist = data[:, 0] * 1.4\n",
" plt.plot(twist, torque)\n",
" plt.xlabel('twist')\n",
" plt.ylabel('torque')\n",
" plt.xlabel(\"twist\")\n",
" plt.ylabel(\"torque\")\n",
" plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2029c4b8",
"metadata": {},
"outputs": [],
"source": [
"os.chdir(\"..\")\n",
"shutil.rmtree(temp_dir)"
]
}
],
"metadata": {
Expand Down

0 comments on commit e178cad

Please sign in to comment.