Skip to content

Commit

Permalink
Ruff check on notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
ColwynGulliford committed Oct 8, 2024
1 parent 862b927 commit 7cccfd1
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions docs/examples/fields/corrector_modeling.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@
"R = 2*2.54e-2 # 2\" radius [m]\n",
"L = 0.1 # Length along z [m]\n",
"theta = 2*np.pi/3 # Opening angle [rad]\n",
"I=1 # Current [Amp]\n",
"current=1 # Current [Amp]\n",
"\n",
"FM = make_dipole_corrector_fieldmesh(current=I,\n",
"FM = make_dipole_corrector_fieldmesh(current=current,\n",
" xmin=-R, xmax=R, nx=101,\n",
" ymin=-R, ymax=R, ny=101,\n",
" zmin=-5*L/2, zmax=5*L/2, nz=101,\n",
Expand Down Expand Up @@ -206,7 +206,7 @@
"h = a # Square corrector\n",
"b = 0.1 # Length [m]\n",
"\n",
"FM = make_dipole_corrector_fieldmesh(current=I,\n",
"FM = make_dipole_corrector_fieldmesh(current=current,\n",
" xmin=-0.99*R, xmax=0.99*R, nx=101, # Mind the wires\n",
" ymin=-0.99*R, ymax=0.99*R, ny=101, # Mind the wires\n",
" zmin=-5*L/2, zmax=+5*L/2, nz=101,\n",
Expand Down Expand Up @@ -404,12 +404,11 @@
"# Define wire endpoints and current\n",
"p1 = np.array([-0.75, 0, 0]) # Start point of the wire\n",
"p2 = np.array([+0.75, 0, 0]) # End point of the wire\n",
"I = 1 # Current in Amperes\n",
"\n",
"\n",
"\n",
"# Compute the magnetic field over the grid\n",
"Bx, By, Bz = bfield_from_thin_straight_wire(X, Y, Z, p1, p2, I, plot_wire=True)\n",
"Bx, By, Bz = bfield_from_thin_straight_wire(X, Y, Z, p1, p2, current, plot_wire=True)\n",
"ax = plt.gca()\n",
"ax.set_xlim([-1, 1])"
]
Expand All @@ -423,7 +422,7 @@
{
"data": {
"text/plain": [
"<matplotlib.colorbar.Colorbar at 0x155411c70>"
"<matplotlib.colorbar.Colorbar at 0x157e68ac0>"
]
},
"execution_count": 13,
Expand Down Expand Up @@ -471,7 +470,7 @@
"metadata": {},
"outputs": [],
"source": [
"I=1\n",
"current=1\n",
"R = 1\n",
"L = 1000\n",
"p1 = [-L/2, 0, 0]\n",
Expand All @@ -485,11 +484,11 @@
"\n",
"X, Y, Z = np.meshgrid(x, y, z)\n",
"\n",
"_, _, Bz = bfield_from_thin_straight_wire(X, Y, Z, p1, p2, I)\n",
"_, _, Bz = bfield_from_thin_straight_wire(X, Y, Z, p1, p2, current)\n",
"\n",
"B0 = Bz[(X==0) & (Y==R) & (Z==0)]\n",
"\n",
"assert np.isclose(mu_0*I/2/pi/R, B0), \"Wire expression does not reproduce infinite limit\""
"assert np.isclose(mu_0*current/2/pi/R, B0), \"Wire expression does not reproduce infinite limit\""
]
},
{
Expand Down Expand Up @@ -545,7 +544,7 @@
"\n",
"X, Y, Z = np.meshgrid(x, y, z, indexing='ij')\n",
"\n",
"BxCoil, ByCoil, BzCoil = bfield_from_thin_rectangular_coil(X, Y, Z, a, b, h, I, plot_wire=True)\n",
"BxCoil, ByCoil, BzCoil = bfield_from_thin_rectangular_coil(X, Y, Z, a, b, h, current, plot_wire=True)\n",
"ax = plt.gca()\n",
"ax.set_xlim([-2*a, 2*a])\n",
"ax.set_ylim([-2*b, 2*b])"
Expand All @@ -560,7 +559,7 @@
{
"data": {
"text/plain": [
"<matplotlib.colorbar.Colorbar at 0x15639bf10>"
"<matplotlib.colorbar.Colorbar at 0x165ec6f40>"
]
},
"execution_count": 16,
Expand Down Expand Up @@ -603,7 +602,7 @@
{
"data": {
"text/plain": [
"<matplotlib.legend.Legend at 0x155445f40>"
"<matplotlib.legend.Legend at 0x157d87f40>"
]
},
"execution_count": 17,
Expand Down Expand Up @@ -671,7 +670,7 @@
"h = a\n",
"b = 0.1\n",
"\n",
"BxCor, ByCor, BzCor = bfield_from_thin_rectangular_corrector(X, Y, Z, a, b, h, I, plot_wire=True)"
"BxCor, ByCor, BzCor = bfield_from_thin_rectangular_corrector(X, Y, Z, a, b, h, current, plot_wire=True)"
]
},
{
Expand All @@ -683,7 +682,7 @@
{
"data": {
"text/plain": [
"<matplotlib.colorbar.Colorbar at 0x16c0afd60>"
"<matplotlib.colorbar.Colorbar at 0x169be0cd0>"
]
},
"execution_count": 19,
Expand Down Expand Up @@ -726,7 +725,7 @@
{
"data": {
"text/plain": [
"<matplotlib.legend.Legend at 0x16c051340>"
"<matplotlib.legend.Legend at 0x169b80670>"
]
},
"execution_count": 20,
Expand Down Expand Up @@ -815,7 +814,7 @@
{
"data": {
"text/plain": [
"<matplotlib.colorbar.Colorbar at 0x1563a68e0>"
"<matplotlib.colorbar.Colorbar at 0x166861d60>"
]
},
"execution_count": 22,
Expand Down Expand Up @@ -897,7 +896,7 @@
{
"data": {
"text/plain": [
"<matplotlib.colorbar.Colorbar at 0x16c16bee0>"
"<matplotlib.colorbar.Colorbar at 0x169cbd0d0>"
]
},
"execution_count": 24,
Expand Down Expand Up @@ -979,7 +978,7 @@
{
"data": {
"text/plain": [
"<matplotlib.colorbar.Colorbar at 0x16c4a9fa0>"
"<matplotlib.colorbar.Colorbar at 0x169f36fa0>"
]
},
"execution_count": 26,
Expand Down Expand Up @@ -1022,7 +1021,7 @@
{
"data": {
"text/plain": [
"<matplotlib.legend.Legend at 0x16c576280>"
"<matplotlib.legend.Legend at 0x16a005250>"
]
},
"execution_count": 27,
Expand Down

0 comments on commit 7cccfd1

Please sign in to comment.