{ "cells": [ { "cell_type": "markdown", "id": "62ccb0e1-2a07-43ca-a4c9-ee8e65185c5f", "metadata": { "execution": { "iopub.execute_input": "2023-05-07T04:59:23.561931Z", "iopub.status.busy": "2023-05-07T04:59:23.560944Z", "iopub.status.idle": "2023-05-07T04:59:23.566706Z", "shell.execute_reply": "2023-05-07T04:59:23.566200Z", "shell.execute_reply.started": "2023-05-07T04:59:23.561931Z" }, "tags": [] }, "source": [ "# Elements Removal Visualization" ] }, { "cell_type": "code", "execution_count": 11, "id": "31c4f952-b0bf-4e63-8e40-e05f63e59e37", "metadata": { "execution": { "iopub.execute_input": "2023-05-07T04:59:32.889623Z", "iopub.status.busy": "2023-05-07T04:59:32.889623Z", "iopub.status.idle": "2023-05-07T04:59:32.901829Z", "shell.execute_reply": "2023-05-07T04:59:32.901829Z", "shell.execute_reply.started": "2023-05-07T04:59:32.889623Z" }, "tags": [] }, "outputs": [], "source": [ "import opstool as opst\n", "import openseespy.opensees as ops" ] }, { "cell_type": "markdown", "id": "85c6aea6-2cd8-4c08-a2c4-f03b9b58a8aa", "metadata": {}, "source": [ "## Model" ] }, { "cell_type": "code", "execution_count": 13, "id": "447e4446-65c2-4942-a8fc-16f81a795e3d", "metadata": { "execution": { "iopub.execute_input": "2023-05-07T05:00:18.896808Z", "iopub.status.busy": "2023-05-07T05:00:18.895810Z", "iopub.status.idle": "2023-05-07T05:00:18.905817Z", "shell.execute_reply": "2023-05-07T05:00:18.905817Z", "shell.execute_reply.started": "2023-05-07T05:00:18.896808Z" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The original Tcl file comes from http://www.dinochen.com/, and the Python version is converted by opstool.tcl2py().\n" ] } ], "source": [ "opst.load_ops_examples(\"Shell3D\")" ] }, { "cell_type": "code", "execution_count": 15, "id": "1ccb0f80-9df7-4774-868d-613d130b8244", "metadata": { "execution": { "iopub.execute_input": "2023-05-07T05:02:49.641601Z", "iopub.status.busy": "2023-05-07T05:02:49.641601Z", "iopub.status.idle": "2023-05-07T05:03:30.999444Z", "shell.execute_reply": "2023-05-07T05:03:30.998360Z", "shell.execute_reply.started": "2023-05-07T05:02:49.641601Z" }, "tags": [] }, "outputs": [ { "data": { "text/html": [ "
Model data saved in opstool_output/ModelData.hdf5!\n",
       "
\n" ], "text/plain": [ "Model data saved in \u001b[1;38;2;0;174;255mopstool_output/ModelData.hdf5\u001b[0m!\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "ModelData = opst.GetFEMdata(results_dir=\"opstool_output\")\n", "ModelData.get_model_data(save_file=\"ModelData.hdf5\")\n", "opsvis = opst.OpsVisPyvista(\n", " point_size=2,\n", " line_width=3,\n", " results_dir=\"opstool_output\",\n", ")\n", "opsvis.model_vis(\n", " input_file=\"ModelData.hdf5\",\n", " show_node_label=True,\n", " show_ele_label=True,\n", " show_outline=False,\n", ")" ] }, { "cell_type": "raw", "id": "a0212d38-5fe4-4b07-b23d-c7d355c57fb8", "metadata": { "raw_mimetype": "text/restructuredtext", "tags": [] }, "source": [ ".. image:: images/EleRemovalModel.png\n", " :align: center" ] }, { "cell_type": "markdown", "id": "78ac41b0-ee81-4f78-839a-d12678e75970", "metadata": {}, "source": [ "## Gravity analysis" ] }, { "cell_type": "raw", "id": "2b21723b-7eff-413c-adda-6cef207ea6cd", "metadata": { "raw_mimetype": "text/restructuredtext", "tags": [] }, "source": [ "We use ``get_resp_step`` a to save the response data of each analysis step, remember to set `model_update` to True.\n", "When `model_update=True`, the data of different analysis cases will be continuously saved." ] }, { "cell_type": "code", "execution_count": 4, "id": "2ccc8ea0-e96b-4dee-8059-084f82a72c9b", "metadata": { "execution": { "iopub.execute_input": "2023-05-07T04:56:46.297886Z", "iopub.status.busy": "2023-05-07T04:56:46.297886Z", "iopub.status.idle": "2023-05-07T04:56:46.412250Z", "shell.execute_reply": "2023-05-07T04:56:46.412250Z", "shell.execute_reply.started": "2023-05-07T04:56:46.297886Z" }, "tags": [] }, "outputs": [], "source": [ "ops.timeSeries(\"Linear\", 1)\n", "ops.pattern(\"Plain\", 1, 1)\n", "ops.load(14, 0.0, 0.0, -1000000.0, 0.0, 0.0, 0.0)\n", "ops.load(20, 0.0, 0.0, -1000000.0, 0.0, 0.0, 0.0)\n", "ops.load(26, 0.0, 0.0, -1000000.0, 0.0, 0.0, 0.0)\n", "ops.load(32, 0.0, 0.0, -1000000.0, 0.0, 0.0, 0.0)\n", "ops.load(56, 0.0, 0.0, -1000000.0, 0.0, 0.0, 0.0)\n", "ops.load(72, 0.0, 0.0, -1000000.0, 0.0, 0.0, 0.0)\n", "ops.load(88, 0.0, 0.0, -1000000.0, 0.0, 0.0, 0.0)\n", "ops.load(104, 0.0, 0.0, -1000000.0, 0.0, 0.0, 0.0)\n", "ops.load(120, 0.0, 0.0, -1000000.0, 0.0, 0.0, 0.0)\n", "ops.constraints(\"Plain\",)\n", "ops.numberer(\"Plain\",)\n", "ops.system(\"BandGeneral\")\n", "ops.test(\"EnergyIncr\", 1e-06, 200)\n", "ops.algorithm(\"Newton\",)\n", "ops.integrator(\"LoadControl\", 0.1)\n", "ops.analysis(\"Static\",)" ] }, { "cell_type": "code", "execution_count": null, "id": "70106e3a-a250-46d2-b8c2-16f849dd22fe", "metadata": {}, "outputs": [], "source": [ "for i in range(10):\n", " ops.analyze(1)\n", " ModelData.get_resp_step(model_update=True) # here!\n", "ops.loadConst(0,)" ] }, { "cell_type": "markdown", "id": "43d367b3-5df9-4e7e-be5c-16d7e466528a", "metadata": {}, "source": [ "## Elements removal" ] }, { "cell_type": "code", "execution_count": 5, "id": "2fac35db-f2b3-4253-bdb0-ca2961fee447", "metadata": { "execution": { "iopub.execute_input": "2023-05-07T04:56:46.413349Z", "iopub.status.busy": "2023-05-07T04:56:46.413349Z", "iopub.status.idle": "2023-05-07T04:56:46.421375Z", "shell.execute_reply": "2023-05-07T04:56:46.421017Z", "shell.execute_reply.started": "2023-05-07T04:56:46.413349Z" }, "tags": [] }, "outputs": [], "source": [ "ops.wipeAnalysis()\n", "ops.timeSeries(\"Linear\", 2)\n", "ops.pattern(\"Plain\", 2, 2)\n", "ops.constraints(\"Transformation\",)\n", "ops.test(\"NormDispIncr\", 0.0001, 60)\n", "ops.algorithm(\"KrylovNewton\",)\n", "ops.numberer(\"RCM\",)\n", "ops.system(\"BandGeneral\",)\n", "ops.integrator(\"LoadControl\", 1)\n", "ops.analysis(\"Static\",)" ] }, { "cell_type": "raw", "id": "89787116-8e48-4d58-8a46-fa611029510b", "metadata": { "raw_mimetype": "text/restructuredtext", "tags": [] }, "source": [ "we want to remove these elements: [32, 50, 52, 70, 31, 49, 51, 69].\n", "\n", ".. note::\n", " After some elements are removed, some free nodes appear in the model, which needs to be fixed." ] }, { "cell_type": "code", "execution_count": 6, "id": "c86c8cf2-17fa-4fef-b414-3a90795d0467", "metadata": { "execution": { "iopub.execute_input": "2023-05-07T04:56:46.421375Z", "iopub.status.busy": "2023-05-07T04:56:46.421375Z", "iopub.status.idle": "2023-05-07T04:56:46.849332Z", "shell.execute_reply": "2023-05-07T04:56:46.849332Z", "shell.execute_reply.started": "2023-05-07T04:56:46.421375Z" }, "tags": [] }, "outputs": [], "source": [ "eleTags = [32, 50, 52, 70, 31, 49, 51, 69] # removed ele tags\n", "for tag in eleTags:\n", " ops.remove(\"element\", tag)\n", " if tag == 49:\n", " ops.fix(67, 1, 1, 1, 1, 1, 1)\n", " if tag == 51:\n", " ops.fix(81, 1, 1, 1, 1, 1, 1)\n", " if tag == 69:\n", " ops.fix(83, 1, 1, 1, 1, 1, 1)\n", " ok = ops.analyze(10)\n", " ModelData.get_resp_step(model_update=True)" ] }, { "cell_type": "raw", "id": "c0ea8897-6f0c-42aa-8800-14ec07d9b902", "metadata": { "raw_mimetype": "text/restructuredtext", "tags": [] }, "source": [ "Finally, save all results to ``hdf5`` files." ] }, { "cell_type": "code", "execution_count": 7, "id": "9809c2bd-0fe6-469f-9e2c-34d76bbaec47", "metadata": { "execution": { "iopub.execute_input": "2023-05-07T04:56:46.850245Z", "iopub.status.busy": "2023-05-07T04:56:46.850245Z", "iopub.status.idle": "2023-05-07T04:56:46.941693Z", "shell.execute_reply": "2023-05-07T04:56:46.941693Z", "shell.execute_reply.started": "2023-05-07T04:56:46.850245Z" }, "tags": [] }, "outputs": [ { "data": { "text/html": [ "
All responses data saved in opstool_output/RespStepData.hdf5!\n",
       "
\n" ], "text/plain": [ "All responses data saved in \u001b[1;38;2;51;105;231mopstool_output/RespStepData.hdf5\u001b[0m!\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "ModelData.save_resp_all(save_file=\"RespStepData.hdf5\", reset_state=True)" ] }, { "cell_type": "markdown", "id": "cdf2e78b-57a7-40a9-a95b-864b08a35b9a", "metadata": {}, "source": [ "Visual deformation, slider style" ] }, { "cell_type": "code", "execution_count": 16, "id": "7605b62d-d955-4dc4-b243-494f820e9913", "metadata": { "execution": { "iopub.execute_input": "2023-05-07T05:15:10.227668Z", "iopub.status.busy": "2023-05-07T05:15:10.227668Z", "iopub.status.idle": "2023-05-07T05:15:49.273992Z", "shell.execute_reply": "2023-05-07T05:15:49.273992Z", "shell.execute_reply.started": "2023-05-07T05:15:10.227668Z" }, "tags": [] }, "outputs": [], "source": [ "opsvis.deform_vis(\n", " input_file=\"RespStepData.hdf5\",\n", " slider=True,\n", " response=\"disp\",\n", " alpha=1.0,\n", " show_outline=False,\n", " show_origin=True,\n", " show_face_line=False,\n", " opacity=1,\n", " model_update=True,\n", ")" ] }, { "cell_type": "raw", "id": "38dfb7e8-809c-404c-812a-84eebe7bd8d5", "metadata": { "raw_mimetype": "text/restructuredtext", "tags": [] }, "source": [ ".. image:: images/EleRemovalDefo.png\n", " :align: center" ] }, { "cell_type": "markdown", "id": "8cfd0132-95a2-4b15-b03c-eae7ee9d72e0", "metadata": {}, "source": [ "create an animated gif" ] }, { "cell_type": "raw", "id": "c717a22b-fae3-4dae-99cf-402859491608", "metadata": { "execution": { "iopub.execute_input": "2023-05-07T05:15:54.867206Z", "iopub.status.busy": "2023-05-07T05:15:54.867206Z", "iopub.status.idle": "2023-05-07T05:17:16.449446Z", "shell.execute_reply": "2023-05-07T05:17:16.449446Z", "shell.execute_reply.started": "2023-05-07T05:15:54.867206Z" }, "raw_mimetype": "text/restructuredtext", "tags": [] }, "source": [ ".. code-block:: python\n", "\n", " opsvis.deform_anim(\n", " input_file=\"RespStepData.hdf5\",\n", " response=\"disp\",\n", " alpha=1.0,\n", " show_outline=False,\n", " show_face_line=False,\n", " opacity=1,\n", " model_update=True,\n", " framerate=5,\n", " save_fig=\"deform_anim.gif\"\n", " )" ] }, { "cell_type": "raw", "id": "643bb103-6faf-435f-9f55-9171aa7b58c0", "metadata": { "raw_mimetype": "text/restructuredtext", "tags": [] }, "source": [ ".. image:: images/EleRemovalDefoAnim.gif\n", " :alt: StreamPlayer\n", " :align: center" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.9.16" } }, "nbformat": 4, "nbformat_minor": 5 }