NTNUJAVA Virtual Physics Laboratory
Enjoy 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 15, 2011, 09:54:27 pm



Title: Ejs Open Source Double Slit Diffraction Model
Post by: lookang on October 15, 2011, 09:54:27 pm
Ejs Open Source Double Slit Diffraction Model by lookang based on the works of Fu-Kwun Hwang found here

reference:
Ejs Open Source Single Slit Diffraction Model by Fu-Kwun Hwang remixed by lookang http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=2314.0
Superposition of several waves http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=2082.0 by Fu-Kwun Hwang
other good applets
JDK Double slit interference by Fu-Kwun Hwang http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=20.0


Title: Re: Ejs Open Source Double Slit Diffraction Model
Post by: lookang on October 16, 2011, 08:22:38 pm
changes made:
redesign the slits to be 2 instead of the older single slit
made the 2 slits symmetric centered with moved by y slider
add the 2 slits scalarField by introducing the idea of superposition from the top set of secondary sources
Code:
for(int i=0;i yc=yi+i*dy; // lay the source in y
 yctop=yitop+i*dy; // duplicate for top slit
 ycc[i] = yi+i*dy; // by lookang for drawing source
  ycctop[i] = yitop+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));
   rtop=Math.sqrt((x-xctop)*(x-xctop)+(y-yctop)*(y-yctop));
   zsum[j][k]+=Math.sin(kw*r-omega*t)+Math.sin(kw*rtop-omega*t);
   }
  
  }
 }
}

add path difference tools to allow sense making that when path difference = integer of wavelength, correspond to constructive interference. and 1/2 of integer is destructive interference like in Ejs Open Source Ripple Tank Interference Model java applet http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=2067.0

17 october 2011
add d separation = ycentre2*2 to align with teaching and learning

this simulation is made possible by the open source codes shared by Fu-Kwun Hwang, the true master teacher!

enjoy!