{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "cb042900",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-03T17:10:30.514909Z",
     "iopub.status.busy": "2022-04-03T17:10:30.513909Z",
     "iopub.status.idle": "2022-04-03T17:10:30.718914Z",
     "shell.execute_reply": "2022-04-03T17:10:30.718914Z"
    }
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "np.set_printoptions(precision=5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "1aa8ea96",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-03T17:10:30.723919Z",
     "iopub.status.busy": "2022-04-03T17:10:30.722910Z",
     "iopub.status.idle": "2022-04-03T17:10:33.493903Z",
     "shell.execute_reply": "2022-04-03T17:10:33.493903Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 15452 characters]\n",
      "text/plain": [
       "<Figure size 864x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "filenames": {
       "image/png": "C:\\Users\\David\\OneDrive\\Desktop\\imwspy\\stanpy\\stanpy\\docs\\_build\\jupyter_execute\\user_guide\\straight_beam_constant_cs_1_0.png"
      },
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "import stanpy as stp\n",
    "\n",
    "EI = 32000  # kNm²\n",
    "l = 6  # m\n",
    "q = 10  # kN/m\n",
    "\n",
    "s = {\"EI\": EI, \"l\": 6, \"q\": q, \"bc_i\":{\"w\":0, \"M\":0},  \"bc_k\":{\"w\":0, \"M\":0, \"H\":0}}\n",
    "\n",
    "fig, ax = plt.subplots(figsize=(12, 5))\n",
    "stp.plot_system(ax, s)\n",
    "stp.plot_load(ax, s)\n",
    "ax.grid(linestyle=\":\")\n",
    "ax.set_axisbelow(True)\n",
    "ax.set_ylim(-0.75, 1.2)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "d43147cc",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-03T17:10:33.497906Z",
     "iopub.status.busy": "2022-04-03T17:10:33.497906Z",
     "iopub.status.idle": "2022-04-03T17:10:33.523907Z",
     "shell.execute_reply": "2022-04-03T17:10:33.523907Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Z_a = [0.0000e+00 2.8125e-03 0.0000e+00 3.0000e+01 1.0000e+00]\n",
      "Z_b = [ 0.0000e+00 -2.8125e-03  0.0000e+00 -3.0000e+01  1.0000e+00]\n"
     ]
    }
   ],
   "source": [
    "dx = 1e-9\n",
    "x = np.linspace(0, l, 100)\n",
    "x = np.sort(np.append(x, [l / 2, l / 4, 3 * l / 4, l-dx]))\n",
    "Z_a, Z_b  = stp.tr_solver(s)\n",
    "Fxa = stp.tr(s, x=x)\n",
    "Z_x = Fxa.dot(Z_a)\n",
    "\n",
    "print(\"Z_a =\", Z_a)\n",
    "print(\"Z_b =\", Z_b)\n",
    "\n",
    "w_x = Z_x[:, 0]\n",
    "phi_x = Z_x[:, 1]\n",
    "M_x = Z_x[:, 2]\n",
    "V_x = Z_x[:, 3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "808a6dcd",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-03T17:10:33.527906Z",
     "iopub.status.busy": "2022-04-03T17:10:33.527906Z",
     "iopub.status.idle": "2022-04-03T17:10:33.779909Z",
     "shell.execute_reply": "2022-04-03T17:10:33.778904Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 32772 characters]\n",
      "text/plain": [
       "<Figure size 864x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "filenames": {
       "image/png": "C:\\Users\\David\\OneDrive\\Desktop\\imwspy\\stanpy\\stanpy\\docs\\_build\\jupyter_execute\\user_guide\\straight_beam_constant_cs_3_0.png"
      },
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "scale = 0.5\n",
    "fig, ax = plt.subplots(figsize=(12, 5))\n",
    "stp.plot_system(ax, s)\n",
    "stp.plot_M(ax, x=x, Mx=M_x, annotate_x=[0, l / 2, l / 4, 3 * l / 4, l], fill_p=\"red\", scale=scale, alpha=0.2)\n",
    "ax.grid(linestyle=\":\")\n",
    "ax.set_axisbelow(True)\n",
    "ax.set_ylim(-0.8, 0.1)\n",
    "ax.set_ylabel(\"M/Mmax*{}\".format(scale))\n",
    "ax.set_title(\"[M] = kNm\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "1c32c3ef",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-03T17:10:33.783907Z",
     "iopub.status.busy": "2022-04-03T17:10:33.782904Z",
     "iopub.status.idle": "2022-04-03T17:10:34.018907Z",
     "shell.execute_reply": "2022-04-03T17:10:34.018907Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 33776 characters]\n",
      "text/plain": [
       "<Figure size 864x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "filenames": {
       "image/png": "C:\\Users\\David\\OneDrive\\Desktop\\imwspy\\stanpy\\stanpy\\docs\\_build\\jupyter_execute\\user_guide\\straight_beam_constant_cs_4_0.png"
      },
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "scale = 0.5\n",
    "fig, ax = plt.subplots(figsize=(12, 5))\n",
    "stp.plot_system(ax, s, watermark_pos=1)\n",
    "stp.plot_solution(ax, x=x, y=V_x, annotate_x=[0, l / 2, l / 4, 3 * l / 4, l-dx], fill_p=\"red\", fill_n=\"blue\", scale=scale, alpha=0.2)\n",
    "ax.grid(linestyle=\":\")\n",
    "ax.set_axisbelow(True)\n",
    "ax.set_ylim(-0.8, 0.8)\n",
    "ax.set_ylabel(\"V/Vmax*{}\".format(scale))\n",
    "ax.set_title(\"[V] = kN\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "93c919a1",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-03T17:10:34.022907Z",
     "iopub.status.busy": "2022-04-03T17:10:34.022907Z",
     "iopub.status.idle": "2022-04-03T17:10:34.228904Z",
     "shell.execute_reply": "2022-04-03T17:10:34.228904Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 23244 characters]\n",
      "text/plain": [
       "<Figure size 864x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "filenames": {
       "image/png": "C:\\Users\\David\\OneDrive\\Desktop\\imwspy\\stanpy\\stanpy\\docs\\_build\\jupyter_execute\\user_guide\\straight_beam_constant_cs_5_0.png"
      },
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "scale = 0.2\n",
    "fig, ax = plt.subplots(figsize=(12, 5))\n",
    "stp.plot_system(ax, s, watermark_pos=1, lw=1, linestyle=\":\", c=\"#111111\")\n",
    "stp.plot_w(ax, x=x, wx=w_x, scale=scale, linestyle=\"-\")\n",
    "ax.grid(linestyle=\":\")\n",
    "ax.set_axisbelow(True)\n",
    "ax.set_ylim(-0.8, 0.8)\n",
    "ax.set_ylabel(\"w/wmax*{}\".format(scale))\n",
    "ax.set_title(\"[w] = m\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "48fb82e1",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-03T17:10:34.232908Z",
     "iopub.status.busy": "2022-04-03T17:10:34.232908Z",
     "iopub.status.idle": "2022-04-03T17:10:34.453903Z",
     "shell.execute_reply": "2022-04-03T17:10:34.453903Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 16980 characters]\n",
      "text/plain": [
       "<Figure size 864x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "filenames": {
       "image/png": "C:\\Users\\David\\OneDrive\\Desktop\\imwspy\\stanpy\\stanpy\\docs\\_build\\jupyter_execute\\user_guide\\straight_beam_constant_cs_6_0.png"
      },
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "import stanpy as stp\n",
    "\n",
    "EI = 32000  # kNm²\n",
    "l = 6  # m\n",
    "P = 2  # kN\n",
    "\n",
    "s = {\n",
    "    \"EI\": EI,\n",
    "    \"l\": 6,\n",
    "    \"P1\": (P, 2),\n",
    "    \"P2\": (P + 1, 3),\n",
    "    \"P3\": (P + 2, 4),\n",
    "    \"bc_i\": {\"w\": 0, \"M\": 0},\n",
    "    \"bc_k\": {\"w\": 0, \"M\": 0, \"H\": 0},\n",
    "}\n",
    "\n",
    "fig, ax = plt.subplots(figsize=(12, 5))\n",
    "stp.plot_system(ax, s)\n",
    "stp.plot_load(ax, s)\n",
    "ax.grid(linestyle=\":\")\n",
    "ax.set_axisbelow(True)\n",
    "ax.set_ylim(-0.75, 1.0)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "94c1d8b4",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-03T17:10:34.457907Z",
     "iopub.status.busy": "2022-04-03T17:10:34.456905Z",
     "iopub.status.idle": "2022-04-03T17:10:34.483907Z",
     "shell.execute_reply": "2022-04-03T17:10:34.483907Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Z_a = [0.00000e+00 5.72049e-04 0.00000e+00 4.16667e+00 1.00000e+00]\n",
      "Z_b = [-0.00000e+00 -5.99826e-04  0.00000e+00 -4.83333e+00  1.00000e+00]\n"
     ]
    }
   ],
   "source": [
    "dx = 1e-9\n",
    "x = np.linspace(0, l, 500)\n",
    "annotation = np.array([2-dx, 2, 3-dx, 3, 4-dx, 4, 6-dx])\n",
    "x = np.sort(np.append(x, annotation))\n",
    "\n",
    "Fxa = stp.tr(s, x=x)\n",
    "Z_a, Z_b = stp.tr_solver(s)\n",
    "Z_x = Fxa.dot(Z_a)\n",
    "\n",
    "print(\"Z_a =\", Z_a)\n",
    "print(\"Z_b =\", Z_b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "edd8c2e5",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-03T17:10:34.487910Z",
     "iopub.status.busy": "2022-04-03T17:10:34.487910Z",
     "iopub.status.idle": "2022-04-03T17:10:34.513908Z",
     "shell.execute_reply": "2022-04-03T17:10:34.513908Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Z_a = [0.00000e+00 5.72049e-04 0.00000e+00 4.16667e+00 1.00000e+00]\n",
      "Z_b = [-0.00000e+00 -5.99826e-04  0.00000e+00 -4.83333e+00  1.00000e+00]\n"
     ]
    }
   ],
   "source": [
    "s1 = {\"EI\": EI, \"l\": 2, \"P1\": (P, 2), \"bc_i\": {\"w\": 0, \"M\": 0}}\n",
    "s2 = {\"EI\": EI, \"l\": 1, \"P2\": (P+1, 1)}\n",
    "s3 = {\"EI\": EI, \"l\": 1, \"P3\": (P+2, 1)}\n",
    "s4 = {\"EI\": EI, \"l\": 2, \"bc_k\": {\"w\": 0, \"M\": 0, \"H\": 0}}\n",
    "\n",
    "s = [s1, s2, s3, s4]\n",
    "Fxa = stp.tr(*s, x=x)\n",
    "Z_a, Z_b = stp.tr_solver(*s)\n",
    "Z_x = Fxa.dot(Z_a)\n",
    "\n",
    "print(\"Z_a =\", Z_a)\n",
    "print(\"Z_b =\", Z_b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "a67dad31",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-03T17:10:34.517910Z",
     "iopub.status.busy": "2022-04-03T17:10:34.517910Z",
     "iopub.status.idle": "2022-04-03T17:10:34.543903Z",
     "shell.execute_reply": "2022-04-03T17:10:34.543903Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Z_a = [0.00000e+00 5.72049e-04 0.00000e+00 4.16667e+00 1.00000e+00]\n",
      "Z_b = [-0.00000e+00 -5.99826e-04  0.00000e+00 -4.83333e+00  1.00000e+00]\n"
     ]
    }
   ],
   "source": [
    "s1 = {\"EI\": EI, \"l\": 2, \"bc_i\": {\"w\": 0, \"M\": 0}}\n",
    "s2 = {\"EI\": EI, \"l\": 1, \"P1\": (P, 0)}\n",
    "s3 = {\"EI\": EI, \"l\": 1, \"P2\": (P+1, 0)}\n",
    "s4 = {\"EI\": EI, \"l\": 2, \"P1\": (P+2, 0), \"bc_k\": {\"w\": 0, \"M\": 0, \"H\": 0}}\n",
    "\n",
    "s = [s1, s2, s3, s4]\n",
    "\n",
    "Fxa = stp.tr(*s, x=x)\n",
    "Z_a, Z_b = stp.tr_solver(*s)\n",
    "Z_x = Fxa.dot(Z_a)\n",
    "\n",
    "print(\"Z_a =\", Z_a)\n",
    "print(\"Z_b =\", Z_b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "726afdda",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-03T17:10:34.547909Z",
     "iopub.status.busy": "2022-04-03T17:10:34.546906Z",
     "iopub.status.idle": "2022-04-03T17:10:34.768904Z",
     "shell.execute_reply": "2022-04-03T17:10:34.768904Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 33232 characters]\n",
      "text/plain": [
       "<Figure size 864x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "filenames": {
       "image/png": "C:\\Users\\David\\OneDrive\\Desktop\\imwspy\\stanpy\\stanpy\\docs\\_build\\jupyter_execute\\user_guide\\straight_beam_constant_cs_10_0.png"
      },
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "w_x = Z_x[:, 0]\n",
    "phi_x = Z_x[:, 1]\n",
    "M_x = Z_x[:, 2]\n",
    "V_x = Z_x[:, 3]\n",
    "\n",
    "scale = 0.5\n",
    "fig, ax = plt.subplots(figsize=(12, 5))\n",
    "stp.plot_system(ax, *s)\n",
    "stp.plot_M(ax, x=x, Mx=M_x, annotate_x=[2, 3, 4], fill_p=\"red\", scale=scale, alpha=0.2)\n",
    "ax.grid(linestyle=\":\")\n",
    "ax.set_axisbelow(True)\n",
    "ax.set_ylim(-0.8, 0.1)\n",
    "ax.set_ylabel(\"M/Mmax*{}\".format(scale))\n",
    "ax.set_title(\"[M] = kNm\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "bd37dc06",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-03T17:10:34.772908Z",
     "iopub.status.busy": "2022-04-03T17:10:34.772908Z",
     "iopub.status.idle": "2022-04-03T17:10:34.993903Z",
     "shell.execute_reply": "2022-04-03T17:10:34.993903Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 24148 characters]\n",
      "text/plain": [
       "<Figure size 864x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "filenames": {
       "image/png": "C:\\Users\\David\\OneDrive\\Desktop\\imwspy\\stanpy\\stanpy\\docs\\_build\\jupyter_execute\\user_guide\\straight_beam_constant_cs_11_0.png"
      },
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "scale = 0.5\n",
    "fig, ax = plt.subplots(figsize=(12, 5))\n",
    "stp.plot_system(ax, *s, watermark_pos=1)\n",
    "stp.plot_solution(ax, x=x, y=V_x, annotate_x=[0, [2-dx, 2], 3-dx, 3, [4, 4-dx], 6-dx], fill_p=\"red\", fill_n=\"blue\", scale=scale, alpha=0.2)\n",
    "ax.grid(linestyle=\":\")\n",
    "ax.set_axisbelow(True)\n",
    "ax.set_ylim(-1.5, 1.5)\n",
    "ax.set_ylabel(\"V/Vmax*{}\".format(scale))\n",
    "ax.set_title(\"[V] = kN\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "b4c454f8",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-03T17:10:34.998909Z",
     "iopub.status.busy": "2022-04-03T17:10:34.997913Z",
     "iopub.status.idle": "2022-04-03T17:10:35.205910Z",
     "shell.execute_reply": "2022-04-03T17:10:35.203913Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 23856 characters]\n",
      "text/plain": [
       "<Figure size 864x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "filenames": {
       "image/png": "C:\\Users\\David\\OneDrive\\Desktop\\imwspy\\stanpy\\stanpy\\docs\\_build\\jupyter_execute\\user_guide\\straight_beam_constant_cs_12_0.png"
      },
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "scale = 0.2\n",
    "fig, ax = plt.subplots(figsize=(12, 5))\n",
    "stp.plot_system(ax, *s, watermark_pos=1, lw=1, linestyle=\":\", c=\"#111111\")\n",
    "stp.plot_w(ax, x=x, wx=w_x, scale=scale, linestyle=\"-\")\n",
    "ax.grid(linestyle=\":\")\n",
    "ax.set_axisbelow(True)\n",
    "ax.set_ylim(-0.8, 0.8)\n",
    "ax.set_ylabel(\"w/wmax*{}\".format(scale))\n",
    "ax.set_title(\"[w] = m\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "a4447828",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-03T17:10:35.209904Z",
     "iopub.status.busy": "2022-04-03T17:10:35.209904Z",
     "iopub.status.idle": "2022-04-03T17:10:35.428911Z",
     "shell.execute_reply": "2022-04-03T17:10:35.428911Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 15716 characters]\n",
      "text/plain": [
       "<Figure size 864x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "filenames": {
       "image/png": "C:\\Users\\David\\OneDrive\\Desktop\\imwspy\\stanpy\\stanpy\\docs\\_build\\jupyter_execute\\user_guide\\straight_beam_constant_cs_13_0.png"
      },
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "import stanpy as stp\n",
    "\n",
    "EI = 32000  # kNm²\n",
    "l = 6  # m\n",
    "P = 10  # kN\n",
    "q = 10 # kN/m\n",
    "N = -1000 # kN\n",
    "\n",
    "s = {\n",
    "    \"EI\": EI,\n",
    "    \"l\": 6,\n",
    "    \"q\":q,\n",
    "    \"P1\": (P, l/3),\n",
    "    \"N\":N,\n",
    "    \"bc_i\": {\"w\": 0, \"M\": 0},\n",
    "    \"bc_k\": {\"w\": 0, \"M\": 0, \"H\": 0},\n",
    "}\n",
    "\n",
    "fig, ax = plt.subplots(figsize=(12, 5))\n",
    "stp.plot_system(ax, s)\n",
    "stp.plot_load(ax, s)\n",
    "ax.grid(linestyle=\":\")\n",
    "ax.set_axisbelow(True)\n",
    "ax.set_ylim(-0.75, 2)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "00570dab",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-03T17:10:35.433917Z",
     "iopub.status.busy": "2022-04-03T17:10:35.432911Z",
     "iopub.status.idle": "2022-04-03T17:10:35.459907Z",
     "shell.execute_reply": "2022-04-03T17:10:35.458905Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Z_a = [0.00000e+00 3.94707e-03 0.00000e+00 3.66667e+01 1.00000e+00]\n",
      "Z_b = [ 0.00000e+00 -3.80371e-03  0.00000e+00 -3.33333e+01  1.00000e+00]\n"
     ]
    }
   ],
   "source": [
    "dx = 1e-9\n",
    "x = np.linspace(0, l, 500)\n",
    "annotation = np.array([0, l / 3 - dx, l / 3, l / 2, 2, 3, 4, l-dx])\n",
    "x = np.sort(np.append(x, annotation))\n",
    "\n",
    "Fxa = stp.tr(s, x=x)\n",
    "Z_a, Z_b = stp.tr_solver(s)\n",
    "Z_x = Fxa.dot(Z_a)\n",
    "\n",
    "print(\"Z_a =\", Z_a)\n",
    "print(\"Z_b =\", Z_b)\n",
    "\n",
    "w_x = Z_x[:, 0]\n",
    "phi_x = Z_x[:, 1]\n",
    "M_x = Z_x[:, 2]\n",
    "R_x = Z_x[:, 3]\n",
    "\n",
    "V_x = stp.R_to_Q(x, Z_x, s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "11407a15",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-03T17:10:35.462908Z",
     "iopub.status.busy": "2022-04-03T17:10:35.462908Z",
     "iopub.status.idle": "2022-04-03T17:10:35.728916Z",
     "shell.execute_reply": "2022-04-03T17:10:35.728916Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 28824 characters]\n",
      "text/plain": [
       "<Figure size 864x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "filenames": {
       "image/png": "C:\\Users\\David\\OneDrive\\Desktop\\imwspy\\stanpy\\stanpy\\docs\\_build\\jupyter_execute\\user_guide\\straight_beam_constant_cs_15_0.png"
      },
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "scale = 0.5\n",
    "fig, ax = plt.subplots(figsize=(12, 5))\n",
    "stp.plot_system(ax, s)\n",
    "stp.plot_M(ax, x=x, Mx=M_x, annotate_x=[0, l/3, x[M_x==np.max(M_x)], l], fill_p=\"red\", scale=scale, alpha=0.2)\n",
    "ax.grid(linestyle=\":\")\n",
    "ax.set_axisbelow(True)\n",
    "ax.set_ylim(-1, 0.1)\n",
    "ax.set_ylabel(\"M/Mmax*{}\".format(scale))\n",
    "ax.set_title(\"[M] = kNm\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "d1745c16",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-03T17:10:35.733911Z",
     "iopub.status.busy": "2022-04-03T17:10:35.732914Z",
     "iopub.status.idle": "2022-04-03T17:10:36.074907Z",
     "shell.execute_reply": "2022-04-03T17:10:36.073909Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 32740 characters]\n",
      "text/plain": [
       "<Figure size 864x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "filenames": {
       "image/png": "C:\\Users\\David\\OneDrive\\Desktop\\imwspy\\stanpy\\stanpy\\docs\\_build\\jupyter_execute\\user_guide\\straight_beam_constant_cs_16_0.png"
      },
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "scale = 0.5\n",
    "fig, ax = plt.subplots(figsize=(12, 5))\n",
    "stp.plot_system(ax, s, watermark_pos=1)\n",
    "stp.plot_R(ax, x=x, Rx=R_x, annotate_x=[0, [l/3-dx, l/3], l/2, l-dx], fill_p=\"red\", fill_n=\"blue\", scale=scale, alpha=0.2)\n",
    "ax.grid(linestyle=\":\")\n",
    "ax.set_axisbelow(True)\n",
    "ax.set_ylim(-1, 1)\n",
    "ax.set_ylabel(\"R/Rmax*{}\".format(scale))\n",
    "ax.set_title(\"[R] = kN\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "99333fe2",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-03T17:10:36.077912Z",
     "iopub.status.busy": "2022-04-03T17:10:36.077912Z",
     "iopub.status.idle": "2022-04-03T17:10:36.553910Z",
     "shell.execute_reply": "2022-04-03T17:10:36.553910Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 32552 characters]\n",
      "text/plain": [
       "<Figure size 864x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "filenames": {
       "image/png": "C:\\Users\\David\\OneDrive\\Desktop\\imwspy\\stanpy\\stanpy\\docs\\_build\\jupyter_execute\\user_guide\\straight_beam_constant_cs_17_0.png"
      },
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "scale = 0.5\n",
    "fig, ax = plt.subplots(figsize=(12, 5))\n",
    "stp.plot_system(ax, s, watermark_pos=1)\n",
    "stp.plot_solution(ax, x=x, y=V_x, annotate_x=[0, [l/3-dx, l/3], l/2, l-dx], fill_p=\"red\", fill_n=\"blue\", scale=scale, alpha=0.2)\n",
    "ax.grid(linestyle=\":\")\n",
    "ax.set_axisbelow(True)\n",
    "ax.set_ylim(-1, 1)\n",
    "ax.set_ylabel(\"V/Vmax*{}\".format(scale))\n",
    "ax.set_title(\"[V] = kN\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "ba13aa95",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-03T17:10:36.558910Z",
     "iopub.status.busy": "2022-04-03T17:10:36.557914Z",
     "iopub.status.idle": "2022-04-03T17:10:36.779911Z",
     "shell.execute_reply": "2022-04-03T17:10:36.778910Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 22880 characters]\n",
      "text/plain": [
       "<Figure size 864x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "filenames": {
       "image/png": "C:\\Users\\David\\OneDrive\\Desktop\\imwspy\\stanpy\\stanpy\\docs\\_build\\jupyter_execute\\user_guide\\straight_beam_constant_cs_18_0.png"
      },
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "scale = 0.2\n",
    "fig, ax = plt.subplots(figsize=(12, 5))\n",
    "stp.plot_system(ax, s, watermark_pos=1, lw=1, linestyle=\":\", c=\"#111111\")\n",
    "stp.plot_w(ax, x=x, wx=w_x, scale=scale, linestyle=\"-\")\n",
    "ax.grid(linestyle=\":\")\n",
    "ax.set_axisbelow(True)\n",
    "ax.set_ylim(-0.8, 0.8)\n",
    "ax.set_ylabel(\"w/wmax*{}\".format(scale))\n",
    "ax.set_title(\"[w] = m\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "38546a02",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-03T17:10:36.785915Z",
     "iopub.status.busy": "2022-04-03T17:10:36.785915Z",
     "iopub.status.idle": "2022-04-03T17:10:37.019907Z",
     "shell.execute_reply": "2022-04-03T17:10:37.018904Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 16372 characters]\n",
      "text/plain": [
       "<Figure size 864x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "filenames": {
       "image/png": "C:\\Users\\David\\OneDrive\\Desktop\\imwspy\\stanpy\\stanpy\\docs\\_build\\jupyter_execute\\user_guide\\straight_beam_constant_cs_19_0.png"
      },
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "import stanpy as stp\n",
    "\n",
    "EI = 32000  # kNm²\n",
    "GA = 20000  # kNm²\n",
    "l = 6  # m\n",
    "H = 10  # kN\n",
    "q = 4 # kN/m\n",
    "N = -1500 # kN\n",
    "w_0 = 0.03 # m\n",
    "\n",
    "s = {\n",
    "    \"EI\": EI,\n",
    "    \"GA\": GA,\n",
    "    \"l\": l,\n",
    "    \"q\": q,\n",
    "    \"P\": (H, l/2),\n",
    "    \"N\": N,\n",
    "    \"w_0\": w_0,\n",
    "    \"bc_i\": {\"w\": 0, \"phi\": 0},\n",
    "    \"bc_k\": {\"w\": 0, \"M\": 0, \"H\": 0},\n",
    "}\n",
    "\n",
    "fig, ax = plt.subplots(figsize=(12, 5))\n",
    "stp.plot_system(ax, s)\n",
    "stp.plot_load(ax, s)\n",
    "ax.grid(linestyle=\":\")\n",
    "ax.set_axisbelow(True)\n",
    "ax.set_ylim(-1.5, 2)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "34a89795",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-03T17:10:37.022908Z",
     "iopub.status.busy": "2022-04-03T17:10:37.022908Z",
     "iopub.status.idle": "2022-04-03T17:10:37.168907Z",
     "shell.execute_reply": "2022-04-03T17:10:37.168907Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Z_a = [  0.        0.      -76.78432  29.79739   1.     ]\n",
      "Z_b = [-0.00000e+00 -3.75553e-03  0.00000e+00 -4.20261e+00  1.00000e+00]\n"
     ]
    }
   ],
   "source": [
    "dx = 1e-9\n",
    "x = np.linspace(0, l, 500)\n",
    "annotation = np.array([l / 2 - dx, l / 2, l-dx])\n",
    "x = np.sort(np.append(x, annotation))\n",
    "\n",
    "Fxa = stp.tr(s, x=x)\n",
    "Z_a, Z_b = stp.solve_tr(Fxa[-1], **s)\n",
    "Z_x = Fxa.dot(Z_a)\n",
    "\n",
    "print(\"Z_a =\", Z_a)\n",
    "print(\"Z_b =\", Z_b)\n",
    "\n",
    "w_x = Z_x[:, 0]\n",
    "phi_x = Z_x[:, 1]\n",
    "M_x = Z_x[:, 2]\n",
    "R_x = Z_x[:, 3]\n",
    "\n",
    "V_x = stp.R_to_Q(x, Z_x, s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "29d4836d",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-03T17:10:37.172909Z",
     "iopub.status.busy": "2022-04-03T17:10:37.171911Z",
     "iopub.status.idle": "2022-04-03T17:10:37.408903Z",
     "shell.execute_reply": "2022-04-03T17:10:37.408903Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 30052 characters]\n",
      "text/plain": [
       "<Figure size 864x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "filenames": {
       "image/png": "C:\\Users\\David\\OneDrive\\Desktop\\imwspy\\stanpy\\stanpy\\docs\\_build\\jupyter_execute\\user_guide\\straight_beam_constant_cs_21_0.png"
      },
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "scale = 0.5\n",
    "fig, ax = plt.subplots(figsize=(12, 5))\n",
    "stp.plot_system(ax, s)\n",
    "stp.plot_M(ax, x=x, Mx=M_x, annotate_x=[0,x[M_x==np.max(M_x)], l], fill_p=\"red\", fill_n=\"blue\", scale=scale, alpha=0.2)\n",
    "ax.grid(linestyle=\":\")\n",
    "ax.set_axisbelow(True)\n",
    "ax.set_ylim(-1, 1.2)\n",
    "ax.set_ylabel(\"M/Mmax*{}\".format(scale))\n",
    "ax.set_title(\"[M] = kNm\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "8523e7c0",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-03T17:10:37.412908Z",
     "iopub.status.busy": "2022-04-03T17:10:37.411912Z",
     "iopub.status.idle": "2022-04-03T17:10:37.618908Z",
     "shell.execute_reply": "2022-04-03T17:10:37.618908Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 26860 characters]\n",
      "text/plain": [
       "<Figure size 864x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "filenames": {
       "image/png": "C:\\Users\\David\\OneDrive\\Desktop\\imwspy\\stanpy\\stanpy\\docs\\_build\\jupyter_execute\\user_guide\\straight_beam_constant_cs_22_0.png"
      },
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "scale = 0.5\n",
    "fig, ax = plt.subplots(figsize=(12, 5))\n",
    "stp.plot_system(ax, s, watermark_pos=1)\n",
    "stp.plot_R(ax, x=x, Rx=R_x, annotate_x=[0, [l/2-dx, l/2], l-dx], fill_p=\"red\", fill_n=\"blue\", scale=scale, alpha=0.2)\n",
    "ax.grid(linestyle=\":\")\n",
    "ax.set_axisbelow(True)\n",
    "ax.set_ylim(-0.8, 1.4)\n",
    "ax.set_ylabel(\"R/Rmax*{}\".format(scale))\n",
    "ax.set_title(\"[R] = kN\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "0d8b7962",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-03T17:10:37.622910Z",
     "iopub.status.busy": "2022-04-03T17:10:37.622910Z",
     "iopub.status.idle": "2022-04-03T17:10:37.813903Z",
     "shell.execute_reply": "2022-04-03T17:10:37.813903Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 30432 characters]\n",
      "text/plain": [
       "<Figure size 864x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "filenames": {
       "image/png": "C:\\Users\\David\\OneDrive\\Desktop\\imwspy\\stanpy\\stanpy\\docs\\_build\\jupyter_execute\\user_guide\\straight_beam_constant_cs_23_0.png"
      },
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "scale = 0.5\n",
    "fig, ax = plt.subplots(figsize=(12, 5))\n",
    "stp.plot_system(ax, s, watermark_pos=1)\n",
    "stp.plot_solution(ax, x=x, y=V_x, annotate_x=[0, [l/2-dx, l/2], l-dx], fill_p=\"red\", fill_n=\"blue\", scale=scale, alpha=0.2)\n",
    "ax.grid(linestyle=\":\")\n",
    "ax.set_axisbelow(True)\n",
    "ax.set_ylim(-0.8, 1.2)\n",
    "ax.set_ylabel(\"V/Vmax*{}\".format(scale))\n",
    "ax.set_title(\"[V] = kN\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "4ef126e2",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-03T17:10:37.817909Z",
     "iopub.status.busy": "2022-04-03T17:10:37.816910Z",
     "iopub.status.idle": "2022-04-03T17:10:38.084915Z",
     "shell.execute_reply": "2022-04-03T17:10:38.083913Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 22724 characters]\n",
      "text/plain": [
       "<Figure size 864x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "filenames": {
       "image/png": "C:\\Users\\David\\OneDrive\\Desktop\\imwspy\\stanpy\\stanpy\\docs\\_build\\jupyter_execute\\user_guide\\straight_beam_constant_cs_24_0.png"
      },
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "scale = 0.2\n",
    "fig, ax = plt.subplots(figsize=(12, 5))\n",
    "stp.plot_system(ax, s, watermark_pos=1, lw=1, linestyle=\":\", c=\"#111111\")\n",
    "stp.plot_w(ax, x=x, wx=w_x, scale=scale, linestyle=\"-\")\n",
    "ax.grid(linestyle=\":\")\n",
    "ax.set_axisbelow(True)\n",
    "ax.set_ylim(-0.8, 0.8)\n",
    "ax.set_ylabel(\"w/wmax*{}\".format(scale))\n",
    "ax.set_title(\"[w] = m\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "16b2a5a3",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2022-04-03T17:10:38.088909Z",
     "iopub.status.busy": "2022-04-03T17:10:38.088909Z",
     "iopub.status.idle": "2022-04-03T17:10:38.098904Z",
     "shell.execute_reply": "2022-04-03T17:10:38.098904Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a_j = [[ 1.   6.  18.  36.  54.  64.8]]\n",
      "b_j = [[ 0.21835  4.33504 15.42461 32.8553  50.82105 62.05548]]\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "import stanpy as stp\n",
    "\n",
    "EI = 32000  # kNm²\n",
    "GA = 20000  # kN\n",
    "l = 6\n",
    "NII = -1500  # kN\n",
    "\n",
    "s = {\"EI\": EI, \"GA\": GA, \"N\": NII}\n",
    "\n",
    "a_j, b_j = stp.bj_opt2_p89(l, return_aj=True, **s)\n",
    "\n",
    "print(\"a_j =\", a_j)\n",
    "print(\"b_j =\", b_j)"
   ]
  }
 ],
 "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.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}