-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalyticalSolution.wl
executable file
·47 lines (36 loc) · 1.46 KB
/
analyticalSolution.wl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env wolframscript
(* Check if we're in the right directory *)
Directory[]
(* Import the numerical data *)
XZBz := Import["Output/XZBz.txt","Table"]
(* List the imported table to check it *)
(*XZBz*)
(* Split the coordinates into separate vectors *)
X := XZBz[[All,1]]
Z := XZBz[[All,2]]
(* List the variables to check them *)
(*X
Z*)
(* Definitions of constants *)
a := 7.25*^-3
L := 2*^-3
\[Micro] := 4*Pi*1*^-7
n := 10
current := 1*^-3
preFactor := (\[Micro]*n*current)/(4*Pi)
(* Definitions of simplifying variables *)
h[rho_] := Sqrt[4*a*rho/(a + rho)^2]
k[rho_,zeta_] := Sqrt[4*a*rho/((a + rho)^2 + zeta^2)]
(* Definitions of functions *)
Br[r_,z_] := preFactor*(1/L)((k[r,z+L/2]^2-2)/k[r,z+L/2])*EllipticK[k[r,z+L/2]^2]+(2/k[r,z+L/2])*EllipticE[k[r,z+L/2]^2]-((k[r,z-L/2]^2-2)/k[r,z-L/2])*EllipticK[k[r,z-L/2]^2]-(2/k[r,z-L/2])*EllipticE[k[r,z-L/2]^2]
Bz[r_,z_] := preFactor*(1/L)1/(Sqrt[a*r])*((z+L/2)k[r,z+L/2](EllipticK[k[r,z+L/2]^2]+((a-r)/(a+r))EllipticPi[h[r]^2,k[r,z+L/2]^2])-(z-L/2)k[r,z-L/2](EllipticK[k[r,z-L/2]^2]+((a-r)/(a+r))EllipticPi[h[r]^2,k[r,z-L/2]^2]))
(* Plot the z component of the B field to check it *)
(*Plot3D[Bz[r,z ],{r,0,1.5*a},{z,-L*2/3,L*2/3}]*)
(* Calculate the z component analytically *)
BzAnalytic := Re[Bz[X,Z]]
(*BzAnalytic*)
(* Collect points and Bx values into a matrix for export *)
dataForExport := Transpose[{X,Z,BzAnalytic}]
(*dataForExport*)
(* Export the data *)
Export["Output/XZBzAnalytic.txt",dataForExport,"Table"]