{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import sympy\n",
    "\n",
    "import qsymm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# C3 rotational symmetry - invariant under 2pi/3\n",
    "C3 = qsymm.rotation(1/3, spin=1/2)\n",
    "\n",
    "# Time reversal\n",
    "TR = qsymm.time_reversal(2, spin=1/2)\n",
    "\n",
    "# Mirror symmetry in x\n",
    "Mx = qsymm.mirror([1, 0], spin=1/2)\n",
    "\n",
    "symmetries = [C3, TR, Mx]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "dim = 2  # Momenta along x and y\n",
    "total_power = 3  # Maximum power of momenta"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}1 & 0\\\\0 & 1\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[1, 0],\n",
       "[0, 1]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & i k_{x} + k_{y}\\\\- i k_{x} + k_{y} & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[           0, I*k_x + k_y],\n",
       "[-I*k_x + k_y,           0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}k_{x}^{2} + k_{y}^{2} & 0\\\\0 & k_{x}^{2} + k_{y}^{2}\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[k_x**2 + k_y**2,               0],\n",
       "[              0, k_x**2 + k_y**2]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & i k_{x}^{3} + k_{x}^{2} k_{y} + i k_{x} k_{y}^{2} + k_{y}^{3}\\\\- i k_{x}^{3} + k_{x}^{2} k_{y} - i k_{x} k_{y}^{2} + k_{y}^{3} & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[                                             0, I*k_x**3 + k_x**2*k_y + I*k_x*k_y**2 + k_y**3],\n",
       "[-I*k_x**3 + k_x**2*k_y - I*k_x*k_y**2 + k_y**3,                                             0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}- \\frac{k_{x}^{3}}{3} + k_{x} k_{y}^{2} & 0\\\\0 & \\frac{k_{x}^{3}}{3} - k_{x} k_{y}^{2}\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[-k_x**3/3 + k_x*k_y**2,                     0],\n",
       "[                     0, k_x**3/3 - k_x*k_y**2]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "family = qsymm.continuum_hamiltonian(symmetries, dim, total_power, prettify=True)\n",
    "qsymm.display_family(family)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "qsymm.hamiltonian_generator.check_symmetry(family, symmetries)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Spatial inversion\n",
    "pU = np.array([\n",
    "    [1.0, 0.0, 0.0, 0.0],\n",
    "    [0.0, -1.0, 0.0, 0.0],\n",
    "    [0.0, 0.0, 1.0, 0.0],\n",
    "    [0.0, 0.0, 0.0, -1.0],\n",
    "])\n",
    "pS = qsymm.inversion(2, U=pU)\n",
    "\n",
    "# Time reversal\n",
    "trU = np.array([\n",
    "    [0.0, 0.0, -1.0, 0.0],\n",
    "    [0.0, 0.0, 0.0, -1.0],\n",
    "    [1.0, 0.0, 0.0, 0.0],\n",
    "    [0.0, 1.0, 0.0, 0.0],\n",
    "])\n",
    "trS = qsymm.time_reversal(2, U=trU)\n",
    "\n",
    "# Rotation\n",
    "phi = 2.0 * np.pi / 4.0  # Impose 4-fold rotational symmetry\n",
    "rotU = np.array([\n",
    "    [np.exp(-1j*phi/2), 0.0, 0.0, 0.0],\n",
    "    [0.0, np.exp(-1j*3*phi/2), 0.0, 0.0],\n",
    "    [0.0, 0.0, np.exp(1j*phi/2), 0.0],\n",
    "    [0.0, 0.0, 0.0, np.exp(1j*3*phi/2)],\n",
    "])\n",
    "rotS = qsymm.rotation(1/4, U=rotU)\n",
    "\n",
    "symmetries = [rotS, trS, pS]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "dim = 2\n",
    "total_power = 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}1 & 0 & 0 & 0\\\\0 & 0 & 0 & 0\\\\0 & 0 & 1 & 0\\\\0 & 0 & 0 & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[1, 0, 0, 0],\n",
       "[0, 0, 0, 0],\n",
       "[0, 0, 1, 0],\n",
       "[0, 0, 0, 0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & 0 & 0 & 0\\\\0 & 1 & 0 & 0\\\\0 & 0 & 0 & 0\\\\0 & 0 & 0 & 1\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[0, 0, 0, 0],\n",
       "[0, 1, 0, 0],\n",
       "[0, 0, 0, 0],\n",
       "[0, 0, 0, 1]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & k_{x} + i k_{y} & 0 & 0\\\\k_{x} - i k_{y} & 0 & 0 & 0\\\\0 & 0 & 0 & - k_{x} + i k_{y}\\\\0 & 0 & - k_{x} - i k_{y} & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[          0, k_x + I*k_y,            0,            0],\n",
       "[k_x - I*k_y,           0,            0,            0],\n",
       "[          0,           0,            0, -k_x + I*k_y],\n",
       "[          0,           0, -k_x - I*k_y,            0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & i k_{x} - k_{y} & 0 & 0\\\\- i k_{x} - k_{y} & 0 & 0 & 0\\\\0 & 0 & 0 & i k_{x} + k_{y}\\\\0 & 0 & - i k_{x} + k_{y} & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[           0, I*k_x - k_y,            0,           0],\n",
       "[-I*k_x - k_y,           0,            0,           0],\n",
       "[           0,           0,            0, I*k_x + k_y],\n",
       "[           0,           0, -I*k_x + k_y,           0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}k_{x}^{2} + k_{y}^{2} & 0 & 0 & 0\\\\0 & 0 & 0 & 0\\\\0 & 0 & k_{x}^{2} + k_{y}^{2} & 0\\\\0 & 0 & 0 & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[k_x**2 + k_y**2, 0,               0, 0],\n",
       "[              0, 0,               0, 0],\n",
       "[              0, 0, k_x**2 + k_y**2, 0],\n",
       "[              0, 0,               0, 0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & 0 & 0 & 0\\\\0 & k_{x}^{2} + k_{y}^{2} & 0 & 0\\\\0 & 0 & 0 & 0\\\\0 & 0 & 0 & k_{x}^{2} + k_{y}^{2}\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[0,               0, 0,               0],\n",
       "[0, k_x**2 + k_y**2, 0,               0],\n",
       "[0,               0, 0,               0],\n",
       "[0,               0, 0, k_x**2 + k_y**2]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "family = qsymm.continuum_hamiltonian(symmetries, dim, total_power, prettify=True)\n",
    "qsymm.display_family(family)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Spatial inversion\n",
    "pU = np.diag([1, -1, 1, -1])\n",
    "pS = qsymm.inversion(3, pU)\n",
    "\n",
    "# Time reversal\n",
    "trU = np.array([\n",
    "    [0.0, 0.0, -1.0, 0.0],\n",
    "    [0.0, 0.0, 0.0, -1.0],\n",
    "    [1.0, 0.0, 0.0, 0.0],\n",
    "    [0.0, 1.0, 0.0, 0.0],\n",
    "])\n",
    "trS = qsymm.time_reversal(3, trU)\n",
    "\n",
    "# Rotation\n",
    "phi = 2.0 * np.pi / 3.0  # Impose 3-fold rotational symmetry\n",
    "rotU = np.array([\n",
    "    [np.exp(1j*phi/2), 0.0, 0.0, 0.0],\n",
    "    [0.0, np.exp(1j*phi/2), 0.0, 0.0],\n",
    "    [0.0, 0.0, np.exp(-1j*phi/2), 0.0],\n",
    "    [0.0, 0.0, 0.0, np.exp(-1j*phi/2)],\n",
    "])\n",
    "rotS = qsymm.rotation(1/3, axis=[0, 0, 1], U=rotU)\n",
    "\n",
    "symmetries = [rotS, trS, pS]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "dim = 3\n",
    "total_power = 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}1 & 0 & 0 & 0\\\\0 & 0 & 0 & 0\\\\0 & 0 & 1 & 0\\\\0 & 0 & 0 & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[1, 0, 0, 0],\n",
       "[0, 0, 0, 0],\n",
       "[0, 0, 1, 0],\n",
       "[0, 0, 0, 0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & 0 & 0 & 0\\\\0 & 1 & 0 & 0\\\\0 & 0 & 0 & 0\\\\0 & 0 & 0 & 1\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[0, 0, 0, 0],\n",
       "[0, 1, 0, 0],\n",
       "[0, 0, 0, 0],\n",
       "[0, 0, 0, 1]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & 0 & 0 & k_{x} + i k_{y}\\\\0 & 0 & k_{x} + i k_{y} & 0\\\\0 & k_{x} - i k_{y} & 0 & 0\\\\k_{x} - i k_{y} & 0 & 0 & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[          0,           0,           0, k_x + I*k_y],\n",
       "[          0,           0, k_x + I*k_y,           0],\n",
       "[          0, k_x - I*k_y,           0,           0],\n",
       "[k_x - I*k_y,           0,           0,           0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & 0 & 0 & i k_{x} - k_{y}\\\\0 & 0 & i k_{x} - k_{y} & 0\\\\0 & - i k_{x} - k_{y} & 0 & 0\\\\- i k_{x} - k_{y} & 0 & 0 & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[           0,            0,           0, I*k_x - k_y],\n",
       "[           0,            0, I*k_x - k_y,           0],\n",
       "[           0, -I*k_x - k_y,           0,           0],\n",
       "[-I*k_x - k_y,            0,           0,           0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & k_{z} & 0 & 0\\\\k_{z} & 0 & 0 & 0\\\\0 & 0 & 0 & - k_{z}\\\\0 & 0 & - k_{z} & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[  0, k_z,    0,    0],\n",
       "[k_z,   0,    0,    0],\n",
       "[  0,   0,    0, -k_z],\n",
       "[  0,   0, -k_z,    0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & i k_{z} & 0 & 0\\\\- i k_{z} & 0 & 0 & 0\\\\0 & 0 & 0 & i k_{z}\\\\0 & 0 & - i k_{z} & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[     0, I*k_z,      0,     0],\n",
       "[-I*k_z,     0,      0,     0],\n",
       "[     0,     0,      0, I*k_z],\n",
       "[     0,     0, -I*k_z,     0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}k_{z}^{2} & 0 & 0 & 0\\\\0 & 0 & 0 & 0\\\\0 & 0 & k_{z}^{2} & 0\\\\0 & 0 & 0 & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[k_z**2, 0,      0, 0],\n",
       "[     0, 0,      0, 0],\n",
       "[     0, 0, k_z**2, 0],\n",
       "[     0, 0,      0, 0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & 0 & 0 & 0\\\\0 & k_{z}^{2} & 0 & 0\\\\0 & 0 & 0 & 0\\\\0 & 0 & 0 & k_{z}^{2}\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[0,      0, 0,      0],\n",
       "[0, k_z**2, 0,      0],\n",
       "[0,      0, 0,      0],\n",
       "[0,      0, 0, k_z**2]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}k_{x}^{2} + k_{y}^{2} & 0 & 0 & 0\\\\0 & 0 & 0 & 0\\\\0 & 0 & k_{x}^{2} + k_{y}^{2} & 0\\\\0 & 0 & 0 & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[k_x**2 + k_y**2, 0,               0, 0],\n",
       "[              0, 0,               0, 0],\n",
       "[              0, 0, k_x**2 + k_y**2, 0],\n",
       "[              0, 0,               0, 0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & 0 & 0 & 0\\\\0 & k_{x}^{2} + k_{y}^{2} & 0 & 0\\\\0 & 0 & 0 & 0\\\\0 & 0 & 0 & k_{x}^{2} + k_{y}^{2}\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[0,               0, 0,               0],\n",
       "[0, k_x**2 + k_y**2, 0,               0],\n",
       "[0,               0, 0,               0],\n",
       "[0,               0, 0, k_x**2 + k_y**2]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "family = qsymm.continuum_hamiltonian(symmetries, dim, total_power, prettify=True)\n",
    "qsymm.display_family(family)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}1 & 0\\\\0 & 1\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[1, 0],\n",
       "[0, 1]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}k_{z} & k_{x} - i k_{y}\\\\k_{x} + i k_{y} & - k_{z}\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[        k_z, k_x - I*k_y],\n",
       "[k_x + I*k_y,        -k_z]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}k_{x}^{2} + k_{y}^{2} + k_{z}^{2} & 0\\\\0 & k_{x}^{2} + k_{y}^{2} + k_{z}^{2}\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[k_x**2 + k_y**2 + k_z**2,                        0],\n",
       "[                       0, k_x**2 + k_y**2 + k_z**2]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 3D real space rotation generators\n",
    "L = qsymm.groups.L_matrices(3)\n",
    "# Spin-1/2 matrices\n",
    "S = qsymm.groups.spin_matrices(1/2)\n",
    "# Spin-3/2 spin matrices\n",
    "J = qsymm.groups.spin_matrices(3/2)\n",
    "# Continuous rotation generators\n",
    "symmetries = [qsymm.ContinuousGroupGenerator(l, s) for l, s in zip(L, S)]\n",
    "\n",
    "dim = 3\n",
    "total_power = 2\n",
    "\n",
    "family = qsymm.continuum_hamiltonian(symmetries, dim, total_power, prettify=True)\n",
    "qsymm.display_family(family)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}1 & 0\\\\0 & 1\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[1, 0],\n",
       "[0, 1]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}k_{x}^{2} + k_{y}^{2} + k_{z}^{2} & 0\\\\0 & k_{x}^{2} + k_{y}^{2} + k_{z}^{2}\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[k_x**2 + k_y**2 + k_z**2,                        0],\n",
       "[                       0, k_x**2 + k_y**2 + k_z**2]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "symmetries = [qsymm.ContinuousGroupGenerator(l, s) for l, s in zip(L, S)]\n",
    "# Add inversion\n",
    "symmetries.append(qsymm.PointGroupElement(-np.eye(3), False, False, np.eye(2)))\n",
    "dim = 3\n",
    "total_power = 2\n",
    "family = qsymm.continuum_hamiltonian(symmetries, dim, total_power, prettify=True)\n",
    "qsymm.display_family(family)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}1 & 0 & 0 & 0\\\\0 & 1 & 0 & 0\\\\0 & 0 & 1 & 0\\\\0 & 0 & 0 & 1\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[1, 0, 0, 0],\n",
       "[0, 1, 0, 0],\n",
       "[0, 0, 1, 0],\n",
       "[0, 0, 0, 1]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}\\sqrt{3} k_{z} & k_{x} - i k_{y} & 0 & 0\\\\k_{x} + i k_{y} & \\frac{\\sqrt{3} k_{z}}{3} & \\frac{2 \\sqrt{3} k_{x}}{3} - \\frac{2 \\sqrt{3} i k_{y}}{3} & 0\\\\0 & \\frac{2 \\sqrt{3} k_{x}}{3} + \\frac{2 \\sqrt{3} i k_{y}}{3} & - \\frac{\\sqrt{3} k_{z}}{3} & k_{x} - i k_{y}\\\\0 & 0 & k_{x} + i k_{y} & - \\sqrt{3} k_{z}\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[sqrt(3)*k_z,                         k_x - I*k_y,                                   0,            0],\n",
       "[k_x + I*k_y,                       sqrt(3)*k_z/3, 2*sqrt(3)*k_x/3 - 2*sqrt(3)*I*k_y/3,            0],\n",
       "[          0, 2*sqrt(3)*k_x/3 + 2*sqrt(3)*I*k_y/3,                      -sqrt(3)*k_z/3,  k_x - I*k_y],\n",
       "[          0,                                   0,                         k_x + I*k_y, -sqrt(3)*k_z]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}\\frac{k_{x}^{2}}{4} + \\frac{k_{y}^{2}}{4} + k_{z}^{2} & \\frac{\\sqrt{3} k_{x} k_{z}}{2} - \\frac{\\sqrt{3} i k_{y} k_{z}}{2} & \\frac{\\sqrt{3} k_{x}^{2}}{4} - \\frac{\\sqrt{3} i k_{x} k_{y}}{2} - \\frac{\\sqrt{3} k_{y}^{2}}{4} & 0\\\\\\frac{\\sqrt{3} k_{x} k_{z}}{2} + \\frac{\\sqrt{3} i k_{y} k_{z}}{2} & \\frac{3 k_{x}^{2}}{4} + \\frac{3 k_{y}^{2}}{4} & 0 & \\frac{\\sqrt{3} k_{x}^{2}}{4} - \\frac{\\sqrt{3} i k_{x} k_{y}}{2} - \\frac{\\sqrt{3} k_{y}^{2}}{4}\\\\\\frac{\\sqrt{3} k_{x}^{2}}{4} + \\frac{\\sqrt{3} i k_{x} k_{y}}{2} - \\frac{\\sqrt{3} k_{y}^{2}}{4} & 0 & \\frac{3 k_{x}^{2}}{4} + \\frac{3 k_{y}^{2}}{4} & - \\frac{\\sqrt{3} k_{x} k_{z}}{2} + \\frac{\\sqrt{3} i k_{y} k_{z}}{2}\\\\0 & \\frac{\\sqrt{3} k_{x}^{2}}{4} + \\frac{\\sqrt{3} i k_{x} k_{y}}{2} - \\frac{\\sqrt{3} k_{y}^{2}}{4} & - \\frac{\\sqrt{3} k_{x} k_{z}}{2} - \\frac{\\sqrt{3} i k_{y} k_{z}}{2} & \\frac{k_{x}^{2}}{4} + \\frac{k_{y}^{2}}{4} + k_{z}^{2}\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[                             k_x**2/4 + k_y**2/4 + k_z**2,                   sqrt(3)*k_x*k_z/2 - sqrt(3)*I*k_y*k_z/2, sqrt(3)*k_x**2/4 - sqrt(3)*I*k_x*k_y/2 - sqrt(3)*k_y**2/4,                                                         0],\n",
       "[                  sqrt(3)*k_x*k_z/2 + sqrt(3)*I*k_y*k_z/2,                                   3*k_x**2/4 + 3*k_y**2/4,                                                         0, sqrt(3)*k_x**2/4 - sqrt(3)*I*k_x*k_y/2 - sqrt(3)*k_y**2/4],\n",
       "[sqrt(3)*k_x**2/4 + sqrt(3)*I*k_x*k_y/2 - sqrt(3)*k_y**2/4,                                                         0,                                   3*k_x**2/4 + 3*k_y**2/4,                  -sqrt(3)*k_x*k_z/2 + sqrt(3)*I*k_y*k_z/2],\n",
       "[                                                        0, sqrt(3)*k_x**2/4 + sqrt(3)*I*k_x*k_y/2 - sqrt(3)*k_y**2/4,                  -sqrt(3)*k_x*k_z/2 - sqrt(3)*I*k_y*k_z/2,                              k_x**2/4 + k_y**2/4 + k_z**2]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}\\frac{3 k_{x}^{2}}{4} + \\frac{3 k_{y}^{2}}{4} & - \\frac{\\sqrt{3} k_{x} k_{z}}{2} + \\frac{\\sqrt{3} i k_{y} k_{z}}{2} & - \\frac{\\sqrt{3} k_{x}^{2}}{4} + \\frac{\\sqrt{3} i k_{x} k_{y}}{2} + \\frac{\\sqrt{3} k_{y}^{2}}{4} & 0\\\\- \\frac{\\sqrt{3} k_{x} k_{z}}{2} - \\frac{\\sqrt{3} i k_{y} k_{z}}{2} & \\frac{k_{x}^{2}}{4} + \\frac{k_{y}^{2}}{4} + k_{z}^{2} & 0 & - \\frac{\\sqrt{3} k_{x}^{2}}{4} + \\frac{\\sqrt{3} i k_{x} k_{y}}{2} + \\frac{\\sqrt{3} k_{y}^{2}}{4}\\\\- \\frac{\\sqrt{3} k_{x}^{2}}{4} - \\frac{\\sqrt{3} i k_{x} k_{y}}{2} + \\frac{\\sqrt{3} k_{y}^{2}}{4} & 0 & \\frac{k_{x}^{2}}{4} + \\frac{k_{y}^{2}}{4} + k_{z}^{2} & \\frac{\\sqrt{3} k_{x} k_{z}}{2} - \\frac{\\sqrt{3} i k_{y} k_{z}}{2}\\\\0 & - \\frac{\\sqrt{3} k_{x}^{2}}{4} - \\frac{\\sqrt{3} i k_{x} k_{y}}{2} + \\frac{\\sqrt{3} k_{y}^{2}}{4} & \\frac{\\sqrt{3} k_{x} k_{z}}{2} + \\frac{\\sqrt{3} i k_{y} k_{z}}{2} & \\frac{3 k_{x}^{2}}{4} + \\frac{3 k_{y}^{2}}{4}\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[                                   3*k_x**2/4 + 3*k_y**2/4,                   -sqrt(3)*k_x*k_z/2 + sqrt(3)*I*k_y*k_z/2, -sqrt(3)*k_x**2/4 + sqrt(3)*I*k_x*k_y/2 + sqrt(3)*k_y**2/4,                                                          0],\n",
       "[                  -sqrt(3)*k_x*k_z/2 - sqrt(3)*I*k_y*k_z/2,                               k_x**2/4 + k_y**2/4 + k_z**2,                                                          0, -sqrt(3)*k_x**2/4 + sqrt(3)*I*k_x*k_y/2 + sqrt(3)*k_y**2/4],\n",
       "[-sqrt(3)*k_x**2/4 - sqrt(3)*I*k_x*k_y/2 + sqrt(3)*k_y**2/4,                                                          0,                               k_x**2/4 + k_y**2/4 + k_z**2,                    sqrt(3)*k_x*k_z/2 - sqrt(3)*I*k_y*k_z/2],\n",
       "[                                                         0, -sqrt(3)*k_x**2/4 - sqrt(3)*I*k_x*k_y/2 + sqrt(3)*k_y**2/4,                    sqrt(3)*k_x*k_z/2 + sqrt(3)*I*k_y*k_z/2,                                    3*k_x**2/4 + 3*k_y**2/4]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "symmetries = [qsymm.ContinuousGroupGenerator(l, s) for l, s in zip(L, J)]\n",
    "dim = 3\n",
    "total_power = 2\n",
    "family = qsymm.continuum_hamiltonian(symmetries, dim, total_power, prettify=True)\n",
    "qsymm.display_family(family)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Double spin-1/2 representation\n",
    "spin = [np.kron(s, np.eye(2)) for s in qsymm.groups.spin_matrices(1/2)]\n",
    "# C3 rotational symmetry\n",
    "C3 = qsymm.rotation(1/3, axis=[0, 0, 1], spin=spin)\n",
    "\n",
    "# Time reversal\n",
    "TR = qsymm.time_reversal(3, spin=spin)\n",
    "\n",
    "# Mirror x\n",
    "Mx = qsymm.mirror([1, 0, 0], spin=spin)\n",
    "\n",
    "# Inversion\n",
    "IU = np.kron(np.eye(2), np.diag([1, -1]))\n",
    "I = qsymm.inversion(3, IU)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}1 & 0 & 0 & 0\\\\0 & 0 & 0 & 0\\\\0 & 0 & 1 & 0\\\\0 & 0 & 0 & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[1, 0, 0, 0],\n",
       "[0, 0, 0, 0],\n",
       "[0, 0, 1, 0],\n",
       "[0, 0, 0, 0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & 0 & 0 & 0\\\\0 & 1 & 0 & 0\\\\0 & 0 & 0 & 0\\\\0 & 0 & 0 & 1\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[0, 0, 0, 0],\n",
       "[0, 1, 0, 0],\n",
       "[0, 0, 0, 0],\n",
       "[0, 0, 0, 1]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & 0 & 0 & i k_{x} + k_{y}\\\\0 & 0 & i k_{x} + k_{y} & 0\\\\0 & - i k_{x} + k_{y} & 0 & 0\\\\- i k_{x} + k_{y} & 0 & 0 & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[           0,            0,           0, I*k_x + k_y],\n",
       "[           0,            0, I*k_x + k_y,           0],\n",
       "[           0, -I*k_x + k_y,           0,           0],\n",
       "[-I*k_x + k_y,            0,           0,           0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & i k_{z} & 0 & 0\\\\- i k_{z} & 0 & 0 & 0\\\\0 & 0 & 0 & i k_{z}\\\\0 & 0 & - i k_{z} & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[     0, I*k_z,      0,     0],\n",
       "[-I*k_z,     0,      0,     0],\n",
       "[     0,     0,      0, I*k_z],\n",
       "[     0,     0, -I*k_z,     0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}k_{z}^{2} & 0 & 0 & 0\\\\0 & 0 & 0 & 0\\\\0 & 0 & k_{z}^{2} & 0\\\\0 & 0 & 0 & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[k_z**2, 0,      0, 0],\n",
       "[     0, 0,      0, 0],\n",
       "[     0, 0, k_z**2, 0],\n",
       "[     0, 0,      0, 0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & 0 & 0 & 0\\\\0 & k_{z}^{2} & 0 & 0\\\\0 & 0 & 0 & 0\\\\0 & 0 & 0 & k_{z}^{2}\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[0,      0, 0,      0],\n",
       "[0, k_z**2, 0,      0],\n",
       "[0,      0, 0,      0],\n",
       "[0,      0, 0, k_z**2]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}k_{x}^{2} + k_{y}^{2} & 0 & 0 & 0\\\\0 & 0 & 0 & 0\\\\0 & 0 & k_{x}^{2} + k_{y}^{2} & 0\\\\0 & 0 & 0 & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[k_x**2 + k_y**2, 0,               0, 0],\n",
       "[              0, 0,               0, 0],\n",
       "[              0, 0, k_x**2 + k_y**2, 0],\n",
       "[              0, 0,               0, 0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & 0 & 0 & 0\\\\0 & k_{x}^{2} + k_{y}^{2} & 0 & 0\\\\0 & 0 & 0 & 0\\\\0 & 0 & 0 & k_{x}^{2} + k_{y}^{2}\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[0,               0, 0,               0],\n",
       "[0, k_x**2 + k_y**2, 0,               0],\n",
       "[0,               0, 0,               0],\n",
       "[0,               0, 0, k_x**2 + k_y**2]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "dim = 3\n",
    "total_power = 2\n",
    "family = qsymm.continuum_hamiltonian([C3, TR, Mx, I], dim, total_power, prettify=True)\n",
    "qsymm.display_family(family)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}1 & 0 & 0 & 0\\\\0 & -1 & 0 & 0\\\\0 & 0 & 1 & 0\\\\0 & 0 & 0 & -1\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[1,  0, 0,  0],\n",
       "[0, -1, 0,  0],\n",
       "[0,  0, 1,  0],\n",
       "[0,  0, 0, -1]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & 0 & 0 & i k_{x} + k_{y}\\\\0 & 0 & i k_{x} + k_{y} & 0\\\\0 & - i k_{x} + k_{y} & 0 & 0\\\\- i k_{x} + k_{y} & 0 & 0 & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[           0,            0,           0, I*k_x + k_y],\n",
       "[           0,            0, I*k_x + k_y,           0],\n",
       "[           0, -I*k_x + k_y,           0,           0],\n",
       "[-I*k_x + k_y,            0,           0,           0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}k_{z}^{2} & 0 & 0 & 0\\\\0 & - k_{z}^{2} & 0 & 0\\\\0 & 0 & k_{z}^{2} & 0\\\\0 & 0 & 0 & - k_{z}^{2}\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[k_z**2,       0,      0,       0],\n",
       "[     0, -k_z**2,      0,       0],\n",
       "[     0,       0, k_z**2,       0],\n",
       "[     0,       0,      0, -k_z**2]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}k_{x}^{2} + k_{y}^{2} & 0 & 0 & 0\\\\0 & - k_{x}^{2} - k_{y}^{2} & 0 & 0\\\\0 & 0 & k_{x}^{2} + k_{y}^{2} & 0\\\\0 & 0 & 0 & - k_{x}^{2} - k_{y}^{2}\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[k_x**2 + k_y**2,                0,               0,                0],\n",
       "[              0, -k_x**2 - k_y**2,               0,                0],\n",
       "[              0,                0, k_x**2 + k_y**2,                0],\n",
       "[              0,                0,               0, -k_x**2 - k_y**2]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & i k_{z} & 0 & 0\\\\- i k_{z} & 0 & 0 & 0\\\\0 & 0 & 0 & i k_{z}\\\\0 & 0 & - i k_{z} & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[     0, I*k_z,      0,     0],\n",
       "[-I*k_z,     0,      0,     0],\n",
       "[     0,     0,      0, I*k_z],\n",
       "[     0,     0, -I*k_z,     0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "identity_terms = qsymm.continuum_hamiltonian([qsymm.groups.identity(dim, 1)], dim, total_power)\n",
    "identity_terms = [\n",
    "    qsymm.Model({\n",
    "        key: np.kron(val, np.eye(4))\n",
    "        for key, val in term.items()\n",
    "    })\n",
    "    for term in identity_terms\n",
    "]\n",
    "\n",
    "family = qsymm.hamiltonian_generator.subtract_family(family, identity_terms, prettify=True)\n",
    "qsymm.display_family(family)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "dim = 3\n",
    "total_power = 2\n",
    "no_c3_family = qsymm.continuum_hamiltonian([TR, Mx, I], dim, total_power, prettify=True)\n",
    "no_c3_family = qsymm.hamiltonian_generator.subtract_family(no_c3_family, identity_terms, prettify=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & k_{x} & 0 & 0\\\\k_{x} & 0 & 0 & 0\\\\0 & 0 & 0 & - k_{x}\\\\0 & 0 & - k_{x} & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[  0, k_x,    0,    0],\n",
       "[k_x,   0,    0,    0],\n",
       "[  0,   0,    0, -k_x],\n",
       "[  0,   0, -k_x,    0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & 0 & 0 & i k_{x} - k_{y}\\\\0 & 0 & i k_{x} - k_{y} & 0\\\\0 & - i k_{x} - k_{y} & 0 & 0\\\\- i k_{x} - k_{y} & 0 & 0 & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[           0,            0,           0, I*k_x - k_y],\n",
       "[           0,            0, I*k_x - k_y,           0],\n",
       "[           0, -I*k_x - k_y,           0,           0],\n",
       "[-I*k_x - k_y,            0,           0,           0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}k_{y} k_{z} & 0 & 0 & 0\\\\0 & - k_{y} k_{z} & 0 & 0\\\\0 & 0 & k_{y} k_{z} & 0\\\\0 & 0 & 0 & - k_{y} k_{z}\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[k_y*k_z,        0,       0,        0],\n",
       "[      0, -k_y*k_z,       0,        0],\n",
       "[      0,        0, k_y*k_z,        0],\n",
       "[      0,        0,       0, -k_y*k_z]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}- k_{x}^{2} + k_{y}^{2} & 0 & 0 & 0\\\\0 & k_{x}^{2} - k_{y}^{2} & 0 & 0\\\\0 & 0 & - k_{x}^{2} + k_{y}^{2} & 0\\\\0 & 0 & 0 & k_{x}^{2} - k_{y}^{2}\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[-k_x**2 + k_y**2,               0,                0,               0],\n",
       "[               0, k_x**2 - k_y**2,                0,               0],\n",
       "[               0,               0, -k_x**2 + k_y**2,               0],\n",
       "[               0,               0,                0, k_x**2 - k_y**2]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & 0 & 0 & k_{z}\\\\0 & 0 & k_{z} & 0\\\\0 & k_{z} & 0 & 0\\\\k_{z} & 0 & 0 & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[  0,   0,   0, k_z],\n",
       "[  0,   0, k_z,   0],\n",
       "[  0, k_z,   0,   0],\n",
       "[k_z,   0,   0,   0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & i k_{y} & 0 & 0\\\\- i k_{y} & 0 & 0 & 0\\\\0 & 0 & 0 & i k_{y}\\\\0 & 0 & - i k_{y} & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[     0, I*k_y,      0,     0],\n",
       "[-I*k_y,     0,      0,     0],\n",
       "[     0,     0,      0, I*k_y],\n",
       "[     0,     0, -I*k_y,     0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "new_terms = qsymm.hamiltonian_generator.subtract_family(no_c3_family, family, prettify=True)\n",
    "qsymm.display_family(new_terms)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & 1 & 0 & 0\\\\1 & 0 & 0 & 0\\\\0 & 0 & 0 & 1\\\\0 & 0 & 1 & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[0, 1, 0, 0],\n",
       "[1, 0, 0, 0],\n",
       "[0, 0, 0, 1],\n",
       "[0, 0, 1, 0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & 0 & 0 & i\\\\0 & 0 & - i & 0\\\\0 & i & 0 & 0\\\\- i & 0 & 0 & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[ 0, 0,  0, I],\n",
       "[ 0, 0, -I, 0],\n",
       "[ 0, I,  0, 0],\n",
       "[-I, 0,  0, 0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}k_{x} & 0 & 0 & 0\\\\0 & 0 & 0 & 0\\\\0 & 0 & - k_{x} & 0\\\\0 & 0 & 0 & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[k_x, 0,    0, 0],\n",
       "[  0, 0,    0, 0],\n",
       "[  0, 0, -k_x, 0],\n",
       "[  0, 0,    0, 0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & 0 & 0 & 0\\\\0 & k_{x} & 0 & 0\\\\0 & 0 & 0 & 0\\\\0 & 0 & 0 & - k_{x}\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[0,   0, 0,    0],\n",
       "[0, k_x, 0,    0],\n",
       "[0,   0, 0,    0],\n",
       "[0,   0, 0, -k_x]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & 0 & i k_{x} & 0\\\\0 & 0 & 0 & 0\\\\- i k_{x} & 0 & 0 & 0\\\\0 & 0 & 0 & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[     0, 0, I*k_x, 0],\n",
       "[     0, 0,     0, 0],\n",
       "[-I*k_x, 0,     0, 0],\n",
       "[     0, 0,     0, 0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & 0 & 0 & 0\\\\0 & 0 & 0 & i k_{x}\\\\0 & 0 & 0 & 0\\\\0 & - i k_{x} & 0 & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[0,      0, 0,     0],\n",
       "[0,      0, 0, I*k_x],\n",
       "[0,      0, 0,     0],\n",
       "[0, -I*k_x, 0,     0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & k_{z}^{2} & 0 & 0\\\\k_{z}^{2} & 0 & 0 & 0\\\\0 & 0 & 0 & k_{z}^{2}\\\\0 & 0 & k_{z}^{2} & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[     0, k_z**2,      0,      0],\n",
       "[k_z**2,      0,      0,      0],\n",
       "[     0,      0,      0, k_z**2],\n",
       "[     0,      0, k_z**2,      0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & 0 & 0 & i k_{z}^{2}\\\\0 & 0 & - i k_{z}^{2} & 0\\\\0 & i k_{z}^{2} & 0 & 0\\\\- i k_{z}^{2} & 0 & 0 & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[        0,        0,         0, I*k_z**2],\n",
       "[        0,        0, -I*k_z**2,        0],\n",
       "[        0, I*k_z**2,         0,        0],\n",
       "[-I*k_z**2,        0,         0,        0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & k_{y} k_{z} & 0 & 0\\\\k_{y} k_{z} & 0 & 0 & 0\\\\0 & 0 & 0 & k_{y} k_{z}\\\\0 & 0 & k_{y} k_{z} & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[      0, k_y*k_z,       0,       0],\n",
       "[k_y*k_z,       0,       0,       0],\n",
       "[      0,       0,       0, k_y*k_z],\n",
       "[      0,       0, k_y*k_z,       0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & 0 & 0 & i k_{y} k_{z}\\\\0 & 0 & - i k_{y} k_{z} & 0\\\\0 & i k_{y} k_{z} & 0 & 0\\\\- i k_{y} k_{z} & 0 & 0 & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[         0,         0,          0, I*k_y*k_z],\n",
       "[         0,         0, -I*k_y*k_z,         0],\n",
       "[         0, I*k_y*k_z,          0,         0],\n",
       "[-I*k_y*k_z,         0,          0,         0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & 0 & 0 & k_{x} k_{y}\\\\0 & 0 & - k_{x} k_{y} & 0\\\\0 & - k_{x} k_{y} & 0 & 0\\\\k_{x} k_{y} & 0 & 0 & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[      0,        0,        0, k_x*k_y],\n",
       "[      0,        0, -k_x*k_y,       0],\n",
       "[      0, -k_x*k_y,        0,       0],\n",
       "[k_x*k_y,        0,        0,       0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & i k_{x} k_{y} & 0 & 0\\\\- i k_{x} k_{y} & 0 & 0 & 0\\\\0 & 0 & 0 & - i k_{x} k_{y}\\\\0 & 0 & i k_{x} k_{y} & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[         0, I*k_x*k_y,         0,          0],\n",
       "[-I*k_x*k_y,         0,         0,          0],\n",
       "[         0,         0,         0, -I*k_x*k_y],\n",
       "[         0,         0, I*k_x*k_y,          0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & k_{y}^{2} & 0 & 0\\\\k_{y}^{2} & 0 & 0 & 0\\\\0 & 0 & 0 & k_{y}^{2}\\\\0 & 0 & k_{y}^{2} & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[     0, k_y**2,      0,      0],\n",
       "[k_y**2,      0,      0,      0],\n",
       "[     0,      0,      0, k_y**2],\n",
       "[     0,      0, k_y**2,      0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & 0 & 0 & i k_{y}^{2}\\\\0 & 0 & - i k_{y}^{2} & 0\\\\0 & i k_{y}^{2} & 0 & 0\\\\- i k_{y}^{2} & 0 & 0 & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[        0,        0,         0, I*k_y**2],\n",
       "[        0,        0, -I*k_y**2,        0],\n",
       "[        0, I*k_y**2,         0,        0],\n",
       "[-I*k_y**2,        0,         0,        0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & 0 & 0 & k_{x} k_{z}\\\\0 & 0 & - k_{x} k_{z} & 0\\\\0 & - k_{x} k_{z} & 0 & 0\\\\k_{x} k_{z} & 0 & 0 & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[      0,        0,        0, k_x*k_z],\n",
       "[      0,        0, -k_x*k_z,       0],\n",
       "[      0, -k_x*k_z,        0,       0],\n",
       "[k_x*k_z,        0,        0,       0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & i k_{x} k_{z} & 0 & 0\\\\- i k_{x} k_{z} & 0 & 0 & 0\\\\0 & 0 & 0 & - i k_{x} k_{z}\\\\0 & 0 & i k_{x} k_{z} & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[         0, I*k_x*k_z,         0,          0],\n",
       "[-I*k_x*k_z,         0,         0,          0],\n",
       "[         0,         0,         0, -I*k_x*k_z],\n",
       "[         0,         0, I*k_x*k_z,          0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & 0 & k_{z} & 0\\\\0 & 0 & 0 & 0\\\\k_{z} & 0 & 0 & 0\\\\0 & 0 & 0 & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[  0, 0, k_z, 0],\n",
       "[  0, 0,   0, 0],\n",
       "[k_z, 0,   0, 0],\n",
       "[  0, 0,   0, 0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & 0 & 0 & 0\\\\0 & 0 & 0 & k_{z}\\\\0 & 0 & 0 & 0\\\\0 & k_{z} & 0 & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[0,   0, 0,   0],\n",
       "[0,   0, 0, k_z],\n",
       "[0,   0, 0,   0],\n",
       "[0, k_z, 0,   0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & k_{x}^{2} & 0 & 0\\\\k_{x}^{2} & 0 & 0 & 0\\\\0 & 0 & 0 & k_{x}^{2}\\\\0 & 0 & k_{x}^{2} & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[     0, k_x**2,      0,      0],\n",
       "[k_x**2,      0,      0,      0],\n",
       "[     0,      0,      0, k_x**2],\n",
       "[     0,      0, k_x**2,      0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & 0 & 0 & i k_{x}^{2}\\\\0 & 0 & - i k_{x}^{2} & 0\\\\0 & i k_{x}^{2} & 0 & 0\\\\- i k_{x}^{2} & 0 & 0 & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[        0,        0,         0, I*k_x**2],\n",
       "[        0,        0, -I*k_x**2,        0],\n",
       "[        0, I*k_x**2,         0,        0],\n",
       "[-I*k_x**2,        0,         0,        0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & 0 & k_{y} & 0\\\\0 & 0 & 0 & 0\\\\k_{y} & 0 & 0 & 0\\\\0 & 0 & 0 & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[  0, 0, k_y, 0],\n",
       "[  0, 0,   0, 0],\n",
       "[k_y, 0,   0, 0],\n",
       "[  0, 0,   0, 0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/latex": [
       "$\\displaystyle \\left[\\begin{matrix}0 & 0 & 0 & 0\\\\0 & 0 & 0 & k_{y}\\\\0 & 0 & 0 & 0\\\\0 & k_{y} & 0 & 0\\end{matrix}\\right]$"
      ],
      "text/plain": [
       "Matrix([\n",
       "[0,   0, 0,   0],\n",
       "[0,   0, 0, k_y],\n",
       "[0,   0, 0,   0],\n",
       "[0, k_y, 0,   0]])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "dim = 3\n",
    "total_power = 2\n",
    "broken_family = qsymm.continuum_hamiltonian([TR, Mx], dim, total_power, prettify=True)\n",
    "broken_family = qsymm.hamiltonian_generator.subtract_family(broken_family, identity_terms, prettify=True)\n",
    "new_terms = qsymm.hamiltonian_generator.subtract_family(broken_family, no_c3_family, prettify=True)\n",
    "qsymm.display_family(new_terms)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "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.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}