-
Notifications
You must be signed in to change notification settings - Fork 0
/
helmholtz.jl
303 lines (253 loc) · 7.42 KB
/
helmholtz.jl
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
### A Pluto.jl notebook ###
# v0.19.46
using Markdown
using InteractiveUtils
# ╔═╡ 162f2bf8-8480-11ef-0e6a-572667782062
let
import Pkg
Pkg.activate(".")
end
# ╔═╡ aa2b0d06-2708-42e9-b2b9-877a58b9664b
begin
using Coils
using DynamicQuantities
using LinearAlgebra
using Plots
end
# ╔═╡ 5fc89931-ac7f-4f6b-baeb-6e213337233d
mfd(coil, ρ, z) = norm(magnetic_flux_density(coil, ρ, 0u"m", z))
# ╔═╡ 23a89706-ead9-47da-bfbe-2a679890848b
mfdρ(coil, ρ, z) = magnetic_flux_density(coil, ρ, 0u"m", z)[1]
# ╔═╡ bae5bcbd-37d4-4a01-a149-c6206bd36795
mfdϕ(coil, ρ, z) = magnetic_flux_density(coil, ρ, 0u"m", z)[2]
# ╔═╡ b77985a7-abd3-4852-ba80-87feb02205af
mfdz(coil, ρ, z) = magnetic_flux_density(coil, ρ, 0u"m", z)[3]
# ╔═╡ 62e6b885-7900-42b5-924b-ce18ae8380b9
loop = CircularLoop(current=1u"A", diameter=2u"m")
# ╔═╡ 201d11b5-9a84-412e-be77-d314a7db0b62
md"## Helmholtz"
# ╔═╡ a3254a0c-d669-4a33-a102-87495ead9312
helmholtz = Helmholtz(loop, distance=1u"m")
# ╔═╡ 7cf3754d-da3f-4537-a106-36d80dc3e795
md"### Axial cuts"
# ╔═╡ 66add5e2-364e-4544-8c91-3cbec816e0b0
let
z = range(-2u"m", 2u"m", 51)
B1 = [mfdρ(helmholtz.coils[1], 0u"m", z) for z in z]
B2 = [mfdρ(helmholtz.coils[2], 0u"m", z) for z in z]
Bhelmholtz = [mfdρ(helmholtz, 0u"m", z) for z in z]
plot(
ustrip.(z),
ustrip.([
B1, B2, Bhelmholtz
]) ./ 1e-4,
label=["Bρ₁" "Bρ₂" "Bρ₁+Bρ₂"],
markershape=[:circle :cross :star]
)
xlabel!("z/R")
ylabel!("Bρ (Gauss)")
end
# ╔═╡ 932eb910-a15e-44b9-a245-5dd1fc4ea1c0
let
z = range(-2u"m", 2u"m", 51)
B1 = [mfdϕ(helmholtz.coils[1], 0u"m", z) for z in z]
B2 = [mfdϕ(helmholtz.coils[2], 0u"m", z) for z in z]
Bhelmholtz = [mfdϕ(helmholtz, 0u"m", z) for z in z]
plot(
ustrip.(z),
ustrip.([
B1, B2, Bhelmholtz
]) ./ 1e-4,
label=["Bϕ₁" "Bϕ₂" "Bϕ₁+Bϕ₂"],
markershape=[:circle :cross :star]
)
xlabel!("z/R")
ylabel!("Bϕ (Gauss)")
end
# ╔═╡ 1e5b9289-10da-4400-9b42-2d838c2f1c59
let
z = range(-2u"m", 2u"m", 51)
B1 = [mfdz(helmholtz.coils[1], 0u"m", z) for z in z]
B2 = [mfdz(helmholtz.coils[2], 0u"m", z) for z in z]
Bhelmholtz = [mfdz(helmholtz, 0u"m", z) for z in z]
plot(
ustrip.(z),
ustrip.([
B1, B2, Bhelmholtz
]) ./ 1e-4,
label=["Bz₁" "Bz₂" "Bz₁+Bz₂"],
markershape=[:circle :cross :star]
)
xlabel!("z/R")
ylabel!("Bz (Gauss)")
end
# ╔═╡ 6b4d7800-9f07-44d5-a336-55d9612a72d2
md"### Radial cuts"
# ╔═╡ 61ee4135-9cef-421f-a47e-ea82e679d61c
let
ρ = range(-2u"m", 2u"m", 101)
B1 = [mfdρ(helmholtz.coils[1], ρ, 0u"m") for ρ in ρ]
B2 = [mfdρ(helmholtz.coils[2], ρ, 0u"m") for ρ in ρ]
Bhelmholtz = [mfdρ(helmholtz, ρ, 0u"m") for ρ in ρ]
scatter(
ustrip.(ρ),
ustrip.([
B1, B2, Bhelmholtz,
]) ./ 1e-4,
label=["Bρ₁" "Bρ₂" "Bρ₁+Bρ₂"],
markershape=[:circle :cross :star]
)
title!("z = 0 mm")
xlabel!("ρ/R")
ylabel!("Bρ (Gauss)")
end
# ╔═╡ b5caef90-ac31-4689-8872-4d3ab3386dc8
let
ρ = range(-2u"m", 2u"m", 101)
B1 = [mfdϕ(helmholtz.coils[1], ρ, 0u"m") for ρ in ρ]
B2 = [mfdϕ(helmholtz.coils[2], ρ, 0u"m") for ρ in ρ]
Bhelmholtz = [mfdϕ(helmholtz, ρ, 0u"m") for ρ in ρ]
scatter(
ustrip.(ρ),
ustrip.([
B1, B2, Bhelmholtz,
]) ./ 1e-4,
label=["Bϕ₁" "Bϕ₂" "Bϕ₁+Bϕ₂"],
markershape=[:circle :cross :star]
)
title!("z = 0 mm")
xlabel!("ρ/R")
ylabel!("Bϕ (Gauss)")
end
# ╔═╡ 4dddd7c0-db87-497b-8d60-c6d2b6c52427
let
ρ = range(-2u"m", 2u"m", 101)
B1 = [mfdz(helmholtz.coils[1], ρ, 0u"m") for ρ in ρ]
B2 = [mfdz(helmholtz.coils[2], ρ, 0u"m") for ρ in ρ]
Bhelmholtz = [mfdz(helmholtz, ρ, 0u"m") for ρ in ρ]
scatter(
ustrip.(ρ),
ustrip.([
B1, B2, Bhelmholtz,
]) ./ 1e-4,
label=["Bz₁" "Bz₂" "Bz₁+Bz₂"],
markershape=[:circle :cross :star]
)
title!("z = 0 mm")
xlabel!("ρ/R")
ylabel!("Bz (Gauss)")
end
# ╔═╡ ca0f1232-0203-4fb0-92b8-cd388bc4492f
let
ρ = range(-2u"m", 2u"m", 101)
z = 10u"mm"
B1 = [mfdz(helmholtz.coils[1], ρ, z) for ρ in ρ]
B2 = [mfdz(helmholtz.coils[2], ρ, z) for ρ in ρ]
Bhelmholtz = [mfdz(helmholtz, ρ, z) for ρ in ρ]
scatter(
ustrip.(ρ),
ustrip.([
B1, B2, Bhelmholtz
]) ./ 1e-4,
label=["Bz₁" "Bz₂" "Bz₁+Bz₂"],
markershape=[:circle :cross :star]
)
title!("z = 10 mm")
xlabel!("ρ/R")
ylabel!("Bz (Gauss)")
end
# ╔═╡ 1096c7c2-fe5b-493f-89da-3025ab7b39ec
let
ρ = range(-2u"m", 2u"m", 100)
z = range(-1u"m", 1u"m", 100)
B = fill(NaN, size(ρ, 1), size(z, 1))
for i in eachindex(ρ), j in eachindex(z)
B[j, i] = ustrip.(mfd(helmholtz, ρ[i], z[j])) ./ 1e-4
end
heatmap(ustrip.(ρ), ustrip.(z), ustrip.(B), colormap = :viridis, colorbar_title="Bz (Gauss)", clim=(0, 0.01))
xlabel!("x/R")
ylabel!("z/R")
end
# ╔═╡ 5071a082-4535-44f9-b66b-46d916d14000
md"## Anti-Helmholtz"
# ╔═╡ d2bb39e5-5396-4392-8123-456ef63b6a6a
ahelmholtz = AntiHelmholtz(loop, distance=1u"m")
# ╔═╡ 34c8ec02-d52b-44c3-863a-bcc9155c2564
let
z = range(-2u"m", 2u"m", 51)
B1 = [mfdρ(ahelmholtz.coils[1], 0u"m", z) for z in z]
B2 = [mfdρ(ahelmholtz.coils[2], 0u"m", z) for z in z]
Bhelmholtz = [mfdρ(ahelmholtz, 0u"m", z) for z in z]
plot(
ustrip.(z),
ustrip.([
B1, B2, Bhelmholtz
]) ./ 1e-4,
label=["Bρ₁" "Bρ₂" "Bρ₁+Bρ₂"],
markershape=[:circle :cross :star]
)
title!("ρ = 0 mm")
xlabel!("Radial coordinate z/R (m)")
ylabel!("Bρ (Gauss)")
end
# ╔═╡ a3964c85-8fa6-4d84-a655-d9ee9b241d78
let
z = range(-2u"m", 2u"m", 51)
B1 = [mfdϕ(ahelmholtz.coils[1], 0u"m", z) for z in z]
B2 = [mfdϕ(ahelmholtz.coils[2], 0u"m", z) for z in z]
Bhelmholtz = [mfdϕ(ahelmholtz, 0u"m", z) for z in z]
plot(
ustrip.(z),
ustrip.([
B1, B2, Bhelmholtz
]) ./ 1e-4,
label=["Bϕ₁" "Bϕ₂" "Bϕ₁+Bϕ₂"],
markershape=[:circle :cross :star]
)
title!("ρ = 0 mm")
xlabel!("Radial coordinate z/R (m)")
ylabel!("Bϕ (Gauss)")
end
# ╔═╡ afcca742-a020-4dda-846a-aadf45de6cdf
let
z = range(-2u"m", 2u"m", 51)
B1 = [mfdz(ahelmholtz.coils[1], 0u"m", z) for z in z]
B2 = [mfdz(ahelmholtz.coils[2], 0u"m", z) for z in z]
Bhelmholtz = [mfdz(ahelmholtz, 0u"m", z) for z in z]
plot(
ustrip.(z),
ustrip.([
B1, B2, Bhelmholtz
]) ./ 1e-4,
label=["Bz₁" "Bz₂" "Bz₁+Bz₂"],
markershape=[:circle :cross :star]
)
title!("ρ = 0 mm")
xlabel!("Radial coordinate z/R (m)")
ylabel!("Bz (Gauss)")
end
# ╔═╡ Cell order:
# ╟─162f2bf8-8480-11ef-0e6a-572667782062
# ╟─aa2b0d06-2708-42e9-b2b9-877a58b9664b
# ╟─5fc89931-ac7f-4f6b-baeb-6e213337233d
# ╟─23a89706-ead9-47da-bfbe-2a679890848b
# ╟─bae5bcbd-37d4-4a01-a149-c6206bd36795
# ╟─b77985a7-abd3-4852-ba80-87feb02205af
# ╠═62e6b885-7900-42b5-924b-ce18ae8380b9
# ╟─201d11b5-9a84-412e-be77-d314a7db0b62
# ╟─a3254a0c-d669-4a33-a102-87495ead9312
# ╟─7cf3754d-da3f-4537-a106-36d80dc3e795
# ╟─66add5e2-364e-4544-8c91-3cbec816e0b0
# ╟─932eb910-a15e-44b9-a245-5dd1fc4ea1c0
# ╟─1e5b9289-10da-4400-9b42-2d838c2f1c59
# ╟─6b4d7800-9f07-44d5-a336-55d9612a72d2
# ╟─61ee4135-9cef-421f-a47e-ea82e679d61c
# ╟─b5caef90-ac31-4689-8872-4d3ab3386dc8
# ╟─4dddd7c0-db87-497b-8d60-c6d2b6c52427
# ╟─ca0f1232-0203-4fb0-92b8-cd388bc4492f
# ╟─1096c7c2-fe5b-493f-89da-3025ab7b39ec
# ╟─5071a082-4535-44f9-b66b-46d916d14000
# ╟─d2bb39e5-5396-4392-8123-456ef63b6a6a
# ╟─34c8ec02-d52b-44c3-863a-bcc9155c2564
# ╟─a3964c85-8fa6-4d84-a655-d9ee9b241d78
# ╟─afcca742-a020-4dda-846a-aadf45de6cdf