tprak

Theoretical Physics Practical Training
git clone git://popovic.xyz/tprak.git
Log | Files | Refs

Untitled.ipynb (2679B)


      1 {
      2  "cells": [
      3   {
      4    "cell_type": "code",
      5    "execution_count": 5,
      6    "id": "42d6aead",
      7    "metadata": {},
      8    "outputs": [],
      9    "source": [
     10     "from sympy import *\n",
     11     "from sympy.physics.quantum import TensorProduct\n"
     12    ]
     13   },
     14   {
     15    "cell_type": "code",
     16    "execution_count": 22,
     17    "id": "d23a5751",
     18    "metadata": {},
     19    "outputs": [],
     20    "source": [
     21     "_1 = Matrix([1, 0])\n",
     22     "_0 = Matrix([0, 1])\n",
     23     "_11 = TensorProduct(_1,_1)\n",
     24     "_00 =  TensorProduct(_0,_0)\n",
     25     "_10 = TensorProduct(_1,_0)\n",
     26     "_01 = TensorProduct(_0,_1)\n",
     27     "\n",
     28     "e1 = 1/sqrt(2)* (_01 - _10)\n",
     29     "e2 = 1/sqrt(2)* (_01 + _10)\n",
     30     "e3 = 1/sqrt(2)* (_00 - _11)\n",
     31     "e4 = 1/sqrt(2)* (_00 + _11)\n",
     32     "\n",
     33     "U_1 = Matrix([[1, 0 ], [0, 1]])\n",
     34     "U_2 = Matrix([[1, 0 ], [0, -1]])\n",
     35     "U_3 = Matrix([[0, 1 ], [1, 0]])\n",
     36     "U_4 = Matrix([[0, -1 ], [1, 0]])\n",
     37     "\n",
     38     "a = Symbol('a'); b = Symbol('b')\n",
     39     "phi_G = a*_0 + b*_1\n",
     40     "\n",
     41     "s3 = TensorProduct(phi_G, e1) @ TensorProduct(phi_G, e1).T"
     42    ]
     43   },
     44   {
     45    "cell_type": "code",
     46    "execution_count": 31,
     47    "id": "49577b06",
     48    "metadata": {},
     49    "outputs": [
     50     {
     51      "ename": "NameError",
     52      "evalue": "name 'axis' is not defined",
     53      "output_type": "error",
     54      "traceback": [
     55       "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
     56       "\u001b[0;31mNameError\u001b[0m                                 Traceback (most recent call last)",
     57       "\u001b[0;32m<ipython-input-31-ed8c20e20c84>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mtrace\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ms3\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
     58       "\u001b[0;31mNameError\u001b[0m: name 'axis' is not defined"
     59      ]
     60     }
     61    ],
     62    "source": [
     63     "trace(s3, axis)"
     64    ]
     65   },
     66   {
     67    "cell_type": "code",
     68    "execution_count": null,
     69    "id": "89a5225b",
     70    "metadata": {},
     71    "outputs": [],
     72    "source": []
     73   },
     74   {
     75    "cell_type": "code",
     76    "execution_count": null,
     77    "id": "0a84f58c",
     78    "metadata": {},
     79    "outputs": [],
     80    "source": []
     81   }
     82  ],
     83  "metadata": {
     84   "kernelspec": {
     85    "display_name": "Python 3",
     86    "language": "python",
     87    "name": "python3"
     88   },
     89   "language_info": {
     90    "codemirror_mode": {
     91     "name": "ipython",
     92     "version": 3
     93    },
     94    "file_extension": ".py",
     95    "mimetype": "text/x-python",
     96    "name": "python",
     97    "nbconvert_exporter": "python",
     98    "pygments_lexer": "ipython3",
     99    "version": "3.9.6"
    100   }
    101  },
    102  "nbformat": 4,
    103  "nbformat_minor": 5
    104 }