{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "from IPython.display import Math, display\n",
    "import numpy as np\n",
    "import sympy as sp\n",
    "from scipy import constants as const\n",
    "from scipy.optimize import minimize_scalar\n",
    "from scipy import sparse\n",
    "\n",
    "#add relative path to backend\n",
    "import sys\n",
    "sys.path.append('../../clean_diag/backend')\n",
    "\n",
    "import trap_units as si\n",
    "from twod_trap import DoubleTweezer, TwoSiteLattice\n",
    "from boson_helpers import *"
   ]
  },
  {
   "attachments": {
    "image.png": {
     "image/png": "[encoded data, 30148 characters]"
    }
   },
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Paper:\n",
    "\n",
    "AR=1: J = 27 Hz, U_s = 3749 Hz\n",
    "\n",
    "\n",
    "AR=2: J = 27 Hz, U_s = 1775 Hz\n",
    "\n",
    "![image.png](attachment:image.png)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "ename": "ValueError",
     "evalue": "too many values to unpack (expected 4)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mValueError\u001b[0m                                Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[3], line 6\u001b[0m\n\u001b[0;32m      1\u001b[0m line_number_1 \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m18\u001b[39m\n\u001b[0;32m      2\u001b[0m line_number_2 \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m20\u001b[39m\n\u001b[1;32m----> 6\u001b[0m J, U_s, U_dds_1, angles_1 \u001b[38;5;241m=\u001b[39m analyse_diagonalisation(line_number_1)\n\u001b[0;32m      7\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mAR=1:\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m      8\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mJ = \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mJ\u001b[38;5;241m/\u001b[39mconst\u001b[38;5;241m.\u001b[39mh\u001b[38;5;250m \u001b[39m\u001b[38;5;132;01m:\u001b[39;00m\u001b[38;5;124m3f\u001b[39m\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m Hz\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
      "\u001b[1;31mValueError\u001b[0m: too many values to unpack (expected 4)"
     ]
    }
   ],
   "source": [
    "line_number_1 = 18\n",
    "line_number_2 = 20\n",
    "\n",
    "\n",
    "\n",
    "J, U_s, U_dds_1, angles_1 = analyse_diagonalisation(line_number_1)\n",
    "print(\"AR=1:\")\n",
    "print(f\"J = {J/const.h :3f} Hz\")\n",
    "print(f\"U_s = {U_s/const.h :.3f} Hz\")\n",
    "plt.plot(np.rad2deg(angles_1), U_dds_1/const.h, color='red',label=\"AR=1\")\n",
    "\n",
    "print(\"\\n\")\n",
    "\n",
    "J, U_s, U_dds_2, angles_2 = analyse_diagonalisation(line_number_2)\n",
    "print(\"AR=2:\")\n",
    "print(f\"J = {J/const.h :3f} Hz\")\n",
    "print(f\"U_s = {U_s/const.h :.3f} Hz\")\n",
    "plt.plot(np.rad2deg(angles_2), U_dds_2/const.h, color='green',label=\"AR=2\")\n",
    "\n",
    "\n",
    "plt.axhline(0,color=\"black\",ls=\"--\")\n",
    "plt.xlabel(\"theta [deg]\")\n",
    "plt.ylabel(r\"$U_{dd} / h$ [Hz]\")\n",
    "plt.legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Check parameters:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 137.0$"
      ],
      "text/plain": [
       "137.000000000000"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "trap.subs(trap.a_s/const.value(\"Bohr radius\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 168.0$"
      ],
      "text/plain": [
       "168.000000000000"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "trap.subs(trap.m)/const.u"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle 6.982806$"
      ],
      "text/plain": [
       "6.98280600000000"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "trap.subs(trap.mu_b/const.value(\"Bohr magneton\"))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Why are higher modes not excited?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-61.588334691519904"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.diff(res[\"energies\"])[0]/const.h"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "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.12.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
