{ "cells": [ { "cell_type": "markdown", "id": "1e2868d3-e876-4135-9043-ed84c42a205b", "metadata": {}, "source": [ "# Beam Section Rendering" ] }, { "cell_type": "code", "execution_count": 1, "id": "8ff838ef", "metadata": { "execution": { "iopub.execute_input": "2023-05-06T11:23:53.351769Z", "iopub.status.busy": "2023-05-06T11:23:53.351769Z", "iopub.status.idle": "2023-05-06T11:23:54.319013Z", "shell.execute_reply": "2023-05-06T11:23:54.319013Z", "shell.execute_reply.started": "2023-05-06T11:23:53.351769Z" }, "tags": [] }, "outputs": [], "source": [ "import numpy as np\n", "import openseespy.opensees as ops\n", "import opstool as opst\n", "\n", "ops.wipe()\n", "ops.model('basic', '-ndm', 3, '-ndf', 6)" ] }, { "cell_type": "markdown", "id": "ec72d934-6454-4536-bdcc-61697080159d", "metadata": {}, "source": [ "## Create section" ] }, { "cell_type": "raw", "id": "ce8411b3-cd2a-4268-a900-85eb6e2a3c55", "metadata": { "raw_mimetype": "text/restructuredtext", "tags": [] }, "source": [ "by :py:class:`opstool.preprocessing.SecMesh`" ] }, { "cell_type": "code", "execution_count": 2, "id": "ab63f0cc", "metadata": { "execution": { "iopub.execute_input": "2023-05-06T11:23:54.320132Z", "iopub.status.busy": "2023-05-06T11:23:54.320132Z", "iopub.status.idle": "2023-05-06T11:23:54.436252Z", "shell.execute_reply": "2023-05-06T11:23:54.436252Z", "shell.execute_reply.started": "2023-05-06T11:23:54.320132Z" }, "tags": [] }, "outputs": [], "source": [ "# the points of the outer contour line, only the turning point of the line is needed, counterclockwise or clockwise.\n", "outlines = [[0.5, 0], [7.5, 0], [8, 0.5], [8, 4.5],\n", " [7.5, 5], [0.5, 5], [0, 4.5], [0, 0.5]]\n", "# cover thick\n", "cover_d = 0.08\n", "# Offset to get the inner boundary of the cover layer\n", "coverlines = opst.offset(outlines, d=cover_d)\n", "\n", "# Generate polygonal geometry object for cover layer\n", "cover = opst.add_polygon(outlines, holes=[coverlines])\n", "\n", "# Creating core with voids\n", "holelines1 = [[1, 1], [3.5, 1], [3.5, 4], [1, 4]]\n", "holelines2 = [[4.5, 1], [7, 1], [7, 4], [4.5, 4]]\n", "core = opst.add_polygon(coverlines, holes=[holelines1, holelines2])\n", "sec = opst.SecMesh(sec_name=\"My Fiber Section\")\n", "# Grouping, the dict key is the group name, which can be arbitrary.\n", "sec.assign_group({\"cover\": cover, \"core\": core})\n", "# Specify the mesh size\n", "sec.assign_mesh_size(dict(cover=1, core=2))\n", "# Specify the region color\n", "sec.assign_group_color(dict(cover=\"gray\", core=\"green\"))\n", "# Specify the material tag in the opensees, the material needs to be defined by you beforehand.\n", "ops.uniaxialMaterial('Concrete01', 1, -30, -0.002, -15, -0.005)\n", "ops.uniaxialMaterial('Concrete01', 2, -40, -0.006, -30, -0.015)\n", "sec.assign_ops_matTag(dict(cover=1, core=2))\n", "# mesh!\n", "sec.mesh()\n", "sec.centring()\n", "#sec.view(fill=True, engine='plotly', save_html=None, on_notebook=True)\n", "# sec_props = sec.get_frame_props(display_results=True)\n", "# G = 3.45E7 / (2 * (1 + 0.2))\n", "# J = sec_props['J'] # or other number if you don't care\n", "sec.opspy_cmds(secTag=1, GJ=10000) # generate openseespy fiber commands" ] }, { "cell_type": "markdown", "id": "80255cea-e90a-47c8-9603-9d9aa1c0ff59", "metadata": {}, "source": [ "## Create Model" ] }, { "cell_type": "code", "execution_count": 3, "id": "b5ec94ee", "metadata": { "execution": { "iopub.execute_input": "2023-05-06T11:23:54.436252Z", "iopub.status.busy": "2023-05-06T11:23:54.436252Z", "iopub.status.idle": "2023-05-06T11:23:54.472642Z", "shell.execute_reply": "2023-05-06T11:23:54.472642Z", "shell.execute_reply.started": "2023-05-06T11:23:54.436252Z" }, "tags": [] }, "outputs": [], "source": [ "def create_pier(sec_tag):\n", " ops.node(1, 0.0, 0.0, 0.0)\n", " ops.node(2, 0.0, 0.0, 10.0)\n", " ops.node(3, 0.0, 0.0, 20.0)\n", " ops.node(4, 0.0, 0.0, 30.0)\n", " ops.node(5, 0.0, 0.0, 40.0)\n", " ops.mass(5, 50, 50, 50, 0.0, 0.0, 0.0)\n", " ops.fix(1, 1, 1, 1, 1, 1, 1)\n", " ops.geomTransf('Linear', 1, *[-1.0, 0.0, 0.0])\n", " ops.beamIntegration('Lobatto', 1, sec_tag, 10)\n", " ops.element('forceBeamColumn', 1, *[1, 2], 1, 1)\n", " ops.element('forceBeamColumn', 2, *[2, 3], 1, 1)\n", " ops.element('forceBeamColumn', 3, *[3, 4], 1, 1)\n", " ops.element('forceBeamColumn', 4, *[4, 5], 1, 1)\n", "create_pier(sec_tag=1)" ] }, { "cell_type": "markdown", "id": "7ba55281-7b4e-44a0-b316-a6c2d573b7fd", "metadata": {}, "source": [ "## Save Model Data" ] }, { "cell_type": "raw", "id": "6116660c-7484-4568-b614-93948be40309", "metadata": { "raw_mimetype": "text/restructuredtext", "tags": [] }, "source": [ "Use Arg `beam_sec` in :py:meth:`opstool.vis.GetFEMdata.get_model_data`" ] }, { "cell_type": "code", "execution_count": 4, "id": "d96634b0", "metadata": { "execution": { "iopub.execute_input": "2023-05-06T11:23:54.472642Z", "iopub.status.busy": "2023-05-06T11:23:54.472642Z", "iopub.status.idle": "2023-05-06T11:23:54.509089Z", "shell.execute_reply": "2023-05-06T11:23:54.508073Z", "shell.execute_reply.started": "2023-05-06T11:23:54.472642Z" }, "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", "beam_sec = {}\n", "for i in range(4):\n", " beam_sec[i+1] = sec\n", "ModelData.get_model_data(beam_sec=beam_sec, save_file=\"ModelData.hdf5\")" ] }, { "cell_type": "markdown", "id": "26e26b97-9c6f-4f9a-8b7f-b60181de597a", "metadata": {}, "source": [ "## Beam Section Rendering" ] }, { "cell_type": "code", "execution_count": 5, "id": "9efce99b", "metadata": { "execution": { "iopub.execute_input": "2023-05-06T11:23:54.510078Z", "iopub.status.busy": "2023-05-06T11:23:54.509089Z", "iopub.status.idle": "2023-05-06T11:24:01.112324Z", "shell.execute_reply": "2023-05-06T11:24:01.112324Z", "shell.execute_reply.started": "2023-05-06T11:23:54.510078Z" }, "tags": [] }, "outputs": [], "source": [ "opsvis = opst.OpsVisPyvista(point_size=2, line_width=3,\n", " colors_dict=None, theme=\"document\",\n", " color_map=\"coolwarm\", on_notebook=False,\n", " results_dir=\"opstool_output\")\n", "# beam_sec_paras = dict(color=\"gray\", opacity=0.5, texture=None)\n", "beam_sec_paras = dict(color=None, opacity=1.0, texture=\"images/concrete.jpg\") # or your own image file, \n", "opsvis.model_vis(input_file=\"ModelData.hdf5\",\n", " show_node_label=False, show_ele_label=False,\n", " show_local_crd=False,\n", " show_fix_node=True,\n", " show_constrain_dof=False,\n", " label_size=8,\n", " show_outline=False,\n", " show_beam_sec=True, # here!!!\n", " beam_sec_paras=beam_sec_paras, # here !!!!!\n", " opacity=1.0,\n", " save_fig=None)" ] }, { "cell_type": "raw", "id": "3c418610-3d38-4019-9147-1c49ec76396b", "metadata": { "raw_mimetype": "text/restructuredtext", "tags": [] }, "source": [ ".. image:: images/beam_sec_render.png\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 }