.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/Rotate_tensor.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_Rotate_tensor.py: =========================================================== Apply a rotation to stiffness tensors =========================================================== This example shows how to apply a rotation to a stiffness tensor. .. GENERATED FROM PYTHON SOURCE LINES 9-14 Define the stiffness tensor for copper --------------------------------------- We define the stiffness tensor for a cubic copper using its elastic constants. They are taken from the `Materials Project (mp-30) `_. .. GENERATED FROM PYTHON SOURCE LINES 14-18 .. code-block:: Python from elasticipy.tensors.elasticity import StiffnessTensor C = StiffnessTensor.cubic(C11=186, C12=134, C44=77) print(C) .. rst-class:: sphx-glr-script-out .. code-block:: none Stiffness tensor (in Voigt mapping): [[186. 134. 134. 0. 0. 0.] [134. 186. 134. 0. 0. 0.] [134. 134. 186. 0. 0. 0.] [ 0. 0. 0. 77. 0. 0.] [ 0. 0. 0. 0. 77. 0.] [ 0. 0. 0. 0. 0. 77.]] .. GENERATED FROM PYTHON SOURCE LINES 19-23 Plot the the Young modulus of the crystal ------------------------------------------------------------ The illustrates the cubic symmetries of the elastic moduli, one can look at the Young modulus: .. GENERATED FROM PYTHON SOURCE LINES 23-26 .. code-block:: Python E = C.Young_modulus E.plot3D() .. raw:: html


.. GENERATED FROM PYTHON SOURCE LINES 27-30 Rotate the tensor -------------------- Assume a rotation of 30° around the X axis: .. GENERATED FROM PYTHON SOURCE LINES 30-33 .. code-block:: Python from scipy.spatial.transform import Rotation r = Rotation.from_euler('X', 30, degrees=True) .. GENERATED FROM PYTHON SOURCE LINES 34-35 Now apply rotation, and check out the "shape" of such tensor: .. GENERATED FROM PYTHON SOURCE LINES 35-38 .. code-block:: Python Crot = C * r print(Crot) .. rst-class:: sphx-glr-script-out .. code-block:: none Stiffness tensor (in Voigt mapping): [[186. 134. 134. 0. 0. 0. ] [134. 224.25 95.75 -22.08 0. 0. ] [134. 95.75 224.25 22.08 0. 0. ] [ 0. -22.08 22.08 38.75 0. 0. ] [ 0. 0. 0. 0. 77. 0. ] [ 0. 0. 0. 0. 0. 77. ]] .. GENERATED FROM PYTHON SOURCE LINES 39-40 Finally, plot the corresponding Young modulus: .. GENERATED FROM PYTHON SOURCE LINES 40-43 .. code-block:: Python Crot.Young_modulus.plot3D() .. raw:: html


.. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.054 seconds) .. _sphx_glr_download_auto_examples_Rotate_tensor.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: Rotate_tensor.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: Rotate_tensor.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: Rotate_tensor.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_