|
|
|
@ -10,6 +10,60 @@
|
|
|
|
|
"import scipy.constants as sc"
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": 16,
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"source": [
|
|
|
|
|
"class Ion:\n",
|
|
|
|
|
" def __init__(self,position, charge, mass, v_z):\n",
|
|
|
|
|
" self.position = position\n",
|
|
|
|
|
" self.charge = charge\n",
|
|
|
|
|
" self.m = mass\n",
|
|
|
|
|
" self.v_z = v_z\n",
|
|
|
|
|
" self.F = np.zeros(3)\n",
|
|
|
|
|
"\n",
|
|
|
|
|
"class infiniteLengthQuadrupole:\n",
|
|
|
|
|
" def __init__(self,R,r_0):\n",
|
|
|
|
|
" self.R = R\n",
|
|
|
|
|
" self.r_0 = r_0\n",
|
|
|
|
|
" self.pPole[0] = [r_0/np.sqrt(2),r_0/np.sqrt(2)]\n",
|
|
|
|
|
" self.pPole[1] = [-r_0/np.sqrt(2),r_0/np.sqrt(2)]\n",
|
|
|
|
|
" self.pPole[2] = [-r_0/np.sqrt(2),-r_0/np.sqrt(2)]\n",
|
|
|
|
|
" self.pPole[3] = [r_0/np.sqrt(2),-r_0/np.sqrt(2)]\n",
|
|
|
|
|
" self.rodsPseudoQ = np.zeros(4)\n",
|
|
|
|
|
" self.K = 1 / (4 * np.pi * sc.epsilon_0)\n",
|
|
|
|
|
" \n",
|
|
|
|
|
" def phi_0(U, V, f, t):\n",
|
|
|
|
|
" return U + V * np.sin(2 * np.pi * f * t)\n",
|
|
|
|
|
" \n",
|
|
|
|
|
" def calcNewIonPos(U,V,f,ion,t_s):\n",
|
|
|
|
|
" \n",
|
|
|
|
|
" # check if ion has left the r_0 boundary\n",
|
|
|
|
|
" if np.abs(ion.p) >= r_0:\n",
|
|
|
|
|
" return None\n",
|
|
|
|
|
" \n",
|
|
|
|
|
"\n",
|
|
|
|
|
" signLUT = [1,-1,1,-1]\n",
|
|
|
|
|
" index = 0;\n",
|
|
|
|
|
" \n",
|
|
|
|
|
" for Q in rodsPseudoQ:\n",
|
|
|
|
|
" # calculate the pseudo charge points of the quadrupole\n",
|
|
|
|
|
" Q = signLUT[index] * phi_0(U,V,f)/2 * K * R\n",
|
|
|
|
|
" index = index + 1\n",
|
|
|
|
|
" \n",
|
|
|
|
|
" # calculate force on ion\n",
|
|
|
|
|
" \n",
|
|
|
|
|
" \n",
|
|
|
|
|
" #ion.F += t_s**2 * 1 / ion.m \n",
|
|
|
|
|
" \n",
|
|
|
|
|
" \n",
|
|
|
|
|
" \n",
|
|
|
|
|
" \n",
|
|
|
|
|
" "
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": 2,
|
|
|
|
@ -23,15 +77,27 @@
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"cell_type": "code",
|
|
|
|
|
"execution_count": 4,
|
|
|
|
|
"execution_count": 1,
|
|
|
|
|
"metadata": {},
|
|
|
|
|
"outputs": [],
|
|
|
|
|
"outputs": [
|
|
|
|
|
{
|
|
|
|
|
"ename": "SyntaxError",
|
|
|
|
|
"evalue": "unexpected EOF while parsing (<ipython-input-1-280824707945>, line 7)",
|
|
|
|
|
"output_type": "error",
|
|
|
|
|
"traceback": [
|
|
|
|
|
"\u001b[0;36m File \u001b[0;32m\"<ipython-input-1-280824707945>\"\u001b[0;36m, line \u001b[0;32m7\u001b[0m\n\u001b[0;31m \u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m unexpected EOF while parsing\n"
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"source": [
|
|
|
|
|
"def force_on_ion(Q_I, p_I, Q_rods, p_rods):\n",
|
|
|
|
|
" K = 1 / (4 * np.pi * sc.epsilon_0)\n",
|
|
|
|
|
" \n",
|
|
|
|
|
" # sum all individual electric field contributions of the rods\n",
|
|
|
|
|
" for Q in Q_rods:\n",
|
|
|
|
|
" \n",
|
|
|
|
|
" \n",
|
|
|
|
|
" \n",
|
|
|
|
|
" "
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|