/******************************************************************************* * * McStas, the neutron ray-tracing package: Guide_four_side_2_shells.comp * * Component: Guide_four_side_2_shells * * %I * Written by: Tobias Panzner * Date: 07/08/2010 * Version: $Revision: 1.1 $ * Release: McStas 1.9 * Origin: PSI * * * This component models a guide with four side walls surounded by up to 2 shells (every shell consists of * additional four walls). In the end it forms a guide with an inner and up to 2 outer channel. * As user you can controll the properties of every wall separatly. All togther you have up to * 24 walls: From the inner channel 4 inner walls and 4 outer walls and from every outer * channel 4 inner and 4 outer walls. * * Every single wall can have a elliptic, parabolic or straight shape. * All four sides of the guide are independent from each other. * In the elliptic case the side wall shape follows the equation x^2/b^2+(z+z0)^2/a^2=1 * (the center of the ellipse is located at (0,-z0)). * In the parabolic case the side wall shape follows the equation z=b-ax^2;mc * In the straight case the side wall shape follows the equation z=l/(w2-w1)*x-w1. * * The shape selection is done by the focal points. The focal points are located at the * z-axis and are defined by their distance to the entrance or exit window of the guide * (in the following called 'focal length'). * * If both focal lengths for one wall are zero it will be a straight wall (entrance and * exit width have to be given in the beginning). * * If one of the focal lengths is not zero the shape will be parabolic (only the entrance width * given in the beginning is recognized; exit width will be calculated). If the the entrance * focal length is zero the guide will be a focusing devise. * If the exit focal length is zero it will be defocusing devise. * * If both focals are non zero the shape of the wall will be elliptic (only the entrance width * given in the beginning is recognized; exit width will be calculated). * * Notice: 1.)The focal points are in general located outside the guide (positive focal lengths). * Focal points inside the guide need to have negative focal lengths. * 2.)The exit width parameters (w2r, w2l, h2u,h2d) are only taken into account if the * walls have a linear shape. In the ellitic or parabolic case they will be ignored. * * For the inner channel: the outer side of each wall is calculated by the component in depentence * of the wallthickness and the shape of the inner side. * * Each of the 24 walls can have a own indepenting reflecting layer (defined by an input file) * or it can be a absorber or it can be transparent. * * The reflectivity properties can be given by an input file (Format [q(Angs-1) R(0-1)]) or by * parameters (Qc, alpha, m, W). * * %BUGS * This component does not work with gravitation on. * * This component does not work correctly in GROUP-modus. * * %P * INPUT PARAMETERS: * * GENERAL PARAMETERS (VALID FOR ALL SIDES): * * l: [m] length of guide (DEFAULT = 0) * * R0: [1] Low-angle reflectivity (DEFAULT = 0.99) * * THE INNER WALLS OF THE INLAY ARE DEFINED BY: * * w1r: [m] Width at the right guide entry (negative x-axis) * (DEFAULT = 0) * * w2r: [m] Width at the right guide exit (negative x-axis) * (DEFAULT = 0) * * w1l: [m] Width at the left guide entry (positive x-axis) * (DEFAULT = 0) * * w2l: [m] Width at the left guide exit (positive x-axis) * (DEFAULT = 0) * * h1d: [m] Height at the bottom guide entry (negative y-axis) * (DEFAULT = 0) * * h2d: [m] Height at the bottom guide entry (negative y-axis) * (DEFAULT = 0) * * h1u: [m] Height at the top guide entry (positive y-axis) * (DEFAULT = 0) * * h2u: [m] Height at the top guide entry (positive y-axis) * (DEFAULT = 0) * * linwr [m] right horizontal wall: distance of 1st focal point * and guide entry (DEFAULT = 0) * * loutwr [m] right horizontal wall: distance of 2nd focal point * and guide exit (DEFAULT = 0) * * linwl [m] left horizontal wall: distance of 1st focal point * and guide entry (DEFAULT = 0) * * loutwl [m] left horizontal wall: distance of 2nd focal point * and guide exit (DEFAULT = 0) * * linhd [m] lower vertical wall: distance of 1st focal point * and guide entry (DEFAULT = 0) * * louthd [m] lower vertical wall: distance of 2nd focal point * and guide exit (DEFAULT = 0) * * linhu [m] upper vertical wall: distance of 1st focal point * and guide entry (DEFAULT = 0) * * louthu [m] upper vertical wall: distance of 2nd focal point * and guide exit (DEFAULT = 0) * * RIreflect: (str) Name of relfectivity file for the right inner wall. * Format [q(Angs-1) R(0-1)] (DEFAULT : no file) * * LIreflect: (str) Name of relfectivity file for the left inner wall. * Format [q(Angs-1) R(0-1)] (DEFAULT : no file) * * DIreflect: (str) Name of relfectivity file for the bottom inner wall. * Format [q(Angs-1) R(0-1)] (DEFAULT : no file) * * UIreflect: (str) Name of relfectivity file for the top inner wall. * Format [q(Angs-1) R(0-1)] (DEFAULT : no file) * * Qcxr: [AA-1] Critical scattering vector for right vertical * inner wall (DEFAULT = 0.0217) * * Qcxl: [AA-1] Critical scattering vector for left vertical * inner wall (DEFAULT = 0.0217) * * Qcyd: [AA-1] Critical scattering vector for bottom inner wall * (DEFAULT = 0.0217) * * Qcyu: [AA-1] Critical scattering vector for top inner wall * (DEFAULT = 0.0217) * * alphaxr: [AA] Slope of reflectivity for right vertical * inner wall (DEFAULT = 6.07) * * alphaxl: [AA] Slope of reflectivity for left vertical * inner wall (DEFAULT = 6.07) * * alphayd: [AA] Slope of reflectivity for bottom inner wall * (DEFAULT = 6.07) * * alphayu: [AA] Slope of reflectivity for top inner wall * (DEFAULT = 6.07) * * mxr: [1] m-value of material for right vertical inner wall. * 0 means the wall is absorbing. * -1 means the wall is transparent. * (DEFAULT = 3.6) * * mxl: [1] m-value of material for left vertical inner wall. * 0 means the wall is absorbing. * -1 means the wall is transparent. * (DEFAULT = 3.6) * * myd: [1] m-value of material for bottom inner wall * 0 means the wall is absorbing. * -1 means the wall is transparent. * (DEFAULT = 3.6) * * myu: [1] m-value of material for top inner wall * 0 means the wall is absorbing. * -1 means the wall is transparent. * (DEFAULT = 3.6) * * Wxr: [AA-1] Width of supermirror cut-off for right inner wall * (DEFAULT = 0.003) * * Wxl: [AA-1] Width of supermirror cut-off for left inner wall * (DEFAULT = 0.003) * * Wyu: [AA-1] Width of supermirror cut-off for top inner wall * (DEFAULT = 0.003) * * Wyd: [AA-1] Width of supermirror cut-off for bottom inner wall * (DEFAULT = 0.003) * * rwallthick: [m] thickness of the right wall (DEFAULT = 0.001 m) * * lwallthick: [m] thickness of the left wall (DEFAULT = 0.001 m) * * uwallthick: [m] thickness of the top wall (DEFAULT = 0.001 m) * * dwallthick: [m] thickness of the bottom wall(DEFAULT = 0.001 m) * * THE OUTER WALLS OF THE INLAY ARE DEFINED BY: * * ROreflect: (str) Name of relfectivity file for the right outer wall. * Format [q(Angs-1) R(0-1)] (DEFAULT : no file) * * LOreflect: (str) Name of relfectivity file for the left outer wall. * Format [q(Angs-1) R(0-1)] (DEFAULT : no file) * * DOreflect: (str) Name of relfectivity file for the bottom outer wall. * Format [q(Angs-1) R(0-1)] (DEFAULT : no file) * * UOreflect: (str) Name of relfectivity file for the top outer wall. * Format [q(Angs-1) R(0-1)] (DEFAULT : no file) * * QcxrOW: [AA-1] Critical scattering vector for right vertical * outer wall (DEFAULT = 0.0217) * * QcxlOW: [AA-1] Critical scattering vector for left vertical * outer wall (DEFAULT = 0.0217) * * QcydOW: [AA-1] Critical scattering vector for bottom outer wall * (DEFAULT = 0.0217) * * QcyuOW: [AA-1] Critical scattering vector for top outer wall * (DEFAULT = 0.0217) * * alphaxrOW: [AA] Slope of reflectivity for right vertical * outer wall (DEFAULT = 6.07) * * alphaxlOW: [AA] Slope of reflectivity for left vertical * outer wall (DEFAULT = 6.07) * * alphaydOW: [AA] Slope of reflectivity for bottom outer wall * (DEFAULT = 6.07) * * alphayuOW: [AA] Slope of reflectivity for top outer wall * (DEFAULT = 6.07) * * mxrOW: [1] m-value of material for right vertical outer wall * 0 means the wall is absorbing. (DEFAULT) * -1 means the wall is transparent. * (DEFAULT = 0) * * mxlOW: [1] m-value of material for left vertical outer wall * 0 means the wall is absorbing.(DEFAULT) * -1 means the wall is transparent. * (DEFAULT = 0) * * mydOW: [1] m-value of material for bottom outer wall * 0 means the wall is absorbing. (DEFAULT) * -1 means the wall is transparent. * (DEFAULT = 0) * * myuOW: [1] m-value of material for top outer wall * 0 means the wall is absorbing. (DEFAULT) * -1 means the wall is transparent. * (DEFAULT = 0) * * WxrOW: [AA-1] Width of supermirror cut-off for right outer wall * (DEFAULT = 0.003) * * WxlOW: [AA-1] Width of supermirror cut-off for left outer wall * (DEFAULT = 0.003) * * WyuOW: [AA-1] Width of supermirror cut-off for top outer wall * (DEFAULT = 0.003) * * WydOW: [AA-1] Width of supermirror cut-off for bottom outer wall * (DEFAULT = 0.003) * * THE INNER WALLS OF THE @ OUTER CHANNEL ARE DEFINED BY: * * w1r@: [m] Width at the right guide entry (negative x-axis) * (DEFAULT = 2.000 + @*0.002) * * w2r@: [m] Width at the right guide exit (negative x-axis) * (DEFAULT = 2.000 + @*0.002) * * w1l@: [m] Width at the left guide entry (positive x-axis) * (DEFAULT = 2.000 + @*0.002) * * w2l@: [m] Width at the left guide exit (positive x-axis) * (DEFAULT = 2.000 + @*0.002) * * h1d@: [m] Height at the bottom guide entry (negative y-axis) * (DEFAULT = 2.000 + @*0.002) * * h2d@: [m] Height at the bottom guide entry (negative y-axis) * (DEFAULT = 2.000 + @*0.002) * * h1u@: [m] Height at the top guide entry (positive y-axis) * (DEFAULT = 2.000 + @*0.002) * * h2u@: [m] Height at the top guide entry (positive y-axis) * (DEFAULT = 2.000 + @*0.002) * * linwr@ [m] right horizontal wall: distance of 1st focal point * and guide entry (DEFAULT = 0) * * loutwr@ [m] right horizontal wall: distance of 2nd focal point * and guide exit (DEFAULT = 0) * * linwl@ [m] left horizontal wall: distance of 1st focal point * and guide entry (DEFAULT = 0) * * loutwl@ [m] left horizontal wall: distance of 2nd focal point * and guide exit (DEFAULT = 0) * * linhd@ [m] lower vertical wall: distance of 1st focal point * and guide entry (DEFAULT = 0) * * louthd@ [m] lower vertical wall: distance of 2nd focal point * and guide exit (DEFAULT = 0) * * linhu@ [m] upper vertical wall: distance of 1st focal point * and guide entry (DEFAULT = 0) * * louthu@ [m] upper vertical wall: distance of 2nd focal point * and guide exit (DEFAULT = 0) * * RIreflect@: (str) Name of relfectivity file for the right inner wall. * Format [q(Angs-1) R(0-1)] (DEFAULT : no file) * * LIreflect@: (str) Name of relfectivity file for the left inner wall. * Format [q(Angs-1) R(0-1)] (DEFAULT : no file) * * DIreflect@: (str) Name of relfectivity file for the bottom inner wall. * Format [q(Angs-1) R(0-1)] (DEFAULT : no file) * * UIreflect@: (str) Name of relfectivity file for the top inner wall. * Format [q(Angs-1) R(0-1)] (DEFAULT : no file) * * Qcxr@: [AA-1] Critical scattering vector for right vertical * inner wall (DEFAULT = 0.0217) * * Qcxl@: [AA-1] Critical scattering vector for left vertical * inner wall (DEFAULT = 0.0217) * * Qcyd@: [AA-1] Critical scattering vector for bottom inner wall * (DEFAULT = 0.0217) * * Qcyu@: [AA-1] Critical scattering vector for top inner wall * (DEFAULT = 0.0217) * * alphaxr@: [AA] Slope of reflectivity for right vertical * inner wall (DEFAULT = 6.07) * * alphaxl@: [AA] Slope of reflectivity for left vertical * inner wall (DEFAULT = 6.07) * * alphayd@: [AA] Slope of reflectivity for bottom inner wall * (DEFAULT = 6.07) * * alphayu@: [AA] Slope of reflectivity for top inner wall * (DEFAULT = 6.07) * * mxr@: [1] m-value of material for right vertical inner wall. * 0 means the wall is absorbing. * -1 means the wall is transparent. * (DEFAULT = -1) * * mxl@: [1] m-value of material for left vertical inner wall. * 0 means the wall is absorbing. * -1 means the wall is transparent. * (DEFAULT = -1) * * myd@: [1] m-value of material for bottom inner wall * 0 means the wall is absorbing. * -1 means the wall is transparent. * (DEFAULT = -1) * * myu@: [1] m-value of material for top inner wall * 0 means the wall is absorbing. * -1 means the wall is transparent. * (DEFAULT = -1) * * Wxr@: [AA-1] Width of supermirror cut-off for right inner wall * (DEFAULT = 0.003) * * Wxl@: [AA-1] Width of supermirror cut-off for left inner wall * (DEFAULT = 0.003) * * Wyu@: [AA-1] Width of supermirror cut-off for top inner wall * (DEFAULT = 0.003) * * Wyd@: [AA-1] Width of supermirror cut-off for bottom inner wall * (DEFAULT = 0.003) * * THE OUTER WALLS THE @ OUTER CHANNEL ARE DEFINED BY: * * ROreflect@: (str) Name of relfectivity file for the right outer wall. * Format [q(Angs-1) R(0-1)] (DEFAULT : no file) * * LOreflect@: (str) Name of relfectivity file for the left outer wall. * Format [q(Angs-1) R(0-1)] (DEFAULT : no file) * * DOreflect@: (str) Name of relfectivity file for the bottom outer wall. * Format [q(Angs-1) R(0-1)] (DEFAULT : no file) * * UOreflect@: (str) Name of relfectivity file for the top outer wall. * Format [q(Angs-1) R(0-1)] (DEFAULT : no file) * * QcxrOW@: [AA-1] Critical scattering vector for right vertical * outer wall (DEFAULT = 0.0217) * * QcxlOW@: [AA-1] Critical scattering vector for left vertical * outer wall (DEFAULT = 0.0217) * * QcydOW@: [AA-1] Critical scattering vector for bottom outer wall * (DEFAULT = 0.0217) * * QcyuOW@: [AA-1] Critical scattering vector for top outer wall * (DEFAULT = 0.0217) * * alphaxrOW@: [AA] Slope of reflectivity for right vertical * outer wall (DEFAULT = 6.07) * * alphaxlOW@: [AA] Slope of reflectivity for left vertical * outer wall (DEFAULT = 6.07) * * alphaydOW@: [AA] Slope of reflectivity for bottom outer wall * (DEFAULT = 6.07) * * alphayuOW@: [AA] Slope of reflectivity for top outer wall * (DEFAULT = 6.07) * * mxrOW@: [1] m-value of material for right vertical outer wall * 0 means the wall is absorbing. (DEFAULT) * -1 means the wall is transparent. * (DEFAULT = -1) * * mxlOW@: [1] m-value of material for left vertical outer wall * 0 means the wall is absorbing.(DEFAULT) * -1 means the wall is transparent. * (DEFAULT = -1) * * mydOW@: [1] m-value of material for bottom outer wall * 0 means the wall is absorbing. (DEFAULT) * -1 means the wall is transparent. * (DEFAULT = -1) * * myuOW@: [1] m-value of material for top outer wall * 0 means the wall is absorbing. (DEFAULT) * -1 means the wall is transparent. * (DEFAULT = -1) * * WxrOW@: [AA-1] Width of supermirror cut-off for right outer wall * (DEFAULT = 0.003) * * WxlOW@: [AA-1] Width of supermirror cut-off for left outer wall * (DEFAULT = 0.003) * * WyuOW@: [AA-1] Width of supermirror cut-off for top outer wall * (DEFAULT = 0.003) * * WydOW@: [AA-1] Width of supermirror cut-off for bottom outer wall * (DEFAULT = 0.003) * %End * ******************************************************************************/ DEFINE COMPONENT Guide_four_side_2_shells DEFINITION PARAMETERS(string RIreflect=0, LIreflect=0, UIreflect=0, DIreflect=0, ROreflect=0, LOreflect=0, UOreflect=0, DOreflect=0, RIreflect1=0, LIreflect1=0, UIreflect1=0, DIreflect1=0, ROreflect1=0, LOreflect1=0, UOreflect1=0, DOreflect1=0,RIreflect2=0, LIreflect2=0, UIreflect2=0, DIreflect2=0, ROreflect2=0, LOreflect2=0, UOreflect2=0, DOreflect2=0) SETTING PARAMETERS (w1l=0.002,w2l=0.002,linwl=0,loutwl=0, w1r=0.002,w2r=0.002,linwr=0.0,loutwr=0, h1u=0.002,h2u=0.002,linhu=0.0,louthu=0, h1d=0.002,h2d=0.002,linhd=0.0,louthd=0, l=0, R0=0.99, Qcxl=0.0217,Qcxr=0.0217,Qcyu=0.0217, Qcyd=0.0217, alphaxl=6.07, alphaxr=6.07, alphayu=6.07, alphayd=6.07, Wxr=0.003,Wxl=0.003,Wyu=0.003,Wyd=0.003, mxr=3.6, mxl=3.6, myu=3.6, myd=3.6, QcxrOW=0.0217,QcxlOW=0.0217,QcyuOW=0.0217, QcydOW=0.0217, alphaxlOW=6.07, alphaxrOW=6.07, alphayuOW=6.07, alphaydOW=6.07, WxrOW=0.003,WxlOW=0.003,WyuOW=0.003,WydOW=0.003, mxrOW=0, mxlOW=0, myuOW=0, mydOW=0, rwallthick=0.001,lwallthick=0.001,uwallthick=0.001,dwallthick=0.001, w1l1=2.002,w2l1=2.002,linwl1=0,loutwl1=0, w1r1=2.002,w2r1=2.002,linwr1=0,loutwr1=0, h1u1=2.002,h2u1=2.002,linhu1=0,louthu1=0, h1d1=2.002,h2d1=2.002,linhd1=0,louthd1=0, Qcxl1=0.0217,Qcxr1=0.0217,Qcyu1=0.0217, Qcyd1=0.0217, alphaxl1=6.07, alphaxr1=6.07, alphayu1=6.07, alphayd1=6.07, Wxr1=0.003,Wxl1=0.003,Wyu1=0.003,Wyd1=0.003, mxr1=-1, mxl1=-1, myu1=-1, myd1=-1, QcxrOW1=0.0217,QcxlOW1=0.0217,QcyuOW1=0.0217, QcydOW1=0.0217, alphaxlOW1=6.07, alphaxrOW1=6.07, alphayuOW1=6.07, alphaydOW1=6.07, WxrOW1=0.003,WxlOW1=0.003,WyuOW1=0.003,WydOW1=0.003, mxrOW1=-1, mxlOW1=-1, myuOW1=-1, mydOW1=-1, rwallthick1=0.001,lwallthick1=0.001,uwallthick1=0.001,dwallthick1=0.001, w1l2=2.004,w2l2=2.004,linwl2=0,loutwl2=0, w1r2=2.004,w2r2=2.004,linwr2=0,loutwr2=0, h1u2=2.004,h2u2=2.004,linhu2=0,louthu2=0, h1d2=2.004,h2d2=2.004,linhd2=0,louthd2=0, Qcxl2=0.0217,Qcxr2=0.0217,Qcyu2=0.0217, Qcyd2=0.0217, alphaxl2=6.07, alphaxr2=6.07, alphayu2=6.07, alphayd2=6.07, Wxr2=0.003,Wxl2=0.003,Wyu2=0.003,Wyd2=0.003, mxr2=-1, mxl2=-1, myu2=-1, myd2=-1, QcxrOW2=0.0217,QcxlOW2=0.0217,QcyuOW2=0.0217, QcydOW2=0.0217, alphaxlOW2=6.07, alphaxrOW2=6.07, alphayuOW2=6.07, alphaydOW2=6.07, WxrOW2=0.003,WxlOW2=0.003,WyuOW2=0.003,WydOW2=0.003, mxrOW2=-1, mxlOW2=-1, myuOW2=-1, mydOW2=-1, rwallthick2=0.001,lwallthick2=0.001,uwallthick2=0.001,dwallthick2=0.001 ) OUTPUT PARAMETERS(w1rwt,w1lwt,h1uwt,h1dwt,w2rwt,w2lwt,h2uwt,h2dwt, pawr,pawl,pbwr,pbwl,pahu,pahd,pbhu,pbhd, awl,bwl,awr,bwr,ahu,bhu,ahd,bhd, awlwt,bwlwt,awrwt,bwrwt,ahuwt,bhuwt,ahdwt,bhdwt, pawrwt,pawlwt,pbwrwt,pbwlwt,pahuwt,pahdwt,pbhuwt,pbhdwt, t1,t2w1r,t2w1l,t2h1u,t2h1d, t2w1rwt,t2w1lwt,t2h1uwt,t2h1dwt, a2wlwt,b2wlwt,a2wrwt,b2wrwt,a2huwt,b2huwt,a2hdwt,b2hdwt, a2wl,b2wl,a2wr,b2wr,a2hu,b2hu,a2hd,b2hd, mru1,mru2,nru1,nru2,mrd1,mrd2,nrd1,nrd2,mlu1,mlu2,nlu1,nlu2,mld1,mld2,nld1,nld2, z0wr,z0wl,z0hu,z0hd, p2parawr,p2parawl,p2parahu,p2parahd, p2parawrwt,p2parawlwt,p2parahuwt,p2parahdwt, m,n, nz,nx,ny,n2, pf, vxin,vyin,vzin, q, xtest,ytest, riTable, liTable, uiTable, diTable, roTable, loTable, uoTable, doTable, w1rwt1,w1lwt1,h1uwt1,h1dwt1,w2rwt1,w2lwt1,h2uwt1,h2dwt1, pawr1,pawl1,pbwr1,pbwl1,pahu1,pahd1,pbhu1,pbhd1, awl1,bwl1,awr1,bwr1,ahu1,bhu1,ahd1,bhd1, awlwt1,bwlwt1,awrwt1,bwrwt1,ahuwt1,bhuwt1,ahdwt1,bhdwt1, pawrwt1,pawlwt1,pbwrwt1,pbwlwt1,pahuwt1,pahdwt1,pbhuwt1,pbhdwt1, t2w1r1,t2w1l1,t2h1u1,t2h1d1, t2w1rwt1,t2w1lwt1,t2h1uwt1,t2h1dwt1, a2wlwt1,b2wlwt1,a2wrwt1,b2wrwt1,a2huwt1,b2huwt1,a2hdwt1,b2hdwt1, a2wl1,b2wl1,a2wr1,b2wr1,a2hu1,b2hu1,a2hd1,b2hd1, mru11,mru21,nru11,nru21,mrd11,mrd21,nrd11,nrd21,mlu11,mlu21,nlu11,nlu21,mld11,mld21,nld11,nld21, z0wr1,z0wl1,z0hu1,z0hd1, p2parawr1,p2parawl1,p2parahu1,p2parahd1, p2parawrwt1,p2parawlwt1,p2parahuwt1,p2parahdwt1, riTable1, liTable1, uiTable1, diTable1, roTable1, loTable1, uoTable1, doTable1, w1rwt2,w1lwt2,h1uwt2,h1dwt2,w2rwt2,w2lwt2,h2uwt2,h2dwt2, pawr2,pawl2,pbwr2,pbwl2,pahu2,pahd2,pbhu2,pbhd2, awl2,bwl2,awr2,bwr2,ahu2,bhu2,ahd2,bhd2, awlwt2,bwlwt2,awrwt2,bwrwt2,ahuwt2,bhuwt2,ahdwt2,bhdwt2, pawrwt2,pawlwt2,pbwrwt2,pbwlwt2,pahuwt2,pahdwt2,pbhuwt2,pbhdwt2, t2w1r2,t2w1l2,t2h1u2,t2h1d2, t2w1rwt2,t2w1lwt2,t2h1uwt2,t2h1dwt2, a2wlwt2,b2wlwt2,a2wrwt2,b2wrwt2,a2huwt2,b2huwt2,a2hdwt2,b2hdwt2, a2wl2,b2wl2,a2wr2,b2wr2,a2hu2,b2hu2,a2hd2,b2hd2, mru12,mru22,nru12,nru22,mrd12,mrd22,nrd12,nrd22,mlu12,mlu22,nlu12,nlu22,mld12,mld22,nld12,nld22, z0wr2,z0wl2,z0hu2,z0hd2, p2parawr2,p2parawl2,p2parahu2,p2parahd2, p2parawrwt2,p2parawlwt2,p2parahuwt2,p2parahdwt2, riTable2, liTable2, uiTable2, diTable2, roTable2, loTable2, uoTable2, doTable2, TEST_INPUT, TEST_INPUT_1, TEST_INPUT_2,TEST_INPUT_3, TEST_INPUT_4, ELLIPSE,PARABEL_FOCUS,PARABEL_DEFOCUS,LINEAR, TIME_LINEAR,TIME_LINEAR_1,TIME_PARABEL,TIME_PARABEL_1,TIME_ELLIPSE,TIME_ELLIPSE_1, TEST_UP_DOWN,TEST_LEFT_RIGHT ) STATE PARAMETERS (x,y,z,vx,vy,vz,t,sx,sy,p) SHARE %{ %include "read_table-lib" %} DECLARE %{ double w1rwt,w1lwt,h1uwt,h1dwt,w2rwt,w2lwt,h2uwt,h2dwt; /* entrance and exit width for th OUTER walls of the guide*/ double pawr,pawl,pbwr,pbwl,pahu,pahd,pbhu,pbhd; /* parameter a and b of the parabolic curves (INNER walls)*/ double awl,bwl,awr,bwr,ahu,bhu,ahd,bhd; /* long and short axis a and b auf the ellipses (INNER walls)*/ double awlwt,bwlwt,awrwt,bwrwt,ahuwt,bhuwt,ahdwt,bhdwt; /* long and short axis a and b auf the ellipses (OUTER walls)*/ double pawrwt,pawlwt,pbwrwt,pbwlwt,pahuwt,pahdwt,pbhuwt,pbhdwt; /* parameter a and b of the parabolic curves for the OUTER wall*/ double t1,t2w1r,t2w1l,t2h1u,t2h1d; /* time variables (INNER walls)*/ double t2w1rwt,t2w1lwt,t2h1uwt,t2h1dwt; /* time variables (OUTER walls)*/ double a2wlwt,b2wlwt,a2wrwt,b2wrwt,a2huwt,b2huwt,a2hdwt,b2hdwt; /* square of long and short axis a and b auf the ellipses (OUTER walls) */ double a2wl,b2wl,a2wr,b2wr,a2hu,b2hu,a2hd,b2hd; /* square of long and short axis a and b auf the ellipses (INNER walls)*/ double mru1,mru2,nru1,nru2,mrd1,mrd2,nrd1,nrd2,mlu1,mlu2,nlu1,nlu2,mld1,mld2,nld1,nld2; /* variables the calculated the guide geometrie in the entrance and exit plane (absorbing mask given by the walls)*/ double z0wr,z0wl,z0hu,z0hd; /* z-component of the center of the ellipse (x-component is allways zero) */ double p2parawr,p2parawl,p2parahu,p2parahd; /* help variables to calculate the parabolic curve parameters a and b (INNER walls)*/ double p2parawrwt,p2parawlwt,p2parahuwt,p2parahdwt; /* help variables to calculate the parabolic curve parameters a and b for (OUTER wall)*/ double m,n; /* zcomponent of the intersection point of the neutron trajectory and the ellipse (INNER walls)*/ double nz,nx,ny,n2; /* component and length of the surfaces normal vector at the intersection point */ double pf; /* prefactor to calculate the velocity vector after the interaction */ double vxin,vyin,vzin; /* velocity vector components before the interaction*/ double q; /* q-vector for the interaction */ double xlimitr,xlimitrwt,xlimitl,xlimitlwt,ylimitd,ylimitdwt,ylimitu,ylimituwt; /* limit variables to determine the interaction position given by the time relative to the guide walls*/ double xtest,ytest; /* interaction position of the neutron given by the interaction time; crosscheck with limit variables*/ t_Table riTable,liTable,uiTable,diTable; t_Table roTable,loTable,uoTable,doTable; double w1rwt1,w1lwt1,h1uwt1,h1dwt1,w2rwt1,w2lwt1,h2uwt1,h2dwt1; double pawr1,pawl1,pbwr1,pbwl1,pahu1,pahd1,pbhu1,pbhd1; double awl1,bwl1,awr1,bwr1,ahu1,bhu1,ahd1,bhd1; double awlwt1,bwlwt1,awrwt1,bwrwt1,ahuwt1,bhuwt1,ahdwt1,bhdwt1; double pawrwt1,pawlwt1,pbwrwt1,pbwlwt1,pahuwt1,pahdwt1,pbhuwt1,pbhdwt1; double t2w1r1,t2w1l1,t2h1u1,t2h1d1; double t2w1rwt1,t2w1lwt1,t2h1uwt1,t2h1dwt1; double a2wlwt1,b2wlwt1,a2wrwt1,b2wrwt1,a2huwt1,b2huwt1,a2hdwt1,b2hdwt1; double a2wl1,b2wl1,a2wr1,b2wr1,a2hu1,b2hu1,a2hd1,b2hd1; double mru11,mru21,nru11,nru21,mrd11,mrd21,nrd11,nrd21,mlu11,mlu21,nlu11,nlu21,mld11,mld21,nld11,nld21; double z0wr1,z0wl1,z0hu1,z0hd1; double p2parawr1,p2parawl1,p2parahu1,p2parahd1; double p2parawrwt1,p2parawlwt1,p2parahuwt1,p2parahdwt1; t_Table riTable1,liTable1,uiTable1,diTable1; t_Table roTable1,loTable1,uoTable1,doTable1; double w1rwt2,w1lwt2,h1uwt2,h1dwt2,w2rwt2,w2lwt2,h2uwt2,h2dwt2; double pawr2,pawl2,pbwr2,pbwl2,pahu2,pahd2,pbhu2,pbhd2; double awl2,bwl2,awr2,bwr2,ahu2,bhu2,ahd2,bhd2; double awlwt2,bwlwt2,awrwt2,bwrwt2,ahuwt2,bhuwt2,ahdwt2,bhdwt2; double pawrwt2,pawlwt2,pbwrwt2,pbwlwt2,pahuwt2,pahdwt2,pbhuwt2,pbhdwt2; double t2w1r2,t2w1l2,t2h1u2,t2h1d2; double t2w1rwt2,t2w1lwt2,t2h1uwt2,t2h1dwt2; double a2wlwt2,b2wlwt2,a2wrwt2,b2wrwt2,a2huwt2,b2huwt2,a2hdwt2,b2hdwt2; double a2wl2,b2wl2,a2wr2,b2wr2,a2hu2,b2hu2,a2hd2,b2hd2; double mru12,mru22,nru12,nru22,mrd12,mrd22,nrd12,nrd22,mlu12,mlu22,nlu12,nlu22,mld12,mld22,nld12,nld22; double z0wr2,z0wl2,z0hu2,z0hd2; double p2parawr2,p2parawl2,p2parahu2,p2parahd2; double p2parawrwt2,p2parawlwt2,p2parahuwt2,p2parahdwt2; t_Table riTable2, liTable2, uiTable2, diTable2; t_Table roTable2, loTable2, uoTable2, doTable2; void TEST_INPUT(char name[20]) { fprintf(stderr,"Component: %s (Guide_four_side) %s should \n", NAME_CURRENT_COMP, name); fprintf(stderr," NOT be negative \n"); fprintf(stderr," (for negative values use the global guide position !) \n"); exit(-1); }; void TEST_INPUT_1(char name[20]) { fprintf(stderr,"Component: %s (Guide_four_side) %s must \n", NAME_CURRENT_COMP, name); fprintf(stderr," be -1 (transperent) or \n"); fprintf(stderr," be 0 (absorbing) or \n"); fprintf(stderr," be > 0 (reflecting) \n"); exit(-1); }; void TEST_INPUT_2(char name[20]) { fprintf(stderr,"Component: %s (Guide_four_side) %s can \n", NAME_CURRENT_COMP, name); fprintf(stderr," NOT be negative \n"); exit(-1); }; void TEST_INPUT_3(char name[20]) { fprintf(stderr,"Component: %s (Guide_four_side) %sr must \n", NAME_CURRENT_COMP, name); fprintf(stderr," be positive\n"); exit(-1); }; void TEST_INPUT_4(char name[20],char name1[20], double inputname, double inputname1) { fprintf(stderr,"Component: %s (Guide_four_side) \n", NAME_CURRENT_COMP); fprintf(stderr," %s have to be bigger or equal %s \n", name, name1); printf(" %s = %f \n",name, inputname ); printf(" %s = %f \n",name1, inputname1 ); fprintf(stderr," check curve parameter and wallthicknesses! \n"); exit(-1); }; /* function to calculate the needed parameters for an elliptic wall*/ void ELLIPSE(double w1,double length, double lin, double lout, double wallthick, double *a, double *b, double *a2, double *b2, double *z0, double *w2, double *awt, double *a2wt, double *bwt, double *b2wt, double *w2wt, double *w1wt) { double DIV1, lb, u1, u2, u1wt, u2wt, dx, dz; lb=lin+length+lout; /* lenght between the two focal points of the wall */ *z0=(lin-length-lout)/2.0; u1=sqrt((lin*lin)+(w1*w1)); /* length between entrance focal point and starting point of the wall (INNER side)*/ u2=sqrt((w1*w1)+((length+lout)*(length+lout))); /* length between exit focal point and end point of the wall (INNER side) */ *a=(u1+u2)/2.0; /* long half axis a of the ellipse (INNER side)*/ *a2=*a*(*a); /* square of the long axis a (INNER side)*/ *b=sqrt(*a2-(lb*(lb)/4.0)); /* short half axis b of the ellipse (INNER side)*/ *b2=*b*(*b); /* square of short half axis b of the ellipse (INNER side)*/ DIV1=sqrt(1.0-((lb/2.0-lout)*(lb/2.0-lout)/(*a2))); /* help variable to calculated the exit width (INNER side)*/ *w2=*b*(DIV1); /* exit width (INNER side)*/ if(length<(lb)/2-lout){ /* if the maximum opening of the guide is smaller than the small half axis b, the OUTER side is defined by: */ dx=wallthick * sin(atan(*a2 * w1/(*b2 * (*z0)))); dz=wallthick * cos(atan(*a2 * w1/(*b2 * (*z0)))); u1wt=sqrt(((lin+dz)*(lin+dz))+((w1+dx)*(w1+dx))); /* length between entrance focal point and starting point of the wall (OUTER side)*/ u2wt=sqrt(((w1+dx)*(w1+dx))+((length+lout-dz)*(length+lout-dz))); /* length between exit focal point and end point of the wall (OUTER side) */ *awt=(u1wt+u2wt)/2.0; /* long half axis a of the ellipse (OUTER side)*/ *a2wt=*awt*(*awt); /* square of the long axis a (OUTER side)*/ *bwt=sqrt(*a2wt-(lb*lb/4.0)); /* short half axis b of the ellipse (OUTER side)*/ *b2wt=*bwt*(*bwt); /* square of short half axis b of the ellipse (OUTER side)*/ *w2wt=*bwt*sqrt(1.0-((lb/2.0-lout)*(lb/2.0-lout)/(*a2wt))); /* exit width for OUTER side */ *w1wt=*bwt*sqrt(1.0-((lb/2.0-lout-length)*(lb/2.0-lout-length)/(*a2wt))); /* entrance width for OUTER side */ }else{ /* if the maximum opening of the guide is the small half axis b the OUTER wall is defined by:*/ *bwt=*b+wallthick; /* short half axis b of the ellipse (OUTER side)*/ *b2wt=*bwt*(*bwt); /* square of the long axis a (OUTER side)*/ *awt=sqrt(*b2wt+(lb*lb/4.0)); /* long half axis a of the ellipse (OUTER side)*/ *a2wt=*b2wt+(lb*lb/4.0); /* square of short half axis b of the ellipse (OUTER side)*/ *w2wt=*bwt*sqrt(1.0-((lb/2.0-lout)*(lb/2.0-lout)/(*a2wt))); /* exit width for OUTER side */ *w1wt=*bwt*sqrt(1.0-((lb/2.0-lin)*(lb/2.0-lin)/(*a2wt))); /* entrance width for OUTER side */ } } /* function to calculate the needed parameters for a parabolical focusing wall*/ void PARABEL_FOCUS(double w1,double length , double lout, double wallthick, double *p2para, double *w2, double *pb , double *pa, double *p2parawt, double *pbwt, double *pawt, double *w2wt, double *w1wt) { double DIV1,DIV1wt, dx, dz; DIV1=(length+lout)*(length+lout); /* help variable to calculate the curve parameters (INNER side) */ *p2para=2.0*(sqrt(DIV1+(w1*w1))-sqrt(DIV1)); /* help variable to calculate the curve parameters (INNER side) */ *w2=sqrt(*p2para*(lout+*p2para/4.0)); /* exit width (INNER side) */ *pb=length+lout+*p2para/4.0; /* parameter b for parabolic equation to define the wall (INNER side)*/ *pa=1.0/(*p2para); /* parameter a for parabolic equation to define the wall (INNER side)*/ dx= wallthick*sin(atan(w1*2*(*pa))); /* help variable dx; needed because the wall is not paralell to the z-axis or the wallthickness is not perpendicular to z*/ dz= wallthick*cos(atan(w1*2*(*pa))); /* help variable dz; needed because the wall is not paralell to the z-axis or the wallthickness is not perpendicular to z*/ DIV1wt=(length+lout-dz)*(length+lout-dz); /* help variable to calculate the curve parameters (OUTER side) */ *p2parawt=2.0*(sqrt(DIV1wt+((w1+dx)*(w1+dx)))-sqrt(DIV1wt)); /* help variable to calculate the curve parameters (OUTER side) */ *pbwt=length+lout+*p2parawt/4.0; /* parameter b for parabolic equation to define the wall (OUTER side)*/ *pawt=1.0/(*p2parawt); /* parameter a for parabolic equation to define the wall (OUTER side)*/ *w2wt=sqrt(*p2parawt*(lout+ *p2parawt/4.0)); /* exit width (OUTER side) */ *w1wt=sqrt(*p2parawt*(lout+l+ *p2parawt/4.0)); /* entrance width (OUTER side) */ } /* function to calculate the needed parameters for a parabolical defocusing wall*/ void PARABEL_DEFOCUS(double w1,double length, double lin, double wallthick, double *p2para, double *w2, double *pb , double *pa, double *p2parawt, double *pbwt, double *pawt, double *w2wt, double *w1wt) { double DIV1,DIV1wt, dx, dz; DIV1=lin*lin; /* help variable to calculate the curve parameters (INNER side) */ *p2para=2.0*(sqrt(DIV1+(w1*w1))-sqrt(DIV1)); /* help variable to calculate the curve parameters (INNER side) */ *w2=sqrt(*p2para*(length+lin+*p2para/4.0)); /* exit width (INNER side) */ *pb=-(lin+*p2para/4.0); /* parameter b for parabolic equation to define the wall (INNER side)*/ *pa=-1.0/(*p2para); /* parameter a for parabolic equation to define the wall (INNER side)*/ dx=wallthick*sin(atan(-*w2*2*(*pa))); /* help variable dx; needed because the wall is not paralell to the z-axis or the wallthickness is not perpendicular to z*/ dz=wallthick*cos(atan(-*w2*2*(*pa))); /* help variable dz; needed because the wall is not paralell to the z-axis or the wallthickness is not perpendicular to z*/ DIV1wt=(lin+length-dz)*(lin+length-dz); /* help variable to calculate the curve parameters (OUTER side) */ *p2parawt=2.0*(sqrt(DIV1wt+((*w2+dx)*(*w2+dx)))-sqrt(DIV1wt)); /* help variable to calculate the curve parameters (OUTER side) */ *w1wt=sqrt(*p2parawt*(lin+*p2parawt/4.0)); /* entrance width for right focusing parabolic wall (OUTER side) */ *w2wt=sqrt(*p2parawt*(lin+length+*p2parawt/4.0)); /* exit width (OUTER side) */ *pbwt=-(lin+*p2parawt/4.0); /* parameter b for parabolic equation to define the wall (OUTER side)*/ *pawt=-1.0/(*p2parawt); /* parameter a for parabolic equation to define the wall (OUTER side)*/ } /* function to calculate the needed parameters for a linear wall*/ void LINEAR(double w1, double w2, double length, double wallthick, double *w1wt, double *w2wt) { *w1wt=w1+wallthick/(cos(atan((w1-w2)/length))); /* entrance width (OUTER side) */ *w2wt=w2+wallthick/(cos(atan((w1-w2)/length))); /* exit width (OUTER side) */ } /* function to calculate the intersection time with a linear wall at an negative axis*/ void TIME_LINEAR(double t1in, double w1, double w2, double length, double xin, double zin, double vxin1, double vzin1, double w1wt, double *t2, double *t2wt) { double anstieg; anstieg=(-w2+w1)/length; *t2=(anstieg*zin-w1-xin)/(vxin1-anstieg*vzin1); /* time untill next interaction with this wall (INNER side)*/ *t2wt=(anstieg*zin-w1wt-xin)/(vxin1-anstieg*vzin1); /* time untill next interaction with this wall (OUTER side)*/ if(*t2<1e-15) /* solving the precision problem for the intersection times given by double variable type, to small times (<1e-15) gives scattering events */ *t2=t1in+2.0; /* at the same postion again (time is set to zero). this results in a sign change in the velocity components, which results in a wall tunneling.*/ if(*t2wt<1e-15) /* see comments above*/ *t2wt=t1in+2.0; } /* function to calculate the intersection time with a linear wall at an positive axis*/ void TIME_LINEAR_1(double t1in, double w1, double w2, double length, double xin, double zin, double vxin1, double vzin1, double w1wt, double *t2, double *t2wt) { double anstieg; anstieg=(w2-w1)/length; *t2=(anstieg*zin+w1-xin)/(vxin1-anstieg*vzin1); *t2wt=(anstieg*zin+w1wt-xin)/(vxin1-anstieg*vzin1); if(*t2<1e-15) *t2=t1in+2.0; if(*t2wt<1e-15) *t2wt=t1in+2.0; } /* function to calculate the intersection time with an elliptical wall at a negative axis*/ void TIME_ELLIPSE(double vxin, double vzin, double xin, double zin, double a2, double b2, double z0, double t1in, double a2wt, double b2wt, double *t2w1, double *t2w1wt) { /* solving the elliptic equation in respect to z and the straight neutron trajectoty, only two z values possible! */ double m,n,q,p,z1,z2,qwt,pwt, xintersec, z1wt, z2wt, xintersecwt,t2w2,t2w2wt; m=vxin/vzin; /* m parameter of the neutron trajectory*/ n=-m*zin+xin; /* n parameter of the neutron trajectory */ p=2.0*(a2*m*n+b2*z0)/(a2*m*m+b2); /* p parameter of quadratic equation for calulation the z component of the intersection point with respect to the neutron trajectory (INNER side)*/ q=(a2*n*n+b2*z0*z0-a2*b2)/(a2*m*m+b2); /* q parameter of quadratic equation for calulation the z component of the intersection point with respect to the neutron trajectory (INNER side)*/ if ((p*p/4.0)-q<0){ *t2w1=t1in+2.0; /* if the neutron never touch the ellipse the time is set to be bigger than the time (t1) needed to pass the component */ }else{ z1=-p/2.0+sqrt(((p)*(p)/4.0)-q); /* first solution for z (INNER side)*/ z2=-p/2.0-sqrt(((p)*(p)/4.0)-q); /* second solution for z (INNER side)*/ *t2w1=(z1-zin)/vzin; /* interaction time for first z value (INNER side)*/ t2w2=(z2-zin)/vzin; /* interactime time for second z value (INNER side)*/ if(*t2w1<1e-15) /* solving the precision problem for the intersection times given by double variable type, to small times (<1e-15) gives scattering events */ *t2w1=t1in+2.0; /* at the same postion again (time is set to zero). this results in a sign change in the velocity components, which results in a wall tunneling.*/ if(t2w2<1e-15) /* see comments above*/ t2w2=t1in+2.0; if(t2w2<*t2w1) /* choosing the smaller positive time solution (INNER side)*/ *t2w1=t2w2; xintersec=m*(vzin*(*t2w1)+zin)+n; /* crosscheck of the x-coordinate of the intersection point */ if (xintersec>0) /* for the right wall x-coordinate of the intersection point have to be negative */ *t2w1=t1in+2.0; /* if this is not the case the time is set to t1+2.0 (time point behind the component) */ } pwt=2.0*(a2wt*m*n+b2wt*z0)/(a2wt*m*m+b2wt); /* p parameter of quadratic equation for calulation the z component of the intersection point with respect to the neutron trajectory (OUTER side)*/ qwt=(a2wt*n*n+b2wt*z0*z0-a2wt*b2wt)/(a2wt*m*m+b2wt); /* q parameter of quadratic equation for calulation the z component of the intersection point with respect to the neutron trajectory (OUTER side)*/ if ((pwt*pwt/4.0)-qwt<0){ *t2w1wt=t1in+2.0; /* if the neutron never touch the ellipse the time is set bigger than need to pass the component */ }else{ z1wt=-pwt/2.0+sqrt((pwt*pwt/4.0)-qwt); /* first solution for z (OUTER side) */ z2wt=-pwt/2.0-sqrt((pwt*pwt/4.0)-qwt); /* second solution for z (OUTER side)*/ *t2w1wt=(z1wt-zin)/vzin; /* interaction time for first z value (OUTER side)*/ t2w2wt=(z2wt-zin)/vzin; /* interactime time for second z value (OUTER side)*/ if(*t2w1wt<1e-15) /* solving the precision problem for the intersection times given by double variable type, to small times (<1e-15) gives scattering events */ *t2w1wt=t1in+2.0; /* at the same postion again (time is set to zero). this results in a sign change in the velocity components, which results in a wall tunneling.*/ if(t2w2wt<1e-15) /* see comments above*/ t2w2wt=t1in+2.0; if(t2w2wt<*t2w1wt) /* choosing the smaller positive time solution (OUTER side)*/ *t2w1wt=t2w2wt; xintersecwt=m*(vzin*(*t2w1wt)+zin)+n; /* crosscheck of the x-coordinate of the intersection point */ if (xintersecwt>0) /* x-coordinate of the intersection point have to be negative */ *t2w1wt=t1in+2.0; /* if this is not the case the time is set to t1+2.0 (time point behind the component) */ } }; /* function to calculate the intersection time with an elliptical wall at a positive axis*/ void TIME_ELLIPSE_1(double vxin, double vzin, double xin, double zin, double a2, double b2, double z0, double t1in, double a2wt, double b2wt, double *t2w1, double *t2w1wt) { double m,n,q,p,z1,z2,qwt,pwt, xintersec, z1wt, z2wt, xintersecwt,t2w2,t2w2wt; m=vxin/vzin; n=-m*zin+xin; p=2.0*(a2*m*n+b2*z0)/(a2*m*m+b2); q=(a2*n*n+b2*z0*z0-a2*b2)/(a2*m*m+b2); if ((p*p/4.0)-q<0){ *t2w1=t1in+2.0; }else{ z1=-p/2.0+sqrt(((p)*(p)/4.0)-q); z2=-p/2.0-sqrt(((p)*(p)/4.0)-q); *t2w1=(z1-zin)/vzin; t2w2=(z2-zin)/vzin; if(*t2w1<1e-15) *t2w1=t1in+2.0; if(t2w2<1e-15) t2w2=t1in+2.0; if(t2w2<*t2w1) *t2w1=t2w2; xintersec=m*(vzin*(*t2w1)+zin)+n; if (xintersec<0){ *t2w1=t1in+2.0;} } pwt=2.0*(a2wt*m*n+b2wt*z0)/(a2wt*m*m+b2wt); qwt=(a2wt*n*n+b2wt*z0*z0-a2wt*b2wt)/(a2wt*m*m+b2wt); if ((pwt*pwt/4.0)-qwt<0){ *t2w1wt=t1in+2.0; }else{ z1wt=-pwt/2.0+sqrt((pwt*pwt/4.0)-qwt); z2wt=-pwt/2.0-sqrt((pwt*pwt/4.0)-qwt); *t2w1wt=(z1wt-zin)/vzin; t2w2wt=(z2wt-zin)/vzin; if(*t2w1wt<1e-15) *t2w1wt=t1in+2.0; if(t2w2wt<1e-15) t2w2wt=t1in+2.0; if(t2w2wt<*t2w1wt) *t2w1wt=t2w2wt; xintersecwt=m*(vzin*(*t2w1wt)+zin)+n; if (xintersecwt<0) *t2w1wt=t1in+2.0; } } /* function to calculate the intersection time with a parabolical wall at an negative axis*/ void TIME_PARABEL(double vxin, double vzin, double xin, double zin, double pa, double pb, double t1in, double pawt, double pbwt, double *t2w1, double *t2w1wt) { double m,n,p,q,z1,z2,t2w2,xintersec,pwt,qwt,t2w2wt,z1wt,z2wt,xintersecwt; m=vxin/vzin; /* m parameter of the neutron trajectory*/ n=-m*zin+xin; /* n parameter of the neutron trajectory */ p=(2.0*m*n*pa+1.0)/(pa*m*m); /* p parameter of quadratic equation (INNER side) */ q=n*n/(m*m)-pb/(pa*m*m); /* q parameter of quadratic equation (INNER side) */ if(q>0 && q>(p*p/4)) { /* in the very special case of no intersection the quadratic equation has no solution (negative square root) the time is set to t1+2.0 */ *t2w1=t1in+2.0; }else{ if(vxin==0) /* in the special case of vx = 0 is x a constant */ { if(xin<0){ /* only neutron with a negativ x-component can hit the RIGHT wall (INNER side)*/ *t2w1=(pb-pa*xin*xin-zin)/vzin; }else{ *t2w1=t1in+2.0; /* the time solution for neutron with a positive x component is set to a time long behind the exit of the guide */ /* (means will not scatter with the right wall)*/ } }else{ /* if vx is not zero and x is a real variable*/ z1=-p/2.0+sqrt(p*p/4.0-q); /* first z-solution for intersection (INNER side)*/ z2=-p/2.0-sqrt(p*p/4.0-q); /* second z-solution for intersection (INNER side)*/ *t2w1=(z1-zin)/vzin; /* first time solution (INNER side)*/ t2w2=(z2-zin)/vzin; /* second time solution (INNER side)*/ if(*t2w1<1e-15) /* solving the precision problem for the intersection times given by double variable type, to small times (<1e-15) gives scattering events */ *t2w1=t1in+2.0; /* at the same postion again (time is set to zero). this results in a sign change in the velocity components, which results in a wall tunneling.*/ if(t2w2<1e-15) /* see comments above*/ t2w2=t1in+2.0; if(t2w2<*t2w1) /* choosing the smaller positive time solution (INNER side)*/ *t2w1=t2w2; } xintersec=m*(vzin*(*t2w1)+zin)+n; /* crosscheck of the x-coordinate of the intersection point */ if (xintersec>0){ /* the x-coordinate of the intersection point have to be negative */ *t2w1=t1in+2.0;} /* if this is not the case the time is set to t1+2.0 (time point behind the component) */ } pwt=(2.0*m*n*pawt+1.0)/(pawt*m*m); /* p parameter of quadratic equation (OUTER side)*/ qwt=n*n/(m*m)-pbwt/(pawt*m*m); /* q parameter of quadratic equation (OUTER side)*/ if(qwt>0 && qwt>(pwt*pwt/4)){ /* in the very special case of no intersection the quadratic equation has no solution (negative square root) and the time is set to t1+2.0 */ *t2w1wt=t1in+2.0; }else{ if(vxin==0) /* in the special case of vx = 0 is x a constant */ { if(xin<0){ *t2w1wt=(pbwt-pawt*xin*xin-zin)/vzin; /* only neutron with a negativ x-component can hit the RIGHT wall (OUTER wall)*/ }else{ *t2w1wt=t1in+2.0; } }else{ /* if vx is not zero */ z1wt=-pwt/2.0+sqrt(pwt*pwt/4.0-qwt); /* first z-solution for intersection (OUTER side)*/ z2wt=-pwt/2.0-sqrt(pwt*pwt/4.0-qwt); /* second z-solution for intersection (OUTER side)*/ *t2w1wt=(z1wt-zin)/vzin; /* first time solution (OUTER side)*/ t2w2wt=(z2wt-zin)/vzin; /* second time solution (OUTER side)*/ if(*t2w1wt<1e-15) /* solving the precision problem for the intersection times given by double variable type, to small times (<1e-15) gives scattering events */ *t2w1wt=t1in+2.0; /* at the same postion again (time is set to zero). this results in a sign change in the velocity components, which results in a wall tunneling.*/ if(t2w2wt<1e-15) /* see comments above*/ t2w2wt=t1in+2.0; if(t2w2wt<*t2w1wt) /* choosing the smaller positive time solution (OUTER wall)*/ *t2w1wt=t2w2wt; } xintersecwt=m*(vzin*(*t2w1wt)+zin)+n; /* crosscheck of the x-coordinate of the intersection point */ if (xintersecwt>0) /* x-coordinate of the intersection point have to be negative */ *t2w1wt=t1in+2.0; /* if this is not the case the time is set to t1+2.0 (time point behind the component) */ } }; /* function to calculate the intersection time with a parabolical wall at an positive axis*/ void TIME_PARABEL_1(double vxin, double vzin, double xin, double zin, double pa, double pb, double t1in, double pawt, double pbwt, double *t2w1, double *t2w1wt) { double m,n,p,q,z1,z2,t2w2,xintersec,pwt,qwt,t2w2wt,z1wt,z2wt,xintersecwt; m=vxin/vzin; n=-m*zin+xin; p=(2.0*m*n*pa+1.0)/(pa*m*m); q=n*n/(m*m)-pb/(pa*m*m); if(q>0 && q>(p*p/4)) { *t2w1=t1in+2.0; }else{ if(vxin==0) { if(xin<0){ *t2w1=(pb-pa*xin*xin-zin)/vzin; }else{ *t2w1=t1in+2.0; } }else{ z1=-p/2.0+sqrt(p*p/4.0-q); z2=-p/2.0-sqrt(p*p/4.0-q); *t2w1=(z1-zin)/vzin; t2w2=(z2-zin)/vzin; if(*t2w1<1e-15) *t2w1=t1in+2.0; if(t2w2<1e-15) t2w2=t1in+2.0; if(t2w2<*t2w1) *t2w1=t2w2; } xintersec=m*(vzin*(*t2w1)+zin)+n; if (xintersec<0){ *t2w1=t1in+2.0;} } pwt=(2.0*m*n*pawt+1.0)/(pawt*m*m); qwt=n*n/(m*m)-pbwt/(pawt*m*m); if(qwt>0 && qwt>(pwt*pwt/4)){ *t2w1wt=t1in+2.0; }else{ if(vxin==0) { if(xin<0){ *t2w1wt=(pbwt-pawt*xin*xin-zin)/vzin; }else{ *t2w1wt=t1in+2.0; } }else{ z1wt=-pwt/2.0+sqrt(pwt*pwt/4.0-qwt); z2wt=-pwt/2.0-sqrt(pwt*pwt/4.0-qwt); *t2w1wt=(z1wt-zin)/vzin; t2w2wt=(z2wt-zin)/vzin; if(*t2w1wt<1e-15) *t2w1wt=t1in+2.0; if(t2w2wt<1e-15) t2w2wt=t1in+2.0; if(t2w2wt<*t2w1wt) *t2w1wt=t2w2wt; } xintersecwt=m*(vzin*(*t2w1wt)+zin)+n; if (xintersecwt<0) *t2w1wt=t1in+2.0; } }; /* test if the left or right scattered neutron in the upper and lower limits defined by TOP und BOTTOM walls */ void TEST_UP_DOWN(double t,double vzin, double zin,double vyin,double yin, double length, double linhdin, double louthdin, double linhuin, double louthuin, double h2din, double h1din, double h2uin, double h1uin, double bhdin, double z0hdin, double a2hdin,double bhuin, double z0huin, double a2huin, double pbhdin, double pahdin, double pbhuin, double pahuin, double *ylimitd, double *ylimitu, double *ytest) { if(linhdin==0 && louthdin==0) { *ylimitd=(-h2din+h1din)/length*(vzin*t+zin)-h1din; /* calculation of the lower y-limit given by a linear bottom wall and the interaction time*/ }else{ if(linhdin!=0 && louthdin!=0) { *ylimitd=-bhdin*sqrt(1-((z0hdin+(vzin*t+zin))*(z0hdin+(vzin*t+zin)))/a2hdin); /* calculation of the lower y-limit given by a elliptic bottom wall and the interaction time*/ }else{ *ylimitd=-sqrt(((vzin*t+zin)-pbhdin)/-pahdin); /* calculation of the lower y-limit given by a parabolic bottom wall and the interaction time*/ } } if(linhuin==0 && louthuin==0) { *ylimitu=(h2uin-h1uin)/length*(vzin*t+zin)+h1uin; /* calculation of the upper y-limit given by a linear top wall and the interaction time*/ } else{ if(linhuin!=0 && louthuin!=0) { *ylimitu=bhuin*sqrt(1-((z0huin+(vzin*t+zin))*(z0huin+(vzin*t+zin)))/a2huin); /* calculation of the upper y-limit given by a elliptic top wall and the interaction time*/ }else{ *ylimitu=sqrt(((vzin*t+zin)-pbhuin)/-pahuin); /* calculation of the upper y-limit given by a parabolic top wall and the interaction time*/ } } *ytest=vyin*t+yin; /* calculation of the y coordinate of the neutron at the interaction time */ }; /* test if the up or down scattered neutron in the right and left limits defined by RIGHT und LEFT walls */ void TEST_LEFT_RIGHT(double t,double vzin, double zin,double vxin,double xin, double length, double linwrin, double loutwrin, double linwlin, double loutwlin, double w2rin, double w1rin, double w2lin, double w1lin, double bwrin, double z0wrin, double a2wrin,double bwlin, double z0wlin, double a2wlin, double pbwrin, double pawrin, double pbwlin, double pawlin, double *xlimitr, double *xlimitl, double *xtest) { if(linwrin==0 && loutwrin==0) { *xlimitr=(-w2rin+w1rin)/length*(vzin*t+zin)-w1rin; }else{ if(linwrin!=0 && loutwrin!=0) { *xlimitr=-bwrin*sqrt(1-((z0wrin+(vzin*t+zin))*(z0wrin+(vzin*t+zin)))/a2wrin); }else{ *xlimitr=-sqrt(((vzin*t+zin)-pbwrin)/-pawrin); } } if(linwlin==0 && loutwlin == 0) { *xlimitl=(w2lin-w1lin)/length*(vzin*t+zin)+w1lin; }else{ if(linwlin!=0 && loutwlin != 0) { *xlimitl=bwlin*sqrt(1-((z0wlin+(vzin*t+zin))*(z0wlin+(vzin*t+zin)))/a2wlin); }else{ *xlimitl=sqrt(((vzin*t+zin)-pbwlin)/-pawlin); } } *xtest=vxin*t+xin; }; %} INITIALIZE %{ int i; if (RIreflect && strlen(RIreflect)) { if (Table_Read(&riTable, RIreflect, 1) <= 0) /* read 1st block data from file into pTable */ exit(fprintf(stderr,"right inner Wall: %s: can not read file %s\n", NAME_CURRENT_COMP, RIreflect)); } if (LIreflect && strlen(LIreflect)) { if (Table_Read(&liTable, LIreflect, 1) <= 0) /* read 1st block data from file into pTable */ exit(fprintf(stderr,"left inner Wall: %s: can not read file %s\n", NAME_CURRENT_COMP, LIreflect)); } if (UIreflect && strlen(UIreflect)) { if (Table_Read(&uiTable, UIreflect, 1) <= 0) /* read 1st block data from file into pTable */ exit(fprintf(stderr,"top inner Wall: %s: can not read file %s\n", NAME_CURRENT_COMP, UIreflect)); } if (DIreflect && strlen(DIreflect)) { if (Table_Read(&diTable, DIreflect, 1) <= 0) /* read 1st block data from file into pTable */ exit(fprintf(stderr,"botton inner Wall: %s: can not read file %s\n", NAME_CURRENT_COMP, DIreflect)); } if (ROreflect && strlen(ROreflect)) { if (Table_Read(&roTable, ROreflect, 1) <= 0) /* read 1st block data from file into pTable */ exit(fprintf(stderr,"right outer Wall: %s: can not read file %s\n", NAME_CURRENT_COMP, ROreflect)); } if (LOreflect && strlen(LOreflect)) { if (Table_Read(&loTable, LOreflect, 1) <= 0) /* read 1st block data from file into pTable */ exit(fprintf(stderr,"left outer Wall: %s: can not read file %s\n", NAME_CURRENT_COMP, LOreflect)); } if (UOreflect && strlen(UOreflect)) { if (Table_Read(&uoTable, UOreflect, 1) <= 0) /* read 1st block data from file into pTable */ exit(fprintf(stderr,"top outer Wall: %s: can not read file %s\n", NAME_CURRENT_COMP, UOreflect)); } if (DOreflect && strlen(DOreflect)) { if (Table_Read(&doTable, DOreflect, 1) <= 0) /* read 1st block data from file into pTable */ exit(fprintf(stderr,"botton outer Wall: %s: can not read file %s\n", NAME_CURRENT_COMP, DOreflect)); } if (w1r < 0) TEST_INPUT("w1r"); if (w1l < 0) TEST_INPUT("w1l"); if (h1u < 0) TEST_INPUT("h1u"); if (h1d < 0) TEST_INPUT("h1d"); if (w2r < 0) TEST_INPUT("w2r"); if (w2l < 0) TEST_INPUT("w2l"); if (h2u < 0) TEST_INPUT("h2u"); if (h2d < 0) TEST_INPUT("h2d"); if (mxrOW !=-1 && mxrOW < 0) TEST_INPUT_1("mxrOW"); if (mxlOW !=-1 && mxlOW < 0) TEST_INPUT_1("mxlOW"); if (myuOW !=-1 && myuOW < 0) TEST_INPUT_1("myuOW"); if (mydOW !=-1 && mydOW < 0) TEST_INPUT_1("mydOW"); if (mxr < 0 && mxr!=-1) TEST_INPUT_1("mxr"); if (mxl < 0 && mxl!=-1) TEST_INPUT_1("mxl"); if (myu < 0 && myu!=-1) TEST_INPUT_1("myu"); if (myd < 0 && myd!=-1) TEST_INPUT_1("myd"); if (Qcxl < 0) TEST_INPUT_2("Qcxl"); if (Qcxr < 0) TEST_INPUT_2("Qcxr"); if (Qcyu < 0) TEST_INPUT_2("Qcyu"); if (Qcyd < 0) TEST_INPUT_2("Qcyd"); if (alphaxl < 0) TEST_INPUT_2("alphaxl"); if (alphaxr < 0) TEST_INPUT_2("alphaxr"); if (alphayu < 0) TEST_INPUT_2("alphayu"); if (alphayd < 0) TEST_INPUT_2("alphayd"); if (QcxlOW < 0) TEST_INPUT_2("QcxlOW"); if (QcxrOW < 0) TEST_INPUT_2("QcxrOW"); if (QcyuOW < 0) TEST_INPUT_2("QcyuOW"); if (QcydOW < 0) TEST_INPUT_2("QcydOW"); if (alphaxlOW < 0) TEST_INPUT_2("alphaxlOW"); if (alphaxrOW < 0) TEST_INPUT_2("alphaxrOW"); if (alphayuOW < 0) TEST_INPUT_2("alphayuOW"); if (alphaydOW < 0) TEST_INPUT_2("alphaydOW"); if (rwallthick < 0) TEST_INPUT_2("rwallthick"); if (lwallthick < 0) TEST_INPUT_2("lwallthick"); if (uwallthick < 0) TEST_INPUT_2("uwallthick"); if (dwallthick < 0) TEST_INPUT_2("dwallthick"); if (Wxr <=0) TEST_INPUT_3("Wxr"); if (Wxl <=0) TEST_INPUT_3("Wxl"); if (Wyu <=0) TEST_INPUT_3("Wyu"); if (Wyd <=0) TEST_INPUT_3("Wyd"); if (WxrOW <=0) TEST_INPUT_3("WxrOW"); if (WxlOW <=0) TEST_INPUT_3("WxlOW"); if (WyuOW <=0) TEST_INPUT_3("WyuOW"); if (WydOW <=0) TEST_INPUT_3("WydOW"); if (RIreflect1 && strlen(RIreflect1)) { if (Table_Read(&riTable1, RIreflect1, 1) <= 0) /* read 1st block data from file into pTable */ exit(fprintf(stderr,"right inner Wall: %s: can not read file %s\n", NAME_CURRENT_COMP, RIreflect1)); } if (LIreflect1 && strlen(LIreflect1)) { if (Table_Read(&liTable1, LIreflect1, 1) <= 0) /* read 1st block data from file into pTable */ exit(fprintf(stderr,"left inner Wall: %s: can not read file %s\n", NAME_CURRENT_COMP, LIreflect1)); } if (UIreflect1 && strlen(UIreflect1)) { if (Table_Read(&uiTable1, UIreflect1, 1) <= 0) /* read 1st block data from file into pTable */ exit(fprintf(stderr,"top inner Wall: %s: can not read file %s\n", NAME_CURRENT_COMP, UIreflect1)); } if (DIreflect1 && strlen(DIreflect1)) { if (Table_Read(&diTable1, DIreflect1, 1) <= 0) /* read 1st block data from file into pTable */ exit(fprintf(stderr,"botton inner Wall: %s: can not read file %s\n", NAME_CURRENT_COMP, DIreflect1)); } if (ROreflect1 && strlen(ROreflect1)) { if (Table_Read(&roTable1, ROreflect1, 1) <= 0) /* read 1st block data from file into pTable */ exit(fprintf(stderr,"right outer Wall: %s: can not read file %s\n", NAME_CURRENT_COMP, ROreflect1)); } if (LOreflect1 && strlen(LOreflect1)) { if (Table_Read(&loTable1, LOreflect1, 1) <= 0) /* read 1st block data from file into pTable */ exit(fprintf(stderr,"left outer Wall: %s: can not read file %s\n", NAME_CURRENT_COMP, LOreflect1)); } if (UOreflect1 && strlen(UOreflect1)) { if (Table_Read(&uoTable1, UOreflect1, 1) <= 0) /* read 1st block data from file into pTable */ exit(fprintf(stderr,"top outer Wall: %s: can not read file %s\n", NAME_CURRENT_COMP, UOreflect1)); } if (DOreflect1 && strlen(DOreflect1)) { if (Table_Read(&doTable1, DOreflect1, 1) <= 0) /* read 1st block data from file into pTable */ exit(fprintf(stderr,"botton outer Wall: %s: can not read file %s\n", NAME_CURRENT_COMP, DOreflect1)); } if (w1r1 < 0) TEST_INPUT("w1r1"); if (w1l1 < 0) TEST_INPUT("w1l1"); if (h1u1 < 0) TEST_INPUT("h1u1"); if (h1d1 < 0) TEST_INPUT("h1d1"); if (w2r1 < 0) TEST_INPUT("w2r1"); if (w2l1 < 0) TEST_INPUT("w2l1"); if (h2u1 < 0) TEST_INPUT("h2u1"); if (h2d1 < 0) TEST_INPUT("h2d1"); if (mxrOW1 !=-1 && mxrOW1 < 0) TEST_INPUT_1("mxrOW1"); if (mxlOW1 !=-1 && mxlOW1 < 0) TEST_INPUT_1("mxlOW1"); if (myuOW1 !=-1 && myuOW1 < 0) TEST_INPUT_1("myuOW1"); if (mydOW1 !=-1 && mydOW1 < 0) TEST_INPUT_1("mydOW1"); if (mxr1 < 0 && mxr1!=-1) TEST_INPUT_1("mxr1"); if (mxl1 < 0 && mxl1!=-1) TEST_INPUT_1("mxl1"); if (myu1 < 0 && myu1!=-1) TEST_INPUT_1("myu1"); if (myd1 < 0 && myd1!=-1) TEST_INPUT_1("myd1"); if (Qcxl1 < 0) TEST_INPUT_2("Qcxl1"); if (Qcxr1 < 0) TEST_INPUT_2("Qcxr1"); if (Qcyu1 < 0) TEST_INPUT_2("Qcyu1"); if (Qcyd1 < 0) TEST_INPUT_2("Qcyd1"); if (alphaxl1 < 0) TEST_INPUT_2("alphaxl1"); if (alphaxr1 < 0) TEST_INPUT_2("alphaxr1"); if (alphayu1 < 0) TEST_INPUT_2("alphayu1"); if (alphayd1 < 0) TEST_INPUT_2("alphayd1"); if (QcxlOW1 < 0) TEST_INPUT_2("QcxlOW1"); if (QcxrOW1 < 0) TEST_INPUT_2("QcxrOW1"); if (QcyuOW1 < 0) TEST_INPUT_2("QcyuOW1"); if (QcydOW1 < 0) TEST_INPUT_2("QcydOW1"); if (alphaxlOW1 < 0) TEST_INPUT_2("alphaxlOW1"); if (alphaxrOW1 < 0) TEST_INPUT_2("alphaxrOW1"); if (alphayuOW1 < 0) TEST_INPUT_2("alphayuOW1"); if (alphaydOW1 < 0) TEST_INPUT_2("alphaydOW1"); if (rwallthick1 < 0) TEST_INPUT_2("rwallthick1"); if (lwallthick1 < 0) TEST_INPUT_2("lwallthick1"); if (uwallthick1 < 0) TEST_INPUT_2("uwallthick1"); if (dwallthick1 < 0) TEST_INPUT_2("dwallthick1"); if (Wxr1 <=0) TEST_INPUT_3("Wxr1"); if (Wxl1 <=0) TEST_INPUT_3("Wxl1"); if (Wyu1 <=0) TEST_INPUT_3("Wyu1"); if (Wyd1 <=0) TEST_INPUT_3("Wyd1"); if (WxrOW1 <=0) TEST_INPUT_3("WxrOW1"); if (WxlOW1 <=0) TEST_INPUT_3("WxlOW1"); if (WyuOW1 <=0) TEST_INPUT_3("WyuOW1"); if (WydOW1 <=0) TEST_INPUT_3("WydOW1"); if (RIreflect2 && strlen(RIreflect2)) { if (Table_Read(&riTable2, RIreflect2, 1) <= 0) /* read 1st block data from file into pTable */ exit(fprintf(stderr,"right inner Wall: %s: can not read file %s\n", NAME_CURRENT_COMP, RIreflect2)); } if (LIreflect2 && strlen(LIreflect2)) { if (Table_Read(&liTable2, LIreflect2, 1) <= 0) /* read 1st block data from file into pTable */ exit(fprintf(stderr,"left inner Wall: %s: can not read file %s\n", NAME_CURRENT_COMP, LIreflect2)); } if (UIreflect2 && strlen(UIreflect2)) { if (Table_Read(&uiTable2, UIreflect2, 1) <= 0) /* read 1st block data from file into pTable */ exit(fprintf(stderr,"top inner Wall: %s: can not read file %s\n", NAME_CURRENT_COMP, UIreflect2)); } if (DIreflect2 && strlen(DIreflect2)) { if (Table_Read(&diTable2, DIreflect2, 1) <= 0) /* read 1st block data from file into pTable */ exit(fprintf(stderr,"botton inner Wall: %s: can not read file %s\n", NAME_CURRENT_COMP, DIreflect2)); } if (ROreflect2 && strlen(ROreflect2)) { if (Table_Read(&roTable2, ROreflect2, 1) <= 0) /* read 1st block data from file into pTable */ exit(fprintf(stderr,"right outer Wall: %s: can not read file %s\n", NAME_CURRENT_COMP, ROreflect2)); } if (LOreflect2 && strlen(LOreflect2)) { if (Table_Read(&loTable2, LOreflect2, 1) <= 0) /* read 1st block data from file into pTable */ exit(fprintf(stderr,"left outer Wall: %s: can not read file %s\n", NAME_CURRENT_COMP, LOreflect2)); } if (UOreflect2 && strlen(UOreflect2)) { if (Table_Read(&uoTable2, UOreflect2, 1) <= 0) /* read 1st block data from file into pTable */ exit(fprintf(stderr,"top outer Wall: %s: can not read file %s\n", NAME_CURRENT_COMP, UOreflect2)); } if (DOreflect2 && strlen(DOreflect2)) { if (Table_Read(&doTable2, DOreflect2, 1) <= 0) /* read 1st block data from file into pTable */ exit(fprintf(stderr,"botton outer Wall: %s: can not read file %s\n", NAME_CURRENT_COMP, DOreflect2)); } if (w1r2 < 0) TEST_INPUT("w1r2"); if (w1l2 < 0) TEST_INPUT("w1l2"); if (h1u2 < 0) TEST_INPUT("h1u2"); if (h1d2 < 0) TEST_INPUT("h1d2"); if (w2r2 < 0) TEST_INPUT("w2r2"); if (w2l2 < 0) TEST_INPUT("w2l2"); if (h2u2 < 0) TEST_INPUT("h2u2"); if (h2d2 < 0) TEST_INPUT("h2d2"); if (mxrOW2 !=-1 && mxrOW2 < 0) TEST_INPUT_1("mxrOW2"); if (mxlOW2 !=-1 && mxlOW2 < 0) TEST_INPUT_1("mxlOW2"); if (myuOW2 !=-1 && myuOW2 < 0) TEST_INPUT_1("myuOW2"); if (mydOW2 !=-1 && mydOW2 < 0) TEST_INPUT_1("mydOW2"); if (mxr2 < 0 && mxr2!=-1) TEST_INPUT_1("mxr2"); if (mxl2 < 0 && mxl2!=-1) TEST_INPUT_1("mxl2"); if (myu2 < 0 && myu2!=-1) TEST_INPUT_1("myu2"); if (myd2 < 0 && myd2!=-1) TEST_INPUT_1("myd2"); if (Qcxl2 < 0) TEST_INPUT_2("Qcxl2"); if (Qcxr2 < 0) TEST_INPUT_2("Qcxr2"); if (Qcyu2 < 0) TEST_INPUT_2("Qcyu2"); if (Qcyd2 < 0) TEST_INPUT_2("Qcyd2"); if (alphaxl2 < 0) TEST_INPUT_2("alphaxl2"); if (alphaxr2 < 0) TEST_INPUT_2("alphaxr2"); if (alphayu2 < 0) TEST_INPUT_2("alphayu2"); if (alphayd2 < 0) TEST_INPUT_2("alphayd2"); if (QcxlOW2 < 0) TEST_INPUT_2("QcxlOW2"); if (QcxrOW2 < 0) TEST_INPUT_2("QcxrOW2"); if (QcyuOW2 < 0) TEST_INPUT_2("QcyuOW2"); if (QcydOW2 < 0) TEST_INPUT_2("QcydOW2"); if (alphaxlOW2 < 0) TEST_INPUT_2("alphaxlOW2"); if (alphaxrOW2 < 0) TEST_INPUT_2("alphaxrOW2"); if (alphayuOW2 < 0) TEST_INPUT_2("alphayuOW2"); if (alphaydOW2 < 0) TEST_INPUT_2("alphaydOW2"); if (rwallthick2 < 0) TEST_INPUT_2("rwallthick2"); if (lwallthick2 < 0) TEST_INPUT_2("lwallthick2"); if (uwallthick2 < 0) TEST_INPUT_2("uwallthick2"); if (dwallthick2 < 0) TEST_INPUT_2("dwallthick2"); if (Wxr2 <=0) TEST_INPUT_3("Wxr2"); if (Wxl2 <=0) TEST_INPUT_3("Wxl2"); if (Wyu2 <=0) TEST_INPUT_3("Wyu2"); if (Wyd2 <=0) TEST_INPUT_3("Wyd2"); if (WxrOW2 <=0) TEST_INPUT_3("WxrOW2"); if (WxlOW2 <=0) TEST_INPUT_3("WxlOW2"); if (WyuOW2 <=0) TEST_INPUT_3("WyuOW2"); if (WydOW2 <=0) TEST_INPUT_3("WydOW2"); if (l <= 0) { fprintf(stderr,"Component: %s (Guide_four_side) real guide length \n", NAME_CURRENT_COMP); fprintf(stderr," is <= ZERO ! \n"); exit(-1); } if (mcgravitation) fprintf(stderr,"WARNING: Guide_four_side: %s: " "This component produces wrong results with gravitation !\n" "Use Guide_gravity.\n", NAME_CURRENT_COMP); /* Calculation of curve-parameters for the right side wall - negative x-axis */ /* Calculation of curve-parameters for the right side wall - negative x-axis */ if(loutwr!=0 && linwr!=0) /* elliptic right side wall */ { ELLIPSE(w1r, l, linwr, loutwr, rwallthick, &awr, &bwr, &a2wr, &b2wr, &z0wr, &w2r, &awrwt, &a2wrwt, &bwrwt, &b2wrwt, &w2rwt, &w1rwt); } if(linwr==0 && loutwr!=0) /* parabolic focusing right side wall */ { PARABEL_FOCUS( w1r,l ,loutwr, rwallthick, &p2parawr, &w2r, &pbwr , &pawr, &p2parawrwt, &pbwrwt, &pawrwt, &w2rwt, &w1rwt); } if (linwr!=0 && loutwr==0) /* parabolic defocusing right side wall */ { PARABEL_DEFOCUS( w1r,l ,linwr, rwallthick, &p2parawr, &w2r, &pbwr , &pawr, &p2parawrwt, &pbwrwt, &pawrwt, &w2rwt, &w1rwt); } if(linwr==0 && loutwr==0) /* straight right side wall */ { LINEAR(w1r, w2r, l, rwallthick, &w1rwt, &w2rwt); } /* Calculation of curve-parameters for the left side wall - positive x-axis - analog to right side*/ if((linwl!=0) && (loutwl!=0) ) /* elleptic left side wall */ { ELLIPSE(w1l, l, linwl, loutwl, lwallthick, &awl, &bwl, &a2wl, &b2wl, &z0wl, &w2l, &awlwt, &a2wlwt, &bwlwt, &b2wlwt, &w2lwt, &w1lwt); } if(linwl==0 && loutwl!=0) /* parabolic focusing left side wall */ { PARABEL_FOCUS( w1l,l ,loutwl, lwallthick, &p2parawl, &w2l, &pbwl , &pawl, &p2parawlwt, &pbwlwt, &pawlwt, &w2lwt, &w1lwt); } if (linwl!=0 && loutwl==0) /* parabolic defocusing left side wall */ { PARABEL_DEFOCUS( w1l,l ,linwl, lwallthick, &p2parawl, &w2l, &pbwl , &pawl, &p2parawlwt, &pbwlwt, &pawlwt, &w2lwt, &w1lwt); } if(linwl==0 && loutwl==0) /* straight left side wall */ { LINEAR(w1l, w2l, l, lwallthick, &w1lwt, &w2lwt); } /* Calculation of curve-parameters for the top wall - positive y-axis - analog right wall*/ if (linhu != 0 && louthu !=0) /* elliptic top wall */ { ELLIPSE(h1u, l, linhu, louthu, uwallthick, &ahu, &bhu, &a2hu, &b2hu, &z0hu , &h2u, &ahuwt, &a2huwt, &bhuwt, &b2huwt, &h2uwt, &h1uwt); } if(linhu==0 && louthu!=0) /* parabolic focusing top wall */ { PARABEL_FOCUS( h1u,l ,louthu, uwallthick, &p2parahu, &h2u, &pbhu , &pahu, &p2parahuwt, &pbhuwt, &pahuwt, &h2uwt, &h1uwt); } if (linhu!=0 && louthu==0) /* parabolic defocusing top wall */ { PARABEL_DEFOCUS( h1u,l ,linhu, uwallthick, &p2parahu, &h2u, &pbhu , &pahu, &p2parahuwt, &pbhuwt, &pahuwt, &h2uwt, &h1uwt); } if(linhu==0 && louthu==0) { LINEAR(h1u, h2u, l, uwallthick, &h1uwt, &h2uwt); } /* Calculation of curve-parameters for the bottom wall - negative y-axis - analog right wall */ if (linhd != 0 && louthd !=0) /* elliptic bottom wall */ { ELLIPSE(h1d, l, linhd, louthd, dwallthick, &ahd, &bhd, &a2hd, &b2hd, &z0hd, &h2d, &ahdwt, &a2hdwt, &bhdwt, &b2hdwt, &h2dwt, &h1dwt); } if(linhd==0 && louthd!=0) /* parabolic focusing bottom wall */ { PARABEL_FOCUS( h1d,l ,louthd, dwallthick, &p2parahd, &h2d, &pbhd , &pahd, &p2parahdwt, &pbhdwt, &pahdwt, &h2dwt, &h1dwt); } if (linhd!=0 && louthd==0) /* parabolic defocusing bottom wall */ { PARABEL_DEFOCUS( h1d,l ,linhd, dwallthick, &p2parahd, &h2d, &pbhd , &pahd, &p2parahdwt, &pbhdwt, &pahdwt, &h2dwt, &h1dwt); } if(linhd==0 && louthd==0) { LINEAR(h1d, h2d, l, dwallthick, &h1dwt, &h2dwt); } mru1=(h1uwt-h1u)/(w1r-w1rwt); /* calculation for entrance and exit absorbing mask for the right upper corner*/ nru1=h1u-mru1*(-w1r); mrd1=(-h1dwt+h1d)/(w1r-w1rwt); /* calculation for entrance and exit absorbing mask for the right lower corner*/ nrd1=-h1d-mrd1*(-w1r); mlu1=(h1uwt-h1u)/(-w1l+w1lwt); /* calculation for entrance and exit absorbing mask for the left upper corner*/ nlu1=h1u-mlu1*w1l; mld1=(-h1dwt+h1d)/(-w1l+w1lwt); /* calculation for entrance and exit absorbing mask for the left lower corner*/ nld1=-h1d-mld1*w1l; mru2=(h2u-h2uwt)/(-w2r+w2rwt); /* calculation for exit absorbing mask for the right upper corner*/ nru2=h2u-mru2*(-w2r); mrd2=(-h2d+h2dwt)/(-w2r+w2rwt); /* calculation for exit absorbing mask for the right lower corner*/ nrd2=-h2d-mrd2*(-w2r); mlu2=(h2u-h2uwt)/(w2l-w2lwt); /* calculation for exit absorbing mask for the left upper corner*/ nlu2=h2u-mlu2*w2l; mld2=(h2dwt-h2d)/(w2l-w2lwt); /* calculation for exit absorbing mask for the left lower corner*/ nld2=-h2d-mld2*w2l; /* FIRST SHELL */ if(loutwr1!=0 && linwr1!=0) /* elliptic right side wall */ { ELLIPSE(w1r1, l, linwr1, loutwr1, rwallthick1, &awr1, &bwr1, &a2wr1, &b2wr1, &z0wr1, &w2r1, &awrwt1, &a2wrwt1, &bwrwt1, &b2wrwt1, &w2rwt1, &w1rwt1); } if(linwr1==0 && loutwr1!=0) /* parabolic focusing right side wall */ { PARABEL_FOCUS( w1r1,l ,loutwr1, rwallthick1, &p2parawr1, &w2r1, &pbwr1 , &pawr1, &p2parawrwt1, &pbwrwt1, &pawrwt1, &w2rwt1, &w1rwt1); } if (linwr1!=0 && loutwr1==0) /* parabolic defocusing right side wall */ { PARABEL_DEFOCUS( w1r1,l ,linwr1, rwallthick1, &p2parawr1, &w2r1, &pbwr1 , &pawr1, &p2parawrwt1, &pbwrwt1, &pawrwt1, &w2rwt1, &w1rwt1); } if(linwr1==0 && loutwr1==0) /* straight right side wall */ { LINEAR(w1r1, w2r1, l, rwallthick1, &w1rwt1, &w2rwt1); } /* Calculation of curve-parameters for the left side wall - positive x-axis - analog to right side*/ if((linwl1!=0) && (loutwl1!=0) ) /* elleptic left side wall */ { ELLIPSE(w1l1, l, linwl1, loutwl1, lwallthick1, &awl1, &bwl1, &a2wl1, &b2wl1, &z0wl1, &w2l1, &awlwt1, &a2wlwt1, &bwlwt1, &b2wlwt1, &w2lwt1, &w1lwt1); } if(linwl1==0 && loutwl1!=0) /* parabolic focusing left side wall */ { PARABEL_FOCUS( w1l1,l ,loutwl1, lwallthick1, &p2parawl1, &w2l1, &pbwl1 , &pawl1, &p2parawlwt1, &pbwlwt1, &pawlwt1, &w2lwt1, &w1lwt1); } if (linwl1!=0 && loutwl1==0) /* parabolic defocusing left side wall */ { PARABEL_DEFOCUS( w1l1,l ,linwl1, lwallthick1, &p2parawl1, &w2l1, &pbwl1 , &pawl1, &p2parawlwt1, &pbwlwt1, &pawlwt1, &w2lwt1, &w1lwt1); } if(linwl1==0 && loutwl1==0) /* straight left side wall */ { LINEAR(w1l1, w2l1, l, lwallthick1, &w1lwt1, &w2lwt1); } /* Calculation of curve-parameters for the top wall - positive y-axis - analog right wall*/ if (linhu1 != 0 && louthu1 !=0) /* elliptic top wall */ { ELLIPSE(h1u1, l, linhu1, louthu1, uwallthick1, &ahu1, &bhu1, &a2hu1, &b2hu1, &z0hu1 , &h2u1, &ahuwt1, &a2huwt1, &bhuwt1, &b2huwt1, &h2uwt1, &h1uwt1); } if(linhu1==0 && louthu1!=0) /* parabolic focusing top wall */ { PARABEL_FOCUS( h1u1,l ,louthu1, uwallthick1, &p2parahu1, &h2u1, &pbhu1 , &pahu1, &p2parahuwt1, &pbhuwt1, &pahuwt1, &h2uwt1, &h1uwt1); } if (linhu1!=0 && louthu1==0) /* parabolic defocusing top wall */ { PARABEL_DEFOCUS( h1u1,l ,linhu1, uwallthick1, &p2parahu1, &h2u1, &pbhu1 , &pahu1, &p2parahuwt1, &pbhuwt1, &pahuwt1, &h2uwt1, &h1uwt1); } if(linhu1==0 && louthu1==0) { LINEAR(h1u1, h2u1, l, uwallthick1, &h1uwt1, &h2uwt1); } /* Calculation of curve-parameters for the bottom wall - negative y-axis - analog right wall */ if (linhd1 != 0 && louthd1 !=0) /* elliptic bottom wall */ { ELLIPSE(h1d1, l, linhd1, louthd1, dwallthick1, &ahd1, &bhd1, &a2hd1, &b2hd1, &z0hd1, &h2d1, &ahdwt1, &a2hdwt1, &bhdwt1, &b2hdwt1, &h2dwt1, &h1dwt1); } if(linhd1==0 && louthd1!=0) /* parabolic focusing bottom wall */ { PARABEL_FOCUS( h1d1,l ,louthd1, dwallthick1, &p2parahd1, &h2d1, &pbhd1 , &pahd1, &p2parahdwt1, &pbhdwt1, &pahdwt1, &h2dwt1, &h1dwt1); } if (linhd1!=0 && louthd1==0) /* parabolic defocusing bottom wall */ { PARABEL_DEFOCUS( h1d1,l ,linhd1, dwallthick1, &p2parahd1, &h2d1, &pbhd1 , &pahd1, &p2parahdwt1, &pbhdwt1, &pahdwt1, &h2dwt1, &h1dwt1); } if(linhd1==0 && louthd1==0) { LINEAR(h1d1, h2d1, l, dwallthick1, &h1dwt1, &h2dwt1); } mru11=(h1uwt1-h1u1)/(w1r1-w1rwt1); /* calculation for entrance and exit absorbing mask for the right upper corner*/ nru11=h1u1-mru11*(-w1r1); mrd11=(-h1dwt1+h1d1)/(w1r1-w1rwt1); /* calculation for entrance and exit absorbing mask for the right lower corner*/ nrd11=-h1d1-mrd11*(-w1r1); mlu11=(h1uwt1-h1u1)/(-w1l1+w1lwt1); /* calculation for entrance and exit absorbing mask for the left upper corner*/ nlu11=h1u1-mlu11*w1l1; mld11=(-h1dwt1+h1d1)/(-w1l1+w1lwt1); /* calculation for entrance and exit absorbing mask for the left lower corner*/ nld11=-h1d1-mld11*w1l1; mru21=(h2u1-h2uwt1)/(-w2r1+w2rwt1); /* calculation for exit absorbing mask for the right upper corner*/ nru21=h2u1-mru21*(-w2r1); mrd21=(-h2d1+h2dwt1)/(-w2r1+w2rwt1); /* calculation for exit absorbing mask for the right lower corner*/ nrd21=-h2d1-mrd21*(-w2r1); mlu21=(h2u1-h2uwt1)/(w2l1-w2lwt1); /* calculation for exit absorbing mask for the left upper corner*/ nlu21=h2u1-mlu21*w2l1; mld21=(h2dwt1-h2d1)/(w2l1-w2lwt1); /* calculation for exit absorbing mask for the left lower corner*/ nld21=-h2d1-mld21*w2l1; if (w1r1 < w1rwt ) TEST_INPUT_4("w1r1", "w1rwt", w1r1, w1rwt); if (w1l1 < w1lwt ) TEST_INPUT_4("w1l1", "w1lwt", w1l1, w1lwt); if (h1u1 < h1uwt ) TEST_INPUT_4("h1u1", "h1uwt", h1u1, h1uwt); if (h1d1 < h1dwt ) TEST_INPUT_4("h1d1", "h1dwt", h1d1, h1dwt); if (w2r1 < w2rwt ) TEST_INPUT_4("w2r1", "w2rwt", w2r1, w2rwt); if (w2l1 < w2lwt ) TEST_INPUT_4("w2l1", "w2lwt", w2l1, w2lwt); if (h2u1 < h2uwt ) TEST_INPUT_4("h2u1", "h2uwt", h2u1, h2uwt); if (h2d1 < h2dwt ) TEST_INPUT_4("h2d1", "h2dwt", h2d1, h2dwt); /* SECOND SHELL */ if(loutwr2!=0 && linwr2!=0) /* elliptic right side wall */ { ELLIPSE(w1r2, l, linwr2, loutwr2, rwallthick2, &awr2, &bwr2, &a2wr2, &b2wr2, &z0wr2, &w2r2, &awrwt2, &a2wrwt2, &bwrwt2, &b2wrwt2, &w2rwt2, &w1rwt2); } if(linwr2==0 && loutwr2!=0) /* parabolic focusing right side wall */ { PARABEL_FOCUS( w1r2,l ,loutwr2, rwallthick2, &p2parawr2, &w2r2, &pbwr2 , &pawr2, &p2parawrwt2, &pbwrwt2, &pawrwt2, &w2rwt2, &w1rwt2); } if (linwr2!=0 && loutwr2==0) /* parabolic defocusing right side wall */ { PARABEL_DEFOCUS( w1r2,l ,linwr2, rwallthick2, &p2parawr2, &w2r2, &pbwr2 , &pawr2, &p2parawrwt2, &pbwrwt2, &pawrwt2, &w2rwt2, &w1rwt2); } if(linwr2==0 && loutwr2==0) /* straight right side wall */ { LINEAR(w1r2, w2r2, l, rwallthick2, &w1rwt2, &w2rwt2); } /* Calculation of curve-parameters for the left side wall - positive x-axis - analog to right side*/ if((linwl2!=0) && (loutwl2!=0) ) /* elleptic left side wall */ { ELLIPSE(w1l2, l, linwl2, loutwl2, lwallthick2, &awl2, &bwl2, &a2wl2, &b2wl2, &z0wl2, &w2l2, &awlwt2, &a2wlwt2, &bwlwt2, &b2wlwt2, &w2lwt2, &w1lwt2); } if(linwl2==0 && loutwl2!=0) /* parabolic focusing left side wall */ { PARABEL_FOCUS( w1l2,l ,loutwl2, lwallthick2, &p2parawl2, &w2l2, &pbwl2 , &pawl2, &p2parawlwt2, &pbwlwt2, &pawlwt2, &w2lwt2, &w1lwt2); } if (linwl2!=0 && loutwl2==0) /* parabolic defocusing left side wall */ { PARABEL_DEFOCUS( w1l2,l ,linwl2, lwallthick2, &p2parawl2, &w2l2, &pbwl2 , &pawl2, &p2parawlwt2, &pbwlwt2, &pawlwt2, &w2lwt2, &w1lwt2); } if(linwl2==0 && loutwl2==0) /* straight left side wall */ { LINEAR(w1l2, w2l2, l, lwallthick2, &w1lwt2, &w2lwt2); } /* Calculation of curve-parameters for the top wall - positive y-axis - analog right wall*/ if (linhu2 != 0 && louthu2 !=0) /* elliptic top wall */ { ELLIPSE(h1u2, l, linhu2, louthu2, uwallthick2, &ahu2, &bhu2, &a2hu2, &b2hu2, &z0hu2 , &h2u2, &ahuwt2, &a2huwt2, &bhuwt2, &b2huwt2, &h2uwt2, &h1uwt2); } if(linhu2==0 && louthu2!=0) /* parabolic focusing top wall */ { PARABEL_FOCUS( h1u2,l ,louthu2, uwallthick2, &p2parahu2, &h2u2, &pbhu2 , &pahu2, &p2parahuwt2, &pbhuwt2, &pahuwt2, &h2uwt2, &h1uwt2); } if (linhu2!=0 && louthu2==0) /* parabolic defocusing top wall */ { PARABEL_DEFOCUS( h1u2,l ,linhu2, uwallthick2, &p2parahu2, &h2u2, &pbhu2 , &pahu2, &p2parahuwt2, &pbhuwt2, &pahuwt2, &h2uwt2, &h1uwt2); } if(linhu2==0 && louthu2==0) { LINEAR(h1u2, h2u2, l, uwallthick2, &h1uwt2, &h2uwt2); } /* Calculation of curve-parameters for the bottom wall - negative y-axis - analog right wall */ if (linhd2 != 0 && louthd2 !=0) /* elliptic top wall */ { ELLIPSE(h1d2, l, linhd2, louthd2, uwallthick2, &ahd2, &bhd2, &a2hd2, &b2hd2, &z0hd2 , &h2d2, &ahdwt2, &a2hdwt2, &bhdwt2, &b2hdwt2, &h2dwt2, &h1dwt2); } if(linhd2==0 && louthd2!=0) /* parabolic focusing bottom wall */ { PARABEL_FOCUS( h1d2,l ,louthd2, dwallthick2, &p2parahd2, &h2d2, &pbhd2 , &pahd2, &p2parahdwt2, &pbhdwt2, &pahdwt2, &h2dwt2, &h1dwt2); } if (linhd2!=0 && louthd2==0) /* parabolic defocusing bottom wall */ { PARABEL_DEFOCUS( h1d2,l ,linhd2, dwallthick2, &p2parahd2, &h2d2, &pbhd2 , &pahd2, &p2parahdwt2, &pbhdwt2, &pahdwt2, &h2dwt2, &h1dwt2); } if(linhd2==0 && louthd2==0) { LINEAR(h1d2, h2d2, l, dwallthick2, &h1dwt2, &h2dwt2); } mru12=(h1uwt2-h1u2)/(w1r2-w1rwt2); /* calculation for entrance and exit absorbing mask for the right upper corner*/ nru12=h1u2-mru12*(-w1r2); mrd12=(-h1dwt2+h1d2)/(w1r2-w1rwt2); /* calculation for entrance and exit absorbing mask for the right lower corner*/ nrd12=-h1d2-mrd12*(-w1r2); mlu12=(h1uwt2-h1u2)/(-w1l2+w1lwt2); /* calculation for entrance and exit absorbing mask for the left upper corner*/ nlu12=h1u2-mlu12*w1l2; mld12=(-h1dwt2+h1d2)/(-w1l2+w1lwt2); /* calculation for entrance and exit absorbing mask for the left lower corner*/ nld12=-h1d2-mld12*w1l2; mru22=(h2u2-h2uwt2)/(-w2r2+w2rwt2); /* calculation for exit absorbing mask for the right upper corner*/ nru22=h2u2-mru22*(-w2r2); mrd22=(-h2d2+h2dwt2)/(-w2r2+w2rwt2); /* calculation for exit absorbing mask for the right lower corner*/ nrd22=-h2d2-mrd22*(-w2r2); mlu22=(h2u2-h2uwt2)/(w2l2-w2lwt2); /* calculation for exit absorbing mask for the left upper corner*/ nlu22=h2u2-mlu22*w2l2; mld22=(h2dwt2-h2d2)/(w2l2-w2lwt2); /* calculation for exit absorbing mask for the left lower corner*/ nld22=-h2d2-mld22*w2l2; if (w1r2 < w1rwt1 ) TEST_INPUT_4("w1r2", "w1rwt1", w1r2, w1rwt1); if (w1l2 < w1lwt1 ) TEST_INPUT_4("w1l2", "w1lwt1", w1l2, w1lwt1); if (h1u2 < h1uwt1 ) TEST_INPUT_4("h1u2", "h1uwt1", h1u2, h1uwt1); if (h1d2 < h1dwt1 ) TEST_INPUT_4("h1d2", "h1dwt1", h1d2, h1dwt1); if (w2r2 < w2rwt1 ) TEST_INPUT_4("w2r2", "w2rwt1", w2r2, w2rwt1); if (w2l2 < w2lwt1 ) TEST_INPUT_4("w2l2", "w2lwt1", w2l2, w2lwt1); if (h2u2 < h2uwt1 ) TEST_INPUT_4("h2u2", "h2uwt1", h2u2, h2uwt1); if (h2d2 < h2dwt1 ) TEST_INPUT_4("h2d2", "h2dwt1", h2d2, h2dwt1); %} TRACE %{ int i; PROP_Z0; /* Propagate neutron to guide entrance. */ if(x <= -w1r && x >= -w1rwt && y <= mru1*x+nru1 && y>= mrd1*x+nrd1 && mxr!=-1 && mxrOW!=-1) /* absorbing the neutron if it hit the RIGHT entrance wall and the wall is not transparent*/ ABSORB; if(x >= w1l && x <= w1lwt && y <= mlu1*x+nlu1 && y>= mld1*x+nld1 && mxl!=-1 && mxlOW!=-1 ) /* absorbing the neutron if it hit the LEFT entrance wall and the wall is not transparent*/ ABSORB; if(y<=-h1d && y >=-h1dwt && x <= (y-nld1)/mld1 && x>= (y-nrd1)/mrd1 && myd!=-1 && mydOW!=-1) /* absorbing the neutron if it hit the BOTTOM entrance wall and the wall is not transparent*/ ABSORB; if(y>=h1u && y <= h1uwt && x <= (y-nlu1)/mlu1 && x>= (y-nru1)/mru1 && myu!=-1 && myuOW!=-1) /* absorbing the neutron if it hit the TOP entrance wall and the wall is not transparent*/ ABSORB; if(x <= -w1r1 && x >= -w1rwt1 && y <= mru11*x+nru11 && y>= mrd11*x+nrd11 && mxr1!=-1 && mxrOW1!=-1) ABSORB; if(x >= w1l1 && x <= w1lwt1 && y <= mlu11*x+nlu11 && y>= mld11*x+nld11 && mxl1!=-1 && mxlOW1!=-1 ) ABSORB; if(y<=-h1d1 && y >=-h1dwt1 && x <= (y-nld11)/mld11 && x>= (y-nrd11)/mrd11 && myd1!=-1 && mydOW1!=-1) ABSORB; if(y>=h1u1 && y <= h1uwt1 && x <= (y-nlu11)/mlu11 && x>= (y-nru11)/mru11 && myu1!=-1 && myuOW1!=-1) ABSORB; if(x <= -w1r2 && x >= -w1rwt2 && y <= mru12*x+nru12 && y>= mrd12*x+nrd12 && mxr2!=-1 && mxrOW2!=-1) ABSORB; if(x >= w1l2 && x <= w1lwt2 && y <= mlu12*x+nlu12 && y>= mld12*x+nld12 && mxl2!=-1 && mxlOW2!=-1 ) ABSORB; if(y<=-h1d2 && y >=-h1dwt2 && x <= (y-nld12)/mld12 && x>= (y-nrd12)/mrd12 && myd2!=-1 && mydOW2!=-1) ABSORB; if(y>=h1u2 && y <= h1uwt2 && x <= (y-nlu12)/mlu12 && x>= (y-nru12)/mru12 && myu2!=-1 && myuOW2!=-1) ABSORB; do{ /* start the propagation loop inside the guide */ t1=(l-z)/vz; /* needed time to pass the guide (or rest of the guide without any interaction)*/ if(loutwr==0 && linwr==0) { TIME_LINEAR(t1, w1r, w2r, l, x, z, vx, vz, w1rwt, &t2w1r, &t2w1rwt); } if(loutwr!=0 && linwr!=0) { TIME_ELLIPSE(vx, vz, x, z, a2wr, b2wr, z0wr, t1, a2wrwt, b2wrwt, &t2w1r, &t2w1rwt); } if((loutwr!=0 && linwr==0)|| (loutwr==0 && linwr!=0)) { TIME_PARABEL(vx, vz, x, z, pawr, pbwr, t1, pawrwt, pbwrwt, &t2w1r, &t2w1rwt); } if(loutwl==0 && linwl==0) { TIME_LINEAR_1(t1, w1l, w2l, l, x, z, vx, vz, w1lwt, &t2w1l, &t2w1lwt); } if(loutwl!=0 && linwl!=0) { TIME_ELLIPSE_1(vx, vz, x, z, a2wl, b2wl, z0wl, t1, a2wlwt, b2wlwt, &t2w1l, &t2w1lwt); } if((loutwl!=0 && linwl==0) || (loutwl==0 && linwl!=0)) { TIME_PARABEL_1(vx, vz, x, z, pawl, pbwl, t1, pawlwt, pbwlwt, &t2w1l, &t2w1lwt); } if(louthu==0 && linhu==0) { TIME_LINEAR_1(t1, h1u, h2u, l, y, z, vy, vz, h1uwt, &t2h1u, &t2h1uwt); } if(louthu!=0 && linhu!=0) { TIME_ELLIPSE_1(vy, vz, y, z, a2hu, b2hu, z0hu, t1, a2huwt, b2huwt, &t2h1u, &t2h1uwt); } if((louthu!=0 && linhu==0)|| (louthu==0 && linhu!=0)) { TIME_PARABEL_1(vy, vz, y, z, pahu, pbhu, t1, pahuwt, pbhuwt, &t2h1u, &t2h1uwt); } if(louthd==0 && linhd==0) { TIME_LINEAR(t1, h1d, h2d, l, y, z, vy, vz, h1dwt, &t2h1d, &t2h1dwt); } if(louthd!=0 && linhd!=0) { TIME_ELLIPSE(vy, vz, y, z, a2hd, b2hd, z0hd, t1, a2hdwt, b2hdwt, &t2h1d, &t2h1dwt); } if((louthd!=0 && linhd==0)|| (louthd==0 && linhd!=0)) { TIME_PARABEL(vy, vz, y, z, pahd, pbhd, t1, pahdwt, pbhdwt, &t2h1d, &t2h1dwt); } /* FIRST SHELL */ if(loutwr1==0 && linwr1==0) { TIME_LINEAR(t1, w1r1, w2r1, l, x, z, vx, vz, w1rwt1, &t2w1r1, &t2w1rwt1); } if(loutwr1!=0 && linwr1!=0) { TIME_ELLIPSE(vx, vz, x, z, a2wr1, b2wr1, z0wr1, t1, a2wrwt1, b2wrwt1, &t2w1r1, &t2w1rwt1); } if((loutwr1!=0 && linwr1==0)|| (loutwr1==0 && linwr1!=0)) { TIME_PARABEL(vx, vz, x, z, pawr1, pbwr1, t1, pawrwt1, pbwrwt1, &t2w1r1, &t2w1rwt1); } if(loutwl1==0 && linwl1==0) { TIME_LINEAR_1(t1, w1l1, w2l1, l, x, z, vx, vz, w1lwt1, &t2w1l1, &t2w1lwt1); } if(loutwl1!=0 && linwl1!=0) { TIME_ELLIPSE_1(vx, vz, x, z, a2wl1, b2wl1, z0wl1, t1, a2wlwt1, b2wlwt1, &t2w1l1, &t2w1lwt1); } if((loutwl1!=0 && linwl1==0) || (loutwl1==0 && linwl1!=0)) { TIME_PARABEL_1(vx, vz, x, z, pawl1, pbwl1, t1, pawlwt1, pbwlwt1, &t2w1l1, &t2w1lwt1); } if(louthu1==0 && linhu1==0) { TIME_LINEAR_1(t1, h1u1, h2u1, l, y, z, vy, vz, h1uwt1, &t2h1u1, &t2h1uwt1); } if(louthu1!=0 && linhu1!=0) { TIME_ELLIPSE_1(vy, vz, y, z, a2hu1, b2hu1, z0hu1, t1, a2huwt1, b2huwt1, &t2h1u1, &t2h1uwt1); } if((louthu1!=0 && linhu1==0)|| (louthu1==0 && linhu1!=0)) { TIME_PARABEL_1(vy, vz, y, z, pahu1, pbhu1, t1, pahuwt1, pbhuwt1, &t2h1u1, &t2h1uwt1); } if(louthd1==0 && linhd1==0) { TIME_LINEAR(t1, h1d1, h2d1, l, y, z, vy, vz, h1dwt1, &t2h1d1, &t2h1dwt1); } if(louthd1!=0 && linhd1!=0) { TIME_ELLIPSE(vy, vz, y, z, a2hd1, b2hd1, z0hd1, t1, a2hdwt1, b2hdwt1, &t2h1d1, &t2h1dwt1); } if((louthd1!=0 && linhd1==0)|| (louthd1==0 && linhd1!=0)) { TIME_PARABEL(vy, vz, y, z, pahd1, pbhd1, t1, pahdwt1, pbhdwt1, &t2h1d1, &t2h1dwt1); } /* SECOND SHELL */ if(loutwr2==0 && linwr2==0) { TIME_LINEAR(t1, w1r2, w2r2, l, x, z, vx, vz, w1rwt2, &t2w1r2, &t2w1rwt2); } if(loutwr2!=0 && linwr2!=0) { TIME_ELLIPSE(vx, vz, x, z, a2wr2, b2wr2, z0wr2, t1, a2wrwt2, b2wrwt2, &t2w1r2, &t2w1rwt2); } if((loutwr2!=0 && linwr2==0)|| (loutwr2==0 && linwr2!=0)) { TIME_PARABEL(vx, vz, x, z, pawr2, pbwr2, t1, pawrwt2, pbwrwt2, &t2w1r2, &t2w1rwt2); } if(loutwl2==0 && linwl2==0) { TIME_LINEAR_1(t1, w1l2, w2l2, l, x, z, vx, vz, w1lwt2, &t2w1l2, &t2w1lwt2); } if(loutwl2!=0 && linwl2!=0) { TIME_ELLIPSE_1(vx, vz, x, z, a2wl2, b2wl2, z0wl2, t1, a2wlwt2, b2wlwt2, &t2w1l2, &t2w1lwt2); } if((loutwl2!=0 && linwl2==0) || (loutwl2==0 && linwl2!=0)) { TIME_PARABEL_1(vx, vz, x, z, pawl2, pbwl2, t1, pawlwt2, pbwlwt2, &t2w1l2, &t2w1lwt2); } if(louthu2==0 && linhu2==0) { TIME_LINEAR_1(t1, h1u2, h2u2, l, y, z, vy, vz, h1uwt2, &t2h1u2, &t2h1uwt2); } if(louthu2!=0 && linhu2!=0) { TIME_ELLIPSE_1(vy, vz, y, z, a2hu2, b2hu2, z0hu2, t1, a2huwt2, b2huwt2, &t2h1u2, &t2h1uwt2); } if((louthu2!=0 && linhu2==0)|| (louthu2==0 && linhu2!=0)) { TIME_PARABEL_1(vy, vz, y, z, pahu2, pbhu2, t1, pahuwt2, pbhuwt2, &t2h1u2, &t2h1uwt2); } if(louthd2==0 && linhd2==0) { TIME_LINEAR(t1, h1d2, h2d2, l, y, z, vy, vz, h1dwt2, &t2h1d2, &t2h1dwt2); } if(louthd2!=0 && linhd2!=0) { TIME_ELLIPSE(vy, vz, y, z, a2hd2, b2hd2, z0hd2, t1, a2hdwt2, b2hdwt2, &t2h1d2, &t2h1dwt2); } if((louthd2!=0 && linhd2==0)|| (louthd2==0 && linhd2!=0)) { TIME_PARABEL(vy, vz, y, z, pahd2, pbhd2, t1, pahdwt2, pbhdwt2, &t2h1d2, &t2h1dwt2); } /* TEST OF THE INNER INTERSECTION - TIMES */ /* possible interactions outside the guide have to be eliminated*/ if(t2w1rylimitu){ t2w1r=t1+2.0; } } if(t2w1lylimitu){ t2w1l=t1+2.0; } } if(t2h1uxlimitl){ t2h1u=t1+2.0; } } if(t2h1dxlimitl) { t2h1d=t1+2.0; } } /* TEST OF THE OUTER INTERSECTION - TIMES */ if(t2w1rwtylimitu){ t2w1rwt=t1+2.0; } } if(t2w1lwtylimitu){ t2w1lwt=t1+2.0; } } if(t2h1uwtxlimitl){ t2h1uwt=t1+2.0; } } if(t2h1dwtxlimitl) { t2h1dwt=t1+2.0; } } /* INTERACTION OF FIRST SHELL */ if(t2w1r1ylimitu){ t2w1r1=t1+2.0; } } if(t2w1l1ylimitu){ t2w1l1=t1+2.0; } } if(t2h1u1xlimitl){ t2h1u1=t1+2.0; } } if(t2h1d1xlimitl) { t2h1d1=t1+2.0; } } /* TEST OF THE OUTER INTERSECTION - TIMES */ if(t2w1rwt1ylimitu){ t2w1rwt1=t1+2.0; } } if(t2w1lwt1ylimitu){ t2w1lwt1=t1+2.0; } } if(t2h1uwt1xlimitl){ t2h1uwt1=t1+2.0; } } if(t2h1dwt1xlimitl) { t2h1dwt1=t1+2.0; } } /* INTERACTION SECOND SHELL */ if(t2w1r2ylimitu){ t2w1r2=t1+2.0; } } if(t2w1l2ylimitu){ t2w1l2=t1+2.0; } } if(t2h1u2xlimitl){ t2h1u2=t1+2.0; } } if(t2h1d2xlimitl) { t2h1d2=t1+2.0; } } /* TEST OF THE OUTER INTERSECTION - TIMES */ if(t2w1rwt2ylimitu){ t2w1rwt2=t1+2.0; } } if(t2w1lwt2ylimitu){ t2w1lwt2=t1+2.0; } } if(t2h1uwt2xlimitl){ t2h1uwt2=t1+2.0; } } if(t2h1dwt2xlimitl) { t2h1dwt2=t1+2.0; } } /* which wall is hit first? which geometry? */ if (t1 < t2w1r && t1 < t2w1l && t1 < t2h1u && t1 < t2h1d && t1 < t2w1rwt && t1 < t2w1lwt && t1 < t2h1uwt && t1 < t2h1dwt && t1 < t2w1r1 && t1 < t2w1l1 && t1 < t2h1u1 && t1 < t2h1d1 && t1 < t2w1rwt1 && t1 < t2w1lwt1 && t1 < t2h1uwt1 && t1 < t2h1dwt1 && t1 < t2w1r2 && t1 < t2w1l2 && t1 < t2h1u2 && t1 < t2h1d2 && t1 < t2w1rwt2 && t1 < t2w1lwt2 && t1 < t2h1uwt2 && t1 < t2h1dwt2){ i=1; } /* neutron interacts with the INNER elliptic right wall and this wall is NOT transparent*/ if (t2w1r > 0 && t2w1r < t1 && t2w1r < t2w1l && t2w1r < t2h1u && t2w1r < t2h1d && t2w1r < t2w1rwt && t2w1r < t2w1lwt && t2w1r < t2h1uwt && t2w1r < t2h1dwt && t2w1r < t2w1r1 && t2w1r < t2w1l1 && t2w1r < t2h1u1 && t2w1r < t2h1d1 && t2w1r < t2w1rwt1 && t2w1r < t2w1lwt1 && t2w1r < t2h1uwt1 && t2w1r < t2h1dwt1 && t2w1r < t2w1r2 && t2w1r < t2w1l2 && t2w1r < t2h1u2 && t2w1r < t2h1d2 && t2w1r < t2w1rwt2 && t2w1r < t2w1lwt2 && t2w1r < t2h1uwt2 && t2w1r < t2h1dwt2) { if (mxr == 0) i = 18; else{ if (mxr ==-1) i = 14; else{ if ((linwr!=0) && (loutwr!=0))i=2; /* the neutron will be reflected*/ else{ if ((loutwr!=0 && linwr==0) || (loutwr==0 && linwr!=0)) i=3; else{ if (loutwr==0 && linwr==0) i=4; }}}}} /* neutron interacts with the elliptic left INNER wall - comments are analog to inner elliptic right wall*/ if (t2w1l > 0 && t2w1l < t1 && t2w1l < t2w1r && t2w1l < t2h1u && t2w1l < t2h1d && t2w1l < t2w1rwt && t2w1l < t2w1lwt && t2w1l < t2h1uwt && t2w1l < t2h1dwt && t2w1l < t2w1r1 && t2w1l < t2w1l1 && t2w1l < t2h1u1 && t2w1l < t2h1d1 && t2w1l < t2w1rwt1 && t2w1l < t2w1lwt1 && t2w1l < t2h1uwt1 && t2w1l < t2h1dwt1 && t2w1l < t2w1r2 && t2w1l < t2w1l2 && t2w1l < t2h1u2 && t2w1l < t2h1d2 && t2w1l < t2w1rwt2 && t2w1l < t2w1lwt2 && t2w1l < t2h1uwt2 && t2w1l < t2h1dwt2) { if (mxl == 0) i = 19; else{ if (mxl == -1) i = 15; else{ if ((linwl!=0) && (loutwl!=0) ) i=5; else{ if ((loutwl!=0 && linwl==0) || (loutwl==0 && linwl!=0)) i=6; else{ if (loutwl==0 && linwl==0) i=7; }}}}} /* neutron interacts with the elliptic top INNER wall - comments are analog to inner elliptic right wall*/ if (t2h1u > 0 && t2h1u < t1 && t2h1u < t2w1r && t2h1u < t2w1l && t2h1u < t2h1d && t2h1u < t2w1rwt && t2h1u < t2w1lwt && t2h1u < t2h1uwt && t2h1u < t2h1dwt && t2h1u < t2w1r1 && t2h1u < t2w1l1 && t2h1u < t2h1u1 && t2h1u < t2h1d1 && t2h1u < t2w1rwt1 && t2h1u < t2w1lwt1 && t2h1u < t2h1uwt1 && t2h1u < t2h1dwt1 && t2h1u < t2w1r2 && t2h1u < t2w1l2 && t2h1u < t2h1u2 && t2h1u < t2h1d2 && t2h1u < t2w1rwt2 && t2h1u < t2w1lwt2 && t2h1u < t2h1uwt2 && t2h1u < t2h1dwt2){ if (myu == 0) i = 20; else{ if (myu == -1) i = 16; else{ if (louthu !=0 && linhu!=0) i=8; else{ if ((louthu!=0 && linhu==0) || (louthu==0 && linhu!=0)) i=9; else{ if (louthu == 0 && linhu == 0) i=10; }}}}} /* neutron interacts with the elliptic down INNER wall - comments are analog to inner elliptic right wall*/ if (t2h1d > 0 && t2h1d < t1 && t2h1d < t2w1r && t2h1d < t2w1l && t2h1d < t2h1u && t2h1d < t2w1rwt && t2h1d < t2w1lwt && t2h1d < t2h1uwt && t2h1d < t2h1dwt && t2h1d < t2w1r1 && t2h1d < t2w1l1 && t2h1d < t2h1u1 && t2h1d < t2h1d1 && t2h1d < t2w1rwt1 && t2h1d < t2w1lwt1 && t2h1d < t2h1uwt1 && t2h1d < t2h1dwt1 && t2h1d < t2w1r2 && t2h1d < t2w1l2 && t2h1d < t2h1u2 && t2h1d < t2h1d2 && t2h1d < t2w1rwt2 && t2h1d < t2w1lwt2 && t2h1d < t2h1uwt2 && t2h1d < t2h1dwt2){ if (myd == 0) i= 21; else{ if (myd == -1) i= 17; else{ if (louthd !=0 && linhd!=0) i=11; else{ if ((louthd !=0 && linhd==0) || (louthd ==0 && linhd!=0)) i=12; else{ if (louthd == 0 && linhd == 0) i=13; }}}}} /* EVERTHING AGAIN FOR THE OUTER WALLS */ /* neutron interacts with the elliptic right OUTER wall - comments are analog to inner elliptic right wall*/ if (t2w1rwt > 0 && t2w1rwt < t1 && t2w1rwt < t2w1r && t2w1rwt < t2w1l && t2w1rwt < t2h1u && t2w1rwt < t2h1d && t2w1rwt 0 && t2w1lwt < t1 && t2w1lwt < t2w1r && t2w1lwt < t2w1l && t2w1lwt < t2h1u && t2w1lwt < t2h1d && t2w1lwt 0 && t2h1uwt < t1 && t2h1uwt < t2w1r && t2h1uwt < t2w1l && t2h1uwt < t2h1u && t2h1uwt < t2h1d && t2h1uwt < t2w1rwt && t2h1uwt < t2w1lwt && t2h1uwt < t2h1dwt && t2h1uwt < t2w1r1 && t2h1uwt < t2w1l1 && t2h1uwt < t2h1u1 && t2h1uwt < t2h1d1 && t2h1uwt < t2w1rwt1 && t2h1uwt < t2w1lwt1 && t2h1uwt < t2h1uwt1 && t2h1uwt < t2h1dwt1 && t2h1uwt < t2w1r2 && t2h1uwt < t2w1l2 && t2h1uwt < t2h1u2 && t2h1uwt < t2h1d2 && t2h1uwt < t2w1rwt2 && t2h1uwt < t2w1lwt2 && t2h1uwt < t2h1uwt2 && t2h1uwt < t2h1dwt2){ if (myuOW == 0) i = 36; else{ if (myuOW == -1) i = 40; else{ if (louthu !=0 && linhu!=0) i=28; else{ if ((louthu!=0 && linhu==0) || (louthu==0 && linhu!=0)) i = 29; else{ if (louthu == 0 && linhu == 0) i =30; }}}}} /* neutron interacts with the elliptic down OUTER wall - comments are analog to inner elliptic right wall*/ if (t2h1dwt > 0 && t2h1dwt < t1 && t2h1dwt < t2w1r && t2h1dwt < t2w1l && t2h1dwt < t2h1u && t2h1dwt < t2h1d && t2h1dwt < t2w1rwt && t2h1dwt < t2w1lwt && t2h1dwt < t2h1uwt && t2h1dwt < t2w1r1 && t2h1dwt < t2w1l1 && t2h1dwt < t2h1u1 && t2h1dwt < t2h1d1 && t2h1dwt < t2w1rwt1 && t2h1dwt < t2w1lwt1 && t2h1dwt < t2h1uwt1 && t2h1dwt < t2h1dwt1 && t2h1dwt < t2w1r2 && t2h1dwt < t2w1l2 && t2h1dwt < t2h1u2 && t2h1dwt < t2h1d2 && t2h1dwt < t2w1rwt2 && t2h1dwt < t2w1lwt2 && t2h1dwt < t2h1uwt2 && t2h1dwt < t2h1dwt2 ){ if ( mydOW == 0 ) i=37; else{ if ( mydOW == -1) i=41; else{ if (louthd !=0 && linhd!=0) i=31; else{ if ((louthd !=0 && linhd==0) || (louthd ==0 && linhd!=0)) i=32; else{ if (louthd == 0 && linhd == 0) i =33; }}}}} /* FIRST SHELL */ if (t2w1r1 > 0 && t2w1r1 < t1 && t2w1r1 < t2w1r && t2w1r1 < t2w1l && t2w1r1 < t2h1u && t2w1r1 < t2h1d && t2w1r1 < t2w1rwt && t2w1r1 < t2w1lwt && t2w1r1 < t2h1uwt && t2w1r1 < t2h1dwt && t2w1r1 < t2w1l1 && t2w1r1 < t2h1u1 && t2w1r1 < t2h1d1 && t2w1r1 < t2w1rwt1 && t2w1r1 < t2w1lwt1 && t2w1r1 < t2h1uwt1 && t2w1r1 < t2h1dwt1 && t2w1r1 < t2w1r2 && t2w1r1 < t2w1l2 && t2w1r1 < t2h1u2 && t2w1r1 < t2h1d2 && t2w1r1 < t2w1rwt2 && t2w1r1 < t2w1lwt2 && t2w1r1 < t2h1uwt2 && t2w1r1 < t2h1dwt2 ){ if (mxr1 == 0) i =54; else{ if (mxr1 == -1) i= 58; else{ if (linwr1!=0 && loutwr1!=0) i= 42; else{ if ((loutwr1!=0 && linwr1==0) || (loutwr1==0 && linwr1!=0)) i = 43; else{ if (loutwr1==0 && linwr1==0) i= 44; }}}}} if (t2w1l1 > 0 && t2w1l1 < t1 && t2w1l1 < t2w1r && t2w1l1 < t2w1l && t2w1l1 < t2h1u && t2w1l1 < t2h1d && t2w1l1 < t2w1rwt && t2w1l1 < t2w1lwt && t2w1l1 < t2h1uwt && t2w1l1 < t2h1dwt && t2w1l1 < t2w1r1 && t2w1l1 < t2h1u1 && t2w1l1 < t2h1d1 && t2w1l1 < t2w1rwt1 && t2w1l1 < t2w1lwt1 && t2w1l1 < t2h1uwt1 && t2w1l1 < t2h1dwt1 && t2w1l1 < t2w1r2 && t2w1l1 < t2w1l2 && t2w1l1 < t2h1u2 && t2w1l1 < t2h1d2 && t2w1l1 < t2w1rwt2 && t2w1l1 < t2w1lwt2 && t2w1l1 < t2h1uwt2 && t2w1l1 < t2h1dwt2 ){ if (mxl1 == 0) i = 55; else{ if (mxl1 == -1) i = 59; else{ if (linwl1!=0 && loutwl1!=0) i=45; else{ if ((loutwl1!=0 && linwl1==0) || (loutwl1==0 && linwl1!=0)) i= 46; else{ if (loutwl1==0 && linwl1==0) i=47; }}}}} if (t2h1u1 > 0 && t2h1u1 < t1 && t2h1u1 < t2w1r && t2h1u1 < t2w1l && t2h1u1 < t2h1u && t2h1u1 < t2h1d && t2h1u1 < t2w1rwt && t2h1u1 < t2w1lwt && t2h1u1 < t2h1uwt && t2h1u1 < t2h1dwt && t2h1u1 < t2w1r1 && t2h1u1 < t2w1l1 && t2h1u1 < t2h1d1 && t2h1u1 < t2w1rwt1 && t2h1u1 < t2w1lwt1 && t2h1u1 < t2h1uwt1 && t2h1u1 < t2h1dwt1 && t2h1u1 < t2w1r2 && t2h1u1 < t2w1l2 && t2h1u1 < t2h1u2 && t2h1u1 < t2h1d2 && t2h1u1 < t2w1rwt2 && t2h1u1 < t2w1lwt2 && t2h1u1 < t2h1uwt2 && t2h1u1 < t2h1dwt2 ){ if (myu1 == 0) i = 56; else{ if (myu1 == -1) i = 60; else{ if (louthu1 !=0 && linhu1!=0) i=48; else{ if ((louthu1!=0 && linhu1==0) || (louthu1==0 && linhu1!=0)) i = 49; else{ if (louthu1 == 0 && linhu1 == 0) i =50; }}}}} if (t2h1d1 > 0 && t2h1d1 < t1 && t2h1d1 < t2w1r && t2h1d1 < t2w1l && t2h1d1 < t2h1u && t2h1d1 < t2h1d && t2h1d1 < t2w1rwt && t2h1d1 < t2w1lwt && t2h1d1 < t2h1uwt && t2h1d1 < t2h1dwt && t2h1d1 < t2w1r1 && t2h1d1 < t2w1l1 && t2h1d1 < t2h1u1 && t2h1d1 < t2w1rwt1 && t2h1d1 < t2w1lwt1 && t2h1d1 < t2h1uwt1 && t2h1d1 < t2h1dwt1 && t2h1d1 < t2w1r2 && t2h1d1 < t2w1l2 && t2h1d1 < t2h1u2 && t2h1d1 < t2h1d2 && t2h1d1 < t2w1rwt2 && t2h1d1 < t2w1lwt2 && t2h1d1 < t2h1uwt2 && t2h1d1 < t2h1dwt2 ){ if (myd1 == 0) i =57; else{ if (myd1 == -1) i = 61; else{ if (louthd1 != 0 && linhd1 != 0) i =51; else{ if ((louthd1 =! 0 && linhd1 == 0) || (louthd1 == 0 && linhd1 != 0)) i = 52; else{ if (louthd1 == 0 && linhd1 == 0) i = 53; }}}}} if (t2w1rwt1 > 0 && t2w1rwt1 < t1 && t2w1rwt1 < t2w1r && t2w1rwt1 < t2w1l && t2w1rwt1 < t2h1u && t2w1rwt1 < t2h1d && t2w1rwt1 0 && t2w1lwt1 < t1 && t2w1lwt1 < t2w1r && t2w1lwt1 < t2w1l && t2w1lwt1 < t2h1u && t2w1lwt1 < t2h1d && t2w1lwt1 0 && t2h1uwt1 < t1 && t2h1uwt1 < t2w1r && t2h1uwt1 < t2w1l && t2h1uwt1 < t2h1u && t2h1uwt1 < t2h1d && t2h1uwt1 < t2w1rwt && t2h1uwt1 < t2w1lwt && t2h1uwt1 < t2h1uwt && t2h1uwt1 < t2h1dwt && t2h1uwt1 < t2w1r1 && t2h1uwt1 < t2w1l1 && t2h1uwt1 < t2h1u1 && t2h1uwt1 < t2h1d1 && t2h1uwt1 < t2w1rwt1 && t2h1uwt1 < t2w1lwt1 && t2h1uwt1 < t2h1dwt1 && t2h1uwt1 < t2w1r2 && t2h1uwt1 < t2w1l2 && t2h1uwt1 < t2h1u2 && t2h1uwt1 < t2h1d2 && t2h1uwt1 < t2w1rwt2 && t2h1uwt1 < t2w1lwt2 && t2h1uwt1 < t2h1uwt2 && t2h1uwt1 < t2h1dwt2 ){ if (myuOW1 == 0) i = 76; else{ if (myuOW1 == -1) i = 80; else{ if (louthu1 !=0 && linhu1!=0) i=68; else{ if ((louthu1!=0 && linhu1==0) || (louthu1==0 && linhu1!=0)) i = 69; else{ if (louthu1 == 0 && linhu1 == 0) i =70; }}}}} if (t2h1dwt1 > 0 && t2h1dwt1 < t1 && t2h1dwt1 < t2w1r && t2h1dwt1 < t2w1l && t2h1dwt1 < t2h1u && t2h1dwt1 < t2h1d && t2h1dwt1 < t2w1rwt && t2h1dwt1 < t2w1lwt && t2h1dwt1 < t2h1uwt && t2h1dwt1 < t2h1dwt && t2h1dwt1 < t2w1r1 && t2h1dwt1 < t2w1l1 && t2h1dwt1 < t2h1u1 && t2h1dwt1 < t2h1d1 && t2h1dwt1 < t2w1rwt1 && t2h1dwt1 < t2w1lwt1 && t2h1dwt1 < t2h1uwt1 && t2h1dwt1 < t2w1r2 && t2h1dwt1 < t2w1l2 && t2h1dwt1 < t2h1u2 && t2h1dwt1 < t2h1d2 && t2h1dwt1 < t2w1rwt2 && t2h1dwt1 < t2w1lwt2 && t2h1dwt1 < t2h1uwt2 && t2h1dwt1 < t2h1dwt2 ) { if ( mydOW1 == 0 ) i=77; else{ if ( mydOW1 == -1) i=81; else{ if (louthd1 !=0 && linhd1!=0) i=71; else{ if ((louthd1 !=0 && linhd1==0) || (louthd1 ==0 && linhd1!=0)) i=72; else{ if (louthd1 == 0 && linhd1 == 0) i =73; }}}}} /* SECOND SHELL */ if (t2w1r2 > 0 && t2w1r2 < t1 && t2w1r2 < t2w1r && t2w1r2 < t2w1l && t2w1r2 < t2h1u && t2w1r2 < t2h1d && t2w1r2 < t2w1rwt && t2w1r2 < t2w1lwt && t2w1r2 < t2h1uwt && t2w1r2 < t2h1dwt && t2w1r2 < t2w1r1 && t2w1r2 < t2w1l1 && t2w1r2 < t2h1u1 && t2w1r2 < t2h1d1 && t2w1r2 < t2w1rwt1 && t2w1r2 < t2w1lwt1 && t2w1r2 < t2h1uwt1 && t2w1r2 < t2h1dwt1 && t2w1r2 < t2w1l2 && t2w1r2 < t2h1u2 && t2w1r2 < t2h1d2 && t2w1r2 < t2w1rwt2 && t2w1r2 < t2w1lwt2 && t2w1r2 < t2h1uwt2 && t2w1r2 < t2h1dwt2 ) { if (mxr2 == 0) i =98; else{ if (mxr2 == -1) i= 94; else{ if (linwr2!=0 && loutwr2!=0) i= 82; else{ if ((loutwr2!=0 && linwr2==0) || (loutwr2==0 && linwr2!=0)) i = 83; else{ if (loutwr2==0 && linwr2==0) i= 84; }}}}} /* neutron interacts with the left INNER wall - comments are analog to inner right wall*/ if (t2w1l2 > 0 && t2w1l2 < t1 && t2w1l2 < t2w1r && t2w1l2 < t2w1l && t2w1l2 < t2h1u && t2w1l2 < t2h1d && t2w1l2 < t2w1rwt && t2w1l2 < t2w1lwt && t2w1l2 < t2h1uwt && t2w1l2 < t2h1dwt && t2w1l2 < t2w1r1 && t2w1l2 < t2w1l1 && t2w1l2 < t2h1u1 && t2w1l2 < t2h1d1 && t2w1l2 < t2w1rwt1 && t2w1l2 < t2w1lwt1 && t2w1l2 < t2h1uwt1 && t2w1l2 < t2h1dwt1 && t2w1l2 < t2w1r2 && t2w1l2 < t2h1u2 && t2w1l2 < t2h1d2 && t2w1l2 < t2w1rwt2 && t2w1l2 < t2w1lwt2 && t2w1l2 < t2h1uwt2 && t2w1l2 < t2h1dwt2) { if (mxl2 == 0) i = 99; else{ if (mxl2 == -1) i = 95; else{ if (linwl2!=0 && loutwl2!=0) i=85; else{ if ((loutwl2!=0 && linwl2==0) || (loutwl2==0 && linwl2!=0)) i= 86; else{ if (loutwl2==0 && linwl2==0) i=87; }}}}} /* neutron interacts with the top INNER wall - comments are analog to inner right wall*/ if (t2h1u2 > 0 && t2h1u2 < t1 && t2h1u2 < t2w1r && t2h1u2 < t2w1l && t2h1u2 < t2h1u && t2h1u2 < t2h1d && t2h1u2 < t2w1rwt && t2h1u2 < t2w1lwt && t2h1u2 < t2h1uwt && t2h1u2 < t2h1dwt && t2h1u2 < t2w1r1 && t2h1u2 < t2w1l1 && t2h1u2 < t2h1u1 && t2h1u2 < t2h1d1 && t2h1u2 < t2w1rwt1 && t2h1u2 < t2w1lwt1 && t2h1u2 < t2h1uwt1 && t2h1u2 < t2h1dwt1 && t2h1u2 < t2w1r2 && t2h1u2 < t2w1l2 && t2h1u2 < t2h1d2 && t2h1u2 < t2w1rwt2 && t2h1u2 < t2w1lwt2 && t2h1u2 < t2h1uwt2 && t2h1u2 < t2h1dwt2) { if (myu2 == 0) i = 100; else{ if (myu2 == -1) i = 96; else{ if (louthu2 !=0 && linhu2!=0) i=88; else{ if ((louthu2!=0 && linhu2==0) || (louthu2==0 && linhu2!=0)) i = 89; else{ if (louthu2 == 0 && linhu2 == 0) i =90; }}}}} /* neutron interacts with the down INNER wall - comments are analog to inner right wall*/ if (t2h1d2 > 0 && t2h1d2 < t1 && t2h1d2 < t2w1r && t2h1d2 < t2w1l && t2h1d2 < t2h1u && t2h1d2 < t2h1d && t2h1d2 < t2w1rwt && t2h1d2 < t2w1lwt && t2h1d2 < t2h1uwt && t2h1d2 < t2h1dwt && t2h1d2 < t2w1r1 && t2h1d2 < t2w1l1 && t2h1d2 < t2h1u1 && t2h1d2 < t2h1d1 && t2h1d2 < t2w1rwt1 && t2h1d2 < t2w1lwt1 && t2h1d2 < t2h1uwt1 && t2h1d2 < t2h1dwt1 && t2h1d2 < t2w1r2 && t2h1d2 < t2w1l2 && t2h1d2 < t2h1u2 && t2h1d2 < t2w1rwt2 && t2h1d2 < t2w1lwt2 && t2h1d2 < t2h1uwt2 && t2h1d2 < t2h1dwt2) { if ( myd2 == 0 ) i=101; else{ if ( myd2 == -1) i=97; else{ if (louthd2 !=0 && linhd2!=0) i=91; else{ if ((louthd2 !=0 && linhd2==0) || (louthd2 ==0 && linhd2!=0)) i=92; else{ if (louthd2 == 0 && linhd2 == 0) i =93; }}}}} /* EVERTHING AGAIN FOR THE OUTER WALLS */ /* neutron interacts with the elliptic right OUTER wall - comments are analog to inner elliptic right wall*/ if (t2w1rwt2 > 0 && t2w1rwt2 < t1 && t2w1rwt2 < t2w1r && t2w1rwt2 < t2w1l && t2w1rwt2 < t2h1u && t2w1rwt2 < t2h1d && t2w1rwt2 0 && t2w1lwt2 < t1 && t2w1lwt2 < t2w1r && t2w1lwt2 < t2w1l && t2w1lwt2 < t2h1u && t2w1lwt2 < t2h1d && t2w1lwt2 0 && t2h1uwt2 < t1 && t2h1uwt2 < t2w1r && t2h1uwt2 < t2w1l && t2h1uwt2 < t2h1u && t2h1uwt2 < t2h1d && t2h1uwt2 < t2w1rwt && t2h1uwt2 < t2w1lwt && t2h1uwt2 < t2h1uwt && t2h1uwt2 < t2h1dwt && t2h1uwt2 < t2w1r1 && t2h1uwt2 < t2w1l1 && t2h1uwt2 < t2h1u1 && t2h1uwt2 < t2h1d1 && t2h1uwt2 < t2w1rwt1 && t2h1uwt2 < t2w1lwt1 && t2h1uwt2 < t2h1uwt1 && t2h1uwt2 < t2h1dwt1 && t2h1uwt2 < t2w1r2 && t2h1uwt2 < t2w1l2 && t2h1uwt2 < t2h1u2 && t2h1uwt2 < t2h1d2 && t2h1uwt2 < t2w1rwt2 && t2h1uwt2 < t2w1lwt2 && t2h1uwt2 < t2h1dwt2) { if (myuOW2 == 0) i = 116; else{ if (myuOW2 == -1) i = 120; else{ if (louthu2 !=0 && linhu2!=0) i=108; else{ if ((louthu2!=0 && linhu2==0) || (louthu2==0 && linhu2!=0)) i = 109; else{ if (louthu2 == 0 && linhu2 == 0) i =110; }}}}} /* neutron interacts with the elliptic down OUTER wall - comments are analog to inner elliptic right wall*/ if (t2h1dwt2 > 0 && t2h1dwt2 < t1 && t2h1dwt2 < t2w1r && t2h1dwt2 < t2w1l && t2h1dwt2 < t2h1u && t2h1dwt2 < t2h1d && t2h1dwt2 < t2w1rwt && t2h1dwt2 < t2w1lwt && t2h1dwt2 < t2h1uwt && t2h1dwt2 < t2h1dwt && t2h1dwt2 < t2w1r1 && t2h1dwt2 < t2w1l1 && t2h1dwt2 < t2h1u1 && t2h1dwt2 < t2h1d1 && t2h1dwt2 < t2w1rwt1 && t2h1dwt2 < t2w1lwt1 && t2h1dwt2 < t2h1uwt1 && t2h1dwt2 < t2h1dwt1 && t2h1dwt2 < t2w1r2 && t2h1dwt2 < t2w1l2 && t2h1dwt2 < t2h1u2 && t2h1dwt2 < t2h1d2 && t2h1dwt2 < t2w1rwt2 && t2h1dwt2 < t2w1lwt2 && t2h1dwt2 < t2h1uwt2) { if ( mydOW2 == 0 ) i=117; else{ if ( mydOW2 == -1) i=121; else{ if (louthd2 !=0 && linhd2!=0) i=111; else{ if ((louthd2 !=0 && linhd2==0) || (louthd2 ==0 && linhd2!=0)) i=112; else{ if (louthd2 == 0 && linhd2 == 0) i =113; }}}}} switch(i){ /* the principal for the calculation is in every case the same: 1.) one needs the surface normal vector at the intersection point. 2.) calculation of the velocity vector after the interaction by */ /* vector subrtation (the basic idea and explanations can be found in the 'Mcstas component manual' in the section 'straight guide') */ case 1: /* no interaction, propagation to the end of the guide */ PROP_DT(t1); break; case 2: PROP_DT(t2w1r); /* propagation to interaction point */ vxin=vx; /* saving the velocity vector before the interaction*/ vyin=vy; vzin=vz; nx=-x; /* surface normal vector components at the intersection point */ nz=-x*x/((a2wr/(z+z0wr))-(z0wr+z)); n2=sqrt(nx*nx+nz*nz); /* lenght of the surface normal */ pf=2.0*(vx*nx+vz*nz)/n2; /* prefactor for the calculation of the velocity vector after the interaction */ vx-=pf*nx/n2; /* velocity vector after the interaction*/ vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); /* calculation the q-vector to calculated the reflectivity*/ break; case 3: PROP_DT(t2w1r); vxin=vx; vyin=vy; vzin=vz; nx=-x; nz=-0.5/pawr; n2=sqrt(nx*nx+nz*nz); pf=2.0*(vx*nx+vz*nz)/n2; vx-=pf*nx/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 4: PROP_DT(t2w1r); vxin=vx; vyin=vy; vzin=vz; nx=l; nz=w2r-w1r; n2=sqrt(nx*nx+nz*nz); pf=2.0*(vx*nx+vz*nz)/n2; vx-=pf*nx/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 5: PROP_DT(t2w1l); vxin=vx; vyin=vy; vzin=vz; nx=-x; nz=-x*x/((a2wl/(z+z0wl))-(z0wl+z)); n2=sqrt(nx*nx+nz*nz); pf=2.0*(vx*nx+vz*nz)/n2; vx-=pf*nx/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); SCATTER; break; case 6: PROP_DT(t2w1l); vxin=vx; vyin=vy; vzin=vz; nx=-x; nz=-0.5/pawl; n2=sqrt(nx*nx+nz*nz); pf=2.0*(vx*nx+vz*nz)/n2; vx-=pf*nx/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 7: PROP_DT(t2w1l); vxin=vx; vyin=vy; vzin=vz; nx=-l; nz=w2l-w1l; n2=sqrt(nx*nx+nz*nz); pf=2.0*(vx*nx+vz*nz)/n2; vx-=pf*nx/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 8: PROP_DT(t2h1u); vxin=vx; vyin=vy; vzin=vz; ny=-y; nz=-y*y/((a2hu/(z+z0hu))-(z0hu+z)); n2=sqrt(ny*ny+nz*nz); pf=2.0*(vy*ny+vz*nz)/n2; vy-=pf*ny/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 9: PROP_DT(t2h1u); vxin=vx; vyin=vy; vzin=vz; ny=-y; nz=-0.5/pahu; n2=sqrt(ny*ny+nz*nz); pf=2.0*(vy*ny+vz*nz)/n2; vy-=pf*ny/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 10: PROP_DT(t2h1u); vxin=vx; vyin=vy; vzin=vz; ny=-l; nz=h2u-h1u; n2=sqrt(ny*ny+nz*nz); pf=2.0*(vy*ny+vz*nz)/n2; vy-=pf*ny/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 11: PROP_DT(t2h1d); vxin=vx; vyin=vy; vzin=vz; ny=-y; nz=-y*y/((a2hd/(z+z0hd))-(z0hd+z)); n2=sqrt(ny*ny+nz*nz); pf=2.0*(vy*ny+vz*nz)/n2; vy-=pf*ny/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 12: PROP_DT(t2h1d); vxin=vx; vyin=vy; vzin=vz; ny=-y; nz=-0.5/pahd; n2=sqrt(ny*ny+nz*nz); pf=2.0*(vy*ny+vz*nz)/n2; vy-=pf*ny/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 13: PROP_DT(t2h1d); vxin=vx; vyin=vy; vzin=vz; ny=l; nz=h2d-h1d; n2=sqrt(ny*ny+nz*nz); pf=2.0*(vy*ny+vz*nz)/n2; vy-=pf*ny/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 14: /* transperent walls - no interaction */ PROP_DT(t2w1r); break; case 15: PROP_DT(t2w1l); break; case 16: PROP_DT(t2h1u); break; case 17: PROP_DT(t2h1d); break; case 18: /* absorbing walls - neutrons are absorbed at interaction point*/ PROP_DT(t2w1r); ABSORB; break; case 19: PROP_DT(t2w1l); ABSORB; break; case 20: PROP_DT(t2h1u); ABSORB; break; case 21: PROP_DT(t2h1d); ABSORB; break; /* OUTER WALLS - analog to inner walls, but sign of surface normal vector is changed */ case 22: PROP_DT(t2w1rwt); /* propagation to interaction point */ vxin=vx; /* saving the velocity vector before the interaction*/ vyin=vy; vzin=vz; nx=x; /* surface normal vector components at the intersection point */ nz=x*x/((a2wrwt/(z+z0wr))-(z0wr+z)); n2=sqrt(nx*nx+nz*nz); /* lenght of the surface normal */ pf=2.0*(vx*nx+vz*nz)/n2; /* prefactor for the calculation of the velocity vector after the interaction */ vx-=pf*nx/n2; /* velocity vector after the interaction*/ vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); /* calculation the q-vector to calculated the reflectivity*/ break; case 23: PROP_DT(t2w1rwt); vxin=vx; vyin=vy; vzin=vz; nx=x; nz=0.5/pawrwt; n2=sqrt(nx*nx+nz*nz); pf=2.0*(vx*nx+vz*nz)/n2; vx-=pf*nx/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 24: PROP_DT(t2w1rwt); vxin=vx; vyin=vy; vzin=vz; nx=-l; nz=-(w2r-w1r); n2=sqrt(nx*nx+nz*nz); pf=2.0*(vx*nx+vz*nz)/n2; vx-=pf*nx/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 25: PROP_DT(t2w1lwt); vxin=vx; vyin=vy; vzin=vz; nx=x; nz=x*x/((a2wlwt/(z+z0wl))-(z0wl+z)); n2=sqrt(nx*nx+nz*nz); pf=2.0*(vx*nx+vz*nz)/n2; vx-=pf*nx/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 26: PROP_DT(t2w1lwt); vxin=vx; vyin=vy; vzin=vz; nx=x; nz=0.5/pawlwt; n2=sqrt(nx*nx+nz*nz); pf=2.0*(vx*nx+vz*nz)/n2; vx-=pf*nx/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 27: PROP_DT(t2w1lwt); vxin=vx; vyin=vy; vzin=vz; nx=l; nz=-(w2l-w1l); n2=sqrt(nx*nx+nz*nz); pf=2.0*(vx*nx+vz*nz)/n2; vx-=pf*nx/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 28: PROP_DT(t2h1uwt); vxin=vx; vyin=vy; vzin=vz; ny=y; nz=y*y/((a2huwt/(z+z0hu))-(z0hu+z)); n2=sqrt(ny*ny+nz*nz); pf=2.0*(vy*ny+vz*nz)/n2; vy-=pf*ny/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 29: PROP_DT(t2h1uwt); vxin=vx; vyin=vy; vzin=vz; ny=y; nz=0.5/pahuwt; n2=sqrt(ny*ny+nz*nz); pf=2.0*(vy*ny+vz*nz)/n2; vy-=pf*ny/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 30: PROP_DT(t2h1uwt); vxin=vx; vyin=vy; vzin=vz; ny=l; nz=-(h2u-h1u); n2=sqrt(ny*ny+nz*nz); pf=2.0*(vy*ny+vz*nz)/n2; vy-=pf*ny/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 31: PROP_DT(t2h1dwt); vxin=vx; vyin=vy; vzin=vz; ny=y; nz=y*y/((a2hdwt/(z+z0hd))-(z0hd+z)); n2=sqrt(ny*ny+nz*nz); pf=2.0*(vy*ny+vz*nz)/n2; vy-=pf*ny/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 32: PROP_DT(t2h1dwt); vxin=vx; vyin=vy; vzin=vz; ny=y; nz=0.5/pahdwt; n2=sqrt(ny*ny+nz*nz); pf=2.0*(vy*ny+vz*nz)/n2; vy-=pf*ny/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 33: PROP_DT(t2h1dwt); vxin=vx; vyin=vy; vzin=vz; ny=-l; nz=-(h2d-h1d); n2=sqrt(ny*ny+nz*nz); pf=2.0*(vy*ny+vz*nz)/n2; vy-=pf*ny/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 34: PROP_DT(t2w1rwt); ABSORB; break; case 35: PROP_DT(t2w1lwt); ABSORB; break; case 36: PROP_DT(t2h1uwt); ABSORB; break; case 37: PROP_DT(t2h1dwt); ABSORB; break; case 38: PROP_DT(t2w1rwt); break; case 39: PROP_DT(t2w1lwt); break; case 40: PROP_DT(t2h1uwt); break; case 41: PROP_DT(t2h1dwt); break; case 42: PROP_DT(t2w1r1); /* propagation to interaction point */ vxin=vx; /* saving the velocity vector before the interaction*/ vyin=vy; vzin=vz; nx=-x; /* surface normal vector components at the intersection point */ nz=-x*x/((a2wr1/(z+z0wr1))-(z0wr1+z)); n2=sqrt(nx*nx+nz*nz); /* lenght of the surface normal */ pf=2.0*(vx*nx+vz*nz)/n2; /* prefactor for the calculation of the velocity vector after the interaction */ vx-=pf*nx/n2; /* velocity vector after the interaction*/ vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); /* calculation the q-vector to calculated the reflectivity*/ break; case 43: PROP_DT(t2w1r1); vxin=vx; vyin=vy; vzin=vz; nx=-x; nz=-0.5/pawr1; n2=sqrt(nx*nx+nz*nz); pf=2.0*(vx*nx+vz*nz)/n2; vx-=pf*nx/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 44: PROP_DT(t2w1r1); vxin=vx; vyin=vy; vzin=vz; nx=l; nz=w2r1-w1r1; n2=sqrt(nx*nx+nz*nz); pf=2.0*(vx*nx+vz*nz)/n2; vx-=pf*nx/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 45: PROP_DT(t2w1l1); vxin=vx; vyin=vy; vzin=vz; nx=-x; nz=-x*x/((a2wl1/(z+z0wl1))-(z0wl1+z)); n2=sqrt(nx*nx+nz*nz); pf=2.0*(vx*nx+vz*nz)/n2; vx-=pf*nx/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 46: PROP_DT(t2w1l1); vxin=vx; vyin=vy; vzin=vz; nx=-x; nz=-0.5/pawl1; n2=sqrt(nx*nx+nz*nz); pf=2.0*(vx*nx+vz*nz)/n2; vx-=pf*nx/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 47: PROP_DT(t2w1l1); vxin=vx; vyin=vy; vzin=vz; nx=-l; nz=w2l1-w1l1; n2=sqrt(nx*nx+nz*nz); pf=2.0*(vx*nx+vz*nz)/n2; vx-=pf*nx/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 48: PROP_DT(t2h1u1); vxin=vx; vyin=vy; vzin=vz; ny=-y; nz=-y*y/((a2hu1/(z+z0hu1))-(z0hu1+z)); n2=sqrt(ny*ny+nz*nz); pf=2.0*(vy*ny+vz*nz)/n2; vy-=pf*ny/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 49: PROP_DT(t2h1u1); vxin=vx; vyin=vy; vzin=vz; ny=-y; nz=-0.5/pahu1; n2=sqrt(ny*ny+nz*nz); pf=2.0*(vy*ny+vz*nz)/n2; vy-=pf*ny/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 50: PROP_DT(t2h1u1); vxin=vx; vyin=vy; vzin=vz; ny=-l; nz=h2u1-h1u1; n2=sqrt(ny*ny+nz*nz); pf=2.0*(vy*ny+vz*nz)/n2; vy-=pf*ny/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 51: PROP_DT(t2h1d1); vxin=vx; vyin=vy; vzin=vz; nx=-y; nz=-y*y/((a2hd1/(z+z0hd1))-(z0hd1+z)); n2=sqrt(ny*ny+nz*nz); pf=2.0*(vy*ny+vz*nz)/n2; vy-=pf*ny/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 52: PROP_DT(t2h1d1); vxin=vx; vyin=vy; vzin=vz; ny=-y; nz=-0.5/pahd1; n2=sqrt(ny*ny+nz*nz); pf=2.0*(vy*ny+vz*nz)/n2; vy-=pf*ny/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 53: PROP_DT(t2h1d1); vxin=vx; vyin=vy; vzin=vz; ny=l; nz=h2d1-h1d1; n2=sqrt(ny*ny+nz*nz); pf=2.0*(vy*ny+vz*nz)/n2; vy-=pf*ny/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 54: PROP_DT(t2w1r1); ABSORB; break; case 55: PROP_DT(t2w1l1); ABSORB; break; case 56: PROP_DT(t2h1u1); ABSORB; break; case 57: PROP_DT(t2h1d1); ABSORB; break; case 58: PROP_DT(t2w1r1); break; case 59: PROP_DT(t2w1l1); break; case 60: PROP_DT(t2h1u1); break; case 61: PROP_DT(t2h1d1); break; case 62: PROP_DT(t2w1rwt1); vxin=vx; vyin=vy; vzin=vz; nx=x; nz=x*x/((a2wrwt1/(z+z0wr1))-(z0wr1+z)); n2=sqrt(nx*nx+nz*nz); pf=2.0*(vx*nx+vz*nz)/n2; vx-=pf*nx/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 63: PROP_DT(t2w1rwt1); vxin=vx; vyin=vy; vzin=vz; nx=x; nz=0.5/pawrwt1; n2=sqrt(nx*nx+nz*nz); pf=2.0*(vx*nx+vz*nz)/n2; vx-=pf*nx/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 64: PROP_DT(t2w1rwt1); vxin=vx; vyin=vy; vzin=vz; nx=-l; nz=-(w2r1-w1r1); n2=sqrt(nx*nx+nz*nz); pf=2.0*(vx*nx+vz*nz)/n2; vx-=pf*nx/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 65: PROP_DT(t2w1lwt1); vxin=vx; vyin=vy; vzin=vz; nx=x; nz=x*x/((a2wlwt1/(z+z0wl1))-(z0wl1+z)); n2=sqrt(nx*nx+nz*nz); pf=2.0*(vx*nx+vz*nz)/n2; vx-=pf*nx/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 66: PROP_DT(t2w1lwt1); vxin=vx; vyin=vy; vzin=vz; nx=x; nz=0.5/pawlwt1; n2=sqrt(nx*nx+nz*nz); pf=2.0*(vx*nx+vz*nz)/n2; vx-=pf*nx/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 67: PROP_DT(t2w1lwt1); vxin=vx; vyin=vy; vzin=vz; nx=l; nz=-(w2l1-w1l1); n2=sqrt(nx*nx+nz*nz); pf=2.0*(vx*nx+vz*nz)/n2; vx-=pf*nx/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 68: PROP_DT(t2h1uwt1); vxin=vx; vyin=vy; vzin=vz; ny=y; nz=y*y/((a2huwt1/(z+z0hu1))-(z0hu1+z)); n2=sqrt(ny*ny+nz*nz); pf=2.0*(vy*ny+vz*nz)/n2; vy-=pf*ny/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 69: PROP_DT(t2h1uwt1); vxin=vx; vyin=vy; vzin=vz; ny=y; nz=0.5/pahuwt1; n2=sqrt(ny*ny+nz*nz); pf=2.0*(vy*ny+vz*nz)/n2; vy-=pf*ny/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 70: PROP_DT(t2h1uwt1); vxin=vx; vyin=vy; vzin=vz; ny=l; nz=-(h2u1-h1u1); n2=sqrt(ny*ny+nz*nz); pf=2.0*(vy*ny+vz*nz)/n2; vy-=pf*ny/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 71: PROP_DT(t2h1dwt1); vxin=vx; vyin=vy; vzin=vz; ny=y; nz=y*y/((a2hdwt1/(z+z0hd1))-(z0hd1+z)); n2=sqrt(ny*ny+nz*nz); pf=2.0*(vy*ny+vz*nz)/n2; vy-=pf*ny/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 72: PROP_DT(t2h1dwt1); vxin=vx; vyin=vy; vzin=vz; ny=y; nz=0.5/pahdwt1; n2=sqrt(ny*ny+nz*nz); pf=2.0*(vy*ny+vz*nz)/n2; vy-=pf*ny/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 73: PROP_DT(t2h1dwt1); vxin=vx; vyin=vy; vzin=vz; ny=-l; nz=-(h2d1-h1d1); n2=sqrt(ny*ny+nz*nz); pf=2.0*(vy*ny+vz*nz)/n2; vy-=pf*ny/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 74: PROP_DT(t2w1rwt1); ABSORB; break; case 75: PROP_DT(t2w1lwt1); ABSORB; break; case 76: PROP_DT(t2h1uwt1); ABSORB; break; case 77: PROP_DT(t2h1dwt1); ABSORB; break; case 78: PROP_DT(t2w1rwt1); break; case 79: PROP_DT(t2w1lwt1); break; case 80: PROP_DT(t2h1uwt1); break; case 81: PROP_DT(t2h1dwt1); break; case 82: PROP_DT(t2w1r2); vxin=vx; vyin=vy; vzin=vz; nx=-x; nz=-x*x/((a2wr2/(z+z0wr2))-(z0wr2+z)); n2=sqrt(nx*nx+nz*nz); pf=2.0*(vx*nx+vz*nz)/n2; vx-=pf*nx/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 83: PROP_DT(t2w1r2); vxin=vx; vyin=vy; vzin=vz; nx=-x; nz=-0.5/pawr2; n2=sqrt(nx*nx+nz*nz); pf=2.0*(vx*nx+vz*nz)/n2; vx-=pf*nx/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 84: PROP_DT(t2w1r2); vxin=vx; vyin=vy; vzin=vz; nx=l; nz=w2r2-w1r2; n2=sqrt(nx*nx+nz*nz); pf=2.0*(vx*nx+vz*nz)/n2; vx-=pf*nx/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 85: PROP_DT(t2w1l2); vxin=vx; vyin=vy; vzin=vz; nx=-x; nz=-x*x/((a2wl2/(z+z0wl2))-(z0wl2+z)); n2=sqrt(nx*nx+nz*nz); pf=2.0*(vx*nx+vz*nz)/n2; vx-=pf*nx/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); SCATTER; break; case 86: PROP_DT(t2w1l2); vxin=vx; vyin=vy; vzin=vz; nx=-x; nz=-0.5/pawl2; n2=sqrt(nx*nx+nz*nz); pf=2.0*(vx*nx+vz*nz)/n2; vx-=pf*nx/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 87: PROP_DT(t2w1l2); vxin=vx; vyin=vy; vzin=vz; nx=-l; nz=w2l2-w1l2; n2=sqrt(nx*nx+nz*nz); pf=2.0*(vx*nx+vz*nz)/n2; vx-=pf*nx/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 88: PROP_DT(t2h1u2); vxin=vx; vyin=vy; vzin=vz; ny=-y; nz=-y*y/((a2hu2/(z+z0hu2))-(z0hu2+z)); n2=sqrt(ny*ny+nz*nz); pf=2.0*(vy*ny+vz*nz)/n2; vy-=pf*ny/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 89: PROP_DT(t2h1u2); vxin=vx; vyin=vy; vzin=vz; ny=-y; nz=-0.5/pahu2; n2=sqrt(ny*ny+nz*nz); pf=2.0*(vy*ny+vz*nz)/n2; vy-=pf*ny/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 90: PROP_DT(t2h1u2); vxin=vx; vyin=vy; vzin=vz; ny=-l; nz=h2u2-h1u2; n2=sqrt(ny*ny+nz*nz); pf=2.0*(vy*ny+vz*nz)/n2; vy-=pf*ny/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 91: PROP_DT(t2h1d2); vxin=vx; vyin=vy; vzin=vz; ny=-y; nz=-y*y/((a2hd2/(z+z0hd2))-(z0hd2+z)); n2=sqrt(ny*ny+nz*nz); pf=2.0*(vy*ny+vz*nz)/n2; vy-=pf*ny/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 92: PROP_DT(t2h1d2); vxin=vx; vyin=vy; vzin=vz; ny=-y; nz=-0.5/pahd2; n2=sqrt(ny*ny+nz*nz); pf=2.0*(vy*ny+vz*nz)/n2; vy-=pf*ny/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 93: PROP_DT(t2h1d2); vxin=vx; vyin=vy; vzin=vz; ny=l; nz=h2d2-h1d2; n2=sqrt(ny*ny+nz*nz); pf=2.0*(vy*ny+vz*nz)/n2; vy-=pf*ny/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 94: /* transperent walls - no interaction */ PROP_DT(t2w1r2); break; case 95: PROP_DT(t2w1l2); break; case 96: PROP_DT(t2h1u2); break; case 97: PROP_DT(t2h1d2); break; case 98: /* absorbing walls - neutrons are absorbed at interaction point*/ PROP_DT(t2w1r2); ABSORB; break; case 99: PROP_DT(t2w1l2); ABSORB; break; case 100: PROP_DT(t2h1u2); ABSORB; break; case 101: PROP_DT(t2h1d2); ABSORB; break; /* OUTER WALLS - analog to inner walls, but sign of surface normal vector is changed */ case 102: PROP_DT(t2w1rwt2); vxin=vx; vyin=vy; vzin=vz; nx=x; nz=x*x/((a2wrwt2/(z+z0wr2))-(z0wr2+z)); n2=sqrt(nx*nx+nz*nz); pf=2.0*(vx*nx+vz*nz)/n2; vx-=pf*nx/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 103: PROP_DT(t2w1rwt2); vxin=vx; vyin=vy; vzin=vz; nx=x; nz=0.5/pawrwt2; n2=sqrt(nx*nx+nz*nz); pf=2.0*(vx*nx+vz*nz)/n2; vx-=pf*nx/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 104: PROP_DT(t2w1rwt2); vxin=vx; vyin=vy; vzin=vz; nx=-l; nz=-(w2r2-w1r2); n2=sqrt(nx*nx+nz*nz); pf=2.0*(vx*nx+vz*nz)/n2; vx-=pf*nx/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 105: PROP_DT(t2w1lwt2); vxin=vx; vyin=vy; vzin=vz; nx=x; nz=x*x/((a2wlwt2/(z+z0wl2))-(z0wl2+z)); n2=sqrt(nx*nx+nz*nz); pf=2.0*(vx*nx+vz*nz)/n2; vx-=pf*nx/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 106: PROP_DT(t2w1lwt2); vxin=vx; vyin=vy; vzin=vz; nx=x; nz=0.5/pawlwt2; n2=sqrt(nx*nx+nz*nz); pf=2.0*(vx*nx+vz*nz)/n2; vx-=pf*nx/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 107: PROP_DT(t2w1lwt2); vxin=vx; vyin=vy; vzin=vz; nx=l; nz=-(w2l2-w1l2); n2=sqrt(nx*nx+nz*nz); pf=2.0*(vx*nx+vz*nz)/n2; vx-=pf*nx/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 108: PROP_DT(t2h1uwt2); vxin=vx; vyin=vy; vzin=vz; ny=y; nz=y*y/((a2huwt2/(z+z0hu2))-(z0hu2+z)); n2=sqrt(ny*ny+nz*nz); pf=2.0*(vy*ny+vz*nz)/n2; vy-=pf*ny/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 109: PROP_DT(t2h1uwt2); vxin=vx; vyin=vy; vzin=vz; ny=y; nz=0.5/pahuwt2; n2=sqrt(ny*ny+nz*nz); pf=2.0*(vy*ny+vz*nz)/n2; vy-=pf*ny/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 110: PROP_DT(t2h1uwt2); vxin=vx; vyin=vy; vzin=vz; ny=l; nz=-(h2u2-h1u2); n2=sqrt(ny*ny+nz*nz); pf=2.0*(vy*ny+vz*nz)/n2; vy-=pf*ny/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 111: PROP_DT(t2h1dwt2); vxin=vx; vyin=vy; vzin=vz; ny=y; nz=y*y/((a2hdwt2/(z+z0hd2))-(z0hd2+z)); n2=sqrt(ny*ny+nz*nz); pf=2.0*(vy*ny+vz*nz)/n2; vy-=pf*ny/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 112: PROP_DT(t2h1dwt2); vxin=vx; vyin=vy; vzin=vz; ny=y; nz=0.5/pahdwt2; n2=sqrt(ny*ny+nz*nz); pf=2.0*(vy*ny+vz*nz)/n2; vy-=pf*ny/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 113: PROP_DT(t2h1dwt2); vxin=vx; vyin=vy; vzin=vz; ny=-l; nz=-(h2d2-h1d2); n2=sqrt(ny*ny+nz*nz); pf=2.0*(vy*ny+vz*nz)/n2; vy-=pf*ny/n2; vz-=pf*nz/n2; q=V2Q*sqrt((vxin-vx)*(vxin-vx)+(vyin-vy)*(vyin-vy)+(vzin-vz)*(vzin-vz)); break; case 114: PROP_DT(t2w1rwt2); ABSORB; break; case 115: PROP_DT(t2w1lwt2); ABSORB; break; case 116: PROP_DT(t2h1uwt2); ABSORB; break; case 117: PROP_DT(t2h1dwt2); ABSORB; break; case 118: PROP_DT(t2w1rwt2); break; case 119: PROP_DT(t2w1lwt2); break; case 120: PROP_DT(t2h1uwt2); break; case 121: PROP_DT(t2h1dwt2); break; } if (((i==2) ||(i==3) || (i == 4 ))){ /* calculating the the probability that the neutron is reflected at the RIGHT INNER wall*/ if (RIreflect && strlen(RIreflect)) { p=Table_Value(riTable, q, 1); }else{ if(mxr > 0 && q > Qcxr){ double arg = (q - mxr*Qcxr)/Wxr; if(arg<10){ p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxr*(q-Qcxr)); }else ABSORB; } } } if (((i==22) ||(i==23) || (i==24 ))){ /* calculating the the probability that the neutron is reflected at the RIGHT OUTER wall*/ if (ROreflect && strlen(ROreflect)) { p=Table_Value(roTable, q, 1); }else{ if(mxrOW > 0 && q > QcxrOW){ double arg = (q - mxrOW*QcxrOW)/WxrOW; if(arg<10){ p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxrOW*(q-QcxrOW)); } else ABSORB; } } } if (((i==5) ||(i==6) || (i == 7 ) ) ){ /* calculating the the probability that the neutron is reflected at the LEFT INNER wall*/ if (LIreflect && strlen(LIreflect)) { p=Table_Value(liTable, q, 1); }else{ if(mxl > 0 && q > Qcxl){ double arg = (q - mxl*Qcxl)/Wxl; if(arg<10){ p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxl*(q-Qcxl)); }else ABSORB; } } } if (((i==25) || (i==26) || (i==27 ))){ /* calculating the the probability that the neutron is reflected at the LEFT OUTER wall*/ if (LOreflect && strlen(LOreflect)) { p=Table_Value(loTable, q, 1); }else{ if(mxlOW > 0 && q > QcxlOW){ double arg = (q - mxlOW*QcxlOW)/WxlOW; if(arg<10){ p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxlOW*(q-QcxlOW)); } else ABSORB; } } } if (((i==8) ||(i==9) || (i == 10 ))){ /* calculating the the probability that the neutron is reflected at the TOP INNER wall*/ if (UIreflect && strlen(UIreflect)) { p=Table_Value(uiTable, q, 1); }else{ if(myu > 0 && q > Qcyu){ double arg = (q - myu*Qcyu)/Wyu; if(arg<10){ p *= 0.5*(1.0-tanh(arg))*(1.0-alphayu*(q-Qcyu)); }else ABSORB; } } } if (((i==28) || (i==29) || (i==30 )) ){ /* calculating the the probability that the neutron is reflected at the TOP OUTER wall*/ if (UOreflect && strlen(UOreflect)) { p=Table_Value(uoTable, q, 1); }else{ if(myuOW > 0 && q > QcyuOW){ double arg = (q - myuOW*QcyuOW)/WyuOW; if(arg<10){ p *= 0.5*(1.0-tanh(arg))*(1.0-alphayuOW*(q-QcyuOW)); }else ABSORB; } } } if (((i==11) ||(i==12) || (i == 13 ))){ /* calculating the the probability that the neutron is reflected at the BOTTOM INNER wall*/ if (DIreflect && strlen(DIreflect)) { p=Table_Value(diTable, q, 1); }else{ if(myd > 0 && q > Qcyd){ double arg = (q - myd*Qcyd)/Wyd; if(arg<10){ p *= 0.5*(1.0-tanh(arg))*(1.0-alphayd*(q-Qcyd)); }else ABSORB; } } } if (((i==31) || (i==32) || (i==33 )) ){ /* calculating the the probability that the neutron is reflected at the BOTTOM OUTER wall*/ if (DOreflect && strlen(DOreflect)) { p=Table_Value(doTable, q, 1); }else{ if(mydOW > 0 && q > QcydOW){ double arg = (q - mydOW*QcydOW)/WydOW; if(arg<10){ p *= 0.5*(1.0-tanh(arg))*(1.0-alphaydOW*(q-QcydOW)); }else ABSORB; } } } if (((i==42) ||(i==43) || (i == 44 )) ){ /* calculating the the probability that the neutron is reflected at the RIGHT INNER wall*/ if (RIreflect1 && strlen(RIreflect1)) { p=Table_Value(riTable1, q, 1); }else{ if(mxr1 > 0 && q > Qcxr1){ double arg = (q - mxr1*Qcxr1)/Wxr1; if(arg<10){ p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxr1*(q-Qcxr1)); }else ABSORB; } } } if (((i==45) ||(i==46) || (i == 47 ) )){ /* calculating the the probability that the neutron is reflected at the LEFT INNER wall*/ if (LIreflect1 && strlen(LIreflect1)) { p=Table_Value(liTable1, q, 1); }else{ if(mxl1 > 0 && q > Qcxl1){ double arg = (q - mxl1*Qcxl1)/Wxl1; if(arg<10){ p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxl1*(q-Qcxl1)); }else ABSORB; } } } if (((i==48) ||(i==49) || (i == 50 )) ){ /* calculating the the probability that the neutron is reflected at the TOP INNER wall*/ if (UIreflect1 && strlen(UIreflect1)) { p=Table_Value(uiTable1, q, 1); }else{ if(myu1 > 0 && q > Qcyu1){ double arg = (q - myu1*Qcyu1)/Wyu1; if(arg<10){ p *= 0.5*(1.0-tanh(arg))*(1.0-alphayu1*(q-Qcyu1)); }else ABSORB; } } } if (((i==51) ||(i==52) || (i == 53 )) ){ /* calculating the the probability that the neutron is reflected at the BOTTOM INNER wall*/ if (DIreflect1 && strlen(DIreflect1)) { p=Table_Value(diTable1, q, 1); }else{ if(myd1 > 0 && q > Qcyd1){ double arg = (q - myd1*Qcyd1)/Wyd1; if(arg<10){ p *= 0.5*(1.0-tanh(arg))*(1.0-alphayd1*(q-Qcyd1)); }else ABSORB; } } } if (((i==62) ||(i==63) || (i==64 ))){ if (ROreflect1 && strlen(ROreflect1)) { p=Table_Value(roTable1, q, 1); }else{ if(mxrOW1 > 0 && q > QcxrOW1){ double arg = (q - mxrOW1*QcxrOW1)/WxrOW1; if(arg<10){ p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxrOW1*(q-QcxrOW1)); } else ABSORB; } } } if (((i==65) || (i==66) || (i==67 ))){ if (LOreflect1 && strlen(LOreflect1)) { p=Table_Value(loTable1, q, 1); }else{ if(mxlOW1 > 0 && q > QcxlOW1){ double arg = (q - mxlOW1*QcxlOW1)/WxlOW1; if(arg<10){ p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxlOW1*(q-QcxlOW1)); } else ABSORB; } } } if (((i==68) || (i==69) || (i==70 )) ){ if (UOreflect1 && strlen(UOreflect1)) { p=Table_Value(uoTable1, q, 1); }else{ if(myuOW1 > 0 && q > QcyuOW1){ double arg = (q - myuOW1*QcyuOW1)/WyuOW1; if(arg<10){ p *= 0.5*(1.0-tanh(arg))*(1.0-alphayuOW1*(q-QcyuOW1)); }else ABSORB; } } } if (((i==71) || (i==72) || (i==73 )) ){ if (DOreflect1 && strlen(DOreflect1)) { p=Table_Value(doTable1, q, 1); }else{ if(mydOW1 > 0 && q > QcydOW1){ double arg = (q - mydOW1*QcydOW1)/WydOW1; if(arg<10){ p *= 0.5*(1.0-tanh(arg))*(1.0-alphaydOW1*(q-QcydOW1)); }else ABSORB; } } } if (((i==82) ||(i==83) || (i == 84 ))){ if (RIreflect2 && strlen(RIreflect2)) { p=Table_Value(riTable2, q, 1); }else{ if(mxr2 > 0 && q > Qcxr2){ double arg = (q - mxr2*Qcxr2)/Wxr2; if(arg<10){ p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxr2*(q-Qcxr2)); }else ABSORB; } } } if (((i==102) ||(i==103) || (i==104 ))){ if (ROreflect2 && strlen(ROreflect2)) { p=Table_Value(roTable2, q, 1); }else{ if(mxrOW2 > 0 && q > QcxrOW2){ double arg = (q - mxrOW2*QcxrOW2)/WxrOW2; if(arg<10){ p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxrOW2*(q-QcxrOW2)); } else ABSORB; } } } if (((i==85) ||(i==86) || (i == 87 ) ) ){ if (LIreflect2 && strlen(LIreflect2)) { p=Table_Value(liTable2, q, 1); }else{ if(mxl2 > 0 && q > Qcxl2){ double arg = (q - mxl2*Qcxl2)/Wxl2; if(arg<10){ p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxl2*(q-Qcxl2)); }else ABSORB; } } } if (((i==105) || (i==106) || (i==107 ))){ if (LOreflect2 && strlen(LOreflect2)) { p=Table_Value(loTable2, q, 1); }else{ if(mxlOW2 > 0 && q > QcxlOW2){ double arg = (q - mxlOW2*QcxlOW2)/WxlOW2; if(arg<10){ p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxlOW2*(q-QcxlOW2)); } else ABSORB; } } } if (((i==88) ||(i==89) || (i == 90 ))){ if (UIreflect2 && strlen(UIreflect2)) { p=Table_Value(uiTable2, q, 1); }else{ if(myu2 > 0 && q > Qcyu2){ double arg = (q - myu2*Qcyu2)/Wyu2; if(arg<10){ p *= 0.5*(1.0-tanh(arg))*(1.0-alphayu2*(q-Qcyu2)); }else ABSORB; } } } if (((i==108) || (i==109) || (i==110 )) ){ if (UOreflect2 && strlen(UOreflect2)) { p=Table_Value(uoTable2, q, 1); }else{ if(myuOW2 > 0 && q > QcyuOW2){ double arg = (q - myuOW2*QcyuOW2)/WyuOW2; if(arg<10){ p *= 0.5*(1.0-tanh(arg))*(1.0-alphayuOW2*(q-QcyuOW2)); }else ABSORB; } } } if (((i==91) ||(i==92) || (i == 93 ))){ if (DIreflect2 && strlen(DIreflect2)) { p=Table_Value(diTable2, q, 1); }else{ if(myd2 > 0 && q > Qcyd2){ double arg = (q - myd2*Qcyd2)/Wyd2; if(arg<10){ p *= 0.5*(1.0-tanh(arg))*(1.0-alphayd2*(q-Qcyd2)); }else ABSORB; } } } if (((i==111) || (i==112) || (i==113 )) ){ if (DOreflect2 && strlen(DOreflect2)) { p=Table_Value(doTable2, q, 1); }else{ if(mydOW2 > 0 && q > QcydOW2){ double arg = (q - mydOW2*QcydOW2)/WydOW2; if(arg<10){ p *= 0.5*(1.0-tanh(arg))*(1.0-alphaydOW2*(q-QcydOW2)); }else ABSORB; } } } p *= R0; SCATTER; } while (z= -w2rwt && y <= mru2*x+nru2 && y >= mrd2*x+nrd2 && mxr!=-1 && mxrOW!=-1) /* absorbing the neutron if it hit the RIGHT exit wall and the wall is not transparent*/ ABSORB; if(x >= w2l && x <= w2lwt && y <= mlu2*x+nlu2 && y >= mld2*x+nld2 && mxl!=-1 && mxlOW!=-1) /* absorbing the neutron if it hit the LEFT exit wall and the wall is not transparent*/ ABSORB; if(y <= -h2d && y >= -h2dwt && x <= (y-nld2)/mld2 && x>= (y-nrd2)/mrd2 && myd!=-1 && mydOW!=-1) /* absorbing the neutron if it hit the BOTTOM exit wall and the wall is not transparent*/ ABSORB; if(y >= h2u && y <= h2uwt && x <= (y-nlu2)/mlu2 && x>= (y-nru2)/mru2 && myu!=-1 && myuOW!=-1) /* absorbing the neutron if it hit the TOP exit wall and the wall is not transparent*/ ABSORB; if(x <= -w2r1 && x >= -w2rwt1 && y <= mru21*x+nru21 && y >= mrd21*x+nrd21 && mxr1!=-1 && mxrOW1!=-1) ABSORB; if(x >= w2l1 && x <= w2lwt1 && y <= mlu21*x+nlu21 && y >= mld21*x+nld21 && mxl1!=-1 && mxlOW1!=-1) ABSORB; if(y <= -h2d1 && y >= -h2dwt1 && x <= (y-nld21)/mld21 && x>= (y-nrd21)/mrd21 && myd1!=-1 && mydOW1!=-1) ABSORB; if(y >= h2u1 && y <= h2uwt1 && x <= (y-nlu21)/mlu21 && x>= (y-nru21)/mru21 && myu1!=-1 && myuOW1!=-1) ABSORB; if(x <= -w2r2 && x >= -w2rwt2 && y <= mru22*x+nru22 && y >= mrd22*x+nrd22 && mxr2!=-1 && mxrOW2!=-1) ABSORB; if(x >= w2l2 && x <= w2lwt2 && y <= mlu22*x+nlu22 && y >= mld22*x+nld22 && mxl2!=-1 && mxlOW2!=-1) ABSORB; if(y <= -h2d2 && y >= -h2dwt2 && x <= (y-nld22)/mld22 && x>= (y-nrd22)/mrd22 && myd2!=-1 && mydOW2!=-1) ABSORB; if(y >= h2u2 && y <= h2uwt2 && x <= (y-nlu22)/mlu22 && x>= (y-nru22)/mru22 && myu2!=-1 && myuOW2!=-1) ABSORB; %} FINALLY %{ %} MCDISPLAY %{ int i,imax; double x1,y1,z,x2,y2,z1,z0wr,z0wl,z0hu,z0hd,xwt,ywt,x1wt,y1wt; double mr,ml,mu,md,nr1,nl1,nu1,nd1,nr2,nl2,nu2,nd2; double lbwl,lbwr,lbhu,lbhd; /* length between focal points , needed for elliptic case */ double x11,y11,x21,y21,z11,z0wr1,z0wl1,z0hu1,z0hd1,xwt1,ywt1,x1wt1,y1wt1; double mr1,ml1,mu1,md1,nr11,nl11,nu11,nd11,nr21,nl21,nu21,nd21; double lbwl1,lbwr1,lbhu1,lbhd1; double x12,y12,x22,y22,z12,z0wr2,z0wl2,z0hu2,z0hd2,xwt2,ywt2,x1wt2,y1wt2; double mr2,ml2,mu2,md2,nr12,nl12,nu12,nd12,nr22,nl22,nu22,nd22; double lbwl2,lbwr2,lbhu2,lbhd2; magnify("xy"); imax=100; /* maximum points for every line in z direction*/ lbwr=linwr+l+loutwr; lbwl=linwl+l+loutwl; lbhu=linhu+l+louthu; lbhd=linhd+l+louthd; lbwr1=linwr1+l+loutwr1; lbwl1=linwl1+l+loutwl1; lbhu1=linhu1+l+louthu1; lbhd1=linhd1+l+louthd1; lbwr2=linwr2+l+loutwr2; lbwl2=linwl2+l+loutwl2; lbhu2=linhu2+l+louthu2; lbhd2=linhd2+l+louthd2; if (linwr==0 && loutwr==0){ mr=(-w2r+w1r)/l; nr1=-w1r; nr2=-(w1rwt); } if (linwl==0 && loutwl==0){ ml=(w2l-w1l)/l; nl1=w1l; nl2=(w1lwt); } if (linhu == 0 && louthu==0) { mu=(h2u-h1u)/l; nu1=h1u; nu2=(h1uwt); } if (linhd == 0 && louthd==0) { md=(-h2d+h1d)/l; nd1=-h1d; nd2=-(h1dwt); } z0wr=(linwr-l-loutwr)/2.0; z0wl=(linwl-l-loutwl)/2.0; z0hu=lbhu/2.0-l-louthu; z0hd=lbhd/2.0-l-louthd; z0wr1=(linwr1-l-loutwr1)/2.0; z0wl1=(linwl1-l-loutwl1)/2.0; z0hu1=lbhu1/2.0-l-louthu1; z0hd1=lbhd1/2.0-l-louthd1; if(myd!=-1) line(w1l, -h1d, 0.0, -w1r, -h1d, 0.0); /* entrance window given by the INNER walls*/ if(myu!=-1)line(w1l, h1u, 0.0, -w1r, h1u, 0.0); if(mxl!=-1)line(w1l, -h1d, 0.0, w1l, h1u, 0.0); if(mxr!=-1)line( -w1r, h1u, 0.0, -w1r, -h1d, 0.0); if(myd!=-1)line(w2l, -h2d, l, -w2r, -h2d, l); /* exit window given by the INNER walls*/ if(myu!=-1)line(w2l, h2u, l, -w2r, h2u, l); if(mxl!=-1)line(w2l, -h2d, l, w2l, h2u, l); if(mxr!=-1)line( -w2r, -h2d, l, -w2r, h2u, l); if(mydOW!=-1) line((w1lwt), -(h1dwt), 0.0, -(w1rwt), -(h1dwt), 0.0); /* entrance window given by the OUTER walls */ if(myuOW!=-1)line((w1lwt), (h1uwt), 0.0, -(w1rwt), (h1uwt), 0.0); if(mxlOW!=-1)line((w1lwt), -(h1dwt), 0.0, (w1lwt), (h1uwt), 0.0); if(mxrOW!=-1)line( -(w1rwt), (h1uwt), 0.0, -(w1rwt), -(h1dwt), 0.0); if(mydOW!=-1)line((w2lwt), -(h2dwt), l, -(w2rwt), -(h2dwt), l); /* exit windows given by the OUTER walls*/ if(myuOW!=-1)line((w2lwt), (h2uwt), l, -(w2rwt), (h2uwt), l); if(mxlOW!=-1)line((w2lwt), -(h2dwt), l, (w2lwt), (h2uwt), l); if(mxrOW!=-1)line( -(w2rwt), -(h2dwt), l, -(w2rwt), (h2uwt), l); if((myd!=-1 && mydOW!=-1) || (mxl!=-1 && mxlOW!=-1)) line(w1l, -h1d, 0.0, (w1lwt), -(h1dwt), 0.0); /* corner connection lines for the entrance windows*/ if((myu!=-1 && myuOW!=-1) || (mxl!=-1 && mxlOW!=-1)) line(w1l, h1u, 0.0, (w1lwt), (h1uwt), 0.0); if((myd!=-1 && mydOW!=-1) || (mxr!=-1 && mxrOW!=-1)) line(-w1r, -h1d, 0.0,-(w1rwt), -(h1dwt), 0.0); if((myu!=-1 && myuOW!=-1) || (mxr!=-1 && mxrOW!=-1)) line( -w1r, h1u, 0.0, -(w1rwt), (h1uwt), 0.0); if((myd!=-1 && mydOW!=-1) || (mxl!=-1 && mxlOW!=-1)) line(w2l, -h2d, l, (w2lwt), -(h2dwt), l); /* corner connection lines for the exit windows*/ if((myu!=-1 && myuOW!=-1) || (mxl!=-1 && mxlOW!=-1)) line(w2l, h2u, l, (w2lwt), (h2uwt), l); if((myd!=-1 && mydOW!=-1) || (mxr!=-1 && mxrOW!=-1)) line(-w2r, -h2d, l,-(w2rwt), -(h2dwt), l); if((myu!=-1 && myuOW!=-1) || (mxr!=-1 && mxrOW!=-1)) line( -w2r, h2u, l, -(w2rwt), (h2uwt), l); for(i=0;i