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: Releases · ylinmtl/flashlight-sim · GitHub

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 calibrated to Convoy L6

19 Thanks

Thanks for stopping by, Probably!

1 Thank

Is building an online interface version of it realistic?

2 Thanks

Oh this is amazing!!
I was looking for a similar solution for a very long time.
Thank you for making this!!
Really appreciate it!
Also, is there a way to update the library of emitters? I want to test the fireflies emitters like FFL351A (3535), FFL505A (5050), FFL5009D/R(5050), FFL909A(9090)?

2 Thanks

I was thinking about doing that. In its current form, it’s tricky because it takes a lot of processing power. It would only be able to serve one user at a time.

I was thinking maybe it would work if I pre-generated all of the combinations and put them up with a beamshot comparison-style interface. However, you would lose the ability to modify any of the settings.

I’ll keep thinking about it. Open to suggestions!

2 Thanks

Thanks!
For sure. I’ll add those when I get home tonight and update the app so you can take adatasheet or a lumen vs current plot and generate the values to add to the library

Maybe progressively caching the results and reusing them if the parameters are the same but running the full simulation if not, but then only once?

1 Thank

An unrelated question: what would it take to parametrize some typical TIRs for a Library?

I updated the app: Release v0.0.3 · ylinmtl/flashlight-sim · GitHub

I added the FFL351A, FFL505A and FFL909A. Had an LLM pull the values from koef3’s plots. Didn’t have info for the FFL5009D.

I also added a “New” button to let you create new emitters. I added a “Simple” mode for the emitter output so you can just put voltage, current and lumens. It’ll ask you for the emitter name when you click “Save”

2 Thanks

That’s a good idea. I can probably reduce some of the variables too to cut down on the permutations and compute. I’ll do a quick build when I get some time to test out the feasibility and let you know.

I would love to model TIRs but they have more “hidden” parameters that aren’t easy to define parametrically. There’s the physical dimensions that are easy to measure. Then there’s an inner cavity, the lens in the middle, the curve of the wall and the surface texture at the face. None of these have a standard shape like a reflector does. I think short of the manufacturers willingly sharing the design files, it would be difficult and expensive to get a meaningful library going.

2 Thanks

Hey @Probably ,
I guess you made that LLM to pull these emitter data :saluting_face::saluting_face:, awesome job !!!
Well, FFL5009D and FFL5009R are both the same emitter, FFL5009D is just a doomed version of FFL5009R.
Thank you so much!
it was a very quick update; I really appreciate it.
Thank you once again
Good day

Hi @Probably ,
The new version is excellent.

I have attached a screenshot with 4 sections.

Section 1 looks fantastic, where is shows a realistic image of the reflector, emitter and the gasket in use, a huge leap in terms of visualising a build. It’s helping as I recently started to build custom flashlights and I always wanted to visualise the beam pattern rather than build everything and find it out way. I wanted to understand the maths and physics on the emitter, reflector and the gasket, and how each plays its role in the final beam pattern.

Section 2 looks pretty clean and informative. I love the options that you have introduced to add new emitter data either in Simple or Advanced mode; super easy to work with and super helpful.

Section 3 & 4 In this version, sections 3 & 4 are stacked as the earlier version was showing up on each other, distorting the beam pattern plotting. Now it looks super clean.

Thank you once again for this tool and for such a quick update.

Looking forward to interacting with you more.

Good day.!!

1 Thank

Awesome tool!
How do you get the data for the reflector? is diameter enough to extrapolate?

1 Thank

Thanks, good to hear that you like it! Let me know if there’s anything else you would like to see.

I used this prompt with ChatGPT or Gemini to generate the values:

I attach a screenshot of the Lm/Ifand Vf/If plot. If I don’t have the height or the emitting surface size, I also attach a picture of the LED package with the footprint size and tell it to estimate.

Btw, in the screenshot you shared, there’s 2 warning messages (circled in green). The emitter doesn’t fit the opening for the reflector or the gasket hole. You’ll get some shadowing from the bottom of the reflector and the gasket. You can either modify the “Opening Dia (mm)” value for the reflector if you plan on modifying one, or use the “Convoy L21A/L21B 13mm” for the 13mm preset.

Based on the part geometries, the emitter is also a bit out of focus (circled in yellow) of the reflector. In this case, it’s 0.65mm too low. You can gain some throw if you reduce the thickness of the gasket.

2 Thanks

Thanks!

You need the diameter, the height and the opening size to define a new reflector. The rest you can leave as default. If you can measure the wall thickness (thickness around the rim) and base thickness (thickness at the opening at the bottom), it’s even better, but it’s usually close enough with the defaults.

If you leave the opening size as 0.0, it will assume an opening size is the smallest size that can fit the emitter.

1 Thank

this is genuinely useful. review beamshots are all over the place with exposure n white balance, so comparing the same emitter across reflectors at fixed settings beats scrolling thru 20 reviews.

feature idea if ur taking them: preset ‘classic combo’ buttons for beginners — same LED in a smooth reflector vs behind a TIR. the eternal flood vs throw question, shown instead of told.

2 Thanks

A suggestion: querying emitters’ library is a great service by itself. I was wondering, since @koef3 includes these in some form in the reviews albeit for a single current, that maybe also listing basics on light quality of the emitter like: CCT, Duv, CRI(Ra)/R9 or TM30 Rf/Rg could be useful even if not used in computations?

1 Thank

Hi @Probably ,

Thank you for pointing out 2 crucial areas to look forward for key information.
This was a random test to get the look and feel of the new interface and specs of the FFL emitters, which you have added.
If you see the emitter i.e. FFL909A, is a 9090 footprint and the gasket I selected was 11mm 7070 and its not supposed to fit at all.
Luckily, thanks to your creation, this tool can easily point out issues/mismatches like this.
I personally thank you for the tool and the information it gives out to make real-time adjustments for my mods.
Thank you once again!

Good day!

1 Thank

Thanks.

The tool is awesome. but the barrier to uses it is some waht high. (by 2026 standards :smiley: )
maybe this in very similar form could exist on as web based tool?!

like this:

1 Thank

Thanks, happy to hear that you find it useful. That’s the use case I had in mind when I built it.

I’m open to all ideas and suggestions! The tricky thing with TIRs is that there’s a few parameters that need special measurement techniques to obtain. Almost impossible to find without help from the manufacturer or to physically get one and measure. Perhaps I can just get some Convoy TIRs just to have some examples to show.