From a1295a061bd1b8c14f8ac133fc239bcc97dccdd5 Mon Sep 17 00:00:00 2001 From: polymurph <eddyed.k@gmail.com> Date: Mon, 4 Jul 2022 22:38:23 +0200 Subject: [PATCH] work on quadrupole model --- ...nfinite_lnegth_Quadrupole-checkpoint.ipynb | 70 ++++++++++++++++++- .../Model_of_infinite_lnegth_Quadrupole.ipynb | 70 ++++++++++++++++++- 2 files changed, 136 insertions(+), 4 deletions(-) diff --git a/quadrupole/.ipynb_checkpoints/Model_of_infinite_lnegth_Quadrupole-checkpoint.ipynb b/quadrupole/.ipynb_checkpoints/Model_of_infinite_lnegth_Quadrupole-checkpoint.ipynb index 8527401..cbec00d 100644 --- a/quadrupole/.ipynb_checkpoints/Model_of_infinite_lnegth_Quadrupole-checkpoint.ipynb +++ b/quadrupole/.ipynb_checkpoints/Model_of_infinite_lnegth_Quadrupole-checkpoint.ipynb @@ -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", " " ] } diff --git a/quadrupole/Model_of_infinite_lnegth_Quadrupole.ipynb b/quadrupole/Model_of_infinite_lnegth_Quadrupole.ipynb index 8527401..cbec00d 100644 --- a/quadrupole/Model_of_infinite_lnegth_Quadrupole.ipynb +++ b/quadrupole/Model_of_infinite_lnegth_Quadrupole.ipynb @@ -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", " " ] }