{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ ], "source": [ "%display latex" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ ], "source": [ "theta, phi, psi = var('theta, phi, psi')" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ ], "source": [ "R_z = matrix([[cos(x),-sin(x),0],[sin(x),cos(x),0],[0,0,1]])" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ ], "source": [ "R_y = matrix([[cos(x),0,sin(x)],[0,1,0],[-sin(x),0,cos(x)]])" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "" ] }, "execution_count": 5, "metadata": { }, "output_type": "execute_result" } ], "source": [ "R1 = R_z(x=phi); R1" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "" ] }, "execution_count": 6, "metadata": { }, "output_type": "execute_result" } ], "source": [ "R2 = R_y(x=theta); R2" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "" ] }, "execution_count": 7, "metadata": { }, "output_type": "execute_result" } ], "source": [ "R3 = R_z(x=psi); R3" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "" ] }, "execution_count": 8, "metadata": { }, "output_type": "execute_result" } ], "source": [ "Lambda = R1*R2*R3; Lambda" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "" ] }, "execution_count": 9, "metadata": { }, "output_type": "execute_result" } ], "source": [ "Lambda_inverse = R3(psi=-psi)*R2(theta=-theta)*R1(phi=-phi); Lambda_inverse.simplify_trig()" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "" ] }, "execution_count": 10, "metadata": { }, "output_type": "execute_result" } ], "source": [ "(Lambda*Lambda_inverse).simplify_trig()" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "" ] }, "execution_count": 11, "metadata": { }, "output_type": "execute_result" } ], "source": [ "e = [\n", " matrix([[1,0,0],[0,-1,0],[0,0,0]]),\n", " matrix([[0,1,0],[1,0,0],[0,0,0]]),\n", " matrix([[1,0,0],[0,1,0],[0,0,0]]),\n", " matrix([[0,0,0],[0,0,0],[0,0,sqrt(2)]]),\n", " matrix([[0,0,1],[0,0,0],[1,0,0]]),\n", " matrix([[0,0,0],[0,0,1],[0,1,0]])\n", "]; e" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "" ] }, "execution_count": 12, "metadata": { }, "output_type": "execute_result" }, { "data": { "text/html": [ "" ] }, "execution_count": 12, "metadata": { }, "output_type": "execute_result" }, { "data": { "text/html": [ "" ] }, "execution_count": 12, "metadata": { }, "output_type": "execute_result" }, { "data": { "text/html": [ "" ] }, "execution_count": 12, "metadata": { }, "output_type": "execute_result" }, { "data": { "text/html": [ "" ] }, "execution_count": 12, "metadata": { }, "output_type": "execute_result" }, { "data": { "text/html": [ "" ] }, "execution_count": 12, "metadata": { }, "output_type": "execute_result" } ], "source": [ "e_bar = []\n", "for i in range(6):\n", " e_bar.append(Lambda*e[i]*Lambda_inverse)\n", " show(e_bar[i].simplify_trig())" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "" ] }, "execution_count": 13, "metadata": { }, "output_type": "execute_result" } ], "source": [ "a = matrix(SR, 6,6)\n", "for i in range(6):\n", " for j in range(6):\n", " a[i,j] = sum(sum(e[i].elementwise_product(Lambda*e[j]*Lambda.transpose()/2))).simplify_trig()\n", "a" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "collapsed": false }, "outputs": [ ], "source": [ "T = Spherical('radius', ['inclination', 'azimuth'])" ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "collapsed": false }, "outputs": [ ], "source": [ "r = var('r')" ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "" ] }, "execution_count": 16, "metadata": { }, "output_type": "execute_result" } ], "source": [ "T.transform(radius=r, azimuth=phi, inclination=theta)" ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "collapsed": false }, "outputs": [ ], "source": [ "# cm = colormaps.hsv\n", "# def c(x,y):\n", "# return float((x+y+x*y)/15) % 1\n", "# pol = ['+', 'cross', 'b', 'l', 'x', 'y']\n", "# for j,k in [(0,0),(1,1),(2,2),(0,1),(1,2),(2,0)]:\n", "# for i in range(2):\n", "# print('polarization: '+pol[i]+', ('+str(j+1)+','+str(k+1)+') component')\n", "# show(plot3d(e_bar[i][j][k], (theta, 0, pi), (phi, 0, 2*pi), transformation=T, color=(c,cm)))" ] }, { "cell_type": "code", "execution_count": 0, "metadata": { "collapsed": false }, "outputs": [ ], "source": [ ] } ], "metadata": { "kernelspec": { "display_name": "SageMath 8.2", "language": "sagemath", "metadata": { "cocalc": { "description": "Open-source mathematical software system", "priority": 1, "url": "https://www.sagemath.org/" } }, "name": "sage-8.2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.14" } }, "nbformat": 4, "nbformat_minor": 4 }