{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 81,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sympy.functions.special.error_functions import erf\n",
    "from fewfermions.simulate.numerics import discrete_hamiltonian\n",
    "from scipy import sparse"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "metadata": {},
   "outputs": [],
   "source": [
    "from helpers_merging import *\n",
    "\n",
    "initial_power = 100* si.uW\n",
    "initial_waist = 1.1*si.uW\n",
    "initial_distance = 4*si.um\n",
    "\n",
    "trap: DoubleTweezer = DoubleTweezer(\n",
    "    power=0,  # Set pancake laser power to 0, no 2D trap\n",
    "    grad_z= 0*si.G/si.cm,\n",
    "    grad_r=0,\n",
    "    power_tweezer1 = initial_power,\n",
    "    power_tweezer2 = initial_power,\n",
    "    waist_tweezer1 = initial_waist,\n",
    "    waist_tweezer2 = initial_waist,\n",
    "    distance_tweezers = initial_distance,\n",
    "\n",
    "    a=180*(4 * np.pi * const.epsilon_0 * const.value(\"Bohr radius\")**3)/(2 * const.epsilon_0 * const.c),\n",
    "    wvl = 532 * si.nm,\n",
    "\n",
    "    g = 0,\n",
    ")\n",
    "\n",
    "left_cutoff = -0.5*initial_distance-3*float(trap.subs(trap.waist_tweezer1))\n",
    "right_cutoff = 0.5*initial_distance+3*float(trap.subs(trap.waist_tweezer2))\n",
    "\n",
    "x, y, z = trap.x, trap.y, trap.z"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 111,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle a \\left(\\frac{2 P_{t1} e^{- \\frac{d_{t}^{2}}{2 W_{t1}^{2}}}}{\\pi W_{t1}^{2}} + \\frac{2 P_{t2} e^{- \\frac{d_{t}^{2}}{2 W_{t2}^{2}}}}{\\pi W_{t2}^{2}}\\right) - a \\left(\\frac{2 P_{t1} e^{\\frac{- 2 y^{2} - 2 \\left(\\frac{d_{t}}{2} + x\\right)^{2}}{W_{t1}^{2} \\left(1 + \\frac{\\lambda^{2} z^{2}}{\\pi^{2} W_{t1}^{4}}\\right)}}}{\\pi W_{t1}^{2} \\left(1 + \\frac{\\lambda^{2} z^{2}}{\\pi^{2} W_{t1}^{4}}\\right)} + \\frac{2 P_{t2} e^{\\frac{- 2 y^{2} - 2 \\left(- \\frac{d_{t}}{2} + x\\right)^{2}}{W_{t2}^{2} \\left(1 + \\frac{\\lambda^{2} z^{2}}{\\pi^{2} W_{t2}^{4}}\\right)}}}{\\pi W_{t2}^{2} \\left(1 + \\frac{\\lambda^{2} z^{2}}{\\pi^{2} W_{t2}^{4}}\\right)}\\right) - g m z$"
      ],
      "text/plain": [
       "a*(2*P_t1*exp(-d_t**2/(2*W_t1**2))/(pi*W_t1**2) + 2*P_t2*exp(-d_t**2/(2*W_t2**2))/(pi*W_t2**2)) - a*(2*P_t1*exp((-2*y**2 - 2*(d_t/2 + x)**2)/(W_t1**2*(1 + lambda**2*z**2/(pi**2*W_t1**4))))/(pi*W_t1**2*(1 + lambda**2*z**2/(pi**2*W_t1**4))) + 2*P_t2*exp((-2*y**2 - 2*(-d_t/2 + x)**2)/(W_t2**2*(1 + lambda**2*z**2/(pi**2*W_t2**4))))/(pi*W_t2**2*(1 + lambda**2*z**2/(pi**2*W_t2**4)))) - g*m*z"
      ]
     },
     "execution_count": 111,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "trap.get_potential().subs({trap.power:0,trap.grad_z:0, trap.grad_r:0})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 112,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle - \\frac{9.24016432665953 \\cdot 10^{-29} e^{- 1652892561983.47 \\left(x + 2.0 \\cdot 10^{-6}\\right)^{2}}}{\\pi} - \\frac{9.24016432665953 \\cdot 10^{-29} e^{- 1652892561983.47 \\left(x - 2.0 \\cdot 10^{-6}\\right)^{2}}}{\\pi}$"
      ],
      "text/plain": [
       "-9.24016432665953e-29*exp(-1652892561983.47*(x + 2.0e-6)**2)/pi - 9.24016432665953e-29*exp(-1652892561983.47*(x - 2.0e-6)**2)/pi"
      ]
     },
     "execution_count": 112,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "trap.subs(trap.get_potential(apply_zero_offset=False)).subs({y:0,z:0})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 113,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 42744 characters]",
      "text/plain": [
       "<Figure size 500x500 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "trap[trap.distance_tweezers] = initial_distance\n",
    "plot_solutions(trap,2,left_cutoff,right_cutoff,display_plot=-1,state_mult=40,n_pot_steps=2000,plot=True,ret_results=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 114,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 100860 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "n_levels=10\n",
    "n_pot_steps=2000\n",
    "x_np = np.linspace(left_cutoff,right_cutoff,n_pot_steps)\n",
    "\n",
    "distances = np.linspace(0*si.um,initial_distance,500)\n",
    "energies = np.zeros((len(distances),n_levels))\n",
    "states = np.zeros((len(distances),n_levels,n_pot_steps))\n",
    "potential = np.zeros((len(distances),n_pot_steps))\n",
    "\n",
    "#diagonalise hamiltonian for all distances\n",
    "for i, dist in enumerate(distances):\n",
    "    trap[trap.distance_tweezers] = dist\n",
    "    num, ener, state, pot = plot_solutions(trap,n_levels,np.min(x_np),np.max(x_np),display_plot=0,state_mult=450,n_pot_steps=n_pot_steps,plot=False,ret_results=True)\n",
    "    energies[i,:len(ener)] = ener\n",
    "    states[i,:len(ener)] = state\n",
    "    potential[i] = pot(x_np)\n",
    "\n",
    "\n",
    "#plot eigenenergies\n",
    "plt.axvline(float(trap.subs(trap.waist_tweezer1))/si.um, color=\"black\",label=\"tweezer waist\")\n",
    "for i in range(n_levels):\n",
    "    plt.plot(distances/si.um,energies[:,i],label=f\"state {i}\")\n",
    "\n",
    "plt.title(\"Eigenenergies of lowest states at different tweezer distances\")\n",
    "plt.xlabel(\"tweezer distance [um]\")\n",
    "plt.ylabel(\"energy [a.u.]\")\n",
    "\n",
    "plt.grid()\n",
    "plt.legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/latex": [
       "$\\displaystyle - \\frac{1139835.08686124 a \\left(P_{t1} W_{t2} \\left(\\operatorname{erf}{\\left(\\frac{1.4142135623731 x}{W_{t1}} \\right)} + \\operatorname{erf}{\\left(\\frac{4.94974746830583 \\cdot 10^{-7} - 1.41421356237309 x}{W_{t1}} \\right)}\\right) + P_{t2} W_{t1} \\left(- \\operatorname{erf}{\\left(\\frac{1.4142135623731 x}{W_{t2}} \\right)} + \\operatorname{erf}{\\left(\\frac{1.41421356237309 x + 4.94974746830583 \\cdot 10^{-7}}{W_{t2}} \\right)}\\right)\\right)}{W_{t1} W_{t2}}$"
      ],
      "text/plain": [
       "-1139835.08686124*a*(P_t1*W_t2*(erf(1.4142135623731*x/W_t1) + erf((4.94974746830583e-7 - 1.41421356237309*x)/W_t1)) + P_t2*W_t1*(-erf(1.4142135623731*x/W_t2) + erf((1.41421356237309*x + 4.94974746830583e-7)/W_t2)))/(W_t1*W_t2)"
      ]
     },
     "execution_count": 108,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "-trap.a*np.sqrt(2/np.pi)/initial_distance/trap.waist_tweezer1/trap.waist_tweezer2* (trap.power_tweezer1*trap.waist_tweezer2*(erf((initial_distance-2*x)/np.sqrt(2)/trap.waist_tweezer1) +\n",
    "                                                                                                                             erf(np.sqrt(2)*x/trap.waist_tweezer1))\n",
    "                                                                                    + trap.power_tweezer2*trap.waist_tweezer1*(erf((initial_distance+2*x)/np.sqrt(2)/trap.waist_tweezer2) -\n",
    "                                                                                                                             erf(np.sqrt(2)*x/trap.waist_tweezer2)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 28940 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#calculate average potential as tweezer distance is decreased from \"initial_distance\" to zero\n",
    "average_pot = sp.lambdify(x,trap.subs(-trap.a*np.sqrt(2/np.pi)/initial_distance/trap.waist_tweezer1/trap.waist_tweezer2* (trap.power_tweezer1*trap.waist_tweezer2*(erf((initial_distance-2*x)/np.sqrt(2)/trap.waist_tweezer1) +\n",
    "                                                                                                                             erf(np.sqrt(2)*x/trap.waist_tweezer1))\n",
    "                                                                                    + trap.power_tweezer2*trap.waist_tweezer1*(erf((initial_distance+2*x)/np.sqrt(2)/trap.waist_tweezer2) -\n",
    "                                                                                                                             erf(np.sqrt(2)*x/trap.waist_tweezer2)))))\n",
    "\n",
    "#average_pot = sp.lambdify(y,trap.subs(-trap.a*np.sqrt(2/np.pi)/initial_distance*((trap.power_tweezer1/trap.waist_tweezer1*erf((initial_distance-2*y)/np.sqrt(2)/trap.waist_tweezer1)) +\n",
    "#                                                                                    (trap.power_tweezer2/trap.waist_tweezer2*erf((initial_distance+2*y)/np.sqrt(2)/trap.waist_tweezer2)))))\n",
    "average_potential = average_pot(x_np)\n",
    "#plt.plot(x_np,average_potential)\n",
    "\n",
    "#get the time averaged hamiltonian\n",
    "dx = np.mean(np.diff(x_np))\n",
    "mean_ham = discrete_hamiltonian(dx,average_potential,float(trap.subs(trap.m).evalf()))\n",
    "mean_ham_square = mean_ham**2\n",
    "\n",
    "#compute the time \"tau\" needed to make it an adiabatic process\n",
    "delta_ham = np.zeros(n_levels)\n",
    "for i in range(n_levels):\n",
    "    delta_ham[i] = np.sqrt(states[-1,i].dot(mean_ham_square.dot(states[-1,i]))-(states[-1,i].dot(mean_ham.dot(states[-1,i])))**2)\n",
    "tau = const.hbar/delta_ham\n",
    "\n",
    "\"\"\"\n",
    "plt.plot(tau/si.us,\"o\")\n",
    "plt.xlabel(\"state number []\")\n",
    "plt.ylabel(\"time [us]\")\n",
    "plt.title(\"time needed for adiabatic process\")\"\"\"\n",
    "\n",
    "\n",
    "plt.plot(initial_distance/si.cm/tau,\"o\")\n",
    "plt.xlabel(\"state number []\")\n",
    "plt.ylabel(\"velocity [cm/s]\")\n",
    "plt.title(\"average velocity for adiabatic process\")\n",
    "\n",
    "plt.grid()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Calculate time interval for adiabatic transition"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "metadata": {},
   "outputs": [],
   "source": [
    "dx = np.mean(np.diff(x_np))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "metadata": {},
   "outputs": [],
   "source": [
    "n_levels = 10\n",
    "\n",
    "mean_ham = 0\n",
    "for i, dist in enumerate(distances):\n",
    "    mean_ham += discrete_hamiltonian(dx,potential[i],float(trap.subs(trap.m).evalf()))\n",
    "\n",
    "\n",
    "eigenvals, eigenvects = sparse.linalg.eigsh(mean_ham, k=n_levels, which=\"LM\", sigma=np.min(potential))\n",
    "eigenvals_square, eigenvects_square = sparse.linalg.eigsh(mean_ham**2, k=n_levels, which=\"LM\", sigma=np.min(potential)**2)\n",
    "\n",
    "tau = const.hbar/np.sqrt(np.abs(eigenvals_square - eigenvals**2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "metadata": {},
   "outputs": [],
   "source": [
    "tau_est = const.hbar/(np.max(energies,axis=0)-np.min(energies,axis=0))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x13da23c5be0>]"
      ]
     },
     "execution_count": 92,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 12752 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(tau,\"o\")\n",
    "plt.plot(tau_est,\"o\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Do the same, but calculate average potential first"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 26252 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "average_pot = sp.lambdify(y,trap.subs(-trap.a*np.sqrt(2/np.pi)/initial_distance*((trap.power_tweezer1/trap.waist_tweezer1*erf((initial_distance-2*y)/np.sqrt(2)/trap.waist_tweezer1)) +\n",
    "                                                                (trap.power_tweezer2/trap.waist_tweezer2*erf((initial_distance+2*y)/np.sqrt(2)/trap.waist_tweezer2)))))\n",
    "average_potential = average_pot(x_np)\n",
    "plt.plot(x_np,average_potential)\n",
    "\n",
    "mean_ham2 = discrete_hamiltonian(dx,average_potential,float(trap.subs(trap.m).evalf()))\n",
    "\n",
    "\n",
    "eigenvals2, eigenvects2 = sparse.linalg.eigsh(mean_ham2, k=n_levels, which=\"LM\", sigma=np.min(potential))\n",
    "eigenvals2_square, eigenvects2_square = sparse.linalg.eigsh(mean_ham2**2, k=n_levels, which=\"LM\", sigma=np.min(potential)**2)\n",
    "\n",
    "tau2 = const.hbar/np.sqrt(np.abs(eigenvals2_square - eigenvals2**2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x13da3741ee0>]"
      ]
     },
     "execution_count": 94,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 11560 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#plt.plot(tau,\"o\")\n",
    "plt.plot(tau2,\"o\")\n",
    "plt.plot(tau_est,\"o\")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Do it actually correctly (implemented in 1st section)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "metadata": {},
   "outputs": [
    {
     "ename": "IndexError",
     "evalue": "index 10 is out of bounds for axis 1 with size 10",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mIndexError\u001b[0m                                Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[95], line 14\u001b[0m\n\u001b[0;32m     12\u001b[0m delta_ham \u001b[38;5;241m=\u001b[39m np\u001b[38;5;241m.\u001b[39mzeros(n_levels)\n\u001b[0;32m     13\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i, dist \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28menumerate\u001b[39m(distances):\n\u001b[1;32m---> 14\u001b[0m     delta_ham[i] \u001b[38;5;241m=\u001b[39m np\u001b[38;5;241m.\u001b[39msqrt(states[\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m,i]\u001b[38;5;241m.\u001b[39mdot(mean_ham_square\u001b[38;5;241m.\u001b[39mdot(states[\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m,i]))\u001b[38;5;241m-\u001b[39m(states[\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m,i]\u001b[38;5;241m.\u001b[39mdot(mean_ham\u001b[38;5;241m.\u001b[39mdot(states[\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m,i])))\u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39m\u001b[38;5;241m2\u001b[39m)\n\u001b[0;32m     15\u001b[0m tau \u001b[38;5;241m=\u001b[39m const\u001b[38;5;241m.\u001b[39mhbar\u001b[38;5;241m/\u001b[39mdelta_ham\n",
      "\u001b[1;31mIndexError\u001b[0m: index 10 is out of bounds for axis 1 with size 10"
     ]
    }
   ],
   "source": [
    "#calculate average potential as tweezer distance is decreased from \"initial_distance\" to zero\n",
    "average_pot = sp.lambdify(y,trap.subs(-trap.a*np.sqrt(2/np.pi)/initial_distance*((trap.power_tweezer1/trap.waist_tweezer1*erf((initial_distance-2*y)/np.sqrt(2)/trap.waist_tweezer1)) +\n",
    "                                                                (trap.power_tweezer2/trap.waist_tweezer2*erf((initial_distance+2*y)/np.sqrt(2)/trap.waist_tweezer2)))))\n",
    "average_potential = average_pot(x_np)\n",
    "#plt.plot(x_np,average_potential)\n",
    "\n",
    "#get the time averaged hamiltonian\n",
    "mean_ham = discrete_hamiltonian(dx,average_potential,float(trap.subs(trap.m).evalf()))\n",
    "mean_ham_square = mean_ham**2\n",
    "\n",
    "#compute the time \"tau\" needed to make it an adiabatic process\n",
    "delta_ham = np.zeros(n_levels)\n",
    "for i, dist in enumerate(distances):\n",
    "    delta_ham[i] = np.sqrt(states[-1,i].dot(mean_ham_square.dot(states[-1,i]))-(states[-1,i].dot(mean_ham.dot(states[-1,i])))**2)\n",
    "tau = const.hbar/delta_ham"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Try to calculate phase imparted on the states"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(150, 10)"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "energies.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(150, 10, 2000)"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "states.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [],
   "source": [
    "#calculate dynamical phase\n",
    "dyn_phase = -np.sum(energies,axis=0)/const.hbar\n",
    "\n",
    "#calculate geometric phase\n",
    "dot_m = np.gradient(states,axis=0)\n",
    "bracket_m_dot_m = np.sum(states*np.conjugate(dot_m),axis=2)\n",
    "geo_phase = 1j*np.sum(bracket_m_dot_m,axis=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([-0.-0.69885833j, -0.-0.6988583j , -0.-0.94850139j, -0.-0.9485013j ,\n",
       "       -0.-0.02460082j,  0.+0.02460068j, -0.-0.04092669j,  0.+0.04092651j,\n",
       "        0.+0.98219236j, -0.-0.98219215j])"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "geo_phase #this can't be correct, since it should be real!!!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([47445210.80639105, 46774256.50928428, 44073351.11611445,\n",
       "       43392945.91945135, 40776693.40224414, 40091176.83504527,\n",
       "       37560433.80642757, 36872657.12805155, 34428490.8809985 ,\n",
       "       33740893.13537717])"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dyn_phase"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "ename": "ValueError",
     "evalue": "operands could not be broadcast together with shapes (2,) (10,) ",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mValueError\u001b[0m                                Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[39], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m c_new \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m1\u001b[39m\u001b[38;5;241m/\u001b[39mnp\u001b[38;5;241m.\u001b[39msqrt(\u001b[38;5;241m2\u001b[39m)\u001b[38;5;241m*\u001b[39mnp\u001b[38;5;241m.\u001b[39marray([\u001b[38;5;241m1\u001b[39m,\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m])\u001b[38;5;241m*\u001b[39mnp\u001b[38;5;241m.\u001b[39mexp(\u001b[38;5;241m1\u001b[39mj\u001b[38;5;241m*\u001b[39m(geo_phase\u001b[38;5;241m+\u001b[39mdyn_phase))\n\u001b[0;32m      2\u001b[0m c_new\n",
      "\u001b[1;31mValueError\u001b[0m: operands could not be broadcast together with shapes (2,) (10,) "
     ]
    }
   ],
   "source": [
    "c_new = 1/np.sqrt(2)*np.array([1,-1])*np.exp(1j*(geo_phase+dyn_phase))\n",
    "c_new"
   ]
  },
  {
   "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.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
