phetsims / wave-interference

"Wave Interference" is an educational simulation in HTML5, by PhET Interactive Simulations.
MIT License
18 stars 5 forks source link

Design review for scaling aperture as a function of wavelength #370

Closed samreid closed 5 years ago

samreid commented 5 years ago

In order to show how the diffraction pattern changes for a fixed aperture size and a varying wavelength, we scale the input to the 2D FFT based on the wavelength. After experimentation, I settled on this rule for scaling:

// Deviation from the default wavelength, in nm
const scaleDifference = ( wavelength - DEFAULT_WAVELENGTH ) / DEFAULT_WAVELENGTH;

// More frequency => more diffraction
const scaleFactor = 1 - scaleDifference * 1.5;

For example, at the default wavelength, the scaleFactor is 1, and at a wavelength of 380nm, the scaleFactor is 1.38 and at a wavelength of 780, the scaleFactor is 0.21.

@arouinfar and @ariel-phet can you please review this behavior and let me know your thoughts? If you want to change it, please let me know different coefficients for the rule above or a different function to compute scaleFactor.

ariel-phet commented 5 years ago

@samreid I will write a more detailed explanation later, but I think what we are going to need to do is set up actual dimensions in the model...get things correct for the airy disk, and base everything off that. It looks like in my initial dive into things, that our assumptions are a bit off, but I will put some numbers and such down in this issue (probably later today).

ariel-phet commented 5 years ago

The short story is that we are seeing numerical artifacts when we exist the far-field condition, and that the dimensions we are labeling our aperture need to be scaled up quite a bit for more "typical" dimensions of such an experiment. We will want to re-calibrate everything to work nicely within the far-field range. Below is going to be some documentation for those conditions.

Alright, let's begin with the governing physics for the airy disk and the conditions we need to meet. Let's also choose some basic dimensions for our setup.

Physics:

  1. For the FFT to be valid we need to be "in the far field"

  2. The condition for the far field is d>2*D^2/λ where: d = the distance from aperture to screen D = aperture diameter λ = wavelength

  3. The airy disk is the fourier transform of the aperture in the far field. The conditions for minima are given by sinθ = mλ/D where: m = a number derived from zero's of the J bessel function divided by 2*π (1.22 for first minima) D = aperture diameter λ = wavelength

Dimensions:

  1. To calibrate we should choose some reasonable dimensions of our setup Distance from aperture to screen = 1 m Size of screen (fairly typical) = 10 cm x 10 cm Wavelength for calibration = 500 nm Apertures in the 10's to 100's of microns range (see MIT video below for an example)

  2. I asked @samreid to make a change so that on my screen the diffraction screen is approximately 500px x 500 px

