{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Symbolic Strain Notebook" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import sympy as sp\n", "\n", "from mechpy.core.symbolic.strain import (\n", " SymbolicStrainTensor,\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Symbolic Strain" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Init Method" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}\\epsilon_{1} & \\epsilon_{2} & \\epsilon_{3} & \\epsilon_{4} & \\epsilon_{5} & \\epsilon_{6}\\end{matrix}\\right]$" ], "text/plain": [ "[epsilon_1, epsilon_2, epsilon_3, epsilon_4, epsilon_5, epsilon_6]" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "e1, e2, e3, e4, e5, e6 = sp.symbols(\"epsilon_1 epsilon_2 epsilon_3 epsilon_4 epsilon_5 epsilon_6\")\n", "data = sp.NDimArray([e1, e2, e3, e4, e5, e6])\n", "strain_tensor = SymbolicStrainTensor(data)\n", "display(strain_tensor.data)\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Create Method" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Default Notation" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}\\epsilon_{1} & \\epsilon_{2} & \\epsilon_{3} & \\epsilon_{4} & \\epsilon_{5} & \\epsilon_{6}\\end{matrix}\\right]$" ], "text/plain": [ "[\\epsilon_1, \\epsilon_2, \\epsilon_3, \\epsilon_4, \\epsilon_5, \\epsilon_6]" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [ "'standard'" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}\\epsilon_{11} & \\epsilon_{22} & \\epsilon_{33}\\\\\\epsilon_{22} & \\epsilon_{23} & \\epsilon_{13}\\\\\\epsilon_{33} & \\epsilon_{13} & \\epsilon_{12}\\end{matrix}\\right]$" ], "text/plain": [ "[[\\epsilon_11, \\epsilon_22, \\epsilon_33], [\\epsilon_22, \\epsilon_23, \\epsilon_13], [\\epsilon_33, \\epsilon_13, \\epsilon_12]]" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "strain_tensor = SymbolicStrainTensor.create()\n", "display(strain_tensor.data)\n", "display(strain_tensor.notation)\n", "display(strain_tensor.to_general().data)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Voigt notation" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}\\epsilon_{11} & \\epsilon_{22} & \\epsilon_{33} & 2 \\epsilon_{23} & 2 \\epsilon_{13} & 2 \\epsilon_{12}\\end{matrix}\\right]$" ], "text/plain": [ "[\\epsilon_11, \\epsilon_22, \\epsilon_33, 2*\\epsilon_23, 2*\\epsilon_13, 2*\\epsilon_12]" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [ "'voigt'" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}\\epsilon_{11} & \\epsilon_{22} & \\epsilon_{33}\\\\\\epsilon_{22} & \\epsilon_{23} & \\epsilon_{13}\\\\\\epsilon_{33} & \\epsilon_{13} & \\epsilon_{12}\\end{matrix}\\right]$" ], "text/plain": [ "[[\\epsilon_11, \\epsilon_22, \\epsilon_33], [\\epsilon_22, \\epsilon_23, \\epsilon_13], [\\epsilon_33, \\epsilon_13, \\epsilon_12]]" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "strain_tensor = SymbolicStrainTensor.create(notation=\"voigt\")\n", "display(strain_tensor.data)\n", "display(strain_tensor.notation)\n", "display(strain_tensor.to_general().data)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Custom name" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}\\epsilon^{1}_{11} & \\epsilon^{1}_{22} & \\epsilon^{1}_{33} & 2 \\epsilon^{1}_{23} & 2 \\epsilon^{1}_{13} & 2 \\epsilon^{1}_{12}\\end{matrix}\\right]$" ], "text/plain": [ "[\\epsilon^1_11, \\epsilon^1_22, \\epsilon^1_33, 2*\\epsilon^1_23, 2*\\epsilon^1_13, 2*\\epsilon^1_12]" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [ "'voigt'" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}\\epsilon^{1}_{11} & \\epsilon^{1}_{22} & \\epsilon^{1}_{33}\\\\\\epsilon^{1}_{22} & \\epsilon^{1}_{23} & \\epsilon^{1}_{13}\\\\\\epsilon^{1}_{33} & \\epsilon^{1}_{13} & \\epsilon^{1}_{12}\\end{matrix}\\right]$" ], "text/plain": [ "[[\\epsilon^1_11, \\epsilon^1_22, \\epsilon^1_33], [\\epsilon^1_22, \\epsilon^1_23, \\epsilon^1_13], [\\epsilon^1_33, \\epsilon^1_13, \\epsilon^1_12]]" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "strain_tensor = SymbolicStrainTensor.create(name=\"\\epsilon^1\", notation=\"voigt\")\n", "display(strain_tensor.data)\n", "display(strain_tensor.notation)\n", "display(strain_tensor.to_general().data)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}\\epsilon^{1}_{11} & \\epsilon^{1}_{22} & \\epsilon^{1}_{33}\\end{matrix}\\right]$" ], "text/plain": [ "[\\epsilon^1_11, \\epsilon^1_22, \\epsilon^1_33]" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}2 \\epsilon^{1}_{23} & 2 \\epsilon^{1}_{13} & 2 \\epsilon^{1}_{12}\\end{matrix}\\right]$" ], "text/plain": [ "[2*\\epsilon^1_23, 2*\\epsilon^1_13, 2*\\epsilon^1_12]" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/latex": [ "$\\displaystyle \\epsilon^{1}_{11} + \\epsilon^{1}_{22} + \\epsilon^{1}_{33}$" ], "text/plain": [ "\\epsilon^1_11 + \\epsilon^1_22 + \\epsilon^1_33" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "display(strain_tensor.normal_components())\n", "display(strain_tensor.shear_components())\n", "display(strain_tensor.volumetric_strain())" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "venv", "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.10.12" } }, "nbformat": 4, "nbformat_minor": 2 }