Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
obouchaara committed Jan 7, 2024
1 parent 5f260df commit a1e41d6
Show file tree
Hide file tree
Showing 6 changed files with 350 additions and 91 deletions.
157 changes: 124 additions & 33 deletions _sources/notebooks/symbolic/elasticity.ipynb.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Stiffness Tensor"
"### Compliance Tensor"
]
},
{
Expand All @@ -55,10 +55,10 @@
{
"data": {
"text/latex": [
"$\\displaystyle \\left[\\begin{matrix}\\frac{E \\left(\\nu - 1\\right)}{\\left(\\nu + 1\\right) \\left(2 \\nu - 1\\right)} & - \\frac{E \\nu}{\\left(\\nu + 1\\right) \\left(2 \\nu - 1\\right)} & - \\frac{E \\nu}{\\left(\\nu + 1\\right) \\left(2 \\nu - 1\\right)} & 0 & 0 & 0\\\\- \\frac{E \\nu}{\\left(\\nu + 1\\right) \\left(2 \\nu - 1\\right)} & \\frac{E \\left(\\nu - 1\\right)}{\\left(\\nu + 1\\right) \\left(2 \\nu - 1\\right)} & - \\frac{E \\nu}{\\left(\\nu + 1\\right) \\left(2 \\nu - 1\\right)} & 0 & 0 & 0\\\\- \\frac{E \\nu}{\\left(\\nu + 1\\right) \\left(2 \\nu - 1\\right)} & - \\frac{E \\nu}{\\left(\\nu + 1\\right) \\left(2 \\nu - 1\\right)} & \\frac{E \\left(\\nu - 1\\right)}{\\left(\\nu + 1\\right) \\left(2 \\nu - 1\\right)} & 0 & 0 & 0\\\\0 & 0 & 0 & \\frac{E}{2 \\left(\\nu + 1\\right)} & 0 & 0\\\\0 & 0 & 0 & 0 & \\frac{E}{2 \\left(\\nu + 1\\right)} & 0\\\\0 & 0 & 0 & 0 & 0 & \\frac{E}{2 \\left(\\nu + 1\\right)}\\end{matrix}\\right]$"
"$\\displaystyle \\left[\\begin{matrix}\\frac{1}{E} & - \\frac{\\nu}{E} & - \\frac{\\nu}{E} & 0 & 0 & 0\\\\- \\frac{\\nu}{E} & \\frac{1}{E} & - \\frac{\\nu}{E} & 0 & 0 & 0\\\\- \\frac{\\nu}{E} & - \\frac{\\nu}{E} & \\frac{1}{E} & 0 & 0 & 0\\\\0 & 0 & 0 & \\frac{2 \\left(\\nu + 1\\right)}{E} & 0 & 0\\\\0 & 0 & 0 & 0 & \\frac{2 \\left(\\nu + 1\\right)}{E} & 0\\\\0 & 0 & 0 & 0 & 0 & \\frac{2 \\left(\\nu + 1\\right)}{E}\\end{matrix}\\right]$"
],
"text/plain": [
"[[E*(nu - 1)/((nu + 1)*(2*nu - 1)), -E*nu/((nu + 1)*(2*nu - 1)), -E*nu/((nu + 1)*(2*nu - 1)), 0, 0, 0], [-E*nu/((nu + 1)*(2*nu - 1)), E*(nu - 1)/((nu + 1)*(2*nu - 1)), -E*nu/((nu + 1)*(2*nu - 1)), 0, 0, 0], [-E*nu/((nu + 1)*(2*nu - 1)), -E*nu/((nu + 1)*(2*nu - 1)), E*(nu - 1)/((nu + 1)*(2*nu - 1)), 0, 0, 0], [0, 0, 0, E/(2*(nu + 1)), 0, 0], [0, 0, 0, 0, E/(2*(nu + 1)), 0], [0, 0, 0, 0, 0, E/(2*(nu + 1))]]"
"[[1/E, -nu/E, -nu/E, 0, 0, 0], [-nu/E, 1/E, -nu/E, 0, 0, 0], [-nu/E, -nu/E, 1/E, 0, 0, 0], [0, 0, 0, 2*(nu + 1)/E, 0, 0], [0, 0, 0, 0, 2*(nu + 1)/E, 0], [0, 0, 0, 0, 0, 2*(nu + 1)/E]]"
]
},
"metadata": {},
Expand All @@ -68,15 +68,15 @@
"source": [
"symbolic_isotropic_material = SymbolicIsotropicMaterial()\n",
"display(symbolic_isotropic_material)\n",
"stiffness_tensor = symbolic_isotropic_material.stiffness_tensor(lames_param=False)\n",
"display(stiffness_tensor.data)"
"compliance_tensor = symbolic_isotropic_material.compliance_tensor()\n",
"display(compliance_tensor.data)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Strain Tensor"
"### Stress Tensor"
]
},
{
Expand All @@ -87,27 +87,27 @@
{
"data": {
"text/latex": [
"$\\displaystyle \\left[\\begin{matrix}\\epsilon_{11} & 0 & 0 & 0 & 0 & 0\\end{matrix}\\right]$"
"$\\displaystyle \\left[\\begin{matrix}\\sigma_{11} & 0 & 0 & 0 & 0 & 0\\end{matrix}\\right]$"
],
"text/plain": [
"[\\epsilon_11, 0, 0, 0, 0, 0]"
"[\\sigma_11, 0, 0, 0, 0, 0]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"strain_tensor = SymbolicStrainTensor.create(notation=2)\n",
"stress_tensor = SymbolicStressTensor.create(notation=2)\n",
"subs_dict = {\n",
" 1: 0,\n",
" 2: 0,\n",
" 3: 0,\n",
" 4: 0,\n",
" 5: 0,\n",
"}\n",
"strain_tensor.subs(subs_dict, keys=True)\n",
"display(strain_tensor.data)"
"stress_tensor.subs(subs_dict, keys=True)\n",
"display(stress_tensor.data)"
]
},
{
Expand All @@ -119,22 +119,53 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle \\left[\\begin{matrix}\\sigma_{11} & \\sigma_{12} & \\sigma_{13}\\\\\\sigma_{12} & \\sigma_{22} & \\sigma_{23}\\\\\\sigma_{13} & \\sigma_{23} & \\sigma_{33}\\end{matrix}\\right] = \\left[\\begin{matrix}\\frac{E \\epsilon_{11} \\left(\\nu - 1\\right)}{\\left(\\nu + 1\\right) \\left(2 \\nu - 1\\right)} & 0 & 0\\\\0 & - \\frac{E \\epsilon_{11} \\nu}{\\left(\\nu + 1\\right) \\left(2 \\nu - 1\\right)} & 0\\\\0 & 0 & - \\frac{E \\epsilon_{11} \\nu}{\\left(\\nu + 1\\right) \\left(2 \\nu - 1\\right)}\\end{matrix}\\right]$"
"$\\displaystyle \\left[\\begin{matrix}\\epsilon_{11} & \\epsilon_{22} & \\epsilon_{33} & 2 \\epsilon_{23} & 2 \\epsilon_{13} & 2 \\epsilon_{12}\\end{matrix}\\right] = \\left[\\begin{matrix}\\frac{\\sigma_{11}}{E} & - \\frac{\\sigma_{11} \\nu}{E} & - \\frac{\\sigma_{11} \\nu}{E} & 0 & 0 & 0\\end{matrix}\\right]$"
],
"text/plain": [
"Eq(Matrix([\n",
"[\\sigma_11, \\sigma_12, \\sigma_13],\n",
"[\\sigma_12, \\sigma_22, \\sigma_23],\n",
"[\\sigma_13, \\sigma_23, \\sigma_33]]), Matrix([\n",
"[E*\\epsilon_11*(nu - 1)/((nu + 1)*(2*nu - 1)), 0, 0],\n",
"[ 0, -E*\\epsilon_11*nu/((nu + 1)*(2*nu - 1)), 0],\n",
"[ 0, 0, -E*\\epsilon_11*nu/((nu + 1)*(2*nu - 1))]]))"
"Eq([\\epsilon_11, \\epsilon_22, \\epsilon_33, 2*\\epsilon_23, 2*\\epsilon_13, 2*\\epsilon_12], [\\sigma_11/E, -\\sigma_11*nu/E, -\\sigma_11*nu/E, 0, 0, 0])"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"strain_tensor = SymbolicStrainTensor.create(notation=2)\n",
"strain_tensor_expr = SymbolicLinearElasticity.hookes_law(compliance_tensor, stress_tensor)\n",
"display(sp.Eq(strain_tensor.data, strain_tensor_expr.data))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Simple Deformation"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Stiffness Tensor"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"SymbolicIsotropicMaterial(\n",
"{'youngs_modulus': E, 'poisson_ratio': nu}\n",
")"
]
},
"metadata": {},
Expand All @@ -143,22 +174,80 @@
{
"data": {
"text/latex": [
"$\\displaystyle \\sigma_{11} = \\frac{E \\epsilon_{11} \\nu - E \\epsilon_{11}}{2 \\nu^{2} + \\nu - 1}$"
"$\\displaystyle \\left[\\begin{matrix}\\frac{E \\left(\\nu - 1\\right)}{\\left(\\nu + 1\\right) \\left(2 \\nu - 1\\right)} & - \\frac{E \\nu}{\\left(\\nu + 1\\right) \\left(2 \\nu - 1\\right)} & - \\frac{E \\nu}{\\left(\\nu + 1\\right) \\left(2 \\nu - 1\\right)} & 0 & 0 & 0\\\\- \\frac{E \\nu}{\\left(\\nu + 1\\right) \\left(2 \\nu - 1\\right)} & \\frac{E \\left(\\nu - 1\\right)}{\\left(\\nu + 1\\right) \\left(2 \\nu - 1\\right)} & - \\frac{E \\nu}{\\left(\\nu + 1\\right) \\left(2 \\nu - 1\\right)} & 0 & 0 & 0\\\\- \\frac{E \\nu}{\\left(\\nu + 1\\right) \\left(2 \\nu - 1\\right)} & - \\frac{E \\nu}{\\left(\\nu + 1\\right) \\left(2 \\nu - 1\\right)} & \\frac{E \\left(\\nu - 1\\right)}{\\left(\\nu + 1\\right) \\left(2 \\nu - 1\\right)} & 0 & 0 & 0\\\\0 & 0 & 0 & \\frac{E}{2 \\left(\\nu + 1\\right)} & 0 & 0\\\\0 & 0 & 0 & 0 & \\frac{E}{2 \\left(\\nu + 1\\right)} & 0\\\\0 & 0 & 0 & 0 & 0 & \\frac{E}{2 \\left(\\nu + 1\\right)}\\end{matrix}\\right]$"
],
"text/plain": [
"Eq(\\sigma_11, (E*\\epsilon_11*nu - E*\\epsilon_11)/(2*nu**2 + nu - 1))"
"[[E*(nu - 1)/((nu + 1)*(2*nu - 1)), -E*nu/((nu + 1)*(2*nu - 1)), -E*nu/((nu + 1)*(2*nu - 1)), 0, 0, 0], [-E*nu/((nu + 1)*(2*nu - 1)), E*(nu - 1)/((nu + 1)*(2*nu - 1)), -E*nu/((nu + 1)*(2*nu - 1)), 0, 0, 0], [-E*nu/((nu + 1)*(2*nu - 1)), -E*nu/((nu + 1)*(2*nu - 1)), E*(nu - 1)/((nu + 1)*(2*nu - 1)), 0, 0, 0], [0, 0, 0, E/(2*(nu + 1)), 0, 0], [0, 0, 0, 0, E/(2*(nu + 1)), 0], [0, 0, 0, 0, 0, E/(2*(nu + 1))]]"
]
},
"metadata": {},
"output_type": "display_data"
},
}
],
"source": [
"symbolic_isotropic_material = SymbolicIsotropicMaterial()\n",
"display(symbolic_isotropic_material)\n",
"stiffness_tensor = symbolic_isotropic_material.stiffness_tensor(lames_param=False)\n",
"display(stiffness_tensor.data)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Strain Tensor"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle \\left[\\begin{matrix}\\epsilon_{11} & 0 & 0 & 0 & 0 & 0\\end{matrix}\\right]$"
],
"text/plain": [
"[\\epsilon_11, 0, 0, 0, 0, 0]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"strain_tensor = SymbolicStrainTensor.create(notation=2)\n",
"subs_dict = {\n",
" 1: 0,\n",
" 2: 0,\n",
" 3: 0,\n",
" 4: 0,\n",
" 5: 0,\n",
"}\n",
"strain_tensor.subs(subs_dict, keys=True)\n",
"display(strain_tensor.data)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Result"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle \\sigma_{11} = E \\epsilon_{11}$"
"$\\displaystyle \\left[\\begin{matrix}\\sigma_{11} & \\sigma_{22} & \\sigma_{33} & \\sigma_{23} & \\sigma_{13} & \\sigma_{12}\\end{matrix}\\right] = \\left[\\begin{matrix}\\frac{E \\epsilon_{11} \\left(\\nu - 1\\right)}{\\left(\\nu + 1\\right) \\left(2 \\nu - 1\\right)} & - \\frac{E \\epsilon_{11} \\nu}{\\left(\\nu + 1\\right) \\left(2 \\nu - 1\\right)} & - \\frac{E \\epsilon_{11} \\nu}{\\left(\\nu + 1\\right) \\left(2 \\nu - 1\\right)} & 0 & 0 & 0\\end{matrix}\\right]$"
],
"text/plain": [
"Eq(\\sigma_11, E*\\epsilon_11)"
"Eq([\\sigma_11, \\sigma_22, \\sigma_33, \\sigma_23, \\sigma_13, \\sigma_12], [E*\\epsilon_11*(nu - 1)/((nu + 1)*(2*nu - 1)), -E*\\epsilon_11*nu/((nu + 1)*(2*nu - 1)), -E*\\epsilon_11*nu/((nu + 1)*(2*nu - 1)), 0, 0, 0])"
]
},
"metadata": {},
Expand All @@ -167,14 +256,16 @@
],
"source": [
"stress_tensor = SymbolicStressTensor.create(notation=2)\n",
"stress_tensor_expr = SymbolicLinearElasticity.hookes_law(stiffness_tensor, strain_tensor)\n",
"stress_eq = sp.Eq(stress_tensor.to_general().to_matrix(), stress_tensor_expr.to_general().to_matrix())\n",
"display(stress_eq)\n",
"solutions = sp.solve(stress_eq, stress_tensor.data[0])\n",
"for k, v in solutions.items():\n",
" display(sp.Eq(k, v))\n",
" display(sp.Eq(k, v.subs({\"nu\": 0})))"
"stress_tensor_expr = SymbolicLinearElasticity.hookes_law_inverse(stiffness_tensor, strain_tensor)\n",
"display(sp.Eq(stress_tensor.data, stress_tensor_expr.data))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -193,7 +284,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.2"
"version": "3.10.12"
}
},
"nbformat": 4,
Expand Down
1 change: 1 addition & 0 deletions notebooks.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ <h1>Notebooks<a class="headerlink" href="#notebooks" title="Link to this heading
</li>
<li class="toctree-l1"><a class="reference internal" href="notebooks/symbolic/elasticity.html">Symblic Elasticity Notebook</a><ul>
<li class="toctree-l2"><a class="reference internal" href="notebooks/symbolic/elasticity.html#Simple-Traction">Simple Traction</a></li>
<li class="toctree-l2"><a class="reference internal" href="notebooks/symbolic/elasticity.html#Simple-Deformation">Simple Deformation</a></li>
</ul>
</li>
</ul>
Expand Down
Loading

0 comments on commit a1e41d6

Please sign in to comment.