Skip to content

Commit

Permalink
add name argument
Browse files Browse the repository at this point in the history
  • Loading branch information
obouchaara committed Dec 22, 2023
1 parent 4f7b231 commit f3180c3
Show file tree
Hide file tree
Showing 4 changed files with 417 additions and 203 deletions.
81 changes: 53 additions & 28 deletions notebooks/symbolic/strain.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@
{
"data": {
"text/plain": [
"SymbolicStrainTensor(\n",
"[epsilon_1, epsilon_2, epsilon_3, epsilon_4, epsilon_5, epsilon_6],\n",
"1\n",
")"
"mechpy.core.symbolic.strain.SymbolicStrainTensor"
]
},
"metadata": {},
Expand All @@ -69,7 +66,7 @@
"data = sp.ImmutableDenseNDimArray([e1, e2, e3, e4, e5, e6])\n",
"display(data)\n",
"strain_tensor = SymbolicStrainTensor(data)\n",
"display(strain_tensor)"
"display(strain_tensor.__class__)"
]
},
{
Expand All @@ -93,32 +90,33 @@
"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]"
"mechpy.core.symbolic.strain.SymbolicStrainTensor"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Only implemented for Voight notation\n"
]
"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)\n",
"display(strain_tensor.data)\n",
"try:\n",
" display(strain_tensor.to_general().data)\n",
"except Exception as e:\n",
" print(e)"
"display(strain_tensor.__class__)\n",
"# display(strain_tensor.data)\n",
"# display(strain_tensor.notation)\n",
"# display(strain_tensor.name)\n",
"display(strain_tensor.to_general().data)"
]
},
{
Expand All @@ -145,13 +143,34 @@
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"2"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/latex": [
"$\\displaystyle \\epsilon$"
],
"text/plain": [
"\\epsilon"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/latex": [
"$\\displaystyle \\left[\\begin{matrix}\\epsilon_{11} & \\epsilon_{12} & \\epsilon_{13}\\\\\\epsilon_{12} & \\epsilon_{22} & \\epsilon_{23}\\\\\\epsilon_{13} & \\epsilon_{23} & \\epsilon_{33}\\end{matrix}\\right]$"
"$\\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_12, \\epsilon_13], [\\epsilon_12, \\epsilon_22, \\epsilon_23], [\\epsilon_13, \\epsilon_23, \\epsilon_33]]"
"[[\\epsilon_11, \\epsilon_22, \\epsilon_33], [\\epsilon_22, \\epsilon_23, \\epsilon_13], [\\epsilon_33, \\epsilon_13, \\epsilon_12]]"
]
},
"metadata": {},
Expand All @@ -162,6 +181,9 @@
"strain_tensor = SymbolicStrainTensor.create(notation=2)\n",
"# display(strain_tensor)\n",
"display(strain_tensor.data)\n",
"display(strain_tensor.notation)\n",
"# display(strain_tensor.name)\n",
"display(sp.symbols(strain_tensor.name))\n",
"display(strain_tensor.to_general().data)"
]
},
Expand All @@ -180,10 +202,10 @@
{
"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]$"
"$\\displaystyle \\epsilon^{1}$"
],
"text/plain": [
"[\\epsilon^1_11, \\epsilon^1_22, \\epsilon^1_33, 2*\\epsilon^1_23, 2*\\epsilon^1_13, 2*\\epsilon^1_12]"
"\\epsilon^1"
]
},
"metadata": {},
Expand All @@ -192,20 +214,23 @@
{
"data": {
"text/latex": [
"$\\displaystyle \\left[\\begin{matrix}\\epsilon^{1}_{11} & \\epsilon^{1}_{12} & \\epsilon^{1}_{13}\\\\\\epsilon^{1}_{12} & \\epsilon^{1}_{22} & \\epsilon^{1}_{23}\\\\\\epsilon^{1}_{13} & \\epsilon^{1}_{23} & \\epsilon^{1}_{33}\\end{matrix}\\right]$"
"$\\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_12, \\epsilon^1_13], [\\epsilon^1_12, \\epsilon^1_22, \\epsilon^1_23], [\\epsilon^1_13, \\epsilon^1_23, \\epsilon^1_33]]"
"[[\\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=2)\n",
"strain_tensor = SymbolicStrainTensor.create(name=\"\\epsilon^1\", notation=2)\n",
"# display(strain_tensor)\n",
"display(strain_tensor.data)\n",
"# display(strain_tensor.data)\n",
"# display(strain_tensor.notation)\n",
"# display(strain_tensor.name)\n",
"display(sp.symbols(strain_tensor.name))\n",
"display(strain_tensor.to_general().data)"
]
},
Expand Down
Loading

0 comments on commit f3180c3

Please sign in to comment.