This worksheet demonstrates a few capabilities of SageManifolds (version 1.0, as included in SageMath 7.5) in computations regarding elasticity theory in Cartesian coordinates.
Click here to download the worksheet file (ipynb format). To run it, you must start SageMath with the Jupyter notebook, via the command sage -n jupyter
NB: a version of SageMath at least equal to 7.5 is required to run this worksheet:
version()
'SageMath version 7.5.1, Release Date: 2017-01-15'
First we set up the notebook to display mathematical objects using LaTeX rendering:
%display latex
We introduce the Euclidean space as a 3-dimensional differentiable manifold:
M = Manifold(3, 'M', start_index=1)
print(M)
3-dimensional differentiable manifold M
We then introduce the Cartesian coordinates $(x,y,z)$ as a chart $X$ on $M$:
X.<x,y,z> = M.chart()
print(X)
X
Chart (M, (x, y, z))
The associated vector frame is
X.frame()
We shall expand vector and tensor fields not on this frame, which is the default one on $M$:
M.default_frame()
Let us define the displacement vector $U$ in terms of its components w.r.t. the orthonormal Cartesian frame:
U = M.vector_field(name='U')
U[:] = [function('U_x')(x,y,z), function('U_y')(x,y,z),
function('U_z')(x,y,z)]
U.display()
The following computations will involve the metric $g$ of the Euclidean space. At the current stage of SageManifolds, we need to introduce it explicitly, as a Riemannian metric on the manifold $M$ (in a future version of SageManifolds, one shall to declare $M$ as an Euclidean space, and not merely as a manifold, so that it will come equipped with $g$):
g = M.riemannian_metric('g')
print(g)
Riemannian metric g on the 3-dimensional differentiable manifold M
We initialize $g$ by declaring that its components with respect to the frame of Cartesian coordinates are $\mathrm{diag}(1,1,1)$:
g[1,1], g[2,2], g[3,3] = 1, 1, 1
g.display()
The covariant derivative operator $\nabla$ is introduced as the (Levi-Civita) connection associated with $g$:
nabla = g.connection()
print(nabla)
nabla
Levi-Civita connection nabla_g associated with the Riemannian metric g on the 3-dimensional differentiable manifold M
The covariant derivative of the displacement vector $U$ is
nabU = nabla(U)
print(nabU)
Tensor field nabla_g(U) of type (1,1) on the 3-dimensional differentiable manifold M
nabU.display()
We convert it to a tensor field of type (0,2) (i.e. a bilinear form) by lowering the upper index with $g$:
nabU_form = nabU.down(g)
print(nabU_form)
Tensor field of type (0,2) on the 3-dimensional differentiable manifold M
nabU_form.display()
The strain tensor $\varepsilon$ is defined as the symmetrized part of this tensor:
E = nabU_form.symmetrize()
print(E)
Field of symmetric bilinear forms on the 3-dimensional differentiable manifold M
E.set_name('E', latex_name=r'\varepsilon')
E.display()
Let us display the components of $\varepsilon$, skipping those that can be deduced by symmetry:
E.display_comp(only_nonredundant=True)
To form the stress tensor according to Hooke's law, we introduce first the Lamé constants:
var('ll', latex_name=r'\lambda')
var('mu', latex_name=r'\mu')
The trace (with respect to $g$) of the bilinear form $\varepsilon$ is obtained by (i) raising the first index (pos=0
) by means of $g$ and (ii) by taking the trace of the resulting endomorphism:
trE = E.up(g, pos=0).trace()
print(trE)
Scalar field on the 3-dimensional differentiable manifold M
trE.display()
The stress tensor $S$ is obtained via Hooke's law for isotropic material: $$ S = \lambda \, \mathrm{tr}\varepsilon \; g + 2\mu \, \varepsilon$$
S = ll*trE*g + 2*mu*E
print(S)
Field of symmetric bilinear forms on the 3-dimensional differentiable manifold M
S.set_name('S')
S.display()
S.display_comp(only_nonredundant=True)
Each component can be accessed individually:
S[1,2]
The divergence of the stress tensor is the 1-form:
$$ f_i = \nabla_j S^j_{\ \, i} $$
In a next version of SageManifolds, there will be a function divergence()
. For the moment, to evaluate $f$,
we first form the tensor $S^j_{\ \, i}$ by raising the first index (pos=0
) of $S$ with $g$:
SU = S.up(g, pos=0)
print(SU)
Tensor field of type (1,1) on the 3-dimensional differentiable manifold M
The divergence is obtained by taking the trace on the first index (0
) and the third one (2
) of the tensor
$(\nabla S)^j_{\ \, ik} = \nabla_k S^j_{\ \, i}$:
divS = nabla(SU).trace(0,2)
print(divS)
1-form on the 3-dimensional differentiable manifold M
divS.set_name('f')
divS.display()
divS.display_comp()
Displaying the components one by one:
divS[1]
divS[2]
divS[3]