# How to simulate an inverse square law dependence of radiant flux from sampled rays?

I am trying to simulate (MonteCarlo integrate) the following scenario, see sketch below (as prequel of a somewhat bigger simulation). Assume a small (point) L'Ambertian emitter, i.e. the radiant intensity is distributed as cosine $$I=I_0 cos(\theta)$$. In a distance $$d$$ and coaxially, there is a circular aperture of width $$a$$. How does the total power $$\Phi$$ transferred from the source to the aperture decrease with distance? We know, that at large distance one should obtain an inverse square law $$\Phi \propto 1/d^2$$.

This is how I tried to code:

i) Generate N samples (i.e. rays, actually just their emission angles) with distribution $$cos(\theta)$$. ii) Count only those samples/rays, that have a value $$\theta < \theta_{max} = \arctan(\frac{a}{2d})$$

iii) Do that for all distances and plot the counted samples from ii) as function of distance, see image below. The problem; Only when I square the count values I obtain an inverse square dependence. Actually, it even reproduces a textbook expression for small $$d$$.

Question: It seems that my sketch is only 2Dimensional, while the inv.-square law refers to 3D space. But, I cannot rationalize why I suddenly have to square the counts. Do I have to setup the sampling differently to get the right dependence directly? I would appreciate if someone could point out (formally) where this squaring comes from.

Thank you!

• – Kyle Kanos Sep 23 '19 at 17:29
• This probably isn't the right way to simulate the inverse square law. It is a known fact that energy is conserved. This means that for a constant power source, and for a constant aperture, a constant amount of power exits that aperture. The intensity of measured energy is proportional to the power exiting the aperture divided by the area that the energy has to cover. – David White Sep 23 '19 at 17:30
• physics.stackexchange.com/a/497304/1194 does this help? – boyfarrell Nov 1 '19 at 19:06

By choosing only a single uniform parameter ($$\theta$$), you are effectively simulating the distribution along a 2D circle. But your emitter is a 3D emitter. So you should be creating either a distribution that is uniform on the surface of a sphere, or use two separate angles (such as $$\theta$$ and $$\phi$$) with the appropriate limits.
• if i do that, assuming radial symmetry w.r.t. angle $\phi$, for each sample i would get another random number in [0,2$\pi$]. then, i would go on to step ii) from the original post, and just end up with the same number of samples that have small enough $\theta$. am i getting this wrong? – bebissig Sep 23 '19 at 19:43
• @bebissig, does $\theta$ represent the (3D) angle from the ray to the normal, or does it represent only the "on page vertical" angle from the normal (similar to the "latitude" of the ray)? – BowlOfRed Sep 23 '19 at 22:57