/*******************************************************************************
*
* McStas, neutron ray-tracing package
*         Copyright (C) 1997-2008, All rights reserved
*         Risoe National Laboratory, Roskilde, Denmark
*         Institut Laue Langevin, Grenoble, France
*
* Instrument: IncoherentPhonon_test
*
* %Identification
* Written by: Mads Bertelsen
* Date: May 2016
* Origin: Johns Hopkins University, Baltimore
* %INSTRUMENT_SITE: Tests_union
*
* Test of IncoherentPhonon_process
*
* %Description
* Test instrument for the IncoherentPhonon_process physics process from
* V. Laliena, Uni Zaragoza.
*
* Example: comp_select=1 Detector: energy_mon_2_I=1156.84
*
* %Parameters
* comp_select:             [] 1: Union components, 2: Incoherent
* sample_radius:          [m] Radius of sample   
* sample_height:          [m] Height of sample     
* pack:                   [ ] Packing factor         
* sigma_inc_vanadium: [barns] Incoherent cross-section
* sigma_abs_vanadium: [barns] Absorption cross-section
* Vc_vanadium:         [AA^3] Unit cell volume
* geometry_interact:      [ ] p_interact for the Union sample
*
*
* %End
*******************************************************************************/

DEFINE INSTRUMENT IncoherentPhonon_test(int comp_select=1, sample_radius=0.01, sample_height=0.03, pack=1,
sigma_inc_vanadium=5.08, sigma_abs_vanadium=5.08, Vc_vanadium=13.827, geometry_interact=0.5,
int nphe_exact=1, int nphe_approx=0, int approx=0, int mph_resum=0,
T=294, density=6.0, M=50.94, sigmaCoh=0.0184, sigmaInc=5.08, string dosfn="dos_meV.txt", nxs=1000, kabsmin=0.1, kabsmax=25,
interact_fraction=-1)

DECLARE
%{
%}

TRACE

COMPONENT init = Union_init()
AT (0,0,0) ABSOLUTE

COMPONENT V_phonon = IncoherentPhonon_process(nphe_exact=nphe_exact, nphe_approx=nphe_approx ,approx=approx, mph_resum=mph_resum,
T=T,density=density,M=M,sigmaCoh=sigmaCoh,sigmaInc=sigmaInc,DOSfn=dosfn,nxs=nxs,kabsmin=kabsmin,kabsmax=kabsmax,interact_fraction=-1)
AT (0,0,0) ABSOLUTE

COMPONENT V = Union_make_material(my_absorption=0,process_string="V_phonon")
AT (0,0,0) ABSOLUTE

COMPONENT a1 = Progress_bar()
  AT (0,0,0) ABSOLUTE

COMPONENT source = Source_div(
        xwidth=0.06, yheight=0.025,focus_aw=0.5, focus_ah=0.5,
        E0 = 20, dE = 0, flux=1E10)
  AT (0,0,0) RELATIVE a1 ROTATED (0,0,0) RELATIVE a1

COMPONENT sample_position = Arm()
AT (0,0,1) RELATIVE a1
ROTATED (0,0,0) RELATIVE a1

COMPONENT cylinder_sample_union = Union_cylinder(radius=sample_radius, yheight=sample_height, priority=1, material_string="V",p_interact = geometry_interact)
WHEN(comp_select == 1)
AT (0,0,0) RELATIVE sample_position
ROTATED (0,0,0) RELATIVE sample_position

COMPONENT test_sample = Union_master()
WHEN(comp_select == 1)
AT(0,0,1) RELATIVE a1

COMPONENT Banana_monitor = Monitor_nD(radius=1, yheight=0.3, options="banana, theta limits=[10,170], bins=40",filename="banana.dat",restore_neutron=1)
AT (0,0,0) RELATIVE sample_position
ROTATED (0,0,0) RELATIVE sample_position

COMPONENT  arm_ener_1 = Arm()
AT (0,0,0) RELATIVE sample_position
ROTATED (0,45,0) RELATIVE sample_position

COMPONENT energy_mon_1 = E_monitor(
    nE = 100, filename = "energy_monitor_1.dat", xwidth = 0.2,
    yheight = 0.2, Emin = 0.0, Emax = 55.0,
    restore_neutron = 1)
AT (0, 0, 0.5) RELATIVE arm_ener_1
ROTATED (0,0,0) RELATIVE arm_ener_1

COMPONENT  arm_ener_2 = Arm()
AT (0,0,0) RELATIVE sample_position
ROTATED (0,-45,0) RELATIVE sample_position

COMPONENT energy_mon_2 = E_monitor(
    nE = 100, filename = "energy_monitor_2.dat", xwidth = 0.2,
    yheight = 0.2, Emin = 0.0, Emax = 55.0,
    restore_neutron = 1)
AT (0, 0, 0.5) RELATIVE arm_ener_2
ROTATED (0,0,0) RELATIVE arm_ener_2

COMPONENT stop = Union_stop()
AT (0,0,0) ABSOLUTE
  
END




