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

Computer simulation of ray of light passing near massive object

  1. May 14, 2015 #1
    I'd like to write a computer program that simulates and visualizes the trajectory of a ray of light as it passes near a massive object (e.g., neutron star). In other words, I'd like to model light deflection in space.

    (FWIW, I have extensive programming experience, but my physics and mathematics understanding is only slightly past what was required of me as a CS undergrad. I understand I'll have to do learn more for this project, and am eager to do so.)

    Since the light deflection is a result of spacetime curvature, I understand that the most accurate model would be based on (at least an approximation of) the general theory of relativity. "Linearized gravity" looks like it might be an adequate approximation, though still rather daunting.

    I did look over related efforts on the web: http://www.vis.uni-stuttgart.de/en/...zation-in-special-and-general-relativity.html (especially their geodesic viewing tools), http://www.spacetimetravel.org/ (especially, their "Light Deflection Near Neutron Stars"). Still rather overwhelmed about how to begin.

    I'd be quite happy to start with a very crude approximation (how far off would it be to just use Newton's law to calculate and apply gravitational acceleration at a each position at fine grained moments in time?).

    To further simplify, I'm planning to do a 2D version first. Should look similar to several of the diagrams of light deflection on the net (/insert google image search for "light deflection"). But those are almost certainly just artistic approximations, not a result of calculations, which is what I'm after.

    To boil this down to a specific question: what's the simplest* formula I can apply to model the trajectory/curvature of spacetime that a ray of light will experience as it passes near a massive object?

    (*) Simplest that gives a visually convincing result

    (I did see the post "Light ray paths near schwarzschild blackhole" that's similar, but that thread didn't come to a conclusion, and it was about black holes, which might be more difficult than say, a star?)
  2. jcsd
  3. May 14, 2015 #2


    User Avatar
    Gold Member

    Sounds like fun
    Basically you're going to need to get into linear algebra, which, at least at my school (for some stupid reason) is not required for the CS program. I started out there before I realized physics is cooler =]

    Not so sure about the linearized gravity, as I haven't read much about it, but from what I (literally just no) just read, it seems reasonable for a computational project. Also, GR is the only way to make this happen, seeing as how photons are massless.
    I'm not really familiar about these, I'll have to look into them, but basically you'll want to start with an understanding of Einsteins field equations. This is something that I, unfortunately don't have, I wish I did, and have been working on it, but... science is hard.
    I don't think it would be that bad, assuming that what you were actually doing, was using the analogy of acceleration in 3 dimensions, and doing the opposite of collapsing a sub/superscript: extend the acceleration in 3 dimensions to curvature in 4 dimensions.

    Always a good start, the 2D, that is.
    I think the simplest would be to get into Linear algebra, a little bit to understand matrices, study different vector spaces, look into curvilinear coordinates and learn how projections work in space time. Then go through and use the acceleration from Newtons gravity around your object to reverse engineer the spacetime curvature. I think that would be easier than trying to get a solution to Einstein's Field Equations from scratch.

    I hope that helped, GR is something I've been looking into a lot lately, but for probably different reasons.
  4. May 14, 2015 #3


    User Avatar
    Gold Member

    Just one comment about
    I would rather say, GR is the only way to get a correct result. Massless particles are deflected also under Newtonian gravity since the trajectory of a test particle is independent of it mass - but the result is just wrong, half the correct one : http://en.wikipedia.org/wiki/Tests_of_general_relativity#Deflection_of_light_by_the_Sun
  5. May 14, 2015 #4


    User Avatar
    Gold Member

    Touché wabbit
  6. May 14, 2015 #5


    Staff: Mentor

    This is a little bit problematic because, first of all, in Newtonian mechanics it's not clear that "massless" particles can exist, and second, if they could, it's not clear that they would be affected by gravity, since while the acceleration due to gravity in Newtonian gravity is independent of the object's mass, the presence of the force of gravity to begin with requires the object to have mass.

    The root problem here is that Newtonian physics didn't include a good theory of what light was and how it worked, and when a good theory for that was discovered (Maxwell's Equations), it proved to be inconsistent with Newtonian mechanics (because the latter is Galilean invariant but the former is Lorentz invariant). So we can't really say that Newtonian physics even includes a consistent prediction for how light will behave under gravity, since that would require a consistent underlying theory that does not in fact exist.
  7. May 14, 2015 #6


    User Avatar
    Gold Member

    Agreed, light is problematic in Newtonian gravity, but this particular case has a clear limit which I would think still qualifies as a prediction of Newtonian gravity.
    Another take would be to say that under NG light (or massless particles) should travel at infinite speed - i.e. in space but not in time, and this would give a consistent theory - I think this is true, and the spatial path should still be the limit of small-mass paths so that prediction would hold.

    But the NG prediction is the same without taking any limit for a low mass particle given enough kinetic energy to be travelling at close to c, and just as wrong I suspect, I think its incorrectness results from the incompatibility of NG with the finite-speed relativity we observe.
  8. May 14, 2015 #7


    Staff: Mentor

    Yes, this is true; the Newtonian prediction is 1/2 of the GR prediction, and there are no issues with theoretical consistency for this case.
  9. May 14, 2015 #8


    User Avatar
    Gold Member

    @BiGyElLoWhAt, one good news is that once you've handled the 2D case, you've handled them all: any trajectory lies in a plane passing through the center of the star, and the equations are the same regardless of orientation.
    One assumption you probably want to stick to though, is that the star is not rotating, for the rotating case is more complex in GR. The non-rotating case corresponds to "null geodesics in Schwarzchild geometry" (Schwarzchild geometry describes spacetime around a non-rotating mass, geodesics are free particle trajectories, and null corresponds to the massless case relevant for light).
    The treatment arriving at the equations (e.g. http://en.wikipedia.org/wiki/Schwarzschild_geodesics) is complex, not to say daunting, but if you are familiar with the Newtonian case, in a way it's not so different: the "geodesic equation" (http://en.wikipedia.org/wiki/Schwarzschild_geodesics#Geodesic_equation - this simplifies a bit, since the path is in a plane you can take ##\theta=\text{constant}=\pi/2;(r,\phi) ## are then polar coordinates in the plane of the trajectory) gives you the acceleration as a function of position and velocity, and you can integrate this numerically. While this may not be the best solution it has the advantage of not involving further complex maths.
    Those equations are ugly, but with care you should be able to program them. I am sure there must be some guides as to how to do that but unfortunately I don't have one I could point to.
    This is not particularly easy to navigate, but perhaps this is a possible route for your project? Others may have better suggestions though.
    Last edited: May 14, 2015
  10. May 14, 2015 #9
    As photons wouldn't be massless in Newtonian mechanics this is actually not an issue.

    This is just a philosophical problem. The singularity of m/m is removable and a particle with infinitesimal small mass can't be distinguished from a massless particle.

    The real problem is the classical theory of gravitation itself. In the far field it's results differ by a factor of 2 from the correct values (as already mentioned) and in the near field it must not even be used for the approximation of the gravitational potential. Thus the simulation of trajectories close to neutron stars must be based on pure general relativity.
  11. May 14, 2015 #10


    Staff: Mentor

    Really? You have a consistent theory of light as massive photons in Newtonian mechanics?

    Yes, I know Newton believed that light was "corpuscles". But he never built that concept into a consistent theory that accounted for the data on light that was available to him.

    What singularity? The force equation is ##F = G M m / r^2##. If ##m = 0##, then ##F = 0##. The fact that ##F = ma## allows you to write the equation as ##a = GM / r^2## is irrelevant; Newtonian mechanics treats the force as primary, not the acceleration.
  12. May 15, 2015 #11
    We have a consistent theory of light in quantum mechanics. That's sufficient. Photons have momentum. In classical mechanics momentum is defined as p=m·v. Therefore m must not be zero. (Don't forget that this "m" is not rest mass!)

    Newtons's second law for constant mass

    [itex]F = m \cdot a[/itex]

    and Newton's law of gravitation

    [itex]F = - \frac{{G \cdot M \cdot m \cdot r}}{{\left| r \right|^3 }}[/itex]

    result in

    [itex]a = - \frac{{G \cdot M \cdot r}}{{\left| r \right|^3 }} \cdot \frac{m}{m}[/itex]

    This equation has a removable singularity for m=0:

    [itex]\mathop {\lim }\limits_{m \to 0} \;a = - \frac{{G \cdot M \cdot r}}{{\left| r \right|^3 }}[/itex]

    There is no reason not to use it for massless particles.
  13. May 15, 2015 #12


    Staff: Mentor

    Newtonian mechanics is not a quantum theory. If by "Newtonian mechanics" you really mean "non-relativistic quantum mechanics", then you should use the latter term.

    There is nothing in Newtonian mechanics corresponding to the distinction in relativity between "rest mass" and "relativistic mass" (aka energy); there is just "mass".

    Mathematically, no. Physically, yes, because in Newtonian mechanics, as I said before, the force is primary, not the acceleration. If by "Newtonian mechanics" you really mean "relativity in the Newtonian limit", then you should use the latter term.
  14. May 15, 2015 #13
    What about the classical definition of momentum, conservation of momentum and isotropy? In relativity (that means by replacing Galilean transformation with Lorentz transformation) they result in a difference between Newton's quantity of matter and rest mass.

    What is the physically difference between ##m \to 0## and ##m = 0##? Can it be distinguished experimentally?

    What do you mean with "primary"?
  15. May 15, 2015 #14


    Staff: Mentor

    Yes, in relativity. Newtonian mechanics is not a relativistic theory.

    (Also, I'm not sure how Newton's "quantity of matter" would translate into relativity anyway.)

    In Newtonian mechanics, ##m = 0## is not physically possible; an object with zero mass does not exist. Mass is the quantity of matter in an object; ##m = 0## means no matter, i.e., no object.

    I mean that in order for an acceleration to be present in Newtonian mechanics, a force must exist. If ##m = 0##, there is no force, hence no acceleration. The fact that you can cancel out the ##m## in the mathematical formula for acceleration is irrelevant.
  16. May 15, 2015 #15
    And that's why any object with momentum must have a mass in Newtonian mechanics. For photons this means they have mass in Newtonian mechanics but no mass in relativity. Thus mass in Newtonian mechanics cannot be identical with mass in relativity.

    It turns into relativistic mass.

    That doesn't answer my question.

    If m=0 there is a force with the amount of zero. It seems this isn't really physically but rather philosophical.

    I didn't cancel it out. I calculated the limit for ##m \to 0## using L'Hôpital's rule. That means m never reaches zero. It just went infinitesimal small and therefore there is also an infinitesimal small force. If you think that this doesn't describe a massless object, you must show that a massless object is physically different from an object with infinitesimal small mass. Can you show that?
  17. May 15, 2015 #16


    Staff: Mentor

    DrStupid, I'm not trying to argue that what I'm calling "Newtonian physics" is a valid physical theory. It isn't. I'm just clarifying what I meant by it: I meant the theory developed by Newton, not the Newtonian limit of relativity, and not Newton's theory plus some ad hoc addition of "massless" objects, which nobody ever actually developed or used.

    I would say "historical". I'm not talking about any theory that anyone uses today, even as an approximation.
  18. May 15, 2015 #17
    I have access to a computer program which runs an algorithm to determine the sum of light incremental deflection angles caused by its passing the Sun over many passes through the algorithm. the final sum of the incremental deflection angles is the deflection angle caused by the Sun. There are two fundamental principles used in the algorithm. One is the deflection of the light which would be expected from Newtonian effects on objects in a gravitational field. The second effect considers the distance the light beam is from the Sun's CG to cause an additional deflection proportional to the magnitude and direction of the escape velocity vector, These two incremental deflection angles are equal and their sums for all passes through the algorithm is the total deflection angle. The program determines the amount of light path deviation in arc-seconds for any star seen at distances from 1 to 1000 solar radii from the sun's limb. Although an equation already exists to calculate the deviation instantly, the purpose of the computer program is to show that the same values can be determined by considering both the Newtonian and the escape velocity effects.
  19. May 15, 2015 #18


    User Avatar
    Staff Emeritus
    Science Advisor

    Google for "orbit of a photon in Schwarzschild geometry". You should find a hit in google books from the textbook "Gravitation", that will give you a differential equation. It will be in geometric units, though. The non-geometrized version would look something like this

    \left( \frac{1}{r^2} \frac{dr}{d\phi} \right) ^2 + \frac{1 - r_s/r}{r^2} = 1/b^2

    where r is the schwarzschild r coordinate, ##r_s## is the Schwarzschild radius of the black hole, ##2GM/c^2##, ##\phi## is the schwarzschild angular coordinate, and b is a constant of motion called the "impact paramter".

    Hopefully this is what you want, as the "schwarzschild gemoetry" is the model for the geometry of a black hole or any massive non-rotating object. Note that this differential equation this just gives the spatial trajectory, r as a function of ##\phi##, not the space-time trajectory. For the later you'd have a different equation based off the geodesic equation. Drop a note if the later is what you're looking for.

    Note that the above eq. does NOT include the effects of frame dragging which happens when the massive body is rotating. Presumably you don't need this level of acacuracy from your previous comments.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook