diff --git a/simulations/magnetic_force_on_coils.ipynb b/simulations/magnetic_force_on_coils.ipynb index d484f97..a1bfbcb 100644 --- a/simulations/magnetic_force_on_coils.ipynb +++ b/simulations/magnetic_force_on_coils.ipynb @@ -24,13 +24,13 @@ "# load up the simple spiral coil\n", "coil1 = parse_coil(f\"coils/coil_{COIL}_spiral.csv\")\n", "plot_coil(f\"coils/coil_{COIL}_spiral.csv\")\n", - "coil1 = slice_coil(coil1, 1)\n", + "coil1 = slice_coil(coil1, 0.01)\n", "coil1 = coil1.T\n", "print(coil1.shape)\n", "\n", "coil2 = parse_coil(f\"coils/coil_{COIL}_custom.csv\")\n", "plot_coil(f\"coils/coil_{COIL}_custom.csv\")\n", - "coil2 = slice_coil(coil2, 1)\n", + "coil2 = slice_coil(coil2, 0.01)\n", "coil2 = coil2.T\n", "print(coil2.shape)" ] @@ -145,6 +145,7 @@ "source": [ "def B(x, y, z, m=0.185, l=0.003, d=0.01):\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", " bx = 0\n", " by = 0\n", @@ -152,19 +153,19 @@ " for degrees in range(0, 360, 30):\n", " angle = np.deg2rad(degrees)\n", " x_, y_, z_ = dipole(\n", - " x + 0.9 * d / 2 * np.cos(angle),\n", - " y + 0.9 * d / 2 * np.sin(angle),\n", - " z - 0.9 * l / 2,\n", - " m / (360 / 60),\n", + " x + d / 2 * np.cos(angle),\n", + " y + d / 2 * np.sin(angle),\n", + " z - l / 2,\n", + " m / (360 / 30),\n", " )\n", " bx += x_\n", " by += y_\n", " bz += z_\n", " x_, y_, z_ = dipole(\n", - " x + 0.9 * d / 2 * np.cos(angle),\n", - " y + 0.9 * d / 2 * np.sin(angle),\n", - " z + 0.9 * l / 2,\n", - " m / (360 / 60),\n", + " x + d / 2 * np.cos(angle),\n", + " y + d / 2 * np.sin(angle),\n", + " z + l / 2,\n", + " m / (360 / 30),\n", " )\n", " bx += x_\n", " by += y_\n", @@ -293,7 +294,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.002\n", "\n", " # loop through the locations and calculate the forces, sum up the force in the X direction for each location\n", " Fx = []\n", @@ -306,9 +307,9 @@ "\n", " points = coil.copy()\n", " for i in range(len(points)):\n", - " points[i][0] = points[i][0] / 1000 + x\n", - " points[i][1] = points[i][1] / 1000 + y\n", - " points[i][2] = points[i][2] / 1000 + z\n", + " points[i][0] = points[i][0] / 100 + x\n", + " points[i][1] = points[i][1] / 100 + y\n", + " points[i][2] = points[i][2] / 100 + z\n", " # feel the force\n", " Fx_, Fy_, Fz_ = calculate_forces_on_wire_points(points)\n", " Fx.append(sum(Fx_))\n", @@ -333,14 +334,22 @@ " # points in meters (coil is in cm)\n", " [x / 100 for x, y, z, _ in points],\n", " [y / 100 for x, y, z, _ in points],\n", - " label=\"coil\",\n", + " label=\"coil2\",\n", " color=\"blue\",\n", ")\n", + "points = coil1.copy()\n", + "plt.plot(\n", + " # points in meters (coil is in cm)\n", + " [x / 100 for x, y, z, _ in points],\n", + " [y / 100 for x, y, z, _ in points],\n", + " label=\"coil1\",\n", + " color=\"red\",\n", + ")\n", "# make the aspect ratio equal\n", "plt.gca().set_aspect(\"equal\")\n", "\n", "Fx_1_curve, Fy_1_curve, Fz_1_curve = sweep_coil_circle(coil1, 20.5 / 1000, theta)\n", - "Fx_2_curve, Fy_2_curve, Fz_2_curve = sweep_coil_circle(coil2, 19.5 / 1000, theta)" + "Fx_2_curve, Fy_2_curve, Fz_2_curve = sweep_coil_circle(coil2, 20.5 / 1000, theta)" ] }, {