# Field around a coil

1. Oct 16, 2008

### trilex987

First of all, this is not homework (before anyone suspects). I'm just doing this out of hobby and expanding my education.

I've been trying to come up with distilled expressions for force on a magnetic dipole , anywhere in space around a simple coil. I started out with these expressions:

http://www.netdenizen.com/emagnettest/offaxis/?offaxisloop

but when I entered them into Mathematica, It gave strange results (if the equations are correct). Here are a couple of screenshots of the relative field magnitude across 2D space slice:

The first picture shows the equations,and the second picture is the graph.

http://img100.imageshack.us/img100/5897/92168291iw8.jpg [Broken]

http://img399.imageshack.us/img399/5261/49623354lc2.jpg [Broken]

In case the graph orientation is confusing, the elevation of "terrain" is relative field magnitude (regardless of field direction), and X axis is offset from the coil center, while the Y axis is offset along the center axis of the coil.
The diagram is only one side from the center of the coil.
The diagram is all wrong, the field should be strongest around the actual wire (which is at 1, on the X axis), instead its zero there, and has a funny lattice shape going from the center of the coil.

Can anyone help me out by telling me where did I go wrong?
Or are those equations I picked up on that website wrong in the first place?
If that is the case, does anyone know the right ones?

Thank you

Last edited by a moderator: May 3, 2017
2. Oct 16, 2008

### trilex987

Nevermind, I have found the right equations. These were faulty (I should give notice to the author of that web page).

I managed to come up with expressions for distribution of force , but they are huge, nothing one could ever hope to do on paper.
It takes about several pages of a Word-type document just to write down the 2D function of force.

3. Oct 16, 2008

### marcusl

The exact expression for the field off the axis of a loop is complicated no matter how you approach it. As for your script above, you incorrectly defined $$\alpha,\beta, \gamma$$. Try it again.

If you are far away from the loop then it will look like a dipole as well, and the expression for the force between 2 dipoles is very simple.

4. Oct 17, 2008

### trilex987

I think this one is right At least it matches the usual on-axis approximation formula, on axis.

http://img362.imageshack.us/img362/8100/90308956sv9.jpg [Broken]

These expressions are for Field/(Field in center) (that's why there's a a/pi in the beginning)
These are taken from Electromagnetic Theory from J.A.Stratton with a little tweaking to make them relative to zero point field and using x and y instead of r and z.

But there is a problem when I try to find the gradient.
I won't post the expression because its huge, but here is what I did.

I used the above equation as a starting point, to get field from two coils (running opposite currents), making a magnetic trap between them. (Not Helmholtz coils! They have currents in the same direction)
And then I combined it all into one expression (radial components add up, vertical components cancel each other).
Here is the field for both coils:

http://img80.imageshack.us/img80/6762/27477814jc9.jpg [Broken]

Looks about right, and again matches the on-axis approximation perfectly.

Now I'm trying to find the gradient (just the magnitude of the gradient in any point regardless of direction), and I get suspicious results.

The approach I had (please tell me if it is the wrong way to do it) was
to get partial derivatives of the field equation. Partial derivative according to x
for the x component of gradient and , y for y component.
And then finding the root of the sum of their squares to get the magnitude
of gradient regardless of direction in any point on this plane.

What I get around the coil axis is nothing similar to the gradient I get by derivation of on-axis approximation.

Here is how it looks like. (this is directionless magnitude of the gradient across the plane)
I've rotated it so that you can better see the on-axis profile

http://img413.imageshack.us/img413/2858/33797978gl2.jpg [Broken]

I doubt this is correct, but any insight would be appreciated

Last edited by a moderator: May 3, 2017
5. Oct 17, 2008

### marcusl

You've messed up all your coordinates. Equations in the link of your OP use a spherical coordinate system-- x is the loop axis and r is the radial distance. If you want to replace x by y, well, go ahead (although you run the risk of confusing yourself as apparently has happened.) But you cannot then set r to "x" because x is a Cartesian coordinate always normal to y. It is not a radius. Add the fact that your definition of $$\alpha$$ is flat wrong and there's no hope.

If you properly code up what's in the link, you'll get the right answers.

6. Oct 17, 2008

### trilex987

I revisited the first equation I used.
Actually the problem wasn't in the coordinate system. The equation is formulated for cylindrical system (not spherical),
the problem was in wrong definition of Alpha, as you said.
But It's not my fault, I just copied what was on that site. The Equation is ok, it's just that alpha is not correctly defined.

With corrected alpha, I managed to get the same results as with the other equation I later used (from the J.A. Stratton book)

But the question of gradient is still there.
Do you have any comments on what I posted later about the gradient? Was my approach wrong there?

