# NTNUJAVA Virtual Physics LaboratoryEnjoy the fun of physics with simulations! Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/

## Easy Java Simulations (2001- ) => Collaborative Community of EJS => Topic started by: lookang on October 13, 2011, 11:42:29 pm

Title: Ejs Open Source Single Slit Diffraction Model
Post by: lookang on October 13, 2011, 11:42:29 pm
Ejs Open Source Single Slit Diffraction Model by Fu-Kwun Hwang remixed by lookang

reference:
Superposition of several waves  http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=2082.0 by Fu-Kwun Hwang

[ejsapplet]

other interesting single slit ejs applets
Single Slit diffraction http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=128.0 by Fu-Kwun Hwang
Like: intensity

http://youtu.be/sjmBcm84iA4

Title: Re: Ejs Open Source Single Slit Diffraction Model
Post by: lookang on October 13, 2011, 11:48:55 pm
changes:

redesign the way the scalar-Field is calculated using a dynamic way that is always correct and to scale instead of the older way of 2 separate scalar-field.
Code:
for(int j=0;j  for(int k=0;k   zsum[j][k]=0;
}
}

for(int i=0;i yc=yi+i*dy; // lay the source in y
ycc[i] = yi+i*dy; // by lookang for drawing source

for(int j=0;j //  if (x     x=xmin+j*d;
//    }
//    else if (x>x1){
//   x=x1+j*d;
// r=x-x1; // r is distance from array point x to slit position x1
//   x2=(x-xc)*(x-xc);
//   }
for(int k=0;k   y=ymin+k*d;

if (x      r=x-x1; // r is distance from array point x to slit position x1
zsum[j][k]=Math.sin(kw*r-omega*t)*n; // need n to compensate for the magnitude
}
else if (x>=x1){
r=Math.sqrt((x-xc)*(x-xc)+(y-yc)*(y-yc));
zsum[j][k]+=Math.sin(kw*r-omega*t);
}

}
}
}
add ns to n and draw the sources with checkbox
add wavelength and drawing checkbox etc
add width and checkbox
add type and colormode for different visualization especially cool is the 3D view that required a square array 
add step of step by step animation

enjoy!

Title: Re: Ejs Open Source Single Slit Diffraction Model
Post by: lookang on October 14, 2011, 09:11:59 pm
http://en.wikipedia.org/wiki/Huygens%E2%80%93Fresnel_principle http://upload.wikimedia.org/wikipedia/commons/thumb/6/60/Refraction_on_an_aperture_-_Huygens-Fresnel_principle.svg/2000px-Refraction_on_an_aperture_-_Huygens-Fresnel_principle.svg.png

Huygens proposed that every point to which a luminous disturbance reaches becomes a source of a spherical wave, and the sum of these secondary waves determines the form of the wave at any subsequent time. Same Huygens-Fresnel principle Refraction on an aperture (slit) but notice the secondary source space equally apart and start from center ending 1/2 space from the edge of slit which is more logical than end at the edge of the slit. Same Animation Huygens-Fresnel principle Refraction on an aperture (slit)

Huygens assumed that the secondary waves traveled only in the "forward" direction and it is not explained in the theory why this is the case. He was able to provide a qualitative explanation of linear and spherical wave propagation, and to derive the laws of reflection and refraction using this principle.

http://electron9.phys.utk.edu/phys136d/modules/m9/diff.htm

Diffraction is a phenomenon whereby waves appear to bend around obstacles, or appear to spread out after passing through a small orifice. The occurrence of
diffraction allows us, for example, to hear sounds from sources that are
hidden from us by some obstacle or other. http://www.physchem.co.za/OB12-wav/diffraction.htm the map reminds me that to easily remember this diffraction occurs when w slit width is comparable to  λ wavelength.

Diffraction is a wave phenomenon and is also observed with water waves in a ripple tank. When wave passes through a small opening, comparable in size to the wavelength, in an obstacle (in this case yellow rectangles) , the wavefront on the other side of the opening resembles the wavefront shown below. http://electron9.phys.utk.edu/phys136d/modules/m9/diff.htm

In the Ejs simulation case, when slit width is comparable in size to the wavelength same animation when slit width is comparable in size to the wavelength

The wave spreads around the edges of the obstacle (yellow in this case).  This is the phenomenon of diffraction.  Therefore, diffraction is "spreading out " wave phenomenon.

http://electron9.phys.utk.edu/phys136d/modules/m9/diff.htm has some photo of the real ripple tank. http://electron9.phys.utk.edu/phys136d/modules/m9/diff.htm when slit width is comparable in size to the wavelength http://electron9.phys.utk.edu/phys136d/modules/m9/diff.htm when slit width >> in size than the wavelength

in Ejs,I managed to capture a similar computational model. when slit width is comparable in size to the wavelength assuming 6 secondary sources, diffraction is noticeable slit width >> in size ( w = 6*λ ) than the wavelength assuming 10 secondary sources. A wave goes largely straight when the size           of the slit is much larger than the wavelength

I love Phet research and simulation

this is a great simulation called Wave Interference, under the water tab, the simulation breaks the 2D with a side view.

I managed to figure out a cool way to generate a 3D visualization is Ejs. when slit width is comparable in size to the wavelength assuming 6 secondary sources, diffraction is noticeable slit width >> in size ( w = 6*λ ) than the wavelength assuming 10 secondary sources. A wave goes largely straight when the size           of the slit is much larger than the wavelength

my favorable visualization is Spectrum visualization of when slit width is comparable in size to the wavelength assuming 10 secondary sources, diffraction is noticeable Spectrum visualization of slit width >> in size ( w = 5*λ ) than the wavelength assuming 10 secondary sources. A wave goes largely straight when the size           of the slit is much larger than the wavelength

other interesting slit simulation are: