forked from scott-k-anderson/Anti-Helmholtz-Magnets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AntiH.m
85 lines (72 loc) · 2.27 KB
/
AntiH.m
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
%
% AntiH.m
%
clear all;
close all;
npts=2000;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% User defined parameters in between the lines
N_L = 5; %Number of coils vertically
N_r = 20; %Number of coils radially
I = 3; %current in amps [A]
t = 0.1; %diameter of coated wire - 16 gauge wire [cm]
r_ave = 5 * 2.54; %interior radius in [cm]
L = r_ave; %distance of center coils for Anti-Helmholtz
%configuration.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
z = 2*[-npts:npts]*L/(2*npts); %Plotting beyond the location of the coils
B=zeros(1,length(z));
for j=1:N_r %radial loop
r_j = r_ave + (j-(N_r+1)/2)*t;
A = 2 * pi * I * r_j^2 / 10;
for i=1:N_L % Longitudinal loop
z_i = (L/2) +(i-(N_L+1)/2) * t ;
C_plus = ((z - z_i).^2 + r_j^2).^(3/2);
C_minus = ((z + z_i).^2 + r_j^2).^(3/2);
B = B + A * (1./C_plus - 1./C_minus);
end
end
fid1=figure;
plot(z,B);
set(fid1,'Position',[41 578 560 420]);
xlabel('z- cm'); ylabel('B(z)- G');
title('B');
grid("on")
grid("minor")
fid2=figure;
plot(z(1:length(z)-1),diff(B)./diff(z))
set(fid2,'Position',[43 84 560 420]);
xlabel('z- cm')
ylabel('dB/dz- G/cm')
t_1 = title("$\frac{dB}{dz}$",'interpreter','latex');
t_1.FontSize = 20;
grid("on")
grid("minor")
fid3=figure;
plot(z(1:length(z)-2),diff(diff(B))./diff(z(1:length(z)-1)).^2)
xlabel('z- cm')
t_2 = title("$\frac{d^2B}{dz^2}$",'interpreter','latex');
t_2.FontSize = 20;
grid("on")
grid("minor")
fid4=figure;
plot(z(1:length(z)-3),diff(diff(diff(B)))./diff(z(1:length(z)-2)).^2)'
xlabel('z- cm')
t_3 = title("$\frac{d^3B}{dz^3}$",'interpreter','latex');
t_3.FontSize = 20;
grid("on")
grid("minor")
coil_area = pi * (t/2)^2;
N_t = 2*(N_L * N_r);
pwr = 2 * pi * r_ave * (1.7e-6) * (N_t * I)^2 / (N_t * coil_area);
volts = pwr / I;
display(pwr);
display(volts);
mu = (4*pi)*10e-7;
inductance = N_t^2 * (r_ave/100) * mu * (log(8*r_ave/coil_area) - 2);
display(inductance);
clamp_V = 500;
current = I;
switch_L = inductance;
switching_T = switch_L * current / clamp_V;
disp(strcat('Switching time = ',num2str(switching_T/1e-6),' usec'));