Skip to content

Commit

Permalink
Add sanity checks and correct R2.
Browse files Browse the repository at this point in the history
  • Loading branch information
dtabell committed Aug 16, 2023
1 parent 204825b commit 8ac129c
Showing 1 changed file with 36 additions and 12 deletions.
48 changes: 36 additions & 12 deletions Radia_Ex06.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,19 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"tags": []
},
"source": [
"## _Create the quadrupole and solve for the fields_"
]
},
{
"cell_type": "markdown",
"metadata": {
"tags": []
},
"source": [
"## _Create the quadrupole and solve for the fields_\n",
"\n",
"First set the various parameters that specify the properties—geometry,\n",
"materials, and current—of our quadrupole. Then also decide how finely\n",
"to segment the iron."
Expand Down Expand Up @@ -547,7 +556,9 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"tags": []
},
"source": [
"## _Plots of the magnetic field and field integrals_\n",
"\n",
Expand Down Expand Up @@ -674,13 +685,12 @@
" This function constructs one half of a vertical sector of a multipole magnet.\n",
" It then applies appropriate symmetries to construct and orient the full magnet.\n",
" '''\n",
" # sanity checks on user input\n",
" # :: even number of magnetic poles?\n",
" # sanity check: even number of magnetic poles?\n",
" assert n_poles % 2 == 0, \"Argument n_poles must equal an even integer.\"\n",
" # :: pole tips do not intersect? ==> automatic!! <==\n",
" # :: lower pole tip includes all of pole face?\n",
" # :: coil_1 does not cross sector diagonal\n",
" # :: coil_2 does not cross sector diagonal\n",
" # sanity check: positive coil height?\n",
" assert tip_coil_sep < height, \"Tip-coil separation exceeds height of pole tip.\"\n",
" # sanity check: chamfers do not cut into all of pole tip?\n",
" assert chamfer < thick / 2, \"Chamfer too large.\"\n",
"\n",
" # define a few useful vectors\n",
" ctr = [0, 0, 0]\n",
Expand All @@ -695,12 +705,19 @@
" z0 = gap / 2\n",
" ym = width / 2\n",
" a_max = asinh(hyp * ym / z0)\n",
" zm = z0 * cosh(a_max)\n",
" # sanity check: pole tip includes all of pole face?\n",
" assert zm <= z0 + height, \\\n",
" \"Pole tip height too short to accommodate entire curved pole face.\"\n",
" da = a_max / n_curve\n",
" na = n_curve + 3 # go two points beyond so we don't have to extend the array\n",
" qq = [ [(z0 / hyp) * sinh(ia * da), z0 * cosh(ia * da)] for ia in range(na) ]\n",
" # and\n",
" # modify last two points so as to outline lower portion of the (half) pole tip\n",
" ht_lower = poletip_frac * height\n",
" # sanity check: lower fraction of pole tip includes all of pole face?\n",
" assert zm <= z0 + ht_lower, \\\n",
" \"Lower fraction of pole tip cannot accommodate entire pole face.\"\n",
" qq[n_curve + 1] = [ym, z0 + ht_lower]\n",
" qq[n_curve + 2] = [ 0, z0 + ht_lower]\n",
"\n",
Expand Down Expand Up @@ -749,8 +766,16 @@
" # and set color for iron\n",
" rad.ObjDrwAtr(g, ironcolor)\n",
"\n",
" # sanity check: coil_1 does not cross sector diagonal\n",
" # assert y_coil < y1\n",
" # sanity check: coil_2 does not cross sector diagonal\n",
" # assert y_coil < y2\n",
"\n",
" # create coil1\n",
" ht_coil = height - tip_coil_sep\n",
" # sanity check: coil does not extend below outer edge of curved pole tip\n",
" assert zm < z0 + height - ht_coil, \\\n",
" \"Inner coil will obscure part of the curved pole tip.\"\n",
" wd_to_diagonal = (gap / 2 + tip_coil_sep) * tan_np\n",
" r_max = wd_to_diagonal - clearance - width / 2 + r_min\n",
" coil1 = rad.ObjRaceTrk([0, 0, z0 + height - ht_coil / 2], [r_min, r_max],\n",
Expand All @@ -760,8 +785,7 @@
" # create coil2\n",
" ht_coil = (height - tip_coil_sep) / 2\n",
" wd_to_diagonal = (gap / 2 + height - ht_coil) * tan_np\n",
" # r2 = wd_to_diagonal - clearance - width / 2 + r_min\n",
" r2 = r_max + 0.8 * ht_coil\n",
" r2 = wd_to_diagonal - clearance - width / 2 + r_min\n",
" coil2 = rad.ObjRaceTrk([0, 0, z0 + height - ht_coil / 2], [r_max, r2],\n",
" [thick, width - 2 * r_min],\n",
" ht_coil, 3, curr_density)\n",
Expand Down

0 comments on commit 8ac129c

Please sign in to comment.