Resources

  1. Wolfram Alpha circular aperture calculator
  2. Wikipedia Near vs Far-Field
  3. [Video of basic airy disk diffraction] (https://www.youtube.com/watch?v=rmg1XyOSAk0)
  4. Old but useful diffraction calculator for first 3 minima
ariel-phet commented 5 years ago

Setting up the conditions above in a situation with some reasonably round numbers and a clear first minima we see that currently we have something like: wavelength = 500 nm chosen aperture in sim = 370 nm displacement of first minima on screen = 60 pixels corresponds to 1.2 cm (50 pixels per cm) corresponding aperture size for calibration = 50 microns (5e-5 m)

calibration

ariel-phet commented 5 years ago

Given the conditions stipulated for the far-field, we should start to see numerical artifact when we exceed an aperture diameter of about 500 microns (for 500 nm wavelength).

Converting what we saw above, things should start to look a little whacky at around 3700 nm aperture in the current sim scaling, and we see some numerical artifacts just creeping in, since we are crossing the boundary to where the Fourier transform no longer applies:

near field

by 4000 nm we see the airy disk pattern breaking down

airy

ariel-phet commented 5 years ago

So to stay in the far field (for our range of wavelengths and assuming the dimensions above)

For 380 nm wavelength, we should keep the aperture below 435 microns (3220 nm currently in sim) For 780 nm wavelength, we should keep the aperture below 625 microns (4625 nm currently in sim)

ariel-phet commented 5 years ago

@samreid we should discuss, but my current recommendations for the sim would be:

  1. For the circular aperture, make the current 3000 nm size in the sim be labelled 400 microns, and make that the largest value of the slider, Make the current 370 nm size in the sim be labeled 50 microns and have that be the lowest value on the slider. (So basically reduce the slider range from 370 nm to 3000 nm, and then relabel it as 50 microns to 400 microns, or 0.050 mm to 0.400 mm)

  2. Keep that aperture size range for all other patterns, using there approximate diameter (so for the grid, the largest diagonal distance being about 3000 nm in the current sim)

  3. The "scale factor" should basically just correspond directly proportionally to the wavelength. So if you half the wavelength the first minima should appear half the distance on the screen (we should be able to check calibration this way).

samreid commented 5 years ago

Notes from discussion with @ariel-phet:

DESIGN QUESTIONS

arouinfar commented 5 years ago

use microns vs mm in the controls?

@samreid @ariel-phet I think it makes sense to keep the aperture controls in nm, so students can more easily compare to the wavelength.

Relabel the 1000nm |<-->| would be 133.84 microns. That is an odd number, so shrink it to 100 microns = 0.1mm indicate the dimensions on the fft result, it will be 10x10 cm^2. Show a 1cm |<---->| indicator

For the scale bars, we might want to keep those in the same units instead of mixing microns and cm. I don't think nm is the right choice, but perhaps mm would work well here?

arouinfar commented 5 years ago

indicate the distance between the aperture and the screen?

I'm not sure that showing the precise distance in the sim adds any pedagogical value. However, the Teacher Tips could certainly indicate that the distance is large (on the order of a meter), or even provide the precise value.

ariel-phet commented 5 years ago

@arouinfar I think mm could be fine for scales on both the aperture and screen views

However, I think using nm for the aperture dimensions is problematic unless you want to use scientific notation (500 microns is 500000 nm), perhaps putting everything besides the wavelength in mm makes sense? If the scale on the aperture view is mm, isn't it natural to have the control in mm?

samreid commented 5 years ago

More notes that may come in handy:

// relabel values for new ranges.  Relabel 3000 nm as 400 microns.
        //   Relabel 370 nm size as labeled 50 micron
        // Relabel the 1000nm |<-->| as .....
        console.log(Util.linear(370,3000,50,400,1000)); // 133.8403041825095 microns, convert to 100 microns = 0.1mm
samreid commented 5 years ago

If the scale on the aperture view is mm, isn't it natural to have the control in mm?

It seems we are deciding between:

// A
50 μm ----- 400 μm

// B
0.05 mm ----- 0.40 mm

On the one hand, μm is somewhat an obscure measurement. On the other hand, showing ranges in the 0.05-0.4 range is somewhat unwieldy.

Our new coding convention is to code the units directly in the model, so this is not something that can be easily factored out and it will save us the most time to decide on this in advance. It sounds like @arouinfar and @ariel-phet are leaning toward "mm" so I'll start there, but please stop me if you think there's a good chance we'll switch to something else.

UPDATE: I'll follow a mixed approach of coding values like 50E-3. This will clearly mark all the places where we are opting in to mm. If we decide to go with μm I can simply delete all the E-3. If we decide to go with mm then I can multiply them out. So it's not too important to decide between them right away.

samreid commented 5 years ago

I've completed an initial pass of the checklist in https://github.com/phetsims/wave-interference/issues/370#issuecomment-484262232. Next steps:

@ariel-phet can you please look into it, and let me know what else remains to be done for this issue?

ariel-phet commented 5 years ago

@samreid I checked on master, and everything looks pretty spot on (getting the correct values for minima for a range of aperture sizes and wavelengths, within measurement error).

The one change I would make is cut off the low end of the aperture size at 0.04 mm for square and circle.

The units question should probably have @kathy-phet involved and we can answer at a design meeting.

ariel-phet commented 5 years ago

@samreid I am assuming you have not yet changed the scaling of the pictorial view of the aperture?

samreid commented 5 years ago

The one change I would make is cut off the low end of the aperture size at 0.04 mm for square and circle.

Changed in the preceding commit.

samreid commented 5 years ago

@ariel-phet and I discussed the pictoral view of the aperture over slack, and I committed to show the aperture rectangle at 1/2 size and the aperture pattern at 1/4 size. Ready for review.

ariel-phet commented 5 years ago

@samreid I think this all looks good, To me this screen is getting now to the final "pixel polish" stage.

ariel-phet commented 5 years ago

Marking for design meeting, so we can decide on units, and look over with the team.

samreid commented 5 years ago

@ariel-phet can you please help us complete this issue soon?

ariel-phet commented 5 years ago

Everything is consistently in mm for the aperture dimensions. Closing.