magnetic field equations

capacitortree, Sun Jan 08 2012, 06:00PM

I am trying to write a program to optimize coil parameters to get the greatest magnetic field density. I looked up the equations for magnetic field density, and found B = u0 * NI/L for the b field density. But this equation says that the field strength is dependent on the # of turns per meter (N/L) and current. This would seem to imply that the best coil would always be the one with the shortest possible length, 1 turn per layer, and multiple layers, because it would have the highest current. Having more turns on each layer wouldn't affect the magnetic field density, it would only negatively impact the amount of current available because of the increased resistance. I always thought field strength was proportional to the total # of turns and current. Am I interpreting the equation incorrectly, or is the best coil really one with the shortest length?
Re: magnetic field equations
Turkey9, Sun Jan 08 2012, 08:24PM

To maximize the field density, you want to maximize turns per meter, not just turns. The best coil will be one with the highest number of turns per unit length, not the shortest.
Re: magnetic field equations
capacitortree, Sun Jan 08 2012, 10:26PM

But resistance goes up if you increase the length and add more turns per layer, so current goes down, and since the total number of turns has no effect on field density, I would still think that a shorter coil is better, at least up to some practical limit.
Re: magnetic field equations
Turkey9, Mon Jan 09 2012, 06:59AM

That equation assumes ideal wires, so I'm not completely sure what the best configuration would be. The resistance would not go up enough adding two or three turns per layer to negate the advantage of more turns. But isn't this what your program is going to find out? I'd start by fixing the number of layers however, too many variables isn't always a good thing.
Re: magnetic field equations
klugesmith, Mon Jan 09 2012, 07:38AM

Welcome to 4hv, CT.

You are using a very simple formula, which is strictly valid only for an infinite, straight solenoid. Might give a reasonably accurate value near the center of a finite solenoid with large length/diameter ratio. For stubby coils, flat ones, ones with finite thickness, or ones with ferromagnetic material nearby, you need other formulas, or numerical field solvers.

Here's a reference I like. Link2 Check out the closed-form formula for "On-axis fields due to round, finite, air core solenoids". See if it matches your formula in the limit, as the length becomes very large and the place of interest is well inside the coil.

[edit] Also please note:
1) the magnetic attraction of a small iron particle depends on the -gradient- or space derivative of the magnetic flux density. That's why there is no force within an infinite solenoid, or in the center of a finite one.

2) as you add turns, you could increase the wire thickness to keep the resistance constant. You will find that the current in any efficient coilgun coil is limited by inductance more than by resistance. A more accurate way to model the attractive force on a magnetic core is from the derivative of inductance with respect to core position.
Re: magnetic field equations
Tetris, Mon Jan 09 2012, 10:11PM

You're such a gauss. (boss) :D

EDIT:
3568d471b87a
Re: magnetic field equations
Pinkamena, Wed Jan 11 2012, 11:29PM

I have written such a program in Wolfram Mathematica. You can alter every coil and cap bank parameter (length, inner diam., outer diam., wire thickness, wire resistance, capacitance, voltage, etc), and it'll give you various graphs, showing all you need to know about the firing of your coil.
I'll post the code here, but if you don't have wolfram mathematica, you can't use it for much... Unless someone re-writes it into flash or something. If anyone want to this, I'll be more than happy to explain the code in detail.
Here are screengrabs of an earlier version of the code, showing a function depending on time and coil thickness (ignore "70ms").Linkylink
And here are a screengrab of how the code I posted looks. It's depending only on time, you edit the other parameters in real-time using the sliders.More links


EDIT: How the hay do I spoiler text?

This version of the code calculates the length of the coil based on inner coil diameter and a set weight for the projectile. The smaller the diameter is, the longer the coil will be. It can easily be changed to allow for manual editing of the coil length.
"Outer radius:" Slider[Dynamic[r0], {minr0, maxr0}, 
  ContinuousAction -> False] {Dynamic[r0*10^2]}
"inner radius:" Slider[Dynamic[ri], {0.0055, maxri}, 
  ContinuousAction -> False] {Dynamic[ri*10^2]}

diam := 0.002 (*diameter wire*)
rw := 0.01954 (*ohm/meter*)
convert := 39.37
time := t
(*Activate this line of code if you want time-dependant functions \
that are dependant on another variable*)
(*Slider[Dynamic[time], {0,0.3}]*)
d := 7870 (*mass per m3*)
v0 := 300 (*cap voltage*)
c := 92.8*10^-3 (*cap capacitance*)
w := 0.400 (*weight projectile*)
magconst := 1.25663706*10^-6 (*magnetic constant*)

L := 0.5 w/(d*(ri^2)*Pi) (*lenght*)
maxL := 0.2
minri := Sqrt[0.5 w/(d*Pi*maxL)]
maxri := 0.02
minr0 := 0.0076(*ri+diam*)
maxr0 := 0.08
turnsPrLayer := Floor[L/diam]
wireLength := turnsPrLayer*2 Pi*(Sum[(ri + i*diam), {i, 0, maxLayers}])
turns := maxLayers*turnsPrLayer
beta := L/2 ri
alpha := r0/ri
maxLayers := Floor[If[(r0 - ri)/diam < 1, 0, (r0 - ri)/diam]]

