Solved

To find optimum number for smoothing in detector viewer

  • 29 August 2021
  • 6 replies
  • 461 views

Hello,

 

I understand that irradiance in NSC simulation result and in the real world has a gap because real world has infinite number of rays and simulation uses limited number of rays.

So, I usually use maximum number for smoothing to make the gap small.

But I also think that smoothing(averaging) could lose accuracy.

Hence, I think I need to balance out between “smoothing” and accuracy of result, based on number of rays in a detector.

If the detector has enough number of rays, smoothing may not be necessary.

For instance, every pixels in a detector has a ray, smoothing may not be necessary to get the result for the smallest gap to the real world.

Understanding those, I am wondering if there is a criteria or a guidance for getting an optimum number of smoothing.

Does anybody know that?

 

Regards

Kazu

 

icon

Best answer by Csilla Timar-Fulep 31 August 2021, 14:41

View original

6 replies

Userlevel 5
Badge +2

Hi Kazu,

Thank you for your post here!

As you said, there is a trade-off between simulation time and noise. Please see the recommendations in this knowledgebase article about how to estimate the signal to noise ratio and how to balance the simulations with the number of rays, number of pixels and smoothing:
Detectors used in illumination design – Knowledgebase (zemax.com)

Also, you might want to change to Sobol sampling to achieve a better signal to noise ratio:
Understanding Sobol sampling – Knowledgebase (zemax.com)

Best,
Csilla

Userlevel 4
Badge

A good first order approximation for quite uniform distributions is that N rays in P pixels gives N/P rays per pixels, and that the expected standard deviation is sqrt(N/P) (Poisson statistics)

So for 10x10 = 100 pixels and 10000 rays, you have 100 rays per pixel and should expect an standard deviation of 10 rays (10%).

A few remarks:

  • Sobol sampling (used by default) can help for noise but it can create very hard to debug problems. I remember spending 1 day trying changing every possible parameter/setting in a simulation to understand why I had some periodic oscillations that I did not expect. After 1 day of hair-pulling, I found that the source was set to Sobol sampling (the default, which I did not know it was) and that was the reason for these oscillations. Using random sampling fixed the problem. It does not happen often, but when it happens...
  • Some settings can help with noise but at the expense of accuracy (as with smoothing as you pointed out). Ray splitting is one of them. Simple ray splitting is more noisy, but is always accurate, while the alternative can be systematically wrong.

So I would always advise you to use double-check at some point without Sobol sampling and with simple ray splitting: if the overall distributions match (check for the total power in particular), then you can use to the less noisy settings.

 

Hello Csilla-san and Ray-san,

 

Thank you very much for your answer for this.

I also went through those articles Csilla-san recommended and found those was very helpfull.

 

Then, I tried to check random sampling in simulation with intentionally few rays to see rays change.

When I checked with “Source Gaussian”, I could see rays change every time when I run simulation.

However, when I use a LED source model, rays did not change even if I re-run simulation many time. The model also did not allow me to change sampling method and it keeps saying “random”.

 

I guess even with that model with no ray change, the theory is applicable to that model as well.

 

Thanks,

 

Regards

Kazu 

 

 

 

 

Userlevel 4
Badge +1

Hi Kazu,

If you are modeling the LED source using a Source File object that uses a .DAT or .SDF source file, and if you are using every single ray listed in the Source File, then there is no randomness to it. Every single ray has a unique starting (x,y,z) location and a direction vector as specified in the Source File. However, if you are only using a subset of the analysis rays from the Source File (setting the # Analysis rays to a value smaller than the total # of rays stored in the source file), then you can turn on the Randomize? flag to randomize the subset of rays selected from the Source file. The Sampling Method option is greyed out for Source File object. 

As for Source Gaussian, there is a certain randomness to the ray set launched by OS, and you can specify the Sampling Method as either Random or Sobol. You can find a description on what these two Sampling methods mean in the Help file at The Setup Tab > Editors Group (Setup Tab) > Non-sequential Component Editor > Object Properties (non-sequential component editor) > Sources > Random vs Sobol Sampling.

Best,

Hui

Hello Hui-san

 

Thank you very much for your additional information.

I tried that but zemax says “the ray file supports more than Randomize ray option supports and hence disable randomize….”

And I could not turn on randomize.

 

Thanks

Kazu

 

 

Userlevel 4
Badge

Hi Kazu-san,

 

In the Non-Sequential section of the System Explorer, you can increase the “Maximum Source Files Rays In Memory” to be at least as big as the number of rays in that file. Then, the “randomize“ setting should work.

 

Reply