DEFINE INSTRUMENT test1() DECLARE %{ int USE_CHOPPERS = 0; int background = 1; //background:1-->neutron from sample and not scattered by analyzer. int SIFLAG = 0; int PGFLAG = 1; int SINGLEFLAG = 1; int ANALYZERFLAG = 0; int collimatorFLAG = 0; double a = 5.430710; //lattice parameter for cubic cell. double d = 0.3; //Source-detector distance. double sSize = 1e-2; //Sample size. double dSize = 5e-2; //Detector size. double angle = 84.0; //Sample angle from vertical. double angle2; char *fileName; %} INITIALIZE %{ fileName=(char*)malloc(100*sizeof(char)); angle2 = 90.0-2*angle; angle2 = -90.0; //This actives monitors at the beam direction. // sprintf(fileName, "monitor%d-%d", (int)(d*1e5), (int)(m*10)); sprintf(fileName, "monitor"); %} TRACE //ORIGIN COMPONENT Origin = Progress_bar(minutes = 0.5) AT (0,0,0) ABSOLUTE //MODERATOR COMPONENT sourceMantid = Source_simple( lambda0 = 4.5, dlambda = 2.5, xwidth = 2e-2, yheight= 2e-2, dist = 2.0, focus_xw = 2e-2, focus_yh = 2e-2) AT (0, 0, 0) ABSOLUTE COMPONENT arm_sample = Arm() AT (0,0,2) ABSOLUTE ////////////////////////////////////////////////////////////////////////////////////////// SPLIT 100 COMPONENT sample = Single_crystal( xwidth = 2e-2, yheight = 2e-2, zdepth = 0.2e-2, sigma_abs = 0.014, sigma_inc = 0.004, // reflections = "C_graphite.lau", barns = 0, mosaic = 48, delta_d_d = 3e-4, reflections = "C_graphite.laz", barns = 1, ax = 0, ay = 2.14, az = 1.24, bx = 0, by = 0, bz = 2.47, cx = 6.71, cy = 0, cz = 0) AT (0,0,0) RELATIVE arm_sample ROTATED (0,0,0) RELATIVE arm_sample EXTEND %{ if(SCATTERED){background=0;} else{background=1;} %} //////////////////////////////////////////////////////////////////////////////////////// /* COMPONENT beamDump = Absorber( xmin = -sSize/2.0, xmax = sSize/2.0, ymin = -1e-3, ymax = 1e-3, zmin = -sSize*sin(angle*PI/180)/1.9, zmax = sSize*sin(angle*PI/180)/1.9) AT (0,-sSize/2.0,0) RELATIVE arm_sample ROTATED (0,0,0) RELATIVE arm_sample */ COMPONENT monitorPSD2 = Monitor_nD( xwidth = 2e-2, yheight = 2e-2, filename = "monitorPSD2", options = "x y parallel, all bins = 20", restore_neutron = 1) WHEN(background==0) // WHEN(background==0 && MC_GETPAR(sample,lambdaReflected)>=6.0 && MC_GETPAR(sample,lambdaReflected)<=6.5) AT (0,0,1.1) ABSOLUTE COMPONENT monitorL1 = Monitor_nD( xwidth = 2, yheight = 2, filename = "monitor1", options = "lambda limits=[0,10] bins=200 parallel") WHEN(background==0) // AT (0,-d*sin(angle2*PI/180),d*cos(angle2*PI/180)) RELATIVE arm_sample AT (0,0,1) ABSOLUTE ROTATED (0,0,0) ABSOLUTE COMPONENT monitorL2 = Monitor_nD( xwidth = 2, yheight = 2, filename = "monitor2", options = "lambda limits=[0,10] bins=200 parallel") WHEN(background==0) // AT (0,-d*sin(angle2*PI/180),d*cos(angle2*PI/180)) RELATIVE arm_sample AT (0,1,2) ABSOLUTE ROTATED (90,0,0) ABSOLUTE COMPONENT monitorL3 = Monitor_nD( xwidth = 2, yheight = 2, filename = "monitor3", options = "lambda limits=[0,10] bins=200 parallel") WHEN(background==0) // AT (0,-d*sin(angle2*PI/180),d*cos(angle2*PI/180)) RELATIVE arm_sample AT (0,-1,2) ABSOLUTE ROTATED (-90,0,0) ABSOLUTE COMPONENT monitorL4 = Monitor_nD( xwidth = 2, yheight = 2, filename = "monitor4", options = "lambda limits=[0,10] bins=200 parallel") WHEN(background==0) // AT (0,-d*sin(angle2*PI/180),d*cos(angle2*PI/180)) RELATIVE arm_sample AT (0,0,3) ABSOLUTE ROTATED (0,-180,0) ABSOLUTE COMPONENT monitorTOF2E = TOF2E_monitor( xwidth = 2e-2, yheight = 2e-2, filename = "monitorTOF2E", Emin = 1.6, Emax = 2.4, nE = 8000, T_zero = 0, L_flight = 2.9, restore_neutron = 1) WHEN(background==0) AT (0,0,1) ABSOLUTE ROTATED (0,0,0) ABSOLUTE COMPONENT monitorE = Monitor_nD( xwidth = 2e-2, yheight = 2e-2, filename = fileName, options = "energy limits=[2.076,2.086] bins=100 parallel") WHEN(background==0) // AT (0,-d*sin(angle2*PI/180),d*cos(angle2*PI/180)) RELATIVE arm_sample AT (0,0,1) ABSOLUTE ROTATED (0,0,0) ABSOLUTE FINALLY %{ %} END