/*****************************************************************************
*         McStas instrument definition URL=http://www.mcstas.org
*
* Instrument: Test_Lens
*
* %Identification
* Written by: E. Farhi/C. Monzat
* Date: Dec 2009.
* Origin: ILL
* %INSTRUMENT_SITE: Tests_optics
*
* Demonstrate focusing effect of refractive lenses
*
* %Test: lambda=10 position_PSD=8.2 Detector: Last_PSD_I=2.6829e-19
*
* %Description
*
* Very simple setup with 30 stacked lenses which focus a cold neutron,
* non diverging beam (ideal case). A set of PSD monitors is positioned
* around the focusing point to show the beam spot.
*
* %Parameters
* lambda: [AA]     Source wavelength
* position_PSD: [m]  Distance from last lens to first monitor
*
* %Link
*
* %End
****************************************************************************/
DEFINE INSTRUMENT Test_Lens(lambda=10,position_PSD=8.2)

TRACE

COMPONENT base=Progress_bar() at (0,0,0) ABSOLUTE

COMPONENT source1 = Source_div(
  xwidth=0.026, yheight=0.026,
  focus_aw= 0.00001, focus_ah= 0.00001,
  lambda0=lambda, dlambda=0.00001,gauss=0)
AT (0,0,.001) relative PREVIOUS

COMPONENT L11=Lens(r1=0.025,r2=0.025,thickness=0.0005,
  density=3.148,weight=62.3018,sigma_coh=11.74,sigma_inc=0,sigma_abs=0,
  radius=0.025,p_interact=0.01,focus_aw=10,focus_ah=10)
AT (0,0,.20) RELATIVE PREVIOUS

COMPONENT COPY(L11) = COPY (L11)
   AT (0,0,0.0071987) RELATIVE PREVIOUS
COMPONENT COPY(L11) = COPY (L11)
   AT (0,0,0.0071987) RELATIVE PREVIOUS
COMPONENT COPY(L11) = COPY (L11)
   AT (0,0,0.0071987) RELATIVE PREVIOUS
COMPONENT COPY(L11) = COPY (L11)
   AT (0,0,0.0071987) RELATIVE PREVIOUS

COMPONENT COPY(L11) = COPY (L11)
   AT (0,0,0.0071987) RELATIVE PREVIOUS
COMPONENT COPY(L11) = COPY (L11)
   AT (0,0,0.0071987) RELATIVE PREVIOUS
COMPONENT COPY(L11) = COPY (L11)
   AT (0,0,0.0071987) RELATIVE PREVIOUS
COMPONENT COPY(L11) = COPY (L11)
   AT (0,0,0.0071987) RELATIVE PREVIOUS
COMPONENT COPY(L11) = COPY (L11)
   AT (0,0,0.0071987) RELATIVE PREVIOUS

COMPONENT COPY(L11) = COPY (L11)
   AT (0,0,0.0071987) RELATIVE PREVIOUS
COMPONENT COPY(L11) = COPY (L11)
   AT (0,0,0.0071987) RELATIVE PREVIOUS
COMPONENT COPY(L11) = COPY (L11)
   AT (0,0,0.0071987) RELATIVE PREVIOUS
COMPONENT COPY(L11) = COPY (L11)
   AT (0,0,0.0071987) RELATIVE PREVIOUS
COMPONENT COPY(L11) = COPY (L11)
   AT (0,0,0.0071987) RELATIVE PREVIOUS


COMPONENT COPY(L11) = COPY (L11)
   AT (0,0,0.0071987) RELATIVE PREVIOUS
COMPONENT COPY(L11) = COPY (L11)
   AT (0,0,0.0071987) RELATIVE PREVIOUS
COMPONENT COPY(L11) = COPY (L11)
   AT (0,0,0.0071987) RELATIVE PREVIOUS
COMPONENT COPY(L11) = COPY (L11)
   AT (0,0,0.0071987) RELATIVE PREVIOUS
COMPONENT COPY(L11) = COPY (L11)
   AT (0,0,0.0071987) RELATIVE PREVIOUS

COMPONENT COPY(L11) = COPY (L11)
   AT (0,0,0.0071987) RELATIVE PREVIOUS
COMPONENT COPY(L11) = COPY (L11)
   AT (0,0,0.0071987) RELATIVE PREVIOUS
COMPONENT COPY(L11) = COPY (L11)
   AT (0,0,0.0071987) RELATIVE PREVIOUS
COMPONENT COPY(L11) = COPY (L11)
   AT (0,0,0.0071987) RELATIVE PREVIOUS
COMPONENT COPY(L11) = COPY (L11)
   AT (0,0,0.0071987) RELATIVE PREVIOUS

COMPONENT COPY(L11) = COPY (L11)
   AT (0,0,0.0071987) RELATIVE PREVIOUS
COMPONENT COPY(L11) = COPY (L11)
   AT (0,0,0.0071987) RELATIVE PREVIOUS
COMPONENT COPY(L11) = COPY (L11)
   AT (0,0,0.0071987) RELATIVE PREVIOUS
COMPONENT COPY(L11) = COPY (L11)
   AT (0,0,0.0071987) RELATIVE PREVIOUS
COMPONENT COPY(L11) = COPY (L11)
   AT (0,0,0.0071987) RELATIVE PREVIOUS

COMPONENT PSD_mon = Monitor_nD(
    xwidth=0.01, yheight = 0.01, options="x y, per cm2",bins=100,restore_neutron=1)
  AT (0, 0, position_PSD) RELATIVE PREVIOUS

COMPONENT COPY(PSD_mon) = COPY(PSD_mon)
AT (0, 0, 0.1) RELATIVE PREVIOUS

COMPONENT COPY(PSD_mon) = COPY(PSD_mon)
AT (0, 0, 0.1) RELATIVE PREVIOUS

COMPONENT COPY(PSD_mon) = COPY(PSD_mon)
AT (0, 0, 0.1) RELATIVE PREVIOUS

COMPONENT COPY(PSD_mon) = COPY(PSD_mon)
AT (0, 0, 0.1) RELATIVE PREVIOUS

COMPONENT COPY(PSD_mon) = COPY(PSD_mon)
AT (0, 0, 0.1) RELATIVE PREVIOUS

COMPONENT COPY(PSD_mon) = COPY(PSD_mon)
AT (0, 0, 0.1) RELATIVE PREVIOUS

COMPONENT COPY(PSD_mon) = COPY(PSD_mon)
AT (0, 0, 0.1) RELATIVE PREVIOUS

COMPONENT COPY(PSD_mon) = COPY(PSD_mon)
AT (0, 0, 0.1) RELATIVE PREVIOUS

COMPONENT COPY(PSD_mon) = COPY(PSD_mon)
AT (0, 0, 0.1) RELATIVE PREVIOUS

COMPONENT COPY(PSD_mon) = COPY(PSD_mon)
AT (0, 0, 0.1) RELATIVE PREVIOUS

COMPONENT COPY(PSD_mon) = COPY(PSD_mon)
AT (0, 0, 0.1) RELATIVE PREVIOUS

COMPONENT COPY(PSD_mon) = COPY(PSD_mon)
AT (0, 0, 0.1) RELATIVE PREVIOUS

COMPONENT COPY(PSD_mon) = COPY(PSD_mon)
AT (0, 0, 0.1) RELATIVE PREVIOUS

COMPONENT Last_PSD = COPY(PSD_mon)
AT (0, 0, 0.1) RELATIVE PREVIOUS

END
