This is the web version of EJS interface
EJS version 4.2.7
  1. Title=Multiple Slit Diffraction
  2. Author=Fu-Kwun Hwang,Robert Mohr, Wolfgang Christian
  3. Keywords=multiple slit difraction, interference
  4. Level=beginner
  5. Language=English
  6. Abstract=Original model by Fu-Kwun Hwang adpted for Ejs 4.1 by Robert Mohr and Wolfgang Christian at Davidson College.
  7. CaptureTools=true
  8. DataTools=true
  9. LanguageTools=true
  10. EmersionSupport=false
  11. UseInterpreter=true
    NameValueTypeDimension
    NameValueTypeDimension

    Init Page

    double dx=(xmax-xmin)/(nx-1); for(int i=0;i<nx;i++){ XP[i]=xmin+i*dx; } lightPalette(lambdar);

    Cons Page

    _view.singleSlitTrial.clear(); _view.multipleSlitTrail.clear(); lambda=lambdar*um; if(dr<1.2*ar) dr=1.2*ar; a=ar*um; d=dr*um; if(N==1)singleSlit=true; else singleSlit=false; double I,alpha,cst,dy,sc,beta,cst2,I2; Imax=a*a*3.e8/N; dy=(spectrumy2-spectrumy1); for(int i=0;i<nx;i++) { sc=XP[i]/Math.sqrt(XP[i]*XP[i]+L*L)*xscale; alpha=pi*a*sc/lambda; beta=pi*d*sc/lambda; if(alpha==0)I2=I=Imax; else { cst2=Math.sin(alpha)/alpha; if(singleSlit) { cst=cst2; } else { cst=cst2*Math.sin(N*beta)/Math.sin(beta)/N; } I=cst*cst; I2=cst2*cst2; } for(int j=0;j<ny;j++) { Intensity[i][j]=I*Imax*N/2; // nonlinear scale for screen } YP[i]=spectrumy1+dy*I*yscale; YP2[i]=spectrumy1+dy*I2*yscale; }
    public void lightPalette (double wavelength) { for(int i=0, n=colors.length; i<n; i++){ int r=i; int g=i; int b=i; //colors[i]=new Color(r,g,b); float h=(float)(-2.5*wavelength+1.625); float s=1; if(wavelength>=0.65){ h=0; s=(float)(1-wavelength)/0.35f; } if(wavelength<=0.35){ h=0.75f; s=(float)(wavelength/0.35f); } colors[i]=java.awt.Color.getHSBColor(h,s,(float)(i/255.0)); } }
    // computes intensity in response to mouse action public void computeIntensity () { double x=_view.DrawingPanel.getMouseX(); double sc=x/Math.sqrt(x*x+L*L)*xscale; double alpha=pi*a*sc/lambda; double beta=pi*d*sc/lambda; if(alpha==0) { mouseReading=Imax*yscale; return; } double cst=Math.sin(alpha)/alpha; if(!singleSlit){ cst=cst*Math.sin(N*beta)/Math.sin(beta)/N; } mouseReading=cst*cst*yscale; }
    EJSVIEW: Click link to view it's content
    Control variables:(testing)
    double,double,int,double,double,double
    title="Multiple Slit Diffraction"
    layout=border
    visible=true
    location="-1,2"
    size="640,447"
    background=BLACK
    position=center
    autoscaleX=true
    autoscaleY=true
    minimumX=xmin
    maximumX=xmax
    square=false
    pressaction=computeIntensity ()
    dragaction=computeIntensity ()
    showCoordinates=true
    yFormat=null
    xyExpression="mouseReading"
    xyFormat="I = 0.00"
    z=Intensity
    autoscaleZ=false
    minimumZ=0
    maximumZ=0.05/yscale/N
    expandedZ=2
    minimumX=xmin
    maximumX=xmax
    minimumY=spectrumy1
    maximumY=spectrumy2
    plotType=GRID
    levels=100
    colormode=colors
    floorcolor=BLACK
    ceilingcolor=colors[255]
    showgrid=false
    inputX=XP
    inputY=YP2
    visible=showXY
    measured=false
    norepeat=true
    connected=true
    lineColor=MAGENTA
    inputX=XP
    inputY=YP
    visible=showXY
    measured=false
    norepeat=true
    connected=true
    lineColor=RED
    position=east
    variable=yscale
    minimum=1.0/N
    maximum=40.0/N
    orientation=VERTICAL
    enabled=true
    foreground=255,128,0
    tooltip="Intensity Scale"
    position=south
    layout=border
    borderType=LOWERED_ETCHED
    position=east
    variable=showXY
    text="Envelope"
    foreground=128,0,192
    position=west
    image="/org/opensourcephysics/resources/controls/images/reset.gif"
    action=_reset()
    background=128,128,0
    foreground=128,128,0
    tooltip="reset simulation"
    position=center
    layout=border
    position=center
    variable=xscale
    minimum=0.1
    maximum=2
    tooltip="Distance along screen."
    position=west
    text=" y = "
    foreground=192,192,0
    position=east
    variable=xscale
    format="0.00"
    action=xscale=Math.max(0.1,xscale); xscale=Math.min(xscale,2);
    size="40,24"
    foreground=192,192,0
    tooltip="Distance along screen."
    position=north
    layout=GRID:1,4,0,0
    borderType=LOWERED_ETCHED
    variable=N
    value=2
    minimum=1
    maximum=20
    format="N = "
    foreground=255,192,0
    tooltip="number of slits"
    position=center
    variable=ar
    minimum=1.0
    maximum=100.
    format="Slit Width = 0 $\mu$m"
    foreground=255,192,0
    variable=dr
    value=99.86734
    minimum=1.0
    maximum=300
    format="Slit Separation = 0 $\mu$m"
    enabled=!singleSlit
    foreground=255,192,0
    variable=lambdar
    value=0.399988
    minimum=0.1
    maximum=1.0
    format="Wavelength = 0.00 $\mu$m"
    dragaction=lightPalette(lambdar);
    foreground=255,192,0