Skip to content

Instantly share code, notes, and snippets.

@tedyapo
Last active March 4, 2022 15:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tedyapo/68c07875c2b0d66544ad4c5e00ecb7c2 to your computer and use it in GitHub Desktop.
Save tedyapo/68c07875c2b0d66544ad4c5e00ecb7c2 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
#
# excitation coil model
#
import loopfield as lf
# field object
field = lf.Field(length_units = lf.mm,
current_units = lf.A,
field_units = lf.uT)
L = 60
d = 1.1
D = 100
layers = 5
turns_per_layer = int(L/d+0.5)
current = 1
for layer_idx in range(0, layers):
radius = int(layer_idx - layers/2 + 0.5) * d + D/2
for loop_idx in range(0, turns_per_layer):
x = int(loop_idx - turns_per_layer/2 + 0.5) * d
loop = lf.Loop(position=[x, 0, 0],
normal=[1, 0, 0],
radius=radius,
current=current)
field.addLoop(loop)
# evaluate field at center of coil
Bc = field.evaluate([0., 0., 0.])
print('Bc = ', Bc, '(uT)')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment