|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": null, |
| 6 | + "id": "158426a6-f7f2-40b4-96fc-087a3035af30", |
| 7 | + "metadata": {}, |
| 8 | + "outputs": [], |
| 9 | + "source": [ |
| 10 | + "from sympy import *\n", |
| 11 | + "\n", |
| 12 | + "init_printing(use_unicode=False, use_latex=False)" |
| 13 | + ] |
| 14 | + }, |
| 15 | + { |
| 16 | + "cell_type": "code", |
| 17 | + "execution_count": null, |
| 18 | + "id": "e15cb269-f88e-4055-b714-bf8b48269d79", |
| 19 | + "metadata": {}, |
| 20 | + "outputs": [], |
| 21 | + "source": [ |
| 22 | + "# Create the Pauli matrices\n", |
| 23 | + "\n", |
| 24 | + "sigma_x = Matrix([[0, 1], [1, 0]])\n", |
| 25 | + "sigma_y = Matrix([[0, -I], [I, 0]])\n", |
| 26 | + "sigma_z = Matrix([[1, 0], [0, -1]])\n", |
| 27 | + "\n", |
| 28 | + "assert sigma_x**2 == eye(2)\n", |
| 29 | + "assert sigma_y**2 == eye(2)\n", |
| 30 | + "assert sigma_z**2 == eye(2)" |
| 31 | + ] |
| 32 | + }, |
| 33 | + { |
| 34 | + "cell_type": "markdown", |
| 35 | + "id": "606b36c4-83b6-4188-a5fe-76555d258a3c", |
| 36 | + "metadata": {}, |
| 37 | + "source": [ |
| 38 | + "## Spin configurations\n", |
| 39 | + "\n", |
| 40 | + "Here we'll show different spin-configurations, and do various operations. First we'll define some generic operators that we'll apply.\n", |
| 41 | + "Then comes the different spin sections." |
| 42 | + ] |
| 43 | + }, |
| 44 | + { |
| 45 | + "cell_type": "code", |
| 46 | + "execution_count": null, |
| 47 | + "id": "ac6a0b74-47e9-49b4-bafa-44b82753a652", |
| 48 | + "metadata": {}, |
| 49 | + "outputs": [], |
| 50 | + "source": [ |
| 51 | + "def equal(M1, M2):\n", |
| 52 | + " return Eq(M1, M2).doit()\n", |
| 53 | + "\n", |
| 54 | + "\n", |
| 55 | + "def trs(H):\n", |
| 56 | + " return sympify(sigma_y * H.conjugate() * sigma_y)\n", |
| 57 | + "\n", |
| 58 | + "\n", |
| 59 | + "def make_trs(H):\n", |
| 60 | + " H_trs = sympify(H + trs(H))\n", |
| 61 | + " return MatMul(H_trs, \"1/2\", evaluate=False)\n", |
| 62 | + "\n", |
| 63 | + "\n", |
| 64 | + "def do_trs(H):\n", |
| 65 | + " H_trs = make_trs(H)\n", |
| 66 | + " assert equal(H_trs, trs(H_trs))\n", |
| 67 | + " return trs(H)" |
| 68 | + ] |
| 69 | + }, |
| 70 | + { |
| 71 | + "cell_type": "markdown", |
| 72 | + "id": "89f80956-a8d3-4b6c-9340-334c76d092a7", |
| 73 | + "metadata": {}, |
| 74 | + "source": [ |
| 75 | + "### Non-collinear" |
| 76 | + ] |
| 77 | + }, |
| 78 | + { |
| 79 | + "cell_type": "code", |
| 80 | + "execution_count": null, |
| 81 | + "id": "e3b2d4e9-f8e4-4c50-b409-057926887d5b", |
| 82 | + "metadata": {}, |
| 83 | + "outputs": [], |
| 84 | + "source": [ |
| 85 | + "uu, dd, ud = symbols(\"m0 m1 m2\")\n", |
| 86 | + "H_nc = Matrix([[uu, ud], [ud.conjugate(), dd]])\n", |
| 87 | + "do_trs(H_nc)" |
| 88 | + ] |
| 89 | + }, |
| 90 | + { |
| 91 | + "cell_type": "markdown", |
| 92 | + "id": "82080cf9-bf53-4b4d-af96-7ae53c0b3079", |
| 93 | + "metadata": {}, |
| 94 | + "source": [ |
| 95 | + "### Spin-orbit" |
| 96 | + ] |
| 97 | + }, |
| 98 | + { |
| 99 | + "cell_type": "code", |
| 100 | + "execution_count": null, |
| 101 | + "id": "8bcf161a-0be1-493f-b6d5-806a0a00360f", |
| 102 | + "metadata": {}, |
| 103 | + "outputs": [], |
| 104 | + "source": [ |
| 105 | + "uu, dd, ud, du = symbols(\"m0 m1 m2 m3\")\n", |
| 106 | + "H_soc = Matrix([[uu, ud], [du, dd]])\n", |
| 107 | + "do_trs(H_soc)" |
| 108 | + ] |
| 109 | + }, |
| 110 | + { |
| 111 | + "cell_type": "markdown", |
| 112 | + "id": "e762a0d9-98f8-4c35-b2d3-8fd7053b74bc", |
| 113 | + "metadata": {}, |
| 114 | + "source": [ |
| 115 | + "### Nambu (Delta matrix)" |
| 116 | + ] |
| 117 | + }, |
| 118 | + { |
| 119 | + "cell_type": "code", |
| 120 | + "execution_count": null, |
| 121 | + "id": "d12089c2-7b11-41bc-92f1-b8cbbc4137b9", |
| 122 | + "metadata": {}, |
| 123 | + "outputs": [], |
| 124 | + "source": [ |
| 125 | + "S, T0, Tu, Td = symbols(\"S T0 Tu Td\")\n", |
| 126 | + "Delta = Matrix([[Tu, S + T0], [-S + T0, Td]])\n", |
| 127 | + "do_trs(Delta)" |
| 128 | + ] |
| 129 | + }, |
| 130 | + { |
| 131 | + "cell_type": "code", |
| 132 | + "execution_count": null, |
| 133 | + "id": "fc6fb8bf-44b6-4a7f-ab8d-f76e0cfe4f21", |
| 134 | + "metadata": {}, |
| 135 | + "outputs": [], |
| 136 | + "source": [] |
| 137 | + } |
| 138 | + ], |
| 139 | + "metadata": { |
| 140 | + "kernelspec": { |
| 141 | + "display_name": "Python 3 (ipykernel)", |
| 142 | + "language": "python", |
| 143 | + "name": "python3" |
| 144 | + }, |
| 145 | + "language_info": { |
| 146 | + "codemirror_mode": { |
| 147 | + "name": "ipython", |
| 148 | + "version": 3 |
| 149 | + }, |
| 150 | + "file_extension": ".py", |
| 151 | + "mimetype": "text/x-python", |
| 152 | + "name": "python", |
| 153 | + "nbconvert_exporter": "python", |
| 154 | + "pygments_lexer": "ipython3", |
| 155 | + "version": "3.11.7" |
| 156 | + } |
| 157 | + }, |
| 158 | + "nbformat": 4, |
| 159 | + "nbformat_minor": 5 |
| 160 | +} |
0 commit comments