Introduction

In this notebook, we will plot representation quadrics for some rank 2 tensors.


In [1]:
# Note that this notebook does require a number of dependencies. 
# pytmatgen is used for the high-level interface to the Materials Project.
# The excellent prettyplotlib is used to make nice plots.
# prettytable is used to make nice ASCII tables.
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d.axes3d import Axes3D

%matplotlib inline

In [2]:
def make_plots(T):
    max_x = np.sqrt(abs(T[2] / T[0]))
    max_y = np.sqrt(abs(T[2] / T[1]))
    x = np.linspace(-3*max_x, 3*max_x, 500)
    y = np.linspace(-3*max_y, 3*max_y, 500) 
    X, Y = np.meshgrid(x, y)
    Z = (1 - T[0]* X ** 2 + - T[1]* Y ** 2) / T[2]
    fig = plt.figure(figsize=(16,12))
    ax = fig.add_subplot(2, 2, 1, projection='3d')    
    ax.set_title("3D representation")
    ax.set_xlabel("X")
    ax.set_xlabel("Y")
    ax.set_zlabel("Z")
    
    #Do projections (using polar coordinates)
    theta = np.linspace(-np.pi, np.pi, 1001)
    p = ax.plot_wireframe(X, Y, np.sqrt(Z), rstride=4, cstride=4)
    p = ax.plot_wireframe(X, Y, -np.sqrt(Z), rstride=4, cstride=4)
    ax = fig.add_subplot(2, 2, 2, polar=True)
    r = np.sqrt(1 / (T[0] * np.cos(theta) ** 2  + T[1] * np.sin(theta) ** 2))
    ax.plot(theta, r, color='r', linewidth=3)
    ax.set_title("x-y plane")
    ax.set_rmax(max(1.1, np.nanmax(r) / 5))
    ax = fig.add_subplot(2, 2, 3, polar=True)
    r = np.sqrt(1 / (T[1] * np.cos(theta) ** 2  + T[2] * np.sin(theta) ** 2))
    ax.plot(theta, r, color='r', linewidth=3)
    ax.set_title("y-z plane")
    ax.set_rmax(max(1.1, np.nanmax(r) / 5))
    ax = fig.add_subplot(2, 2, 4, polar=True)
    theta = np.linspace(0, 2 * np.pi, 5000)
    r = np.sqrt(1 / (T[0] * np.cos(theta) ** 2  + T[2] * np.sin(theta) ** 2))
    ax.plot(theta, r, color='r', linewidth=3)
    ax.set_title("x-z plane")
    ax.grid(True)
    ax.set_rmax(max(1.1, np.nanmax(r) / 5))

All tensor eigenvalues positive.


In [3]:
make_plots([1.1, 1.5, 1.7])


/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/kernel/__main__.py:17: RuntimeWarning: invalid value encountered in sqrt
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/kernel/__main__.py:18: RuntimeWarning: invalid value encountered in sqrt

One negative tensor eigenvalue


In [4]:
make_plots([-0.5, 1, 1])


/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/kernel/__main__.py:17: RuntimeWarning: invalid value encountered in sqrt
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/kernel/__main__.py:18: RuntimeWarning: invalid value encountered in sqrt
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/kernel/__main__.py:20: RuntimeWarning: invalid value encountered in sqrt
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/kernel/__main__.py:31: RuntimeWarning: invalid value encountered in sqrt
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/projections/polar.py:65: RuntimeWarning: invalid value encountered in less
  mask = r < 0

Two negative tensor eigenvalue


In [5]:
make_plots([-0.5, -0.7, 1])


/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/kernel/__main__.py:20: RuntimeWarning: invalid value encountered in sqrt
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/lib/nanfunctions.py:319: RuntimeWarning: All-NaN slice encountered
  warnings.warn("All-NaN slice encountered", RuntimeWarning)
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/kernel/__main__.py:25: RuntimeWarning: invalid value encountered in sqrt
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/kernel/__main__.py:31: RuntimeWarning: invalid value encountered in sqrt

In [ ]: