Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
{
"cells": [
{
"cell_type": "markdown",
"id": "8f26cf66-3f14-4613-8e59-c7034c15126b",
"metadata": {},
"source": [
"# Twisted beam\n",
"\n",
"cover page picture of:\n",
"\n",
"[Nonlinear Solid Mechanics for Finite Element Analysis: Statics 1st Edition\n",
"by Javier Bonet (Author), Antonio J. Gil (Author), Richard D. Wood (Author)](https://www.amazon.com/Nonlinear-Mechanics-Finite-Element-Analysis/dp/1107115795/ref=pd_bxgy_thbs_d_sccl_1/144-7614425-7391713?pd_rd_w=CqCvS&content-id=amzn1.sym.c51e3ad7-b551-4b1a-b43c-3cf69addb649&pf_rd_p=c51e3ad7-b551-4b1a-b43c-3cf69addb649&pf_rd_r=9HSD8RKNRHDBSK8B5YKQ&pd_rd_wg=B0gaE&pd_rd_r=5fbf0386-d903-408e-b180-af0fd134e615&pd_rd_i=1107115795&psc=1)\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d28b4250-1afa-4e63-abf3-7f2241648b44",
"metadata": {},
"outputs": [],
"source": [
"from ngsolve import *\n",
"from netgen.occ import *\n",
"from ngsolve.webgui import Draw\n",
"import ipywidgets as widgets\n",
"\n",
"ea = { \"euler_angles\" : (-120,70,116) }"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "acb8edb8-bfaa-4416-a3d2-017923f3dd8c",
"metadata": {},
"outputs": [],
"source": [
"d = 0.01\n",
"box = Box ( (-d/2,-d/2,0), (d/2,d/2,0.1) ) + Box( (-d/2, -3*d/2,0.1), (d/2, 3*d/2, 0.1+d) )\n",
"box.faces.Min(Z).name = \"bottom\"\n",
"box.faces.Max(Z).name = \"top\"\n",
"Draw (box, **ea);\n",
"\n",
"mesh = Mesh(OCCGeometry(box).GenerateMesh(maxh=0.005))\n",
"Draw (mesh, **ea);"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1cc4ef26-4a7a-4721-bd41-ec16ee51f61a",
"metadata": {},
"outputs": [],
"source": [
"E, nu = 210, 0.2\n",
"mu = E / 2 / (1+nu)\n",
"lam = E * nu / ((1+nu)*(1-2*nu))\n",
"\n",
"def C(u):\n",
" F = Id(u.dim) + Grad(u)\n",
" return F.trans * F\n",
"\n",
"def NeoHooke (C):\n",
" # return 0.5*mu*InnerProduct(C-Id(3), C-Id(3))\n",
" return 0.5*mu*(Trace(C-Id(3)) + 2*mu/lam*Det(C)**(-lam/2/mu)-1)"
]
},
{
"cell_type": "markdown",
"id": "71caf2e5-b4e1-4eb8-9403-636868c1ad29",
"metadata": {},
"source": [
"A follower load is *rotated* with the deformation gradient $F = I + \\nabla u$. "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ea29c090-c5fe-46ae-8c32-de947e64f643",
"metadata": {},
"outputs": [],
"source": [
"loadfactor = Parameter(1)\n",
"force = loadfactor * CF ( (-y, x, 0) )\n",
"\n",
"fes = H1(mesh, order=3, dirichlet=\"bottom\", dim=mesh.dim)\n",
"u,v = fes.TnT()\n",
"\n",
"a = BilinearForm(fes, symmetric=True)\n",
"a += Variation(NeoHooke(C(u)).Compile()*dx)\n",
"a += ((Id(3)+Grad(u.Trace()))*force)*v*ds(\"top\")\n",
"\n",
"gfu = GridFunction(fes)\n",
"gfu.vec[:] = 0"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d0c8fd72-4d13-4df4-997b-de5100a005ba",
"metadata": {},
"outputs": [],
"source": [
"gfu_history = GridFunction(fes, multidim=0)\n",
"scene = Draw (gfu, deformation=True, **ea)\n",
"tw = widgets.Text(value='step = 0')\n",
"display(tw)\n",
"\n",
"gfu.vec[:] = 0\n",
"\n",
"numsteps = 30\n",
"for step in range(numsteps):\n",
" loadfactor.Set(300*step/numsteps)\n",
" solvers.Newton (a, gfu, printing=False, dampfactor=0.5)\n",
" scene.Redraw()\n",
" tw.value = 'step = '+str(step+1)+'/'+str(numsteps)\n",
" gfu_history.AddMultiDimComponent(gfu.vec)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "917c32e7-c410-4490-adf6-cc2df3422d80",
"metadata": {},
"outputs": [],
"source": [
"Draw (gfu_history, mesh, animate=True, min=0, max=0.04, autoscale=True, deformation=True, **ea);"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "373cf0de-d9b7-4cdf-80b3-9bf3c7eb529c",
"metadata": {},
"outputs": [],
"source": []
}
],
"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.12.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
4426a015fThis file is pinned to the selected release. Download the original to open it in your design tool.