1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

I Magnetic Field at any Point Around a Finite Straight Wire

  1. Aug 9, 2016 #1

    First of all, this question does stem from graduate work, but it seems far too simple to tag "advanced".

    I am looking to write some code to simulate the force from a railgun. The first step in doing this (from a tutorial I found) is to find the magnetic field at any point within the current "loop" created by the railgun. (The back end / power source is considered to be a straight connection between the rails in this case).

    I wrote a bunch about everything I didn't understand in this tutorial, decided to do it my own way, and happened to do almost everything the way the tutorial did it. So a lot of this has been adjusted to meet my new questions, and to serve as a resource if anyone else is stuck with this. Hopefully I've adjusted things sufficiently.

    "New Questions":
    - What is wrong with the tutorial's "final answer" ? (In the last equation in part 1 of the tutorial, the author mentions it is "all wrong").
    - How do I tell which angle is theta1 and which is theta2?
    - Various specific questions on the final answers

    (1) Tutorial: http://web.mit.edu/mouser/www/railgun/physics.html
    (2) Teacher's Notes on "Griffith" (Pages 11 to13): http://teacher.pas.rochester.edu/PHY217/LectureNotes/Chapter5/LectureNotesChapter5.pdf
    (3) Griffith's Intro to Electromagnetics Text Book (Pages 216 and 217) : by Griffiths.pdf
    (4) Additional Reference (Pages 9-4 to 9-6) : http://web.mit.edu/8.02t/www/materials/StudyGuide/guide09.pdf

    Problem Approach

    I need to find the magnetic field at a point (P) within a rectangular wire loop. I can get this by summing the contributions of each of the four finite wires. Then, using the Biot-Savart Law listed in the tutorial:

    B = (mu0I/4z*pi) * [sin(theta2) - sin(theta1)]

    I simply need to find sin(theta2) and sin(theta1) using the x and y coordinates of the point, the length of the rails (L), and the separation between them (W). This is how the tutorial approaches the problem. However, the figure listed in the tutorial does not provide a theta1 and theta2. It provides a theta and a phi. But through my efforts, I discovered the equations actually refer to figure 5.19 in source (3) on page 217. I still cannot understand why the tutorial refers to theta1 and theta2 the way it does, as I come up with everything reversed when I use this figure. This is significant because the final equation will have a difference in it, and thus it is significant since I'll either do (sin(theta2) - sin(theta1)) or (sin(theta1) - sin(theta2)).

    I am using the set of equations from (3) and referencing figure 5.19 and the picture in the tutorial for variable names.
    I am using a single origin at the bottom left of the current loop for each rail length

    P = point of interest
    z = perpendicular distance from rail to point P
    l = distance along the rail from P to the vertex of theta1 or theta2 (the bottom line of the triangle, best shown in the picture in the tutorial)
    r = length of the line from the angle vertex to P (hypotenuse of triangle, best shown in the picture in the tutorial)
    L = length of the rail to the differential length being evaluated
    W = rail separation
    theta1 = angle from rail to point P at the start of the section (x = 0 for rail 1)
    theta2 = angle from rail to Point P at the differential length (x = L for rail 1)

    B = (mu0 * I / 4 * pi * z) * [sin(theta2) - sin(theta1)]
    and in all cases r = sqrt( l ^2 + z^2 )

    Rail 1 (the bottom rail)
    z = y
    l1 = x
    r1 = sqrt( l1^2 + z^2 ) = sqrt( x^2 + y^2 )
    l2 = L - x
    r2 = sqrt( l2^2 + z^2 ) = sqrt( (L-x)^2 + y^2 )

    sin(theta1) = l1 / r1 = x / sqrt(x^2 + y^2)
    ***sin(theta2) = l2 / r2 = (L - x) / sqrt( (L-x)^2 + y^2)

    Rail 2 (the top rail)
    z = (W - y)
    l1 = (L - x)
    r1 = sqrt( l1^2 + z^2 ) = sqrt( (L - x)^2 + (W - y)^2 )
    l2 = x
    r2 = sqrt( l2^2 + z^2 ) = sqrt( x^2 + (W - y)^2 )

    ***sin(theta1) = l1 / r1 = (L - x) / sqrt( (L - x)^2 + (W - y)^2 )
    sin(theta2) = l2 / r2 = x / sqrt( x^2 + (W - y)^2 )

    z = (L - x)
    l1 = y
    r1 = sqrt( l1^2 + z^2 ) = sqrt( y^2 + (L - x)^2 )
    l2 = (W - y)
    r2 = sqrt( l2^2 + z^2 ) = sqrt( (W - y)^2 + (L - x)^2 )

    sin(theta1) = l1 / r1 = y / sqrt( y^2 + (L - x)^2 )
    sin(theta2) = l2 / r2 = (W - y) / sqrt( (W - y)^2 + (L - x)^2 )

    Back / Power
    z = x
    l1 = (W - y)
    r1 = sqrt( l1^2 + z^2 ) = sqrt( (W - y)^2 + x^2 )
    l2 = y
    r2 = sqrt( l2^2 + z^2 ) = sqrt( y^2 + x^2 )

    sin(theta1) = l1 / r1 = (W - y) / sqrt( (W - y)^2 + x^2 )
    ***sin(theta2) = l2 / r2 = y / sqrt( y^2 + x^2 )

    The *** denotes a place where the tutorial has a result different from mine. In all of these cases there is a (-) in front of the equation, and I do not understand where it comes from.

    Also, after the tutorial's "final answer", it lists a correction which has mu0 * I / 4 * pi as the coefficient to all of this. How would the 1/z factor out ? My plan was to compute each rail individually, since this code would not be too computation intensive. But I am still curious where the 1/z goes.

    In summary, I would like to know:
    - What is wrong with the tutorial's "final answer" ? (In the last equation in part 1 of the tutorial, the author mentions it is "all wrong").
    - How do I tell which angle is theta1 and which is theta2?
    - Where do the (-)'s come from in the sin equations?
    - Where does the 1/z go in B = (mu0I/4z*pi) * [sin(theta2) - sin(theta1)] ?

    Extra Note: Sources (3) and (4) use different equations. Source (3) uses (sin(theta2) - sin(theta1). Source (4) uses (cos(theta2) + cos(theta1). Source (4) defines the angle differently, so the sin in (3) and the cos in (4) would be equivalent, and Source (4) integrates from -theta rather than 0, which changes the sign.
    Last edited: Aug 9, 2016
  2. jcsd
  3. Aug 9, 2016 #2


    User Avatar
    Gold Member

    As for the confusion with θ1, θ2 locations, they are shown here:


    You may also ( writing some code anyway ) use Biot-Savart directly, doing a numeric integration using cross-products, etc., along several pieces of wire in one calculation. I'm doing so at the moment, it's fairly easy :smile:.
    Last edited: Aug 9, 2016
  4. Aug 11, 2016 #3
    Thank you for the additional reference. That is another way I could do it if I find issues later on, but do you think there is a particular reason to take the integral directly? My understanding was that the "sin - sin" formula was an analytic solution to the integral. Thus (so long as you are only integrating over straight lines) it would capture everything the integral does.
  5. Aug 11, 2016 #4


    User Avatar
    Gold Member

    Yes it is, and the result is exact.
    It's easy to find the analytic solution as for a straight wire. You may find approximated solutions for a solenoid ( very long, many turns ), but they are far from exact for a short solenoid with few turns. Here Biot-Savart can find the exact result ( ±0.01% ) anywhere inside/outside the solenoid, and for other sophisticated coil shapes as well. You just have to describe the path that the conductor follows and choose a current, then your computer can integrate a result in any x,y,z point.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted