{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Beam2" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "%matplotlib widget" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "from pysketcher import *" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "import time" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "\"\"\"A more sophisticated beam than in beam1.py.\"\"\"\n", "def beam():\n", " L = 8.0\n", " a = 3*L/4\n", " b = L - a\n", " H = 1.0\n", " xpos = 0.0\n", " ypos = 3.0\n", "\n", " drawing_tool.set_coordinate_system(\n", " xmin=-3, xmax=xpos+1.5*L,\n", " ymin=0, ymax=ypos+5*H,\n", " axis=False)\n", " drawing_tool.set_linecolor('blue')\n", " #drawing_tool.set_grid(True)\n", " drawing_tool.set_fontsize(16)\n", "\n", " A = point(xpos,ypos)\n", "\n", " beam = Rectangle(A, L, H)\n", "\n", " h = L/16 # size of support, clamped wall etc\n", "\n", " clamped = Rectangle(A - point(h,0) - point(0,2*h), h,\n", " 6*h).set_filled_curves(pattern='/')\n", "\n", " load = ConstantBeamLoad(A + point(0,H), L, H)\n", " load.set_linewidth(1).set_linecolor('black')\n", " load_text = Text('$w$',\n", " load.geometric_features()['mid_top'] +\n", " point(0,h/2.))\n", "\n", " B = A + point(a, 0)\n", " C = B + point(b, 0)\n", "\n", " support = SimplySupportedBeam(B, h) # pt B is simply supported\n", "\n", "\n", " R1 = Force(A-point(0,2*H), A, '$R_1$', text_spacing=1./50)\n", " R1.set_linewidth(3).set_linecolor('black')\n", " R2 = Force(B-point(0,2*H),\n", " support.geometric_features()['mid_support'],\n", " '$R_2$', text_spacing=1./50)\n", " R2.set_linewidth(3).set_linecolor('black')\n", " M1 = Moment('$M_1$', center=A + point(-H, H/2), radius=H/2,\n", " left=True, text_spacing=1/30.)\n", " M1.set_linecolor('black')\n", "\n", " ab_level = point(0, 3*h)\n", " a_dim = Distance_wText(A - ab_level, B - ab_level, '$a$')\n", " b_dim = Distance_wText(B - ab_level, C - ab_level, '$b$')\n", " dims = Composition({'a': a_dim, 'b': b_dim})\n", " symbols = Composition(\n", " {'R1': R1, 'R2': R2, 'M1': M1,\n", " 'w': load, 'w text': load_text,\n", " 'A': Text('$A$', A+point(0.7*h,-0.9*h)),\n", " 'B': Text('$B$',\n", " support.geometric_features()['mid_support']-\n", " point(1.25*h,0)),\n", " 'C': Text('$C$', C+point(h/2,-h/2))})\n", "\n", " x_axis = Axis(A + point(L+h, H/2), 2*H, '$x$',).\\\n", " set_linecolor('black')\n", " y_axis = Axis(A + point(0,H/2), 3.5*H, '$y$',\n", " label_alignment='left',\n", " rotation_angle=90).set_linecolor('black')\n", " axes = Composition({'x axis': x_axis, 'y axis': y_axis})\n", "\n", " annotations = Composition({'dims': dims, 'symbols': symbols,\n", " 'axes': axes})\n", " beam = Composition({'beam': beam, 'support': support,\n", " 'clamped end': clamped, 'load': load})\n", "\n", " def deflection(x, a, b, w):\n", " import numpy as np\n", " R1 = 5./8*w*a - 3*w*b**2/(4*a)\n", " R2 = 3./8*w*a + w*b + 3*w*b**2/(4*a)\n", " M1 = R1*a/3 - w*a**2/12\n", " y = -(M1/2.)*x**2 + 1./6*R1*x**3 - w/24.*x**4 + \\\n", " 1./6*R2*np.where(x > a, 1, 0)*(x-a)**3\n", " return y\n", "\n", " x = linspace(0, L, 101)\n", " y = deflection(x, a, b, w=1.0)\n", " y /= abs(y.max() - y.min())\n", " y += ypos + H/2\n", "\n", " elastic_line = Curve(x, y).\\\n", " set_linecolor('red').\\\n", " set_linestyle('dashed').\\\n", " set_linewidth(3)\n", "\n", " beam.draw()\n", " beam.draw_dimensions()\n", " annotations.draw()\n", " elastic_line.draw()\n", " drawing_tool.display()" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "80c268fe8be04b52b488fdeb4bcb8c58", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "drawing_tool.mpl.gcf().canvas" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.8.5" } }, "nbformat": 4, "nbformat_minor": 4 }