Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

How to limit processing demand simulating electromagnetic trajectory

  1. Sep 17, 2014 #1
    so suppose i have a wire given parametrically by C(t)=x(t),y(t),z(t), and i run a current of I amps through it. to find the total B field i would sum up the contributions over the length of the wire, and (please tell me if im wrong) the total B field due to the wire at point p=xp,yp,zp would be


    where [itex]\hat{C}'(t)[/itex] is the unit vector tangeant to C and m is the permeability of free space, and the bounds of the integral would be t0 and t1 where the curve begins and ends.

    So heres the problem:
    while i was programming to find the trajectory of a charged particle due to a current through the wire, i realized that i need to calculate the integral(numerically) on every time step to find the B field at that point in space. this is very inefficient and, with my computer, impossible. I was wondering if there is any way i can calculate the integral only once and be able to use that to find the magnetic field at all points in space?

    edit: i just noticed i posted this in the wrong forum can mods please move this?
    Last edited: Sep 17, 2014
  2. jcsd
  3. Sep 17, 2014 #2


    User Avatar
    2017 Award

    Staff: Mentor

    Why every time step? Does your wire move?

    Depending on the shape of the wire, you might be able to exploit some symmetry or be able to neglect some parts. If that does not work, in general it is very tricky to save some time on those integrals. Do you really need the magnetic field everywhere?
  4. Sep 17, 2014 #3
    The wire is stationary, its kind of hard to explain why i have to do the integral at every time step, but ill try

    warning really messy math.
    Im basically doing 3 integrals here:
    [itex]B_{x}=\frac{mI}{4\pi}\int\frac{y'*(z_{p}-z)-z'*(y_{p}-y )}{((x_{p}-x )^{2}+(y_{p}-y )^{2}+(z_{p}-z )^{2})^{3/2}*\sqrt{x'^{2}+y'^{2}+z'^{2}}}dt[/itex]

    [itex]B_{y}=\frac{mI}{4\pi}\int\frac{z'*(x_{p}-x)-x'*(z_{p}-z )}{((x_{p}-x )^{2}+(y_{p}-y )^{2}+(z_{p}-z )^{2})^{3/2}*\sqrt{x'^{2}+y'^{2}+z'^{2}}}dt[/itex]

    [itex]B_{z}=\frac{mI}{4\pi}\int\frac{x'*(y_{p}-y)-y'*(x_{p}-x )}{((x_{p}-x )^{2}+(y_{p}-y )^{2}+(z_{p}-z )^{2})^{3/2}*\sqrt{x'^{2}+y'^{2}+z'^{2}}}dt[/itex]

    now, basically x,y,z and x',y',z' are functions of t, while xp, yp,zp are constants as far as the integration goes, and i want a general numerical solution to the integral for all xp, yp,zp
    so, seperating even further, i get

    [itex]a=\int\frac{y'}{((x_{p}-x )^{2}+(y_{p}-y )^{2}+(z_{p}-z )^{2})^{3/2}*\sqrt{x'^{2}+y'^{2}+z'^{2}}} dt[/itex]

    [itex]b=\int\frac{y'*z}{((x_{p}-x )^{2}+(y_{p}-y )^{2}+(z_{p}-z )^{2})^{3/2}*\sqrt{x'^{2}+y'^{2}+z'^{2}}} dt[/itex]

    [itex]c=\int\frac{z'}{((x_{p}-x )^{2}+(y_{p}-y )^{2}+(z_{p}-z )^{2})^{3/2}*\sqrt{x'^{2}+y'^{2}+z'^{2}}} dt[/itex]

    [itex]d=\int\frac{z'*y}{((x_{p}-x )^{2}+(y_{p}-y )^{2}+(z_{p}-z )^{2})^{3/2}*\sqrt{x'^{2}+y'^{2}+z'^{2}}} dt[/itex]

    [itex]e=\int\frac{x'}{((x_{p}-x )^{2}+(y_{p}-y )^{2}+(z_{p}-z )^{2})^{3/2}*\sqrt{x'^{2}+y'^{2}+z'^{2}}}dt [/itex]

    [itex]f=\int\frac{x'*z}{((x_{p}-x )^{2}+(y_{p}-y )^{2}+(z_{p}-z )^{2})^{3/2}*\sqrt{x'^{2}+y'^{2}+z'^{2}}} dt[/itex]

    [itex]g=\int\frac{x'*y}{((x_{p}-x )^{2}+(y_{p}-y )^{2}+(z_{p}-z )^{2})^{3/2}*\sqrt{x'^{2}+y'^{2}+z'^{2}}} dt[/itex]

    [itex]h=\int\frac{y'*x}{((x_{p}-x )^{2}+(y_{p}-y )^{2}+(z_{p}-z )^{2})^{3/2}*\sqrt{x'^{2}+y'^{2}+z'^{2}}} dt[/itex]

    [itex]i=\int\frac{z'*x}{((x_{p}-x )^{2}+(y_{p}-y )^{2}+(z_{p}-z )^{2})^{3/2}*\sqrt{x'^{2}+y'^{2}+z'^{2}}} dt[/itex]

    these are definite integrals (im still getting the hang of this latex thing lol)
    the idea is i could sum all of these up, multiply some of them by xp or yp or zp, and get the field at all points, but unfortunately, i have those pesky p's on the bottom of the fraction, so i cant figure out a way to seperate them. if i knew a general way to deal with this i could simply do several integrals only once which isnt so bad.

    Damn physics for making force a function of distance! :P
    Last edited: Sep 17, 2014
  5. Sep 18, 2014 #4
    note: im beginning to think the sqrt(x'2+y'2+z'2) term doesnt belong there. i really wish there were more people here to help me :(
  6. Sep 18, 2014 #5


    User Avatar
    2017 Award

    Staff: Mentor

    I don't see where that sqrt term comes from either. Your integral is (or should be) the Biot-Savart law.

    If (!!) you need to know the field at "all" points in space, then yes, you'll have to calculate many integrals. How many, depends on the required precision for the fields. You can pre-calculate x', y', z'(t) because it is the same in every integration.
    And I don't see any time-dependence here.
  7. Sep 18, 2014 #6
    damn. i wonder if i could approximate the curve over small intervals with a polynomial, then (provided the B field due to the approximation of the wire is an elementary integral), i could add up the field due to the approximating segments.
    it seems like the best choice.

    ive been looking around and found this thing called "bezier curves", ive never heard of them before, so im trying to figure out how they work, and if theyll work with this problem

    the sqrt term shouldnt be there (my mistake), but i still have the same problem. really i only need to find the field at the locations where a particle will be at some time, but that still requires doing an integral at each time step
    Last edited: Sep 18, 2014
  8. Nov 26, 2014 #7
  9. Nov 27, 2014 #8
    Also, noticed another possible problem. does the force depend upon the thickness of the wire?
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook