Skip to content

Commit

Permalink
Update ex01_specimen_amplitudes.ipynb
Browse files Browse the repository at this point in the history
  • Loading branch information
adtzlr committed Aug 23, 2023
1 parent 8e5f894 commit b230e1c
Showing 1 changed file with 265 additions and 5 deletions.
270 changes: 265 additions & 5 deletions docs/notebooks/ex01_specimen_amplitudes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
"import termtables as tt\n",
"from pypardiso import spsolve\n",
"\n",
"import fiberreinforcedrubber as frr"
"import fiberreinforcedrubber as frr\n",
"\n",
"frr.__version__"
]
},
{
Expand Down Expand Up @@ -190,10 +192,268 @@
" color=\"lightgrey\",\n",
" line_width=4,\n",
")\n",
"plotter.camera.tight()\n",
"# plotter.add_axes(label_size=(0.06, 0.06), viewport=(-0.1, -0.1, 0.2, 0.2))\n",
"# plotter.camera.zoom(0.8)\n",
"plotter.show(\"test_specimen_mesh_rubber.png\", scale=2, jupyter_backend=\"static)"
"plotter.show(jupyter_backend=\"static\")"
]
},
{
"cell_type": "markdown",
"id": "670ebca4-0b05-4f49-bc8d-d7ca94bce291",
"metadata": {},
"source": [
"View the fiber mesh"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "740d2142-5096-42cc-bf4f-8c022e513ac4",
"metadata": {},
"outputs": [],
"source": [
"view = fem.ViewMesh(fem.mesh.concatenate([fibers_1, fibers_2]))\n",
"plotter = view.plot(\n",
" notebook=True,\n",
" theme=\"document\",\n",
" add_axes=False,\n",
" color=\"black\",\n",
" line_width=4,\n",
")\n",
"plotter.show(jupyter_backend=\"static\")"
]
},
{
"cell_type": "markdown",
"id": "4de0761b-1584-4f30-a44d-ab917885d153",
"metadata": {},
"source": [
"Create a numeric region and a displacement field"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e664a84b-d735-453d-81ec-163e6391eb2f",
"metadata": {},
"outputs": [],
"source": [
"region = fem.RegionQuad(mesh)\n",
"field = fem.FieldContainer([fem.Field(region, dim=2)])"
]
},
{
"cell_type": "markdown",
"id": "37925fc3-01de-4167-a71c-2190d00e3f21",
"metadata": {},
"source": [
"Setup boundary conditions"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "23e14ba6-d67b-4ed5-b711-222f9d8cd04a",
"metadata": {},
"outputs": [],
"source": [
"bounds, loadcase = fem.dof.shear(field)"
]
},
{
"cell_type": "markdown",
"id": "a69ceeea-5075-41e0-9ae3-2f57af29c813",
"metadata": {},
"source": [
"Constitutive material behavior for rubber and cord"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ca660c8b-1575-43a3-a968-3e08edcd1acb",
"metadata": {},
"outputs": [],
"source": [
"neohooke, fibermat1, fibermat2, vector1, vector2 = frr.fiber_reinforced_rubber(\n",
" C10=C10,\n",
" fiber_angle=fiber_angle,\n",
" fiber_modulus=fiber_modulus,\n",
" fiber_area=fiber_area,\n",
" thickness=thickness,\n",
" strain_exponent=strain_exponent,\n",
" axis=fiber_axis,\n",
" fiber_distance=fiber_distance,\n",
")"
]
},
{
"cell_type": "markdown",
"id": "fe4f68c0-8845-4426-8a00-2b8d43f1acc4",
"metadata": {},
"source": [
"Solid bodies"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "32f27770-e91e-4e88-b72c-3caf3242dbaa",
"metadata": {},
"outputs": [],
"source": [
"rubber = fem.SolidBody(neohooke, field)\n",
"fiber1 = fem.SolidBody(fibermat1, field)\n",
"fiber2 = fem.SolidBody(fibermat2, field)"
]
},
{
"cell_type": "markdown",
"id": "7c61f1c5-2907-4298-baf4-b1c8ccd1e6f1",
"metadata": {},
"source": [
"Tension and shear at V = 3 mm (Fy = 3 kN)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "99534f23-7d1d-4618-a9fe-c680a53be7d0",
"metadata": {},
"outputs": [],
"source": [
"fiber_forces = [[], []]\n",
"\n",
"\n",
"def evaluate_fiber_forces(i, j, substep):\n",
" field = substep.x\n",
"\n",
" # get fiber normal forces per undeformed (fiber) area\n",
" force1 = frr.fiber_force(fiber1, thickness, fiber_area, vector1)\n",
" force2 = frr.fiber_force(fiber2, thickness, fiber_area, vector2)\n",
"\n",
" # interpolate fiber forces to the line-meshes of the fiber families\n",
" r_1 = frr.interpolate(mesh, force1, fibers_1, mask_points_1)\n",
" r_2 = frr.interpolate(mesh, force2, fibers_2, mask_points_2)\n",
"\n",
" fiber_forces[0].append(r_1)\n",
" fiber_forces[1].append(r_2)\n",
"\n",
"\n",
"step = fem.Step(\n",
" items=[rubber, fiber1, fiber2],\n",
" boundaries=bounds,\n",
" ramp={\n",
" bounds[\"compression_top\"]: fem.math.linsteps([3, 3], num=2),\n",
" bounds[\"move\"]: lateral_max * fem.math.linsteps([-1, 1], num=2),\n",
" },\n",
")\n",
"job = fem.Job(steps=[step], callback=evaluate_fiber_forces)\n",
"job.evaluate(solver=spsolve, tol=1e-2)"
]
},
{
"cell_type": "markdown",
"id": "4e5f97fb-d1e8-4a0f-a255-41e740949500",
"metadata": {},
"source": [
"Interpolate displacements to the line-meshes of the fiber families"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "29bcfb45-c182-4839-b0ec-3afa8663ba73",
"metadata": {},
"outputs": [],
"source": [
"u_1 = frr.interpolate(mesh, field[0].values, fibers_1, mask_points_1)\n",
"u_2 = frr.interpolate(mesh, field[0].values, fibers_2, mask_points_2)"
]
},
{
"cell_type": "markdown",
"id": "28589f7c-ee4b-4754-92f9-6b9a56f4996a",
"metadata": {},
"source": [
"Deformed line mesh for the fibers"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f1ce9d7c-98b0-43c4-9deb-616495afb20c",
"metadata": {},
"outputs": [],
"source": [
"fibers_1.points += u_1\n",
"fibers_2.points += u_2"
]
},
{
"cell_type": "markdown",
"id": "08c9c252-368f-4c7f-9aad-ed5b900d205e",
"metadata": {},
"source": [
"## Postprocessing\n",
"Deformed Views"
]
},
{
"cell_type": "markdown",
"id": "e25fe2c5-99a9-41b3-998b-b4d9593d10be",
"metadata": {},
"source": [
"View on fiber families"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0fbd325a-20af-42cf-a02b-043072e0d2a9",
"metadata": {},
"outputs": [],
"source": [
"fiberfamilies = [\n",
" (fiber_forces[0], fibers_1, fibers_2, [400, 900]),\n",
" (fiber_forces[1], fibers_2, fibers_1, [400, 900]),\n",
"]\n",
"for i, (fiberforce, fiberfamily1, fiberfamily2, clim) in enumerate(fiberfamilies):\n",
" view = fem.ViewSolid(field)\n",
" plotter = view.plot(\n",
" notebook=True,\n",
" theme=\"document\",\n",
" show_edges=False,\n",
" add_axes=False,\n",
" )\n",
" plotter.add_axes(label_size=(0.06, 0.06))\n",
"\n",
" forcerange = np.abs(fiberforce[-1] - fiberforce[-3])\n",
"\n",
" fiberview1 = fem.ViewMesh(\n",
" fiberfamily1,\n",
" point_data={\n",
" \"Normal Force (Range) per Undeformed Area (Fibre) in MPa\": forcerange\n",
" },\n",
" )\n",
" fiberview2 = fem.ViewMesh(\n",
" fiberfamily2,\n",
" )\n",
" plotter = fiberview2.plot(\n",
" plotter=plotter,\n",
" line_width=3,\n",
" add_axes=False,\n",
" )\n",
" fiberplotter = fiberview1.plot(\n",
" \"Normal Force (Range) per Undeformed Area (Fibre) in MPa\",\n",
" label=\"Normal Force (Range) per Undeformed Area (Fibre) in MPa\",\n",
" plotter=plotter,\n",
" component=None,\n",
" clim=clim,\n",
" below_color=\"darkgrey\",\n",
" above_color=\"lightgrey\",\n",
" line_width=3,\n",
" add_axes=False,\n",
" )\n",
" fiberplotter.show(jupyter_backend=\"static\")"
]
}
],
Expand Down

0 comments on commit b230e1c

Please sign in to comment.