Last edited: Oct 17, 2008
7. Oct 17, 2008

### marcusl

Sorry, I didn't look carefully at the link--you are right about cylindrical, not spherical coordinates.

There are two more gradients, Hxy and Hyx in addition to the two you list: Hxx, Hyy.
Don't know whether those interest you or not.

You don't provide details of your calc, but I wonder if you went astray here:
Remember that you've called the cylindrical radius "x". It's not x, it's cylindrical radius rho, so you can't take simple partial as you would in cartesian coordinates.
Be sure you calculate the rho gradient using proper cylindrical expressions.

What is your eventual goal? If you are trying to develop a coil system that produces a uniform z-directed gradient (I prefer z as coil axis), there are better approaches.

8. Oct 17, 2008

### trilex987

Actually, I think the two gradients I came up with are neither of the 4 you mentioned.
What these two are , are x and y gradients of the magnitude of field, rather than gradients of the components of the field vector.

I think for calculation of force, these are the two I need (gradients of magnitude of field).
Correct me if I'm wrong.

Which gets me to your next question. The final result is suppose to be a complete algorithm for calculation of the force vector affecting any magnetic dipole moment within the space enclosed between two coils (which make a magnetic trap)

So, I don't think I need Hxx or Hxy or Hyy or Hyx gradients, bur rather |H|x and |H|y gradients, isn't that right?

By the way, let me ask you a question if you don't mind.
Suppose now I have a field vector in some place, and a gradient vector.
Of course if I put a dipole in that place, it will align with the field vector.
And then the gradient will be the source of force on that dipole.
Is the vector of that force, always parallel with the gradient vector , or is it
a dot product of dipole and gradient vectors?

And as for, cylindrical coordinates. I've renamed it back to z and r later on, to avoid confusion.
But, I'm not yet, sure how the difference between Cartesian and cylindrical coordinates present a problem in this case,
when I'm limiting myself to 2 dimensions.
I'm doing all the calculations across a 2D slice. When you throw away the angle in the cylindrical system, doesn't that leave
you with a 2D Cartesian system?
Have in mind that my end goal is a 2D function , not 3D

Last edited: Oct 17, 2008
9. Oct 17, 2008

### trilex987

Hm... the actual force vector

is the gradient of the dot product of mag dipole vector and field (induction) vector...

so, would it be correct to simply make a dot product of the field and dipole, and then use the derivative of that as the force vector?

10. Oct 17, 2008

### marcusl

Sorry, that's wrong. You need field gradients.
Neither. It is

$$\vec{F}=\vec{\nabla}(\vec{m}\cdot\vec{B})$$

(in cgs units)
No. Think of a simple example like standing waves in a rectangular versus a cylindrical pipe with closed ends. Transverse solutions ("your 2D slice") consist of cosines and sines in the first case but Bessel functions in the second even with azimuthal symmetry.

11. Oct 17, 2008

### marcusl

Not derivative, gradient. It's a vector quantity! If you've been using Stratton, then you should be well familiar with vector calculus in cylindrical coordinates.

12. Oct 17, 2008

### trilex987

I think I'm slowly getting a little bit over my head, I'm not formally educated in physics

But before I give up on this, I'll ask a few more questions.

Would this be the right way to calculate the force vector, I think this is the development of the grad ( m dot B)
for dummies like me, to a more obvious form:

It's a bit tiny but, it's not my scan, I just found it on the internet, it is from
Portis, A." Electromagnetic Fields: Sources and Media"

Is this what I'm looking for?

As for cylindrical derivatives. I am only aware that usually, when doing a
partial derivative in cylindrical coordinates there is a correction done to the
angular component (just multiplying it by 1/r) , but the z and r components are done in a regular way. Is there something more I should be aware of?

As for the last comment, I'm not sure what was your objection, you need to do a derivative to get a gradient, don't you?

Last edited by a moderator: May 3, 2017
13. Oct 18, 2008

### trilex987

I think it finally works. Now I've calculated force using the approach I posted in the previous post, yesterday.
I've checked it on couple of places along the z axis, by comparing it to the on-axis formula for H and dB/Dz , and the results are identical.
I have no way of checking whether off-axis results are correct, but here it is (this formula assumes very small diamagnetic or paramagnetic objects of volume V to avoid integration across the actual object). Also the H and B components of the vector are values relative to H in the center of one coil (I/2R) (that's why there is H0 (which is field in center of a singular coil) square times permeability in front)

http://img337.imageshack.us/img337/11/72946546ow5.jpg [Broken]

http://img134.imageshack.us/img134/8083/26344052kd8.jpg [Broken]

The output of the algorithm will not be in magnitude as this diagram but in the vector format

Last edited by a moderator: May 3, 2017