From 3394682f84ab53d905a6da73991267247d1d72e0 Mon Sep 17 00:00:00 2001 From: "Marco A. Lopez-Sanchez" Date: Fri, 12 Jul 2024 14:20:06 +0200 Subject: [PATCH] Delete test_rotation.ipynb --- src/test_rotation.ipynb | 866 ---------------------------------------- 1 file changed, 866 deletions(-) delete mode 100644 src/test_rotation.ipynb diff --git a/src/test_rotation.ipynb b/src/test_rotation.ipynb deleted file mode 100644 index fedf54f..0000000 --- a/src/test_rotation.ipynb +++ /dev/null @@ -1,866 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "import numpy as np" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "Cij_example = np.array(\n", - " [\n", - " [96.2, 46.1, 38.4, 5.9, -0.2, -0.4],\n", - " [46.1, 189.4, 15.4, -7.0, -5.1, -6.8],\n", - " [38.4, 15.4, 171.9, 2.2, 7.2, -9.8],\n", - " [5.9, -7.0, 2.2, 23.6, -1.1, -4.8],\n", - " [-0.2, -5.1, 7.2, -1.1, 33.1, 1.4],\n", - " [-0.4, -6.8, -9.8, -4.8, 1.4, 35.5],\n", - " ]\n", - ")\n" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "def rotate_Cij(\n", - " stiffness_matrix: np.ndarray,\n", - " angle_degrees: float,\n", - " rotation_axis: int = 3\n", - " ) -> tuple[np.ndarray, np.ndarray]:\n", - " \"\"\"\n", - " Rotates the 6x6 stiffness matrix in Voigt notation using the Bond\n", - " transformation matrix by rotating it around a specified axis. The\n", - " rotation is performed in the right-handed coordinate system.\n", - "\n", - " Parameters\n", - " ----------\n", - " stiffness_matrix : np.ndarray\n", - " The original 6x6 stiffness matrix in Voigt notation.\n", - "\n", - " angle_degrees : float\n", - " The rotation angle in degrees (positive for counterclockwise rotation).\n", - "\n", - " rotation_axis : int, optional\n", - " The axis around which to rotate:\n", - " 1: Rotate around x1-axis (fix x1, rotate x2 and x3)\n", - " 2: Rotate around x2-axis (fix x2, rotate x1 and x3)\n", - " 3: Rotate around x3-axis (fix x3, rotate x1 and x2)\n", - " Default is 3.\n", - "\n", - " Returns\n", - " -------\n", - " tuple[np.ndarray, np.ndarray]\n", - " - The rotated 6x6 stiffness matrix\n", - " - The Bond transformation matrix used for rotation\n", - "\n", - " References\n", - " ----------\n", - " Bond, W. (1943). The mathematics of the physical properties of crystals. \n", - " The Bell System Technical Journal, 22(1), 1-72.\n", - " \"\"\"\n", - "\n", - " # Convert angle from degrees to radians\n", - " theta = np.deg2rad(angle_degrees)\n", - "\n", - " # Calculate cosines and sines\n", - " cos_theta = np.cos(theta)\n", - " sin_theta = np.sin(theta)\n", - "\n", - " if rotation_axis == 1:\n", - " # Rotation around the 1-axis (x1 is fixed)\n", - " bond_matrix = np.array([\n", - " [1, 0, 0, 0, 0, 0],\n", - " [0, cos_theta**2, sin_theta**2, 0, 0, 2*cos_theta*sin_theta],\n", - " [0, sin_theta**2, cos_theta**2, 0, 0, -2*cos_theta*sin_theta],\n", - " [0, 0, 0, cos_theta, -sin_theta, 0],\n", - " [0, 0, 0, sin_theta, cos_theta, 0],\n", - " [0, -cos_theta*sin_theta, cos_theta*sin_theta, 0, 0, cos_theta**2 - sin_theta**2]\n", - " ])\n", - " elif rotation_axis == 2:\n", - " # Rotation around the 2-axis (x2 is fixed)\n", - " bond_matrix = np.array([\n", - " [cos_theta**2, 0, sin_theta**2, 0, 2*cos_theta*sin_theta, 0],\n", - " [0, 1, 0, 0, 0, 0],\n", - " [sin_theta**2, 0, cos_theta**2, 0, -2*cos_theta*sin_theta, 0],\n", - " [0, 0, 0, cos_theta, 0, sin_theta],\n", - " [-cos_theta*sin_theta, 0, cos_theta*sin_theta, 0, cos_theta**2 - sin_theta**2, 0],\n", - " [0, 0, 0, -sin_theta, 0, cos_theta]\n", - " ])\n", - " elif rotation_axis == 3:\n", - " # Rotation around the 3-axis (x3 is fixed)\n", - " bond_matrix = np.array([\n", - " [cos_theta**2, sin_theta**2, 0, 0, 0, 2*cos_theta*sin_theta],\n", - " [sin_theta**2, cos_theta**2, 0, 0, 0, -2*cos_theta*sin_theta],\n", - " [0, 0, 1, 0, 0, 0],\n", - " [0, 0, 0, cos_theta, -sin_theta, 0],\n", - " [0, 0, 0, sin_theta, cos_theta, 0],\n", - " [-cos_theta*sin_theta, cos_theta*sin_theta, 0, 0, 0, cos_theta**2 - sin_theta**2]\n", - " ])\n", - " else:\n", - " raise ValueError(\"rotation_axis must be either 1, 2, or 3\")\n", - "\n", - " # Apply the Bond transformation to the stiffness matrix\n", - " rotated_stiffness_matrix = bond_matrix @ stiffness_matrix @ bond_matrix.T\n", - "\n", - " return rotated_stiffness_matrix, bond_matrix\n", - "\n", - "\n", - "def rotate_Cij_fromMatlab(c: np.ndarray, theta: float) -> tuple[np.ndarray, np.ndarray]:\n", - " \"\"\"\n", - " Calculate the Bond transformation of the elastic stiffness matrix.\n", - "\n", - " This function rotates the stiffness tensor around the vertical axis (x3).\n", - " The old axes are x1 (horizontal), x2 (horizontal), x3 (vertical).\n", - " The new axes are x1' (horizontal), x2' (horizontal), x3' = x3 (vertical).\n", - " The vertical axis stays the same, while the x1 axis rotates counter-clockwise.\n", - "\n", - " Parameters:\n", - " -----------\n", - " c : np.ndarray\n", - " The 6x6 stiffness tensor (cij, i,j=1 to 6) under the old coordinate system.\n", - " theta : float\n", - " The angle (in degrees) required to rotate x1 to x1'.\n", - "\n", - " Returns:\n", - " --------\n", - " tuple[np.ndarray, np.ndarray]\n", - " cnew : The stiffness tensor under the new coordinate system.\n", - " M : The Bond transformation matrix.\n", - "\n", - " Notes:\n", - " ------\n", - " - This transformation may be applied to TIH (Transverse Isotropic with \n", - " Horizontal symmetry axis) media, e.g., that caused by vertically aligned fractures.\n", - " - The angle theta may be assigned to be the angle between the fracture normal \n", - " and a seismic line.\n", - " - To test validity, apply this function twice to an arbitrary 6x6 matrix,\n", - " first by degree phi, then by degree -phi, to see if the original matrix is recovered.\n", - "\n", - " References:\n", - " -----------\n", - " - Rock Physics Handbook, Chapter 1.4, \"Coordinate Transformations\"\n", - " - Originally written by Haibin Xu, 2002\n", - " - Modified by G. Mavko, 2003\n", - " \"\"\"\n", - " if c.shape != (6, 6):\n", - " raise ValueError(\"Input stiffness matrix must be 6x6\")\n", - "\n", - " # Convert angle to radians\n", - " theta = np.deg2rad(theta)\n", - "\n", - " # Calculate the cosines\n", - " b11 = b22 = np.cos(theta)\n", - " b33 = 1\n", - " b21 = np.cos(theta + np.pi/2)\n", - " b12 = np.cos(np.pi/2 - theta)\n", - " b13 = b31 = b23 = b32 = 0\n", - "\n", - " # Calculate the Bond matrix\n", - " M1 = np.array([[b11**2, b12**2, b13**2],\n", - " [b21**2, b22**2, b23**2],\n", - " [b31**2, b32**2, b33**2]])\n", - "\n", - " M2 = np.array([[b12*b13, b13*b11, b11*b12],\n", - " [b22*b23, b23*b21, b21*b22],\n", - " [b32*b33, b33*b31, b31*b32]])\n", - "\n", - " M3 = np.array([[b21*b31, b22*b32, b23*b33],\n", - " [b31*b11, b32*b12, b33*b13],\n", - " [b11*b21, b12*b22, b13*b23]])\n", - "\n", - " M4 = np.array([[b22*b33+b23*b32, b21*b33+b23*b31, b22*b31+b21*b32],\n", - " [b12*b33+b13*b32, b11*b33+b13*b31, b11*b32+b12*b31],\n", - " [b22*b13+b12*b23, b11*b23+b13*b21, b22*b11+b12*b21]])\n", - "\n", - " M = np.block([[M1, 2*M2],\n", - " [M3, M4]])\n", - "\n", - " # Calculate the new stiffness tensor\n", - " cnew = M @ c @ M.T\n", - "\n", - " return cnew, M\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "\n", - "## Test x3 axis rotation (vertical rotation)" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([[106.4 , 52.97, 24.16, -1.18, -0.93, 11.21],\n", - " [ 52.97, 165.47, 29.64, 2.87, -4.21, 25.54],\n", - " [ 24.16, 29.64, 171.9 , -1.69, 7.34, -14.86],\n", - " [ -1.18, 2.87, -1.69, 26.93, -4.66, -6.21],\n", - " [ -0.93, -4.21, 7.34, -4.66, 29.77, -5.22],\n", - " [ 11.21, 25.54, -14.86, -6.21, -5.22, 42.37]])" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "Cij_rot1, M1 = rotate_Cij(Cij_example, angle_degrees=30, rotation_axis=3)\n", - "np.around(Cij_rot1, 2)" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([[106.4 , 52.97, 24.16, -1.18, -0.93, 11.21],\n", - " [ 52.97, 165.47, 29.64, 2.87, -4.21, 25.54],\n", - " [ 24.16, 29.64, 171.9 , -1.69, 7.34, -14.86],\n", - " [ -1.18, 2.87, -1.69, 26.93, -4.66, -6.21],\n", - " [ -0.93, -4.21, 7.34, -4.66, 29.77, -5.22],\n", - " [ 11.21, 25.54, -14.86, -6.21, -5.22, 42.37]])" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# Matlab reimplementation for x3\n", - "Cij_rot2, M2 = rotate_Cij_fromMatlab(Cij_example, theta=30)\n", - "np.around(Cij_rot2, 2)" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "True" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# assert that the rotated Cij are similar\n", - "np.allclose(Cij_rot1, Cij_rot2)" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[True, True]" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# assert that when rotated -30 we obtain the original tensor\n", - "[np.allclose(Cij_example, rotate_Cij(Cij_rot1, angle_degrees=-30, rotation_axis=3)[0]),\n", - " np.allclose(Cij_example, rotate_Cij(Cij_rot2, angle_degrees=-30, rotation_axis=3)[0])] " - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([[ 0.75, 0.25, 0. , 0. , 0. , 0.87],\n", - " [ 0.25, 0.75, 0. , 0. , 0. , -0.87],\n", - " [ 0. , 0. , 1. , 0. , 0. , 0. ],\n", - " [ 0. , 0. , 0. , 0.87, -0.5 , 0. ],\n", - " [ 0. , 0. , 0. , 0.5 , 0.87, 0. ],\n", - " [-0.43, 0.43, 0. , 0. , 0. , 0.5 ]])" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "np.around(M1, 2)" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "True" - ] - }, - "execution_count": 9, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# assert that the Bond transformation matrices are the same\n", - "np.allclose(M1, M2)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### x1 axis rotation" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([[ 96.2 , 43.83, 40.67, 5.21, 2.78, -3.53],\n", - " [ 43.83, 136.6 , 49.44, -7.26, -5.13, -29.09],\n", - " [ 40.67, 49.44, 156.61, 2.06, 4.55, 13.22],\n", - " [ 5.21, -7.26, 2.06, 26.93, -4.66, -1.64],\n", - " [ 2.78, -5.13, 4.55, -4.66, 29.77, 6.01],\n", - " [ -3.53, -29.09, 13.22, -1.64, 6.01, 69.54]])" - ] - }, - "execution_count": 10, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "Cij_rot1, M1 = rotate_Cij(Cij_example, angle_degrees=30, rotation_axis=1)\n", - "np.around(Cij_rot1, 2)" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "True" - ] - }, - "execution_count": 11, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# assert that when rotated -30 we obtain the original tensor\n", - "np.allclose(Cij_example, rotate_Cij(Cij_rot1, angle_degrees=-30, rotation_axis=1)[0])" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([[ 1. , 0. , 0. , 0. , 0. , 0. ],\n", - " [ 0. , 0.75, 0.25, 0. , 0. , 0.87],\n", - " [ 0. , 0.25, 0.75, 0. , 0. , -0.87],\n", - " [ 0. , 0. , 0. , 0.87, -0.5 , 0. ],\n", - " [ 0. , 0. , 0. , 0.5 , 0.87, 0. ],\n", - " [ 0. , -0.43, 0.43, 0. , 0. , 0.5 ]])" - ] - }, - "execution_count": 12, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "np.around(M1, 2)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### x2 axis rotation" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([[106.94, 34.01, 52.65, 2.71, 13.61, -3.34],\n", - " [ 34.01, 189.4 , 27.49, -9.46, -15.84, -2.39],\n", - " [ 52.65, 27.49, 132.66, -0.8 , 22.67, -9.54],\n", - " [ 2.71, -9.46, -0.8 , 22.42, -3.55, 2.75],\n", - " [ 13.61, -15.84, 22.67, -3.55, 47.35, -1.84],\n", - " [ -3.34, -2.39, -9.54, 2.75, -1.84, 36.68]])" - ] - }, - "execution_count": 13, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "Cij_rot1, M1 = rotate_Cij(Cij_example, angle_degrees=30, rotation_axis=2)\n", - "np.around(Cij_rot1, 2)" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "True" - ] - }, - "execution_count": 14, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# assert that when rotated -30 we obtain the original tensor\n", - "np.allclose(Cij_example, rotate_Cij(Cij_rot1, angle_degrees=-30, rotation_axis=2)[0])" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([[ 0.75, 0. , 0.25, 0. , 0.87, 0. ],\n", - " [ 0. , 1. , 0. , 0. , 0. , 0. ],\n", - " [ 0.25, 0. , 0.75, 0. , -0.87, 0. ],\n", - " [ 0. , 0. , 0. , 0.87, 0. , 0.5 ],\n", - " [-0.43, 0. , 0.43, 0. , 0.5 , 0. ],\n", - " [ 0. , 0. , 0. , -0.5 , 0. , 0.87]])" - ] - }, - "execution_count": 15, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "np.around(M1, 2)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "Test with olivine (comparison with MTEX)" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [], - "source": [ - "# Density (g/cm3) of Fe-bearing San Carlos olivine at 1.5 GPa and 1027°C (1300 K), custom fitting from Zhang and Bass (2016)\n", - "rho_Fo90 = 3.291\n", - "\n", - "# elastic constants of San Carlos olivine at 1.5 GPa and 1027°C (1300 K), custom fitting from Zhang and Bass (2016)\n", - "C11 = 280.2\n", - "C22 = 182.1\n", - "C33 = 207.6\n", - "C44 = 56.8\n", - "C55 = 68.8\n", - "C66 = 68.5\n", - "C12 = 71.9\n", - "C13 = 67.2\n", - "C23 = 70.1\n", - "\n", - "# Elastic stiffness tensor (in GPa) values as a Cij matrix\n", - "Cij_Fo90 = np.array(\n", - " [[C11, C12, C13, 0.0, 0.0, 0.0],\n", - " [ C12, C22, C23, 0.0, 0.0, 0.0],\n", - " [ C13, C23, C33, 0.0, 0.0, 0.0],\n", - " [ 0.0, 0.0, 0.0, C44, 0.0, 0.0],\n", - " [ 0.0, 0.0, 0.0, 0.0, C55, 0.0],\n", - " [ 0.0, 0.0, 0.0, 0.0, 0.0, C66]])" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([[280.2, 71.9, 67.2, 0. , 0. , 0. ],\n", - " [ 71.9, 182.1, 70.1, 0. , 0. , 0. ],\n", - " [ 67.2, 70.1, 207.6, 0. , 0. , 0. ],\n", - " [ 0. , 0. , 0. , 56.8, 0. , 0. ],\n", - " [ 0. , 0. , 0. , 0. , 68.8, 0. ],\n", - " [ 0. , 0. , 0. , 0. , 0. , 68.5]])" - ] - }, - "execution_count": 20, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "Cij_Fo90" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([[182.1, 71.9, 70.1, 0. , 0. , -0. ],\n", - " [ 71.9, 280.2, 67.2, 0. , 0. , -0. ],\n", - " [ 70.1, 67.2, 207.6, 0. , 0. , 0. ],\n", - " [ 0. , 0. , 0. , 68.8, -0. , 0. ],\n", - " [ 0. , 0. , 0. , -0. , 56.8, 0. ],\n", - " [ -0. , -0. , 0. , 0. , 0. , 68.5]])" - ] - }, - "execution_count": 17, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "Cij_rot3, M3 = rotate_Cij(Cij_Fo90, angle_degrees=90, rotation_axis=3)\n", - "np.around(Cij_rot3, 2)" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([[280.2, 67.2, 71.9, 0. , 0. , -0. ],\n", - " [ 67.2, 207.6, 70.1, 0. , 0. , 0. ],\n", - " [ 71.9, 70.1, 182.1, 0. , 0. , 0. ],\n", - " [ 0. , 0. , 0. , 68.8, -0. , 0. ],\n", - " [ 0. , 0. , 0. , -0. , 56.8, 0. ],\n", - " [ -0. , 0. , 0. , 0. , 0. , 68.5]])" - ] - }, - "execution_count": 18, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "Cij_rot1, M1 = rotate_Cij(Cij_Fo90, angle_degrees=90, rotation_axis=1)\n", - "np.around(Cij_rot1, 2)" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([[207.6, 70.1, 67.2, 0. , 0. , 0. ],\n", - " [ 70.1, 182.1, 71.9, 0. , -0. , 0. ],\n", - " [ 67.2, 71.9, 280.2, 0. , -0. , 0. ],\n", - " [ 0. , 0. , 0. , 68.5, 0. , 0. ],\n", - " [ 0. , -0. , -0. , 0. , 68.8, 0. ],\n", - " [ 0. , 0. , 0. , 0. , 0. , 56.8]])" - ] - }, - "execution_count": 19, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "Cij_rot2, M2 = rotate_Cij(Cij_Fo90, angle_degrees=90, rotation_axis=2)\n", - "np.around(Cij_rot2, 2)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "## test a rotation of 45 degrees" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([[220.03, 83.03, 68.65, 0. , 0. , -24.53],\n", - " [ 83.03, 220.03, 68.65, 0. , 0. , -24.53],\n", - " [ 68.65, 68.65, 207.6 , 0. , 0. , 1.45],\n", - " [ 0. , 0. , 0. , 62.8 , -6. , 0. ],\n", - " [ 0. , 0. , 0. , -6. , 62.8 , 0. ],\n", - " [-24.53, -24.53, 1.45, 0. , 0. , 79.63]])" - ] - }, - "execution_count": 21, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "Cij_rot3, M3 = rotate_Cij(Cij_Fo90, angle_degrees=45, rotation_axis=3)\n", - "np.around(Cij_rot3, 2)" - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "True" - ] - }, - "execution_count": 26, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# test result\n", - "np.allclose(Cij_rot3, rotate_Cij_fromMatlab(Cij_Fo90, theta=45)[0])" - ] - }, - { - "cell_type": "code", - "execution_count": 27, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "True" - ] - }, - "execution_count": 27, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "np.allclose(Cij_Fo90, rotate_Cij(Cij_rot3, angle_degrees=-45, rotation_axis=3)[0])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "45 degrees zvector in MTEX:\n", - "```\n", - " tensor in Voigt matrix representation:\n", - " 220.02 83.02 68.65 0 0 24.53\n", - " 83.02 220.03 68.65 0 0 24.53\n", - " 68.65 68.65 207.6 0 0 -1.45\n", - " 0 0 0 62.8 6 0\n", - " 0 0 0 6 62.8 0\n", - " 24.52 24.53 -1.45 0 0 79.62\n", - "```" - ] - }, - { - "cell_type": "code", - "execution_count": 29, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([[ 0.5 , 0.5 , 0. , 0. , 0. , 1. ],\n", - " [ 0.5 , 0.5 , 0. , 0. , 0. , -1. ],\n", - " [ 0. , 0. , 1. , 0. , 0. , 0. ],\n", - " [ 0. , 0. , 0. , 0.71, -0.71, 0. ],\n", - " [ 0. , 0. , 0. , 0.71, 0.71, 0. ],\n", - " [-0.5 , 0.5 , 0. , 0. , 0. , 0. ]])" - ] - }, - "execution_count": 29, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "np.around(M3, 2)" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([[280.2 , 69.55, 69.55, 0. , 0. , -2.35],\n", - " [ 69.55, 200.98, 63.98, 0. , 0. , 6.38],\n", - " [ 69.55, 63.98, 200.98, 0. , 0. , 6.38],\n", - " [ 0. , 0. , 0. , 62.8 , -6. , 0. ],\n", - " [ 0. , 0. , 0. , -6. , 62.8 , 0. ],\n", - " [ -2.35, 6.38, 6.38, 0. , 0. , 62.38]])" - ] - }, - "execution_count": 22, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "Cij_rot1, M1 = rotate_Cij(Cij_Fo90, angle_degrees=45, rotation_axis=1)\n", - "np.around(Cij_rot1, 2)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "```\n", - " tensor in Voigt matrix representation:\n", - " 280.2 69.55 69.55 2.35 0 0\n", - " 69.55 189.27 75.67 -6.38 0 0\n", - " 69.55 75.67 189.27 -6.38 0 0\n", - " 2.35 -6.38 -6.38 62.38 0 0\n", - " 0 0 0 0 68.65 -0.15\n", - " 0 0 0 0 -0.15 68.65\n", - "```" - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([[224.35, 71. , 86.75, 0. , -18.15, 0. ],\n", - " [ 71. , 182.1 , 71. , 0. , -0.9 , 0. ],\n", - " [ 86.75, 71. , 224.35, 0. , -18.15, 0. ],\n", - " [ 0. , 0. , 0. , 62.65, 0. , 5.85],\n", - " [-18.15, -0.9 , -18.15, 0. , 88.35, 0. ],\n", - " [ 0. , 0. , 0. , 5.85, 0. , 62.65]])" - ] - }, - "execution_count": 23, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "Cij_rot2, M2 = rotate_Cij(Cij_Fo90, angle_degrees=45, rotation_axis=2)\n", - "np.around(Cij_rot2, 2)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "```\n", - " tensor in Voigt matrix representation:\n", - " 224.35 71 86.75 0 -18.15 0\n", - " 71 182.1 71 0 -0.9 0\n", - " 86.75 71 224.35 0 -18.15 0\n", - " 0 0 0 62.65 0 -5.85\n", - " -18.15 -0.9 -18.15 0 88.35 0\n", - " 0 0 0 -5.85 0 62.65\n", - "\n", - "```" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "main", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.11.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -}