Message: Re: Optical Photons Spectrum  Not Logged In (login) 
Thank you Benton. I saw your previous posting as well and I have used your method from the start but I wanted to understand more what is going on here. A resolution of 1/nm is more than enough to correctly sample the emission spectrum. However, the sampling procedure gives me optical photons in regions where I should have no photons at all. I will post back once I am finished with my investigation.
Regards, Dragos On Fri, 21 Jan 2011 23:21:27 GMT, Benton Pahlka wrote: > Hi, > > Just my two cents. For my simulations, I have text files that I read in > for each optical property. Each file contains 500 data points, one for > each integer wavelength (which I convert to from the energy), in a range > from 200 nm to 700 nm (as this is the relevant range for my purposes). I > read the files in and store them in an array. This produces very smooth > output spectra for me. > > Benton > > On Fri, 21 Jan 2011 23:05:55 GMT, Gumplinger Peter wrote: > > > I'll try to explain the photon energy sampling with words although a > > simple graph would explain it much better and easier. > > > > If you have a spectrum that is defined at discrete locations and you > > want to sample from this spectrum, you have the two simplest choices: > > > > (1) You can either brute force sample with the rejection method  slow  > > or (2) you can resort to the faster integral method. The integral method > > was chosen. > > > > This means that you need to first integrate the spectrum and make a new > > vector which is monotonically increasing and holds the integral of the > > spectrum to the left of the bin in question. The (linear) integral of a > > spectral bin F(x) is the width of the bin times the average y=f(x) at > > the bin's edges. > > > > During simulation a flat random number is taken from zero to the > > integral vector's largest entry: Y_max=F(x_max). For this number (Y) we > > now find the corresponding integral vector's left bin, x_i, then sample > > x above the bin's lower limit, x_i, by linearly interpolating the > > integral vector's entries at the bin edges, F(x_i) and F(x_i+1). > > > > If you think about it, what that produces is a flat spectrum in x (the > > photon energy) within the bin because the line connecting the bin's > > edges Y_i=F(x_i) and Y_i+1=F(x_i+1) is a straight line. > > >

to: 