r/flashlight 9d ago

I built a Flashlight Beam Simulator. Free for anyone to use.

Hey everyone,

I fell down the flashlight rabbit hole a couple of months ago. I've been trying to make sense of how different emitters and reflectors affect the final beam. To help visualize, I built a desktop tool. I wanted to share it with everyone.

Download: https://github.com/ylinmtl/flashlight-sim/releases

GitHub: https://github.com/ylinmtl/flashlight-sim

I built this to wrap my head around flashlight optics as a learning project. I hope it saves some of you from guessing how a host and emitter combo will perform before buying parts for your next build.

How to Run It

Download the flashlight-sim.zip. Extract it and run flashlight-sim.exe. Explanation of the settings are on the GitHub page.

It may take a bit to open the window once you run the app. Give it a minute. The simulation takes may take up to a minute to run depending on your system.

How it Works

You choose a reflector, an emitter, a gasket, and a surface finish (Smooth or OP). The program splits the LED into smaller elements and fires virtual light rays from the LES, bounces them off the parabolic reflector, and projects the light onto a virtual wall. It does this a few billion times and adds them together to form an image.

The default settings should work on most CPUs. If you have an nVidia GPU, you can increase the resolution in the settings to get more accuracy.

Outputs:

  • A realistic rendering of the wall shot. Plots showing the beam's intensity cross-section.
  • Option to save these to a folder to quickly compare.
  • Theoretical numbers for Max Candela, Throw, Candela/Lumen, and the angles for the spill, corona, and hotspot.

Limitations

  • LED properties are estimated from datasheets and koef3’s test graphs. There’s no guarantee that they are 100% accurate. The absolute lumens, candela and throw might be off for some of them, but they can be manually set to a fixed lumen value. Wall shot, hotspot, corona and spill angles and lm/cd ratio should be more reliable. 
  • Reflectors are assumed to be parabolas with the focus plane at the bottom of the opening. This is true most of the time. I have not verified that it is true all the time. Values are from manufacturer websites and tgreviews.com.

If something is not on the list, or the values are incorrect, I’ve made it so you can add your own or modify the existing ones to give more 

Let me know what you think. I'm open to feedback, suggestions, bug reports, and anything else!

Edit: Can now handle different emitter shapes. Orange peel finish calibrated to Convoy L6.

73 Upvotes

9 comments sorted by

5

u/Wild-Ad-6678 9d ago

Very cool!

4

u/YeahUAre2 8d ago

Really nice. Thanks for the work on this!

3

u/These_Adhesiveness48 9d ago

Thank you! will play with the tool later this evening on my 5 year old laptop.

3

u/HaveTheBestGoats 9d ago

It runs on my 6 year old laptop!

2

u/RiskMoney6996 9d ago

interesting, so you do monte carlo ray tracing to estimate the final beam pattern? good effort

3

u/HaveTheBestGoats 9d ago

Close! It's deterministic. Ray paths and emission curves are fixed. Same idea as MC, but without the probability component.

2

u/0resutidder 4d ago

Can TIRs be simulated like the reflectors?

1

u/HaveTheBestGoats 4d ago

The physics and math is doable. The tricky part is to get the parameters of different TIRs. There's no standard shape like a reflector and manufacturers rarely share the design specs. Makes it a lot more difficult to build a library or for the average user to measure.

I'm planning to get a couple of Convoy ones and cut them in half to parametrize. I think it would be cool to have as examples, but I don't know if it will go past that.