diff --git a/coil_generator-6.ipynb b/coil_generator-6.ipynb index 0f99dba..4675be0 100644 --- a/coil_generator-6.ipynb +++ b/coil_generator-6.ipynb @@ -675,7 +675,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3.10.7 ('venv': venv)", + "display_name": "venv", "language": "python", "name": "python3" }, @@ -689,11 +689,11 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.7" + "version": "3.10.7 (main, Sep 27 2022, 14:37:32) [Clang 14.0.0 (clang-1400.0.29.102)]" }, "vscode": { "interpreter": { - "hash": "fc384f9db26c31784edfba3761ba3d2c7b2f9b8a63e03a9eb0778fc35334efe1" + "hash": "1ce20143987840b9786ebb5907032c9c3a8efacbb887dbb0ebc4934f2ad26cb3" } } }, diff --git a/coil_generator-radial.ipynb b/coil_generator-radial.ipynb index ed599ea..e68463c 100644 --- a/coil_generator-radial.ipynb +++ b/coil_generator-radial.ipynb @@ -566,7 +566,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.7" + "version": "3.10.7 (main, Sep 27 2022, 14:37:32) [Clang 14.0.0 (clang-1400.0.29.102)]" }, "vscode": { "interpreter": { diff --git a/simulations/magnetic_force_on_coils.ipynb b/simulations/magnetic_force_on_coils.ipynb index add5cec..ab2749c 100644 --- a/simulations/magnetic_force_on_coils.ipynb +++ b/simulations/magnetic_force_on_coils.ipynb @@ -45,10 +45,10 @@ "# magnetic field at a point x,y,z of a dipole magnet with moment m in the z direction\n", "def dipole(x, y, z, m=0.185):\n", " mu0 = 1e-7 / 4 * np.pi\n", - " r = np.sqrt(x ** 2 + y ** 2 + z ** 2)\n", + " r = np.sqrt(x**2 + y**2 + z**2)\n", " return (\n", " np.array(\n", - " [3 * x * z / r ** 5, 3 * y * z / r ** 5, (3 * z ** 2 / r ** 5 - 1 / r ** 3)]\n", + " [3 * x * z / r**5, 3 * y * z / r**5, (3 * z**2 / r**5 - 1 / r**3)]\n", " )\n", " * m\n", " * mu0\n", @@ -108,7 +108,7 @@ " Z,\n", " Bx,\n", " Bz,\n", - " np.log(np.sqrt(Bx ** 2 + By ** 2 + Bz ** 2)),\n", + " np.log(np.sqrt(Bx**2 + By**2 + Bz**2)),\n", " \"dipole_field_side.png\",\n", " False,\n", ")\n", @@ -124,7 +124,7 @@ " Y,\n", " Bx,\n", " By,\n", - " np.log(np.sqrt(Bx ** 2 + By ** 2 + Bz ** 2)),\n", + " np.log(np.sqrt(Bx**2 + By**2 + Bz**2)),\n", " \"dipole_field_bottom.png\",\n", " False,\n", ")" @@ -143,7 +143,7 @@ "metadata": {}, "outputs": [], "source": [ - "def B(x, y, z, m=0.185, l=0.003, d=0.01):\n", + "def B(x, y, z, m=0.185, l=0.003, d=0.006):\n", " d = d * 0.75\n", " l = l * 0.75\n", " # simulate multiple points in the cylinder and add them together to create a disk of field\n", @@ -186,7 +186,7 @@ " Z,\n", " Bx,\n", " Bz,\n", - " np.log(np.sqrt(Bx ** 2 + By ** 2 + Bz ** 2)),\n", + " np.log(np.sqrt(Bx**2 + By**2 + Bz**2)),\n", " \"magnetic_field_side.png\",\n", ")\n", "\n", @@ -201,7 +201,7 @@ " Y,\n", " Bx,\n", " By,\n", - " np.log(np.sqrt(Bx ** 2 + By ** 2 + Bz ** 2)),\n", + " np.log(np.sqrt(Bx**2 + By**2 + Bz**2)),\n", " \"magnetic_field_bottom.png\",\n", ")\n", "\n", @@ -268,7 +268,7 @@ " dz = points[i][2] - points[(i + 1)][2]\n", " d = np.array([dx, dy, dz])\n", " # get the length of d\n", - " l = np.sqrt(dx ** 2 + dy ** 2 + dz ** 2)\n", + " l = np.sqrt(dx**2 + dy**2 + dz**2)\n", " if l > 0:\n", " # normalise d\n", " d = d / l\n", @@ -308,7 +308,7 @@ "def sweep_coil_circle(coil, coil_center_radius, theta):\n", " X = coil_center_radius * np.cos(np.deg2rad(theta))\n", " Y = coil_center_radius * np.sin(np.deg2rad(theta)) - coil_center_radius\n", - " Z = -0.01\n", + " Z = -0.0025\n", "\n", " # loop through the locations and calculate the forces, sum up the force in the X direction for each location\n", " Fx = []\n", @@ -357,6 +357,13 @@ " label=\"coil1\",\n", " color=\"red\",\n", ")\n", + "# plot the 6 mm diagmeter magnet as a circle\n", + "plt.plot(\n", + " 0.006 * np.cos(np.linspace(0, 2 * np.pi, 100)),\n", + " 0.006 * np.sin(np.linspace(0, 2 * np.pi, 100)),\n", + " color=\"black\",\n", + ")\n", + "\n", "# make the aspect ratio equal\n", "plt.gca().set_aspect(\"equal\")\n", "\n", @@ -397,11 +404,11 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.7" + "version": "3.10.7 (main, Sep 27 2022, 14:37:32) [Clang 14.0.0 (clang-1400.0.29.102)]" }, "vscode": { "interpreter": { - "hash": "fc384f9db26c31784edfba3761ba3d2c7b2f9b8a63e03a9eb0778fc35334efe1" + "hash": "1ce20143987840b9786ebb5907032c9c3a8efacbb887dbb0ebc4934f2ad26cb3" } } },