lundi 27 avril 2020

Random Walk in a 3D spherical coordinates system-Python

I am currently attempting to map and show the path of a photon from the center of the sun until it reaches the surface and is emitted. I also want to show the time taken for this to happen.

So far all I have done is set the parameters (density of sun, Thompson cross-section, mass of electron, mass of proton) and using these I was able find the mean free path in the sun for a photon. I know that I will have to set an array of some sorts, and create random numbers for each random walk. I do not know what to do to make the random walk so that the photon can go in any direction in the x, y or z values.

I also do not know what I should loop in order to create this random walk. I need it so that the random walk will stop when d is equal to or greater than the radius of the sun. I know that d=l*sqrt(N), where l is the average size of each step, or mean free path, and N is the number of steps taken.

Lastly, I would not know where to start with plotting the results. I would like to show an animation of the photon travelling through a sphere from the center, where the sphere would resemble the sun.

Below is the only code I have so far, any help would be much appreciated.

from random import random, seed, randint
import numpy as np
import matplotlib.pyplot as plt

N=100000
rho=1408.6 #the mass density of the sun
thompson=6.65*10**-29 #Thompson cross-section for an electro 
proton=1.67*10**-27 #mass of a proton
electron=9.11*10**-31 #mass of an electron
radius=6.9634*10**8 #radius of a sun
c=2.99*10**8

mfp=(electron+proton)/(rho*thompson*np.sqrt(2))
timestep=mfp/c



Aucun commentaire:

Enregistrer un commentaire