Sun is mainly consisted of huge amount of Hydrogen and Helium with the total mass of 2*10^30 Kg, and so due to the internal gravity, the central mass become increasingly hot and dense, eventually initiating thermonuclear fusion in its core. As the result of this thermonuclear fusion the photons will be produced in the form of energy.

figure1. thermonuclear reaction

The speed of light is almost 3*10^8 m/s. Knowing that the radius of Sun is roughly 0.7 M Km, it should take 2.3 seconds for a photon to reach the sun’s surface when it is produced. But sophisticated simulation using powerful supercomputers tells us that this is not the end of the story. They suggest that it will take actually in the order of **Million years** for the photon to get out of the Sun when it is produced! In other words by the time when this Fusion reaction stops, it will take million years for **Sun to not shine**! This phenomenon is due to the fact that inside the Sun everything is so dense and therefor photons will be absorbed by Atoms and then emit in random direction and this happens so many times.

figure2. Different layers inside the Sun

This simulation aims to find that how much time will it take for a Photon which is created in the center of Sun due to Fusion to reach the Sun’s surface and get out. But we want to follow basic and simple approach. However at we will see at the end of this simulation our result is quite acceptable and says the same order of other sophisticated results. Here is a sample path which photon passes.

figure3. Random walk [2]

This kind of “walk” of photon which has a random direction each time is called “Random Walk”. The vector ‘d’ shows the total net distance which photon has passed and the length vectors ‘vi’ show the path after each absorption and emission. So we would have:

figure3. Cont. [2]

Due to the complete randomness the term two sigma will vanishes. Then we have:

d=l√N

which according to the concept of ‘l’ it is the total length that each time takes for photon to get absorbed which is called “Mean Free Path” (mfp).

figure4. Mean Free Path

figure5. Calculation of mfp

figure6. Calculation of total time

figure7. Putting real values

figure7. Final Results

Following is the MATLAB program to simulate the path of three different photons. You can download and see the animation on your computer.

figure8. MATLAB simulation

**Reference
**-[1] Wikipedia

-[2] An Introduction to Modern Astrophysics (2nd Edition) by Bradley W. Carroll (Author), Dale A. Ostlie (Author)

**Source Code
**MATLAB Code

Presentation

Especial Thanks to Ehsan Ebrahimian who helped me through this project.