(* 
This notebook describes the magnetic field of the finished Anti-helmholtz coil for the Strontium 6in Spherical Octagon along the axis of the coil.

Sorrentino gives the magnetic field gradient near the center of their MOT as 50 Gauss/cm. However, Dan thinks we'll only need ~15 Gauss/cm for the initial trapping stage.
*)

(* Definitions *)
in = 2.54cm;
cm = 0.01m;
T = 10000G;
Ω = Watts/A^2 ;
μ0 = 4Pi 10^-7 T m/A;

Clear[Current, B, BGradient]

(* Coil Properties *)
Turns = 22*14;
RCoil = 7.25/2in;
Separation=4.530in;

(* Wire Properties *)
ConductorDiameter = 0.0320 in; (* 20 AWG *)
ρ = 1.8558 10^-8 Ω m; (* Advertized by MWS *)

(* Wire Calculations *)
ConductorLength = 2 RCoil Pi Turns;
ConductorArea = Pi (ConductorDiameter)^2/4;

(* Resistance = ρ ConductorLength/ConductorArea; *)
Resistance = 7.2 Watts/A^2;

Voltage = Current Resistance;
Dissipation = Current Voltage;

(* Magnetic field profile *)
B[z_] =μ0 Current(A/G) Turns (RCoil/m)^2 /(2 m)(((RCoil/m)^2+(z-Separation/(2 m))^2)^(-3/2)-((RCoil/m)^2+(z+Separation/(2 m))^2)^(-3/2));

BGradient[z_] = D[B[z],z];
BGradZero = Normal[Series[BGradient[z],{z,0,1}]];

(* Vary Current to find optimal B gradient and power losses *)

Animate[
Evaluate[
{{Current "A"},{Voltage "V"A^2/Watts,Dissipation A^2,BGradZero/100 "G/cm" }}
],
{Current,1,5},AnimationRunning->False]

(* Set definite Current value *)

Current=4;

{Voltage "V"A^2/Watts,Dissipation A^2,BGradZero/100 "G/cm" }

{
Plot[B[z],{z,-2RCoil/m,2RCoil/m},AxesLabel->{"x (m)","B (G)"},ImageSize->Small],

Plot[BGradient[z]/100,{z,-2RCoil/m,2RCoil/m},AxesLabel->{"x (m)","dB/dz (G/cm)"},ImageSize->Small]
}
Clear[Current]