(* This notebook attempts to calculate the vector potential and resulting EM waves due to a tesla coil's pancake spiral primary *)

(* Definitions *)
in=2.54/100m;
degrees=Pi/180;

(* User Entry *)
InsideDiameter=5in;
Turns=10;
WireSpacing=0.5in;
WireAngle=25degrees;

(* Calculate *)
Clear[r,θ]
LowerLimit=2Pi InsideDiameter/WireSpacing ;
UpperLimit=2Pi Turns+LowerLimit;
WireSlope=WireSpacing Tan[WireAngle];

rx[θ_]=WireSpacing θ Cos[θ]/(2Pi);
ry[θ_]=WireSpacing θ Sin[θ]/(2Pi);
rz[θ_]=WireSlope (θ-LowerLimit)/(2Pi);

r[θ_]={rx[θ],ry[θ],rz[θ]};

ParametricPlot3D[r[θ]/m,{θ,LowerLimit,UpperLimit}]

(* The plot above represents the curve over which the curent density should be integrated. Current density can be approximated by a normalized θhat vector field with a upward slope component *)

(* User Input *)
Current=1Amp; (* This will eventually be sinusoidal *)

(* Calculate *)
jx[θ_]=Cos[θ];
jy[θ_]=Sin[θ];
jz[θ_]=Tan[WireAngle];

j[θ_]=Current{jx[θ],jy[θ],jz[θ]};

(* Now we combine the path with the vector field representing current density to obtain vector potential *)

rmeasure={0,0,z}; (* Measurement axis *)

μ0=4Pi 10^-7 m kg/(Amp^2 s^2);

A[z_]=μ0/(4 Pi)NIntegrate[j[θ]/Norm[rmeasure-r[θ]],{θ,LowerLimit,UpperLimit}]