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

Simulation of Electromagnet Force

  1. Sep 1, 2004 #1
    Hello,
    This sounds like a silly idea, but I am trying to simulate all forces of in the universe on my computer, putting in the correct physics equations for each force, one by one.
    I was already able to simulate the force of gravity with the following formulas/equations:

    G = 6.674205043E-11 'The Universal Constant of Gravitation
    initialspeed = 0 'No additional force added.

    mass1 = 70 'Average Person

    'Earth
    mass2 = 5.98E+24 'Planet's Mass
    distances = 6378000 'On surface

    force = (G * mass1 * mass2) / distances ^ 2
    acceleration = force / mass1
    'Or
    acceleration = (G * mass2) / distances ^ 2

    'loop through time
    newposition=initialspeed * Time + (1 / 2) * acceleration * Time ^ 2)
    'Stop looping when crashed into planet


    Now, I am trying to simulate electromagnetisem. I found one formula that is probably the correct its:
    K = 8987550000 'Coulomb's Constant
    force = (K * q1 * q2) / distance

    My question is, can I use the same equation "acceleration = force / mass1" to convert this force into acceleration? If so, is mass1 equal to q1?

    If both are true, This seems to become an interesting equation as a result:
    (G * mass) / distance ^ 2 = (K * mass) / distance

    ...supposedly meaning that gravity is produced by an electromagnetic force...

    Please correct me if I am wrong.

    Edit:
    I just did the calculations.
    As an example, I made mass equal 70 and distance equal to .2

    As a result I got:
    (G*mass)/distance^2 = 1.167985883E-7
    (K*mass)/distance = 3.1456425E+12

    So.. something is wrong.



    Also, its possible that I posted in the wrong section, I am not sure where to post this since I am new to this website.. Moderators, please redirect it to the correct position if it is in the wrong section. Thanks.
     
    Last edited: Sep 1, 2004
  2. jcsd
  3. Sep 1, 2004 #2

    robphy

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    What you wrote is almost Coulomb's Law of Electrostatics.
    In your notation, it should be
    force = (K * q1 * q2) / distance2

    The correct application of Newton's Law of Motion requires you to
    write "acceleration = net force / mass1"

    mass1 is not equal to q1. q1 is an electric charge, measured in coulombs.
    (Note that G and K have units associated with the numbers you quoted.)


    Looking over what you wrote, you need to work with vector--not merely scalar--quantities if you wish to, say, model the orbit of a planet.

    You might wish to look over a text on simulations in physics, e.g.,
    http://sip.clarku.edu/ .
     
  4. Sep 1, 2004 #3
    Thanks for the response.
    Some how, I didn't notice the "2" in:
    force = (K * q1 * q2) / distance2

    A vector, not merely a scalar? I don't seem to understand what you are talking about... Can you elaborate? On the simulation, I am trying to make a visual of the actual objects, reacting to different forces. So, I would need both direction and speed. Also, as additional properties, it would have mass, length, and others... So, I suppose it would need both a vector and a scalar.. Is it possible to use both? Sorry if this is an elementary question.. I am relatively new to some math calculations in physics, and I am teaching all the information to myself, with many of the resources on the internet.
     
  5. Sep 2, 2004 #4
    But right now, the main question is, can I use the same formula as used in gravity to change force into acceleration, to use in electromagnetism too?

    In the rewritten form:
    acceleration = force / q1

    Can I use this formula to change electromagnetism force into acceleration? Or is a different formula needed?
     
  6. Sep 2, 2004 #5
    You are reffering to Newtons second law. This tells you, given a force, what the accelleration will be, independent of the source of the force. So even when you're delaing with electromagnetism you use acceleration = force / mass (note that this only applies when the mass of the object is constant).
     
  7. Sep 2, 2004 #6
    robphy, I finally understand what you ment about working with a vector.. So, right now, I'm trying to my the 1-deminsional calculation into a 2d visual of the objects moving.
     
  8. Sep 3, 2004 #7
    I dont know what language you are programming in... but from what i have read vpython might be good for you... it already has a vector "type" so to speak thats easy to manipulate and it will draw simple 3d scenes with little programming at all... there are also alot of basic physics sims already available that you could look at and modify or what ever... note: the language is indent specific.

    with the following....
    'loop through time
    newposition=initialspeed * Time + (1 / 2) * acceleration * Time ^ 2)
    'Stop looping when crashed into planet

    as your position is changing... you should be recalculating the force based on the new position in each iteration or you are using constant force...

    i am not sure how you are using Time... i am assume you are using it as a dt? like a really small increment of time, in which case the following is what i think:

    also i dont see initalspeed being updated in each iteration... so i dont think you are really conserving momentum of the object... but are actually calculating on each loop what the displacement would be if the object was stationary and now feeling an acceleration for the first time at this location.

    otherwise if Time is total time elapsed... you dont seem to be updating it in your loop. also v0 + (1/2)at gives average velocity as t gets bigger im sure that will start adding significant error.

    i like to look at it as

    dp/dt = fnet, so the rate of change of momentum is force (fnet should be the vector addition of all forces acting on the object... electric, gravity etc...

    so

    dp = fnet*dt this would tell you how much momentum changed for when a force fnet was applied for a time dt.... the smaller dt the more accurate the calculation....

    then update total momentum

    p = p+dp

    now you can get the velocity from p=mv so the current velocity is now
    p/m or p*(1/m)

    so updating position

    newpos=oldpos+(p/m)*dt

    (note fnet, p and dp should be vectors)
     
  9. Sep 3, 2004 #8

    robphy

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    In the VPython installation (see http://vpython.org ), there is a demo program called orbit.py. You might like to look at the source. It's under 30 lines of code.
     
  10. Sep 3, 2004 #9
    Well, programming is actually one of my strongest points, so, I would continue writing the program instead. Anyway, my program works a bit differently.. I'm coding it to have the most posible simplicty, to be able to handle all the forces simitaniusly, with correct timing.
    Anyway, I tried running VPython, but it just freezes, when I try to run it...
     
    Last edited: Sep 3, 2004
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?