{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Simple beam - Diagrams\n", "In this third notebook, the axial N, shear V and bending moment M diagrams are presented. " ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "# Import the packages needed\n", "import math\n", "import numpy as np \n", "from bokeh.layouts import layout, column, row\n", "from bokeh.models.annotations import Label, Arrow\n", "from bokeh.models.arrow_heads import VeeHead\n", "from bokeh.models import Div, CustomJS, Slider, Spacer, Text\n", "from bokeh.models.widgets import RadioButtonGroup, CheckboxButtonGroup\n", "from bokeh.plotting import figure, show, ColumnDataSource\n", "from bokeh.io import output_notebook\n", "from cienpy import simplebeam as sb\n", "from cienpy import rectangular_section as beam_section\n", "from cienpy import models\n", "from cienpy import javascriptcodes as js\n", "\n", "# output_notebook()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Define the geometry and uniform load. Note that given the graphical nature of the notebook, extreme cases can cause the figures to not be displayed." ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "# Choose the dimensions\n", "L = 6 # [m]\n", "h = 200 # [mm]\n", "b = 100 # [mm]\n", "q = 4; # [kN/m]\n", "P = 10; # [kN]\n", "\n", "# compute the internal forces (at x=L)\n", "discr_NVM = 100\n", "x_discr = np.linspace(0, L, discr_NVM)\n", "N_discr = sb.compute_N(x_discr, P)\n", "V_discr = sb.compute_V(x_discr, q, L)\n", "M_discr = sb.compute_M(x_discr, q, L)\n", "N = N_discr[-1]\n", "V = V_discr[-1]\n", "M = M_discr[-1]\n", "\n", "# compute the parameters\n", "A = beam_section.compute_area(b, h) # [mm2]\n", "Iy = beam_section.compute_inertia_y(b, h) # [mm4] strong axis\n", "Iz = beam_section.compute_inertia_z(b, h) # [mm4] weak axis\n", "\n", "# compute the reactions\n", "Rx = sb.compute_Rx(P)\n", "Ry_l = sb.compute_Ry_l(q, L)\n", "Ry_r = sb.compute_Ry_r(q, L)\n", "\n", "\n", "# constants for the visualisation\n", "SCALE = 10\n", "OFFSET_Q = q\n", "MAX_B = 3*b\n", "MAX_H = 3*h\n", "MAX_Q = q/4*5\n", "\n", "# store the values in a specific format\n", "data_beam = dict(\n", " x=[0, L],\n", " y=[0, 0]\n", ")\n", "\n", "data_scheme_beam = dict(\n", " x=[0, L*SCALE],\n", " y=[0, 0]\n", ")\n", "\n", "data_scheme_q = dict(\n", " x=[0, 0, L*SCALE, L*SCALE],\n", " y=[OFFSET_Q, OFFSET_Q+q, OFFSET_Q+q, OFFSET_Q],\n", " x_fade=[0, 0, L*SCALE, L*SCALE]\n", ")\n", "\n", "initial_position = L\n", "initial_state = 'IDLE' # possible cases: IDLE, R_SEC, L_SEC\n", "initial_FBD = 0 # right=0 left=1\n", "data = dict( # stores every useful single variable\n", " state=[initial_state], \n", " FBD=[initial_FBD],\n", " SCALE=[SCALE],\n", " L=[L],\n", " b=[b],\n", " h=[h],\n", " A=[A],\n", " Iy=[Iy],\n", " Iz=[Iz],\n", " P=[P],\n", " x=[initial_position],\n", " y=[0],\n", " q=[q],\n", " Rx=[Rx],\n", " Ry_l=[Ry_l],\n", " Ry_r=[Ry_r],\n", " N=[N],\n", " V=[V],\n", " M=[M],\n", " xF=[L*SCALE]\n", ")\n", "\n", "source_beam = ColumnDataSource(data_beam)\n", "source_scheme_beam = ColumnDataSource(data_scheme_beam)\n", "source_scheme_q = ColumnDataSource(data_scheme_q)\n", "source = ColumnDataSource(data)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Create the figures, the plots and the widgets (same of Notebook 2 - Actions):" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "FIG_H_B = 200 # height figure beam\n", "FIG_B_B = 700 # width figure beam\n", "FIG_H_S = FIG_H_B # height figure scheme\n", "FIG_B_S = FIG_B_B # width figure scheme\n", "FIG_H_SEC = 600 # height figure section\n", "\n", "options = dict(\n", " toolbar_location=None\n", ")\n", "\n", "# figure for the beam\n", "paddingx = 0.2*L\n", "int_x_b = (0-paddingx, L+paddingx)\n", "int_y_b = (-OFFSET_Q/SCALE, (MAX_Q+OFFSET_Q)/SCALE)\n", "fig_beam = sb.define_fig_beam(int_x_b, int_y_b, options,\n", " f_h=FIG_H_B, f_b=FIG_B_B)\n", "\n", "\n", "# figure for the cross-section\n", "fig_section = sb.define_fig_section(MAX_B, MAX_H*0.8, options, FIG_H_SEC)\n", "\n", "\n", "# Darth Vader for scale (if not visualized, remove this part because the browser don't support it correctly)\n", "h_img = 300 # mm\n", "fig_section.image_url(url=['https://cdn.popcultcha.com.au/media/catalog/product/cache/207e23213cf636ccdef205098cf3c8a3/s/t/star-wars-darth-vader-premium-electronic-helmet-black-series-replica-hasbro-popcultcha.png'], x=-h_img/2, y=-MAX_H/2*1.05, h=h_img, w=h_img/681*700)\n", "fig_section.text(x=[0], y=[-MAX_H/2-h_img*1.15], text_align=\"center\", text=[f\"Darth Vader's helmet for scale (h={h_img} mm)\"], text_font_size=\"10px\")\n", "\n", "\n", "# beam\n", "(beam, support_l, support_r) = sb.draw_beam(fig_beam, source_beam, L,\n", " ratio = (int_y_b[1]-int_y_b[0])/FIG_H_B*100)\n", "\n", "\n", "# section\n", "section = beam_section.draw_section(fig_section, b, h)\n", "\n", "\n", "# show mechanical parameters\n", "div_geo = Div(text=beam_section.div_text_geo(round(h), round(b), round(L),\n", " \"{:.2e}\".format(A),\n", " \"{:.2e}\".format(Iy),\n", " \"{:.2e}\".format(Iz)))\n", "\n", "\n", "# change geometry\n", "slider_b = Slider(\n", " title=\"Change the width b [mm]\",\n", " start=10,\n", " end=MAX_B,\n", " step=10,\n", " value=b\n", ")\n", "slider_h = Slider(\n", " title=\"Change the height h [mm]\",\n", " start=20,\n", " end=MAX_H,\n", " step=20,\n", " value=h\n", ")\n", "\n", "# reference system\n", "axis_arrow_length = 0.8\n", "axis_arrow_scale = 100\n", "models.force_vector(fig_section, axis_arrow_length*10, 0, 0, 0, axis_arrow_length*axis_arrow_scale*1.6, 'gray') # y axis\n", "fig_section.text(x=[0], y=[axis_arrow_length*axis_arrow_scale*1.7], text=[\"y\"], text_color='gray', text_baseline='middle', angle=math.pi/2)\n", "models.force_vector(fig_section, axis_arrow_length*10, 0, -axis_arrow_length*axis_arrow_scale, 0, 0, 'gray') # z axis\n", "fig_section.text(x=[-axis_arrow_length*axis_arrow_scale*1.1], y=[0], text=[\"z\"], text_color='gray', text_align='right', text_baseline='middle')\n", "\n", "\n", "# figure for the forces and moments\n", "fig_scheme = sb.define_figure_scheme(L, SCALE, MAX_Q, OFFSET_Q, options, FIG_H_S, FIG_B_S)\n", "\n", "\n", "# uniform load (beam)\n", "u_load = fig_beam.rect([L/2], [(q/2+OFFSET_Q)/SCALE], width=L, height=q/SCALE,\n", " fill_color='blue', color='navy', fill_alpha=0.6, alpha=0.6)\n", "label_u_load = fig_beam.text(x=[-0.2], y=[OFFSET_Q/SCALE], text=[\"q\"], text_color=\"blue\")\n", "\n", "\n", "# axial force (beam)\n", "axial_force = models.force_vector(fig_beam, P, L+P/SCALE, L, 0, 0, 'green')\n", "label_P_force = fig_beam.text(x=[L+P/2/SCALE], y=[OFFSET_Q/SCALE/2], text=[\"P\"], text_color=\"green\")\n", "\n", "\n", "# position point\n", "pos_opt = dict(\n", " source=source,\n", " size=10,\n", " fill_alpha=0.5,\n", " fill_color=\"magenta\",\n", " color=\"magenta\",\n", " alpha=0.5\n", ")\n", "beam_position = fig_beam.circle('x', 'y', **pos_opt)\n", "forces_position = fig_scheme.circle('xF', 'y', **pos_opt)\n", "\n", "\n", "# beam (scheme)\n", "scheme_beam = fig_scheme.line('x', 'y', source=source_scheme_beam, line_width=2, color='black')\n", "scheme_fade_beam = fig_scheme.line(x=[0, L*SCALE], y=[0, 0], line_width=2, color='black', alpha=0.2)\n", "# uniform load (scheme)\n", "scheme_u_load = fig_scheme.patch('x', 'y', source=source_scheme_q, fill_color='blue', color='navy',\n", " fill_alpha=0.3, alpha=0.3)\n", "scheme_fade_u_load = fig_scheme.patch('x_fade', 'y', source=source_scheme_q, fill_color='blue',\n", " color='navy', fill_alpha=0.3, alpha=0.3)\n", "# axial force (scheme)\n", "scheme_axial_force = models.force_vector(fig_scheme, P, L*SCALE+P, L*SCALE, 0, 0, 'green')\n", "# Reactions (scheme)\n", "scheme_Ry_r = models.force_vector(fig_scheme, Ry_r, L*SCALE, L*SCALE, -Ry_r, 0, 'orange')\n", "scheme_Ry_l = models.force_vector(fig_scheme, Ry_l, 0, 0, -Ry_l, 0, 'orange')\n", "scheme_Rx_l = models.force_vector(fig_scheme, Rx, -Rx, 0, 0, 0, 'orange')\n", "# force N\n", "scheme_N = models.force_vector(fig_scheme, 0, 0, 0, 0, 0, 'red')\n", "# force V\n", "scheme_V = models.force_vector(fig_scheme, 0, 0, 0, 0, 0, 'red')\n", "# moment M\n", "(scheme_M_line, scheme_M_head, source_M) = models.define_curvedArrow(fig_scheme, 0, 0, 0, size_head=0)\n", "\n", "\n", "# change the uniform load q\n", "slider_q = Slider(\n", " title=\"Change the uniform load q [kN/m]\",\n", " start=0.1,\n", " end=MAX_Q,\n", " step=0.1,\n", " value=q\n", ")\n", "\n", "\n", "# choose position of interest\n", "slider_position = Slider(\n", " title=\"Change the position x along the beam [m]\",\n", " start=0,\n", " end=L,\n", " step=0.02,\n", " value=L\n", ")\n", "\n", "\n", "# choose left or right FBD\n", "div_rg_FBD = Div(text=\"Free-body diagram (FBD):\")\n", "radiogroup_FBD = RadioButtonGroup(labels=['Right-hand', 'Left-hand'], active=initial_FBD)\n", "\n", "\n", "# choose axial force or not\n", "div_cb_P = Div(text=f\"Axial force P={P} kN (applied)\")\n", "checkbox_P = CheckboxButtonGroup(labels=['Apply or remove axial force P'], active=[0])\n", "\n", "\n", "# show values of forces and moments\n", "div_forces = Div(text=sb.div_text_forces(P, P, Ry_l, Ry_r, \"No cross section analysed.\", 0, 0, 0))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now define the new figures, renderers and widgets:" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "# figures for the diagrams\n", "options_diag = dict(\n", " toolbar_location=None,\n", " x_axis_label=\"Position [m]\",\n", " plot_width=FIG_B_B,\n", " x_range=fig_beam.x_range\n", ")\n", "fig_N = figure(**options_diag,\n", " tooltips= [(\"Position\", \"@x m\"),\n", " (\"Axial force\", \"@y kN\")],\n", " y_axis_label=\"Axial force N [kN]\",\n", " plot_height=int(FIG_H_B*0.8),\n", " title=\"N V M Diagrams\")\n", "fig_V = figure(**options_diag,\n", " tooltips= [(\"Position\", \"@x m\"),\n", " (\"Shear force\", \"@y kN\")],\n", " y_axis_label=\"Shear force V [kN]\",\n", " plot_height=int(FIG_H_B*0.8))\n", "fig_M = figure(**options_diag,\n", " tooltips= [(\"Position\", \"@x m\"),\n", " (\"Bending moment\", \"@y kNm\")],\n", " y_axis_label=\"Bending moment M [kNm]\",\n", " plot_height=FIG_H_B)\n", "fig_N.xaxis.visible = False\n", "fig_V.xaxis.visible = False\n", "\n", "\n", "# plot N V M\n", "N_diag = models.NVM_diagram(fig_N, x_discr, N_discr, L, source_beam)\n", "V_diag = models.NVM_diagram(fig_V, x_discr, V_discr, L, source_beam)\n", "M_diag = models.NVM_diagram(fig_M, x_discr, M_discr, L, source_beam)\n", "\n", "# point that shows the position that it's analyzed\n", "N_position = fig_N.circle('x', 'N', **pos_opt)\n", "V_position = fig_V.circle('x', 'V', **pos_opt)\n", "M_position = fig_M.circle('x', 'M', **pos_opt)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Configure the logics:" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "args_slider_pos = dict(source=source,\n", " s_sb=source_scheme_beam,\n", " s_q=source_scheme_q,\n", " div_P=div_cb_P,\n", " div_f=div_forces,\n", " fP=scheme_axial_force,\n", " fRx=scheme_Rx_l,\n", " fRyl=scheme_Ry_l,\n", " fRyr=scheme_Ry_r,\n", " fN=scheme_N,\n", " fV=scheme_V,\n", " s_M=source_M,\n", " arr_head=scheme_M_head)\n", "code_slider_pos = f\"\"\"\n", "// retrieve data\n", "const db = source.data\n", "const data_sb = s_sb.data\n", "const data_q = s_q.data\n", "const FBD = db['FBD'][0]\n", "const pos = cb_obj.value\n", "const q = db['q'][0]\n", "const L = db['L'][0]\n", "\n", "// update data\n", "db['N'][0] = compute_N(db['P'][0])\n", "db['V'][0] = compute_V(pos, q, L)\n", "db['M'][0] = compute_M(pos, q, L)\n", "db['x'][0] = pos\n", "\n", "// check state\n", "check_state(db)\n", "\n", "// update:\n", "update_internal_forces(db, fN, fV, arr_head, s_M)\n", "update_scheme_position(db, data_sb, data_q)\n", "update_reactions(db, fRx, fRyl, fRyr)\n", "update_external_forces(db, fP, div_P)\n", "update_div_forces(db, div_f)\n", "\n", "// apply the changes\n", "source.change.emit()\n", "s_sb.change.emit()\n", "s_q.change.emit()\n", "\n", "// declare functions\n", "{sb.implement_compute_NJS()}\n", "{sb.implement_compute_VJS()}\n", "{sb.implement_compute_MJS()}\n", "{sb.implement_update_internal_forcesJS()}\n", "{sb.implement_update_scheme_positionJS()}\n", "{sb.implement_update_reactionsJS()}\n", "{sb.implement_update_external_forcesJS()}\n", "{sb.implement_update_div_forcesJS()}\n", "{js.implement_linspaceJS()}\n", "{js.implement_parabolaJS()}\n", "{js.implement_arrow_alphaJS()}\n", "{js.implement_update_arrowJS()}\n", "{js.implement_arrow_growthJS()}\n", "{js.implement_update_curvedArrowJS()}\n", "{js.implement_update_NVM_diagramJS()}\n", "{models.implement_check_stateJS()}\n", "\"\"\"\n", "updade_slider_pos = CustomJS(args=args_slider_pos, code=code_slider_pos)\n", "\n", "\n", "args_slider_b_h = dict(source=source,\n", " s_b=source_beam,\n", " div=div_geo, \n", " section=section,\n", " support_r=support_r)\n", "code_change_b = f\"\"\"\n", "// retrieve data used\n", "const db = source.data\n", "const b = cb_obj.value // value of the slider\n", "const h = db['h'][0]\n", "const A = compute_area(b, h)\n", "const Iy = compute_inertia_y(b, h)\n", "\n", "// apply the changes\n", "db['b'][0] = b\n", "db['A'][0] = A\n", "db['Iy'][0] = Iy\n", "db['Iz'][0] = compute_inertia_z(b, h)\n", "\n", "// update\n", "update_div_geo(db, div)\n", "update_section(db, section)\n", "\n", "// emit the changes\n", "source.change.emit()\n", "\n", "{beam_section.implement_update_div_geoJS()}\n", "{beam_section.implement_update_sectionJS()}\n", "{beam_section.implement_compute_areaJS()}\n", "{beam_section.implement_compute_inertia_yJS()}\n", "{beam_section.implement_compute_inertia_zJS()}\n", "\"\"\"\n", "update_b = CustomJS(args=args_slider_b_h, code=code_change_b)\n", "\n", "\n", "code_change_h = f\"\"\"\n", "// retrieve data used\n", "const db = source.data\n", "const b = db['b'][0]\n", "const h = cb_obj.value // value of the slider\n", "const A = compute_area(b, h)\n", "const Iy = compute_inertia_y(b, h)\n", "\n", "// apply the changes\n", "db['h'][0] = h\n", "db['A'][0] = A\n", "db['Iy'][0] = Iy\n", "db['Iz'][0] = compute_inertia_z(b, h)\n", "\n", "// update\n", "update_div_geo(db, div)\n", "update_section(db, section)\n", "\n", "// emit the changes\n", "source.change.emit()\n", "\n", "{beam_section.implement_update_div_geoJS()}\n", "{beam_section.implement_update_sectionJS()}\n", "{beam_section.implement_compute_areaJS()}\n", "{beam_section.implement_compute_inertia_yJS()}\n", "{beam_section.implement_compute_inertia_zJS()}\n", "\"\"\"\n", "update_h = CustomJS(args=args_slider_b_h, code=code_change_h)\n", "\n", "\n", "args_checkbox_P = dict(source=source,\n", " s_M=source_M,\n", " div_P=div_cb_P,\n", " div_f=div_forces,\n", " fP=scheme_axial_force, \n", " fRx=scheme_Rx_l,\n", " fRyl=scheme_Ry_l,\n", " fRyr=scheme_Ry_r, \n", " fN=scheme_N,\n", " fV=scheme_V, \n", " arr_head=scheme_M_head,\n", " N_diag=N_diag)\n", "code_checkbox_P = f\"\"\"\n", "// retrieve var from the object that uses callback\n", "var f = cb_obj.active // checkbox P\n", "if (f.length==0) f = [1]\n", "const db = source.data\n", "\n", "// apply the changes\n", "db['P'][0] = {P}*(1-f)\n", "db['N'][0] = compute_N(db['P'][0])\n", "db['Rx'][0] = compute_Rx(db['P'][0])\n", "\n", "// update\n", "update_reactions(db, fRx, fRyl, fRyr)\n", "update_external_forces(db, fP, div_P)\n", "update_N_diagram(db, N_diag)\n", "update_internal_forces(db, fN, fV, arr_head, s_M)\n", "update_div_forces(db, div_f)\n", "\n", "// emit the changes\n", "source.change.emit()\n", "\n", "// declare functions\n", "{sb.implement_update_external_forcesJS()}\n", "{sb.implement_update_reactionsJS()}\n", "{sb.implement_compute_RxJS()}\n", "{js.implement_update_arrowJS()}\n", "{js.implement_arrow_alphaJS()}\n", "{js.implement_update_NVM_diagramJS()}\n", "{sb.implement_compute_NJS()}\n", "{sb.implement_update_N_diagramJS(discr_NVM)}\n", "{sb.implement_update_internal_forcesJS()}\n", "{js.implement_update_curvedArrowJS()}\n", "{sb.implement_update_div_forcesJS()}\n", "{js.implement_arrow_growthJS()}\n", "\"\"\"\n", "update_checkbox_P = CustomJS(args=args_checkbox_P, code=code_checkbox_P)\n", "\n", "\n", "args_radiogroup_FBD = dict(source=source, \n", " s_sb=source_scheme_beam,\n", " s_q=source_scheme_q,\n", " s_M=source_M, \n", " div_P=div_cb_P,\n", " fP=scheme_axial_force,\n", " fRx=scheme_Rx_l,\n", " fRyl=scheme_Ry_l,\n", " fRyr=scheme_Ry_r,\n", " fN=scheme_N, \n", " fV=scheme_V,\n", " arr_head=scheme_M_head)\n", "code_radiogroup_FBD = f\"\"\"\n", "// retrieve data\n", "const db = source.data\n", "const FBD = cb_obj.active\n", "const data_sb = s_sb.data\n", "const data_q = s_q.data\n", "const pos = db['x'][0]\n", "\n", "// apply the changes\n", "db['FBD'][0] = FBD\n", "\n", "// update\n", "check_state(db)\n", "update_internal_forces(db, fN, fV, arr_head, s_M)\n", "update_scheme_position(db, data_sb, data_q)\n", "update_reactions(db, fRx, fRyl, fRyr)\n", "update_external_forces(db, fP, div_P)\n", "\n", "// emit the changes\n", "source.change.emit()\n", "s_sb.change.emit()\n", "s_q.change.emit()\n", "\n", "{models.implement_check_stateJS()}\n", "{sb.implement_update_internal_forcesJS()}\n", "{sb.implement_update_scheme_positionJS()}\n", "{js.implement_update_curvedArrowJS()}\n", "{js.implement_update_arrowJS()}\n", "{sb.implement_update_reactionsJS()}\n", "{sb.implement_update_external_forcesJS()}\n", "{js.implement_arrow_alphaJS()}\n", "{js.implement_arrow_growthJS()}\n", "\"\"\"\n", "update_radiogroup_FBD = CustomJS(args=args_radiogroup_FBD, code=code_radiogroup_FBD)\n", "\n", "\n", "args_slider_q = dict(source=source,\n", " s_q=source_scheme_q,\n", " s_M=source_M,\n", " div_f=div_forces,\n", " div_P=div_cb_P,\n", " fP=scheme_axial_force,\n", " fRx=scheme_Rx_l,\n", " fRyl=scheme_Ry_l,\n", " fRyr=scheme_Ry_r,\n", " fN=scheme_N,\n", " fV=scheme_V,\n", " arr_head=scheme_M_head,\n", " V_diag=V_diag,\n", " M_diag=M_diag)\n", "code_slider_q = f\"\"\"\n", "// retrieve data\n", "const db = source.data\n", "const q = cb_obj.value\n", "const pos = db['x'][0]\n", "const L = db['L'][0]\n", "\n", "// update q\n", "db['q'][0] = q\n", "db['V'][0] = compute_V(pos, q, L)\n", "db['M'][0] = compute_M(pos, q, L)\n", "db['Ry_l'][0] = compute_Ry_l(q, L)\n", "db['Ry_r'][0] = compute_Ry_r(q, L)\n", "\n", "// update\n", "update_u_load(db, s_q)\n", "update_reactions(db, fRx, fRyl, fRyr)\n", "update_external_forces(db, fP, div_P)\n", "update_V_diagram(db, V_diag)\n", "update_M_diagram(db, M_diag)\n", "update_internal_forces(db, fN, fV, arr_head, s_M)\n", "update_div_forces(db, div_f)\n", "\n", "// apply changes\n", "source.change.emit()\n", "\n", "// declare functions\n", "{js.implement_update_arrowJS()}\n", "{js.implement_linspaceJS()}\n", "{js.implement_parabolaJS()}\n", "{js.implement_arrow_alphaJS()}\n", "{js.implement_update_arrowJS()}\n", "{sb.implement_compute_VJS()}\n", "{sb.implement_compute_MJS()}\n", "{sb.implement_compute_Ry_lJS()}\n", "{sb.implement_compute_Ry_rJS()}\n", "{js.implement_update_NVM_diagramJS()}\n", "{sb.implement_update_V_diagramJS(discr_NVM)}\n", "{sb.implement_update_M_diagramJS(discr_NVM)}\n", "{sb.implement_update_reactionsJS()}\n", "{sb.implement_update_external_forcesJS()}\n", "{sb.implement_update_u_loadJS(OFFSET_Q)}\n", "{sb.implement_update_internal_forcesJS()}\n", "{js.implement_update_curvedArrowJS()}\n", "{sb.implement_update_div_forcesJS()}\n", "{js.implement_arrow_growthJS()}\n", "\"\"\"\n", "update_slider_q = CustomJS(args=args_slider_q, code=code_slider_q)\n", "\n", "\n", "# apply the logics\n", "slider_b.js_on_change('value', update_b)\n", "slider_h.js_on_change('value', update_h)\n", "slider_position.js_on_change('value', updade_slider_pos)\n", "checkbox_P.js_on_click(update_checkbox_P)\n", "radiogroup_FBD.js_on_click(update_radiogroup_FBD)\n", "slider_q.js_on_change('value', update_slider_q)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Build the layout and show the figures. Note that the forces in the scheme are updated after moving the position of the point with the slider.\n", "Note that the value of the forces and moments shown below represents the intensity, thus is always positive. The direction is given by the vector in the scheme." ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "libva error: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Opening in existing browser session.\n" ] } ], "source": [ "padding_layout = 10\n", "layout1 = layout([\n", " [column(row(column(fig_scheme,\n", " row(fig_section, Spacer(width=padding_layout), column(Spacer(height=padding_layout),\n", " slider_b,\n", " slider_h,\n", " div_geo,\n", " Spacer(height=padding_layout),\n", " slider_position,\n", " slider_q,\n", " div_rg_FBD,\n", " radiogroup_FBD,\n", " div_cb_P,\n", " checkbox_P))),\n", " column(fig_beam,\n", " Spacer(height=padding_layout),\n", " fig_N,\n", " fig_V,\n", " fig_M,\n", " div_forces))\n", " )],\n", "])\n", "\n", "show(layout1)" ] } ], "metadata": { "interpreter": { "hash": "f29f3a16a5c47811d2900cf82e6584cc83572ddcd5db25d9cf9bef77823b3d45" }, "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.8.10" } }, "nbformat": 4, "nbformat_minor": 2 }