-
-

Symblic Elasticity Notebook

+
+

Symbolic Elasticity Notebook

[1]:
 
@@ -124,9 +124,10 @@

Compliance Tensor
[2]:
 

- -
stress_tensor = SymbolicStressTensor.create(notation=2)
-subs_dict = {
+
stress_tensor = SymbolicStressTensor.create(notation="voigt")
+display(stress_tensor.data)
+components_values = {
     1: 0,
     2: 0,
     3: 0,
     4: 0,
     5: 0,
 }
-stress_tensor.subs(subs_dict, keys=True)
+stress_tensor.subs_tensor_components(components_values)
 display(stress_tensor.data)
 
+
+
+
+
+
+$\displaystyle \left[\begin{matrix}\sigma_{11} & \sigma_{22} & \sigma_{33} & \sigma_{23} & \sigma_{13} & \sigma_{12}\end{matrix}\right]$
+
@@ -205,9 +255,10 @@

Stiffness Tensor
[5]:
 

- -
strain_tensor = SymbolicStrainTensor.create(notation=2)
-subs_dict = {
+
strain_tensor = SymbolicStrainTensor.create(notation="voigt")
+display(strain_tensor.data)
+components_values = {
     1: 0,
     2: 0,
     3: 0,
     4: 0,
     5: 0,
 }
-strain_tensor.subs(subs_dict, keys=True)
+strain_tensor.subs_tensor_components(components_values)
 display(strain_tensor.data)
 
+
+
+
+
+
+$\displaystyle \left[\begin{matrix}\epsilon_{11} & \epsilon_{22} & \epsilon_{33} & 2 \epsilon_{23} & 2 \epsilon_{13} & 2 \epsilon_{12}\end{matrix}\right]$
+
@@ -263,19 +320,62 @@

Result
[7]:
 
-
stress_tensor = SymbolicStressTensor.create(notation=2)
+
stress_tensor = SymbolicStressTensor.create(notation="voigt")
 stress_tensor_expr = SymbolicLinearElasticity.hookes_law_inverse(stiffness_tensor, strain_tensor)
-display(sp.Eq(stress_tensor.data, stress_tensor_expr.data))
+display(sp.Equality(stress_tensor.data, stress_tensor_expr.data))
+display(*[sp.Equality(stress_tensor[_], stress_tensor_expr[_]) for _ in range(6)])
 
-
+
$\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]$
+
+
+
+
+
+$\displaystyle \sigma_{11} = \frac{E \epsilon_{11} \left(\nu - 1\right)}{\left(\nu + 1\right) \left(2 \nu - 1\right)}$
+
+
+
+
+
+
+$\displaystyle \sigma_{22} = - \frac{E \epsilon_{11} \nu}{\left(\nu + 1\right) \left(2 \nu - 1\right)}$
+
+
+
+
+
+
+$\displaystyle \sigma_{33} = - \frac{E \epsilon_{11} \nu}{\left(\nu + 1\right) \left(2 \nu - 1\right)}$
+
+
+
+
+
+
+$\displaystyle \sigma_{23} = 0$
+
+
+
+
+
+
+$\displaystyle \sigma_{13} = 0$
+
+
+
+
+
+
+$\displaystyle \sigma_{12} = 0$
+
[ ]:
 
diff --git a/notebooks/symbolic/elasticity.ipynb b/notebooks/symbolic/elasticity.ipynb index 61e4d60..018a52f 100644 --- a/notebooks/symbolic/elasticity.ipynb +++ b/notebooks/symbolic/elasticity.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Symblic Elasticity Notebook" + "# Symbolic Elasticity Notebook" ] }, { @@ -44,9 +44,7 @@ { "data": { "text/plain": [ - "SymbolicIsotropicMaterial(\n", - "{'youngs_modulus': E, 'poisson_ratio': nu}\n", - ")" + "SymbolicIsotropicMaterial(E=E, nu=nu)" ] }, "metadata": {}, @@ -66,9 +64,10 @@ } ], "source": [ - "symbolic_isotropic_material = SymbolicIsotropicMaterial()\n", - "display(symbolic_isotropic_material)\n", - "compliance_tensor = symbolic_isotropic_material.compliance_tensor()\n", + "material_props = {\"E\": sp.symbols(\"E\"), \"nu\": sp.symbols(\"nu\")}\n", + "material = SymbolicIsotropicMaterial(**material_props)\n", + "display(material)\n", + "compliance_tensor = material.compliance_tensor()\n", "display(compliance_tensor.data)" ] }, @@ -84,6 +83,18 @@ "execution_count": 3, "metadata": {}, "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\left[\\begin{matrix}\\sigma_{11} & \\sigma_{22} & \\sigma_{33} & \\sigma_{23} & \\sigma_{13} & \\sigma_{12}\\end{matrix}\\right]$" + ], + "text/plain": [ + "[\\sigma_11, \\sigma_22, \\sigma_33, \\sigma_23, \\sigma_13, \\sigma_12]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, { "data": { "text/latex": [ @@ -98,15 +109,16 @@ } ], "source": [ - "stress_tensor = SymbolicStressTensor.create(notation=2)\n", - "subs_dict = {\n", + "stress_tensor = SymbolicStressTensor.create(notation=\"voigt\")\n", + "display(stress_tensor.data)\n", + "components_values = {\n", " 1: 0,\n", " 2: 0,\n", " 3: 0,\n", " 4: 0,\n", " 5: 0,\n", "}\n", - "stress_tensor.subs(subs_dict, keys=True)\n", + "stress_tensor.subs_tensor_components(components_values)\n", "display(stress_tensor.data)" ] }, @@ -133,12 +145,85 @@ }, "metadata": {}, "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\epsilon_{11} = \\frac{\\sigma_{11}}{E}$" + ], + "text/plain": [ + "Eq(\\epsilon_11, \\sigma_11/E)" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\epsilon_{22} = - \\frac{\\sigma_{11} \\nu}{E}$" + ], + "text/plain": [ + "Eq(\\epsilon_22, -\\sigma_11*nu/E)" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\epsilon_{33} = - \\frac{\\sigma_{11} \\nu}{E}$" + ], + "text/plain": [ + "Eq(\\epsilon_33, -\\sigma_11*nu/E)" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$\\displaystyle 2 \\epsilon_{23} = 0$" + ], + "text/plain": [ + "Eq(2*\\epsilon_23, 0)" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$\\displaystyle 2 \\epsilon_{13} = 0$" + ], + "text/plain": [ + "Eq(2*\\epsilon_13, 0)" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$\\displaystyle 2 \\epsilon_{12} = 0$" + ], + "text/plain": [ + "Eq(2*\\epsilon_12, 0)" + ] + }, + "metadata": {}, + "output_type": "display_data" } ], "source": [ - "strain_tensor = SymbolicStrainTensor.create(notation=2)\n", + "strain_tensor = SymbolicStrainTensor.create(notation=\"voigt\")\n", "strain_tensor_expr = SymbolicLinearElasticity.hookes_law(compliance_tensor, stress_tensor)\n", - "display(sp.Eq(strain_tensor.data, strain_tensor_expr.data))" + "display(sp.Equality(strain_tensor.data, strain_tensor_expr.data))\n", + "display(*[sp.Equality(strain_tensor[_], strain_tensor_expr[_]) for _ in range(6)])" ] }, { @@ -163,9 +248,7 @@ { "data": { "text/plain": [ - "SymbolicIsotropicMaterial(\n", - "{'youngs_modulus': E, 'poisson_ratio': nu}\n", - ")" + "SymbolicIsotropicMaterial(E=E, nu=nu)" ] }, "metadata": {}, @@ -185,9 +268,10 @@ } ], "source": [ - "symbolic_isotropic_material = SymbolicIsotropicMaterial()\n", - "display(symbolic_isotropic_material)\n", - "stiffness_tensor = symbolic_isotropic_material.stiffness_tensor(lames_param=False)\n", + "material_props = {\"E\": sp.symbols(\"E\"), \"nu\": sp.symbols(\"nu\")}\n", + "material = SymbolicIsotropicMaterial(**material_props)\n", + "display(material)\n", + "stiffness_tensor = material.stiffness_tensor()\n", "display(stiffness_tensor.data)" ] }, @@ -203,6 +287,18 @@ "execution_count": 6, "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/latex": [ @@ -217,15 +313,16 @@ } ], "source": [ - "strain_tensor = SymbolicStrainTensor.create(notation=2)\n", - "subs_dict = {\n", + "strain_tensor = SymbolicStrainTensor.create(notation=\"voigt\")\n", + "display(strain_tensor.data)\n", + "components_values = {\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", + "strain_tensor.subs_tensor_components(components_values)\n", "display(strain_tensor.data)" ] }, @@ -252,12 +349,85 @@ }, "metadata": {}, "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\sigma_{11} = \\frac{E \\epsilon_{11} \\left(\\nu - 1\\right)}{\\left(\\nu + 1\\right) \\left(2 \\nu - 1\\right)}$" + ], + "text/plain": [ + "Eq(\\sigma_11, E*\\epsilon_11*(nu - 1)/((nu + 1)*(2*nu - 1)))" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\sigma_{22} = - \\frac{E \\epsilon_{11} \\nu}{\\left(\\nu + 1\\right) \\left(2 \\nu - 1\\right)}$" + ], + "text/plain": [ + "Eq(\\sigma_22, -E*\\epsilon_11*nu/((nu + 1)*(2*nu - 1)))" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\sigma_{33} = - \\frac{E \\epsilon_{11} \\nu}{\\left(\\nu + 1\\right) \\left(2 \\nu - 1\\right)}$" + ], + "text/plain": [ + "Eq(\\sigma_33, -E*\\epsilon_11*nu/((nu + 1)*(2*nu - 1)))" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\sigma_{23} = 0$" + ], + "text/plain": [ + "Eq(\\sigma_23, 0)" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\sigma_{13} = 0$" + ], + "text/plain": [ + "Eq(\\sigma_13, 0)" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\sigma_{12} = 0$" + ], + "text/plain": [ + "Eq(\\sigma_12, 0)" + ] + }, + "metadata": {}, + "output_type": "display_data" } ], "source": [ - "stress_tensor = SymbolicStressTensor.create(notation=2)\n", + "stress_tensor = SymbolicStressTensor.create(notation=\"voigt\")\n", "stress_tensor_expr = SymbolicLinearElasticity.hookes_law_inverse(stiffness_tensor, strain_tensor)\n", - "display(sp.Eq(stress_tensor.data, stress_tensor_expr.data))" + "display(sp.Equality(stress_tensor.data, stress_tensor_expr.data))\n", + "display(*[sp.Equality(stress_tensor[_], stress_tensor_expr[_]) for _ in range(6)])" ] }, { diff --git a/notebooks/symbolic/material.html b/notebooks/symbolic/material.html index d877a7a..cae8e47 100644 --- a/notebooks/symbolic/material.html +++ b/notebooks/symbolic/material.html @@ -18,7 +18,7 @@ - + @@ -26,7 +26,7 @@ - + @@ -66,7 +66,7 @@