(*Inductance formula*)
res := wireLength*rw 
induc := ((31.6*turns^2*ri^2)/(6 ri + 9 L + 10 (r0 - ri)))*10^-6

(*Currentformula*)
betaI := Sqrt[(1/(induc*c)) - (res^2/(4*(induc^2)))]
alphaI := res/(2*induc)
curr := (v0/(betaI*induc))*Exp[-alphaI*time]*Sin[betaI*time]

(*Voltage in caps Formula*)
v := v0 - {1/c}*
   NIntegrate[(v0/(betaI*induc))*Exp[-alphaI*tid]*
     Sin[betaI*tid], {tid, 0, time}, PrecisionGoal -> 3]
(*Energy in caps formula*)
eCap := 0.5*c*(N[v]^2)

(*F (a, b) formula*)
F := beta (ArcSinh[alpha/beta] - ArcSinh[1/beta])

(*H0 equation*)
H0 := (turns*curr*F)/(2*beta*ri*(alpha - 1))*10^-3
oersted := 4*Pi*H0/1000
jPrOe := 4000 - eCap

"Length of coil:" Dynamic[L]
"turns per layer:" Dynamic[turnsPrLayer]
"Resistance coil:" Dynamic[res]
"Length of wire:" Dynamic[wireLength]
(*"current:"Dynamic[curr]
"magnetic field:"Dynamic[H0]*)


Dynamic[Plot[oersted, {t, 0, 0.05}, PlotRange -> {0, 150}, 
  AxesLabel -> {seconds, "Oerstedts"}, Filling -> Bottom]]
Dynamic[Plot[eCap, {t, 0, 0.05}, PlotRange -> {0, 4400}, 
  AxesLabel -> {seconds, "energy left in coils, J"}, 
  Filling -> Bottom]]
Dynamic[Plot[curr, {t, 0, 0.05}, PlotRange -> {0, 800}, 
  AxesLabel -> {seconds, "current, A"}, Filling -> Bottom]]

(*These lines of code are for time-fixed simulations *)
(*Dynamic[Plot[res, {z,minr0,maxr0}, PlotRange->{-2,10}, \
AxesLabel->{coil thickness, resistance},Filling->Bottom]]
Dynamic[Plot[wireLength, {t,0,0.1}, PlotRange->{0,1000}, \
AxesLabel->{seconds,wirelength}]]
Dynamic[Plot[induc, {z,minr0,maxr0}, PlotRange->{0,0.04}, \
AxesLabel->{coil thickness,inductance (H)}]]
Dynamic[Plot[L, {z,minr0,maxr0}, PlotRange->{0,0.5}, AxesLabel->{coil \
thickness,coil length}]]
Dynamic[Plot[F, {z,minr0,maxr0}, PlotRange->{0,0.001}, \
AxesLabel->{coil thickness, function}]]*) 

(*WARNING: Extremely time-consuming to simulate*)
(*Style[Dynamic[Plot3D[H0, {z,0.00206,maxr0},{y,minri,0.015}, \
PlotRange->{0,100},AxesLabel->{coil thickness, \
coilgap}]],DynamicEvaluationTimeout->100]*)
(*Style[Dynamic[DensityPlot[curr, {z,0.00206,maxr0},{y,minri,0.015}, \
PlotRange->{-100,1000},AxesLabel->{coil thickness, \
coilgap}]],DynamicEvaluationTimeout->100]*)
(*Dynamic[ContourPlot[maxLayers, {x,0.00206,maxr0},{y,minri,0.015}, \
PlotRange->{0,30}, AxesLabel->{coil thickness,layers}]]*)
Re: magnetic field equations
capacitortree, Thu Jan 12 2012, 02:41AM

@kludgesmith
Thanks for the link. It's much nicer than reading through wikipedia.

1) the magnetic attraction of a small iron particle depends on the -gradient- or space derivative of the magnetic flux density. That's why there is no force within an infinite solenoid, or in the center of a finite one.

I guess this is why the position of the projectile in the coil matters so much, and the strongest magnetic attraction is not when the projectile is almost completely in the coil.
But I think the field max field strength would still give you a good idea of the total impulse the projectile will get from the coil.

Pinkamena, I like the graphs that your program produces. I've been having a hard time getting my python3 program to graph points directly, although I can still graph easily by copy and pasting into excel. But why did you choose to calculate the H field of the coil? I thought B fields were more accurate for solenoid coils.

I'll upload my program when I've finished it. It doesn't account for capacitor discharge but it allows you to put in a range of values to radius and length and it determines the best combo.
Re: magnetic field equations
Pinkamena, Sun Jan 15 2012, 12:07AM

capacitortree wrote ...

Pinkamena, I like the graphs that your program produces. I've been having a hard time getting my python3 program to graph points directly, although I can still graph easily by copy and pasting into excel. But why did you choose to calculate the H field of the coil? I thought B fields were more accurate for solenoid coils.

Logic
Re: magnetic field equations
capacitortree, Mon Jan 23 2012, 06:14AM

Well I finally finished the program. You can input a range of lengths, outer radii, and gauges, and it gives you the best values and some nice graphs.
It requires python3.2 and gnuplot.
It automatically outputs graphs on linux, I think it should run on windows if you comment out some code at the bottom and run gnuplot separately (there is a note about it in the program).

I think I got rid of all the bugs, but its always possible there are still some.
]coilgun7.py.zip[/file]