/*******************************************************************************
*
* McStas, the neutron ray-tracing package: Guide_four_side_10_shells.comp
*
* Component: Guide_four_side_10_shells
*
* %I
* Written by: Tobias Panzner
* Date: 07/08/2010
* Version: $Revision: 1.1 $
* Release: McStas 1.12c
* Origin: PSI
*
*
*  This component models a guide with four side walls surounded by up to 10 shells (every shell consists of 
*  additional four walls). In the  end it  forms a guide with an inner and up to 10 outer channel.
*  As user you can controll the properties of every wall separatly. All togther you have up to 
*  88 walls: From the inner channel 4 inner walls and four 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 88 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_10_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, RIreflect3=0, LIreflect3=0, UIreflect3=0, DIreflect3=0, ROreflect3=0, LOreflect3=0, UOreflect3=0, DOreflect3=0,RIreflect4=0, LIreflect4=0, UIreflect4=0, DIreflect4=0, ROreflect4=0, LOreflect4=0, UOreflect4=0, DOreflect4=0, RIreflect5=0, LIreflect5=0, UIreflect5=0, DIreflect5=0, ROreflect5=0, LOreflect5=0, UOreflect5=0, DOreflect5=0,RIreflect6=0, LIreflect6=0, UIreflect6=0, DIreflect6=0, ROreflect6=0, LOreflect6=0, UOreflect6=0, DOreflect6=0, RIreflect7=0, LIreflect7=0, UIreflect7=0, DIreflect7=0, ROreflect7=0, LOreflect7=0, UOreflect7=0,  DOreflect7=0,RIreflect8=0, LIreflect8=0, UIreflect8=0, DIreflect8=0, ROreflect8=0, LOreflect8=0, UOreflect8=0, DOreflect8=0, RIreflect9=0, LIreflect9=0, UIreflect9=0, DIreflect9=0, ROreflect9=0, LOreflect9=0, UOreflect9=0, DOreflect9=0,RIreflect10=0, LIreflect10=0, UIreflect10=0, DIreflect10=0, ROreflect10=0, LOreflect10=0, UOreflect10=0, DOreflect10=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,

                    w1l3=2.006,w2l3=2.006,linwl3=0,loutwl3=0,
                    w1r3=2.006,w2r3=2.006,linwr3=0,loutwr3=0,
                    h1u3=2.006,h2u3=2.006,linhu3=0,louthu3=0,
                    h1d3=2.006,h2d3=2.006,linhd3=0,louthd3=0,
                    Qcxl3=0.0217,Qcxr3=0.0217,Qcyu3=0.0217, Qcyd3=0.0217,
                    alphaxl3=6.07, alphaxr3=6.07, alphayu3=6.07, alphayd3=6.07,
                    Wxr3=0.003,Wxl3=0.003,Wyu3=0.003,Wyd3=0.003,
                    mxr3=-1, mxl3=-1, myu3=-1, myd3=-1,
                    QcxrOW3=0.0217,QcxlOW3=0.0217,QcyuOW3=0.0217, QcydOW3=0.0217,
                    alphaxlOW3=6.07, alphaxrOW3=6.07, alphayuOW3=6.07, alphaydOW3=6.07,
                    WxrOW3=0.003,WxlOW3=0.003,WyuOW3=0.003,WydOW3=0.003,
                    mxrOW3=-1, mxlOW3=-1, myuOW3=-1, mydOW3=-1,
		    rwallthick3=0.001,lwallthick3=0.001,uwallthick3=0.001,dwallthick3=0.001,

                    w1l4=2.008,w2l4=2.008,linwl4=0,loutwl4=0,
                    w1r4=2.008,w2r4=2.008,linwr4=0,loutwr4=0,
                    h1u4=2.008,h2u4=2.008,linhu4=0,louthu4=0,
                    h1d4=2.008,h2d4=2.008,linhd4=0,louthd4=0,
                    Qcxl4=0.0217,Qcxr4=0.0217,Qcyu4=0.0217, Qcyd4=0.0217,
                    alphaxl4=6.07, alphaxr4=6.07, alphayu4=6.07, alphayd4=6.07,
                    Wxr4=0.003,Wxl4=0.003,Wyu4=0.003,Wyd4=0.003,
                    mxr4=-1, mxl4=-1, myu4=-1, myd4=-1,
                    QcxrOW4=0.0217,QcxlOW4=0.0217,QcyuOW4=0.0217, QcydOW4=0.0217,
                    alphaxlOW4=6.07, alphaxrOW4=6.07, alphayuOW4=6.07, alphaydOW4=6.07,
                    WxrOW4=0.003,WxlOW4=0.003,WyuOW4=0.003,WydOW4=0.003,
                    mxrOW4=-1, mxlOW4=-1, myuOW4=-1, mydOW4=-1,
		   rwallthick4=0.001,lwallthick4=0.001,uwallthick4=0.001,dwallthick4=0.001,

                    w1l5=2.01,w2l5=2.01,linwl5=0,loutwl5=0,
                    w1r5=2.01,w2r5=2.01,linwr5=0,loutwr5=0,
                    h1u5=2.01,h2u5=2.01,linhu5=0,louthu5=0,
                    h1d5=2.01,h2d5=2.01,linhd5=0,louthd5=0,
                    Qcxl5=0.0217,Qcxr5=0.0217,Qcyu5=0.0217, Qcyd5=0.0217,
                    alphaxl5=6.07, alphaxr5=6.07, alphayu5=6.07, alphayd5=6.07,
                    Wxr5=0.003,Wxl5=0.003,Wyu5=0.003,Wyd5=0.003,
                    mxr5=-1, mxl5=-1, myu5=-1, myd5=-1,
                    QcxrOW5=0.0217,QcxlOW5=0.0217,QcyuOW5=0.0217, QcydOW5=0.0217,
                    alphaxlOW5=6.07, alphaxrOW5=6.07, alphayuOW5=6.07, alphaydOW5=6.07,
                    WxrOW5=0.003,WxlOW5=0.003,WyuOW5=0.003,WydOW5=0.003,
                    mxrOW5=-1, mxlOW5=-1, myuOW5=-1, mydOW5=-1,
		    rwallthick5=0.001,lwallthick5=0.001,uwallthick5=0.001,dwallthick5=0.001,

                    w1l6=2.012,w2l6=2.012,linwl6=0,loutwl6=0,
                    w1r6=2.012,w2r6=2.012,linwr6=0,loutwr6=0,
                    h1u6=2.012,h2u6=2.012,linhu6=0,louthu6=0,
                    h1d6=2.012,h2d6=2.012,linhd6=0,louthd6=0,
                    Qcxl6=0.0217,Qcxr6=0.0217,Qcyu6=0.0217, Qcyd6=0.0217,
                    alphaxl6=6.07, alphaxr6=6.07, alphayu6=6.07, alphayd6=6.07,
                    Wxr6=0.003,Wxl6=0.003,Wyu6=0.003,Wyd6=0.003,
                    mxr6=-1, mxl6=-1, myu6=-1, myd6=-1,
                    QcxrOW6=0.0217,QcxlOW6=0.0217,QcyuOW6=0.0217, QcydOW6=0.0217,
                    alphaxlOW6=6.07, alphaxrOW6=6.07, alphayuOW6=6.07, alphaydOW6=6.07,
                    WxrOW6=0.003,WxlOW6=0.003,WyuOW6=0.003,WydOW6=0.003,
                    mxrOW6=-1, mxlOW6=-1, myuOW6=-1, mydOW6=-1,
		    rwallthick6=0.001,lwallthick6=0.001,uwallthick6=0.001,dwallthick6=0.001,

                    w1l7=2.014,w2l7=2.014,linwl7=0,loutwl7=0,
                    w1r7=2.014,w2r7=2.014,linwr7=0,loutwr7=0,
                    h1u7=2.014,h2u7=2.014,linhu7=0,louthu7=0,
                    h1d7=2.014,h2d7=2.014,linhd7=0,louthd7=0,
                    Qcxl7=0.0217,Qcxr7=0.0217,Qcyu7=0.0217, Qcyd7=0.0217,
                    alphaxl7=6.07, alphaxr7=6.07, alphayu7=6.07, alphayd7=6.07,
                    Wxr7=0.003,Wxl7=0.003,Wyu7=0.003,Wyd7=0.003,
                    mxr7=-1, mxl7=-1, myu7=-1, myd7=-1,
                    QcxrOW7=0.0217,QcxlOW7=0.0217,QcyuOW7=0.0217, QcydOW7=0.0217,
                    alphaxlOW7=6.07, alphaxrOW7=6.07, alphayuOW7=6.07, alphaydOW7=6.07,
                    WxrOW7=0.003,WxlOW7=0.003,WyuOW7=0.003,WydOW7=0.003,
                    mxrOW7=-1, mxlOW7=-1, myuOW7=-1, mydOW7=-1,
		   rwallthick7=0.001,lwallthick7=0.001,uwallthick7=0.001,dwallthick7=0.001,

                    w1l8=2.016,w2l8=2.016,linwl8=0,loutwl8=0,
                    w1r8=2.016,w2r8=2.016,linwr8=0,loutwr8=0,
                    h1u8=2.016,h2u8=2.016,linhu8=0,louthu8=0,
                    h1d8=2.016,h2d8=2.016,linhd8=0,louthd8=0,
                    Qcxl8=0.0217,Qcxr8=0.0217,Qcyu8=0.0217, Qcyd8=0.0217,
                    alphaxl8=6.07, alphaxr8=6.07, alphayu8=6.07, alphayd8=6.07,
                    Wxr8=0.003,Wxl8=0.003,Wyu8=0.003,Wyd8=0.003,
                    mxr8=-1, mxl8=-1, myu8=-1, myd8=-1,
                    QcxrOW8=0.0217,QcxlOW8=0.0217,QcyuOW8=0.0217, QcydOW8=0.0217,
                    alphaxlOW8=6.07, alphaxrOW8=6.07, alphayuOW8=6.07, alphaydOW8=6.07,
                    WxrOW8=0.003,WxlOW8=0.003,WyuOW8=0.003,WydOW8=0.003,
                    mxrOW8=-1, mxlOW8=-1, myuOW8=-1, mydOW8=-1,
		   rwallthick8=0.001,lwallthick8=0.001,uwallthick8=0.001,dwallthick8=0.001,

                    w1l9=2.018,w2l9=2.018,linwl9=0,loutwl9=0,
                    w1r9=2.018,w2r9=2.018,linwr9=0,loutwr9=0,
                    h1u9=2.018,h2u9=2.018,linhu9=0,louthu9=0,
                    h1d9=2.018,h2d9=2.018,linhd9=0,louthd9=0,
                    Qcxl9=0.0217,Qcxr9=0.0217,Qcyu9=0.0217, Qcyd9=0.0217,
                    alphaxl9=6.07, alphaxr9=6.07, alphayu9=6.07, alphayd9=6.07,
                    Wxr9=0.003,Wxl9=0.003,Wyu9=0.003,Wyd9=0.003,
                    mxr9=-1, mxl9=-1, myu9=-1, myd9=-1,
                    QcxrOW9=0.0217,QcxlOW9=0.0217,QcyuOW9=0.0217, QcydOW9=0.0217,
                    alphaxlOW9=6.07, alphaxrOW9=6.07, alphayuOW9=6.07, alphaydOW9=6.07,
                    WxrOW9=0.003,WxlOW9=0.003,WyuOW9=0.003,WydOW9=0.003,
                    mxrOW9=-1, mxlOW9=-1, myuOW9=-1, mydOW9=-1,
		   rwallthick9=0.001,lwallthick9=0.001,uwallthick9=0.001,dwallthick9=0.001,

                    w1l10=2.02,w2l10=2.02,linwl10=0,loutwl10=0,
                    w1r10=2.02,w2r10=2.02,linwr10=0,loutwr10=0,
                    h1u10=2.02,h2u10=2.02,linhu10=0,louthu10=0,
                    h1d10=2.02,h2d10=2.02,linhd10=0,louthd10=0,
                    Qcxl10=0.0217,Qcxr10=0.0217,Qcyu10=0.0217, Qcyd10=0.0217,
                    alphaxl10=6.07, alphaxr10=6.07, alphayu10=6.07, alphayd10=6.07,
                    Wxr10=0.003,Wxl10=0.003,Wyu10=0.003,Wyd10=0.003,
                    mxr10=-1, mxl10=-1, myu10=-1, myd10=-1,
                    QcxrOW10=0.0217,QcxlOW10=0.0217,QcyuOW10=0.0217, QcydOW10=0.0217,
                    alphaxlOW10=6.07, alphaxrOW10=6.07, alphayuOW10=6.07, alphaydOW10=6.07,
                    WxrOW10=0.003,WxlOW10=0.003,WyuOW10=0.003,WydOW10=0.003,
                    mxrOW10=-1, mxlOW10=-1, myuOW10=-1, mydOW10=-1,
		   rwallthick10=0.001,lwallthick10=0.001,uwallthick10=0.001,dwallthick10=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,

                  t2w1r3,t2w1l3,t2h1u3,t2h1d3,
                  t2w1rwt3,t2w1lwt3,t2h1uwt3,t2h1dwt3,
		  t2w1r4,t2w1l4,t2h1u4,t2h1d4,
                  t2w1rwt4,t2w1lwt4,t2h1uwt4,t2h1dwt4,
		  t2w1r5,t2w1l5,t2h1u5,t2h1d5,
                  t2w1rwt5,t2w1lwt5,t2h1uwt5,t2h1dwt5,
		  t2w1r6,t2w1l6,t2h1u6,t2h1d6,
                  t2w1rwt6,t2w1lwt6,t2h1uwt6,t2h1dwt6,
		  t2w1r7,t2w1l7,t2h1u7,t2h1d7,
                  t2w1rwt7,t2w1lwt7,t2h1uwt7,t2h1dwt7,
		  t2w1r8,t2w1l8,t2h1u8,t2h1d8,
                  t2w1rwt8,t2w1lwt8,t2h1uwt8,t2h1dwt8,
		  t2w1r9,t2w1l9,t2h1u9,t2h1d9,
                  t2w1rwt9,t2w1lwt9,t2h1uwt9,t2h1dwt9,
		  t2w1r10,t2w1l10,t2h1u10,t2h1d10,
                  t2w1rwt10,t2w1lwt10,t2h1uwt10,t2h1dwt10,

                  w1rwt3,w1lwt3,h1uwt3,h1dwt3,w2rwt3,w2lwt3,h2uwt3,h2dwt3,
                  pawr3,pawl3,pbwr3,pbwl3,pahu3,pahd3,pbhu3,pbhd3,
                  awl3,bwl3,awr3,bwr3,ahu3,bhu3,ahd3,bhd3,
                  awlwt3,bwlwt3,awrwt3,bwrwt3,ahuwt3,bhuwt3,ahdwt3,bhdwt3,
                  pawrwt3,pawlwt3,pbwrwt3,pbwlwt3,pahuwt3,pahdwt3,pbhuwt3,pbhdwt3,

                  a2wlwt3,b2wlwt3,a2wrwt3,b2wrwt3,a2huwt3,b2huwt3,a2hdwt3,b2hdwt3,
                  a2wl3,b2wl3,a2wr3,b2wr3,a2hu3,b2hu3,a2hd3,b2hd3,
                  mru13,mru23,nru13,nru23,mrd13,mrd23,nrd13,nrd23,mlu13,mlu23,nlu13,nlu23,mld13,mld23,nld13,nld23,
                  z0wr3,z0wl3,z0hu3,z0hd3,

                  p2parawr3,p2parawl3,p2parahu3,p2parahd3,
                  p2parawrwt3,p2parawlwt3,p2parahuwt3,p2parahdwt3,


                  riTable3, liTable3, uiTable3, diTable3,
                  roTable3, loTable3, uoTable3, doTable3,

                  w1rwt4,w1lwt4,h1uwt4,h1dwt4,w2rwt4,w2lwt4,h2uwt4,h2dwt4,
                  pawr4,pawl4,pbwr4,pbwl4,pahu4,pahd4,pbhu4,pbhd4,
                  awl4,bwl4,awr4,bwr4,ahu4,bhu4,ahd4,bhd4,
                  awlwt4,bwlwt4,awrwt4,bwrwt4,ahuwt4,bhuwt4,ahdwt4,bhdwt4,
                  pawrwt4,pawlwt4,pbwrwt4,pbwlwt4,pahuwt4,pahdwt4,pbhuwt4,pbhdwt4,

                  a2wlwt4,b2wlwt4,a2wrwt4,b2wrwt4,a2huwt4,b2huwt4,a2hdwt4,b2hdwt4,
                  a2wl4,b2wl4,a2wr4,b2wr4,a2hu4,b2hu4,a2hd4,b2hd4,
                  mru14,mru24,nru14,nru24,mrd14,mrd24,nrd14,nrd24,mlu14,mlu24,nlu14,nlu24,mld14,mld24,nld14,nld24,
                  z0wr4,z0wl4,z0hu4,z0hd4,


                  p2parawr4,p2parawl4,p2parahu4,p2parahd4,
                  p2parawrwt4,p2parawlwt4,p2parahuwt4,p2parahdwt4,


                  riTable4, liTable4, uiTable4, diTable4,
                  roTable4, loTable4, uoTable4, doTable4,

                  w1rwt5,w1lwt5,h1uwt5,h1dwt5,w2rwt5,w2lwt5,h2uwt5,h2dwt5,
                  pawr5,pawl5,pbwr5,pbwl5,pahu5,pahd5,pbhu5,pbhd5,
                  awl5,bwl5,awr5,bwr5,ahu5,bhu5,ahd5,bhd5,
                  awlwt5,bwlwt5,awrwt5,bwrwt5,ahuwt5,bhuwt5,ahdwt5,bhdwt5,
                  pawrwt5,pawlwt5,pbwrwt5,pbwlwt5,pahuwt5,pahdwt5,pbhuwt5,pbhdwt5,

                  a2wlwt5,b2wlwt5,a2wrwt5,b2wrwt5,a2huwt5,b2huwt5,a2hdwt5,b2hdwt5,
                  a2wl5,b2wl5,a2wr5,b2wr5,a2hu5,b2hu5,a2hd5,b2hd5,
                  mru15,mru25,nru15,nru25,mrd15,mrd25,nrd15,nrd25,mlu15,mlu25,nlu15,nlu25,mld15,mld25,nld15,nld25,
                  z0wr5,z0wl5,z0hu5,z0hd5,


                  p2parawr5,p2parawl5,p2parahu5,p2parahd5,
                  p2parawrwt5,p2parawlwt5,p2parahuwt5,p2parahdwt5,

                  riTable5, liTable5, uiTable5, diTable5,
                  roTable5, loTable5, uoTable5, doTable5,

                  w1rwt6,w1lwt6,h1uwt6,h1dwt6,w2rwt6,w2lwt6,h2uwt6,h2dwt6,
                  pawr6,pawl6,pbwr6,pbwl6,pahu6,pahd6,pbhu6,pbhd6,
                  awl6,bwl6,awr6,bwr6,ahu6,bhu6,ahd6,bhd6,
                  awlwt6,bwlwt6,awrwt6,bwrwt6,ahuwt6,bhuwt6,ahdwt6,bhdwt6,
                  pawrwt6,pawlwt6,pbwrwt6,pbwlwt6,pahuwt6,pahdwt6,pbhuwt6,pbhdwt6,

                  a2wlwt6,b2wlwt6,a2wrwt6,b2wrwt6,a2huwt6,b2huwt6,a2hdwt6,b2hdwt6,
                  a2wl6,b2wl6,a2wr6,b2wr6,a2hu6,b2hu6,a2hd6,b2hd6,
                  mru16,mru26,nru16,nru26,mrd16,mrd26,nrd16,nrd26,mlu16,mlu26,nlu16,nlu26,mld16,mld26,nld16,nld26,
                  z0wr6,z0wl6,z0hu6,z0hd6,


                  p2parawr6,p2parawl6,p2parahu6,p2parahd6,
                  p2parawrwt6,p2parawlwt6,p2parahuwt6,p2parahdwt6,


                  riTable6, liTable6, uiTable6, diTable6,
                  roTable6, loTable6, uoTable6, doTable6,

                  w1rwt7,w1lwt7,h1uwt7,h1dwt7,w2rwt7,w2lwt7,h2uwt7,h2dwt7,
                  pawr7,pawl7,pbwr7,pbwl7,pahu7,pahd7,pbhu7,pbhd7,
                  awl7,bwl7,awr7,bwr7,ahu7,bhu7,ahd7,bhd7,
                  awlwt7,bwlwt7,awrwt7,bwrwt7,ahuwt7,bhuwt7,ahdwt7,bhdwt7,
                  pawrwt7,pawlwt7,pbwrwt7,pbwlwt7,pahuwt7,pahdwt7,pbhuwt7,pbhdwt7,

                  a2wlwt7,b2wlwt7,a2wrwt7,b2wrwt7,a2huwt7,b2huwt7,a2hdwt7,b2hdwt7,
                  a2wl7,b2wl7,a2wr7,b2wr7,a2hu7,b2hu7,a2hd7,b2hd7,
                  mru17,mru27,nru17,nru27,mrd17,mrd27,nrd17,nrd27,mlu17,mlu27,nlu17,nlu27,mld17,mld27,nld17,nld27,
                  z0wr7,z0wl7,z0hu7,z0hd7,


                  p2parawr7,p2parawl7,p2parahu7,p2parahd7,
                  p2parawrwt7,p2parawlwt7,p2parahuwt7,p2parahdwt7,

                  riTable7, liTable7, uiTable7, diTable7,
                  roTable7, loTable7, uoTable7, doTable7,

                  w1rwt8,w1lwt8,h1uwt8,h1dwt8,w2rwt8,w2lwt8,h2uwt8,h2dwt8,
                  pawr8,pawl8,pbwr8,pbwl8,pahu8,pahd8,pbhu8,pbhd8,
                  awl8,bwl8,awr8,bwr8,ahu8,bhu8,ahd8,bhd8,
                  awlwt8,bwlwt8,awrwt8,bwrwt8,ahuwt8,bhuwt8,ahdwt8,bhdwt8,
                  pawrwt8,pawlwt8,pbwrwt8,pbwlwt8,pahuwt8,pahdwt8,pbhuwt8,pbhdwt8,

                  a2wlwt8,b2wlwt8,a2wrwt8,b2wrwt8,a2huwt8,b2huwt8,a2hdwt8,b2hdwt8,
                  a2wl8,b2wl8,a2wr8,b2wr8,a2hu8,b2hu8,a2hd8,b2hd8,
                  mru18,mru28,nru18,nru28,mrd18,mrd28,nrd18,nrd28,mlu18,mlu28,nlu18,nlu28,mld18,mld28,nld18,nld28,
                  z0wr8,z0wl8,z0hu8,z0hd8,


                  p2parawr8,p2parawl8,p2parahu8,p2parahd8,
                  p2parawrwt8,p2parawlwt8,p2parahuwt8,p2parahdwt8,


                  riTable8, liTable8, uiTable8, diTable8,
                  roTable8, loTable8, uoTable8, doTable8,

                  w1rwt9,w1lwt9,h1uwt9,h1dwt9,w2rwt9,w2lwt9,h2uwt9,h2dwt9,
                  pawr9,pawl9,pbwr9,pbwl9,pahu9,pahd9,pbhu9,pbhd9,
                  awl9,bwl9,awr9,bwr9,ahu9,bhu9,ahd9,bhd9,
                  awlwt9,bwlwt9,awrwt9,bwrwt9,ahuwt9,bhuwt9,ahdwt9,bhdwt9,
                  pawrwt9,pawlwt9,pbwrwt9,pbwlwt9,pahuwt9,pahdwt9,pbhuwt9,pbhdwt9,

                  a2wlwt9,b2wlwt9,a2wrwt9,b2wrwt9,a2huwt9,b2huwt9,a2hdwt9,b2hdwt9,
                  a2wl9,b2wl9,a2wr9,b2wr9,a2hu9,b2hu9,a2hd9,b2hd9,
                  mru19,mru29,nru19,nru29,mrd19,mrd29,nrd19,nrd29,mlu19,mlu29,nlu19,nlu29,mld19,mld29,nld19,nld29,
                  z0wr9,z0wl9,z0hu9,z0hd9,


                  p2parawr9,p2parawl9,p2parahu9,p2parahd9,
                  p2parawrwt9,p2parawlwt9,p2parahuwt9,p2parahdwt9,


                  riTable9, liTable9, uiTable9, diTable9,
                  roTable9, loTable9, uoTable9, doTable9,

                  w1rwt10,w1lwt10,h1uwt10,h1dwt10,w2rwt10,w2lwt10,h2uwt10,h2dwt10,
                  pawr10,pawl10,pbwr10,pbwl10,pahu10,pahd10,pbhu10,pbhd10,
                  awl10,bwl10,awr10,bwr10,ahu10,bhu10,ahd10,bhd10,
                  awlwt10,bwlwt10,awrwt10,bwrwt10,ahuwt10,bhuwt10,ahdwt10,bhdwt10,
                  pawrwt10,pawlwt10,pbwrwt10,pbwlwt10,pahuwt10,pahdwt10,pbhuwt10,pbhdwt10,

                  a2wlwt10,b2wlwt10,a2wrwt10,b2wrwt10,a2huwt10,b2huwt10,a2hdwt10,b2hdwt10,
                  a2wl10,b2wl10,a2wr10,b2wr10,a2hu10,b2hu10,a2hd10,b2hd10,
                  mru110,mru210,nru110,nru210,mrd110,mrd210,nrd110,nrd210,mlu110,mlu210,nlu110,nlu210,mld110,mld210,nld110,nld210,
                  z0wr10,z0wl10,z0hu10,z0hd10,


                  p2parawr10,p2parawl10,p2parahu10,p2parahd10,
                  p2parawrwt10,p2parawlwt10,p2parahuwt10,p2parahdwt10,


                  riTable10, liTable10, uiTable10, diTable10,
                  roTable10, loTable10, uoTable10, doTable10,

                  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;

  double t2w1r3,t2w1l3,t2h1u3,t2h1d3;
  double t2w1rwt3,t2w1lwt3,t2h1uwt3,t2h1dwt3;
  double t2w1r4,t2w1l4,t2h1u4,t2h1d4;
  double t2w1rwt4,t2w1lwt4,t2h1uwt4,t2h1dwt4;
  double t2w1r5,t2w1l5,t2h1u5,t2h1d5;
  double t2w1rwt5,t2w1lwt5,t2h1uwt5,t2h1dwt5;
  double t2w1r6,t2w1l6,t2h1u6,t2h1d6;
  double t2w1rwt6,t2w1lwt6,t2h1uwt6,t2h1dwt6;
  double t2w1r7,t2w1l7,t2h1u7,t2h1d7;
  double t2w1rwt7,t2w1lwt7,t2h1uwt7,t2h1dwt7;
  double t2w1r8,t2w1l8,t2h1u8,t2h1d8;
  double t2w1rwt8,t2w1lwt8,t2h1uwt8,t2h1dwt8;
  double t2w1r9,t2w1l9,t2h1u9,t2h1d9;
  double t2w1rwt9,t2w1lwt9,t2h1uwt9,t2h1dwt9;
  double t2w1r10,t2w1l10,t2h1u10,t2h1d10;
  double t2w1rwt10,t2w1lwt10,t2h1uwt10,t2h1dwt10;

  double w1rwt3,w1lwt3,h1uwt3,h1dwt3,w2rwt3,w2lwt3,h2uwt3,h2dwt3;
  double pawr3,pawl3,pbwr3,pbwl3,pahu3,pahd3,pbhu3,pbhd3;
  double awl3,bwl3,awr3,bwr3,ahu3,bhu3,ahd3,bhd3;
  double awlwt3,bwlwt3,awrwt3,bwrwt3,ahuwt3,bhuwt3,ahdwt3,bhdwt3;
  double pawrwt3,pawlwt3,pbwrwt3,pbwlwt3,pahuwt3,pahdwt3,pbhuwt3,pbhdwt3;

  double a2wlwt3,b2wlwt3,a2wrwt3,b2wrwt3,a2huwt3,b2huwt3,a2hdwt3,b2hdwt3;
  double a2wl3,b2wl3,a2wr3,b2wr3,a2hu3,b2hu3,a2hd3,b2hd3;
  double mru13,mru23,nru13,nru23,mrd13,mrd23,nrd13,nrd23,mlu13,mlu23,nlu13,nlu23,mld13,mld23,nld13,nld23;
  double z0wr3,z0wl3,z0hu3,z0hd3;


  double p2parawr3,p2parawl3,p2parahu3,p2parahd3;
  double p2parawrwt3,p2parawlwt3,p2parahuwt3,p2parahdwt3;

  t_Table riTable3,liTable3,uiTable3,diTable3;
  t_Table roTable3,loTable3,uoTable3,doTable3;

  double w1rwt4,w1lwt4,h1uwt4,h1dwt4,w2rwt4,w2lwt4,h2uwt4,h2dwt4;
  double pawr4,pawl4,pbwr4,pbwl4,pahu4,pahd4,pbhu4,pbhd4;
  double awl4,bwl4,awr4,bwr4,ahu4,bhu4,ahd4,bhd4;
  double awlwt4,bwlwt4,awrwt4,bwrwt4,ahuwt4,bhuwt4,ahdwt4,bhdwt4;
  double pawrwt4,pawlwt4,pbwrwt4,pbwlwt4,pahuwt4,pahdwt4,pbhuwt4,pbhdwt4;

  double a2wlwt4,b2wlwt4,a2wrwt4,b2wrwt4,a2huwt4,b2huwt4,a2hdwt4,b2hdwt4;
  double a2wl4,b2wl4,a2wr4,b2wr4,a2hu4,b2hu4,a2hd4,b2hd4;
  double mru14,mru24,nru14,nru24,mrd14,mrd24,nrd14,nrd24,mlu14,mlu24,nlu14,nlu24,mld14,mld24,nld14,nld24;
  double z0wr4,z0wl4,z0hu4,z0hd4;


  double p2parawr4,p2parawl4,p2parahu4,p2parahd4;
  double p2parawrwt4,p2parawlwt4,p2parahuwt4,p2parahdwt4;

  t_Table riTable4,liTable4,uiTable4,diTable4;
  t_Table roTable4,loTable4,uoTable4,doTable4;

  double w1rwt5,w1lwt5,h1uwt5,h1dwt5,w2rwt5,w2lwt5,h2uwt5,h2dwt5;
  double pawr5,pawl5,pbwr5,pbwl5,pahu5,pahd5,pbhu5,pbhd5;
  double awl5,bwl5,awr5,bwr5,ahu5,bhu5,ahd5,bhd5;
  double awlwt5,bwlwt5,awrwt5,bwrwt5,ahuwt5,bhuwt5,ahdwt5,bhdwt5;
  double pawrwt5,pawlwt5,pbwrwt5,pbwlwt5,pahuwt5,pahdwt5,pbhuwt5,pbhdwt5;

  double a2wlwt5,b2wlwt5,a2wrwt5,b2wrwt5,a2huwt5,b2huwt5,a2hdwt5,b2hdwt5;
  double a2wl5,b2wl5,a2wr5,b2wr5,a2hu5,b2hu5,a2hd5,b2hd5;
  double mru15,mru25,nru15,nru25,mrd15,mrd25,nrd15,nrd25,mlu15,mlu25,nlu15,nlu25,mld15,mld25,nld15,nld25;
  double z0wr5,z0wl5,z0hu5,z0hd5;


  double p2parawr5,p2parawl5,p2parahu5,p2parahd5;
  double p2parawrwt5,p2parawlwt5,p2parahuwt5,p2parahdwt5;

  t_Table riTable5,liTable5,uiTable5,diTable5;
  t_Table roTable5,loTable5,uoTable5,doTable5;

  double w1rwt6,w1lwt6,h1uwt6,h1dwt6,w2rwt6,w2lwt6,h2uwt6,h2dwt6;
  double pawr6,pawl6,pbwr6,pbwl6,pahu6,pahd6,pbhu6,pbhd6;
  double awl6,bwl6,awr6,bwr6,ahu6,bhu6,ahd6,bhd6;
  double awlwt6,bwlwt6,awrwt6,bwrwt6,ahuwt6,bhuwt6,ahdwt6,bhdwt6;
  double pawrwt6,pawlwt6,pbwrwt6,pbwlwt6,pahuwt6,pahdwt6,pbhuwt6,pbhdwt6;

  double a2wlwt6,b2wlwt6,a2wrwt6,b2wrwt6,a2huwt6,b2huwt6,a2hdwt6,b2hdwt6;
  double a2wl6,b2wl6,a2wr6,b2wr6,a2hu6,b2hu6,a2hd6,b2hd6;
  double mru16,mru26,nru16,nru26,mrd16,mrd26,nrd16,nrd26,mlu16,mlu26,nlu16,nlu26,mld16,mld26,nld16,nld26;
  double z0wr6,z0wl6,z0hu6,z0hd6;


  double p2parawr6,p2parawl6,p2parahu6,p2parahd6;
  double p2parawrwt6,p2parawlwt6,p2parahuwt6,p2parahdwt6;

  t_Table riTable6,liTable6,uiTable6,diTable6;
  t_Table roTable6,loTable6,uoTable6,doTable6;

  double w1rwt7,w1lwt7,h1uwt7,h1dwt7,w2rwt7,w2lwt7,h2uwt7,h2dwt7;
  double pawr7,pawl7,pbwr7,pbwl7,pahu7,pahd7,pbhu7,pbhd7;
  double awl7,bwl7,awr7,bwr7,ahu7,bhu7,ahd7,bhd7;
  double awlwt7,bwlwt7,awrwt7,bwrwt7,ahuwt7,bhuwt7,ahdwt7,bhdwt7;
  double pawrwt7,pawlwt7,pbwrwt7,pbwlwt7,pahuwt7,pahdwt7,pbhuwt7,pbhdwt7;

  double a2wlwt7,b2wlwt7,a2wrwt7,b2wrwt7,a2huwt7,b2huwt7,a2hdwt7,b2hdwt7;
  double a2wl7,b2wl7,a2wr7,b2wr7,a2hu7,b2hu7,a2hd7,b2hd7;
  double mru17,mru27,nru17,nru27,mrd17,mrd27,nrd17,nrd27,mlu17,mlu27,nlu17,nlu27,mld17,mld27,nld17,nld27;
  double z0wr7,z0wl7,z0hu7,z0hd7;

  double p2parawr7,p2parawl7,p2parahu7,p2parahd7;
  double p2parawrwt7,p2parawlwt7,p2parahuwt7,p2parahdwt7;

  t_Table riTable7,liTable7,uiTable7,diTable7;
  t_Table roTable7,loTable7,uoTable7,doTable7;

  double w1rwt8,w1lwt8,h1uwt8,h1dwt8,w2rwt8,w2lwt8,h2uwt8,h2dwt8;
  double pawr8,pawl8,pbwr8,pbwl8,pahu8,pahd8,pbhu8,pbhd8;
  double awl8,bwl8,awr8,bwr8,ahu8,bhu8,ahd8,bhd8;
  double awlwt8,bwlwt8,awrwt8,bwrwt8,ahuwt8,bhuwt8,ahdwt8,bhdwt8;
  double pawrwt8,pawlwt8,pbwrwt8,pbwlwt8,pahuwt8,pahdwt8,pbhuwt8,pbhdwt8;

  double a2wlwt8,b2wlwt8,a2wrwt8,b2wrwt8,a2huwt8,b2huwt8,a2hdwt8,b2hdwt8;
  double a2wl8,b2wl8,a2wr8,b2wr8,a2hu8,b2hu8,a2hd8,b2hd8;
  double mru18,mru28,nru18,nru28,mrd18,mrd28,nrd18,nrd28,mlu18,mlu28,nlu18,nlu28,mld18,mld28,nld18,nld28;
  double z0wr8,z0wl8,z0hu8,z0hd8;


  double p2parawr8,p2parawl8,p2parahu8,p2parahd8;
  double p2parawrwt8,p2parawlwt8,p2parahuwt8,p2parahdwt8;

  t_Table riTable8,liTable8,uiTable8,diTable8;
  t_Table roTable8,loTable8,uoTable8,doTable8;

  double w1rwt9,w1lwt9,h1uwt9,h1dwt9,w2rwt9,w2lwt9,h2uwt9,h2dwt9;
  double pawr9,pawl9,pbwr9,pbwl9,pahu9,pahd9,pbhu9,pbhd9;
  double awl9,bwl9,awr9,bwr9,ahu9,bhu9,ahd9,bhd9;
  double awlwt9,bwlwt9,awrwt9,bwrwt9,ahuwt9,bhuwt9,ahdwt9,bhdwt9;
  double pawrwt9,pawlwt9,pbwrwt9,pbwlwt9,pahuwt9,pahdwt9,pbhuwt9,pbhdwt9;

  double a2wlwt9,b2wlwt9,a2wrwt9,b2wrwt9,a2huwt9,b2huwt9,a2hdwt9,b2hdwt9;
  double a2wl9,b2wl9,a2wr9,b2wr9,a2hu9,b2hu9,a2hd9,b2hd9;
  double mru19,mru29,nru19,nru29,mrd19,mrd29,nrd19,nrd29,mlu19,mlu29,nlu19,nlu29,mld19,mld29,nld19,nld29;
  double z0wr9,z0wl9,z0hu9,z0hd9;


  double p2parawr9,p2parawl9,p2parahu9,p2parahd9;
  double p2parawrwt9,p2parawlwt9,p2parahuwt9,p2parahdwt9;


  t_Table riTable9,liTable9,uiTable9,diTable9;
  t_Table roTable9,loTable9,uoTable9,doTable9;

  double w1rwt10,w1lwt10,h1uwt10,h1dwt10,w2rwt10,w2lwt10,h2uwt10,h2dwt10;
  double pawr10,pawl10,pbwr10,pbwl10,pahu10,pahd10,pbhu10,pbhd10;
  double awl10,bwl10,awr10,bwr10,ahu10,bhu10,ahd10,bhd10;
  double awlwt10,bwlwt10,awrwt10,bwrwt10,ahuwt10,bhuwt10,ahdwt10,bhdwt10;
  double pawrwt10,pawlwt10,pbwrwt10,pbwlwt10,pahuwt10,pahdwt10,pbhuwt10,pbhdwt10;

  double a2wlwt10,b2wlwt10,a2wrwt10,b2wrwt10,a2huwt10,b2huwt10,a2hdwt10,b2hdwt10;
  double a2wl10,b2wl10,a2wr10,b2wr10,a2hu10,b2hu10,a2hd10,b2hd10;
  double mru110,mru210,nru110,nru210,mrd110,mrd210,nrd110,nrd210,mlu110,mlu210,nlu110,nlu210,mld110,mld210,nld110,nld210;
  double z0wr10,z0wl10,z0hu10,z0hd10;


  double p2parawr10,p2parawl10,p2parahu10,p2parahd10;
  double p2parawrwt10,p2parawlwt10,p2parahuwt10,p2parahdwt10;

  t_Table riTable10,liTable10,uiTable10,diTable10;
  t_Table roTable10,loTable10,uoTable10,doTable10;


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 (RIreflect3 && strlen(RIreflect3)) {
    if (Table_Read(&riTable3, RIreflect3, 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, RIreflect3));
  }

if (LIreflect3 && strlen(LIreflect3)) {
    if (Table_Read(&liTable3, LIreflect3, 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, LIreflect3));
  }

if (UIreflect3 && strlen(UIreflect3)) {
    if (Table_Read(&uiTable3, UIreflect3, 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, UIreflect3));
  }

if (DIreflect3 && strlen(DIreflect3)) {
    if (Table_Read(&diTable3, DIreflect3, 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, DIreflect3));
  }

if (ROreflect3 && strlen(ROreflect3)) {
    if (Table_Read(&roTable3, ROreflect3, 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, ROreflect3));
  }

if (LOreflect3 && strlen(LOreflect3)) {
    if (Table_Read(&loTable3, LOreflect3, 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, LOreflect3));
  }

if (UOreflect3 && strlen(UOreflect3)) {
    if (Table_Read(&uoTable3, UOreflect3, 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, UOreflect3));
  }

if (DOreflect3 && strlen(DOreflect3)) {
    if (Table_Read(&doTable3, DOreflect3, 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, DOreflect3));
  }

if (w1r3 < 0) TEST_INPUT("w1r3");

if (w1l3 < 0) TEST_INPUT("w1l3");

if (h1u3 < 0) TEST_INPUT("h1u3");

if (h1d3 < 0) TEST_INPUT("h1d3");

if (w2r3 < 0) TEST_INPUT("w2r3");

if (w2l3 < 0) TEST_INPUT("w2l3");

if (h2u3 < 0) TEST_INPUT("h2u3");

if (h2d3 < 0) TEST_INPUT("h2d3");

if (mxrOW3 !=-1 && mxrOW3 < 0) TEST_INPUT_1("mxrOW3");

if (mxlOW3 !=-1 && mxlOW3 < 0) TEST_INPUT_1("mxlOW3");

if (myuOW3 !=-1 && myuOW3 < 0) TEST_INPUT_1("myuOW3");

if (mydOW3 !=-1 && mydOW3 < 0) TEST_INPUT_1("mydOW3");

if (mxr3 < 0 && mxr3!=-1) TEST_INPUT_1("mxr3");

if (mxl3 < 0 && mxl3!=-1) TEST_INPUT_1("mxl3");

if (myu3 < 0 && myu3!=-1) TEST_INPUT_1("myu3");

if (myd3 < 0 && myd3!=-1) TEST_INPUT_1("myd3");

if (Qcxl3 < 0) TEST_INPUT_2("Qcxl3");

if (Qcxr3 < 0) TEST_INPUT_2("Qcxr3");

if (Qcyu3 < 0) TEST_INPUT_2("Qcyu3");

if (Qcyd3 < 0) TEST_INPUT_2("Qcyd3");

if (alphaxl3 < 0) TEST_INPUT_2("alphaxl3");

if (alphaxr3 < 0) TEST_INPUT_2("alphaxr3");

if (alphayu3 < 0) TEST_INPUT_2("alphayu3");

if (alphayd3 < 0) TEST_INPUT_2("alphayd3");

if (QcxlOW3 < 0) TEST_INPUT_2("QcxlOW3");

if (QcxrOW3 < 0) TEST_INPUT_2("QcxrOW3");

if (QcyuOW3 < 0) TEST_INPUT_2("QcyuOW3");

if (QcydOW3 < 0) TEST_INPUT_2("QcydOW3");

if (alphaxlOW3 < 0) TEST_INPUT_2("alphaxlOW3");

if (alphaxrOW3 < 0) TEST_INPUT_2("alphaxrOW3");

if (alphayuOW3 < 0) TEST_INPUT_2("alphayuOW3");

if (alphaydOW3 < 0) TEST_INPUT_2("alphaydOW3");

if (rwallthick3 < 0) TEST_INPUT_2("rwallthick3");

if (lwallthick3 < 0) TEST_INPUT_2("lwallthick3");

if (uwallthick3 < 0) TEST_INPUT_2("uwallthick3");

if (dwallthick3 < 0) TEST_INPUT_2("dwallthick3");


if (Wxr3 <=0) TEST_INPUT_3("Wxr3");

if (Wxl3 <=0) TEST_INPUT_3("Wxl3");

if (Wyu3 <=0) TEST_INPUT_3("Wyu3");

if (Wyd3 <=0) TEST_INPUT_3("Wyd3");

if (WxrOW3 <=0) TEST_INPUT_3("WxrOW3");

if (WxlOW3 <=0) TEST_INPUT_3("WxlOW3");

if (WyuOW3 <=0) TEST_INPUT_3("WyuOW3");

if (WydOW3 <=0) TEST_INPUT_3("WydOW3");

if (RIreflect4 && strlen(RIreflect4)) {
    if (Table_Read(&riTable4, RIreflect4, 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, RIreflect4));
  }

if (LIreflect4 && strlen(LIreflect4)) {
    if (Table_Read(&liTable4, LIreflect4, 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, LIreflect4));
  }

if (UIreflect4 && strlen(UIreflect4)) {
    if (Table_Read(&uiTable4, UIreflect4, 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, UIreflect4));
  }

if (DIreflect4 && strlen(DIreflect4)) {
    if (Table_Read(&diTable4, DIreflect4, 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, DIreflect4));
  }

if (ROreflect4 && strlen(ROreflect4)) {
    if (Table_Read(&roTable4, ROreflect4, 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, ROreflect4));
  }

if (LOreflect4 && strlen(LOreflect4)) {
    if (Table_Read(&loTable4, LOreflect4, 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, LOreflect4));
  }

if (UOreflect4 && strlen(UOreflect4)) {
    if (Table_Read(&uoTable4, UOreflect4, 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, UOreflect4));
  }

if (DOreflect4 && strlen(DOreflect4)) {
    if (Table_Read(&doTable4, DOreflect4, 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, DOreflect4));
  }

if (w1r4 < 0) TEST_INPUT("w1r4");

if (w1l4 < 0) TEST_INPUT("w1l4");

if (h1u4 < 0) TEST_INPUT("h1u4");

if (h1d4 < 0) TEST_INPUT("h1d4");

if (w2r4 < 0) TEST_INPUT("w2r4");

if (w2l4 < 0) TEST_INPUT("w2l4");

if (h2u4 < 0) TEST_INPUT("h2u4");

if (h2d4 < 0) TEST_INPUT("h2d4");

if (mxrOW4 !=-1 && mxrOW4 < 0) TEST_INPUT_1("mxrOW4");

if (mxlOW4 !=-1 && mxlOW4 < 0) TEST_INPUT_1("mxlOW4");

if (myuOW4 !=-1 && myuOW4 < 0) TEST_INPUT_1("myuOW4");

if (mydOW4 !=-1 && mydOW4 < 0) TEST_INPUT_1("mydOW4");

if (mxr4 < 0 && mxr4!=-1) TEST_INPUT_1("mxr4");

if (mxl4 < 0 && mxl4!=-1) TEST_INPUT_1("mxl4");

if (myu4 < 0 && myu4!=-1) TEST_INPUT_1("myu4");

if (myd4 < 0 && myd4!=-1) TEST_INPUT_1("myd4");

if (Qcxl4 < 0) TEST_INPUT_2("Qcxl4");

if (Qcxr4 < 0) TEST_INPUT_2("Qcxr4");

if (Qcyu4 < 0) TEST_INPUT_2("Qcyu4");

if (Qcyd4 < 0) TEST_INPUT_2("Qcyd4");

if (alphaxl4 < 0) TEST_INPUT_2("alphaxl4");

if (alphaxr4 < 0) TEST_INPUT_2("alphaxr4");

if (alphayu4 < 0) TEST_INPUT_2("alphayu4");

if (alphayd4 < 0) TEST_INPUT_2("alphayd4");

if (QcxlOW4 < 0) TEST_INPUT_2("QcxlOW4");

if (QcxrOW4 < 0) TEST_INPUT_2("QcxrOW4");

if (QcyuOW4 < 0) TEST_INPUT_2("QcyuOW4");

if (QcydOW4 < 0) TEST_INPUT_2("QcydOW4");

if (alphaxlOW4 < 0) TEST_INPUT_2("alphaxlOW4");

if (alphaxrOW4 < 0) TEST_INPUT_2("alphaxrOW4");

if (alphayuOW4 < 0) TEST_INPUT_2("alphayuOW4");

if (alphaydOW4 < 0) TEST_INPUT_2("alphaydOW4");

if (rwallthick4 < 0) TEST_INPUT_2("rwallthick4");

if (lwallthick4 < 0) TEST_INPUT_2("lwallthick4");

if (uwallthick4 < 0) TEST_INPUT_2("uwallthick4");

if (dwallthick4 < 0) TEST_INPUT_2("dwallthick4");


if (Wxr4 <=0) TEST_INPUT_3("Wxr4");

if (Wxl4 <=0) TEST_INPUT_3("Wxl4");

if (Wyu4 <=0) TEST_INPUT_3("Wyu4");

if (Wyd4 <=0) TEST_INPUT_3("Wyd4");

if (WxrOW4 <=0) TEST_INPUT_3("WxrOW4");

if (WxlOW4 <=0) TEST_INPUT_3("WxlOW4");

if (WyuOW4 <=0) TEST_INPUT_3("WyuOW4");

if (WydOW4 <=0) TEST_INPUT_3("WydOW4");

if (RIreflect5 && strlen(RIreflect5)) {
    if (Table_Read(&riTable5, RIreflect5, 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, RIreflect5));
  }

if (LIreflect5 && strlen(LIreflect5)) {
    if (Table_Read(&liTable5, LIreflect5, 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, LIreflect5));
  }

if (UIreflect5 && strlen(UIreflect5)) {
    if (Table_Read(&uiTable5, UIreflect5, 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, UIreflect5));
  }

if (DIreflect5 && strlen(DIreflect5)) {
    if (Table_Read(&diTable5, DIreflect5, 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, DIreflect5));
  }

if (ROreflect5 && strlen(ROreflect5)) {
    if (Table_Read(&roTable5, ROreflect5, 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, ROreflect5));
  }

if (LOreflect5 && strlen(LOreflect5)) {
    if (Table_Read(&loTable5, LOreflect5, 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, LOreflect5));
  }

if (UOreflect5 && strlen(UOreflect5)) {
    if (Table_Read(&uoTable5, UOreflect5, 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, UOreflect5));
  }

if (DOreflect5 && strlen(DOreflect5)) {
    if (Table_Read(&doTable5, DOreflect5, 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, DOreflect5));
  }

if (w1r5 < 0) TEST_INPUT("w1r5");

if (w1l5 < 0) TEST_INPUT("w1l5");

if (h1u5 < 0) TEST_INPUT("h1u5");

if (h1d5 < 0) TEST_INPUT("h1d5");

if (w2r5 < 0) TEST_INPUT("w2r5");

if (w2l5 < 0) TEST_INPUT("w2l5");

if (h2u5 < 0) TEST_INPUT("h2u5");

if (h2d5 < 0) TEST_INPUT("h2d5");

if (mxrOW5 !=-1 && mxrOW5 < 0) TEST_INPUT_1("mxrOW5");

if (mxlOW5 !=-1 && mxlOW5 < 0) TEST_INPUT_1("mxlOW5");

if (myuOW5 !=-1 && myuOW5 < 0) TEST_INPUT_1("myuOW5");

if (mydOW5 !=-1 && mydOW5 < 0) TEST_INPUT_1("mydOW5");

if (mxr5 < 0 && mxr5!=-1) TEST_INPUT_1("mxr5");

if (mxl5 < 0 && mxl5!=-1) TEST_INPUT_1("mxl5");

if (myu5 < 0 && myu5!=-1) TEST_INPUT_1("myu5");

if (myd5 < 0 && myd5!=-1) TEST_INPUT_1("myd5");

if (Qcxl5 < 0) TEST_INPUT_2("Qcxl5");

if (Qcxr5 < 0) TEST_INPUT_2("Qcxr5");

if (Qcyu5 < 0) TEST_INPUT_2("Qcyu5");

if (Qcyd5 < 0) TEST_INPUT_2("Qcyd5");

if (alphaxl5 < 0) TEST_INPUT_2("alphaxl5");

if (alphaxr5 < 0) TEST_INPUT_2("alphaxr5");

if (alphayu5 < 0) TEST_INPUT_2("alphayu5");

if (alphayd5 < 0) TEST_INPUT_2("alphayd5");

if (QcxlOW5 < 0) TEST_INPUT_2("QcxlOW5");

if (QcxrOW5 < 0) TEST_INPUT_2("QcxrOW5");

if (QcyuOW5 < 0) TEST_INPUT_2("QcyuOW5");

if (QcydOW5 < 0) TEST_INPUT_2("QcydOW5");

if (alphaxlOW5 < 0) TEST_INPUT_2("alphaxlOW5");

if (alphaxrOW5 < 0) TEST_INPUT_2("alphaxrOW5");

if (alphayuOW5 < 0) TEST_INPUT_2("alphayuOW5");

if (alphaydOW5 < 0) TEST_INPUT_2("alphaydOW5");

if (rwallthick5 < 0) TEST_INPUT_2("rwallthick5");

if (lwallthick5 < 0) TEST_INPUT_2("lwallthick5");

if (uwallthick5 < 0) TEST_INPUT_2("uwallthick5");

if (dwallthick5 < 0) TEST_INPUT_2("dwallthick5");


if (Wxr5 <=0) TEST_INPUT_3("Wxr5");

if (Wxl5 <=0) TEST_INPUT_3("Wxl5");

if (Wyu5 <=0) TEST_INPUT_3("Wyu5");

if (Wyd5 <=0) TEST_INPUT_3("Wyd5");

if (WxrOW5 <=0) TEST_INPUT_3("WxrOW5");

if (WxlOW5 <=0) TEST_INPUT_3("WxlOW5");

if (WyuOW5 <=0) TEST_INPUT_3("WyuOW5");

if (WydOW5 <=0) TEST_INPUT_3("WydOW5");

if (RIreflect6 && strlen(RIreflect6)) {
    if (Table_Read(&riTable6, RIreflect6, 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, RIreflect6));
  }

if (LIreflect6 && strlen(LIreflect6)) {
    if (Table_Read(&liTable6, LIreflect6, 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, LIreflect6));
  }

if (UIreflect6 && strlen(UIreflect6)) {
    if (Table_Read(&uiTable6, UIreflect6, 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, UIreflect6));
  }

if (DIreflect6 && strlen(DIreflect6)) {
    if (Table_Read(&diTable6, DIreflect6, 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, DIreflect6));
  }

if (ROreflect6 && strlen(ROreflect6)) {
    if (Table_Read(&roTable6, ROreflect6, 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, ROreflect6));
  }

if (LOreflect6 && strlen(LOreflect6)) {
    if (Table_Read(&loTable6, LOreflect6, 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, LOreflect6));
  }

if (UOreflect6 && strlen(UOreflect6)) {
    if (Table_Read(&uoTable6, UOreflect6, 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, UOreflect6));
  }

if (DOreflect6 && strlen(DOreflect6)) {
    if (Table_Read(&doTable6, DOreflect6, 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, DOreflect6));
  }

if (w1r6 < 0) TEST_INPUT("w1r6");

if (w1l6 < 0) TEST_INPUT("w1l6");

if (h1u6 < 0) TEST_INPUT("h1u6");

if (h1d6 < 0) TEST_INPUT("h1d6");

if (w2r6 < 0) TEST_INPUT("w2r6");

if (w2l6 < 0) TEST_INPUT("w2l6");

if (h2u6 < 0) TEST_INPUT("h2u6");

if (h2d6 < 0) TEST_INPUT("h2d6");

if (mxrOW6 !=-1 && mxrOW6 < 0) TEST_INPUT_1("mxrOW6");

if (mxlOW6 !=-1 && mxlOW6 < 0) TEST_INPUT_1("mxlOW6");

if (myuOW6 !=-1 && myuOW6 < 0) TEST_INPUT_1("myuOW6");

if (mydOW6 !=-1 && mydOW6 < 0) TEST_INPUT_1("mydOW6");

if (mxr6 < 0 && mxr6!=-1) TEST_INPUT_1("mxr6");

if (mxl6 < 0 && mxl6!=-1) TEST_INPUT_1("mxl6");

if (myu6 < 0 && myu6!=-1) TEST_INPUT_1("myu6");

if (myd6 < 0 && myd6!=-1) TEST_INPUT_1("myd6");

if (Qcxl6 < 0) TEST_INPUT_2("Qcxl6");

if (Qcxr6 < 0) TEST_INPUT_2("Qcxr6");

if (Qcyu6 < 0) TEST_INPUT_2("Qcyu6");

if (Qcyd6 < 0) TEST_INPUT_2("Qcyd6");

if (alphaxl6 < 0) TEST_INPUT_2("alphaxl6");

if (alphaxr6 < 0) TEST_INPUT_2("alphaxr6");

if (alphayu6 < 0) TEST_INPUT_2("alphayu6");

if (alphayd6 < 0) TEST_INPUT_2("alphayd6");

if (QcxlOW6 < 0) TEST_INPUT_2("QcxlOW6");

if (QcxrOW6 < 0) TEST_INPUT_2("QcxrOW6");

if (QcyuOW6 < 0) TEST_INPUT_2("QcyuOW6");

if (QcydOW6 < 0) TEST_INPUT_2("QcydOW6");

if (alphaxlOW6 < 0) TEST_INPUT_2("alphaxlOW6");

if (alphaxrOW6 < 0) TEST_INPUT_2("alphaxrOW6");

if (alphayuOW6 < 0) TEST_INPUT_2("alphayuOW6");

if (alphaydOW6 < 0) TEST_INPUT_2("alphaydOW6");

if (rwallthick6 < 0) TEST_INPUT_2("rwallthick6");

if (lwallthick6 < 0) TEST_INPUT_2("lwallthick6");

if (uwallthick6 < 0) TEST_INPUT_2("uwallthick6");

if (dwallthick6 < 0) TEST_INPUT_2("dwallthick6");


if (Wxr6 <=0) TEST_INPUT_3("Wxr6");

if (Wxl6 <=0) TEST_INPUT_3("Wxl6");

if (Wyu6 <=0) TEST_INPUT_3("Wyu6");

if (Wyd6 <=0) TEST_INPUT_3("Wyd6");

if (WxrOW6 <=0) TEST_INPUT_3("WxrOW6");

if (WxlOW6 <=0) TEST_INPUT_3("WxlOW6");

if (WyuOW6 <=0) TEST_INPUT_3("WyuOW6");

if (WydOW6 <=0) TEST_INPUT_3("WydOW6");


if (RIreflect7 && strlen(RIreflect7)) {
    if (Table_Read(&riTable7, RIreflect7, 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, RIreflect7));
  }

if (LIreflect7 && strlen(LIreflect7)) {
    if (Table_Read(&liTable7, LIreflect7, 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, LIreflect7));
  }

if (UIreflect7 && strlen(UIreflect7)) {
    if (Table_Read(&uiTable7, UIreflect7, 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, UIreflect7));
  }

if (DIreflect7 && strlen(DIreflect7)) {
    if (Table_Read(&diTable7, DIreflect7, 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, DIreflect7));
  }

if (ROreflect7 && strlen(ROreflect7)) {
    if (Table_Read(&roTable7, ROreflect7, 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, ROreflect7));
  }

if (LOreflect7 && strlen(LOreflect7)) {
    if (Table_Read(&loTable7, LOreflect7, 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, LOreflect7));
  }

if (UOreflect7 && strlen(UOreflect7)) {
    if (Table_Read(&uoTable7, UOreflect7, 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, UOreflect7));
  }

if (DOreflect7 && strlen(DOreflect7)) {
    if (Table_Read(&doTable7, DOreflect7, 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, DOreflect7));
  }

if (w1r7 < 0) TEST_INPUT("w1r7");

if (w1l7 < 0) TEST_INPUT("w1l7");

if (h1u7 < 0) TEST_INPUT("h1u7");

if (h1d7 < 0) TEST_INPUT("h1d7");

if (w2r7 < 0) TEST_INPUT("w2r7");

if (w2l7 < 0) TEST_INPUT("w2l7");

if (h2u7 < 0) TEST_INPUT("h2u7");

if (h2d7 < 0) TEST_INPUT("h2d7");

if (mxrOW7 !=-1 && mxrOW7 < 0) TEST_INPUT_1("mxrOW7");

if (mxlOW7 !=-1 && mxlOW7 < 0) TEST_INPUT_1("mxlOW7");

if (myuOW7 !=-1 && myuOW7 < 0) TEST_INPUT_1("myuOW7");

if (mydOW7 !=-1 && mydOW7 < 0) TEST_INPUT_1("mydOW7");

if (mxr7 < 0 && mxr7!=-1) TEST_INPUT_1("mxr7");

if (mxl7 < 0 && mxl7!=-1) TEST_INPUT_1("mxl7");

if (myu7 < 0 && myu7!=-1) TEST_INPUT_1("myu7");

if (myd7 < 0 && myd7!=-1) TEST_INPUT_1("myd7");

if (Qcxl7 < 0) TEST_INPUT_2("Qcxl7");

if (Qcxr7 < 0) TEST_INPUT_2("Qcxr7");

if (Qcyu7 < 0) TEST_INPUT_2("Qcyu7");

if (Qcyd7 < 0) TEST_INPUT_2("Qcyd7");

if (alphaxl7 < 0) TEST_INPUT_2("alphaxl7");

if (alphaxr7 < 0) TEST_INPUT_2("alphaxr7");

if (alphayu7 < 0) TEST_INPUT_2("alphayu7");

if (alphayd7 < 0) TEST_INPUT_2("alphayd7");

if (QcxlOW7 < 0) TEST_INPUT_2("QcxlOW7");

if (QcxrOW7 < 0) TEST_INPUT_2("QcxrOW7");

if (QcyuOW7 < 0) TEST_INPUT_2("QcyuOW7");

if (QcydOW7 < 0) TEST_INPUT_2("QcydOW7");

if (alphaxlOW7 < 0) TEST_INPUT_2("alphaxlOW7");

if (alphaxrOW7 < 0) TEST_INPUT_2("alphaxrOW7");

if (alphayuOW7 < 0) TEST_INPUT_2("alphayuOW7");

if (alphaydOW7 < 0) TEST_INPUT_2("alphaydOW7");

if (rwallthick7 < 0) TEST_INPUT_2("rwallthick7");

if (lwallthick7 < 0) TEST_INPUT_2("lwallthick7");

if (uwallthick7 < 0) TEST_INPUT_2("uwallthick7");

if (dwallthick7 < 0) TEST_INPUT_2("dwallthick7");


if (Wxr7 <=0) TEST_INPUT_3("Wxr7");

if (Wxl7 <=0) TEST_INPUT_3("Wxl7");

if (Wyu7 <=0) TEST_INPUT_3("Wyu7");

if (Wyd7 <=0) TEST_INPUT_3("Wyd7");

if (WxrOW7 <=0) TEST_INPUT_3("WxrOW7");

if (WxlOW7 <=0) TEST_INPUT_3("WxlOW7");

if (WyuOW7 <=0) TEST_INPUT_3("WyuOW7");

if (WydOW7 <=0) TEST_INPUT_3("WydOW7");


if (RIreflect8 && strlen(RIreflect8)) {
    if (Table_Read(&riTable8, RIreflect8, 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, RIreflect8));
  }

if (LIreflect8 && strlen(LIreflect8)) {
    if (Table_Read(&liTable8, LIreflect8, 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, LIreflect8));
  }

if (UIreflect8 && strlen(UIreflect8)) {
    if (Table_Read(&uiTable8, UIreflect8, 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, UIreflect8));
  }

if (DIreflect8 && strlen(DIreflect8)) {
    if (Table_Read(&diTable8, DIreflect8, 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, DIreflect8));
  }

if (ROreflect8 && strlen(ROreflect8)) {
    if (Table_Read(&roTable8, ROreflect8, 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, ROreflect8));
  }

if (LOreflect8 && strlen(LOreflect8)) {
    if (Table_Read(&loTable8, LOreflect8, 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, LOreflect8));
  }

if (UOreflect8 && strlen(UOreflect8)) {
    if (Table_Read(&uoTable8, UOreflect8, 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, UOreflect8));
  }

if (DOreflect8 && strlen(DOreflect8)) {
    if (Table_Read(&doTable8, DOreflect8, 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, DOreflect8));
  }

if (w1r8 < 0) TEST_INPUT("w1r8");

if (w1l8 < 0) TEST_INPUT("w1l8");

if (h1u8 < 0) TEST_INPUT("h1u8");

if (h1d8 < 0) TEST_INPUT("h1d8");

if (w2r8 < 0) TEST_INPUT("w2r8");

if (w2l8 < 0) TEST_INPUT("w2l8");

if (h2u8 < 0) TEST_INPUT("h2u8");

if (h2d8 < 0) TEST_INPUT("h2d8");

if (mxrOW8 !=-1 && mxrOW8 < 0) TEST_INPUT_1("mxrOW8");

if (mxlOW8 !=-1 && mxlOW8 < 0) TEST_INPUT_1("mxlOW8");

if (myuOW8 !=-1 && myuOW8 < 0) TEST_INPUT_1("myuOW8");

if (mydOW8 !=-1 && mydOW8 < 0) TEST_INPUT_1("mydOW8");

if (mxr8 < 0 && mxr8!=-1) TEST_INPUT_1("mxr8");

if (mxl8 < 0 && mxl8!=-1) TEST_INPUT_1("mxl8");

if (myu8 < 0 && myu8!=-1) TEST_INPUT_1("myu8");

if (myd8 < 0 && myd8!=-1) TEST_INPUT_1("myd8");

if (Qcxl8 < 0) TEST_INPUT_2("Qcxl8");

if (Qcxr8 < 0) TEST_INPUT_2("Qcxr8");

if (Qcyu8 < 0) TEST_INPUT_2("Qcyu8");

if (Qcyd8 < 0) TEST_INPUT_2("Qcyd8");

if (alphaxl8 < 0) TEST_INPUT_2("alphaxl8");

if (alphaxr8 < 0) TEST_INPUT_2("alphaxr8");

if (alphayu8 < 0) TEST_INPUT_2("alphayu8");

if (alphayd8 < 0) TEST_INPUT_2("alphayd8");

if (QcxlOW8 < 0) TEST_INPUT_2("QcxlOW8");

if (QcxrOW8 < 0) TEST_INPUT_2("QcxrOW8");

if (QcyuOW8 < 0) TEST_INPUT_2("QcyuOW8");

if (QcydOW8 < 0) TEST_INPUT_2("QcydOW8");

if (alphaxlOW8 < 0) TEST_INPUT_2("alphaxlOW8");

if (alphaxrOW8 < 0) TEST_INPUT_2("alphaxrOW8");

if (alphayuOW8 < 0) TEST_INPUT_2("alphayuOW8");

if (alphaydOW8 < 0) TEST_INPUT_2("alphaydOW8");

if (rwallthick8 < 0) TEST_INPUT_2("rwallthick8");

if (lwallthick8 < 0) TEST_INPUT_2("lwallthick8");

if (uwallthick8 < 0) TEST_INPUT_2("uwallthick8");

if (dwallthick8 < 0) TEST_INPUT_2("dwallthick8");


if (Wxr8 <=0) TEST_INPUT_3("Wxr8");

if (Wxl8 <=0) TEST_INPUT_3("Wxl8");

if (Wyu8 <=0) TEST_INPUT_3("Wyu8");

if (Wyd8 <=0) TEST_INPUT_3("Wyd8");

if (WxrOW8 <=0) TEST_INPUT_3("WxrOW8");

if (WxlOW8 <=0) TEST_INPUT_3("WxlOW8");

if (WyuOW8 <=0) TEST_INPUT_3("WyuOW8");

if (WydOW8 <=0) TEST_INPUT_3("WydOW8");


if (RIreflect9 && strlen(RIreflect9)) {
    if (Table_Read(&riTable9, RIreflect9, 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, RIreflect9));
  }

if (LIreflect9 && strlen(LIreflect9)) {
    if (Table_Read(&liTable9, LIreflect9, 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, LIreflect9));
  }

if (UIreflect9 && strlen(UIreflect9)) {
    if (Table_Read(&uiTable9, UIreflect9, 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, UIreflect9));
  }

if (DIreflect9 && strlen(DIreflect9)) {
    if (Table_Read(&diTable9, DIreflect9, 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, DIreflect9));
  }

if (ROreflect9 && strlen(ROreflect9)) {
    if (Table_Read(&roTable9, ROreflect9, 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, ROreflect9));
  }

if (LOreflect9 && strlen(LOreflect9)) {
    if (Table_Read(&loTable9, LOreflect9, 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, LOreflect9));
  }

if (UOreflect9 && strlen(UOreflect9)) {
    if (Table_Read(&uoTable9, UOreflect9, 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, UOreflect9));
  }

if (DOreflect9 && strlen(DOreflect9)) {
    if (Table_Read(&doTable9, DOreflect9, 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, DOreflect9));
  }

if (w1r9 < 0) TEST_INPUT("w1r9");

if (w1l9 < 0) TEST_INPUT("w1l9");

if (h1u9 < 0) TEST_INPUT("h1u9");

if (h1d9 < 0) TEST_INPUT("h1d9");

if (w2r9 < 0) TEST_INPUT("w2r9");

if (w2l9 < 0) TEST_INPUT("w2l9");

if (h2u9 < 0) TEST_INPUT("h2u9");

if (h2d9 < 0) TEST_INPUT("h2d9");

if (mxrOW9 !=-1 && mxrOW9 < 0) TEST_INPUT_1("mxrOW9");

if (mxlOW9 !=-1 && mxlOW9 < 0) TEST_INPUT_1("mxlOW9");

if (myuOW9 !=-1 && myuOW9 < 0) TEST_INPUT_1("myuOW9");

if (mydOW9 !=-1 && mydOW9 < 0) TEST_INPUT_1("mydOW9");

if (mxr9 < 0 && mxr9!=-1) TEST_INPUT_1("mxr9");

if (mxl9 < 0 && mxl9!=-1) TEST_INPUT_1("mxl9");

if (myu9 < 0 && myu9!=-1) TEST_INPUT_1("myu9");

if (myd9 < 0 && myd9!=-1) TEST_INPUT_1("myd9");

if (Qcxl9 < 0) TEST_INPUT_2("Qcxl9");

if (Qcxr9 < 0) TEST_INPUT_2("Qcxr9");

if (Qcyu9 < 0) TEST_INPUT_2("Qcyu9");

if (Qcyd9 < 0) TEST_INPUT_2("Qcyd9");

if (alphaxl9 < 0) TEST_INPUT_2("alphaxl9");

if (alphaxr9 < 0) TEST_INPUT_2("alphaxr9");

if (alphayu9 < 0) TEST_INPUT_2("alphayu9");

if (alphayd9 < 0) TEST_INPUT_2("alphayd9");

if (QcxlOW9 < 0) TEST_INPUT_2("QcxlOW9");

if (QcxrOW9 < 0) TEST_INPUT_2("QcxrOW9");

if (QcyuOW9 < 0) TEST_INPUT_2("QcyuOW9");

if (QcydOW9 < 0) TEST_INPUT_2("QcydOW9");

if (alphaxlOW9 < 0) TEST_INPUT_2("alphaxlOW9");

if (alphaxrOW9 < 0) TEST_INPUT_2("alphaxrOW9");

if (alphayuOW9 < 0) TEST_INPUT_2("alphayuOW9");

if (alphaydOW9 < 0) TEST_INPUT_2("alphaydOW9");

if (rwallthick9 < 0) TEST_INPUT_2("rwallthick9");

if (lwallthick9 < 0) TEST_INPUT_2("lwallthick9");

if (uwallthick9 < 0) TEST_INPUT_2("uwallthick9");

if (dwallthick9 < 0) TEST_INPUT_2("dwallthick9");


if (Wxr9 <=0) TEST_INPUT_3("Wxr9");

if (Wxl9 <=0) TEST_INPUT_3("Wxl9");

if (Wyu9 <=0) TEST_INPUT_3("Wyu9");

if (Wyd9 <=0) TEST_INPUT_3("Wyd9");

if (WxrOW9 <=0) TEST_INPUT_3("WxrOW9");

if (WxlOW9 <=0) TEST_INPUT_3("WxlOW9");

if (WyuOW9 <=0) TEST_INPUT_3("WyuOW9");

if (WydOW9 <=0) TEST_INPUT_3("WydOW9");

if (RIreflect10 && strlen(RIreflect10)) {
    if (Table_Read(&riTable10, RIreflect10, 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, RIreflect10));
  }

if (LIreflect10 && strlen(LIreflect10)) {
    if (Table_Read(&liTable10, LIreflect10, 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, LIreflect10));
  }

if (UIreflect10 && strlen(UIreflect10)) {
    if (Table_Read(&uiTable10, UIreflect10, 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, UIreflect10));
  }

if (DIreflect10 && strlen(DIreflect10)) {
    if (Table_Read(&diTable10, DIreflect10, 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, DIreflect10));
  }

if (ROreflect10 && strlen(ROreflect10)) {
    if (Table_Read(&roTable10, ROreflect10, 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, ROreflect10));
  }

if (LOreflect10 && strlen(LOreflect10)) {
    if (Table_Read(&loTable10, LOreflect10, 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, LOreflect10));
  }

if (UOreflect10 && strlen(UOreflect10)) {
    if (Table_Read(&uoTable10, UOreflect10, 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, UOreflect10));
  }

if (DOreflect10 && strlen(DOreflect10)) {
    if (Table_Read(&doTable10, DOreflect10, 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, DOreflect10));
  }

if (w1r10 < 0) TEST_INPUT("w1r10");

if (w1l10 < 0) TEST_INPUT("w1l10");

if (h1u10 < 0) TEST_INPUT("h1u10");

if (h1d10 < 0) TEST_INPUT("h1d10");

if (w2r10 < 0) TEST_INPUT("w2r10");

if (w2l10 < 0) TEST_INPUT("w2l10");

if (h2u10 < 0) TEST_INPUT("h2u10");

if (h2d10 < 0) TEST_INPUT("h2d10");

if (mxrOW10 !=-1 && mxrOW10 < 0) TEST_INPUT_1("mxrOW10");

if (mxlOW10 !=-1 && mxlOW10 < 0) TEST_INPUT_1("mxlOW10");

if (myuOW10 !=-1 && myuOW10 < 0) TEST_INPUT_1("myuOW10");

if (mydOW10 !=-1 && mydOW10 < 0) TEST_INPUT_1("mydOW10");

if (mxr10 < 0 && mxr10!=-1) TEST_INPUT_1("mxr10");

if (mxl10 < 0 && mxl10!=-1) TEST_INPUT_1("mxl10");

if (myu10 < 0 && myu10!=-1) TEST_INPUT_1("myu10");

if (myd10 < 0 && myd10!=-1) TEST_INPUT_1("myd10");

if (Qcxl10 < 0) TEST_INPUT_2("Qcxl10");

if (Qcxr10 < 0) TEST_INPUT_2("Qcxr10");

if (Qcyu10 < 0) TEST_INPUT_2("Qcyu10");

if (Qcyd10 < 0) TEST_INPUT_2("Qcyd10");

if (alphaxl10 < 0) TEST_INPUT_2("alphaxl10");

if (alphaxr10 < 0) TEST_INPUT_2("alphaxr10");

if (alphayu10 < 0) TEST_INPUT_2("alphayu10");

if (alphayd10 < 0) TEST_INPUT_2("alphayd10");

if (QcxlOW10 < 0) TEST_INPUT_2("QcxlOW10");

if (QcxrOW10 < 0) TEST_INPUT_2("QcxrOW10");

if (QcyuOW10 < 0) TEST_INPUT_2("QcyuOW10");

if (QcydOW10 < 0) TEST_INPUT_2("QcydOW10");

if (alphaxlOW10 < 0) TEST_INPUT_2("alphaxlOW10");

if (alphaxrOW10 < 0) TEST_INPUT_2("alphaxrOW10");

if (alphayuOW10 < 0) TEST_INPUT_2("alphayuOW10");

if (alphaydOW10 < 0) TEST_INPUT_2("alphaydOW10");

if (rwallthick10 < 0) TEST_INPUT_2("rwallthick10");

if (lwallthick10 < 0) TEST_INPUT_2("lwallthick10");

if (uwallthick10 < 0) TEST_INPUT_2("uwallthick10");

if (dwallthick10 < 0) TEST_INPUT_2("dwallthick10");


if (Wxr10 <=0) TEST_INPUT_3("Wxr10");

if (Wxl10 <=0) TEST_INPUT_3("Wxl10");

if (Wyu10 <=0) TEST_INPUT_3("Wyu10");

if (Wyd10 <=0) TEST_INPUT_3("Wyd10");

if (WxrOW10 <=0) TEST_INPUT_3("WxrOW10");

if (WxlOW10 <=0) TEST_INPUT_3("WxlOW10");

if (WyuOW10 <=0) TEST_INPUT_3("WyuOW10");

if (WydOW10 <=0) TEST_INPUT_3("WydOW10");


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 bottom wall */
    {
      ELLIPSE(h1d2, l, linhd2, louthd2, dwallthick2, &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);

/* THIRED SHELL  */


if(loutwr3!=0 && linwr3!=0)										/* elliptic right side wall */
   { 
     ELLIPSE(w1r3, l, linwr3, loutwr3, rwallthick3, &awr3, &bwr3, &a2wr3, &b2wr3, &z0wr3, &w2r3, &awrwt3, &a2wrwt3, &bwrwt3, &b2wrwt3, &w2rwt3, &w1rwt3);
   }


if(linwr3==0 && loutwr3!=0)										/* parabolic focusing right side wall */
   {
     PARABEL_FOCUS( w1r3,l ,loutwr3, rwallthick3, &p2parawr3, &w2r3, &pbwr3 , &pawr3, &p2parawrwt3, &pbwrwt3, &pawrwt3, &w2rwt3, &w1rwt3);
   }

if (linwr3!=0 && loutwr3==0)										/* parabolic defocusing right side wall  */
    {
      PARABEL_DEFOCUS( w1r3,l ,linwr3, rwallthick3, &p2parawr3, &w2r3, &pbwr3 , &pawr3, &p2parawrwt3, &pbwrwt3, &pawrwt3, &w2rwt3, &w1rwt3);
    }

if(linwr3==0 && loutwr3==0)										/* straight right side wall */
    {
      LINEAR(w1r3, w2r3, l, rwallthick3, &w1rwt3, &w2rwt3);
    }


													/* Calculation of curve-parameters for the left side wall - positive x-axis - analog to right side*/

if((linwl3!=0) && (loutwl3!=0) ) 										/* elleptic left side wall */
  { 
    ELLIPSE(w1l3, l, linwl3, loutwl3, lwallthick3, &awl3, &bwl3, &a2wl3, &b2wl3, &z0wl3, &w2l3, &awlwt3, &a2wlwt3, &bwlwt3, &b2wlwt3, &w2lwt3, &w1lwt3);
   }

if(linwl3==0 && loutwl3!=0)										/* parabolic focusing left side wall */
   {
     PARABEL_FOCUS( w1l3,l ,loutwl3, lwallthick3, &p2parawl3, &w2l3, &pbwl3 , &pawl3, &p2parawlwt3, &pbwlwt3, &pawlwt3, &w2lwt3, &w1lwt3);
   }

if (linwl3!=0 && loutwl3==0)										/* parabolic defocusing left side wall  */
    {
      PARABEL_DEFOCUS( w1l3,l ,linwl3, lwallthick3, &p2parawl3, &w2l3, &pbwl3 , &pawl3, &p2parawlwt3, &pbwlwt3, &pawlwt3, &w2lwt3, &w1lwt3);
    }

if(linwl3==0 && loutwl3==0)										/* straight left side wall */
    {
      LINEAR(w1l3, w2l3, l, lwallthick3, &w1lwt3, &w2lwt3);
    }


													/* Calculation of curve-parameters for the top wall - positive y-axis - analog  right wall*/


if (linhu3 != 0 && louthu3 !=0)										/* elliptic top wall */
    {
      ELLIPSE(h1u3, l, linhu3, louthu3, uwallthick3, &ahu3, &bhu3, &a2hu3, &b2hu3, &z0hu3 , &h2u3, &ahuwt3, &a2huwt3, &bhuwt3, &b2huwt3, &h2uwt3, &h1uwt3); 
    }

if(linhu3==0 && louthu3!=0)										/* parabolic focusing top wall */
    { 	
      PARABEL_FOCUS( h1u3,l ,louthu3, uwallthick3, &p2parahu3, &h2u3, &pbhu3 , &pahu3, &p2parahuwt3, &pbhuwt3, &pahuwt3, &h2uwt3, &h1uwt3);
    } 

if (linhu3!=0 && louthu3==0)										/* parabolic defocusing top wall */
    {
      PARABEL_DEFOCUS( h1u3,l ,linhu3, uwallthick3, &p2parahu3, &h2u3, &pbhu3 , &pahu3, &p2parahuwt3, &pbhuwt3, &pahuwt3, &h2uwt3, &h1uwt3);
    }

if(linhu3==0 && louthu3==0)
    {
      LINEAR(h1u3, h2u3, l, uwallthick3, &h1uwt3, &h2uwt3);
    }


													/* Calculation of curve-parameters for the bottom wall - negative y-axis - analog right wall */

if (linhd3 != 0 && louthd3 !=0)										/* elliptic bottom wall */
    {
      ELLIPSE(h1d3, l, linhd3, louthd3, dwallthick3, &ahd3, &bhd3, &a2hd3, &b2hd3, &z0hd3 , &h2d3, &ahdwt3, &a2hdwt3, &bhdwt3, &b2hdwt3, &h2dwt3, &h1dwt3);
    }

if(linhd3==0 && louthd3!=0)										/* parabolic focusing bottom wall */
   {	
     PARABEL_FOCUS( h1d3,l ,louthd3, dwallthick3, &p2parahd3, &h2d3, &pbhd3 , &pahd3, &p2parahdwt3, &pbhdwt3, &pahdwt3, &h2dwt3, &h1dwt3);
   }

if (linhd3!=0 && louthd3==0)										/* parabolic defocusing bottom wall */
    {
      PARABEL_DEFOCUS( h1d3,l ,linhd3, dwallthick3, &p2parahd3, &h2d3, &pbhd3 , &pahd3, &p2parahdwt3, &pbhdwt3, &pahdwt3, &h2dwt3, &h1dwt3);
    }

if(linhd3==0 && louthd3==0)
    {
      LINEAR(h1d3, h2d3, l, dwallthick3, &h1dwt3, &h2dwt3);
    }



mru13=(h1uwt3-h1u3)/(w1r3-w1rwt3);										/* calculation for entrance and exit absorbing mask for the right upper corner*/
nru13=h1u3-mru13*(-w1r3);

mrd13=(-h1dwt3+h1d3)/(w1r3-w1rwt3);										/* calculation for entrance and exit absorbing mask for the right lower corner*/
nrd13=-h1d3-mrd13*(-w1r3);

mlu13=(h1uwt3-h1u3)/(-w1l3+w1lwt3);										/* calculation for entrance and exit absorbing mask for the left upper corner*/
nlu13=h1u3-mlu13*w1l3;

mld13=(-h1dwt3+h1d3)/(-w1l3+w1lwt3);										/* calculation for entrance and exit absorbing mask for the left lower corner*/
nld13=-h1d3-mld13*w1l3;


mru23=(h2u3-h2uwt3)/(-w2r3+w2rwt3);										/* calculation for exit absorbing mask for the right upper corner*/
nru23=h2u3-mru23*(-w2r3);

mrd23=(-h2d3+h2dwt3)/(-w2r3+w2rwt3);										/* calculation for exit absorbing mask for the right lower corner*/
nrd23=-h2d3-mrd23*(-w2r3);

mlu23=(h2u3-h2uwt3)/(w2l3-w2lwt3);										/* calculation for exit absorbing mask for the left upper corner*/
nlu23=h2u3-mlu23*w2l3;

mld23=(h2dwt3-h2d3)/(w2l3-w2lwt3);										/* calculation for exit absorbing mask for the left lower corner*/
nld23=-h2d3-mld23*w2l3;


if (w1r3 < w1rwt2 ) TEST_INPUT_4("w1r3", "w1rwt2", w1r3, w1rwt2);

if (w1l3 < w1lwt2 ) TEST_INPUT_4("w1l3", "w1lwt2", w1l3, w1lwt2);

if (h1u3 < h1uwt2 ) TEST_INPUT_4("h1u3", "h1uwt2", h1u3, h1uwt2);

if (h1d3 < h1dwt2 ) TEST_INPUT_4("h1d3", "h1dwt2", h1d3, h1dwt2);

if (w2r3 < w2rwt2 ) TEST_INPUT_4("w2r3", "w2rwt2", w2r3, w2rwt2);

if (w2l3 < w2lwt2 ) TEST_INPUT_4("w2l3", "w2lwt2", w2l3, w2lwt2);

if (h2u3 < h2uwt2 ) TEST_INPUT_4("h2u3", "h2uwt2", h2u3, h2uwt2);

if (h2d3 < h2dwt2 ) TEST_INPUT_4("h2d3", "h2dwt2", h2d3, h2dwt2);


/* FORTH SHELL */

if(loutwr4!=0 && linwr4!=0)										/* elliptic right side wall */
   { 
     ELLIPSE(w1r4, l, linwr4, loutwr4, rwallthick4, &awr4, &bwr4, &a2wr4, &b2wr4, &z0wr4, &w2r4, &awrwt4, &a2wrwt4, &bwrwt4, &b2wrwt4, &w2rwt4, &w1rwt4);
   }


if(linwr4==0 && loutwr4!=0)										/* parabolic focusing right side wall */
   {
     PARABEL_FOCUS( w1r4,l ,loutwr4, rwallthick4, &p2parawr4, &w2r4, &pbwr4 , &pawr4, &p2parawrwt4, &pbwrwt4, &pawrwt4, &w2rwt4, &w1rwt4);
   }

if (linwr4!=0 && loutwr4==0)										/* parabolic defocusing right side wall  */
    {
      PARABEL_DEFOCUS( w1r4,l ,linwr4, rwallthick4, &p2parawr4, &w2r4, &pbwr4 , &pawr4, &p2parawrwt4, &pbwrwt4, &pawrwt4, &w2rwt4, &w1rwt4);
    }

if(linwr4==0 && loutwr4==0)										/* straight right side wall */
    {
      LINEAR(w1r4, w2r4, l, rwallthick4, &w1rwt4, &w2rwt4);
    }


													/* Calculation of curve-parameters for the left side wall - positive x-axis - analog to right side*/

if((linwl4!=0) && (loutwl4!=0) ) 										/* elleptic left side wall */
  { 
    ELLIPSE(w1l4, l, linwl4, loutwl4, lwallthick4, &awl4, &bwl4, &a2wl4, &b2wl4, &z0wl4, &w2l4, &awlwt4, &a2wlwt4, &bwlwt4, &b2wlwt4, &w2lwt4, &w1lwt4);
   }

if(linwl4==0 && loutwl4!=0)										/* parabolic focusing left side wall */
   {
     PARABEL_FOCUS( w1l4,l ,loutwl4, lwallthick4, &p2parawl4, &w2l4, &pbwl4 , &pawl4, &p2parawlwt4, &pbwlwt4, &pawlwt4, &w2lwt4, &w1lwt4);
   }

if (linwl4!=0 && loutwl4==0)										/* parabolic defocusing left side wall  */
    {
      PARABEL_DEFOCUS( w1l4,l ,linwl4, lwallthick4, &p2parawl4, &w2l4, &pbwl4 , &pawl4, &p2parawlwt4, &pbwlwt4, &pawlwt4, &w2lwt4, &w1lwt4);
    }

if(linwl4==0 && loutwl4==0)										/* straight left side wall */
    {
      LINEAR(w1l4, w2l4, l, lwallthick4, &w1lwt4, &w2lwt4);
    }


													/* Calculation of curve-parameters for the top wall - positive y-axis - analog  right wall*/


if (linhu4 != 0 && louthu4 !=0)										/* elliptic top wall */
    {
      ELLIPSE(h1u4, l, linhu4, louthu4, uwallthick4, &ahu4, &bhu4, &a2hu4, &b2hu4, &z0hu4 , &h2u4, &ahuwt4, &a2huwt4, &bhuwt4, &b2huwt4, &h2uwt4, &h1uwt4); 
    }

if(linhu4==0 && louthu4!=0)										/* parabolic focusing top wall */
    { 	
      PARABEL_FOCUS( h1u4,l ,louthu4, uwallthick4, &p2parahu4, &h2u4, &pbhu4 , &pahu4, &p2parahuwt4, &pbhuwt4, &pahuwt4, &h2uwt4, &h1uwt4);
    } 

if (linhu4!=0 && louthu4==0)										/* parabolic defocusing top wall */
    {
      PARABEL_DEFOCUS( h1u4,l ,linhu4, uwallthick4, &p2parahu4, &h2u4, &pbhu4 , &pahu4, &p2parahuwt4, &pbhuwt4, &pahuwt4, &h2uwt4, &h1uwt4);
    }

if(linhu4==0 && louthu4==0)
    {
      LINEAR(h1u4, h2u4, l, uwallthick4, &h1uwt4, &h2uwt4);
    }


													/* Calculation of curve-parameters for the bottom wall - negative y-axis - analog right wall */

if (linhd4 != 0 && louthd4 !=0)										/* elliptic bottom wall */
    {
      ELLIPSE(h1d4, l, linhd4, louthd4, dwallthick4, &ahd4, &bhd4, &a2hd4, &b2hd4, &z0hd4 , &h2d4, &ahdwt4, &a2hdwt4, &bhdwt4, &b2hdwt4, &h2dwt4, &h1dwt4);
    }

if(linhd4==0 && louthd4!=0)										/* parabolic focusing bottom wall */
   {	
     PARABEL_FOCUS( h1d4,l ,louthd4, dwallthick4, &p2parahd4, &h2d4, &pbhd4 , &pahd4, &p2parahdwt4, &pbhdwt4, &pahdwt4, &h2dwt4, &h1dwt4);
   }

if (linhd4!=0 && louthd4==0)										/* parabolic defocusing bottom wall */
    {
      PARABEL_DEFOCUS( h1d4,l ,linhd4, dwallthick4, &p2parahd4, &h2d4, &pbhd4 , &pahd4, &p2parahdwt4, &pbhdwt4, &pahdwt4, &h2dwt4, &h1dwt4);
    }

if(linhd4==0 && louthd4==0)
    {
      LINEAR(h1d4, h2d4, l, dwallthick4, &h1dwt4, &h2dwt4);
    }



mru14=(h1uwt4-h1u4)/(w1r4-w1rwt4);										/* calculation for entrance and exit absorbing mask for the right upper corner*/
nru14=h1u4-mru14*(-w1r4);

mrd14=(-h1dwt4+h1d4)/(w1r4-w1rwt4);										/* calculation for entrance and exit absorbing mask for the right lower corner*/
nrd14=-h1d4-mrd14*(-w1r4);

mlu14=(h1uwt4-h1u4)/(-w1l4+w1lwt4);										/* calculation for entrance and exit absorbing mask for the left upper corner*/
nlu14=h1u4-mlu14*w1l4;

mld14=(-h1dwt4+h1d4)/(-w1l4+w1lwt4);										/* calculation for entrance and exit absorbing mask for the left lower corner*/
nld14=-h1d4-mld14*w1l4;


mru24=(h2u4-h2uwt4)/(-w2r4+w2rwt4);										/* calculation for exit absorbing mask for the right upper corner*/
nru24=h2u4-mru24*(-w2r4);

mrd24=(-h2d4+h2dwt4)/(-w2r4+w2rwt4);										/* calculation for exit absorbing mask for the right lower corner*/
nrd24=-h2d4-mrd24*(-w2r4);

mlu24=(h2u4-h2uwt4)/(w2l4-w2lwt4);										/* calculation for exit absorbing mask for the left upper corner*/
nlu24=h2u4-mlu24*w2l4;

mld24=(h2dwt4-h2d4)/(w2l4-w2lwt4);										/* calculation for exit absorbing mask for the left lower corner*/
nld24=-h2d4-mld24*w2l4;


if (w1r4 < w1rwt3 ) TEST_INPUT_4("w1r4", "w1rwt3", w1r4, w1rwt3);

if (w1l4 < w1lwt3 ) TEST_INPUT_4("w1l4", "w1lwt3", w1l4, w1lwt3);

if (h1u4 < h1uwt3 ) TEST_INPUT_4("h1u4", "h1uwt3", h1u4, h1uwt3);

if (h1d4 < h1dwt3 ) TEST_INPUT_4("h1d4", "h1dwt3", h1d4, h1dwt3);

if (w2r4 < w2rwt3 ) TEST_INPUT_4("w2r4", "w2rwt3", w2r4, w2rwt3);

if (w2l4 < w2lwt3 ) TEST_INPUT_4("w2l4", "w2lwt3", w2l4, w2lwt3);

if (h2u4 < h2uwt3 ) TEST_INPUT_4("h2u4", "h2uwt3", h2u4, h2uwt3);

if (h2d4 < h2dwt3 ) TEST_INPUT_4("h2d4", "h2dwt3", h2d4, h2dwt3);

/* FIFTH SHELL */


if(loutwr5!=0 && linwr5!=0)										/* elliptic right side wall */
   { 
     ELLIPSE(w1r5, l, linwr5, loutwr5, rwallthick5, &awr5, &bwr5, &a2wr5, &b2wr5, &z0wr5, &w2r5, &awrwt5, &a2wrwt5, &bwrwt5, &b2wrwt5, &w2rwt5, &w1rwt5);
   }


if(linwr5==0 && loutwr5!=0)										/* parabolic focusing right side wall */
   {
     PARABEL_FOCUS( w1r5,l ,loutwr5, rwallthick5, &p2parawr5, &w2r5, &pbwr5 , &pawr5, &p2parawrwt5, &pbwrwt5, &pawrwt5, &w2rwt5, &w1rwt5);
   }

if (linwr5!=0 && loutwr5==0)										/* parabolic defocusing right side wall  */
    {
      PARABEL_DEFOCUS( w1r5,l ,linwr5, rwallthick5, &p2parawr5, &w2r5, &pbwr5 , &pawr5, &p2parawrwt5, &pbwrwt5, &pawrwt5, &w2rwt5, &w1rwt5);
    }

if(linwr5==0 && loutwr5==0)										/* straight right side wall */
    {
      LINEAR(w1r5, w2r5, l, rwallthick5, &w1rwt5, &w2rwt5);
    }


													/* Calculation of curve-parameters for the left side wall - positive x-axis - analog to right side*/

if((linwl5!=0) && (loutwl5!=0) ) 										/* elleptic left side wall */
  { 
    ELLIPSE(w1l5, l, linwl5, loutwl5, lwallthick5, &awl5, &bwl5, &a2wl5, &b2wl5, &z0wl5, &w2l5, &awlwt5, &a2wlwt5, &bwlwt5, &b2wlwt5, &w2lwt5, &w1lwt5);
   }

if(linwl5==0 && loutwl5!=0)										/* parabolic focusing left side wall */
   {
     PARABEL_FOCUS( w1l5,l ,loutwl5, lwallthick5, &p2parawl5, &w2l5, &pbwl5 , &pawl5, &p2parawlwt5, &pbwlwt5, &pawlwt5, &w2lwt5, &w1lwt5);
   }

if (linwl5!=0 && loutwl5==0)										/* parabolic defocusing left side wall  */
    {
      PARABEL_DEFOCUS( w1l5,l ,linwl5, lwallthick5, &p2parawl5, &w2l5, &pbwl5 , &pawl5, &p2parawlwt5, &pbwlwt5, &pawlwt5, &w2lwt5, &w1lwt5);
    }

if(linwl5==0 && loutwl5==0)										/* straight left side wall */
    {
      LINEAR(w1l5, w2l5, l, lwallthick5, &w1lwt5, &w2lwt5);
    }


													/* Calculation of curve-parameters for the top wall - positive y-axis - analog  right wall*/


if (linhu5 != 0 && louthu5 !=0)										/* elliptic top wall */
    {
      ELLIPSE(h1u5, l, linhu5, louthu5, uwallthick5, &ahu5, &bhu5, &a2hu5, &b2hu5, &z0hu5 , &h2u5, &ahuwt5, &a2huwt5, &bhuwt5, &b2huwt5, &h2uwt5, &h1uwt5); 
    }

if(linhu5==0 && louthu5!=0)										/* parabolic focusing top wall */
    { 	
      PARABEL_FOCUS( h1u5,l ,louthu5, uwallthick5, &p2parahu5, &h2u5, &pbhu5 , &pahu5, &p2parahuwt5, &pbhuwt5, &pahuwt5, &h2uwt5, &h1uwt5);
    } 

if (linhu5!=0 && louthu5==0)										/* parabolic defocusing top wall */
    {
      PARABEL_DEFOCUS( h1u5,l ,linhu5, uwallthick5, &p2parahu5, &h2u5, &pbhu5 , &pahu5, &p2parahuwt5, &pbhuwt5, &pahuwt5, &h2uwt5, &h1uwt5);
    }

if(linhu5==0 && louthu5==0)
    {
      LINEAR(h1u5, h2u5, l, uwallthick5, &h1uwt5, &h2uwt5);
    }


													/* Calculation of curve-parameters for the bottom wall - negative y-axis - analog right wall */

if (linhd5 != 0 && louthd5 !=0)										/* elliptic bottom wall */
    {
      ELLIPSE(h1d5, l, linhd5, louthd5, dwallthick5, &ahd5, &bhd5, &a2hd5, &b2hd5, &z0hd5 , &h2d5, &ahdwt5, &a2hdwt5, &bhdwt5, &b2hdwt5, &h2dwt5, &h1dwt5);
    }

if(linhd5==0 && louthd5!=0)										/* parabolic focusing bottom wall */
   {	
     PARABEL_FOCUS( h1d5,l ,louthd5, dwallthick5, &p2parahd5, &h2d5, &pbhd5 , &pahd5, &p2parahdwt5, &pbhdwt5, &pahdwt5, &h2dwt5, &h1dwt5);
   }

if (linhd5!=0 && louthd5==0)										/* parabolic defocusing bottom wall */
    {
      PARABEL_DEFOCUS( h1d5,l ,linhd5, dwallthick5, &p2parahd5, &h2d5, &pbhd5 , &pahd5, &p2parahdwt5, &pbhdwt5, &pahdwt5, &h2dwt5, &h1dwt5);
    }

if(linhd5==0 && louthd5==0)
    {
      LINEAR(h1d5, h2d5, l, dwallthick5, &h1dwt5, &h2dwt5);
    }



mru15=(h1uwt5-h1u5)/(w1r5-w1rwt5);										/* calculation for entrance and exit absorbing mask for the right upper corner*/
nru15=h1u5-mru15*(-w1r5);

mrd15=(-h1dwt5+h1d5)/(w1r5-w1rwt5);										/* calculation for entrance and exit absorbing mask for the right lower corner*/
nrd15=-h1d5-mrd15*(-w1r5);

mlu15=(h1uwt5-h1u5)/(-w1l5+w1lwt5);										/* calculation for entrance and exit absorbing mask for the left upper corner*/
nlu15=h1u5-mlu15*w1l5;

mld15=(-h1dwt5+h1d5)/(-w1l5+w1lwt5);										/* calculation for entrance and exit absorbing mask for the left lower corner*/
nld15=-h1d5-mld15*w1l5;


mru25=(h2u5-h2uwt5)/(-w2r5+w2rwt5);										/* calculation for exit absorbing mask for the right upper corner*/
nru25=h2u5-mru25*(-w2r5);

mrd25=(-h2d5+h2dwt5)/(-w2r5+w2rwt5);										/* calculation for exit absorbing mask for the right lower corner*/
nrd25=-h2d5-mrd25*(-w2r5);

mlu25=(h2u5-h2uwt5)/(w2l5-w2lwt5);										/* calculation for exit absorbing mask for the left upper corner*/
nlu25=h2u5-mlu25*w2l5;

mld25=(h2dwt5-h2d5)/(w2l5-w2lwt5);										/* calculation for exit absorbing mask for the left lower corner*/
nld25=-h2d5-mld25*w2l5;


if (w1r5 < w1rwt4 ) TEST_INPUT_4("w1r5", "w1rwt4", w1r5, w1rwt4);

if (w1l5 < w1lwt4 ) TEST_INPUT_4("w1l5", "w1lwt4", w1l5, w1lwt4);

if (h1u5 < h1uwt4 ) TEST_INPUT_4("h1u5", "h1uwt4", h1u5, h1uwt4);

if (h1d5 < h1dwt4 ) TEST_INPUT_4("h1d5", "h1dwt4", h1d5, h1dwt4);

if (w2r5 < w2rwt4 ) TEST_INPUT_4("w2r5", "w2rwt4", w2r5, w2rwt4);

if (w2l5 < w2lwt4 ) TEST_INPUT_4("w2l5", "w2lwt4", w2l5, w2lwt4);

if (h2u5 < h2uwt4 ) TEST_INPUT_4("h2u5", "h2uwt4", h2u5, h2uwt4);

if (h2d5 < h2dwt4 ) TEST_INPUT_4("h2d5", "h2dwt4", h2d5, h2dwt4);


/* SIXTH SHELL */

if(loutwr6!=0 && linwr6!=0)										/* elliptic right side wall */
   { 
     ELLIPSE(w1r6, l, linwr6, loutwr6, rwallthick6, &awr6, &bwr6, &a2wr6, &b2wr6, &z0wr6, &w2r6, &awrwt6, &a2wrwt6, &bwrwt6, &b2wrwt6, &w2rwt6, &w1rwt6);
   }


if(linwr6==0 && loutwr6!=0)										/* parabolic focusing right side wall */
   {
     PARABEL_FOCUS( w1r6,l ,loutwr6, rwallthick6, &p2parawr6, &w2r6, &pbwr6 , &pawr6, &p2parawrwt6, &pbwrwt6, &pawrwt6, &w2rwt6, &w1rwt6);
   }

if (linwr6!=0 && loutwr6==0)										/* parabolic defocusing right side wall  */
    {
      PARABEL_DEFOCUS( w1r6,l ,linwr6, rwallthick6, &p2parawr6, &w2r6, &pbwr6 , &pawr6, &p2parawrwt6, &pbwrwt6, &pawrwt6, &w2rwt6, &w1rwt6);
    }

if(linwr6==0 && loutwr6==0)										/* straight right side wall */
    {
      LINEAR(w1r6, w2r6, l, rwallthick6, &w1rwt6, &w2rwt6);
    }


													/* Calculation of curve-parameters for the left side wall - positive x-axis - analog to right side*/

if((linwl6!=0) && (loutwl6!=0) ) 										/* elleptic left side wall */
  { 
    ELLIPSE(w1l6, l, linwl6, loutwl6, lwallthick6, &awl6, &bwl6, &a2wl6, &b2wl6, &z0wl6, &w2l6, &awlwt6, &a2wlwt6, &bwlwt6, &b2wlwt6, &w2lwt6, &w1lwt6);
   }

if(linwl6==0 && loutwl6!=0)										/* parabolic focusing left side wall */
   {
     PARABEL_FOCUS( w1l6,l ,loutwl6, lwallthick6, &p2parawl6, &w2l6, &pbwl6 , &pawl6, &p2parawlwt6, &pbwlwt6, &pawlwt6, &w2lwt6, &w1lwt6);
   }

if (linwl6!=0 && loutwl6==0)										/* parabolic defocusing left side wall  */
    {
      PARABEL_DEFOCUS( w1l6,l ,linwl6, lwallthick6, &p2parawl6, &w2l6, &pbwl6 , &pawl6, &p2parawlwt6, &pbwlwt6, &pawlwt6, &w2lwt6, &w1lwt6);
    }

if(linwl6==0 && loutwl6==0)										/* straight left side wall */
    {
      LINEAR(w1l6, w2l6, l, lwallthick6, &w1lwt6, &w2lwt6);
    }


													/* Calculation of curve-parameters for the top wall - positive y-axis - analog  right wall*/


if (linhu6 != 0 && louthu6 !=0)										/* elliptic top wall */
    {
      ELLIPSE(h1u6, l, linhu6, louthu6, uwallthick6, &ahu6, &bhu6, &a2hu6, &b2hu6, &z0hu6 , &h2u6, &ahuwt6, &a2huwt6, &bhuwt6, &b2huwt6, &h2uwt6, &h1uwt6); 
    }

if(linhu6==0 && louthu6!=0)										/* parabolic focusing top wall */
    { 	
      PARABEL_FOCUS( h1u6,l ,louthu6, uwallthick6, &p2parahu6, &h2u6, &pbhu6 , &pahu6, &p2parahuwt6, &pbhuwt6, &pahuwt6, &h2uwt6, &h1uwt6);
    } 

if (linhu6!=0 && louthu6==0)										/* parabolic defocusing top wall */
    {
      PARABEL_DEFOCUS( h1u6,l ,linhu6, uwallthick6, &p2parahu6, &h2u6, &pbhu6 , &pahu6, &p2parahuwt6, &pbhuwt6, &pahuwt6, &h2uwt6, &h1uwt6);
    }

if(linhu6==0 && louthu6==0)
    {
      LINEAR(h1u6, h2u6, l, uwallthick6, &h1uwt6, &h2uwt6);
    }


													/* Calculation of curve-parameters for the bottom wall - negative y-axis - analog right wall */

if (linhd6 != 0 && louthd6 !=0)										/* elliptic bottom wall */
    {
      ELLIPSE(h1d6, l, linhd6, louthd6, dwallthick6, &ahd6, &bhd6, &a2hd6, &b2hd6, &z0hd6 , &h2d6, &ahdwt6, &a2hdwt6, &bhdwt6, &b2hdwt6, &h2dwt6, &h1dwt6);
    }

if(linhd6==0 && louthd6!=0)										/* parabolic focusing bottom wall */
   {	
     PARABEL_FOCUS( h1d6,l ,louthd6, dwallthick6, &p2parahd6, &h2d6, &pbhd6 , &pahd6, &p2parahdwt6, &pbhdwt6, &pahdwt6, &h2dwt6, &h1dwt6);
   }

if (linhd6!=0 && louthd6==0)										/* parabolic defocusing bottom wall */
    {
      PARABEL_DEFOCUS( h1d6,l ,linhd6, dwallthick6, &p2parahd6, &h2d6, &pbhd6 , &pahd6, &p2parahdwt6, &pbhdwt6, &pahdwt6, &h2dwt6, &h1dwt6);
    }

if(linhd6==0 && louthd6==0)
    {
      LINEAR(h1d6, h2d6, l, dwallthick6, &h1dwt6, &h2dwt6);
    }



mru16=(h1uwt6-h1u6)/(w1r6-w1rwt6);										/* calculation for entrance and exit absorbing mask for the right upper corner*/
nru16=h1u6-mru16*(-w1r6);

mrd16=(-h1dwt6+h1d6)/(w1r6-w1rwt6);										/* calculation for entrance and exit absorbing mask for the right lower corner*/
nrd16=-h1d6-mrd16*(-w1r6);

mlu16=(h1uwt6-h1u6)/(-w1l6+w1lwt6);										/* calculation for entrance and exit absorbing mask for the left upper corner*/
nlu16=h1u6-mlu16*w1l6;

mld16=(-h1dwt6+h1d6)/(-w1l6+w1lwt6);										/* calculation for entrance and exit absorbing mask for the left lower corner*/
nld16=-h1d6-mld16*w1l6;


mru26=(h2u6-h2uwt6)/(-w2r6+w2rwt6);										/* calculation for exit absorbing mask for the right upper corner*/
nru26=h2u6-mru26*(-w2r6);

mrd26=(-h2d6+h2dwt6)/(-w2r6+w2rwt6);										/* calculation for exit absorbing mask for the right lower corner*/
nrd26=-h2d6-mrd26*(-w2r6);

mlu26=(h2u6-h2uwt6)/(w2l6-w2lwt6);										/* calculation for exit absorbing mask for the left upper corner*/
nlu26=h2u6-mlu26*w2l6;

mld26=(h2dwt6-h2d6)/(w2l6-w2lwt6);										/* calculation for exit absorbing mask for the left lower corner*/
nld26=-h2d6-mld26*w2l6;


if (w1r6 < w1rwt5 ) TEST_INPUT_4("w1r6", "w1rwt5", w1r6, w1rwt5);

if (w1l6 < w1lwt5 ) TEST_INPUT_4("w1l6", "w1lwt5", w1l6, w1lwt5);

if (h1u6 < h1uwt5 ) TEST_INPUT_4("h1u6", "h1uwt5", h1u6, h1uwt5);

if (h1d6 < h1dwt5 ) TEST_INPUT_4("h1d6", "h1dwt5", h1d6, h1dwt5);

if (w2r6 < w2rwt5 ) TEST_INPUT_4("w2r6", "w2rwt5", w2r6, w2rwt5);

if (w2l6 < w2lwt5 ) TEST_INPUT_4("w2l6", "w2lwt5", w2l6, w2lwt5);

if (h2u6 < h2uwt5 ) TEST_INPUT_4("h2u6", "h2uwt5", h2u6, h2uwt5);

if (h2d6 < h2dwt5 ) TEST_INPUT_4("h2d6", "h2dwt5", h2d6, h2dwt5);




/* SEVENTH SHELL */

if(loutwr7!=0 && linwr7!=0)										/* elliptic right side wall */
   { 
     ELLIPSE(w1r7, l, linwr7, loutwr7, rwallthick7, &awr7, &bwr7, &a2wr7, &b2wr7, &z0wr7, &w2r7, &awrwt7, &a2wrwt7, &bwrwt7, &b2wrwt7, &w2rwt7, &w1rwt7);
   }


if(linwr7==0 && loutwr7!=0)										/* parabolic focusing right side wall */
   {
     PARABEL_FOCUS( w1r7,l ,loutwr7, rwallthick7, &p2parawr7, &w2r7, &pbwr7 , &pawr7, &p2parawrwt7, &pbwrwt7, &pawrwt7, &w2rwt7, &w1rwt7);
   }

if (linwr7!=0 && loutwr7==0)										/* parabolic defocusing right side wall  */
    {
      PARABEL_DEFOCUS( w1r7,l ,linwr7, rwallthick7, &p2parawr7, &w2r7, &pbwr7 , &pawr7, &p2parawrwt7, &pbwrwt7, &pawrwt7, &w2rwt7, &w1rwt7);
    }

if(linwr7==0 && loutwr7==0)										/* straight right side wall */
    {
      LINEAR(w1r7, w2r7, l, rwallthick7, &w1rwt7, &w2rwt7);
    }


													/* Calculation of curve-parameters for the left side wall - positive x-axis - analog to right side*/

if((linwl7!=0) && (loutwl7!=0) ) 										/* elleptic left side wall */
  { 
    ELLIPSE(w1l7, l, linwl7, loutwl7, lwallthick7, &awl7, &bwl7, &a2wl7, &b2wl7, &z0wl7, &w2l7, &awlwt7, &a2wlwt7, &bwlwt7, &b2wlwt7, &w2lwt7, &w1lwt7);
   }

if(linwl7==0 && loutwl7!=0)										/* parabolic focusing left side wall */
   {
     PARABEL_FOCUS( w1l7,l ,loutwl7, lwallthick7, &p2parawl7, &w2l7, &pbwl7 , &pawl7, &p2parawlwt7, &pbwlwt7, &pawlwt7, &w2lwt7, &w1lwt7);
   }

if (linwl7!=0 && loutwl7==0)										/* parabolic defocusing left side wall  */
    {
      PARABEL_DEFOCUS( w1l7,l ,linwl7, lwallthick7, &p2parawl7, &w2l7, &pbwl7 , &pawl7, &p2parawlwt7, &pbwlwt7, &pawlwt7, &w2lwt7, &w1lwt7);
    }

if(linwl7==0 && loutwl7==0)										/* straight left side wall */
    {
      LINEAR(w1l7, w2l7, l, lwallthick7, &w1lwt7, &w2lwt7);
    }


													/* Calculation of curve-parameters for the top wall - positive y-axis - analog  right wall*/


if (linhu7 != 0 && louthu7 !=0)										/* elliptic top wall */
    {
      ELLIPSE(h1u7, l, linhu7, louthu7, uwallthick7, &ahu7, &bhu7, &a2hu7, &b2hu7, &z0hu7 , &h2u7, &ahuwt7, &a2huwt7, &bhuwt7, &b2huwt7, &h2uwt7, &h1uwt7); 
    }

if(linhu7==0 && louthu7!=0)										/* parabolic focusing top wall */
    { 	
      PARABEL_FOCUS( h1u7,l ,louthu7, uwallthick7, &p2parahu7, &h2u7, &pbhu7 , &pahu7, &p2parahuwt7, &pbhuwt7, &pahuwt7, &h2uwt7, &h1uwt7);
    } 

if (linhu7!=0 && louthu7==0)										/* parabolic defocusing top wall */
    {
      PARABEL_DEFOCUS( h1u7,l ,linhu7, uwallthick7, &p2parahu7, &h2u7, &pbhu7 , &pahu7, &p2parahuwt7, &pbhuwt7, &pahuwt7, &h2uwt7, &h1uwt7);
    }

if(linhu7==0 && louthu7==0)
    {
      LINEAR(h1u7, h2u7, l, uwallthick7, &h1uwt7, &h2uwt7);
    }


													/* Calculation of curve-parameters for the bottom wall - negative y-axis - analog right wall */

if (linhd7 != 0 && louthd7 !=0)										/* elliptic bottom wall */
    {
      ELLIPSE(h1d7, l, linhd7, louthd7, dwallthick7, &ahd7, &bhd7, &a2hd7, &b2hd7, &z0hd7 , &h2d7, &ahdwt7, &a2hdwt7, &bhdwt7, &b2hdwt7, &h2dwt7, &h1dwt7);
    }

if(linhd7==0 && louthd7!=0)										/* parabolic focusing bottom wall */
   {	
     PARABEL_FOCUS( h1d7,l ,louthd7, dwallthick7, &p2parahd7, &h2d7, &pbhd7 , &pahd7, &p2parahdwt7, &pbhdwt7, &pahdwt7, &h2dwt7, &h1dwt7);
   }

if (linhd7!=0 && louthd7==0)										/* parabolic defocusing bottom wall */
    {
      PARABEL_DEFOCUS( h1d7,l ,linhd7, dwallthick7, &p2parahd7, &h2d7, &pbhd7 , &pahd7, &p2parahdwt7, &pbhdwt7, &pahdwt7, &h2dwt7, &h1dwt7);
    }

if(linhd7==0 && louthd7==0)
    {
      LINEAR(h1d7, h2d7, l, dwallthick7, &h1dwt7, &h2dwt7);
    }



mru17=(h1uwt7-h1u7)/(w1r7-w1rwt7);										/* calculation for entrance and exit absorbing mask for the right upper corner*/
nru17=h1u7-mru17*(-w1r7);

mrd17=(-h1dwt7+h1d7)/(w1r7-w1rwt7);										/* calculation for entrance and exit absorbing mask for the right lower corner*/
nrd17=-h1d7-mrd17*(-w1r7);

mlu17=(h1uwt7-h1u7)/(-w1l7+w1lwt7);										/* calculation for entrance and exit absorbing mask for the left upper corner*/
nlu17=h1u7-mlu17*w1l7;

mld17=(-h1dwt7+h1d7)/(-w1l7+w1lwt7);										/* calculation for entrance and exit absorbing mask for the left lower corner*/
nld17=-h1d7-mld17*w1l7;


mru27=(h2u7-h2uwt7)/(-w2r7+w2rwt7);										/* calculation for exit absorbing mask for the right upper corner*/
nru27=h2u7-mru27*(-w2r7);

mrd27=(-h2d7+h2dwt7)/(-w2r7+w2rwt7);										/* calculation for exit absorbing mask for the right lower corner*/
nrd27=-h2d7-mrd27*(-w2r7);

mlu27=(h2u7-h2uwt7)/(w2l7-w2lwt7);										/* calculation for exit absorbing mask for the left upper corner*/
nlu27=h2u7-mlu27*w2l7;

mld27=(h2dwt7-h2d7)/(w2l7-w2lwt7);										/* calculation for exit absorbing mask for the left lower corner*/
nld27=-h2d7-mld27*w2l7;


if (w1r7 < w1rwt6 ) TEST_INPUT_4("w1r7", "w1rwt6", w1r7, w1rwt6);

if (w1l7 < w1lwt6 ) TEST_INPUT_4("w1l7", "w1lwt6", w1l7, w1lwt6);

if (h1u7 < h1uwt6 ) TEST_INPUT_4("h1u7", "h1uwt6", h1u7, h1uwt6);

if (h1d7 < h1dwt6 ) TEST_INPUT_4("h1d7", "h1dwt6", h1d7, h1dwt6);

if (w2r7 < w2rwt6 ) TEST_INPUT_4("w2r7", "w2rwt6", w2r7, w2rwt6);

if (w2l7 < w2lwt6 ) TEST_INPUT_4("w2l7", "w2lwt6", w2l7, w2lwt6);

if (h2u7 < h2uwt6 ) TEST_INPUT_4("h2u7", "h2uwt6", h2u7, h2uwt6);

if (h2d7 < h2dwt6 ) TEST_INPUT_4("h2d7", "h2dwt6", h2d7, h2dwt6);



/* EIGHTH SHELL */


if(loutwr8!=0 && linwr8!=0)										/* elliptic right side wall */
   { 
     ELLIPSE(w1r8, l, linwr8, loutwr8, rwallthick8, &awr8, &bwr8, &a2wr8, &b2wr8, &z0wr8, &w2r8, &awrwt8, &a2wrwt8, &bwrwt8, &b2wrwt8, &w2rwt8, &w1rwt8);
   }


if(linwr8==0 && loutwr8!=0)										/* parabolic focusing right side wall */
   {
     PARABEL_FOCUS( w1r8,l ,loutwr8, rwallthick8, &p2parawr8, &w2r8, &pbwr8 , &pawr8, &p2parawrwt8, &pbwrwt8, &pawrwt8, &w2rwt8, &w1rwt8);
   }

if (linwr8!=0 && loutwr8==0)										/* parabolic defocusing right side wall  */
    {
      PARABEL_DEFOCUS( w1r8,l ,linwr8, rwallthick8, &p2parawr8, &w2r8, &pbwr8 , &pawr8, &p2parawrwt8, &pbwrwt8, &pawrwt8, &w2rwt8, &w1rwt8);
    }

if(linwr8==0 && loutwr8==0)										/* straight right side wall */
    {
      LINEAR(w1r8, w2r8, l, rwallthick8, &w1rwt8, &w2rwt8);
    }


													/* Calculation of curve-parameters for the left side wall - positive x-axis - analog to right side*/

if((linwl8!=0) && (loutwl8!=0) ) 										/* elleptic left side wall */
  { 
    ELLIPSE(w1l8, l, linwl8, loutwl8, lwallthick8, &awl8, &bwl8, &a2wl8, &b2wl8, &z0wl8, &w2l8, &awlwt8, &a2wlwt8, &bwlwt8, &b2wlwt8, &w2lwt8, &w1lwt8);
   }

if(linwl8==0 && loutwl8!=0)										/* parabolic focusing left side wall */
   {
     PARABEL_FOCUS( w1l8,l ,loutwl8, lwallthick8, &p2parawl8, &w2l8, &pbwl8 , &pawl8, &p2parawlwt8, &pbwlwt8, &pawlwt8, &w2lwt8, &w1lwt8);
   }

if (linwl8!=0 && loutwl8==0)										/* parabolic defocusing left side wall  */
    {
      PARABEL_DEFOCUS( w1l8,l ,linwl8, lwallthick8, &p2parawl8, &w2l8, &pbwl8 , &pawl8, &p2parawlwt8, &pbwlwt8, &pawlwt8, &w2lwt8, &w1lwt8);
    }

if(linwl8==0 && loutwl8==0)										/* straight left side wall */
    {
      LINEAR(w1l8, w2l8, l, lwallthick8, &w1lwt8, &w2lwt8);
    }


													/* Calculation of curve-parameters for the top wall - positive y-axis - analog  right wall*/


if (linhu8 != 0 && louthu8 !=0)										/* elliptic top wall */
    {
      ELLIPSE(h1u8, l, linhu8, louthu8, uwallthick8, &ahu8, &bhu8, &a2hu8, &b2hu8, &z0hu8 , &h2u8, &ahuwt8, &a2huwt8, &bhuwt8, &b2huwt8, &h2uwt8, &h1uwt8); 
    }

if(linhu8==0 && louthu8!=0)										/* parabolic focusing top wall */
    { 	
      PARABEL_FOCUS( h1u8,l ,louthu8, uwallthick8, &p2parahu8, &h2u8, &pbhu8 , &pahu8, &p2parahuwt8, &pbhuwt8, &pahuwt8, &h2uwt8, &h1uwt8);
    } 

if (linhu8!=0 && louthu8==0)										/* parabolic defocusing top wall */
    {
      PARABEL_DEFOCUS( h1u8,l ,linhu8, uwallthick8, &p2parahu8, &h2u8, &pbhu8 , &pahu8, &p2parahuwt8, &pbhuwt8, &pahuwt8, &h2uwt8, &h1uwt8);
    }

if(linhu8==0 && louthu8==0)
    {
      LINEAR(h1u8, h2u8, l, uwallthick8, &h1uwt8, &h2uwt8);
    }


													/* Calculation of curve-parameters for the bottom wall - negative y-axis - analog right wall */

if (linhd8 != 0 && louthd8 !=0)										/* elliptic bottom wall */
    {
      ELLIPSE(h1d8, l, linhd8, louthd8, dwallthick8, &ahd8, &bhd8, &a2hd8, &b2hd8, &z0hd8 , &h2d8, &ahdwt8, &a2hdwt8, &bhdwt8, &b2hdwt8, &h2dwt8, &h1dwt8);
    }

if(linhd8==0 && louthd8!=0)										/* parabolic focusing bottom wall */
   {	
     PARABEL_FOCUS( h1d8,l ,louthd8, dwallthick8, &p2parahd8, &h2d8, &pbhd8 , &pahd8, &p2parahdwt8, &pbhdwt8, &pahdwt8, &h2dwt8, &h1dwt8);
   }

if (linhd8!=0 && louthd8==0)										/* parabolic defocusing bottom wall */
    {
      PARABEL_DEFOCUS( h1d8,l ,linhd8, dwallthick8, &p2parahd8, &h2d8, &pbhd8 , &pahd8, &p2parahdwt8, &pbhdwt8, &pahdwt8, &h2dwt8, &h1dwt8);
    }

if(linhd8==0 && louthd8==0)
    {
      LINEAR(h1d8, h2d8, l, dwallthick8, &h1dwt8, &h2dwt8);
    }



mru18=(h1uwt8-h1u8)/(w1r8-w1rwt8);										/* calculation for entrance and exit absorbing mask for the right upper corner*/
nru18=h1u8-mru18*(-w1r8);

mrd18=(-h1dwt8+h1d8)/(w1r8-w1rwt8);										/* calculation for entrance and exit absorbing mask for the right lower corner*/
nrd18=-h1d8-mrd18*(-w1r8);

mlu18=(h1uwt8-h1u8)/(-w1l8+w1lwt8);										/* calculation for entrance and exit absorbing mask for the left upper corner*/
nlu18=h1u8-mlu18*w1l8;

mld18=(-h1dwt8+h1d8)/(-w1l8+w1lwt8);										/* calculation for entrance and exit absorbing mask for the left lower corner*/
nld18=-h1d8-mld18*w1l8;


mru28=(h2u8-h2uwt8)/(-w2r8+w2rwt8);										/* calculation for exit absorbing mask for the right upper corner*/
nru28=h2u8-mru28*(-w2r8);

mrd28=(-h2d8+h2dwt8)/(-w2r8+w2rwt8);										/* calculation for exit absorbing mask for the right lower corner*/
nrd28=-h2d8-mrd28*(-w2r8);

mlu28=(h2u8-h2uwt8)/(w2l8-w2lwt8);										/* calculation for exit absorbing mask for the left upper corner*/
nlu28=h2u8-mlu28*w2l8;

mld28=(h2dwt8-h2d8)/(w2l8-w2lwt8);										/* calculation for exit absorbing mask for the left lower corner*/
nld28=-h2d8-mld28*w2l8;


if (w1r8 < w1rwt7 ) TEST_INPUT_4("w1r8", "w1rwt7", w1r8, w1rwt7);

if (w1l8 < w1lwt7 ) TEST_INPUT_4("w1l8", "w1lwt7", w1l8, w1lwt7);

if (h1u8 < h1uwt7 ) TEST_INPUT_4("h1u8", "h1uwt7", h1u8, h1uwt7);

if (h1d8 < h1dwt7 ) TEST_INPUT_4("h1d8", "h1dwt7", h1d8, h1dwt7);

if (w2r8 < w2rwt7 ) TEST_INPUT_4("w2r8", "w2rwt7", w2r8, w2rwt7);

if (w2l8 < w2lwt7 ) TEST_INPUT_4("w2l8", "w2lwt7", w2l8, w2lwt7);

if (h2u8 < h2uwt7 ) TEST_INPUT_4("h2u8", "h2uwt7", h2u8, h2uwt7);

if (h2d8 < h2dwt7 ) TEST_INPUT_4("h2d8", "h2dwt7", h2d8, h2dwt7);


/* NINETH SHELL */


if(loutwr9!=0 && linwr9!=0)										/* elliptic right side wall */
   { 
     ELLIPSE(w1r9, l, linwr9, loutwr9, rwallthick9, &awr9, &bwr9, &a2wr9, &b2wr9, &z0wr9, &w2r9, &awrwt9, &a2wrwt9, &bwrwt9, &b2wrwt9, &w2rwt9, &w1rwt9);
   }


if(linwr9==0 && loutwr9!=0)										/* parabolic focusing right side wall */
   {
     PARABEL_FOCUS( w1r9,l ,loutwr9, rwallthick9, &p2parawr9, &w2r9, &pbwr9 , &pawr9, &p2parawrwt9, &pbwrwt9, &pawrwt9, &w2rwt9, &w1rwt9);
   }

if (linwr9!=0 && loutwr9==0)										/* parabolic defocusing right side wall  */
    {
      PARABEL_DEFOCUS( w1r9,l ,linwr9, rwallthick9, &p2parawr9, &w2r9, &pbwr9 , &pawr9, &p2parawrwt9, &pbwrwt9, &pawrwt9, &w2rwt9, &w1rwt9);
    }

if(linwr9==0 && loutwr9==0)										/* straight right side wall */
    {
      LINEAR(w1r9, w2r9, l, rwallthick9, &w1rwt9, &w2rwt9);
    }


													/* Calculation of curve-parameters for the left side wall - positive x-axis - analog to right side*/

if((linwl9!=0) && (loutwl9!=0) ) 										/* elleptic left side wall */
  { 
    ELLIPSE(w1l9, l, linwl9, loutwl9, lwallthick9, &awl9, &bwl9, &a2wl9, &b2wl9, &z0wl9, &w2l9, &awlwt9, &a2wlwt9, &bwlwt9, &b2wlwt9, &w2lwt9, &w1lwt9);
   }

if(linwl9==0 && loutwl9!=0)										/* parabolic focusing left side wall */
   {
     PARABEL_FOCUS( w1l9,l ,loutwl9, lwallthick9, &p2parawl9, &w2l9, &pbwl9 , &pawl9, &p2parawlwt9, &pbwlwt9, &pawlwt9, &w2lwt9, &w1lwt9);
   }

if (linwl9!=0 && loutwl9==0)										/* parabolic defocusing left side wall  */
    {
      PARABEL_DEFOCUS( w1l9,l ,linwl9, lwallthick9, &p2parawl9, &w2l9, &pbwl9 , &pawl9, &p2parawlwt9, &pbwlwt9, &pawlwt9, &w2lwt9, &w1lwt9);
    }

if(linwl9==0 && loutwl9==0)										/* straight left side wall */
    {
      LINEAR(w1l9, w2l9, l, lwallthick9, &w1lwt9, &w2lwt9);
    }


													/* Calculation of curve-parameters for the top wall - positive y-axis - analog  right wall*/


if (linhu9 != 0 && louthu9 !=0)										/* elliptic top wall */
    {
      ELLIPSE(h1u9, l, linhu9, louthu9, uwallthick9, &ahu9, &bhu9, &a2hu9, &b2hu9, &z0hu9 , &h2u9, &ahuwt9, &a2huwt9, &bhuwt9, &b2huwt9, &h2uwt9, &h1uwt9); 
    }

if(linhu9==0 && louthu9!=0)										/* parabolic focusing top wall */
    { 	
      PARABEL_FOCUS( h1u9,l ,louthu9, uwallthick9, &p2parahu9, &h2u9, &pbhu9 , &pahu9, &p2parahuwt9, &pbhuwt9, &pahuwt9, &h2uwt9, &h1uwt9);
    } 

if (linhu9!=0 && louthu9==0)										/* parabolic defocusing top wall */
    {
      PARABEL_DEFOCUS( h1u9,l ,linhu9, uwallthick9, &p2parahu9, &h2u9, &pbhu9 , &pahu9, &p2parahuwt9, &pbhuwt9, &pahuwt9, &h2uwt9, &h1uwt9);
    }

if(linhu9==0 && louthu9==0)
    {
      LINEAR(h1u9, h2u9, l, uwallthick9, &h1uwt9, &h2uwt9);
    }


													/* Calculation of curve-parameters for the bottom wall - negative y-axis - analog right wall */

if (linhd9 != 0 && louthd9 !=0)										/* elliptic bottom wall */
    {
      ELLIPSE(h1d9, l, linhd9, louthd9, dwallthick9, &ahd9, &bhd9, &a2hd9, &b2hd9, &z0hd9 , &h2d9, &ahdwt9, &a2hdwt9, &bhdwt9, &b2hdwt9, &h2dwt9, &h1dwt9);
    }

if(linhd9==0 && louthd9!=0)										/* parabolic focusing bottom wall */
   {	
     PARABEL_FOCUS( h1d9,l ,louthd9, dwallthick9, &p2parahd9, &h2d9, &pbhd9 , &pahd9, &p2parahdwt9, &pbhdwt9, &pahdwt9, &h2dwt9, &h1dwt9);
   }

if (linhd9!=0 && louthd9==0)										/* parabolic defocusing bottom wall */
    {
      PARABEL_DEFOCUS( h1d9,l ,linhd9, dwallthick9, &p2parahd9, &h2d9, &pbhd9 , &pahd9, &p2parahdwt9, &pbhdwt9, &pahdwt9, &h2dwt9, &h1dwt9);
    }

if(linhd9==0 && louthd9==0)
    {
      LINEAR(h1d9, h2d9, l, dwallthick9, &h1dwt9, &h2dwt9);
    }



mru19=(h1uwt9-h1u9)/(w1r9-w1rwt9);										/* calculation for entrance and exit absorbing mask for the right upper corner*/
nru19=h1u9-mru19*(-w1r9);

mrd19=(-h1dwt9+h1d9)/(w1r9-w1rwt9);										/* calculation for entrance and exit absorbing mask for the right lower corner*/
nrd19=-h1d9-mrd19*(-w1r9);

mlu19=(h1uwt9-h1u9)/(-w1l9+w1lwt9);										/* calculation for entrance and exit absorbing mask for the left upper corner*/
nlu19=h1u9-mlu19*w1l9;

mld19=(-h1dwt9+h1d9)/(-w1l9+w1lwt9);										/* calculation for entrance and exit absorbing mask for the left lower corner*/
nld19=-h1d9-mld19*w1l9;


mru29=(h2u9-h2uwt9)/(-w2r9+w2rwt9);										/* calculation for exit absorbing mask for the right upper corner*/
nru29=h2u9-mru29*(-w2r9);

mrd29=(-h2d9+h2dwt9)/(-w2r9+w2rwt9);										/* calculation for exit absorbing mask for the right lower corner*/
nrd29=-h2d9-mrd29*(-w2r9);

mlu29=(h2u9-h2uwt9)/(w2l9-w2lwt9);										/* calculation for exit absorbing mask for the left upper corner*/
nlu29=h2u9-mlu29*w2l9;

mld29=(h2dwt9-h2d9)/(w2l9-w2lwt9);										/* calculation for exit absorbing mask for the left lower corner*/
nld29=-h2d9-mld29*w2l9;


if (w1r9 < w1rwt8 ) TEST_INPUT_4("w1r9", "w1rwt8", w1r9, w1rwt8);

if (w1l9 < w1lwt8 ) TEST_INPUT_4("w1l9", "w1lwt8", w1l9, w1lwt8);

if (h1u9 < h1uwt8 ) TEST_INPUT_4("h1u9", "h1uwt8", h1u9, h1uwt8);

if (h1d9 < h1dwt8 ) TEST_INPUT_4("h1d9", "h1dwt8", h1d9, h1dwt8);

if (w2r9 < w2rwt8 ) TEST_INPUT_4("w2r9", "w2rwt8", w2r9, w2rwt8);

if (w2l9 < w2lwt8 ) TEST_INPUT_4("w2l9", "w2lwt8", w2l9, w2lwt8);

if (h2u9 < h2uwt8 ) TEST_INPUT_4("h2u9", "h2uwt8", h2u9, h2uwt8);

if (h2d9 < h2dwt8 ) TEST_INPUT_4("h2d9", "h2dwt8", h2d9, h2dwt8);

/* TENTH SHELL */

if(loutwr10!=0 && linwr10!=0)										/* elliptic right side wall */
   { 
     ELLIPSE(w1r10, l, linwr10, loutwr10, rwallthick10, &awr10, &bwr10, &a2wr10, &b2wr10, &z0wr10, &w2r10, &awrwt10, &a2wrwt10, &bwrwt10, &b2wrwt10, &w2rwt10, &w1rwt10);
   }


if(linwr10==0 && loutwr10!=0)										/* parabolic focusing right side wall */
   {
     PARABEL_FOCUS( w1r10,l ,loutwr10, rwallthick10, &p2parawr10, &w2r10, &pbwr10 , &pawr10, &p2parawrwt10, &pbwrwt10, &pawrwt10, &w2rwt10, &w1rwt10);
   }

if (linwr10!=0 && loutwr10==0)										/* parabolic defocusing right side wall  */
    {
      PARABEL_DEFOCUS( w1r10,l ,linwr10, rwallthick10, &p2parawr10, &w2r10, &pbwr10 , &pawr10, &p2parawrwt10, &pbwrwt10, &pawrwt10, &w2rwt10, &w1rwt10);
    }

if(linwr10==0 && loutwr10==0)										/* straight right side wall */
    {
      LINEAR(w1r10, w2r10, l, rwallthick10, &w1rwt10, &w2rwt10);
    }


													/* Calculation of curve-parameters for the left side wall - positive x-axis - analog to right side*/

if((linwl10!=0) && (loutwl10!=0) ) 										/* elleptic left side wall */
  { 
    ELLIPSE(w1l10, l, linwl10, loutwl10, lwallthick10, &awl10, &bwl10, &a2wl10, &b2wl10, &z0wl10, &w2l10, &awlwt10, &a2wlwt10, &bwlwt10, &b2wlwt10, &w2lwt10, &w1lwt10);
   }

if(linwl10==0 && loutwl10!=0)										/* parabolic focusing left side wall */
   {
     PARABEL_FOCUS( w1l10,l ,loutwl10, lwallthick10, &p2parawl10, &w2l10, &pbwl10 , &pawl10, &p2parawlwt10, &pbwlwt10, &pawlwt10, &w2lwt10, &w1lwt10);
   }

if (linwl10!=0 && loutwl10==0)										/* parabolic defocusing left side wall  */
    {
      PARABEL_DEFOCUS( w1l10,l ,linwl10, lwallthick10, &p2parawl10, &w2l10, &pbwl10 , &pawl10, &p2parawlwt10, &pbwlwt10, &pawlwt10, &w2lwt10, &w1lwt10);
    }

if(linwl10==0 && loutwl10==0)										/* straight left side wall */
    {
      LINEAR(w1l10, w2l10, l, lwallthick10, &w1lwt10, &w2lwt10);
    }


													/* Calculation of curve-parameters for the top wall - positive y-axis - analog  right wall*/


if (linhu10 != 0 && louthu10 !=0)										/* elliptic top wall */
    {
      ELLIPSE(h1u10, l, linhu10, louthu10, uwallthick10, &ahu10, &bhu10, &a2hu10, &b2hu10, &z0hu10 , &h2u10, &ahuwt10, &a2huwt10, &bhuwt10, &b2huwt10, &h2uwt10, &h1uwt10); 
    }

if(linhu10==0 && louthu10!=0)										/* parabolic focusing top wall */
    { 	
      PARABEL_FOCUS( h1u10,l ,louthu10, uwallthick10, &p2parahu10, &h2u10, &pbhu10 , &pahu10, &p2parahuwt10, &pbhuwt10, &pahuwt10, &h2uwt10, &h1uwt10);
    } 

if (linhu10!=0 && louthu10==0)										/* parabolic defocusing top wall */
    {
      PARABEL_DEFOCUS( h1u10,l ,linhu10, uwallthick10, &p2parahu10, &h2u10, &pbhu10 , &pahu10, &p2parahuwt10, &pbhuwt10, &pahuwt10, &h2uwt10, &h1uwt10);
    }

if(linhu10==0 && louthu10==0)
    {
      LINEAR(h1u10, h2u10, l, uwallthick10, &h1uwt10, &h2uwt10);
    }


													/* Calculation of curve-parameters for the bottom wall - negative y-axis - analog right wall */

if (linhd10 != 0 && louthd10 !=0)										/* elliptic bottom wall */
    {
      ELLIPSE(h1d10, l, linhd10, louthd10, dwallthick10, &ahd10, &bhd10, &a2hd10, &b2hd10, &z0hd10 , &h2d10, &ahdwt10, &a2hdwt10, &bhdwt10, &b2hdwt10, &h2dwt10, &h1dwt10);
    }

if(linhd10==0 && louthd10!=0)										/* parabolic focusing bottom wall */
   {	
     PARABEL_FOCUS( h1d10,l ,louthd10, dwallthick10, &p2parahd10, &h2d10, &pbhd10 , &pahd10, &p2parahdwt10, &pbhdwt10, &pahdwt10, &h2dwt10, &h1dwt10);
   }

if (linhd10!=0 && louthd10==0)										/* parabolic defocusing bottom wall */
    {
      PARABEL_DEFOCUS( h1d10,l ,linhd10, dwallthick10, &p2parahd10, &h2d10, &pbhd10 , &pahd10, &p2parahdwt10, &pbhdwt10, &pahdwt10, &h2dwt10, &h1dwt10);
    }

if(linhd10==0 && louthd10==0)
    {
      LINEAR(h1d10, h2d10, l, dwallthick10, &h1dwt10, &h2dwt10);
    }



mru110=(h1uwt10-h1u10)/(w1r10-w1rwt10);										/* calculation for entrance and exit absorbing mask for the right upper corner*/
nru110=h1u10-mru110*(-w1r10);

mrd110=(-h1dwt10+h1d10)/(w1r10-w1rwt10);										/* calculation for entrance and exit absorbing mask for the right lower corner*/
nrd110=-h1d10-mrd110*(-w1r10);

mlu110=(h1uwt10-h1u10)/(-w1l10+w1lwt10);										/* calculation for entrance and exit absorbing mask for the left upper corner*/
nlu110=h1u10-mlu110*w1l10;

mld110=(-h1dwt10+h1d10)/(-w1l10+w1lwt10);										/* calculation for entrance and exit absorbing mask for the left lower corner*/
nld110=-h1d10-mld110*w1l10;


mru210=(h2u10-h2uwt10)/(-w2r10+w2rwt10);										/* calculation for exit absorbing mask for the right upper corner*/
nru210=h2u10-mru210*(-w2r10);

mrd210=(-h2d10+h2dwt10)/(-w2r10+w2rwt10);										/* calculation for exit absorbing mask for the right lower corner*/
nrd210=-h2d10-mrd210*(-w2r10);

mlu210=(h2u10-h2uwt10)/(w2l10-w2lwt10);										/* calculation for exit absorbing mask for the left upper corner*/
nlu210=h2u10-mlu210*w2l10;

mld210=(h2dwt10-h2d10)/(w2l10-w2lwt10);										/* calculation for exit absorbing mask for the left lower corner*/
nld210=-h2d10-mld210*w2l10;


if (w1r10 < w1rwt9 ) TEST_INPUT_4("w1r10", "w1rwt9", w1r10, w1rwt9);

if (w1l10 < w1lwt9 ) TEST_INPUT_4("w1l10", "w1lwt9", w1l10, w1lwt9);

if (h1u10 < h1uwt9 ) TEST_INPUT_4("h1u10", "h1uwt9", h1u10, h1uwt9);

if (h1d10 < h1dwt9 ) TEST_INPUT_4("h1d10", "h1dwt9", h1d10, h1dwt9);

if (w2r10 < w2rwt9 ) TEST_INPUT_4("w2r10", "w2rwt9", w2r10, w2rwt9);

if (w2l10 < w2lwt9 ) TEST_INPUT_4("w2l10", "w2lwt9", w2l10, w2lwt9);

if (h2u10 < h2uwt9 ) TEST_INPUT_4("h2u10", "h2uwt9", h2u10, h2uwt9);

if (h2d10 < h2dwt9 ) TEST_INPUT_4("h2d10", "h2dwt9", h2d10, h2dwt9);


%}



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; 

    if(x <= -w1r3 && x >= -w1rwt3 && y <= mru13*x+nru13 && y>= mrd13*x+nrd13 && mxr3!=-1 && mxrOW3!=-1)
      ABSORB;
  if(x >= w1l3 && x <=  w1lwt3 && y <= mlu13*x+nlu13 && y>= mld13*x+nld13 && mxl3!=-1 && mxlOW3!=-1 )
      ABSORB;
  if(y<=-h1d3 && y >=-h1dwt3 && x <= (y-nld13)/mld13 && x>= (y-nrd13)/mrd13 && myd3!=-1 && mydOW3!=-1)
      ABSORB;
  if(y>=h1u3 && y <= h1uwt3 && x <= (y-nlu13)/mlu13 && x>= (y-nru13)/mru13 && myu3!=-1 && myuOW3!=-1)
    ABSORB;

if(x <= -w1r4 && x >= -w1rwt4 && y <= mru14*x+nru14 && y>= mrd14*x+nrd14 && mxr4!=-1 && mxrOW4!=-1)
      ABSORB;
  if(x >= w1l4 && x <=  w1lwt4 && y <= mlu14*x+nlu14 && y>= mld14*x+nld14 && mxl4!=-1 && mxlOW4!=-1 )
      ABSORB;
  if(y<=-h1d4 && y >=-h1dwt4 && x <= (y-nld14)/mld14 && x>= (y-nrd14)/mrd14 && myd4!=-1 && mydOW4!=-1)
      ABSORB;
  if(y>=h1u4 && y <= h1uwt4 && x <= (y-nlu14)/mlu14 && x>= (y-nru14)/mru13 && myu4!=-1 && myuOW4!=-1)
    ABSORB;

  if(x <= -w1r5 && x >= -w1rwt5 && y <= mru15*x+nru15 && y>= mrd15*x+nrd15 && mxr5!=-1 && mxrOW5!=-1)
      ABSORB;
  if(x >= w1l5 && x <=  w1lwt5 && y <= mlu15*x+nlu15 && y>= mld15*x+nld15 && mxl5!=-1 && mxlOW5!=-1 )
      ABSORB;
  if(y<=-h1d5 && y >=-h1dwt5 && x <= (y-nld15)/mld15 && x>= (y-nrd15)/mrd15 && myd5!=-1 && mydOW5!=-1)
      ABSORB;
  if(y>=h1u5 && y <= h1uwt5 && x <= (y-nlu15)/mlu15 && x>= (y-nru15)/mru15 && myu5!=-1 && myuOW5!=-1)
    ABSORB; 

  if(x <= -w1r6 && x >= -w1rwt6 && y <= mru16*x+nru16 && y>= mrd16*x+nrd16 && mxr6!=-1 && mxrOW6!=-1)
      ABSORB;
  if(x >= w1l6 && x <=  w1lwt6 && y <= mlu16*x+nlu16 && y>= mld16*x+nld16 && mxl6!=-1 && mxlOW6!=-1 )
      ABSORB;
  if(y<=-h1d6 && y >=-h1dwt6 && x <= (y-nld16)/mld16 && x>= (y-nrd16)/mrd16 && myd6!=-1 && mydOW6!=-1)
      ABSORB;
  if(y>=h1u6 && y <= h1uwt6 && x <= (y-nlu16)/mlu16 && x>= (y-nru16)/mru16 && myu6!=-1 && myuOW6!=-1)
    ABSORB; 

  if(x <= -w1r7 && x >= -w1rwt7 && y <= mru17*x+nru17 && y>= mrd17*x+nrd17 && mxr7!=-1 && mxrOW7!=-1)
      ABSORB;
  if(x >= w1l7 && x <=  w1lwt7 && y <= mlu17*x+nlu17 && y>= mld17*x+nld17 && mxl7!=-1 && mxlOW7!=-1 )
      ABSORB;
  if(y<=-h1d7 && y >=-h1dwt7 && x <= (y-nld17)/mld17 && x>= (y-nrd17)/mrd17 && myd7!=-1 && mydOW7!=-1)
      ABSORB;
  if(y>=h1u7 && y <= h1uwt7 && x <= (y-nlu17)/mlu17 && x>= (y-nru17)/mru17 && myu7!=-1 && myuOW7!=-1)
    ABSORB; 

  if(x <= -w1r8 && x >= -w1rwt8 && y <= mru18*x+nru18 && y>= mrd18*x+nrd18 && mxr8!=-1 && mxrOW8!=-1)
      ABSORB;
  if(x >= w1l8 && x <=  w1lwt8 && y <= mlu18*x+nlu18 && y>= mld18*x+nld18 && mxl8!=-1 && mxlOW8!=-1 )
      ABSORB;
  if(y<=-h1d8 && y >=-h1dwt8 && x <= (y-nld18)/mld18 && x>= (y-nrd18)/mrd18 && myd8!=-1 && mydOW8!=-1)
      ABSORB;
  if(y>=h1u8 && y <= h1uwt8 && x <= (y-nlu18)/mlu18 && x>= (y-nru18)/mru18 && myu8!=-1 && myuOW8!=-1)
    ABSORB; 

  if(x <= -w1r9 && x >= -w1rwt9 && y <= mru19*x+nru19 && y>= mrd19*x+nrd19 && mxr9!=-1 && mxrOW9!=-1)
      ABSORB;
  if(x >= w1l9 && x <=  w1lwt9 && y <= mlu19*x+nlu19 && y>= mld19*x+nld19 && mxl9!=-1 && mxlOW9!=-1 )
      ABSORB;
  if(y<=-h1d9 && y >=-h1dwt9 && x <= (y-nld19)/mld19 && x>= (y-nrd19)/mrd19 && myd9!=-1 && mydOW9!=-1)
      ABSORB;
  if(y>=h1u9 && y <= h1uwt9 && x <= (y-nlu19)/mlu19 && x>= (y-nru19)/mru19 && myu9!=-1 && myuOW9!=-1)
    ABSORB; 

  if(x <= -w1r10 && x >= -w1rwt10 && y <= mru110*x+nru110 && y>= mrd110*x+nrd110 && mxr10!=-1 && mxrOW10!=-1)
      ABSORB;
  if(x >= w1l10 && x <=  w1lwt10 && y <= mlu110*x+nlu110 && y>= mld110*x+nld110 && mxl10!=-1 && mxlOW10!=-1 )
      ABSORB;
  if(y<=-h1d10 && y >=-h1dwt10 && x <= (y-nld110)/mld110 && x>= (y-nrd110)/mrd110 && myd10!=-1 && mydOW10!=-1)
      ABSORB;
  if(y>=h1u10 && y <= h1uwt10 && x <= (y-nlu110)/mlu110 && x>= (y-nru110)/mru110 && myu10!=-1 && myuOW10!=-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);
    }

/* THIRD SHELL */

if(loutwr3==0 && linwr3==0)							
    {
      TIME_LINEAR(t1, w1r3, w2r3, l, x, z, vx, vz, w1rwt3, &t2w1r3, &t2w1rwt3); 
    }

  if(loutwr3!=0 && linwr3!=0)							
    { 										
      TIME_ELLIPSE(vx, vz, x, z, a2wr3, b2wr3, z0wr3, t1, a2wrwt3, b2wrwt3, &t2w1r3, &t2w1rwt3);
    }

  if((loutwr3!=0 && linwr3==0)|| (loutwr3==0 && linwr3!=0))				
    {										
      TIME_PARABEL(vx, vz, x, z, pawr3, pbwr3, t1, pawrwt3, pbwrwt3, &t2w1r3, &t2w1rwt3);
    }


  if(loutwl3==0 && linwl3==0)
    {
      TIME_LINEAR_1(t1, w1l3, w2l3, l, x, z, vx, vz, w1lwt3, &t2w1l3, &t2w1lwt3); 
    }

  if(loutwl3!=0 && linwl3!=0)
    { 
      TIME_ELLIPSE_1(vx, vz, x, z, a2wl3, b2wl3, z0wl3, t1, a2wlwt3, b2wlwt3, &t2w1l3, &t2w1lwt3);
    }


  if((loutwl3!=0 && linwl3==0) || (loutwl3==0 && linwl3!=0))
    {
      TIME_PARABEL_1(vx, vz, x, z, pawl3, pbwl3, t1, pawlwt3, pbwlwt3, &t2w1l3, &t2w1lwt3);
    }


  if(louthu3==0 && linhu3==0)							
    {
      TIME_LINEAR_1(t1, h1u3, h2u3, l, y, z, vy, vz, h1uwt3, &t2h1u3, &t2h1uwt3); 
    }


  if(louthu3!=0 && linhu3!=0)
    { 
      TIME_ELLIPSE_1(vy, vz, y, z, a2hu3, b2hu3, z0hu3, t1, a2huwt3, b2huwt3, &t2h1u3, &t2h1uwt3);
    }


  if((louthu3!=0 && linhu3==0)|| (louthu3==0 && linhu3!=0))
    {
      TIME_PARABEL_1(vy, vz, y, z, pahu3, pbhu3, t1, pahuwt3, pbhuwt3, &t2h1u3, &t2h1uwt3);
    }


  if(louthd3==0 && linhd3==0)							
    {
      TIME_LINEAR(t1, h1d3, h2d3, l, y, z, vy, vz, h1dwt3, &t2h1d3, &t2h1dwt3); 
    }

  if(louthd3!=0 && linhd3!=0)
    { 										
      TIME_ELLIPSE(vy, vz, y, z, a2hd3, b2hd3, z0hd3, t1, a2hdwt3, b2hdwt3, &t2h1d3, &t2h1dwt3);
    }

  if((louthd3!=0 && linhd3==0)|| (louthd3==0 && linhd3!=0))
    {
      TIME_PARABEL(vy, vz, y, z, pahd3, pbhd3, t1, pahdwt3, pbhdwt3, &t2h1d3, &t2h1dwt3);
    }

/* FOURTH SHELL */

if(loutwr4==0 && linwr4==0)							
    {
      TIME_LINEAR(t1, w1r4, w2r4, l, x, z, vx, vz, w1rwt4, &t2w1r4, &t2w1rwt4); 
    }

  if(loutwr4!=0 && linwr4!=0)							
    { 										
      TIME_ELLIPSE(vx, vz, x, z, a2wr4, b2wr4, z0wr4, t1, a2wrwt4, b2wrwt4, &t2w1r4, &t2w1rwt4);
    }

  if((loutwr4!=0 && linwr4==0)|| (loutwr4==0 && linwr4!=0))				
    {										
      TIME_PARABEL(vx, vz, x, z, pawr4, pbwr4, t1, pawrwt4, pbwrwt4, &t2w1r4, &t2w1rwt4);
    }


  if(loutwl4==0 && linwl4==0)
    {
      TIME_LINEAR_1(t1, w1l4, w2l4, l, x, z, vx, vz, w1lwt4, &t2w1l4, &t2w1lwt4); 
    }

  if(loutwl4!=0 && linwl4!=0)
    { 
      TIME_ELLIPSE_1(vx, vz, x, z, a2wl4, b2wl4, z0wl4, t1, a2wlwt4, b2wlwt4, &t2w1l4, &t2w1lwt4);
    }


  if((loutwl4!=0 && linwl4==0) || (loutwl4==0 && linwl4!=0))
    {
      TIME_PARABEL_1(vx, vz, x, z, pawl4, pbwl4, t1, pawlwt4, pbwlwt4, &t2w1l4, &t2w1lwt4);
    }


  if(louthu4==0 && linhu4==0)							
    {
      TIME_LINEAR_1(t1, h1u4, h2u4, l, y, z, vy, vz, h1uwt4, &t2h1u4, &t2h1uwt4); 
    }


  if(louthu4!=0 && linhu4!=0)
    { 
      TIME_ELLIPSE_1(vy, vz, y, z, a2hu4, b2hu4, z0hu4, t1, a2huwt4, b2huwt4, &t2h1u4, &t2h1uwt4);
    }


  if((louthu4!=0 && linhu4==0)|| (louthu4==0 && linhu4!=0))
    {
      TIME_PARABEL_1(vy, vz, y, z, pahu4, pbhu4, t1, pahuwt4, pbhuwt4, &t2h1u4, &t2h1uwt4);
    }


  if(louthd4==0 && linhd4==0)							
    {
      TIME_LINEAR(t1, h1d4, h2d4, l, y, z, vy, vz, h1dwt4, &t2h1d4, &t2h1dwt4); 
    }

  if(louthd4!=0 && linhd4!=0)
    { 										
      TIME_ELLIPSE(vy, vz, y, z, a2hd4, b2hd4, z0hd4, t1, a2hdwt4, b2hdwt4, &t2h1d4, &t2h1dwt4);
    }

  if((louthd4!=0 && linhd4==0)|| (louthd4==0 && linhd4!=0))
    {
      TIME_PARABEL(vy, vz, y, z, pahd4, pbhd4, t1, pahdwt4, pbhdwt4, &t2h1d4, &t2h1dwt4);
    }

/* FIFTH SHELL */


if(loutwr5==0 && linwr5==0)							
    {
      TIME_LINEAR(t1, w1r5, w2r5, l, x, z, vx, vz, w1rwt5, &t2w1r5, &t2w1rwt5); 
    }

  if(loutwr5!=0 && linwr5!=0)							
    { 										
      TIME_ELLIPSE(vx, vz, x, z, a2wr5, b2wr5, z0wr5, t1, a2wrwt5, b2wrwt5, &t2w1r5, &t2w1rwt5);
    }

  if((loutwr5!=0 && linwr5==0)|| (loutwr5==0 && linwr5!=0))				
    {										
      TIME_PARABEL(vx, vz, x, z, pawr5, pbwr5, t1, pawrwt5, pbwrwt5, &t2w1r5, &t2w1rwt5);
    }


  if(loutwl5==0 && linwl5==0)
    {
      TIME_LINEAR_1(t1, w1l5, w2l5, l, x, z, vx, vz, w1lwt5, &t2w1l5, &t2w1lwt5); 
    }

  if(loutwl5!=0 && linwl5!=0)
    { 
      TIME_ELLIPSE_1(vx, vz, x, z, a2wl5, b2wl5, z0wl5, t1, a2wlwt5, b2wlwt5, &t2w1l5, &t2w1lwt5);
    }


  if((loutwl5!=0 && linwl5==0) || (loutwl5==0 && linwl5!=0))
    {
      TIME_PARABEL_1(vx, vz, x, z, pawl5, pbwl5, t1, pawlwt5, pbwlwt5, &t2w1l5, &t2w1lwt5);
    }


  if(louthu5==0 && linhu5==0)							
    {
      TIME_LINEAR_1(t1, h1u5, h2u5, l, y, z, vy, vz, h1uwt5, &t2h1u5, &t2h1uwt5); 
    }


  if(louthu5!=0 && linhu5!=0)
    { 
      TIME_ELLIPSE_1(vy, vz, y, z, a2hu5, b2hu5, z0hu5, t1, a2huwt5, b2huwt5, &t2h1u5, &t2h1uwt5);
    }


  if((louthu5!=0 && linhu5==0)|| (louthu5==0 && linhu5!=0))
    {
      TIME_PARABEL_1(vy, vz, y, z, pahu5, pbhu5, t1, pahuwt5, pbhuwt5, &t2h1u5, &t2h1uwt5);
    }


  if(louthd5==0 && linhd5==0)							
    {
      TIME_LINEAR(t1, h1d5, h2d5, l, y, z, vy, vz, h1dwt5, &t2h1d5, &t2h1dwt5); 
    }

  if(louthd5!=0 && linhd5!=0)
    { 										
      TIME_ELLIPSE(vy, vz, y, z, a2hd5, b2hd5, z0hd5, t1, a2hdwt5, b2hdwt5, &t2h1d5, &t2h1dwt5);
    }

  if((louthd5!=0 && linhd5==0)|| (louthd5==0 && linhd5!=0))
    {
      TIME_PARABEL(vy, vz, y, z, pahd5, pbhd5, t1, pahdwt5, pbhdwt5, &t2h1d5, &t2h1dwt5);
    }

/* SIXTH SHELL */

if(loutwr6==0 && linwr6==0)							
    {
      TIME_LINEAR(t1, w1r6, w2r6, l, x, z, vx, vz, w1rwt6, &t2w1r6, &t2w1rwt6); 
    }

  if(loutwr6!=0 && linwr6!=0)							
    { 										
      TIME_ELLIPSE(vx, vz, x, z, a2wr6, b2wr6, z0wr6, t1, a2wrwt6, b2wrwt6, &t2w1r6, &t2w1rwt6);
    }

  if((loutwr6!=0 && linwr6==0)|| (loutwr6==0 && linwr6!=0))				
    {										
      TIME_PARABEL(vx, vz, x, z, pawr6, pbwr6, t1, pawrwt6, pbwrwt6, &t2w1r6, &t2w1rwt6);
    }


  if(loutwl6==0 && linwl6==0)
    {
      TIME_LINEAR_1(t1, w1l6, w2l6, l, x, z, vx, vz, w1lwt6, &t2w1l6, &t2w1lwt6); 
    }

  if(loutwl6!=0 && linwl6!=0)
    { 
      TIME_ELLIPSE_1(vx, vz, x, z, a2wl6, b2wl6, z0wl6, t1, a2wlwt6, b2wlwt6, &t2w1l6, &t2w1lwt6);
    }


  if((loutwl6!=0 && linwl6==0) || (loutwl6==0 && linwl6!=0))
    {
      TIME_PARABEL_1(vx, vz, x, z, pawl6, pbwl6, t1, pawlwt6, pbwlwt6, &t2w1l6, &t2w1lwt6);
    }


  if(louthu6==0 && linhu6==0)							
    {
      TIME_LINEAR_1(t1, h1u6, h2u6, l, y, z, vy, vz, h1uwt6, &t2h1u6, &t2h1uwt6); 
    }


  if(louthu6!=0 && linhu6!=0)
    { 
      TIME_ELLIPSE_1(vy, vz, y, z, a2hu6, b2hu6, z0hu6, t1, a2huwt6, b2huwt6, &t2h1u6, &t2h1uwt6);
    }


  if((louthu6!=0 && linhu6==0)|| (louthu6==0 && linhu6!=0))
    {
      TIME_PARABEL_1(vy, vz, y, z, pahu6, pbhu6, t1, pahuwt6, pbhuwt6, &t2h1u6, &t2h1uwt6);
    }


  if(louthd6==0 && linhd6==0)							
    {
      TIME_LINEAR(t1, h1d6, h2d6, l, y, z, vy, vz, h1dwt6, &t2h1d6, &t2h1dwt6); 
    }

  if(louthd6!=0 && linhd6!=0)
    { 										
      TIME_ELLIPSE(vy, vz, y, z, a2hd6, b2hd6, z0hd6, t1, a2hdwt6, b2hdwt6, &t2h1d6, &t2h1dwt6);
    }

  if((louthd6!=0 && linhd6==0)|| (louthd6==0 && linhd6!=0))
    {
      TIME_PARABEL(vy, vz, y, z, pahd6, pbhd6, t1, pahdwt6, pbhdwt6, &t2h1d6, &t2h1dwt6);
    }

/* SEVENTH SHELL */

if(loutwr7==0 && linwr7==0)							
    {
      TIME_LINEAR(t1, w1r7, w2r7, l, x, z, vx, vz, w1rwt7, &t2w1r7, &t2w1rwt7); 
    }

  if(loutwr7!=0 && linwr7!=0)							
    { 										
      TIME_ELLIPSE(vx, vz, x, z, a2wr7, b2wr7, z0wr7, t1, a2wrwt7, b2wrwt7, &t2w1r7, &t2w1rwt7);
    }

  if((loutwr7!=0 && linwr7==0)|| (loutwr7==0 && linwr7!=0))				
    {										
      TIME_PARABEL(vx, vz, x, z, pawr7, pbwr7, t1, pawrwt7, pbwrwt7, &t2w1r7, &t2w1rwt7);
    }


  if(loutwl7==0 && linwl7==0)
    {
      TIME_LINEAR_1(t1, w1l7, w2l7, l, x, z, vx, vz, w1lwt7, &t2w1l7, &t2w1lwt7); 
    }

  if(loutwl7!=0 && linwl7!=0)
    { 
      TIME_ELLIPSE_1(vx, vz, x, z, a2wl7, b2wl7, z0wl7, t1, a2wlwt7, b2wlwt7, &t2w1l7, &t2w1lwt7);
    }


  if((loutwl7!=0 && linwl7==0) || (loutwl7==0 && linwl7!=0))
    {
      TIME_PARABEL_1(vx, vz, x, z, pawl7, pbwl7, t1, pawlwt7, pbwlwt7, &t2w1l7, &t2w1lwt7);
    }


  if(louthu7==0 && linhu7==0)							
    {
      TIME_LINEAR_1(t1, h1u7, h2u7, l, y, z, vy, vz, h1uwt7, &t2h1u7, &t2h1uwt7); 
    }


  if(louthu7!=0 && linhu7!=0)
    { 
      TIME_ELLIPSE_1(vy, vz, y, z, a2hu7, b2hu7, z0hu7, t1, a2huwt7, b2huwt7, &t2h1u7, &t2h1uwt7);
    }


  if((louthu7!=0 && linhu7==0)|| (louthu7==0 && linhu7!=0))
    {
      TIME_PARABEL_1(vy, vz, y, z, pahu7, pbhu7, t1, pahuwt7, pbhuwt7, &t2h1u7, &t2h1uwt7);
    }


  if(louthd7==0 && linhd7==0)							
    {
      TIME_LINEAR(t1, h1d7, h2d7, l, y, z, vy, vz, h1dwt7, &t2h1d7, &t2h1dwt7); 
    }

  if(louthd7!=0 && linhd7!=0)
    { 										
      TIME_ELLIPSE(vy, vz, y, z, a2hd7, b2hd7, z0hd7, t1, a2hdwt7, b2hdwt7, &t2h1d7, &t2h1dwt7);
    }

  if((louthd7!=0 && linhd7==0)|| (louthd7==0 && linhd7!=0))
    {
      TIME_PARABEL(vy, vz, y, z, pahd7, pbhd7, t1, pahdwt7, pbhdwt7, &t2h1d7, &t2h1dwt7);
    }

/* EIHGHT SHELL */


if(loutwr8==0 && linwr8==0)							
    {
      TIME_LINEAR(t1, w1r8, w2r8, l, x, z, vx, vz, w1rwt8, &t2w1r8, &t2w1rwt8); 
    }

  if(loutwr8!=0 && linwr8!=0)							
    { 										
      TIME_ELLIPSE(vx, vz, x, z, a2wr8, b2wr8, z0wr8, t1, a2wrwt8, b2wrwt8, &t2w1r8, &t2w1rwt8);
    }

  if((loutwr8!=0 && linwr8==0)|| (loutwr8==0 && linwr8!=0))				
    {										
      TIME_PARABEL(vx, vz, x, z, pawr8, pbwr8, t1, pawrwt8, pbwrwt8, &t2w1r8, &t2w1rwt8);
    }


  if(loutwl8==0 && linwl8==0)
    {
      TIME_LINEAR_1(t1, w1l8, w2l8, l, x, z, vx, vz, w1lwt8, &t2w1l8, &t2w1lwt8); 
    }

  if(loutwl8!=0 && linwl8!=0)
    { 
      TIME_ELLIPSE_1(vx, vz, x, z, a2wl8, b2wl8, z0wl8, t1, a2wlwt8, b2wlwt8, &t2w1l8, &t2w1lwt8);
    }


  if((loutwl8!=0 && linwl8==0) || (loutwl8==0 && linwl8!=0))
    {
      TIME_PARABEL_1(vx, vz, x, z, pawl8, pbwl8, t1, pawlwt8, pbwlwt8, &t2w1l8, &t2w1lwt8);
    }


  if(louthu8==0 && linhu8==0)							
    {
      TIME_LINEAR_1(t1, h1u8, h2u8, l, y, z, vy, vz, h1uwt8, &t2h1u8, &t2h1uwt8); 
    }


  if(louthu8!=0 && linhu8!=0)
    { 
      TIME_ELLIPSE_1(vy, vz, y, z, a2hu8, b2hu8, z0hu8, t1, a2huwt8, b2huwt8, &t2h1u8, &t2h1uwt8);
    }


  if((louthu8!=0 && linhu8==0)|| (louthu8==0 && linhu8!=0))
    {
      TIME_PARABEL_1(vy, vz, y, z, pahu8, pbhu8, t1, pahuwt8, pbhuwt8, &t2h1u8, &t2h1uwt8);
    }


  if(louthd8==0 && linhd8==0)							
    {
      TIME_LINEAR(t1, h1d8, h2d8, l, y, z, vy, vz, h1dwt8, &t2h1d8, &t2h1dwt8); 
    }

  if(louthd8!=0 && linhd8!=0)
    { 										
      TIME_ELLIPSE(vy, vz, y, z, a2hd8, b2hd8, z0hd8, t1, a2hdwt8, b2hdwt8, &t2h1d8, &t2h1dwt8);
    }

  if((louthd8!=0 && linhd8==0)|| (louthd8==0 && linhd8!=0))
    {
      TIME_PARABEL(vy, vz, y, z, pahd8, pbhd8, t1, pahdwt8, pbhdwt8, &t2h1d8, &t2h1dwt8);
    }

/* NINETH SHELL */

if(loutwr9==0 && linwr9==0)							
    {
      TIME_LINEAR(t1, w1r9, w2r9, l, x, z, vx, vz, w1rwt9, &t2w1r9, &t2w1rwt9); 
    }

  if(loutwr9!=0 && linwr9!=0)							
    { 										
      TIME_ELLIPSE(vx, vz, x, z, a2wr9, b2wr9, z0wr9, t1, a2wrwt9, b2wrwt9, &t2w1r9, &t2w1rwt9);
    }

  if((loutwr9!=0 && linwr9==0)|| (loutwr9==0 && linwr9!=0))				
    {										
      TIME_PARABEL(vx, vz, x, z, pawr9, pbwr9, t1, pawrwt9, pbwrwt9, &t2w1r9, &t2w1rwt9);
    }


  if(loutwl9==0 && linwl9==0)
    {
      TIME_LINEAR_1(t1, w1l9, w2l9, l, x, z, vx, vz, w1lwt9, &t2w1l9, &t2w1lwt9); 
    }

  if(loutwl9!=0 && linwl9!=0)
    { 
      TIME_ELLIPSE_1(vx, vz, x, z, a2wl9, b2wl9, z0wl9, t1, a2wlwt9, b2wlwt9, &t2w1l9, &t2w1lwt9);
    }


  if((loutwl9!=0 && linwl9==0) || (loutwl9==0 && linwl9!=0))
    {
      TIME_PARABEL_1(vx, vz, x, z, pawl9, pbwl9, t1, pawlwt9, pbwlwt9, &t2w1l9, &t2w1lwt9);
    }


  if(louthu9==0 && linhu9==0)							
    {
      TIME_LINEAR_1(t1, h1u9, h2u9, l, y, z, vy, vz, h1uwt9, &t2h1u9, &t2h1uwt9); 
    }


  if(louthu9!=0 && linhu9!=0)
    { 
      TIME_ELLIPSE_1(vy, vz, y, z, a2hu9, b2hu9, z0hu9, t1, a2huwt9, b2huwt9, &t2h1u9, &t2h1uwt9);
    }


  if((louthu9!=0 && linhu9==0)|| (louthu9==0 && linhu9!=0))
    {
      TIME_PARABEL_1(vy, vz, y, z, pahu9, pbhu9, t1, pahuwt9, pbhuwt9, &t2h1u9, &t2h1uwt9);
    }


  if(louthd9==0 && linhd9==0)							
    {
      TIME_LINEAR(t1, h1d9, h2d9, l, y, z, vy, vz, h1dwt9, &t2h1d9, &t2h1dwt9); 
    }

  if(louthd9!=0 && linhd9!=0)
    { 										
      TIME_ELLIPSE(vy, vz, y, z, a2hd9, b2hd9, z0hd9, t1, a2hdwt9, b2hdwt9, &t2h1d9, &t2h1dwt9);
    }

  if((louthd9!=0 && linhd9==0)|| (louthd9==0 && linhd9!=0))
    {
      TIME_PARABEL(vy, vz, y, z, pahd9, pbhd9, t1, pahdwt9, pbhdwt9, &t2h1d9, &t2h1dwt9);
    }

/* TENTH SHELL */


if(loutwr10==0 && linwr10==0)							
    {
      TIME_LINEAR(t1, w1r10, w2r10, l, x, z, vx, vz, w1rwt10, &t2w1r10, &t2w1rwt10); 
    }

  if(loutwr10!=0 && linwr10!=0)							
    { 										
      TIME_ELLIPSE(vx, vz, x, z, a2wr10, b2wr10, z0wr10, t1, a2wrwt10, b2wrwt10, &t2w1r10, &t2w1rwt10);
    }

  if((loutwr10!=0 && linwr10==0)|| (loutwr10==0 && linwr10!=0))				
    {										
      TIME_PARABEL(vx, vz, x, z, pawr10, pbwr10, t1, pawrwt10, pbwrwt10, &t2w1r10, &t2w1rwt10);
    }


  if(loutwl10==0 && linwl10==0)
    {
      TIME_LINEAR_1(t1, w1l10, w2l10, l, x, z, vx, vz, w1lwt10, &t2w1l10, &t2w1lwt10); 
    }

  if(loutwl10!=0 && linwl10!=0)
    { 
      TIME_ELLIPSE_1(vx, vz, x, z, a2wl10, b2wl10, z0wl10, t1, a2wlwt10, b2wlwt10, &t2w1l10, &t2w1lwt10);
    }


  if((loutwl10!=0 && linwl10==0) || (loutwl10==0 && linwl10!=0))
    {
      TIME_PARABEL_1(vx, vz, x, z, pawl10, pbwl10, t1, pawlwt10, pbwlwt10, &t2w1l10, &t2w1lwt10);
    }


  if(louthu10==0 && linhu10==0)							
    {
      TIME_LINEAR_1(t1, h1u10, h2u10, l, y, z, vy, vz, h1uwt10, &t2h1u10, &t2h1uwt10); 
    }


  if(louthu10!=0 && linhu10!=0)
    { 
      TIME_ELLIPSE_1(vy, vz, y, z, a2hu10, b2hu10, z0hu10, t1, a2huwt10, b2huwt10, &t2h1u10, &t2h1uwt10);
    }


  if((louthu10!=0 && linhu10==0)|| (louthu10==0 && linhu10!=0))
    {
      TIME_PARABEL_1(vy, vz, y, z, pahu10, pbhu10, t1, pahuwt10, pbhuwt10, &t2h1u10, &t2h1uwt10);
    }


  if(louthd10==0 && linhd10==0)							
    {
      TIME_LINEAR(t1, h1d10, h2d10, l, y, z, vy, vz, h1dwt10, &t2h1d10, &t2h1dwt10); 
    }

  if(louthd10!=0 && linhd10!=0)
    { 										
      TIME_ELLIPSE(vy, vz, y, z, a2hd10, b2hd10, z0hd10, t1, a2hdwt10, b2hdwt10, &t2h1d10, &t2h1dwt10);
    }

  if((louthd10!=0 && linhd10==0)|| (louthd10==0 && linhd10!=0))
    {
      TIME_PARABEL(vy, vz, y, z, pahd10, pbhd10, t1, pahdwt10, pbhdwt10, &t2h1d10, &t2h1dwt10);
    }



													/* TEST OF THE INNER INTERSECTION - TIMES */
													/* possible interactions outside the guide have to be eliminated*/

if(t2w1r<t1+2.0){											/* test of RIGHT INNER wall interaction time*/
  TEST_UP_DOWN(t2w1r,vz, z,vy,y, l,
               linhd, louthd, linhu, louthu,
               h2d, h1d,h2u, h1u,
               bhd, z0hd, a2hd,bhu, z0hu, a2hu,
               pbhd, pahd, pbhu, pahu,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){	
  t2w1r=t1+2.0;
  }
  }

if(t2w1l<t1+2.0){											/* test of LEFT INNER wall interaction time - analog to right wall*/
  TEST_UP_DOWN(t2w1l,vz, z,vy,y,l,
               linhd, louthd, linhu, louthu,
               h2d, h1d,h2u, h1u,
               bhd, z0hd, a2hd,bhu, z0hu, a2hu,
               pbhd, pahd, pbhu, pahu,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){
  t2w1l=t1+2.0;
  }
  }


if(t2h1u<t1+2.0){											/* test of TOP INNER wall interaction time - analog to right wall*/
  TEST_LEFT_RIGHT(t2h1u,vz,z,vx,x, l,
                 linwr,loutwr,linwl,loutwl,
                 w2r, w1r,w2l,w1l,
                 bwr, z0wr,a2wr,bwl, z0wl, a2wl,
                 pbwr, pawr, pbwl, pawl,
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl){
  t2h1u=t1+2.0;
  }
  }


if(t2h1d<t1+2.0){											/* test of BOTTOM INNER wall interaction time - analog to right wall*/
  TEST_LEFT_RIGHT(t2h1d,vz,z,vx,x,l,
                 linwr,loutwr,linwl,loutwl,
                 w2r, w1r,w2l,w1l,
                 bwr, z0wr,a2wr,bwl, z0wl, a2wl,
                 pbwr, pawr, pbwl, pawl, 
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl)
  {
  t2h1d=t1+2.0;
  }
  }


													/* TEST OF THE OUTER INTERSECTION - TIMES */

if(t2w1rwt<t1+2.0){											/* test of RIGHT OUTER wall interaction time - analog inner wall*/
  TEST_UP_DOWN(t2w1rwt,vz, z,vy,y, l,
               linhd, louthd, linhu, louthu,
               h2dwt, h1dwt,h2uwt, h1uwt,
               bhdwt, z0hd, a2hdwt,bhuwt, z0hu, a2huwt,
               pbhdwt, pahdwt, pbhuwt, pahuwt,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){
  t2w1rwt=t1+2.0;
  }
  }


if(t2w1lwt<t1+2.0){											/* test of LEFT OUTER wall interaction time - analog inner wall*/
  TEST_UP_DOWN(t2w1lwt,vz, z,vy,y,l,
               linhd, louthd, linhu, louthu,
               h2dwt, h1dwt,h2uwt, h1uwt,
               bhdwt, z0hd, a2hdwt,bhuwt, z0hu, a2huwt,
               pbhdwt, pahdwt, pbhuwt, pahuwt,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){
  t2w1lwt=t1+2.0;
  }
  }

if(t2h1uwt<t1+2.0){											/* test of TOP OUTER wall interaction time - analog inner wall*/
  TEST_LEFT_RIGHT(t2h1uwt,vz,z,vx,x,l, 
                 linwr,loutwr,linwl,loutwl,
                 w2rwt, w1rwt,w2lwt,w1lwt,
                 bwrwt, z0wr,a2wrwt,bwlwt, z0wl, a2wlwt,
                 pbwrwt, pawrwt, pbwlwt, pawlwt,
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl){
  t2h1uwt=t1+2.0;
  }
  }


if(t2h1dwt<t1+2.0){											/* test of BOTTOM OUTER wall interaction time - analog inner wall*/
 TEST_LEFT_RIGHT(t2h1dwt,vz,z,vx,x,l, 
                 linwr,loutwr,linwl,loutwl,
                 w2rwt, w1rwt,w2lwt,w1lwt,
                 bwrwt, z0wr,a2wrwt,bwlwt, z0wl, a2wlwt,
                 pbwrwt, pawrwt, pbwlwt, pawlwt,
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl)
  {
  t2h1dwt=t1+2.0;
  }
  }

								/*         INTERACTION OF FIRST SHELL                  */


if(t2w1r1<t1+2.0){											/* test of RIGHT INNER wall interaction time*/
  TEST_UP_DOWN(t2w1r1,vz, z,vy,y, l,
               linhd1, louthd1, linhu1, louthu1,
               h2d1, h1d1,h2u1, h1u1,
               bhd1, z0hd1, a2hd1,bhu1, z0hu1, a2hu1,
               pbhd1, pahd1, pbhu1, pahu1,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){	
  t2w1r1=t1+2.0;
  }
  }

if(t2w1l1<t1+2.0){											/* test of LEFT INNER wall interaction time - analog to right wall*/
  TEST_UP_DOWN(t2w1l1,vz, z,vy,y,l,
               linhd1, louthd1, linhu1, louthu1,
               h2d1, h1d1,h2u1, h1u1,
               bhd1, z0hd1, a2hd1,bhu1, z0hu1, a2hu1,
               pbhd1, pahd1, pbhu1, pahu1,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){
  t2w1l1=t1+2.0;
  }
  }


if(t2h1u1<t1+2.0){											/* test of TOP INNER wall interaction time - analog to right wall*/
  TEST_LEFT_RIGHT(t2h1u1,vz,z,vx,x, l,
                 linwr1,loutwr1,linwl1,loutwl1,
                 w2r1, w1r1,w2l1,w1l1,
                 bwr1, z0wr1,a2wr1,bwl1, z0wl1, a2wl1,
                 pbwr1, pawr1, pbwl1, pawl1,
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl){
  t2h1u1=t1+2.0;
  }
  }


if(t2h1d1<t1+2.0){											/* test of BOTTOM INNER wall interaction time - analog to right wall*/
  TEST_LEFT_RIGHT(t2h1d1,vz,z,vx,x,l,
                 linwr1,loutwr1,linwl1,loutwl1,
                 w2r1, w1r1,w2l1,w1l1,
                 bwr1, z0wr1,a2wr1,bwl1, z0wl1, a2wl1,
                 pbwr1, pawr1, pbwl1, pawl1, 
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl)
  {
  t2h1d1=t1+2.0;
  }
  }


													/* TEST OF THE OUTER INTERSECTION - TIMES */

if(t2w1rwt1<t1+2.0){											/* test of RIGHT OUTER wall interaction time - analog inner wall*/
  TEST_UP_DOWN(t2w1rwt1,vz, z,vy,y, l,
               linhd1, louthd1, linhu1, louthu1,
               h2dwt1, h1dwt1,h2uwt1, h1uwt1,
               bhdwt1, z0hd1, a2hdwt1,bhuwt1, z0hu1, a2huwt1,
               pbhdwt1, pahdwt1, pbhuwt1, pahuwt1,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){
  t2w1rwt1=t1+2.0;
  }
  }


if(t2w1lwt1<t1+2.0){											/* test of LEFT OUTER wall interaction time - analog inner wall*/
  TEST_UP_DOWN(t2w1lwt1,vz, z,vy,y,l,
               linhd1, louthd1, linhu1, louthu1,
               h2dwt1, h1dwt1,h2uwt1, h1uwt1,
               bhdwt1, z0hd1, a2hdwt1,bhuwt1, z0hu1, a2huwt1,
               pbhdwt1, pahdwt1, pbhuwt1, pahuwt1,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){
  t2w1lwt1=t1+2.0;
  }
  }

if(t2h1uwt1<t1+2.0){											/* test of TOP OUTER wall interaction time - analog inner wall*/
  TEST_LEFT_RIGHT(t2h1uwt1,vz,z,vx,x,l, 
                 linwr1,loutwr1,linwl1,loutwl1,
                 w2rwt1, w1rwt1,w2lwt1,w1lwt1,
                 bwrwt1, z0wr1,a2wrwt1,bwlwt1, z0wl1, a2wlwt1,
                 pbwrwt1, pawrwt1, pbwlwt1, pawlwt1,
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl){
  t2h1uwt1=t1+2.0;
  }
  }


if(t2h1dwt1<t1+2.0){											/* test of BOTTOM OUTER wall interaction time - analog inner wall*/
 TEST_LEFT_RIGHT(t2h1dwt1,vz,z,vx,x,l, 
                 linwr1,loutwr1,linwl1,loutwl1,
                 w2rwt1, w1rwt1,w2lwt1,w1lwt1,
                 bwrwt1, z0wr1,a2wrwt1,bwlwt1, z0wl1, a2wlwt1,
                 pbwrwt1, pawrwt1, pbwlwt1, pawlwt1,
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl)
  {
  t2h1dwt1=t1+2.0;
  }
  }

								/* INTERACTION SECOND SHELL */

if(t2w1r2<t1+2.0){											/* test of RIGHT INNER wall interaction time*/
  TEST_UP_DOWN(t2w1r2,vz, z,vy,y, l,
               linhd2, louthd2, linhu2, louthu2,
               h2d2, h1d2,h2u2, h1u2,
               bhd2, z0hd2, a2hd2,bhu2, z0hu2, a2hu2,
               pbhd2, pahd2, pbhu2, pahu2,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){	
  t2w1r2=t1+2.0;
  }
  }

if(t2w1l2<t1+2.0){											/* test of LEFT INNER wall interaction time - analog to right wall*/
  TEST_UP_DOWN(t2w1l2,vz, z,vy,y,l,
               linhd2, louthd2, linhu2, louthu2,
               h2d2, h1d2,h2u2, h1u2,
               bhd2, z0hd2, a2hd2,bhu2, z0hu2, a2hu2,
               pbhd2, pahd2, pbhu2, pahu2,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){
  t2w1l2=t1+2.0;
  }
  }


if(t2h1u2<t1+2.0){											/* test of TOP INNER wall interaction time - analog to right wall*/
  TEST_LEFT_RIGHT(t2h1u2,vz,z,vx,x, l,
                 linwr2,loutwr2,linwl2,loutwl2,
                 w2r2, w1r2,w2l2,w1l2,
                 bwr2, z0wr2,a2wr2,bwl2, z0wl2, a2wl2,
                 pbwr2, pawr2, pbwl2, pawl2,
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl){
  t2h1u2=t1+2.0;
  }
  }


if(t2h1d2<t1+2.0){											/* test of BOTTOM INNER wall interaction time - analog to right wall*/
  TEST_LEFT_RIGHT(t2h1d2,vz,z,vx,x,l,
                 linwr2,loutwr2,linwl2,loutwl2,
                 w2r2, w1r2,w2l2,w1l2,
                 bwr2, z0wr2,a2wr2,bwl2, z0wl2, a2wl2,
                 pbwr2, pawr2, pbwl2, pawl2, 
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl)
  {
  t2h1d2=t1+2.0;
  }
  }


													/* TEST OF THE OUTER INTERSECTION - TIMES */

if(t2w1rwt2<t1+2.0){											/* test of RIGHT OUTER wall interaction time - analog inner wall*/
  TEST_UP_DOWN(t2w1rwt2,vz, z,vy,y, l,
               linhd2, louthd2, linhu2, louthu2,
               h2dwt2, h1dwt2,h2uwt2, h1uwt2,
               bhdwt2, z0hd2, a2hdwt2,bhuwt2, z0hu2, a2huwt2,
               pbhdwt2, pahdwt2, pbhuwt2, pahuwt2,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){
  t2w1rwt2=t1+2.0;
  }
  }


if(t2w1lwt2<t1+2.0){											/* test of LEFT OUTER wall interaction time - analog inner wall*/
  TEST_UP_DOWN(t2w1lwt2,vz, z,vy,y,l,
               linhd2, louthd2, linhu2, louthu2,
               h2dwt2, h1dwt2,h2uwt2, h1uwt2,
               bhdwt2, z0hd2, a2hdwt2,bhuwt2, z0hu2, a2huwt2,
               pbhdwt2, pahdwt2, pbhuwt2, pahuwt2,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){
  t2w1lwt2=t1+2.0;
  }
  }

if(t2h1uwt2<t1+2.0){											/* test of TOP OUTER wall interaction time - analog inner wall*/
  TEST_LEFT_RIGHT(t2h1uwt2,vz,z,vx,x,l, 
                 linwr2,loutwr2,linwl2,loutwl2,
                 w2rwt2, w1rwt2,w2lwt2,w1lwt2,
                 bwrwt2, z0wr2,a2wrwt2,bwlwt2, z0wl2, a2wlwt2,
                 pbwrwt2, pawrwt2, pbwlwt2, pawlwt2,
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl){
  t2h1uwt2=t1+2.0;
  }
  }


if(t2h1dwt2<t1+2.0){											/* test of BOTTOM OUTER wall interaction time - analog inner wall*/
 TEST_LEFT_RIGHT(t2h1dwt2,vz,z,vx,x,l, 
                 linwr2,loutwr2,linwl2,loutwl2,
                 w2rwt2, w1rwt2,w2lwt2,w1lwt2,
                 bwrwt2, z0wr2,a2wrwt2,bwlwt2, z0wl2, a2wlwt2,
                 pbwrwt2, pawrwt2, pbwlwt2, pawlwt2,
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl)
  {
  t2h1dwt2=t1+2.0;
  }
  }


									/* TEST THIRD SHELL*/

    if(t2w1r3<t1+2.0){											/* test of RIGHT INNER wall interaction time*/
	    TEST_UP_DOWN(t2w1r3,vz, z,vy,y, l,
			 linhd3, louthd3, linhu3, louthu3,
			 h2d3, h1d3,h2u3, h1u3,
			 bhd3, z0hd3, a2hd3,bhu3, z0hu3, a2hu3,
			 pbhd3, pahd3, pbhu3, pahu3,
			 &ylimitd, &ylimitu, &ytest);
    if (ytest<ylimitd || ytest>ylimitu){	
	    t2w1r3=t1+2.0;
}
}

    if(t2w1l3<t1+2.0){											/* test of LEFT INNER wall interaction time - analog to right wall*/
	    TEST_UP_DOWN(t2w1l3,vz, z,vy,y,l,
			 linhd3, louthd3, linhu3, louthu3,
			 h2d3, h1d3,h2u3, h1u3,
			 bhd3, z0hd3, a2hd3,bhu3, z0hu3, a2hu3,
			 pbhd3, pahd3, pbhu3, pahu3,
			 &ylimitd, &ylimitu, &ytest);
    if (ytest<ylimitd || ytest>ylimitu){
	    t2w1l3=t1+2.0;
}
}


    if(t2h1u3<t1+2.0){											/* test of TOP INNER wall interaction time - analog to right wall*/
	    TEST_LEFT_RIGHT(t2h1u3,vz,z,vx,x, l,
			    linwr3,loutwr3,linwl3,loutwl3,
			    w2r3, w1r3,w2l3,w1l3,
			    bwr3, z0wr3,a2wr3,bwl3, z0wl3, a2wl3,
			    pbwr3, pawr3, pbwl3, pawl3,
			    &xlimitr, &xlimitl, &xtest);
    if (xtest<xlimitr || xtest>xlimitl){
	    t2h1u3=t1+2.0;
}
}


    if(t2h1d3<t1+2.0){											/* test of BOTTOM INNER wall interaction time - analog to right wall*/
	    TEST_LEFT_RIGHT(t2h1d3,vz,z,vx,x,l,
			    linwr3,loutwr3,linwl3,loutwl3,
			    w2r3, w1r3,w2l3,w1l3,
			    bwr3, z0wr3,a2wr3,bwl3, z0wl3, a2wl3,
			    pbwr3, pawr3, pbwl3, pawl3, 
			    &xlimitr, &xlimitl, &xtest);
    if (xtest<xlimitr || xtest>xlimitl)
{
	    t2h1d3=t1+2.0;
}
}


    /* TEST OF THE OUTER INTERSECTION - TIMES */

    if(t2w1rwt3<t1+2.0){											/* test of RIGHT OUTER wall interaction time - analog inner wall*/
	    TEST_UP_DOWN(t2w1rwt3,vz, z,vy,y, l,
			 linhd3, louthd3, linhu3, louthu3,
			 h2dwt3, h1dwt3,h2uwt3, h1uwt3,
			 bhdwt3, z0hd3, a2hdwt3,bhuwt3, z0hu3, a2huwt3,
			 pbhdwt3, pahdwt3, pbhuwt3, pahuwt3,
			 &ylimitd, &ylimitu, &ytest);
    if (ytest<ylimitd || ytest>ylimitu){
	    t2w1rwt3=t1+2.0;
}
}


    if(t2w1lwt3<t1+2.0){											/* test of LEFT OUTER wall interaction time - analog inner wall*/
	    TEST_UP_DOWN(t2w1lwt3,vz, z,vy,y,l,
			 linhd3, louthd3, linhu3, louthu3,
			 h2dwt3, h1dwt3,h2uwt3, h1uwt3,
			 bhdwt3, z0hd3, a2hdwt3,bhuwt3, z0hu3, a2huwt3,
			 pbhdwt3, pahdwt3, pbhuwt3, pahuwt3,
			 &ylimitd, &ylimitu, &ytest);
    if (ytest<ylimitd || ytest>ylimitu){
	    t2w1lwt3=t1+2.0;
}
}

    if(t2h1uwt3<t1+2.0){											/* test of TOP OUTER wall interaction time - analog inner wall*/
	    TEST_LEFT_RIGHT(t2h1uwt3,vz,z,vx,x,l, 
			    linwr3,loutwr3,linwl3,loutwl3,
			    w2rwt3, w1rwt3,w2lwt3,w1lwt3,
			    bwrwt3, z0wr3,a2wrwt3,bwlwt3, z0wl3, a2wlwt3,
			    pbwrwt3, pawrwt3, pbwlwt3, pawlwt3,
			    &xlimitr, &xlimitl, &xtest);
    if (xtest<xlimitr || xtest>xlimitl){
	    t2h1uwt3=t1+2.0;
}
}


    if(t2h1dwt3<t1+2.0){											/* test of BOTTOM OUTER wall interaction time - analog inner wall*/
	    TEST_LEFT_RIGHT(t2h1dwt3,vz,z,vx,x,l, 
			    linwr3,loutwr3,linwl3,loutwl3,
			    w2rwt3, w1rwt3,w2lwt3,w1lwt3,
			    bwrwt3, z0wr3,a2wrwt3,bwlwt3, z0wl3, a2wlwt3,
			    pbwrwt3, pawrwt3, pbwlwt3, pawlwt3,
			    &xlimitr, &xlimitl, &xtest);
    if (xtest<xlimitr || xtest>xlimitl)
{
	    t2h1dwt3=t1+2.0;
}
}

											/*  FOURTH SHELL */

if(t2w1r4<t1+2.0){											/* test of RIGHT INNER wall interaction time*/
  TEST_UP_DOWN(t2w1r4,vz, z,vy,y, l,
               linhd4, louthd4, linhu4, louthu4,
               h2d4, h1d4,h2u4, h1u4,
               bhd4, z0hd4, a2hd4,bhu4, z0hu4, a2hu4,
               pbhd4, pahd4, pbhu4, pahu4,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){	
  t2w1r4=t1+2.0;
  }
  }

if(t2w1l4<t1+2.0){											/* test of LEFT INNER wall interaction time - analog to right wall*/
  TEST_UP_DOWN(t2w1l4,vz, z,vy,y,l,
               linhd4, louthd4, linhu4, louthu4,
               h2d4, h1d4,h2u4, h1u4,
               bhd4, z0hd4, a2hd4,bhu4, z0hu4, a2hu4,
               pbhd4, pahd4, pbhu4, pahu4,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){
  t2w1l4=t1+2.0;
  }
  }


if(t2h1u4<t1+2.0){											/* test of TOP INNER wall interaction time - analog to right wall*/
  TEST_LEFT_RIGHT(t2h1u4,vz,z,vx,x, l,
                 linwr4,loutwr4,linwl4,loutwl4,
                 w2r4, w1r4,w2l4,w1l4,
                 bwr4, z0wr4,a2wr4,bwl4, z0wl4, a2wl4,
                 pbwr4, pawr4, pbwl4, pawl4,
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl){
  t2h1u4=t1+2.0;
  }
  }


if(t2h1d4<t1+2.0){											/* test of BOTTOM INNER wall interaction time - analog to right wall*/
  TEST_LEFT_RIGHT(t2h1d4,vz,z,vx,x,l,
                 linwr4,loutwr4,linwl4,loutwl4,
                 w2r4, w1r4,w2l4,w1l4,
                 bwr4, z0wr4,a2wr4,bwl4, z0wl4, a2wl4,
                 pbwr4, pawr4, pbwl4, pawl4, 
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl)
  {
  t2h1d4=t1+2.0;
  }
  }


													/* TEST OF THE OUTER INTERSECTION - TIMES */

if(t2w1rwt4<t1+2.0){											/* test of RIGHT OUTER wall interaction time - analog inner wall*/
  TEST_UP_DOWN(t2w1rwt4,vz, z,vy,y, l,
               linhd4, louthd4, linhu4, louthu4,
               h2dwt4, h1dwt4,h2uwt4, h1uwt4,
               bhdwt4, z0hd4, a2hdwt4,bhuwt4, z0hu4, a2huwt4,
               pbhdwt4, pahdwt4, pbhuwt4, pahuwt4,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){
  t2w1rwt4=t1+2.0;
  }
  }


if(t2w1lwt4<t1+2.0){											/* test of LEFT OUTER wall interaction time - analog inner wall*/
  TEST_UP_DOWN(t2w1lwt4,vz, z,vy,y,l,
               linhd4, louthd4, linhu4, louthu4,
               h2dwt4, h1dwt4,h2uwt4, h1uwt4,
               bhdwt4, z0hd4, a2hdwt4,bhuwt4, z0hu4, a2huwt4,
               pbhdwt4, pahdwt4, pbhuwt4, pahuwt4,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){
  t2w1lwt4=t1+2.0;
  }
  }

if(t2h1uwt4<t1+2.0){											/* test of TOP OUTER wall interaction time - analog inner wall*/
  TEST_LEFT_RIGHT(t2h1uwt4,vz,z,vx,x,l, 
                 linwr4,loutwr4,linwl4,loutwl4,
                 w2rwt4, w1rwt4,w2lwt4,w1lwt4,
                 bwrwt4, z0wr4,a2wrwt4,bwlwt4, z0wl4, a2wlwt4,
                 pbwrwt4, pawrwt4, pbwlwt4, pawlwt4,
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl){
  t2h1uwt4=t1+2.0;
  }
  }


if(t2h1dwt4<t1+2.0){											/* test of BOTTOM OUTER wall interaction time - analog inner wall*/
 TEST_LEFT_RIGHT(t2h1dwt4,vz,z,vx,x,l, 
                 linwr4,loutwr4,linwl4,loutwl4,
                 w2rwt4, w1rwt4,w2lwt4,w1lwt4,
                 bwrwt4, z0wr4,a2wrwt4,bwlwt4, z0wl4, a2wlwt4,
                 pbwrwt4, pawrwt4, pbwlwt4, pawlwt4,
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl)
  {
  t2h1dwt4=t1+2.0;
  }
  }


						/*        FIFTH SHELL          */

if(t2w1r5<t1+2.0){											/* test of RIGHT INNER wall interaction time*/
  TEST_UP_DOWN(t2w1r5,vz, z,vy,y, l,
               linhd5, louthd5, linhu5, louthu5,
               h2d5, h1d5,h2u5, h1u5,
               bhd5, z0hd5, a2hd5,bhu5, z0hu5, a2hu5,
               pbhd5, pahd5, pbhu5, pahu5,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){	
  t2w1r5=t1+2.0;
  }
  }

if(t2w1l5<t1+2.0){											/* test of LEFT INNER wall interaction time - analog to right wall*/
  TEST_UP_DOWN(t2w1l5,vz, z,vy,y,l,
               linhd5, louthd5, linhu5, louthu5,
               h2d5, h1d5,h2u5, h1u5,
               bhd5, z0hd5, a2hd5,bhu5, z0hu5, a2hu5,
               pbhd5, pahd5, pbhu5, pahu5,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){
  t2w1l5=t1+2.0;
  }
  }


if(t2h1u5<t1+2.0){											/* test of TOP INNER wall interaction time - analog to right wall*/
  TEST_LEFT_RIGHT(t2h1u5,vz,z,vx,x, l,
                 linwr5,loutwr5,linwl5,loutwl5,
                 w2r5, w1r5,w2l5,w1l5,
                 bwr5, z0wr5,a2wr5,bwl5, z0wl5, a2wl5,
                 pbwr5, pawr5, pbwl5, pawl5,
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl){
  t2h1u5=t1+2.0;
  }
  }


if(t2h1d5<t1+2.0){											/* test of BOTTOM INNER wall interaction time - analog to right wall*/
  TEST_LEFT_RIGHT(t2h1d5,vz,z,vx,x,l,
                 linwr5,loutwr5,linwl5,loutwl5,
                 w2r5, w1r5,w2l5,w1l5,
                 bwr5, z0wr5,a2wr5,bwl5, z0wl5, a2wl5,
                 pbwr5, pawr5, pbwl5, pawl5, 
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl)
  {
  t2h1d5=t1+2.0;
  }
  }


													/* TEST OF THE OUTER INTERSECTION - TIMES */

if(t2w1rwt5<t1+2.0){											/* test of RIGHT OUTER wall interaction time - analog inner wall*/
  TEST_UP_DOWN(t2w1rwt5,vz, z,vy,y, l,
               linhd5, louthd5, linhu5, louthu5,
               h2dwt5, h1dwt5,h2uwt5, h1uwt5,
               bhdwt5, z0hd5, a2hdwt5,bhuwt5, z0hu5, a2huwt5,
               pbhdwt5, pahdwt5, pbhuwt5, pahuwt5,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){
  t2w1rwt5=t1+2.0;
  }
  }


if(t2w1lwt5<t1+2.0){											/* test of LEFT OUTER wall interaction time - analog inner wall*/
  TEST_UP_DOWN(t2w1lwt5,vz, z,vy,y,l,
               linhd5, louthd5, linhu5, louthu5,
               h2dwt5, h1dwt5,h2uwt5, h1uwt5,
               bhdwt5, z0hd5, a2hdwt5,bhuwt5, z0hu5, a2huwt5,
               pbhdwt5, pahdwt5, pbhuwt5, pahuwt5,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){
  t2w1lwt5=t1+2.0;
  }
  }

if(t2h1uwt5<t1+2.0){											/* test of TOP OUTER wall interaction time - analog inner wall*/
  TEST_LEFT_RIGHT(t2h1uwt5,vz,z,vx,x,l, 
                 linwr5,loutwr5,linwl5,loutwl5,
                 w2rwt5, w1rwt5,w2lwt5,w1lwt5,
                 bwrwt5, z0wr5,a2wrwt5,bwlwt5, z0wl5, a2wlwt5,
                 pbwrwt5, pawrwt5, pbwlwt5, pawlwt5,
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl){
  t2h1uwt5=t1+2.0;
  }
  }


if(t2h1dwt5<t1+2.0){											/* test of BOTTOM OUTER wall interaction time - analog inner wall*/
 TEST_LEFT_RIGHT(t2h1dwt5,vz,z,vx,x,l, 
                 linwr5,loutwr5,linwl5,loutwl5,
                 w2rwt5, w1rwt5,w2lwt5,w1lwt5,
                 bwrwt5, z0wr5,a2wrwt5,bwlwt5, z0wl5, a2wlwt5,
                 pbwrwt5, pawrwt5, pbwlwt5, pawlwt5,
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl)
  {
  t2h1dwt5=t1+2.0;
  }
  }

											/*   SIXT SHELL   */

if(t2w1r6<t1+2.0){											/* test of RIGHT INNER wall interaction time*/
  TEST_UP_DOWN(t2w1r6,vz, z,vy,y, l,
               linhd6, louthd6, linhu6, louthu6,
               h2d6, h1d6,h2u6, h1u6,
               bhd6, z0hd6, a2hd6,bhu6, z0hu6, a2hu6,
               pbhd6, pahd6, pbhu6, pahu6,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){	
  t2w1r6=t1+2.0;
  }
  }

if(t2w1l6<t1+2.0){											/* test of LEFT INNER wall interaction time - analog to right wall*/
  TEST_UP_DOWN(t2w1l6,vz, z,vy,y,l,
               linhd6, louthd6, linhu6, louthu6,
               h2d6, h1d6,h2u6, h1u6,
               bhd6, z0hd6, a2hd6,bhu6, z0hu6, a2hu6,
               pbhd6, pahd6, pbhu6, pahu6,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){
  t2w1l6=t1+2.0;
  }
  }


if(t2h1u6<t1+2.0){											/* test of TOP INNER wall interaction time - analog to right wall*/
  TEST_LEFT_RIGHT(t2h1u6,vz,z,vx,x, l,
                 linwr6,loutwr6,linwl6,loutwl6,
                 w2r6, w1r6,w2l6,w1l6,
                 bwr6, z0wr6,a2wr6,bwl6, z0wl6, a2wl6,
                 pbwr6, pawr6, pbwl6, pawl6,
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl){
  t2h1u6=t1+2.0;
  }
  }


if(t2h1d6<t1+2.0){											/* test of BOTTOM INNER wall interaction time - analog to right wall*/
  TEST_LEFT_RIGHT(t2h1d6,vz,z,vx,x,l,
                 linwr6,loutwr6,linwl6,loutwl6,
                 w2r6, w1r6,w2l6,w1l6,
                 bwr6, z0wr6,a2wr6,bwl6, z0wl6, a2wl6,
                 pbwr6, pawr6, pbwl6, pawl6, 
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl)
  {
  t2h1d6=t1+2.0;
  }
  }


													/* TEST OF THE OUTER INTERSECTION - TIMES */

if(t2w1rwt6<t1+2.0){											/* test of RIGHT OUTER wall interaction time - analog inner wall*/
  TEST_UP_DOWN(t2w1rwt6,vz, z,vy,y, l,
               linhd6, louthd6, linhu6, louthu6,
               h2dwt6, h1dwt6,h2uwt6, h1uwt6,
               bhdwt6, z0hd6, a2hdwt6,bhuwt6, z0hu6, a2huwt6,
               pbhdwt6, pahdwt6, pbhuwt6, pahuwt6,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){
  t2w1rwt6=t1+2.0;
  }
  }


if(t2w1lwt6<t1+2.0){											/* test of LEFT OUTER wall interaction time - analog inner wall*/
  TEST_UP_DOWN(t2w1lwt6,vz, z,vy,y,l,
               linhd6, louthd6, linhu6, louthu6,
               h2dwt6, h1dwt6,h2uwt6, h1uwt6,
               bhdwt6, z0hd6, a2hdwt6,bhuwt6, z0hu6, a2huwt6,
               pbhdwt6, pahdwt6, pbhuwt6, pahuwt6,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){
  t2w1lwt6=t1+2.0;
  }
  }

if(t2h1uwt6<t1+2.0){											/* test of TOP OUTER wall interaction time - analog inner wall*/
  TEST_LEFT_RIGHT(t2h1uwt6,vz,z,vx,x,l, 
                 linwr6,loutwr6,linwl6,loutwl6,
                 w2rwt6, w1rwt6,w2lwt6,w1lwt6,
                 bwrwt6, z0wr6,a2wrwt6,bwlwt6, z0wl6, a2wlwt6,
                 pbwrwt6, pawrwt6, pbwlwt6, pawlwt6,
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl){
  t2h1uwt6=t1+2.0;
  }
  }


if(t2h1dwt6<t1+2.0){											/* test of BOTTOM OUTER wall interaction time - analog inner wall*/
 TEST_LEFT_RIGHT(t2h1dwt6,vz,z,vx,x,l, 
                 linwr6,loutwr6,linwl6,loutwl6,
                 w2rwt6, w1rwt6,w2lwt6,w1lwt6,
                 bwrwt6, z0wr6,a2wrwt6,bwlwt6, z0wl6, a2wlwt6,
                 pbwrwt6, pawrwt6, pbwlwt6, pawlwt6,
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl)
  {
  t2h1dwt6=t1+2.0;
  }
  }

									/* SEVENTH SHELL */

if(t2w1r7<t1+2.0){											/* test of RIGHT INNER wall interaction time*/
  TEST_UP_DOWN(t2w1r7,vz, z,vy,y, l,
               linhd7, louthd7, linhu7, louthu7,
               h2d7, h1d7,h2u7, h1u7,
               bhd7, z0hd7, a2hd7,bhu7, z0hu7, a2hu7,
               pbhd7, pahd7, pbhu7, pahu7,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){	
  t2w1r7=t1+2.0;
  }
  }

if(t2w1l7<t1+2.0){											/* test of LEFT INNER wall interaction time - analog to right wall*/
  TEST_UP_DOWN(t2w1l7,vz, z,vy,y,l,
               linhd7, louthd7, linhu7, louthu7,
               h2d7, h1d7,h2u7, h1u7,
               bhd7, z0hd7, a2hd7,bhu7, z0hu7, a2hu7,
               pbhd7, pahd7, pbhu7, pahu7,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){
  t2w1l7=t1+2.0;
  }
  }


if(t2h1u7<t1+2.0){											/* test of TOP INNER wall interaction time - analog to right wall*/
  TEST_LEFT_RIGHT(t2h1u7,vz,z,vx,x, l,
                 linwr7,loutwr7,linwl7,loutwl7,
                 w2r7, w1r7,w2l7,w1l7,
                 bwr7, z0wr7,a2wr7,bwl7, z0wl7, a2wl7,
                 pbwr7, pawr7, pbwl7, pawl7,
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl){
  t2h1u7=t1+2.0;
  }
  }


if(t2h1d7<t1+2.0){											/* test of BOTTOM INNER wall interaction time - analog to right wall*/
  TEST_LEFT_RIGHT(t2h1d7,vz,z,vx,x,l,
                 linwr7,loutwr7,linwl7,loutwl7,
                 w2r7, w1r7,w2l7,w1l7,
                 bwr7, z0wr7,a2wr7,bwl7, z0wl7, a2wl7,
                 pbwr7, pawr7, pbwl7, pawl7, 
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl)
  {
  t2h1d7=t1+2.0;
  }
  }


													/* TEST OF THE OUTER INTERSECTION - TIMES */

if(t2w1rwt7<t1+2.0){											/* test of RIGHT OUTER wall interaction time - analog inner wall*/
  TEST_UP_DOWN(t2w1rwt7,vz, z,vy,y, l,
               linhd7, louthd7, linhu7, louthu7,
               h2dwt7, h1dwt7,h2uwt7, h1uwt7,
               bhdwt7, z0hd7, a2hdwt7,bhuwt7, z0hu7, a2huwt7,
               pbhdwt7, pahdwt7, pbhuwt7, pahuwt7,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){
  t2w1rwt7=t1+2.0;
  }
  }


if(t2w1lwt7<t1+2.0){											/* test of LEFT OUTER wall interaction time - analog inner wall*/
  TEST_UP_DOWN(t2w1lwt7,vz, z,vy,y,l,
               linhd7, louthd7, linhu7, louthu7,
               h2dwt7, h1dwt7,h2uwt7, h1uwt7,
               bhdwt7, z0hd7, a2hdwt7,bhuwt7, z0hu7, a2huwt7,
               pbhdwt7, pahdwt7, pbhuwt7, pahuwt7,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){
  t2w1lwt7=t1+2.0;
  }
  }

if(t2h1uwt7<t1+2.0){											/* test of TOP OUTER wall interaction time - analog inner wall*/
  TEST_LEFT_RIGHT(t2h1uwt7,vz,z,vx,x,l, 
                 linwr7,loutwr7,linwl7,loutwl7,
                 w2rwt7, w1rwt7,w2lwt7,w1lwt7,
                 bwrwt7, z0wr7,a2wrwt7,bwlwt7, z0wl7, a2wlwt7,
                 pbwrwt7, pawrwt7, pbwlwt7, pawlwt7,
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl){
  t2h1uwt7=t1+2.0;
  }
  }


if(t2h1dwt7<t1+2.0){											/* test of BOTTOM OUTER wall interaction time - analog inner wall*/
 TEST_LEFT_RIGHT(t2h1dwt7,vz,z,vx,x,l, 
                 linwr7,loutwr7,linwl7,loutwl7,
                 w2rwt7, w1rwt7,w2lwt7,w1lwt7,
                 bwrwt7, z0wr7,a2wrwt7,bwlwt7, z0wl7, a2wlwt7,
                 pbwrwt7, pawrwt7, pbwlwt7, pawlwt7,
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl)
  {
  t2h1dwt7=t1+2.0;
  }
  }


									/*	EIGHTH SHELL	*/

if(t2w1r8<t1+2.0){											/* test of RIGHT INNER wall interaction time*/
  TEST_UP_DOWN(t2w1r8,vz, z,vy,y, l,
               linhd8, louthd8, linhu8, louthu8,
               h2d8, h1d8,h2u8, h1u8,
               bhd8, z0hd8, a2hd8,bhu8, z0hu8, a2hu8,
               pbhd8, pahd8, pbhu8, pahu8,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){	
  t2w1r8=t1+2.0;
  }
  }

if(t2w1l8<t1+2.0){											/* test of LEFT INNER wall interaction time - analog to right wall*/
  TEST_UP_DOWN(t2w1l8,vz, z,vy,y,l,
               linhd8, louthd8, linhu8, louthu8,
               h2d8, h1d8,h2u8, h1u8,
               bhd8, z0hd8, a2hd8,bhu8, z0hu8, a2hu8,
               pbhd8, pahd8, pbhu8, pahu8,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){
  t2w1l8=t1+2.0;
  }
  }


if(t2h1u8<t1+2.0){											/* test of TOP INNER wall interaction time - analog to right wall*/
  TEST_LEFT_RIGHT(t2h1u8,vz,z,vx,x, l,
                 linwr8,loutwr8,linwl8,loutwl8,
                 w2r8, w1r8,w2l8,w1l8,
                 bwr8, z0wr8,a2wr8,bwl8, z0wl8, a2wl8,
                 pbwr8, pawr8, pbwl8, pawl8,
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl){
  t2h1u8=t1+2.0;
  }
  }


if(t2h1d8<t1+2.0){											/* test of BOTTOM INNER wall interaction time - analog to right wall*/
  TEST_LEFT_RIGHT(t2h1d8,vz,z,vx,x,l,
                 linwr8,loutwr8,linwl8,loutwl8,
                 w2r8, w1r8,w2l8,w1l8,
                 bwr8, z0wr8,a2wr8,bwl8, z0wl8, a2wl8,
                 pbwr8, pawr8, pbwl8, pawl8, 
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl)
  {
  t2h1d8=t1+2.0;
  }
  }


													/* TEST OF THE OUTER INTERSECTION - TIMES */

if(t2w1rwt8<t1+2.0){											/* test of RIGHT OUTER wall interaction time - analog inner wall*/
  TEST_UP_DOWN(t2w1rwt8,vz, z,vy,y, l,
               linhd8, louthd8, linhu8, louthu8,
               h2dwt8, h1dwt8,h2uwt8, h1uwt8,
               bhdwt8, z0hd8, a2hdwt8,bhuwt8, z0hu8, a2huwt8,
               pbhdwt8, pahdwt8, pbhuwt8, pahuwt8,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){
  t2w1rwt8=t1+2.0;
  }
  }


if(t2w1lwt8<t1+2.0){											/* test of LEFT OUTER wall interaction time - analog inner wall*/
  TEST_UP_DOWN(t2w1lwt8,vz, z,vy,y,l,
               linhd8, louthd8, linhu8, louthu8,
               h2dwt8, h1dwt8,h2uwt8, h1uwt8,
               bhdwt8, z0hd8, a2hdwt8,bhuwt8, z0hu8, a2huwt8,
               pbhdwt8, pahdwt8, pbhuwt8, pahuwt8,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){
  t2w1lwt8=t1+2.0;
  }
  }

if(t2h1uwt8<t1+2.0){											/* test of TOP OUTER wall interaction time - analog inner wall*/
  TEST_LEFT_RIGHT(t2h1uwt8,vz,z,vx,x,l, 
                 linwr8,loutwr8,linwl8,loutwl8,
                 w2rwt8, w1rwt8,w2lwt8,w1lwt8,
                 bwrwt8, z0wr8,a2wrwt8,bwlwt8, z0wl8, a2wlwt8,
                 pbwrwt8, pawrwt8, pbwlwt8, pawlwt8,
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl){
  t2h1uwt8=t1+2.0;
  }
  }


if(t2h1dwt8<t1+2.0){											/* test of BOTTOM OUTER wall interaction time - analog inner wall*/
 TEST_LEFT_RIGHT(t2h1dwt8,vz,z,vx,x,l, 
                 linwr8,loutwr8,linwl8,loutwl8,
                 w2rwt8, w1rwt8,w2lwt8,w1lwt8,
                 bwrwt8, z0wr8,a2wrwt8,bwlwt8, z0wl8, a2wlwt8,
                 pbwrwt8, pawrwt8, pbwlwt8, pawlwt8,
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl)
  {
  t2h1dwt8=t1+2.0;
  }
  }

									/*	NINTH SHELL	*/

if(t2w1r9<t1+2.0){											/* test of RIGHT INNER wall interaction time*/
  TEST_UP_DOWN(t2w1r9,vz, z,vy,y, l,
               linhd9, louthd9, linhu9, louthu9,
               h2d9, h1d9,h2u9, h1u9,
               bhd9, z0hd9, a2hd9,bhu9, z0hu9, a2hu9,
               pbhd9, pahd9, pbhu9, pahu9,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){	
  t2w1r9=t1+2.0;
  }
  }

if(t2w1l9<t1+2.0){											/* test of LEFT INNER wall interaction time - analog to right wall*/
  TEST_UP_DOWN(t2w1l9,vz, z,vy,y,l,
               linhd9, louthd9, linhu9, louthu9,
               h2d9, h1d9,h2u9, h1u9,
               bhd9, z0hd9, a2hd9,bhu9, z0hu9, a2hu9,
               pbhd9, pahd9, pbhu9, pahu9,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){
  t2w1l9=t1+2.0;
  }
  }


if(t2h1u9<t1+2.0){											/* test of TOP INNER wall interaction time - analog to right wall*/
  TEST_LEFT_RIGHT(t2h1u9,vz,z,vx,x, l,
                 linwr9,loutwr9,linwl9,loutwl9,
                 w2r9, w1r9,w2l9,w1l9,
                 bwr9, z0wr9,a2wr9,bwl9, z0wl9, a2wl9,
                 pbwr9, pawr9, pbwl9, pawl9,
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl){
  t2h1u9=t1+2.0;
  }
  }


if(t2h1d9<t1+2.0){											/* test of BOTTOM INNER wall interaction time - analog to right wall*/
  TEST_LEFT_RIGHT(t2h1d9,vz,z,vx,x,l,
                 linwr9,loutwr9,linwl9,loutwl9,
                 w2r9, w1r9,w2l9,w1l9,
                 bwr9, z0wr9,a2wr9,bwl9, z0wl9, a2wl9,
                 pbwr9, pawr9, pbwl9, pawl9, 
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl)
  {
  t2h1d9=t1+2.0;
  }
  }


													/* TEST OF THE OUTER INTERSECTION - TIMES */

if(t2w1rwt9<t1+2.0){											/* test of RIGHT OUTER wall interaction time - analog inner wall*/
  TEST_UP_DOWN(t2w1rwt9,vz, z,vy,y, l,
               linhd9, louthd9, linhu9, louthu9,
               h2dwt9, h1dwt9,h2uwt9, h1uwt9,
               bhdwt9, z0hd9, a2hdwt9,bhuwt9, z0hu9, a2huwt9,
               pbhdwt9, pahdwt9, pbhuwt9, pahuwt9,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){
  t2w1rwt9=t1+2.0;
  }
  }


if(t2w1lwt9<t1+2.0){											/* test of LEFT OUTER wall interaction time - analog inner wall*/
  TEST_UP_DOWN(t2w1lwt9,vz, z,vy,y,l,
               linhd9, louthd9, linhu9, louthu9,
               h2dwt9, h1dwt9,h2uwt9, h1uwt9,
               bhdwt9, z0hd9, a2hdwt9,bhuwt9, z0hu9, a2huwt9,
               pbhdwt9, pahdwt9, pbhuwt9, pahuwt9,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){
  t2w1lwt9=t1+2.0;
  }
  }

if(t2h1uwt9<t1+2.0){											/* test of TOP OUTER wall interaction time - analog inner wall*/
  TEST_LEFT_RIGHT(t2h1uwt9,vz,z,vx,x,l, 
                 linwr9,loutwr9,linwl9,loutwl9,
                 w2rwt9, w1rwt9,w2lwt9,w1lwt9,
                 bwrwt9, z0wr9,a2wrwt9,bwlwt9, z0wl9, a2wlwt9,
                 pbwrwt9, pawrwt9, pbwlwt9, pawlwt9,
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl){
  t2h1uwt9=t1+2.0;
  }
  }


if(t2h1dwt9<t1+2.0){											/* test of BOTTOM OUTER wall interaction time - analog inner wall*/
 TEST_LEFT_RIGHT(t2h1dwt9,vz,z,vx,x,l, 
                 linwr9,loutwr9,linwl9,loutwl9,
                 w2rwt9, w1rwt9,w2lwt9,w1lwt9,
                 bwrwt9, z0wr9,a2wrwt9,bwlwt9, z0wl9, a2wlwt9,
                 pbwrwt9, pawrwt9, pbwlwt9, pawlwt9,
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl)
  {
  t2h1dwt9=t1+2.0;
  }
  }

								/*	TENTH SHELL */

									/* test INNER wall interaction time*/


if(t2w1r10<t1+2.0){											/* test of RIGHT INNER wall interaction time*/
  TEST_UP_DOWN(t2w1r10,vz, z,vy,y, l,
               linhd10, louthd10, linhu10, louthu10,
               h2d10, h1d10,h2u10, h1u10,
               bhd10, z0hd10, a2hd10,bhu10, z0hu10, a2hu10,
               pbhd10, pahd10, pbhu10, pahu10,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){	
  t2w1r10=t1+2.0;
  }
  }

if(t2w1l10<t1+2.0){											/* test of LEFT INNER wall interaction time - analog to right wall*/
  TEST_UP_DOWN(t2w1l10,vz, z,vy,y,l,
               linhd10, louthd10, linhu10, louthu10,
               h2d10, h1d10,h2u10, h1u10,
               bhd10, z0hd10, a2hd10,bhu10, z0hu10, a2hu10,
               pbhd10, pahd10, pbhu10, pahu10,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){
  t2w1l10=t1+2.0;
  }
  }


if(t2h1u10<t1+2.0){											/* test of TOP INNER wall interaction time - analog to right wall*/
  TEST_LEFT_RIGHT(t2h1u10,vz,z,vx,x, l,
                 linwr10,loutwr10,linwl10,loutwl10,
                 w2r10, w1r10,w2l10,w1l10,
                 bwr10, z0wr10,a2wr10,bwl10, z0wl10, a2wl10,
                 pbwr10, pawr10, pbwl10, pawl10,
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl){
  t2h1u10=t1+2.0;
  }
  }


if(t2h1d10<t1+2.0){											/* test of BOTTOM INNER wall interaction time - analog to right wall*/
  TEST_LEFT_RIGHT(t2h1d10,vz,z,vx,x,l,
                 linwr10,loutwr10,linwl10,loutwl10,
                 w2r10, w1r10,w2l10,w1l10,
                 bwr10, z0wr10,a2wr10,bwl10, z0wl10, a2wl10,
                 pbwr10, pawr10, pbwl10, pawl10, 
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl)
  {
  t2h1d10=t1+2.0;
  }
  }


													/* TEST OF THE OUTER INTERSECTION - TIMES */

if(t2w1rwt10<t1+2.0){											/* test of RIGHT OUTER wall interaction time - analog inner wall*/
  TEST_UP_DOWN(t2w1rwt10,vz, z,vy,y, l,
               linhd10, louthd10, linhu10, louthu10,
               h2dwt10, h1dwt10,h2uwt10, h1uwt10,
               bhdwt10, z0hd10, a2hdwt10,bhuwt10, z0hu10, a2huwt10,
               pbhdwt10, pahdwt10, pbhuwt10, pahuwt10,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){
  t2w1rwt10=t1+2.0;
  }
  }


if(t2w1lwt10<t1+2.0){											/* test of LEFT OUTER wall interaction time - analog inner wall*/
  TEST_UP_DOWN(t2w1lwt10,vz, z,vy,y,l,
               linhd10, louthd10, linhu10, louthu10,
               h2dwt10, h1dwt10,h2uwt10, h1uwt10,
               bhdwt10, z0hd10, a2hdwt10,bhuwt10, z0hu10, a2huwt10,
               pbhdwt10, pahdwt10, pbhuwt10, pahuwt10,
               &ylimitd, &ylimitu, &ytest);
  if (ytest<ylimitd || ytest>ylimitu){
  t2w1lwt10=t1+2.0;
  }
  }

if(t2h1uwt10<t1+2.0){											/* test of TOP OUTER wall interaction time - analog inner wall*/
  TEST_LEFT_RIGHT(t2h1uwt10,vz,z,vx,x,l, 
                 linwr10,loutwr10,linwl10,loutwl10,
                 w2rwt10, w1rwt10,w2lwt10,w1lwt10,
                 bwrwt10, z0wr10,a2wrwt10,bwlwt10, z0wl10, a2wlwt10,
                 pbwrwt10, pawrwt10, pbwlwt10, pawlwt10,
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl){
  t2h1uwt10=t1+2.0;
  }
  }


if(t2h1dwt10<t1+2.0){											/* test of BOTTOM OUTER wall interaction time - analog inner wall*/
 TEST_LEFT_RIGHT(t2h1dwt10,vz,z,vx,x,l, 
                 linwr10,loutwr10,linwl10,loutwl10,
                 w2rwt10, w1rwt10,w2lwt10,w1lwt10,
                 bwrwt10, z0wr10,a2wrwt10,bwlwt10, z0wl10, a2wlwt10,
                 pbwrwt10, pawrwt10, pbwlwt10, pawlwt10,
                 &xlimitr, &xlimitl, &xtest);
  if (xtest<xlimitr || xtest>xlimitl)
  {
  t2h1dwt10=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 && t1 < t2w1r3 && t1 < t2w1l3 && t1 < t2h1u3 && t1 < t2h1d3 && t1 < t2w1rwt3 && t1 < t2w1lwt3 && t1 < t2h1uwt3 && t1 < t2h1dwt3 && t1 < t2w1r4 && t1 < t2w1l4 && t1 < t2h1u4 && t1 < t2h1d4 && t1 < t2w1rwt4 && t1 < t2w1lwt4 && t1 < t2h1uwt4 && t1 < t2h1dwt4 && t1 < t2w1r5 && t1 < t2w1l5 && t1 < t2h1u5 && t1 < t2h1d5 && t1 < t2w1rwt5 && t1 < t2w1lwt5 && t1 < t2h1uwt5 && t1 < t2h1dwt5 && t1 < t2w1r6 && t1 < t2w1l6 && t1 < t2h1u6 && t1 < t2h1d6 && t1 < t2w1rwt6 && t1 < t2w1lwt6 && t1 < t2h1uwt6 && t1 < t2h1dwt6 && t1 < t2w1r7 && t1 < t2w1l7 && t1 < t2h1u7 && t1 < t2h1d7 && t1 < t2w1rwt7 && t1 < t2w1lwt7 && t1 < t2h1uwt7 && t1 < t2h1dwt7 && t1 < t2w1r8 && t1 < t2w1l8 && t1 < t2h1u8 && t1 < t2h1d8 && t1 < t2w1rwt8 && t1 < t2w1lwt8 && t1 < t2h1uwt8 && t1 < t2h1dwt8 && t1 < t2w1r9 && t1 < t2w1l9 && t1 < t2h1u9 && t1 < t2h1d9 && t1 < t2w1rwt9 && t1 < t2w1lwt9 && t1 < t2h1uwt9 && t1 < t2h1dwt9 && t1 < t2w1r10 && t1 < t2w1l10 && t1 < t2h1u10 && t1 < t2h1d10 && t1 < t2w1rwt10 && t1 < t2w1lwt10 && t1 < t2h1uwt10 && t1 < t2h1dwt10){
  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 
     && t2w1r < t2w1r3 && t2w1r < t2w1l3 && t2w1r < t2h1u3 && t2w1r < t2h1d3 && t2w1r < t2w1rwt3 && t2w1r < t2w1lwt3 && t2w1r < t2h1uwt3 && t2w1r < t2h1dwt3
     && t2w1r < t2w1r4 && t2w1r < t2w1l4 && t2w1r < t2h1u4 && t2w1r < t2h1d4 && t2w1r < t2w1rwt4 && t2w1r < t2w1lwt4 && t2w1r < t2h1uwt4 && t2w1r < t2h1dwt4
     && t2w1r < t2w1r5 && t2w1r < t2w1l5 && t2w1r < t2h1u5 && t2w1r < t2h1d5 && t2w1r < t2w1rwt5 && t2w1r < t2w1lwt5 && t2w1r < t2h1uwt5 && t2w1r < t2h1dwt5
     && t2w1r < t2w1r6 && t2w1r < t2w1l6 && t2w1r < t2h1u6 && t2w1r < t2h1d6 && t2w1r < t2w1rwt6 && t2w1r < t2w1lwt6 && t2w1r < t2h1uwt6 && t2w1r < t2h1dwt6
     && t2w1r < t2w1r7 && t2w1r < t2w1l7 && t2w1r < t2h1u7 && t2w1r < t2h1d7 && t2w1r < t2w1rwt7 && t2w1r < t2w1lwt7 && t2w1r < t2h1uwt7 && t2w1r < t2h1dwt7
     && t2w1r < t2w1r8 && t2w1r < t2w1l8 && t2w1r < t2h1u8 && t2w1r < t2h1d8 && t2w1r < t2w1rwt8 && t2w1r < t2w1lwt8 && t2w1r < t2h1uwt8 && t2w1r < t2h1dwt8
     && t2w1r < t2w1r9 && t2w1r < t2w1l9 && t2w1r < t2h1u9 && t2w1r < t2h1d9 && t2w1r < t2w1rwt9 && t2w1r < t2w1lwt9 && t2w1r < t2h1uwt9 && t2w1r < t2h1dwt9
     && t2w1r < t2w1r10 && t2w1r < t2w1l10 && t2w1r < t2h1u10 && t2w1r < t2h1d10 && t2w1r < t2w1rwt10 && t2w1r < t2w1lwt10 && t2w1r < t2h1uwt10 && t2w1r < t2h1dwt10) 
    {	
     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
      && t2w1l < t2w1r3 && t2w1l < t2w1l3 && t2w1l < t2h1u3 && t2w1l < t2h1d3 && t2w1l < t2w1rwt3 && t2w1l < t2w1lwt3 && t2w1l < t2h1uwt3 && t2w1l < t2h1dwt3
      && t2w1l < t2w1r4 && t2w1l < t2w1l4 && t2w1l < t2h1u4 && t2w1l < t2h1d4 && t2w1l < t2w1rwt4 && t2w1l < t2w1lwt4 && t2w1l < t2h1uwt4 && t2w1l < t2h1dwt4
      && t2w1l < t2w1r5 && t2w1l < t2w1l5 && t2w1l < t2h1u5 && t2w1l < t2h1d5 && t2w1l < t2w1rwt5 && t2w1l < t2w1lwt5 && t2w1l < t2h1uwt5 && t2w1l < t2h1dwt5
      && t2w1l < t2w1r6 && t2w1l < t2w1l6 && t2w1l < t2h1u6 && t2w1l < t2h1d6 && t2w1l < t2w1rwt6 && t2w1l < t2w1lwt6 && t2w1l < t2h1uwt6 && t2w1l < t2h1dwt6
      && t2w1l < t2w1r7 && t2w1l < t2w1l7 && t2w1l < t2h1u7 && t2w1l < t2h1d7 && t2w1l < t2w1rwt7 && t2w1l < t2w1lwt7 && t2w1l < t2h1uwt7 && t2w1l < t2h1dwt7
      && t2w1l < t2w1r8 && t2w1l < t2w1l8 && t2w1l < t2h1u8 && t2w1l < t2h1d8 && t2w1l < t2w1rwt8 && t2w1l < t2w1lwt8 && t2w1l < t2h1uwt8 && t2w1l < t2h1dwt8
      && t2w1l < t2w1r9 && t2w1l < t2w1l9 && t2w1l < t2h1u9 && t2w1l < t2h1d9 && t2w1l < t2w1rwt9 && t2w1l < t2w1lwt9 && t2w1l < t2h1uwt9 && t2w1l < t2h1dwt9
      && t2w1l < t2w1r10 && t2w1l < t2w1l10 && t2w1l < t2h1u10 && t2w1l < t2h1d10 && t2w1l < t2w1rwt10 && t2w1l < t2w1lwt10 && t2w1l < t2h1uwt10 && t2w1l < t2h1dwt10)
      {
      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
      && t2h1u < t2w1r3 && t2h1u < t2w1l3 && t2h1u < t2h1u3 && t2h1u < t2h1d3 && t2h1u < t2w1rwt3 && t2h1u < t2w1lwt3 && t2h1u < t2h1uwt3 && t2h1u < t2h1dwt3
      && t2h1u < t2w1r4 && t2h1u < t2w1l4 && t2h1u < t2h1u4 && t2h1u < t2h1d4 && t2h1u < t2w1rwt4 && t2h1u < t2w1lwt4 && t2h1u < t2h1uwt4 && t2h1u < t2h1dwt4
      && t2h1u < t2w1r5 && t2h1u < t2w1l5 && t2h1u < t2h1u5 && t2h1u < t2h1d5 && t2h1u < t2w1rwt5 && t2h1u < t2w1lwt5 && t2h1u < t2h1uwt5 && t2h1u < t2h1dwt5
      && t2h1u < t2w1r6 && t2h1u < t2w1l6 && t2h1u < t2h1u6 && t2h1u < t2h1d6 && t2h1u < t2w1rwt6 && t2h1u < t2w1lwt6 && t2h1u < t2h1uwt6 && t2h1u < t2h1dwt6
      && t2h1u < t2w1r7 && t2h1u < t2w1l7 && t2h1u < t2h1u7 && t2h1u < t2h1d7 && t2h1u < t2w1rwt7 && t2h1u < t2w1lwt7 && t2h1u < t2h1uwt7 && t2h1u < t2h1dwt7
      && t2h1u < t2w1r8 && t2h1u < t2w1l8 && t2h1u < t2h1u8 && t2h1u < t2h1d8 && t2h1u < t2w1rwt8 && t2h1u < t2w1lwt8 && t2h1u < t2h1uwt8 && t2h1u < t2h1dwt8
      && t2h1u < t2w1r9 && t2h1u < t2w1l9 && t2h1u < t2h1u9 && t2h1u < t2h1d9 && t2h1u < t2w1rwt9 && t2h1u < t2w1lwt9 && t2h1u < t2h1uwt9 && t2h1u < t2h1dwt9
      && t2h1u < t2w1r10 && t2h1u < t2w1l10 && t2h1u < t2h1u10 && t2h1u < t2h1d10 && t2h1u < t2w1rwt10 && t2h1u < t2w1lwt10 && t2h1u < t2h1uwt10 && t2h1u < t2h1dwt10){
        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
      && t2h1d < t2w1r3 && t2h1d < t2w1l3 && t2h1d < t2h1u3 && t2h1d < t2h1d3 && t2h1d < t2w1rwt3 && t2h1d < t2w1lwt3 && t2h1d < t2h1uwt3 && t2h1d < t2h1dwt3
      && t2h1d < t2w1r4 && t2h1d < t2w1l4 && t2h1d < t2h1u4 && t2h1d < t2h1d4 && t2h1d < t2w1rwt4 && t2h1d < t2w1lwt4 && t2h1d < t2h1uwt4 && t2h1d < t2h1dwt4
      && t2h1d < t2w1r5 && t2h1d < t2w1l5 && t2h1d < t2h1u5 && t2h1d < t2h1d5 && t2h1d < t2w1rwt5 && t2h1d < t2w1lwt5 && t2h1d < t2h1uwt5 && t2h1d < t2h1dwt5
      && t2h1d < t2w1r6 && t2h1d < t2w1l6 && t2h1d < t2h1u6 && t2h1d < t2h1d6 && t2h1d < t2w1rwt6 && t2h1d < t2w1lwt6 && t2h1d < t2h1uwt6 && t2h1d < t2h1dwt6
      && t2h1d < t2w1r7 && t2h1d < t2w1l7 && t2h1d < t2h1u7 && t2h1d < t2h1d7 && t2h1d < t2w1rwt7 && t2h1d < t2w1lwt7 && t2h1d < t2h1uwt7 && t2h1d < t2h1dwt7
      && t2h1d < t2w1r8 && t2h1d < t2w1l8 && t2h1d < t2h1u8 && t2h1d < t2h1d8 && t2h1d < t2w1rwt8 && t2h1d < t2w1lwt8 && t2h1d < t2h1uwt8 && t2h1d < t2h1dwt8
      && t2h1d < t2w1r9 && t2h1d < t2w1l9 && t2h1d < t2h1u9 && t2h1d < t2h1d9 && t2h1d < t2w1rwt9 && t2h1d < t2w1lwt9 && t2h1d < t2h1uwt9 && t2h1d < t2h1dwt9
      && t2h1d < t2w1r10 && t2h1d < t2w1l10 && t2h1d < t2h1u10 && t2h1d < t2h1d10 && t2h1d < t2w1rwt10 && t2h1d < t2w1lwt10 && t2h1d < t2h1uwt10 && t2h1d < t2h1dwt10){
      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 <t2w1lwt && t2w1rwt < t2h1uwt && t2w1rwt < t2h1dwt
  && t2w1rwt < t2w1r1 && t2w1rwt < t2w1l1 && t2w1rwt < t2h1u1 && t2w1rwt < t2h1d1 && t2w1rwt <t2w1rwt1 && t2w1rwt <t2w1lwt1 && t2w1rwt < t2h1uwt1 && t2w1rwt < t2h1dwt1
  && t2w1rwt < t2w1r2 && t2w1rwt < t2w1l2 && t2w1rwt < t2h1u2 && t2w1rwt < t2h1d2 && t2w1rwt <t2w1rwt2 && t2w1rwt <t2w1lwt2 && t2w1rwt < t2h1uwt2 && t2w1rwt < t2h1dwt2
  && t2w1rwt < t2w1r3 && t2w1rwt < t2w1l3 && t2w1rwt < t2h1u3 && t2w1rwt < t2h1d3 && t2w1rwt <t2w1rwt3 && t2w1rwt <t2w1lwt3 && t2w1rwt < t2h1uwt3 && t2w1rwt < t2h1dwt3
  && t2w1rwt < t2w1r4 && t2w1rwt < t2w1l4 && t2w1rwt < t2h1u4 && t2w1rwt < t2h1d4 && t2w1rwt <t2w1rwt4 && t2w1rwt <t2w1lwt4 && t2w1rwt < t2h1uwt4 && t2w1rwt < t2h1dwt4
  && t2w1rwt < t2w1r5 && t2w1rwt < t2w1l5 && t2w1rwt < t2h1u5 && t2w1rwt < t2h1d5 && t2w1rwt <t2w1rwt5 && t2w1rwt <t2w1lwt5 && t2w1rwt < t2h1uwt5 && t2w1rwt < t2h1dwt5
  && t2w1rwt < t2w1r6 && t2w1rwt < t2w1l6 && t2w1rwt < t2h1u6 && t2w1rwt < t2h1d6 && t2w1rwt <t2w1rwt6 && t2w1rwt <t2w1lwt6 && t2w1rwt < t2h1uwt6 && t2w1rwt < t2h1dwt6
  && t2w1rwt < t2w1r7 && t2w1rwt < t2w1l7 && t2w1rwt < t2h1u7 && t2w1rwt < t2h1d7 && t2w1rwt <t2w1rwt7 && t2w1rwt <t2w1lwt7 && t2w1rwt < t2h1uwt7 && t2w1rwt < t2h1dwt7
  && t2w1rwt < t2w1r8 && t2w1rwt < t2w1l8 && t2w1rwt < t2h1u8 && t2w1rwt < t2h1d8 && t2w1rwt <t2w1rwt8 && t2w1rwt <t2w1lwt8 && t2w1rwt < t2h1uwt8 && t2w1rwt < t2h1dwt8
  && t2w1rwt < t2w1r9 && t2w1rwt < t2w1l9 && t2w1rwt < t2h1u9 && t2w1rwt < t2h1d9 && t2w1rwt <t2w1rwt9 && t2w1rwt <t2w1lwt9 && t2w1rwt < t2h1uwt9 && t2w1rwt < t2h1dwt9
  && t2w1rwt < t2w1r10 && t2w1rwt < t2w1l10 && t2w1rwt < t2h1u10 && t2w1rwt < t2h1d10 && t2w1rwt <t2w1rwt10 && t2w1rwt <t2w1lwt10 && t2w1rwt < t2h1uwt10 && t2w1rwt < t2h1dwt10
 ){	
   if (mxrOW == 0) i =34;
   else{
   if (mxrOW == -1) i= 38;
   else{
   if (linwr!=0 && loutwr!=0) i= 22;
   else{
   if ((loutwr!=0 && linwr==0) || (loutwr==0 && linwr!=0)) i = 23;
   else{
   if (loutwr==0 && linwr==0) i= 24;
  }}}}}

/* neutron interacts with the elliptic left OUTER wall - comments are analog to inner elliptic right wall*/

  if (t2w1lwt > 0 && t2w1lwt < t1 
  && t2w1lwt < t2w1r && t2w1lwt < t2w1l && t2w1lwt < t2h1u && t2w1lwt < t2h1d && t2w1lwt <t2w1rwt && t2w1lwt < t2h1uwt && t2w1lwt < t2h1dwt
  && t2w1lwt < t2w1r1 && t2w1lwt < t2w1l1 && t2w1lwt < t2h1u1 && t2w1lwt < t2h1d1 && t2w1lwt <t2w1rwt1 && t2w1lwt <t2w1lwt1 && t2w1lwt < t2h1uwt1 && t2w1lwt < t2h1dwt1
  && t2w1lwt < t2w1r2 && t2w1lwt < t2w1l2 && t2w1lwt < t2h1u2 && t2w1lwt < t2h1d2 && t2w1lwt <t2w1rwt2 && t2w1lwt <t2w1lwt2 && t2w1lwt < t2h1uwt2 && t2w1lwt < t2h1dwt2
  && t2w1lwt < t2w1r3 && t2w1lwt < t2w1l3 && t2w1lwt < t2h1u3 && t2w1lwt < t2h1d3 && t2w1lwt <t2w1rwt3 && t2w1lwt <t2w1lwt3 && t2w1lwt < t2h1uwt3 && t2w1lwt < t2h1dwt3
  && t2w1lwt < t2w1r4 && t2w1lwt < t2w1l4 && t2w1lwt < t2h1u4 && t2w1lwt < t2h1d4 && t2w1lwt <t2w1rwt4 && t2w1lwt <t2w1lwt4 && t2w1lwt < t2h1uwt4 && t2w1lwt < t2h1dwt4
  && t2w1lwt < t2w1r5 && t2w1lwt < t2w1l5 && t2w1lwt < t2h1u5 && t2w1lwt < t2h1d5 && t2w1lwt <t2w1rwt5 && t2w1lwt <t2w1lwt5 && t2w1lwt < t2h1uwt5 && t2w1lwt < t2h1dwt5
  && t2w1lwt < t2w1r6 && t2w1lwt < t2w1l6 && t2w1lwt < t2h1u6 && t2w1lwt < t2h1d6 && t2w1lwt <t2w1rwt6 && t2w1lwt <t2w1lwt6 && t2w1lwt < t2h1uwt6 && t2w1lwt < t2h1dwt6
  && t2w1lwt < t2w1r7 && t2w1lwt < t2w1l7 && t2w1lwt < t2h1u7 && t2w1lwt < t2h1d7 && t2w1lwt <t2w1rwt7 && t2w1lwt <t2w1lwt7 && t2w1lwt < t2h1uwt7 && t2w1lwt < t2h1dwt7
  && t2w1lwt < t2w1r8 && t2w1lwt < t2w1l8 && t2w1lwt < t2h1u8 && t2w1lwt < t2h1d8 && t2w1lwt <t2w1rwt8 && t2w1lwt <t2w1lwt8 && t2w1lwt < t2h1uwt8 && t2w1lwt < t2h1dwt8
  && t2w1lwt < t2w1r9 && t2w1lwt < t2w1l9 && t2w1lwt < t2h1u9 && t2w1lwt < t2h1d9 && t2w1lwt <t2w1rwt9 && t2w1lwt <t2w1lwt9 && t2w1lwt < t2h1uwt9 && t2w1lwt < t2h1dwt9
  && t2w1lwt < t2w1r10 && t2w1lwt < t2w1l10 && t2w1lwt < t2h1u10 && t2w1lwt < t2h1d10 && t2w1lwt <t2w1rwt10 && t2w1lwt <t2w1lwt10 && t2w1lwt < t2h1uwt10 && t2w1lwt < t2h1dwt10
  ){
    if (mxlOW == 0) i = 35;
    else{
    if (mxlOW == -1) i = 39;
    else{
    if (linwl!=0 && loutwl!=0) i=25;
    else{
    if ((loutwl!=0 && linwl==0) || (loutwl==0 && linwl!=0)) i= 26;
    else{
    if (loutwl==0 && linwl==0) i=27;
  }}}}}

/* neutron interacts with the elliptic top OUTER wall - comments are analog to inner elliptic right wall*/

   if (t2h1uwt > 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
  && t2h1uwt < t2w1r3 && t2h1uwt < t2w1l3 && t2h1uwt < t2h1u3 && t2h1uwt < t2h1d3 && t2h1uwt < t2w1rwt3 && t2h1uwt < t2w1lwt3 && t2h1uwt < t2h1uwt3 && t2h1uwt < t2h1dwt3
  && t2h1uwt < t2w1r4 && t2h1uwt < t2w1l4 && t2h1uwt < t2h1u4 && t2h1uwt < t2h1d4 && t2h1uwt < t2w1rwt4 && t2h1uwt < t2w1lwt4 && t2h1uwt < t2h1uwt4 && t2h1uwt < t2h1dwt4
  && t2h1uwt < t2w1r5 && t2h1uwt < t2w1l5 && t2h1uwt < t2h1u5 && t2h1uwt < t2h1d5 && t2h1uwt < t2w1rwt5 && t2h1uwt < t2w1lwt5 && t2h1uwt < t2h1uwt5 && t2h1uwt < t2h1dwt5
  && t2h1uwt < t2w1r6 && t2h1uwt < t2w1l6 && t2h1uwt < t2h1u6 && t2h1uwt < t2h1d6 && t2h1uwt < t2w1rwt6 && t2h1uwt < t2w1lwt6 && t2h1uwt < t2h1uwt6 && t2h1uwt < t2h1dwt6
  && t2h1uwt < t2w1r7 && t2h1uwt < t2w1l7 && t2h1uwt < t2h1u7 && t2h1uwt < t2h1d7 && t2h1uwt < t2w1rwt7 && t2h1uwt < t2w1lwt7 && t2h1uwt < t2h1uwt7 && t2h1uwt < t2h1dwt7
  && t2h1uwt < t2w1r8 && t2h1uwt < t2w1l8 && t2h1uwt < t2h1u8 && t2h1uwt < t2h1d8 && t2h1uwt < t2w1rwt8 && t2h1uwt < t2w1lwt8 && t2h1uwt < t2h1uwt8 && t2h1uwt < t2h1dwt8
  && t2h1uwt < t2w1r9 && t2h1uwt < t2w1l9 && t2h1uwt < t2h1u9 && t2h1uwt < t2h1d9 && t2h1uwt < t2w1rwt9 && t2h1uwt < t2w1lwt9 && t2h1uwt < t2h1uwt9 && t2h1uwt < t2h1dwt9
  && t2h1uwt < t2w1r10 && t2h1uwt < t2w1l10 && t2h1uwt < t2h1u10 && t2h1uwt < t2h1d10 && t2h1uwt < t2w1rwt10 && t2h1uwt < t2w1lwt10 && t2h1uwt < t2h1uwt10 && t2h1uwt < t2h1dwt10
  ){
   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 
  && t2h1dwt < t2w1r3 && t2h1dwt < t2w1l3 && t2h1dwt < t2h1u3 && t2h1dwt < t2h1d3 && t2h1dwt < t2w1rwt3 && t2h1dwt < t2w1lwt3 && t2h1dwt < t2h1uwt3 && t2h1dwt < t2h1dwt3
  && t2h1dwt < t2w1r4 && t2h1dwt < t2w1l4 && t2h1dwt < t2h1u4 && t2h1dwt < t2h1d4 && t2h1dwt < t2w1rwt4 && t2h1dwt < t2w1lwt4 && t2h1dwt < t2h1uwt4 && t2h1dwt < t2h1dwt4
  && t2h1dwt < t2w1r5 && t2h1dwt < t2w1l5 && t2h1dwt < t2h1u5 && t2h1dwt < t2h1d5 && t2h1dwt < t2w1rwt5 && t2h1dwt < t2w1lwt5 && t2h1dwt < t2h1uwt5 && t2h1dwt < t2h1dwt5
  && t2h1dwt < t2w1r6 && t2h1dwt < t2w1l6 && t2h1dwt < t2h1u6 && t2h1dwt < t2h1d6 && t2h1dwt < t2w1rwt6 && t2h1dwt < t2w1lwt6 && t2h1dwt < t2h1uwt6 && t2h1dwt < t2h1dwt6
  && t2h1dwt < t2w1r7 && t2h1dwt < t2w1l7 && t2h1dwt < t2h1u7 && t2h1dwt < t2h1d7 && t2h1dwt < t2w1rwt7 && t2h1dwt < t2w1lwt7 && t2h1dwt < t2h1uwt7 && t2h1dwt < t2h1dwt7 
  && t2h1dwt < t2w1r8 && t2h1dwt < t2w1l8 && t2h1dwt < t2h1u8 && t2h1dwt < t2h1d8 && t2h1dwt < t2w1rwt8 && t2h1dwt < t2w1lwt8 && t2h1dwt < t2h1uwt8 && t2h1dwt < t2h1dwt8
  && t2h1dwt < t2w1r9 && t2h1dwt < t2w1l9 && t2h1dwt < t2h1u9 && t2h1dwt < t2h1d9 && t2h1dwt < t2w1rwt9 && t2h1dwt < t2w1lwt9 && t2h1dwt < t2h1uwt9 && t2h1dwt < t2h1dwt9 
  && t2h1dwt < t2w1r10 && t2h1dwt < t2w1l10 && t2h1dwt < t2h1u10 && t2h1dwt < t2h1d10 && t2h1dwt < t2w1rwt10 && t2h1dwt < t2w1lwt10 && t2h1dwt < t2h1uwt10 && t2h1dwt < t2h1dwt10
  ){
   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 
     && t2w1r1 < t2w1r3 && t2w1r1 < t2w1l3 && t2w1r1 < t2h1u3 && t2w1r1 < t2h1d3 && t2w1r1 < t2w1rwt3 && t2w1r1 < t2w1lwt3 && t2w1r1 < t2h1uwt3 && t2w1r1 < t2h1dwt3
     && t2w1r1 < t2w1r4 && t2w1r1 < t2w1l4 && t2w1r1 < t2h1u4 && t2w1r1 < t2h1d4 && t2w1r1 < t2w1rwt4 && t2w1r1 < t2w1lwt4 && t2w1r1 < t2h1uwt4 && t2w1r1 < t2h1dwt4
     && t2w1r1 < t2w1r5 && t2w1r1 < t2w1l5 && t2w1r1 < t2h1u5 && t2w1r1 < t2h1d5 && t2w1r1 < t2w1rwt5 && t2w1r1 < t2w1lwt5 && t2w1r1 < t2h1uwt5 && t2w1r1 < t2h1dwt5
     && t2w1r1 < t2w1r6 && t2w1r1 < t2w1l6 && t2w1r1 < t2h1u6 && t2w1r1 < t2h1d6 && t2w1r1 < t2w1rwt6 && t2w1r1 < t2w1lwt6 && t2w1r1 < t2h1uwt6 && t2w1r1 < t2h1dwt6
     && t2w1r1 < t2w1r7 && t2w1r1 < t2w1l7 && t2w1r1 < t2h1u7 && t2w1r1 < t2h1d7 && t2w1r1 < t2w1rwt7 && t2w1r1 < t2w1lwt7 && t2w1r1 < t2h1uwt7 && t2w1r1 < t2h1dwt7
     && t2w1r1 < t2w1r8 && t2w1r1 < t2w1l8 && t2w1r1 < t2h1u8 && t2w1r1 < t2h1d8 && t2w1r1 < t2w1rwt8 && t2w1r1 < t2w1lwt8 && t2w1r1 < t2h1uwt8 && t2w1r1 < t2h1dwt8
     && t2w1r1 < t2w1r9 && t2w1r1 < t2w1l9 && t2w1r1 < t2h1u9 && t2w1r1 < t2h1d9 && t2w1r1 < t2w1rwt9 && t2w1r1 < t2w1lwt9 && t2w1r1 < t2h1uwt9 && t2w1r1 < t2h1dwt9
     && t2w1r1 < t2w1r10 && t2w1r1 < t2w1l10 && t2w1r1 < t2h1u10 && t2w1r1 < t2h1d10 && t2w1r1 < t2w1rwt10 && t2w1r1 < t2w1lwt10 && t2w1r1 < t2h1uwt10 && t2w1r1 < t2h1dwt10
     ){
      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
      && t2w1l1 < t2w1r3 && t2w1l1 < t2w1l3 && t2w1l1 < t2h1u3 && t2w1l1 < t2h1d3 && t2w1l1 < t2w1rwt3 && t2w1l1 < t2w1lwt3 && t2w1l1 < t2h1uwt3 && t2w1l1 < t2h1dwt3
      && t2w1l1 < t2w1r4 && t2w1l1 < t2w1l4 && t2w1l1 < t2h1u4 && t2w1l1 < t2h1d4 && t2w1l1 < t2w1rwt4 && t2w1l1 < t2w1lwt4 && t2w1l1 < t2h1uwt4 && t2w1l1 < t2h1dwt4
      && t2w1l1 < t2w1r5 && t2w1l1 < t2w1l5 && t2w1l1 < t2h1u5 && t2w1l1 < t2h1d5 && t2w1l1 < t2w1rwt5 && t2w1l1 < t2w1lwt5 && t2w1l1 < t2h1uwt5 && t2w1l1 < t2h1dwt5
      && t2w1l1 < t2w1r6 && t2w1l1 < t2w1l6 && t2w1l1 < t2h1u6 && t2w1l1 < t2h1d6 && t2w1l1 < t2w1rwt6 && t2w1l1 < t2w1lwt6 && t2w1l1 < t2h1uwt6 && t2w1l1 < t2h1dwt6
      && t2w1l1 < t2w1r7 && t2w1l1 < t2w1l7 && t2w1l1 < t2h1u7 && t2w1l1 < t2h1d7 && t2w1l1 < t2w1rwt7 && t2w1l1 < t2w1lwt7 && t2w1l1 < t2h1uwt7 && t2w1l1 < t2h1dwt7
      && t2w1l1 < t2w1r8 && t2w1l1 < t2w1l8 && t2w1l1 < t2h1u8 && t2w1l1 < t2h1d8 && t2w1l1 < t2w1rwt8 && t2w1l1 < t2w1lwt8 && t2w1l1 < t2h1uwt8 && t2w1l1 < t2h1dwt8
      && t2w1l1 < t2w1r9 && t2w1l1 < t2w1l9 && t2w1l1 < t2h1u9 && t2w1l1 < t2h1d9 && t2w1l1 < t2w1rwt9 && t2w1l1 < t2w1lwt9 && t2w1l1 < t2h1uwt9 && t2w1l1 < t2h1dwt9
      && t2w1l1 < t2w1r10 && t2w1l1 < t2w1l10 && t2w1l1 < t2h1u10 && t2w1l1 < t2h1d10 && t2w1l1 < t2w1rwt10 && t2w1l1 < t2w1lwt10 && t2w1l1 < t2h1uwt10 && t2w1l1 < t2h1dwt10
     ){
        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
  && t2h1u1 < t2w1r3 && t2h1u1 < t2w1l3 && t2h1u1 < t2h1u3 && t2h1u1 < t2h1d3 && t2h1u1 < t2w1rwt3 && t2h1u1 < t2w1lwt3 && t2h1u1 < t2h1uwt3 && t2h1u1 < t2h1dwt3
  && t2h1u1 < t2w1r4 && t2h1u1 < t2w1l4 && t2h1u1 < t2h1u4 && t2h1u1 < t2h1d4 && t2h1u1 < t2w1rwt4 && t2h1u1 < t2w1lwt4 && t2h1u1 < t2h1uwt4 && t2h1u1 < t2h1dwt4
  && t2h1u1 < t2w1r5 && t2h1u1 < t2w1l5 && t2h1u1 < t2h1u5 && t2h1u1 < t2h1d5 && t2h1u1 < t2w1rwt5 && t2h1u1 < t2w1lwt5 && t2h1u1 < t2h1uwt5 && t2h1u1 < t2h1dwt5
  && t2h1u1 < t2w1r6 && t2h1u1 < t2w1l6 && t2h1u1 < t2h1u6 && t2h1u1 < t2h1d6 && t2h1u1 < t2w1rwt6 && t2h1u1 < t2w1lwt6 && t2h1u1 < t2h1uwt6 && t2h1u1 < t2h1dwt6
  && t2h1u1 < t2w1r7 && t2h1u1 < t2w1l7 && t2h1u1 < t2h1u7 && t2h1u1 < t2h1d7 && t2h1u1 < t2w1rwt7 && t2h1u1 < t2w1lwt7 && t2h1u1 < t2h1uwt7 && t2h1u1 < t2h1dwt7
  && t2h1u1 < t2w1r8 && t2h1u1 < t2w1l8 && t2h1u1 < t2h1u8 && t2h1u1 < t2h1d8 && t2h1u1 < t2w1rwt8 && t2h1u1 < t2w1lwt8 && t2h1u1 < t2h1uwt8 && t2h1u1 < t2h1dwt8
  && t2h1u1 < t2w1r9 && t2h1u1 < t2w1l9 && t2h1u1 < t2h1u9 && t2h1u1 < t2h1d9 && t2h1u1 < t2w1rwt9 && t2h1u1 < t2w1lwt9 && t2h1u1 < t2h1uwt9 && t2h1u1 < t2h1dwt9
  && t2h1u1 < t2w1r10 && t2h1u1 < t2w1l10 && t2h1u1 < t2h1u10 && t2h1u1 < t2h1d10 && t2h1u1 < t2w1rwt10 && t2h1u1 < t2w1lwt10 && t2h1u1 < t2h1uwt10 && t2h1u1 < t2h1dwt10
){
   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
  && t2h1d1 < t2w1r3 && t2h1d1 < t2w1l3 && t2h1d1 < t2h1u3 && t2h1d1 < t2h1d3 && t2h1d1 < t2w1rwt3 && t2h1d1 < t2w1lwt3 && t2h1d1 < t2h1uwt3 && t2h1d1 < t2h1dwt3
  && t2h1d1 < t2w1r4 && t2h1d1 < t2w1l4 && t2h1d1 < t2h1u4 && t2h1d1 < t2h1d4 && t2h1d1 < t2w1rwt4 && t2h1d1 < t2w1lwt4 && t2h1d1 < t2h1uwt4 && t2h1d1 < t2h1dwt4
  && t2h1d1 < t2w1r5 && t2h1d1 < t2w1l5 && t2h1d1 < t2h1u5 && t2h1d1 < t2h1d5 && t2h1d1 < t2w1rwt5 && t2h1d1 < t2w1lwt5 && t2h1d1 < t2h1uwt5 && t2h1d1 < t2h1dwt5
  && t2h1d1 < t2w1r6 && t2h1d1 < t2w1l6 && t2h1d1 < t2h1u6 && t2h1d1 < t2h1d6 && t2h1d1 < t2w1rwt6 && t2h1d1 < t2w1lwt6 && t2h1d1 < t2h1uwt6 && t2h1d1 < t2h1dwt6
  && t2h1d1 < t2w1r7 && t2h1d1 < t2w1l7 && t2h1d1 < t2h1u7 && t2h1d1 < t2h1d7 && t2h1d1 < t2w1rwt7 && t2h1d1 < t2w1lwt7 && t2h1d1 < t2h1uwt7 && t2h1d1 < t2h1dwt7
  && t2h1d1 < t2w1r8 && t2h1d1 < t2w1l8 && t2h1d1 < t2h1u8 && t2h1d1 < t2h1d8 && t2h1d1 < t2w1rwt8 && t2h1d1 < t2w1lwt8 && t2h1d1 < t2h1uwt8 && t2h1d1 < t2h1dwt8
  && t2h1d1 < t2w1r9 && t2h1d1 < t2w1l9 && t2h1d1 < t2h1u9 && t2h1d1 < t2h1d9 && t2h1d1 < t2w1rwt9 && t2h1d1 < t2w1lwt9 && t2h1d1 < t2h1uwt9 && t2h1d1 < t2h1dwt9
  && t2h1d1 < t2w1r10 && t2h1d1 < t2w1l10 && t2h1d1 < t2h1u10 && t2h1d1 < t2h1d10 && t2h1d1 < t2w1rwt10 && t2h1d1 < t2w1lwt10 && t2h1d1 < t2h1uwt10 && t2h1d1 < t2h1dwt10
  ){
  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 <t2w1rwt && t2w1rwt1 <t2w1lwt && t2w1rwt1 < t2h1uwt && t2w1rwt1 < t2h1dwt
  && t2w1rwt1 < t2w1r1 && t2w1rwt1 < t2w1l1 && t2w1rwt1 < t2h1u1 && t2w1rwt1 < t2h1d1 && t2w1rwt1 <t2w1lwt1 && t2w1rwt1 < t2h1uwt1 && t2w1rwt1 < t2h1dwt1
  && t2w1rwt1 < t2w1r2 && t2w1rwt1 < t2w1l2 && t2w1rwt1 < t2h1u2 && t2w1rwt1 < t2h1d2 && t2w1rwt1 <t2w1rwt2 && t2w1rwt1 <t2w1lwt2 && t2w1rwt1 < t2h1uwt2 && t2w1rwt1 < t2h1dwt2
  && t2w1rwt1 < t2w1r3 && t2w1rwt1 < t2w1l3 && t2w1rwt1 < t2h1u3 && t2w1rwt1 < t2h1d3 && t2w1rwt1 <t2w1rwt3 && t2w1rwt1 <t2w1lwt3 && t2w1rwt1 < t2h1uwt3 && t2w1rwt1 < t2h1dwt3
  && t2w1rwt1 < t2w1r4 && t2w1rwt1 < t2w1l4 && t2w1rwt1 < t2h1u4 && t2w1rwt1 < t2h1d4 && t2w1rwt1 <t2w1rwt4 && t2w1rwt1 <t2w1lwt4 && t2w1rwt1 < t2h1uwt4 && t2w1rwt1 < t2h1dwt4
  && t2w1rwt1 < t2w1r5 && t2w1rwt1 < t2w1l5 && t2w1rwt1 < t2h1u5 && t2w1rwt1 < t2h1d5 && t2w1rwt1 <t2w1rwt5 && t2w1rwt1 <t2w1lwt5 && t2w1rwt1 < t2h1uwt5 && t2w1rwt1 < t2h1dwt5
  && t2w1rwt1 < t2w1r6 && t2w1rwt1 < t2w1l6 && t2w1rwt1 < t2h1u6 && t2w1rwt1 < t2h1d6 && t2w1rwt1 <t2w1rwt6 && t2w1rwt1 <t2w1lwt6 && t2w1rwt1 < t2h1uwt6 && t2w1rwt1 < t2h1dwt6
  && t2w1rwt1 < t2w1r7 && t2w1rwt1 < t2w1l7 && t2w1rwt1 < t2h1u7 && t2w1rwt1 < t2h1d7 && t2w1rwt1 <t2w1rwt7 && t2w1rwt1 <t2w1lwt7 && t2w1rwt1 < t2h1uwt7 && t2w1rwt1 < t2h1dwt7
  && t2w1rwt1 < t2w1r8 && t2w1rwt1 < t2w1l8 && t2w1rwt1 < t2h1u8 && t2w1rwt1 < t2h1d8 && t2w1rwt1 <t2w1rwt8 && t2w1rwt1 <t2w1lwt8 && t2w1rwt1 < t2h1uwt8 && t2w1rwt1 < t2h1dwt8
  && t2w1rwt1 < t2w1r9 && t2w1rwt1 < t2w1l9 && t2w1rwt1 < t2h1u9 && t2w1rwt1 < t2h1d9 && t2w1rwt1 <t2w1rwt9 && t2w1rwt1 <t2w1lwt9 && t2w1rwt1 < t2h1uwt9 && t2w1rwt1 < t2h1dwt9
  && t2w1rwt1 < t2w1r10 && t2w1rwt1 < t2w1l10 && t2w1rwt1 < t2h1u10 && t2w1rwt1 < t2h1d10 && t2w1rwt1 <t2w1rwt10 && t2w1rwt1 <t2w1lwt10 && t2w1rwt1 < t2h1uwt10 && t2w1rwt1 < t2h1dwt10
  ){	
      if (mxrOW1 == 0) i =74;
      else{
      if (mxrOW1 == -1) i= 78;
      else{
      if (linwr1!=0 && loutwr1!=0) i= 62;
      else{
      if ((loutwr1!=0 && linwr1==0) || (loutwr1==0 && linwr1!=0)) i = 63;
      else{
      if (loutwr1==0 && linwr1==0) i= 64;
  }}}}}


 if (t2w1lwt1 > 0 && t2w1lwt1 < t1 
  && t2w1lwt1 < t2w1r && t2w1lwt1 < t2w1l && t2w1lwt1 < t2h1u && t2w1lwt1 < t2h1d && t2w1lwt1 <t2w1rwt && t2w1lwt1 <t2w1lwt && t2w1lwt1 < t2h1uwt && t2w1lwt1 < t2h1dwt
  && t2w1lwt1 < t2w1r1 && t2w1lwt1 < t2w1l1 && t2w1lwt1 < t2h1u1 && t2w1lwt1 < t2h1d1 && t2w1lwt1 <t2w1rwt1 && t2w1lwt1 < t2h1uwt1 && t2w1lwt1 < t2h1dwt1
  && t2w1lwt1 < t2w1r2 && t2w1lwt1 < t2w1l2 && t2w1lwt1 < t2h1u2 && t2w1lwt1 < t2h1d2 && t2w1lwt1 <t2w1rwt2 && t2w1lwt1 <t2w1lwt2 && t2w1lwt1 < t2h1uwt2 && t2w1lwt1 < t2h1dwt2
  && t2w1lwt1 < t2w1r3 && t2w1lwt1 < t2w1l3 && t2w1lwt1 < t2h1u3 && t2w1lwt1 < t2h1d3 && t2w1lwt1 <t2w1rwt3 && t2w1lwt1 <t2w1lwt3 && t2w1lwt1 < t2h1uwt3 && t2w1lwt1 < t2h1dwt3
  && t2w1lwt1 < t2w1r4 && t2w1lwt1 < t2w1l4 && t2w1lwt1 < t2h1u4 && t2w1lwt1 < t2h1d4 && t2w1lwt1 <t2w1rwt4 && t2w1lwt1 <t2w1lwt4 && t2w1lwt1 < t2h1uwt4 && t2w1lwt1 < t2h1dwt4
  && t2w1lwt1 < t2w1r5 && t2w1lwt1 < t2w1l5 && t2w1lwt1 < t2h1u5 && t2w1lwt1 < t2h1d5 && t2w1lwt1 <t2w1rwt5 && t2w1lwt1 <t2w1lwt5 && t2w1lwt1 < t2h1uwt5 && t2w1lwt1 < t2h1dwt5
  && t2w1lwt1 < t2w1r6 && t2w1lwt1 < t2w1l6 && t2w1lwt1 < t2h1u6 && t2w1lwt1 < t2h1d6 && t2w1lwt1 <t2w1rwt6 && t2w1lwt1 <t2w1lwt6 && t2w1lwt1 < t2h1uwt6 && t2w1lwt1 < t2h1dwt6
  && t2w1lwt1 < t2w1r7 && t2w1lwt1 < t2w1l7 && t2w1lwt1 < t2h1u7 && t2w1lwt1 < t2h1d7 && t2w1lwt1 <t2w1rwt7 && t2w1lwt1 <t2w1lwt7 && t2w1lwt1 < t2h1uwt7 && t2w1lwt1 < t2h1dwt7
  && t2w1lwt1 < t2w1r8 && t2w1lwt1 < t2w1l8 && t2w1lwt1 < t2h1u8 && t2w1lwt1 < t2h1d8 && t2w1lwt1 <t2w1rwt8 && t2w1lwt1 <t2w1lwt8 && t2w1lwt1 < t2h1uwt8 && t2w1lwt1 < t2h1dwt8
  && t2w1lwt1 < t2w1r9 && t2w1lwt1 < t2w1l9 && t2w1lwt1 < t2h1u9 && t2w1lwt1 < t2h1d9 && t2w1lwt1 <t2w1rwt9 && t2w1lwt1 <t2w1lwt9 && t2w1lwt1 < t2h1uwt9 && t2w1lwt1 < t2h1dwt9
  && t2w1lwt1 < t2w1r10 && t2w1lwt1 < t2w1l10 && t2w1lwt1 < t2h1u10 && t2w1lwt1 < t2h1d10 && t2w1lwt1 <t2w1rwt10 && t2w1lwt1 <t2w1lwt10 && t2w1lwt1 < t2h1uwt10 && t2w1lwt1 < t2h1dwt10
  ){
        if (mxlOW1 == 0) i = 75;
        else{
        if (mxlOW1 == -1) i = 79;
        else{
        if (linwl1!=0 && loutwl1!=0) i=65;
        else{
        if ((loutwl1!=0 && linwl1==0) || (loutwl1==0 && linwl1!=0)) i= 66;
        else{
        if (loutwl1==0 && linwl1==0) i=67;
  }}}}}


  if (t2h1uwt1 > 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
  && t2h1uwt1 < t2w1r3 && t2h1uwt1 < t2w1l3 && t2h1uwt1 < t2h1u3 && t2h1uwt1 < t2h1d3 && t2h1uwt1 < t2w1rwt3 && t2h1uwt1 < t2w1lwt3 && t2h1uwt1 < t2h1uwt3 && t2h1uwt1 < t2h1dwt3
  && t2h1uwt1 < t2w1r4 && t2h1uwt1 < t2w1l4 && t2h1uwt1 < t2h1u4 && t2h1uwt1 < t2h1d4 && t2h1uwt1 < t2w1rwt4 && t2h1uwt1 < t2w1lwt4 && t2h1uwt1 < t2h1uwt4 && t2h1uwt1 < t2h1dwt4
  && t2h1uwt1 < t2w1r5 && t2h1uwt1 < t2w1l5 && t2h1uwt1 < t2h1u5 && t2h1uwt1 < t2h1d5 && t2h1uwt1 < t2w1rwt5 && t2h1uwt1 < t2w1lwt5 && t2h1uwt1 < t2h1uwt5 && t2h1uwt1 < t2h1dwt5
  && t2h1uwt1 < t2w1r6 && t2h1uwt1 < t2w1l6 && t2h1uwt1 < t2h1u6 && t2h1uwt1 < t2h1d6 && t2h1uwt1 < t2w1rwt6 && t2h1uwt1 < t2w1lwt6 && t2h1uwt1 < t2h1uwt6 && t2h1uwt1 < t2h1dwt6
  && t2h1uwt1 < t2w1r7 && t2h1uwt1 < t2w1l7 && t2h1uwt1 < t2h1u7 && t2h1uwt1 < t2h1d7 && t2h1uwt1 < t2w1rwt7 && t2h1uwt1 < t2w1lwt7 && t2h1uwt1 < t2h1uwt7 && t2h1uwt1 < t2h1dwt7
  && t2h1uwt1 < t2w1r8 && t2h1uwt1 < t2w1l8 && t2h1uwt1 < t2h1u8 && t2h1uwt1 < t2h1d8 && t2h1uwt1 < t2w1rwt8 && t2h1uwt1 < t2w1lwt8 && t2h1uwt1 < t2h1uwt8 && t2h1uwt1 < t2h1dwt8
  && t2h1uwt1 < t2w1r9 && t2h1uwt1 < t2w1l9 && t2h1uwt1 < t2h1u9 && t2h1uwt1 < t2h1d9 && t2h1uwt1 < t2w1rwt9 && t2h1uwt1 < t2w1lwt9 && t2h1uwt1 < t2h1uwt9 && t2h1uwt1 < t2h1dwt9
  && t2h1uwt1 < t2w1r10 && t2h1uwt1 < t2w1l10 && t2h1uwt1 < t2h1u10 && t2h1uwt1 < t2h1d10 && t2h1uwt1 < t2w1rwt10 && t2h1uwt1 < t2w1lwt10 && t2h1uwt1 < t2h1uwt10 && t2h1uwt1 < t2h1dwt10
  ){
   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 
  && t2h1dwt1 < t2w1r3 && t2h1dwt1 < t2w1l3 && t2h1dwt1 < t2h1u3 && t2h1dwt1 < t2h1d3 && t2h1dwt1 < t2w1rwt3 && t2h1dwt1 < t2w1lwt3 && t2h1dwt1 < t2h1uwt3 && t2h1dwt1 < t2h1dwt3
  && t2h1dwt1 < t2w1r4 && t2h1dwt1 < t2w1l4 && t2h1dwt1 < t2h1u4 && t2h1dwt1 < t2h1d4 && t2h1dwt1 < t2w1rwt4 && t2h1dwt1 < t2w1lwt4 && t2h1dwt1 < t2h1uwt4 && t2h1dwt1 < t2h1dwt4
  && t2h1dwt1 < t2w1r5 && t2h1dwt1 < t2w1l5 && t2h1dwt1 < t2h1u5 && t2h1dwt1 < t2h1d5 && t2h1dwt1 < t2w1rwt5 && t2h1dwt1 < t2w1lwt5 && t2h1dwt1 < t2h1uwt5 && t2h1dwt1 < t2h1dwt5
  && t2h1dwt1 < t2w1r6 && t2h1dwt1 < t2w1l6 && t2h1dwt1 < t2h1u6 && t2h1dwt1 < t2h1d6 && t2h1dwt1 < t2w1rwt6 && t2h1dwt1 < t2w1lwt6 && t2h1dwt1 < t2h1uwt6 && t2h1dwt1 < t2h1dwt6
  && t2h1dwt1 < t2w1r7 && t2h1dwt1 < t2w1l7 && t2h1dwt1 < t2h1u7 && t2h1dwt1 < t2h1d7 && t2h1dwt1 < t2w1rwt7 && t2h1dwt1 < t2w1lwt7 && t2h1dwt1 < t2h1uwt7 && t2h1dwt1 < t2h1dwt7 
  && t2h1dwt1 < t2w1r8 && t2h1dwt1 < t2w1l8 && t2h1dwt1 < t2h1u8 && t2h1dwt1 < t2h1d8 && t2h1dwt1 < t2w1rwt8 && t2h1dwt1 < t2w1lwt8 && t2h1dwt1 < t2h1uwt8 && t2h1dwt1 < t2h1dwt8
  && t2h1dwt1 < t2w1r9 && t2h1dwt1 < t2w1l9 && t2h1dwt1 < t2h1u9 && t2h1dwt1 < t2h1d9 && t2h1dwt1 < t2w1rwt9 && t2h1dwt1 < t2w1lwt9 && t2h1dwt1 < t2h1uwt9 && t2h1dwt1 < t2h1dwt9 
  && t2h1dwt1 < t2w1r10 && t2h1dwt1 < t2w1l10 && t2h1dwt1 < t2h1u10 && t2h1dwt1 < t2h1d10 && t2h1dwt1 < t2w1rwt10 && t2h1dwt1 < t2w1lwt10 && t2h1dwt1 < t2h1uwt10 && t2h1dwt1 < t2h1dwt10)
  {
   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 
     && t2w1r2 < t2w1r3 && t2w1r2 < t2w1l3 && t2w1r2 < t2h1u3 && t2w1r2 < t2h1d3 && t2w1r2 < t2w1rwt3 && t2w1r2 < t2w1lwt3 && t2w1r2 < t2h1uwt3 && t2w1r2 < t2h1dwt3
     && t2w1r2 < t2w1r4 && t2w1r2 < t2w1l4 && t2w1r2 < t2h1u4 && t2w1r2 < t2h1d4 && t2w1r2 < t2w1rwt4 && t2w1r2 < t2w1lwt4 && t2w1r2 < t2h1uwt4 && t2w1r2 < t2h1dwt4
     && t2w1r2 < t2w1r5 && t2w1r2 < t2w1l5 && t2w1r2 < t2h1u5 && t2w1r2 < t2h1d5 && t2w1r2 < t2w1rwt5 && t2w1r2 < t2w1lwt5 && t2w1r2 < t2h1uwt5 && t2w1r2 < t2h1dwt5
     && t2w1r2 < t2w1r6 && t2w1r2 < t2w1l6 && t2w1r2 < t2h1u6 && t2w1r2 < t2h1d6 && t2w1r2 < t2w1rwt6 && t2w1r2 < t2w1lwt6 && t2w1r2 < t2h1uwt6 && t2w1r2 < t2h1dwt6
     && t2w1r2 < t2w1r7 && t2w1r2 < t2w1l7 && t2w1r2 < t2h1u7 && t2w1r2 < t2h1d7 && t2w1r2 < t2w1rwt7 && t2w1r2 < t2w1lwt7 && t2w1r2 < t2h1uwt7 && t2w1r2 < t2h1dwt7
     && t2w1r2 < t2w1r8 && t2w1r2 < t2w1l8 && t2w1r2 < t2h1u8 && t2w1r2 < t2h1d8 && t2w1r2 < t2w1rwt8 && t2w1r2 < t2w1lwt8 && t2w1r2 < t2h1uwt8 && t2w1r2 < t2h1dwt8
     && t2w1r2 < t2w1r9 && t2w1r2 < t2w1l9 && t2w1r2 < t2h1u9 && t2w1r2 < t2h1d9 && t2w1r2 < t2w1rwt9 && t2w1r2 < t2w1lwt9 && t2w1r2 < t2h1uwt9 && t2w1r2 < t2h1dwt9
     && t2w1r2 < t2w1r10 && t2w1r2 < t2w1l10 && t2w1r2 < t2h1u10 && t2w1r2 < t2h1d10 && t2w1r2 < t2w1rwt10 && t2w1r2 < t2w1lwt10 && t2w1r2 < t2h1uwt10 && t2w1r2 < t2h1dwt10)
     {
      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
      && t2w1l2 < t2w1r3 && t2w1l2 < t2w1l3 && t2w1l2 < t2h1u3 && t2w1l2 < t2h1d3 && t2w1l2 < t2w1rwt3 && t2w1l2 < t2w1lwt3 && t2w1l2 < t2h1uwt3 && t2w1l2 < t2h1dwt3
      && t2w1l2 < t2w1r4 && t2w1l2 < t2w1l4 && t2w1l2 < t2h1u4 && t2w1l2 < t2h1d4 && t2w1l2 < t2w1rwt4 && t2w1l2 < t2w1lwt4 && t2w1l2 < t2h1uwt4 && t2w1l2 < t2h1dwt4
      && t2w1l2 < t2w1r5 && t2w1l2 < t2w1l5 && t2w1l2 < t2h1u5 && t2w1l2 < t2h1d5 && t2w1l2 < t2w1rwt5 && t2w1l2 < t2w1lwt5 && t2w1l2 < t2h1uwt5 && t2w1l2 < t2h1dwt5
      && t2w1l2 < t2w1r6 && t2w1l2 < t2w1l6 && t2w1l2 < t2h1u6 && t2w1l2 < t2h1d6 && t2w1l2 < t2w1rwt6 && t2w1l2 < t2w1lwt6 && t2w1l2 < t2h1uwt6 && t2w1l2 < t2h1dwt6
      && t2w1l2 < t2w1r7 && t2w1l2 < t2w1l7 && t2w1l2 < t2h1u7 && t2w1l2 < t2h1d7 && t2w1l2 < t2w1rwt7 && t2w1l2 < t2w1lwt7 && t2w1l2 < t2h1uwt7 && t2w1l2 < t2h1dwt7
      && t2w1l2 < t2w1r8 && t2w1l2 < t2w1l8 && t2w1l2 < t2h1u8 && t2w1l2 < t2h1d8 && t2w1l2 < t2w1rwt8 && t2w1l2 < t2w1lwt8 && t2w1l2 < t2h1uwt8 && t2w1l2 < t2h1dwt8
      && t2w1l2 < t2w1r9 && t2w1l2 < t2w1l9 && t2w1l2 < t2h1u9 && t2w1l2 < t2h1d9 && t2w1l2 < t2w1rwt9 && t2w1l2 < t2w1lwt9 && t2w1l2 < t2h1uwt9 && t2w1l2 < t2h1dwt9
      && t2w1l2 < t2w1r10 && t2w1l2 < t2w1l10 && t2w1l2 < t2h1u10 && t2w1l2 < t2h1d10 && t2w1l2 < t2w1rwt10 && t2w1l2 < t2w1lwt10 && t2w1l2 < t2h1uwt10 && t2w1l2 < t2h1dwt10)
      {
        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
  && t2h1u2 < t2w1r3 && t2h1u2 < t2w1l3 && t2h1u2 < t2h1u3 && t2h1u2 < t2h1d3 && t2h1u2 < t2w1rwt3 && t2h1u2 < t2w1lwt3 && t2h1u2 < t2h1uwt3 && t2h1u2 < t2h1dwt3
  && t2h1u2 < t2w1r4 && t2h1u2 < t2w1l4 && t2h1u2 < t2h1u4 && t2h1u2 < t2h1d4 && t2h1u2 < t2w1rwt4 && t2h1u2 < t2w1lwt4 && t2h1u2 < t2h1uwt4 && t2h1u2 < t2h1dwt4
  && t2h1u2 < t2w1r5 && t2h1u2 < t2w1l5 && t2h1u2 < t2h1u5 && t2h1u2 < t2h1d5 && t2h1u2 < t2w1rwt5 && t2h1u2 < t2w1lwt5 && t2h1u2 < t2h1uwt5 && t2h1u2 < t2h1dwt5
  && t2h1u2 < t2w1r6 && t2h1u2 < t2w1l6 && t2h1u2 < t2h1u6 && t2h1u2 < t2h1d6 && t2h1u2 < t2w1rwt6 && t2h1u2 < t2w1lwt6 && t2h1u2 < t2h1uwt6 && t2h1u2 < t2h1dwt6
  && t2h1u2 < t2w1r7 && t2h1u2 < t2w1l7 && t2h1u2 < t2h1u7 && t2h1u2 < t2h1d7 && t2h1u2 < t2w1rwt7 && t2h1u2 < t2w1lwt7 && t2h1u2 < t2h1uwt7 && t2h1u2 < t2h1dwt7
  && t2h1u2 < t2w1r8 && t2h1u2 < t2w1l8 && t2h1u2 < t2h1u8 && t2h1u2 < t2h1d8 && t2h1u2 < t2w1rwt8 && t2h1u2 < t2w1lwt8 && t2h1u2 < t2h1uwt8 && t2h1u2 < t2h1dwt8
  && t2h1u2 < t2w1r9 && t2h1u2 < t2w1l9 && t2h1u2 < t2h1u9 && t2h1u2 < t2h1d9 && t2h1u2 < t2w1rwt9 && t2h1u2 < t2w1lwt9 && t2h1u2 < t2h1uwt9 && t2h1u2 < t2h1dwt9
  && t2h1u2 < t2w1r10 && t2h1u2 < t2w1l10 && t2h1u2 < t2h1u10 && t2h1u2 < t2h1d10 && t2h1u2 < t2w1rwt10 && t2h1u2 < t2w1lwt10 && t2h1u2 < t2h1uwt10 && t2h1u2 < t2h1dwt10)
  {
   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
  && t2h1d2 < t2w1r3 && t2h1d2 < t2w1l3 && t2h1d2 < t2h1u3 && t2h1d2 < t2h1d3 && t2h1d2 < t2w1rwt3 && t2h1d2 < t2w1lwt3 && t2h1d2 < t2h1uwt3 && t2h1d2 < t2h1dwt3
  && t2h1d2 < t2w1r4 && t2h1d2 < t2w1l4 && t2h1d2 < t2h1u4 && t2h1d2 < t2h1d4 && t2h1d2 < t2w1rwt4 && t2h1d2 < t2w1lwt4 && t2h1d2 < t2h1uwt4 && t2h1d2 < t2h1dwt4
  && t2h1d2 < t2w1r5 && t2h1d2 < t2w1l5 && t2h1d2 < t2h1u5 && t2h1d2 < t2h1d5 && t2h1d2 < t2w1rwt5 && t2h1d2 < t2w1lwt5 && t2h1d2 < t2h1uwt5 && t2h1d2 < t2h1dwt5
  && t2h1d2 < t2w1r6 && t2h1d2 < t2w1l6 && t2h1d2 < t2h1u6 && t2h1d2 < t2h1d6 && t2h1d2 < t2w1rwt6 && t2h1d2 < t2w1lwt6 && t2h1d2 < t2h1uwt6 && t2h1d2 < t2h1dwt6
  && t2h1d2 < t2w1r7 && t2h1d2 < t2w1l7 && t2h1d2 < t2h1u7 && t2h1d2 < t2h1d7 && t2h1d2 < t2w1rwt7 && t2h1d2 < t2w1lwt7 && t2h1d2 < t2h1uwt7 && t2h1d2 < t2h1dwt7
  && t2h1d2 < t2w1r8 && t2h1d2 < t2w1l8 && t2h1d2 < t2h1u8 && t2h1d2 < t2h1d8 && t2h1d2 < t2w1rwt8 && t2h1d2 < t2w1lwt8 && t2h1d2 < t2h1uwt8 && t2h1d2 < t2h1dwt8
  && t2h1d2 < t2w1r9 && t2h1d2 < t2w1l9 && t2h1d2 < t2h1u9 && t2h1d2 < t2h1d9 && t2h1d2 < t2w1rwt9 && t2h1d2 < t2w1lwt9 && t2h1d2 < t2h1uwt9 && t2h1d2 < t2h1dwt9
  && t2h1d2 < t2w1r10 && t2h1d2 < t2w1l10 && t2h1d2 < t2h1u10 && t2h1d2 < t2h1d10 && t2h1d2 < t2w1rwt10 && t2h1d2 < t2w1lwt10 && t2h1d2 < t2h1uwt10 && t2h1d2 < t2h1dwt10)
{
   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 <t2w1rwt && t2w1rwt2 <t2w1lwt && t2w1rwt2 < t2h1uwt && t2w1rwt2 < t2h1dwt
  && t2w1rwt2 < t2w1r1 && t2w1rwt2 < t2w1l1 && t2w1rwt2 < t2h1u1 && t2w1rwt2 < t2h1d1 && t2w1rwt2 <t2w1rwt1 && t2w1rwt2 <t2w1lwt1 && t2w1rwt2 < t2h1uwt1 && t2w1rwt2 < t2h1dwt1
  && t2w1rwt2 < t2w1r2 && t2w1rwt2 < t2w1l2 && t2w1rwt2 < t2h1u2 && t2w1rwt2 < t2h1d2 && t2w1rwt2 <t2w1lwt2 && t2w1rwt2 < t2h1uwt2 && t2w1rwt2 < t2h1dwt2
  && t2w1rwt2 < t2w1r3 && t2w1rwt2 < t2w1l3 && t2w1rwt2 < t2h1u3 && t2w1rwt2 < t2h1d3 && t2w1rwt2 <t2w1rwt3 && t2w1rwt2 <t2w1lwt3 && t2w1rwt2 < t2h1uwt3 && t2w1rwt2 < t2h1dwt3
  && t2w1rwt2 < t2w1r4 && t2w1rwt2 < t2w1l4 && t2w1rwt2 < t2h1u4 && t2w1rwt2 < t2h1d4 && t2w1rwt2 <t2w1rwt4 && t2w1rwt2 <t2w1lwt4 && t2w1rwt2 < t2h1uwt4 && t2w1rwt2 < t2h1dwt4
  && t2w1rwt2 < t2w1r5 && t2w1rwt2 < t2w1l5 && t2w1rwt2 < t2h1u5 && t2w1rwt2 < t2h1d5 && t2w1rwt2 <t2w1rwt5 && t2w1rwt2 <t2w1lwt5 && t2w1rwt2 < t2h1uwt5 && t2w1rwt2 < t2h1dwt5
  && t2w1rwt2 < t2w1r6 && t2w1rwt2 < t2w1l6 && t2w1rwt2 < t2h1u6 && t2w1rwt2 < t2h1d6 && t2w1rwt2 <t2w1rwt6 && t2w1rwt2 <t2w1lwt6 && t2w1rwt2 < t2h1uwt6 && t2w1rwt2 < t2h1dwt6
  && t2w1rwt2 < t2w1r7 && t2w1rwt2 < t2w1l7 && t2w1rwt2 < t2h1u7 && t2w1rwt2 < t2h1d7 && t2w1rwt2 <t2w1rwt7 && t2w1rwt2 <t2w1lwt7 && t2w1rwt2 < t2h1uwt7 && t2w1rwt2 < t2h1dwt7
  && t2w1rwt2 < t2w1r8 && t2w1rwt2 < t2w1l8 && t2w1rwt2 < t2h1u8 && t2w1rwt2 < t2h1d8 && t2w1rwt2 <t2w1rwt8 && t2w1rwt2 <t2w1lwt8 && t2w1rwt2 < t2h1uwt8 && t2w1rwt2 < t2h1dwt8
  && t2w1rwt2 < t2w1r9 && t2w1rwt2 < t2w1l9 && t2w1rwt2 < t2h1u9 && t2w1rwt2 < t2h1d9 && t2w1rwt2 <t2w1rwt9 && t2w1rwt2 <t2w1lwt9 && t2w1rwt2 < t2h1uwt9 && t2w1rwt2 < t2h1dwt9
  && t2w1rwt2 < t2w1r10 && t2w1rwt2 < t2w1l10 && t2w1rwt2 < t2h1u10 && t2w1rwt2 < t2h1d10 && t2w1rwt2 <t2w1rwt10 && t2w1rwt2 <t2w1lwt10 && t2w1rwt2 < t2h1uwt10 && t2w1rwt2 < t2h1dwt10)
 {
      if (mxrOW2 == 0) i =114;
      else{
      if (mxrOW2 == -1) i= 118;
      else{
      if (linwr2!=0 && loutwr2!=0) i= 102;
      else{
      if ((loutwr2!=0 && linwr2==0) || (loutwr2==0 && linwr2!=0)) i = 103;
      else{
      if (loutwr2==0 && linwr2==0) i= 104;
     }}}}}

													/* neutron interacts with the elliptic left OUTER wall - comments are analog to inner elliptic right wall*/

  if (t2w1lwt2 > 0 && t2w1lwt2 < t1 
  && t2w1lwt2 < t2w1r && t2w1lwt2 < t2w1l && t2w1lwt2 < t2h1u && t2w1lwt2 < t2h1d && t2w1lwt2 <t2w1rwt && t2w1lwt2 <t2w1lwt && t2w1lwt2 < t2h1uwt && t2w1lwt2 < t2h1dwt
  && t2w1lwt2 < t2w1r1 && t2w1lwt2 < t2w1l1 && t2w1lwt2 < t2h1u1 && t2w1lwt2 < t2h1d1 && t2w1lwt2 <t2w1rwt1 && t2w1lwt2 <t2w1lwt1 && t2w1lwt2 < t2h1uwt1 && t2w1lwt2 < t2h1dwt1
  && t2w1lwt2 < t2w1r2 && t2w1lwt2 < t2w1l2 && t2w1lwt2 < t2h1u2 && t2w1lwt2 < t2h1d2 && t2w1lwt2 <t2w1rwt2 && t2w1lwt2 < t2h1uwt2 && t2w1lwt2 < t2h1dwt2
  && t2w1lwt2 < t2w1r3 && t2w1lwt2 < t2w1l3 && t2w1lwt2 < t2h1u3 && t2w1lwt2 < t2h1d3 && t2w1lwt2 <t2w1rwt3 && t2w1lwt2 <t2w1lwt3 && t2w1lwt2 < t2h1uwt3 && t2w1lwt2 < t2h1dwt3
  && t2w1lwt2 < t2w1r4 && t2w1lwt2 < t2w1l4 && t2w1lwt2 < t2h1u4 && t2w1lwt2 < t2h1d4 && t2w1lwt2 <t2w1rwt4 && t2w1lwt2 <t2w1lwt4 && t2w1lwt2 < t2h1uwt4 && t2w1lwt2 < t2h1dwt4
  && t2w1lwt2 < t2w1r5 && t2w1lwt2 < t2w1l5 && t2w1lwt2 < t2h1u5 && t2w1lwt2 < t2h1d5 && t2w1lwt2 <t2w1rwt5 && t2w1lwt2 <t2w1lwt5 && t2w1lwt2 < t2h1uwt5 && t2w1lwt2 < t2h1dwt5
  && t2w1lwt2 < t2w1r6 && t2w1lwt2 < t2w1l6 && t2w1lwt2 < t2h1u6 && t2w1lwt2 < t2h1d6 && t2w1lwt2 <t2w1rwt6 && t2w1lwt2 <t2w1lwt6 && t2w1lwt2 < t2h1uwt6 && t2w1lwt2 < t2h1dwt6
  && t2w1lwt2 < t2w1r7 && t2w1lwt2 < t2w1l7 && t2w1lwt2 < t2h1u7 && t2w1lwt2 < t2h1d7 && t2w1lwt2 <t2w1rwt7 && t2w1lwt2 <t2w1lwt7 && t2w1lwt2 < t2h1uwt7 && t2w1lwt2 < t2h1dwt7
  && t2w1lwt2 < t2w1r8 && t2w1lwt2 < t2w1l8 && t2w1lwt2 < t2h1u8 && t2w1lwt2 < t2h1d8 && t2w1lwt2 <t2w1rwt8 && t2w1lwt2 <t2w1lwt8 && t2w1lwt2 < t2h1uwt8 && t2w1lwt2 < t2h1dwt8
  && t2w1lwt2 < t2w1r9 && t2w1lwt2 < t2w1l9 && t2w1lwt2 < t2h1u9 && t2w1lwt2 < t2h1d9 && t2w1lwt2 <t2w1rwt9 && t2w1lwt2 <t2w1lwt9 && t2w1lwt2 < t2h1uwt9 && t2w1lwt2 < t2h1dwt9
  && t2w1lwt2 < t2w1r10 && t2w1lwt2 < t2w1l10 && t2w1lwt2 < t2h1u10 && t2w1lwt2 < t2h1d10 && t2w1lwt2 <t2w1rwt10 && t2w1lwt2 <t2w1lwt10 && t2w1lwt2 < t2h1uwt10 && t2w1lwt2 < t2h1dwt10)
{
        if (mxlOW2 == 0) i = 115;
        else{
        if (mxlOW2 == -1) i = 119;
        else{
        if (linwl2!=0 && loutwl2!=0) i=105;
        else{
        if ((loutwl2!=0 && linwl2==0) || (loutwl2==0 && linwl2!=0)) i= 106;
        else{
        if (loutwl2==0 && linwl2==0) i=107;
  }}}}}


															/* neutron interacts with the elliptic top OUTER wall - comments are analog to inner elliptic right wall*/

  if (t2h1uwt2 > 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
  && t2h1uwt2 < t2w1r3 && t2h1uwt2 < t2w1l3 && t2h1uwt2 < t2h1u3 && t2h1uwt2 < t2h1d3 && t2h1uwt2 < t2w1rwt3 && t2h1uwt2 < t2w1lwt3 && t2h1uwt2 < t2h1uwt3 && t2h1uwt2 < t2h1dwt3
  && t2h1uwt2 < t2w1r4 && t2h1uwt2 < t2w1l4 && t2h1uwt2 < t2h1u4 && t2h1uwt2 < t2h1d4 && t2h1uwt2 < t2w1rwt4 && t2h1uwt2 < t2w1lwt4 && t2h1uwt2 < t2h1uwt4 && t2h1uwt2 < t2h1dwt4
  && t2h1uwt2 < t2w1r5 && t2h1uwt2 < t2w1l5 && t2h1uwt2 < t2h1u5 && t2h1uwt2 < t2h1d5 && t2h1uwt2 < t2w1rwt5 && t2h1uwt2 < t2w1lwt5 && t2h1uwt2 < t2h1uwt5 && t2h1uwt2 < t2h1dwt5
  && t2h1uwt2 < t2w1r6 && t2h1uwt2 < t2w1l6 && t2h1uwt2 < t2h1u6 && t2h1uwt2 < t2h1d6 && t2h1uwt2 < t2w1rwt6 && t2h1uwt2 < t2w1lwt6 && t2h1uwt2 < t2h1uwt6 && t2h1uwt2 < t2h1dwt6
  && t2h1uwt2 < t2w1r7 && t2h1uwt2 < t2w1l7 && t2h1uwt2 < t2h1u7 && t2h1uwt2 < t2h1d7 && t2h1uwt2 < t2w1rwt7 && t2h1uwt2 < t2w1lwt7 && t2h1uwt2 < t2h1uwt7 && t2h1uwt2 < t2h1dwt7
  && t2h1uwt2 < t2w1r8 && t2h1uwt2 < t2w1l8 && t2h1uwt2 < t2h1u8 && t2h1uwt2 < t2h1d8 && t2h1uwt2 < t2w1rwt8 && t2h1uwt2 < t2w1lwt8 && t2h1uwt2 < t2h1uwt8 && t2h1uwt2 < t2h1dwt8
  && t2h1uwt2 < t2w1r9 && t2h1uwt2 < t2w1l9 && t2h1uwt2 < t2h1u9 && t2h1uwt2 < t2h1d9 && t2h1uwt2 < t2w1rwt9 && t2h1uwt2 < t2w1lwt9 && t2h1uwt2 < t2h1uwt9 && t2h1uwt2 < t2h1dwt9
  && t2h1uwt2 < t2w1r10 && t2h1uwt2 < t2w1l10 && t2h1uwt2 < t2h1u10 && t2h1uwt2 < t2h1d10 && t2h1uwt2 < t2w1rwt10 && t2h1uwt2 < t2w1lwt10 && t2h1uwt2 < t2h1uwt10 && t2h1uwt2 < t2h1dwt10)
{
   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  
  && t2h1dwt2 < t2w1r3 && t2h1dwt2 < t2w1l3 && t2h1dwt2 < t2h1u3 && t2h1dwt2 < t2h1d3 && t2h1dwt2 < t2w1rwt3 && t2h1dwt2 < t2w1lwt3 && t2h1dwt2 < t2h1uwt3 && t2h1dwt2 < t2h1dwt3
  && t2h1dwt2 < t2w1r4 && t2h1dwt2 < t2w1l4 && t2h1dwt2 < t2h1u4 && t2h1dwt2 < t2h1d4 && t2h1dwt2 < t2w1rwt4 && t2h1dwt2 < t2w1lwt4 && t2h1dwt2 < t2h1uwt4 && t2h1dwt2 < t2h1dwt4
  && t2h1dwt2 < t2w1r5 && t2h1dwt2 < t2w1l5 && t2h1dwt2 < t2h1u5 && t2h1dwt2 < t2h1d5 && t2h1dwt2 < t2w1rwt5 && t2h1dwt2 < t2w1lwt5 && t2h1dwt2 < t2h1uwt5 && t2h1dwt2 < t2h1dwt5
  && t2h1dwt2 < t2w1r6 && t2h1dwt2 < t2w1l6 && t2h1dwt2 < t2h1u6 && t2h1dwt2 < t2h1d6 && t2h1dwt2 < t2w1rwt6 && t2h1dwt2 < t2w1lwt6 && t2h1dwt2 < t2h1uwt6 && t2h1dwt2 < t2h1dwt6
  && t2h1dwt2 < t2w1r7 && t2h1dwt2 < t2w1l7 && t2h1dwt2 < t2h1u7 && t2h1dwt2 < t2h1d7 && t2h1dwt2 < t2w1rwt7 && t2h1dwt2 < t2w1lwt7 && t2h1dwt2 < t2h1uwt7 && t2h1dwt2 < t2h1dwt7 
  && t2h1dwt2 < t2w1r8 && t2h1dwt2 < t2w1l8 && t2h1dwt2 < t2h1u8 && t2h1dwt2 < t2h1d8 && t2h1dwt2 < t2w1rwt8 && t2h1dwt2 < t2w1lwt8 && t2h1dwt2 < t2h1uwt8 && t2h1dwt2 < t2h1dwt8
  && t2h1dwt2 < t2w1r9 && t2h1dwt2 < t2w1l9 && t2h1dwt2 < t2h1u9 && t2h1dwt2 < t2h1d9 && t2h1dwt2 < t2w1rwt9 && t2h1dwt2 < t2w1lwt9 && t2h1dwt2 < t2h1uwt9 && t2h1dwt2 < t2h1dwt9 
  && t2h1dwt2 < t2w1r10 && t2h1dwt2 < t2w1l10 && t2h1dwt2 < t2h1u10 && t2h1dwt2 < t2h1d10 && t2h1dwt2 < t2w1rwt10 && t2h1dwt2 < t2w1lwt10 && t2h1dwt2 < t2h1uwt10 && t2h1dwt2 < t2h1dwt10)
{
   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;
  }}}}}

/*   THIRD SHELL  */

/* neutron interacts with the INNER right wall and this wall is NOT transparent*/

  if (t2w1r3 > 0 && t2w1r3 < t1 
     && t2w1r3 < t2w1r && t2w1r3 < t2w1l && t2w1r3 < t2h1u && t2w1r3 < t2h1d && t2w1r3 < t2w1rwt && t2w1r3 < t2w1lwt && t2w1r3 < t2h1uwt && t2w1r3 < t2h1dwt
     && t2w1r3 < t2w1r1 && t2w1r3 < t2w1l1 && t2w1r3 < t2h1u1 && t2w1r3 < t2h1d1 && t2w1r3 < t2w1rwt1 && t2w1r3 < t2w1lwt1 && t2w1r3 < t2h1uwt1 && t2w1r3 < t2h1dwt1
     && t2w1r3 < t2w1r2 && t2w1r3 < t2w1l2 && t2w1r3 < t2h1u2 && t2w1r3 < t2h1d2 && t2w1r3 < t2w1rwt2 && t2w1r3 < t2w1lwt2 && t2w1r3 < t2h1uwt2 && t2w1r3 < t2h1dwt2 
     && t2w1r3 < t2w1l3 && t2w1r3 < t2h1u3 && t2w1r3 < t2h1d3 && t2w1r3 < t2w1rwt3 && t2w1r3 < t2w1lwt3 && t2w1r3 < t2h1uwt3 && t2w1r3 < t2h1dwt3
     && t2w1r3 < t2w1r4 && t2w1r3 < t2w1l4 && t2w1r3 < t2h1u4 && t2w1r3 < t2h1d4 && t2w1r3 < t2w1rwt4 && t2w1r3 < t2w1lwt4 && t2w1r3 < t2h1uwt4 && t2w1r3 < t2h1dwt4
     && t2w1r3 < t2w1r5 && t2w1r3 < t2w1l5 && t2w1r3 < t2h1u5 && t2w1r3 < t2h1d5 && t2w1r3 < t2w1rwt5 && t2w1r3 < t2w1lwt5 && t2w1r3 < t2h1uwt5 && t2w1r3 < t2h1dwt5
     && t2w1r3 < t2w1r6 && t2w1r3 < t2w1l6 && t2w1r3 < t2h1u6 && t2w1r3 < t2h1d6 && t2w1r3 < t2w1rwt6 && t2w1r3 < t2w1lwt6 && t2w1r3 < t2h1uwt6 && t2w1r3 < t2h1dwt6
     && t2w1r3 < t2w1r7 && t2w1r3 < t2w1l7 && t2w1r3 < t2h1u7 && t2w1r3 < t2h1d7 && t2w1r3 < t2w1rwt7 && t2w1r3 < t2w1lwt7 && t2w1r3 < t2h1uwt7 && t2w1r3 < t2h1dwt7
     && t2w1r3 < t2w1r8 && t2w1r3 < t2w1l8 && t2w1r3 < t2h1u8 && t2w1r3 < t2h1d8 && t2w1r3 < t2w1rwt8 && t2w1r3 < t2w1lwt8 && t2w1r3 < t2h1uwt8 && t2w1r3 < t2h1dwt8
     && t2w1r3 < t2w1r9 && t2w1r3 < t2w1l9 && t2w1r3 < t2h1u9 && t2w1r3 < t2h1d9 && t2w1r3 < t2w1rwt9 && t2w1r3 < t2w1lwt9 && t2w1r3 < t2h1uwt9 && t2w1r3 < t2h1dwt9
     && t2w1r3 < t2w1r10 && t2w1r3 < t2w1l10 && t2w1r3 < t2h1u10 && t2w1r3 < t2h1d10 && t2w1r3 < t2w1rwt10 && t2w1r3 < t2w1lwt10 && t2w1r3 < t2h1uwt10 && t2w1r3 < t2h1dwt10) 
    {
	    if (mxr3 == 0) i =138;
    else{
	    if (mxr3 == -1) i= 134;
    else{
	    if (linwr3!=0 && loutwr3!=0) i= 122;
    else{
	    if ((loutwr3!=0 && linwr3==0) || (loutwr3==0 && linwr3!=0)) i = 123;
    else{
	    if (loutwr3==0 && linwr3==0) i= 124;
}}}}}


/* neutron interacts with the left INNER wall - comments are analog to inner right wall*/

  if (t2w1l3 > 0 && t2w1l3 < t1 
      && t2w1l3 < t2w1r && t2w1l3 < t2w1l && t2w1l3 < t2h1u && t2w1l3 < t2h1d && t2w1l3 < t2w1rwt && t2w1l3 < t2w1lwt && t2w1l3 < t2h1uwt && t2w1l3 < t2h1dwt
      && t2w1l3 < t2w1r1 && t2w1l3 < t2w1l1 && t2w1l3 < t2h1u1 && t2w1l3 < t2h1d1 && t2w1l3 < t2w1rwt1 && t2w1l3 < t2w1lwt1 && t2w1l3 < t2h1uwt1 && t2w1l3 < t2h1dwt1
      && t2w1l3 < t2w1r2 && t2w1l3 < t2w1l2 && t2w1l3 < t2h1u2 && t2w1l3 < t2h1d2 && t2w1l3 < t2w1rwt2 && t2w1l3 < t2w1lwt2 && t2w1l3 < t2h1uwt2 && t2w1l3 < t2h1dwt2
      && t2w1l3 < t2w1r3 && t2w1l3 < t2h1u3 && t2w1l3 < t2h1d3 && t2w1l3 < t2w1rwt3 && t2w1l3 < t2w1lwt3 && t2w1l3 < t2h1uwt3 && t2w1l3 < t2h1dwt3
      && t2w1l3 < t2w1r4 && t2w1l3 < t2w1l4 && t2w1l3 < t2h1u4 && t2w1l3 < t2h1d4 && t2w1l3 < t2w1rwt4 && t2w1l3 < t2w1lwt4 && t2w1l3 < t2h1uwt4 && t2w1l3 < t2h1dwt4
      && t2w1l3 < t2w1r5 && t2w1l3 < t2w1l5 && t2w1l3 < t2h1u5 && t2w1l3 < t2h1d5 && t2w1l3 < t2w1rwt5 && t2w1l3 < t2w1lwt5 && t2w1l3 < t2h1uwt5 && t2w1l3 < t2h1dwt5
      && t2w1l3 < t2w1r6 && t2w1l3 < t2w1l6 && t2w1l3 < t2h1u6 && t2w1l3 < t2h1d6 && t2w1l3 < t2w1rwt6 && t2w1l3 < t2w1lwt6 && t2w1l3 < t2h1uwt6 && t2w1l3 < t2h1dwt6
      && t2w1l3 < t2w1r7 && t2w1l3 < t2w1l7 && t2w1l3 < t2h1u7 && t2w1l3 < t2h1d7 && t2w1l3 < t2w1rwt7 && t2w1l3 < t2w1lwt7 && t2w1l3 < t2h1uwt7 && t2w1l3 < t2h1dwt7
      && t2w1l3 < t2w1r8 && t2w1l3 < t2w1l8 && t2w1l3 < t2h1u8 && t2w1l3 < t2h1d8 && t2w1l3 < t2w1rwt8 && t2w1l3 < t2w1lwt8 && t2w1l3 < t2h1uwt8 && t2w1l3 < t2h1dwt8
      && t2w1l3 < t2w1r9 && t2w1l3 < t2w1l9 && t2w1l3 < t2h1u9 && t2w1l3 < t2h1d9 && t2w1l3 < t2w1rwt9 && t2w1l3 < t2w1lwt9 && t2w1l3 < t2h1uwt9 && t2w1l3 < t2h1dwt9
      && t2w1l3 < t2w1r10 && t2w1l3 < t2w1l10 && t2w1l3 < t2h1u10 && t2w1l3 < t2h1d10 && t2w1l3 < t2w1rwt10 && t2w1l3 < t2w1lwt10 && t2w1l3 < t2h1uwt10 && t2w1l3 < t2h1dwt10)
{
	    if (mxl3 == 0) i = 139;
    else{
	    if (mxl3 == -1) i = 135;
    else{
	    if (linwl3!=0 && loutwl3!=0) i=125;
    else{
	    if ((loutwl3!=0 && linwl3==0) || (loutwl3==0 && linwl3!=0)) i= 126;
    else{
	    if (loutwl3==0 && linwl3==0) i=127;
}}}}}

/* neutron interacts with the top INNER wall - comments are analog to inner right wall*/

  if (t2h1u3 > 0 && t2h1u3 < t1 
  && t2h1u3 < t2w1r && t2h1u3 < t2w1l && t2h1u3 < t2h1u && t2h1u3 < t2h1d && t2h1u3 < t2w1rwt && t2h1u3 < t2w1lwt && t2h1u3 < t2h1uwt && t2h1u3 < t2h1dwt
  && t2h1u3 < t2w1r1 && t2h1u3 < t2w1l1 && t2h1u3 < t2h1u1 && t2h1u3 < t2h1d1 && t2h1u3 < t2w1rwt1 && t2h1u3 < t2w1lwt1 && t2h1u3 < t2h1uwt1 && t2h1u3 < t2h1dwt1
  && t2h1u3 < t2w1r2 && t2h1u3 < t2w1l2 && t2h1u3 < t2h1u2 && t2h1u3 < t2h1d2 && t2h1u3 < t2w1rwt2 && t2h1u3 < t2w1lwt2 && t2h1u3 < t2h1uwt2 && t2h1u3 < t2h1dwt2
  && t2h1u3 < t2w1r3 && t2h1u3 < t2w1l3 && t2h1u3 < t2h1d3 && t2h1u3 < t2w1rwt3 && t2h1u3 < t2w1lwt3 && t2h1u3 < t2h1uwt3 && t2h1u3 < t2h1dwt3
  && t2h1u3 < t2w1r4 && t2h1u3 < t2w1l4 && t2h1u3 < t2h1u4 && t2h1u3 < t2h1d4 && t2h1u3 < t2w1rwt4 && t2h1u3 < t2w1lwt4 && t2h1u3 < t2h1uwt4 && t2h1u3 < t2h1dwt4
  && t2h1u3 < t2w1r5 && t2h1u3 < t2w1l5 && t2h1u3 < t2h1u5 && t2h1u3 < t2h1d5 && t2h1u3 < t2w1rwt5 && t2h1u3 < t2w1lwt5 && t2h1u3 < t2h1uwt5 && t2h1u3 < t2h1dwt5
  && t2h1u3 < t2w1r6 && t2h1u3 < t2w1l6 && t2h1u3 < t2h1u6 && t2h1u3 < t2h1d6 && t2h1u3 < t2w1rwt6 && t2h1u3 < t2w1lwt6 && t2h1u3 < t2h1uwt6 && t2h1u3 < t2h1dwt6
  && t2h1u3 < t2w1r7 && t2h1u3 < t2w1l7 && t2h1u3 < t2h1u7 && t2h1u3 < t2h1d7 && t2h1u3 < t2w1rwt7 && t2h1u3 < t2w1lwt7 && t2h1u3 < t2h1uwt7 && t2h1u3 < t2h1dwt7
  && t2h1u3 < t2w1r8 && t2h1u3 < t2w1l8 && t2h1u3 < t2h1u8 && t2h1u3 < t2h1d8 && t2h1u3 < t2w1rwt8 && t2h1u3 < t2w1lwt8 && t2h1u3 < t2h1uwt8 && t2h1u3 < t2h1dwt8
  && t2h1u3 < t2w1r9 && t2h1u3 < t2w1l9 && t2h1u3 < t2h1u9 && t2h1u3 < t2h1d9 && t2h1u3 < t2w1rwt9 && t2h1u3 < t2w1lwt9 && t2h1u3 < t2h1uwt9 && t2h1u3 < t2h1dwt9
  && t2h1u3 < t2w1r10 && t2h1u3 < t2w1l10 && t2h1u3 < t2h1u10 && t2h1u3 < t2h1d10 && t2h1u3 < t2w1rwt10 && t2h1u3 < t2w1lwt10 && t2h1u3 < t2h1uwt10 && t2h1u3 < t2h1dwt10)
{
	    if (myu3 == 0) i = 140;
    else{
	    if (myu3 == -1) i = 136;
    else{
	    if (louthu3 !=0 && linhu3!=0) i=128;
    else{
	    if ((louthu3!=0 && linhu3==0) || (louthu3==0 && linhu3!=0)) i = 129;
    else{
	    if (louthu3 == 0 && linhu3 == 0) i =130;
}}}}}



/* neutron interacts with the down INNER wall - comments are analog to inner right wall*/

  if (t2h1d3 > 0 && t2h1d3 < t1 
  && t2h1d3 < t2w1r && t2h1d3 < t2w1l && t2h1d3 < t2h1u && t2h1d3 < t2h1d && t2h1d3 < t2w1rwt && t2h1d3 < t2w1lwt && t2h1d3 < t2h1uwt && t2h1d3 < t2h1dwt
  && t2h1d3 < t2w1r1 && t2h1d3 < t2w1l1 && t2h1d3 < t2h1u1 && t2h1d3 < t2h1d1 && t2h1d3 < t2w1rwt1 && t2h1d3 < t2w1lwt1 && t2h1d3 < t2h1uwt1 && t2h1d3 < t2h1dwt1
  && t2h1d3 < t2w1r2 && t2h1d3 < t2w1l2 && t2h1d3 < t2h1u2 && t2h1d3 < t2h1d2 && t2h1d3 < t2w1rwt2 && t2h1d3 < t2w1lwt2 && t2h1d3 < t2h1uwt2 && t2h1d3 < t2h1dwt2
  && t2h1d3 < t2w1r3 && t2h1d3 < t2w1l3 && t2h1d3 < t2h1u3 && t2h1d3 < t2w1rwt3 && t2h1d3 < t2w1lwt3 && t2h1d3 < t2h1uwt3 && t2h1d3 < t2h1dwt3
  && t2h1d3 < t2w1r4 && t2h1d3 < t2w1l4 && t2h1d3 < t2h1u4 && t2h1d3 < t2h1d4 && t2h1d3 < t2w1rwt4 && t2h1d3 < t2w1lwt4 && t2h1d3 < t2h1uwt4 && t2h1d3 < t2h1dwt4
  && t2h1d3 < t2w1r5 && t2h1d3 < t2w1l5 && t2h1d3 < t2h1u5 && t2h1d3 < t2h1d5 && t2h1d3 < t2w1rwt5 && t2h1d3 < t2w1lwt5 && t2h1d3 < t2h1uwt5 && t2h1d3 < t2h1dwt5
  && t2h1d3 < t2w1r6 && t2h1d3 < t2w1l6 && t2h1d3 < t2h1u6 && t2h1d3 < t2h1d6 && t2h1d3 < t2w1rwt6 && t2h1d3 < t2w1lwt6 && t2h1d3 < t2h1uwt6 && t2h1d3 < t2h1dwt6
  && t2h1d3 < t2w1r7 && t2h1d3 < t2w1l7 && t2h1d3 < t2h1u7 && t2h1d3 < t2h1d7 && t2h1d3 < t2w1rwt7 && t2h1d3 < t2w1lwt7 && t2h1d3 < t2h1uwt7 && t2h1d3 < t2h1dwt7
  && t2h1d3 < t2w1r8 && t2h1d3 < t2w1l8 && t2h1d3 < t2h1u8 && t2h1d3 < t2h1d8 && t2h1d3 < t2w1rwt8 && t2h1d3 < t2w1lwt8 && t2h1d3 < t2h1uwt8 && t2h1d3 < t2h1dwt8
  && t2h1d3 < t2w1r9 && t2h1d3 < t2w1l9 && t2h1d3 < t2h1u9 && t2h1d3 < t2h1d9 && t2h1d3 < t2w1rwt9 && t2h1d3 < t2w1lwt9 && t2h1d3 < t2h1uwt9 && t2h1d3 < t2h1dwt9
  && t2h1d3 < t2w1r10 && t2h1d3 < t2w1l10 && t2h1d3 < t2h1u10 && t2h1d3 < t2h1d10 && t2h1d3 < t2w1rwt10 && t2h1d3 < t2w1lwt10 && t2h1d3 < t2h1uwt10 && t2h1d3 < t2h1dwt10)
{
	    if ( myd3 == 0 ) i=141;
    else{
	    if ( myd3 == -1) i=137;
    else{
	    if (louthd3 !=0 && linhd3!=0)  i=131;
    else{
	    if ((louthd3 !=0 && linhd3==0) || (louthd3 ==0 && linhd3!=0)) i=132;
    else{
	    if (louthd3 == 0 && linhd3 == 0) i =133;
}}}}}

/* EVERTHING AGAIN FOR THE OUTER WALLS */

/* neutron interacts with the right OUTER wall - comments are analog to inner right wall*/

  if (t2w1rwt3 > 0 && t2w1rwt3 < t1 
  && t2w1rwt3 < t2w1r && t2w1rwt3 < t2w1l && t2w1rwt3 < t2h1u && t2w1rwt3 < t2h1d && t2w1rwt3 <t2w1rwt && t2w1rwt3 <t2w1lwt && t2w1rwt3 < t2h1uwt && t2w1rwt3 < t2h1dwt
  && t2w1rwt3 < t2w1r1 && t2w1rwt3 < t2w1l1 && t2w1rwt3 < t2h1u1 && t2w1rwt3 < t2h1d1 && t2w1rwt3 <t2w1rwt1 && t2w1rwt3 <t2w1lwt1 && t2w1rwt3 < t2h1uwt1 && t2w1rwt3 < t2h1dwt1
  && t2w1rwt3 < t2w1r2 && t2w1rwt3 < t2w1l2 && t2w1rwt3 < t2h1u2 && t2w1rwt3 < t2h1d2 && t2w1rwt3 <t2w1rwt2 && t2w1rwt3 <t2w1lwt2 && t2w1rwt3 < t2h1uwt2 && t2w1rwt3 < t2h1dwt2
  && t2w1rwt3 < t2w1r3 && t2w1rwt3 < t2w1l3 && t2w1rwt3 < t2h1u3 && t2w1rwt3 < t2h1d3 && t2w1rwt3 <t2w1lwt3 && t2w1rwt3 < t2h1uwt3 && t2w1rwt3 < t2h1dwt3
  && t2w1rwt3 < t2w1r4 && t2w1rwt3 < t2w1l4 && t2w1rwt3 < t2h1u4 && t2w1rwt3 < t2h1d4 && t2w1rwt3 <t2w1rwt4 && t2w1rwt3 <t2w1lwt4 && t2w1rwt3 < t2h1uwt4 && t2w1rwt3 < t2h1dwt4
  && t2w1rwt3 < t2w1r5 && t2w1rwt3 < t2w1l5 && t2w1rwt3 < t2h1u5 && t2w1rwt3 < t2h1d5 && t2w1rwt3 <t2w1rwt5 && t2w1rwt3 <t2w1lwt5 && t2w1rwt3 < t2h1uwt5 && t2w1rwt3 < t2h1dwt5
  && t2w1rwt3 < t2w1r6 && t2w1rwt3 < t2w1l6 && t2w1rwt3 < t2h1u6 && t2w1rwt3 < t2h1d6 && t2w1rwt3 <t2w1rwt6 && t2w1rwt3 <t2w1lwt6 && t2w1rwt3 < t2h1uwt6 && t2w1rwt3 < t2h1dwt6
  && t2w1rwt3 < t2w1r7 && t2w1rwt3 < t2w1l7 && t2w1rwt3 < t2h1u7 && t2w1rwt3 < t2h1d7 && t2w1rwt3 <t2w1rwt7 && t2w1rwt3 <t2w1lwt7 && t2w1rwt3 < t2h1uwt7 && t2w1rwt3 < t2h1dwt7
  && t2w1rwt3 < t2w1r8 && t2w1rwt3 < t2w1l8 && t2w1rwt3 < t2h1u8 && t2w1rwt3 < t2h1d8 && t2w1rwt3 <t2w1rwt8 && t2w1rwt3 <t2w1lwt8 && t2w1rwt3 < t2h1uwt8 && t2w1rwt3 < t2h1dwt8
  && t2w1rwt3 < t2w1r9 && t2w1rwt3 < t2w1l9 && t2w1rwt3 < t2h1u9 && t2w1rwt3 < t2h1d9 && t2w1rwt3 <t2w1rwt9 && t2w1rwt3 <t2w1lwt9 && t2w1rwt3 < t2h1uwt9 && t2w1rwt3 < t2h1dwt9
  && t2w1rwt3 < t2w1r10 && t2w1rwt3 < t2w1l10 && t2w1rwt3 < t2h1u10 && t2w1rwt3 < t2h1d10 && t2w1rwt3 <t2w1rwt10 && t2w1rwt3 <t2w1lwt10 && t2w1rwt3 < t2h1uwt10 && t2w1rwt3 < t2h1dwt10)
{
	    if (mxrOW3 == 0) i =154;
    else{
	    if (mxrOW3 == -1) i= 158;
    else{
	    if (linwr3!=0 && loutwr3!=0) i= 142;
    else{
	    if ((loutwr3!=0 && linwr3==0) || (loutwr3==0 && linwr3!=0)) i = 143;
    else{
	    if (loutwr3==0 && linwr3==0) i= 144;
}}}}}


/* neutron interacts with the left OUTER wall - comments are analog to inner right wall*/

  if (t2w1lwt3 > 0 && t2w1lwt3 < t1 
  && t2w1lwt3 < t2w1r && t2w1lwt3 < t2w1l && t2w1lwt3 < t2h1u && t2w1lwt3 < t2h1d && t2w1lwt3 <t2w1rwt && t2w1lwt3 <t2w1lwt && t2w1lwt3 < t2h1uwt && t2w1lwt3 < t2h1dwt
  && t2w1lwt3 < t2w1r1 && t2w1lwt3 < t2w1l1 && t2w1lwt3 < t2h1u1 && t2w1lwt3 < t2h1d1 && t2w1lwt3 <t2w1rwt1 && t2w1lwt3 <t2w1lwt1 && t2w1lwt3 < t2h1uwt1 && t2w1lwt3 < t2h1dwt1
  && t2w1lwt3 < t2w1r2 && t2w1lwt3 < t2w1l2 && t2w1lwt3 < t2h1u2 && t2w1lwt3 < t2h1d2 && t2w1lwt3 <t2w1rwt2 && t2w1lwt3 <t2w1lwt2 && t2w1lwt3 < t2h1uwt2 && t2w1lwt3 < t2h1dwt2
  && t2w1lwt3 < t2w1r3 && t2w1lwt3 < t2w1l3 && t2w1lwt3 < t2h1u3 && t2w1lwt3 < t2h1d3 && t2w1lwt3 <t2w1rwt3 && t2w1lwt3 < t2h1uwt3 && t2w1lwt3 < t2h1dwt3
  && t2w1lwt3 < t2w1r4 && t2w1lwt3 < t2w1l4 && t2w1lwt3 < t2h1u4 && t2w1lwt3 < t2h1d4 && t2w1lwt3 <t2w1rwt4 && t2w1lwt3 <t2w1lwt4 && t2w1lwt3 < t2h1uwt4 && t2w1lwt3 < t2h1dwt4
  && t2w1lwt3 < t2w1r5 && t2w1lwt3 < t2w1l5 && t2w1lwt3 < t2h1u5 && t2w1lwt3 < t2h1d5 && t2w1lwt3 <t2w1rwt5 && t2w1lwt3 <t2w1lwt5 && t2w1lwt3 < t2h1uwt5 && t2w1lwt3 < t2h1dwt5
  && t2w1lwt3 < t2w1r6 && t2w1lwt3 < t2w1l6 && t2w1lwt3 < t2h1u6 && t2w1lwt3 < t2h1d6 && t2w1lwt3 <t2w1rwt6 && t2w1lwt3 <t2w1lwt6 && t2w1lwt3 < t2h1uwt6 && t2w1lwt3 < t2h1dwt6
  && t2w1lwt3 < t2w1r7 && t2w1lwt3 < t2w1l7 && t2w1lwt3 < t2h1u7 && t2w1lwt3 < t2h1d7 && t2w1lwt3 <t2w1rwt7 && t2w1lwt3 <t2w1lwt7 && t2w1lwt3 < t2h1uwt7 && t2w1lwt3 < t2h1dwt7
  && t2w1lwt3 < t2w1r8 && t2w1lwt3 < t2w1l8 && t2w1lwt3 < t2h1u8 && t2w1lwt3 < t2h1d8 && t2w1lwt3 <t2w1rwt8 && t2w1lwt3 <t2w1lwt8 && t2w1lwt3 < t2h1uwt8 && t2w1lwt3 < t2h1dwt8
  && t2w1lwt3 < t2w1r9 && t2w1lwt3 < t2w1l9 && t2w1lwt3 < t2h1u9 && t2w1lwt3 < t2h1d9 && t2w1lwt3 <t2w1rwt9 && t2w1lwt3 <t2w1lwt9 && t2w1lwt3 < t2h1uwt9 && t2w1lwt3 < t2h1dwt9
  && t2w1lwt3 < t2w1r10 && t2w1lwt3 < t2w1l10 && t2w1lwt3 < t2h1u10 && t2w1lwt3 < t2h1d10 && t2w1lwt3 <t2w1rwt10 && t2w1lwt3 <t2w1lwt10 && t2w1lwt3 < t2h1uwt10 && t2w1lwt3 < t2h1dwt10)
{
	    if (mxlOW3 == 0) i = 155;
    else{
	    if (mxlOW3 == -1) i = 159;
    else{
	    if (linwl3!=0 && loutwl3!=0) i=145;
    else{
	    if ((loutwl3!=0 && linwl3==0) || (loutwl3==0 && linwl3!=0)) i= 146;
    else{
	    if (loutwl3==0 && linwl3==0) i=147;
}}}}}


/* neutron interacts with the top OUTER wall - comments are analog to inner right wall*/

  if (t2h1uwt3 > 0 && t2h1uwt3 < t1 
  && t2h1uwt3 < t2w1r && t2h1uwt3 < t2w1l && t2h1uwt3 < t2h1u && t2h1uwt3 < t2h1d && t2h1uwt3 < t2w1rwt && t2h1uwt3 < t2w1lwt && t2h1uwt3 < t2h1uwt && t2h1uwt3 < t2h1dwt 
  && t2h1uwt3 < t2w1r1 && t2h1uwt3 < t2w1l1 && t2h1uwt3 < t2h1u1 && t2h1uwt3 < t2h1d1 && t2h1uwt3 < t2w1rwt1 && t2h1uwt3 < t2w1lwt1 && t2h1uwt3 < t2h1uwt1 && t2h1uwt3 < t2h1dwt1
  && t2h1uwt3 < t2w1r2 && t2h1uwt3 < t2w1l2 && t2h1uwt3 < t2h1u2 && t2h1uwt3 < t2h1d2 && t2h1uwt3 < t2w1rwt2 && t2h1uwt3 < t2w1lwt2 && t2h1uwt3 < t2h1uwt2 && t2h1uwt3 < t2h1dwt2
  && t2h1uwt3 < t2w1r3 && t2h1uwt3 < t2w1l3 && t2h1uwt3 < t2h1u3 && t2h1uwt3 < t2h1d3 && t2h1uwt3 < t2w1rwt3 && t2h1uwt3 < t2w1lwt3 && t2h1uwt3 < t2h1dwt3
  && t2h1uwt3 < t2w1r4 && t2h1uwt3 < t2w1l4 && t2h1uwt3 < t2h1u4 && t2h1uwt3 < t2h1d4 && t2h1uwt3 < t2w1rwt4 && t2h1uwt3 < t2w1lwt4 && t2h1uwt3 < t2h1uwt4 && t2h1uwt3 < t2h1dwt4
  && t2h1uwt3 < t2w1r5 && t2h1uwt3 < t2w1l5 && t2h1uwt3 < t2h1u5 && t2h1uwt3 < t2h1d5 && t2h1uwt3 < t2w1rwt5 && t2h1uwt3 < t2w1lwt5 && t2h1uwt3 < t2h1uwt5 && t2h1uwt3 < t2h1dwt5
  && t2h1uwt3 < t2w1r6 && t2h1uwt3 < t2w1l6 && t2h1uwt3 < t2h1u6 && t2h1uwt3 < t2h1d6 && t2h1uwt3 < t2w1rwt6 && t2h1uwt3 < t2w1lwt6 && t2h1uwt3 < t2h1uwt6 && t2h1uwt3 < t2h1dwt6
  && t2h1uwt3 < t2w1r7 && t2h1uwt3 < t2w1l7 && t2h1uwt3 < t2h1u7 && t2h1uwt3 < t2h1d7 && t2h1uwt3 < t2w1rwt7 && t2h1uwt3 < t2w1lwt7 && t2h1uwt3 < t2h1uwt7 && t2h1uwt3 < t2h1dwt7
  && t2h1uwt3 < t2w1r8 && t2h1uwt3 < t2w1l8 && t2h1uwt3 < t2h1u8 && t2h1uwt3 < t2h1d8 && t2h1uwt3 < t2w1rwt8 && t2h1uwt3 < t2w1lwt8 && t2h1uwt3 < t2h1uwt8 && t2h1uwt3 < t2h1dwt8
  && t2h1uwt3 < t2w1r9 && t2h1uwt3 < t2w1l9 && t2h1uwt3 < t2h1u9 && t2h1uwt3 < t2h1d9 && t2h1uwt3 < t2w1rwt9 && t2h1uwt3 < t2w1lwt9 && t2h1uwt3 < t2h1uwt9 && t2h1uwt3 < t2h1dwt9
  && t2h1uwt3 < t2w1r10 && t2h1uwt3 < t2w1l10 && t2h1uwt3 < t2h1u10 && t2h1uwt3 < t2h1d10 && t2h1uwt3 < t2w1rwt10 && t2h1uwt3 < t2w1lwt10 && t2h1uwt3 < t2h1uwt10 && t2h1uwt3 < t2h1dwt10)
{
	    if (myuOW3 == 0) i = 156;
    else{
	    if (myuOW3 == -1) i = 160;
    else{
	    if (louthu3 !=0 && linhu3!=0) i=148;
    else{
	    if ((louthu3!=0 && linhu3==0) || (louthu3==0 && linhu3!=0)) i = 149;
    else{
	    if (louthu3 == 0 && linhu3 == 0) i =150;
}}}}}


/* neutron interacts with the down OUTER wall - comments are analog to inner right wall*/

  if (t2h1dwt3 > 0 && t2h1dwt3 < t1 
  && t2h1dwt3 < t2w1r && t2h1dwt3 < t2w1l && t2h1dwt3 < t2h1u && t2h1dwt3 < t2h1d && t2h1dwt3 < t2w1rwt && t2h1dwt3 < t2w1lwt && t2h1dwt3 < t2h1uwt && t2h1dwt3 < t2h1dwt 
  && t2h1dwt3 < t2w1r1 && t2h1dwt3 < t2w1l1 && t2h1dwt3 < t2h1u1 && t2h1dwt3 < t2h1d1 && t2h1dwt3 < t2w1rwt1 && t2h1dwt3 < t2w1lwt1 && t2h1dwt3 < t2h1uwt1 && t2h1dwt3 < t2h1dwt1
  && t2h1dwt3 < t2w1r2 && t2h1dwt3 < t2w1l2 && t2h1dwt3 < t2h1u2 && t2h1dwt3 < t2h1d2 && t2h1dwt3 < t2w1rwt2 && t2h1dwt3 < t2w1lwt2 && t2h1dwt3 < t2h1uwt2 && t2h1dwt3 < t2h1dwt2 
  && t2h1dwt3 < t2w1r3 && t2h1dwt3 < t2w1l3 && t2h1dwt3 < t2h1u3 && t2h1dwt3 < t2h1d3 && t2h1dwt3 < t2w1rwt3 && t2h1dwt3 < t2w1lwt3 && t2h1dwt3 < t2h1uwt3 
  && t2h1dwt3 < t2w1r4 && t2h1dwt3 < t2w1l4 && t2h1dwt3 < t2h1u4 && t2h1dwt3 < t2h1d4 && t2h1dwt3 < t2w1rwt4 && t2h1dwt3 < t2w1lwt4 && t2h1dwt3 < t2h1uwt4 && t2h1dwt3 < t2h1dwt4
  && t2h1dwt3 < t2w1r5 && t2h1dwt3 < t2w1l5 && t2h1dwt3 < t2h1u5 && t2h1dwt3 < t2h1d5 && t2h1dwt3 < t2w1rwt5 && t2h1dwt3 < t2w1lwt5 && t2h1dwt3 < t2h1uwt5 && t2h1dwt3 < t2h1dwt5
  && t2h1dwt3 < t2w1r6 && t2h1dwt3 < t2w1l6 && t2h1dwt3 < t2h1u6 && t2h1dwt3 < t2h1d6 && t2h1dwt3 < t2w1rwt6 && t2h1dwt3 < t2w1lwt6 && t2h1dwt3 < t2h1uwt6 && t2h1dwt3 < t2h1dwt6
  && t2h1dwt3 < t2w1r7 && t2h1dwt3 < t2w1l7 && t2h1dwt3 < t2h1u7 && t2h1dwt3 < t2h1d7 && t2h1dwt3 < t2w1rwt7 && t2h1dwt3 < t2w1lwt7 && t2h1dwt3 < t2h1uwt7 && t2h1dwt3 < t2h1dwt7 
  && t2h1dwt3 < t2w1r8 && t2h1dwt3 < t2w1l8 && t2h1dwt3 < t2h1u8 && t2h1dwt3 < t2h1d8 && t2h1dwt3 < t2w1rwt8 && t2h1dwt3 < t2w1lwt8 && t2h1dwt3 < t2h1uwt8 && t2h1dwt3 < t2h1dwt8
  && t2h1dwt3 < t2w1r9 && t2h1dwt3 < t2w1l9 && t2h1dwt3 < t2h1u9 && t2h1dwt3 < t2h1d9 && t2h1dwt3 < t2w1rwt9 && t2h1dwt3 < t2w1lwt9 && t2h1dwt3 < t2h1uwt9 && t2h1dwt3 < t2h1dwt9 
  && t2h1dwt3 < t2w1r10 && t2h1dwt3 < t2w1l10 && t2h1dwt3 < t2h1u10 && t2h1dwt3 < t2h1d10 && t2h1dwt3 < t2w1rwt10 && t2h1dwt3 < t2w1lwt10 && t2h1dwt3 < t2h1uwt10 && t2h1dwt3 < t2h1dwt10)
{
	    if ( mydOW3 == 0 ) i=157;
    else{
	    if ( mydOW3 == -1) i=161;
    else{
	    if (louthd3 !=0 && linhd3!=0)  i=151;
    else{
	    if ((louthd3 !=0 && linhd3==0) || (louthd3 ==0 && linhd3!=0)) i=152;
    else{
	    if (louthd3 == 0 && linhd3 == 0) i =153;
}}}}}

    /* FORTH SHELL */

  if (t2w1r4 > 0 && t2w1r4 < t1 
     && t2w1r4 < t2w1r && t2w1r4 < t2w1l && t2w1r4 < t2h1u && t2w1r4 < t2h1d && t2w1r4 < t2w1rwt && t2w1r4 < t2w1lwt && t2w1r4 < t2h1uwt && t2w1r4 < t2h1dwt
     && t2w1r4 < t2w1r1 && t2w1r4 < t2w1l1 && t2w1r4 < t2h1u1 && t2w1r4 < t2h1d1 && t2w1r4 < t2w1rwt1 && t2w1r4 < t2w1lwt1 && t2w1r4 < t2h1uwt1 && t2w1r4 < t2h1dwt1
     && t2w1r4 < t2w1r2 && t2w1r4 < t2w1l2 && t2w1r4 < t2h1u2 && t2w1r4 < t2h1d2 && t2w1r4 < t2w1rwt2 && t2w1r4 < t2w1lwt2 && t2w1r4 < t2h1uwt2 && t2w1r4 < t2h1dwt2 
     && t2w1r4 < t2w1r3 && t2w1r4 < t2w1l3 && t2w1r4 < t2h1u3 && t2w1r4 < t2h1d3 && t2w1r4 < t2w1rwt3 && t2w1r4 < t2w1lwt3 && t2w1r4 < t2h1uwt3 && t2w1r4 < t2h1dwt3
     && t2w1r4 < t2w1l4 && t2w1r4 < t2h1u4 && t2w1r4 < t2h1d4 && t2w1r4 < t2w1rwt4 && t2w1r4 < t2w1lwt4 && t2w1r4 < t2h1uwt4 && t2w1r4 < t2h1dwt4
     && t2w1r4 < t2w1r5 && t2w1r4 < t2w1l5 && t2w1r4 < t2h1u5 && t2w1r4 < t2h1d5 && t2w1r4 < t2w1rwt5 && t2w1r4 < t2w1lwt5 && t2w1r4 < t2h1uwt5 && t2w1r4 < t2h1dwt5
     && t2w1r4 < t2w1r6 && t2w1r4 < t2w1l6 && t2w1r4 < t2h1u6 && t2w1r4 < t2h1d6 && t2w1r4 < t2w1rwt6 && t2w1r4 < t2w1lwt6 && t2w1r4 < t2h1uwt6 && t2w1r4 < t2h1dwt6
     && t2w1r4 < t2w1r7 && t2w1r4 < t2w1l7 && t2w1r4 < t2h1u7 && t2w1r4 < t2h1d7 && t2w1r4 < t2w1rwt7 && t2w1r4 < t2w1lwt7 && t2w1r4 < t2h1uwt7 && t2w1r4 < t2h1dwt7
     && t2w1r4 < t2w1r8 && t2w1r4 < t2w1l8 && t2w1r4 < t2h1u8 && t2w1r4 < t2h1d8 && t2w1r4 < t2w1rwt8 && t2w1r4 < t2w1lwt8 && t2w1r4 < t2h1uwt8 && t2w1r4 < t2h1dwt8
     && t2w1r4 < t2w1r9 && t2w1r4 < t2w1l9 && t2w1r4 < t2h1u9 && t2w1r4 < t2h1d9 && t2w1r4 < t2w1rwt9 && t2w1r4 < t2w1lwt9 && t2w1r4 < t2h1uwt9 && t2w1r4 < t2h1dwt9
     && t2w1r4 < t2w1r10 && t2w1r4 < t2w1l10 && t2w1r4 < t2h1u10 && t2w1r4 < t2h1d10 && t2w1r4 < t2w1rwt10 && t2w1r4 < t2w1lwt10 && t2w1r4 < t2h1uwt10 && t2w1r4 < t2h1dwt10)
{
	    if (mxr4 == 0) i =178;
    else{
	    if (mxr4 == -1) i= 174;
    else{
	    if (linwr4!=0 && loutwr4!=0) i= 162;
    else{
	    if ((loutwr4!=0 && linwr4==0) || (loutwr4==0 && linwr4!=0)) i = 163;
    else{
	    if (loutwr4==0 && linwr4==0) i= 164;
}}}}}


/* neutron interacts with the elliptic left INNER wall - comments are analog to inner elliptic right wall*/

  if (t2w1l4 > 0 && t2w1l4 < t1 
      && t2w1l4 < t2w1r && t2w1l4 < t2w1l && t2w1l4 < t2h1u && t2w1l4 < t2h1d && t2w1l4 < t2w1rwt && t2w1l4 < t2w1lwt && t2w1l4 < t2h1uwt && t2w1l4 < t2h1dwt
      && t2w1l4 < t2w1r1 && t2w1l4 < t2w1l1 && t2w1l4 < t2h1u1 && t2w1l4 < t2h1d1 && t2w1l4 < t2w1rwt1 && t2w1l4 < t2w1lwt1 && t2w1l4 < t2h1uwt1 && t2w1l4 < t2h1dwt1
      && t2w1l4 < t2w1r2 && t2w1l4 < t2w1l2 && t2w1l4 < t2h1u2 && t2w1l4 < t2h1d2 && t2w1l4 < t2w1rwt2 && t2w1l4 < t2w1lwt2 && t2w1l4 < t2h1uwt2 && t2w1l4 < t2h1dwt2
      && t2w1l4 < t2w1r3 && t2w1l4 < t2w1l3 && t2w1l4 < t2h1u3 && t2w1l4 < t2h1d3 && t2w1l4 < t2w1rwt3 && t2w1l4 < t2w1lwt3 && t2w1l4 < t2h1uwt3 && t2w1l4 < t2h1dwt3
      && t2w1l4 < t2w1r4 && t2w1l4 < t2h1u4 && t2w1l4 < t2h1d4 && t2w1l4 < t2w1rwt4 && t2w1l4 < t2w1lwt4 && t2w1l4 < t2h1uwt4 && t2w1l4 < t2h1dwt4
      && t2w1l4 < t2w1r5 && t2w1l4 < t2w1l5 && t2w1l4 < t2h1u5 && t2w1l4 < t2h1d5 && t2w1l4 < t2w1rwt5 && t2w1l4 < t2w1lwt5 && t2w1l4 < t2h1uwt5 && t2w1l4 < t2h1dwt5
      && t2w1l4 < t2w1r6 && t2w1l4 < t2w1l6 && t2w1l4 < t2h1u6 && t2w1l4 < t2h1d6 && t2w1l4 < t2w1rwt6 && t2w1l4 < t2w1lwt6 && t2w1l4 < t2h1uwt6 && t2w1l4 < t2h1dwt6
      && t2w1l4 < t2w1r7 && t2w1l4 < t2w1l7 && t2w1l4 < t2h1u7 && t2w1l4 < t2h1d7 && t2w1l4 < t2w1rwt7 && t2w1l4 < t2w1lwt7 && t2w1l4 < t2h1uwt7 && t2w1l4 < t2h1dwt7
      && t2w1l4 < t2w1r8 && t2w1l4 < t2w1l8 && t2w1l4 < t2h1u8 && t2w1l4 < t2h1d8 && t2w1l4 < t2w1rwt8 && t2w1l4 < t2w1lwt8 && t2w1l4 < t2h1uwt8 && t2w1l4 < t2h1dwt8
      && t2w1l4 < t2w1r9 && t2w1l4 < t2w1l9 && t2w1l4 < t2h1u9 && t2w1l4 < t2h1d9 && t2w1l4 < t2w1rwt9 && t2w1l4 < t2w1lwt9 && t2w1l4 < t2h1uwt9 && t2w1l4 < t2h1dwt9
      && t2w1l4 < t2w1r10 && t2w1l4 < t2w1l10 && t2w1l4 < t2h1u10 && t2w1l4 < t2h1d10 && t2w1l4 < t2w1rwt10 && t2w1l4 < t2w1lwt10 && t2w1l4 < t2h1uwt10 && t2w1l4 < t2h1dwt10)
{
	    if (mxl4 == 0) i = 179;
    else{
	    if (mxl4 == -1) i = 175;
    else{
	    if (loutwl4 !=0 && linwl4!=0) i=165;
    else{
	    if ((loutwl4!=0 && linwl4==0) || (loutwl4==0 && linwl4!=0)) i = 166;
    else{
	    if (loutwl4 == 0 && linwl4 == 0) i =167;
}}}}}


/* neutron interacts with the elliptic top INNER wall - comments are analog to inner elliptic right wall*/

  if (t2h1u4 > 0 && t2h1u4 < t1 
  && t2h1u4 < t2w1r && t2h1u4 < t2w1l && t2h1u4 < t2h1u && t2h1u4 < t2h1d && t2h1u4 < t2w1rwt && t2h1u4 < t2w1lwt && t2h1u4 < t2h1uwt && t2h1u4 < t2h1dwt
  && t2h1u4 < t2w1r1 && t2h1u4 < t2w1l1 && t2h1u4 < t2h1u1 && t2h1u4 < t2h1d1 && t2h1u4 < t2w1rwt1 && t2h1u4 < t2w1lwt1 && t2h1u4 < t2h1uwt1 && t2h1u4 < t2h1dwt1
  && t2h1u4 < t2w1r2 && t2h1u4 < t2w1l2 && t2h1u4 < t2h1u2 && t2h1u4 < t2h1d2 && t2h1u4 < t2w1rwt2 && t2h1u4 < t2w1lwt2 && t2h1u4 < t2h1uwt2 && t2h1u4 < t2h1dwt2
  && t2h1u4 < t2w1r3 && t2h1u4 < t2w1l3 && t2h1u4 < t2h1u3 && t2h1u4 < t2h1d3 && t2h1u4 < t2w1rwt3 && t2h1u4 < t2w1lwt3 && t2h1u4 < t2h1uwt3 && t2h1u4 < t2h1dwt3
  && t2h1u4 < t2w1r4 && t2h1u4 < t2w1l4 && t2h1u4 < t2h1d4 && t2h1u4 < t2w1rwt4 && t2h1u4 < t2w1lwt4 && t2h1u4 < t2h1uwt4 && t2h1u4 < t2h1dwt4
  && t2h1u4 < t2w1r5 && t2h1u4 < t2w1l5 && t2h1u4 < t2h1u5 && t2h1u4 < t2h1d5 && t2h1u4 < t2w1rwt5 && t2h1u4 < t2w1lwt5 && t2h1u4 < t2h1uwt5 && t2h1u4 < t2h1dwt5
  && t2h1u4 < t2w1r6 && t2h1u4 < t2w1l6 && t2h1u4 < t2h1u6 && t2h1u4 < t2h1d6 && t2h1u4 < t2w1rwt6 && t2h1u4 < t2w1lwt6 && t2h1u4 < t2h1uwt6 && t2h1u4 < t2h1dwt6
  && t2h1u4 < t2w1r7 && t2h1u4 < t2w1l7 && t2h1u4 < t2h1u7 && t2h1u4 < t2h1d7 && t2h1u4 < t2w1rwt7 && t2h1u4 < t2w1lwt7 && t2h1u4 < t2h1uwt7 && t2h1u4 < t2h1dwt7
  && t2h1u4 < t2w1r8 && t2h1u4 < t2w1l8 && t2h1u4 < t2h1u8 && t2h1u4 < t2h1d8 && t2h1u4 < t2w1rwt8 && t2h1u4 < t2w1lwt8 && t2h1u4 < t2h1uwt8 && t2h1u4 < t2h1dwt8
  && t2h1u4 < t2w1r9 && t2h1u4 < t2w1l9 && t2h1u4 < t2h1u9 && t2h1u4 < t2h1d9 && t2h1u4 < t2w1rwt9 && t2h1u4 < t2w1lwt9 && t2h1u4 < t2h1uwt9 && t2h1u4 < t2h1dwt9
  && t2h1u4 < t2w1r10 && t2h1u4 < t2w1l10 && t2h1u4 < t2h1u10 && t2h1u4 < t2h1d10 && t2h1u4 < t2w1rwt10 && t2h1u4 < t2w1lwt10 && t2h1u4 < t2h1uwt10 && t2h1u4 < t2h1dwt10)
{
	    if (myu4 == 0) i = 180;
    else{
	    if (myu4 == -1) i = 176;
    else{
	    if (louthu4 !=0 && linhu4!=0) i=168;
    else{
	    if ((louthu4!=0 && linhu4==0) || (louthu4==0 && linhu4!=0)) i = 169;
    else{
	    if (louthu4 == 0 && linhu4 == 0) i =170;
}}}}}


/* neutron interacts with the elliptic down INNER wall - comments are analog to inner elliptic right wall*/

  if (t2h1d4 > 0 && t2h1d4 < t1 
  && t2h1d4 < t2w1r && t2h1d4 < t2w1l && t2h1d4 < t2h1u && t2h1d4 < t2h1d && t2h1d4 < t2w1rwt && t2h1d4 < t2w1lwt && t2h1d4 < t2h1uwt && t2h1d4 < t2h1dwt
  && t2h1d4 < t2w1r1 && t2h1d4 < t2w1l1 && t2h1d4 < t2h1u1 && t2h1d4 < t2h1d1 && t2h1d4 < t2w1rwt1 && t2h1d4 < t2w1lwt1 && t2h1d4 < t2h1uwt1 && t2h1d4 < t2h1dwt1
  && t2h1d4 < t2w1r2 && t2h1d4 < t2w1l2 && t2h1d4 < t2h1u2 && t2h1d4 < t2h1d2 && t2h1d4 < t2w1rwt2 && t2h1d4 < t2w1lwt2 && t2h1d4 < t2h1uwt2 && t2h1d4 < t2h1dwt2
  && t2h1d4 < t2w1r3 && t2h1d4 < t2w1l3 && t2h1d4 < t2h1u3 && t2h1d4 < t2h1d3 && t2h1d4 < t2w1rwt3 && t2h1d4 < t2w1lwt3 && t2h1d4 < t2h1uwt3 && t2h1d4 < t2h1dwt3
  && t2h1d4 < t2w1r4 && t2h1d4 < t2w1l4 && t2h1d4 < t2h1u4 && t2h1d4 < t2w1rwt4 && t2h1d4 < t2w1lwt4 && t2h1d4 < t2h1uwt4 && t2h1d4 < t2h1dwt4
  && t2h1d4 < t2w1r5 && t2h1d4 < t2w1l5 && t2h1d4 < t2h1u5 && t2h1d4 < t2h1d5 && t2h1d4 < t2w1rwt5 && t2h1d4 < t2w1lwt5 && t2h1d4 < t2h1uwt5 && t2h1d4 < t2h1dwt5
  && t2h1d4 < t2w1r6 && t2h1d4 < t2w1l6 && t2h1d4 < t2h1u6 && t2h1d4 < t2h1d6 && t2h1d4 < t2w1rwt6 && t2h1d4 < t2w1lwt6 && t2h1d4 < t2h1uwt6 && t2h1d4 < t2h1dwt6
  && t2h1d4 < t2w1r7 && t2h1d4 < t2w1l7 && t2h1d4 < t2h1u7 && t2h1d4 < t2h1d7 && t2h1d4 < t2w1rwt7 && t2h1d4 < t2w1lwt7 && t2h1d4 < t2h1uwt7 && t2h1d4 < t2h1dwt7
  && t2h1d4 < t2w1r8 && t2h1d4 < t2w1l8 && t2h1d4 < t2h1u8 && t2h1d4 < t2h1d8 && t2h1d4 < t2w1rwt8 && t2h1d4 < t2w1lwt8 && t2h1d4 < t2h1uwt8 && t2h1d4 < t2h1dwt8
  && t2h1d4 < t2w1r9 && t2h1d4 < t2w1l9 && t2h1d4 < t2h1u9 && t2h1d4 < t2h1d9 && t2h1d4 < t2w1rwt9 && t2h1d4 < t2w1lwt9 && t2h1d4 < t2h1uwt9 && t2h1d4 < t2h1dwt9
  && t2h1d4 < t2w1r10 && t2h1d4 < t2w1l10 && t2h1d4 < t2h1u10 && t2h1d4 < t2h1d10 && t2h1d4 < t2w1rwt10 && t2h1d4 < t2w1lwt10 && t2h1d4 < t2h1uwt10 && t2h1d4 < t2h1dwt10)
{
	    if ( myd4 == 0 ) i=181;
    else{
	    if ( myd4 == -1) i=177;
    else{
	    if (louthd4 !=0 && linhd4!=0)  i=171;
    else{
	    if ((louthd4 !=0 && linhd4==0) || (louthd4 ==0 && linhd4!=0)) i=172;
    else{
	    if (louthd4 == 0 && linhd4 == 0) i =173;
}}}}}

/* EVERTHING AGAIN FOR THE OUTER WALLS */

/* neutron interacts with the elliptic right OUTER wall - comments are analog to inner elliptic right wall*/

  if (t2w1rwt4 > 0 && t2w1rwt4 < t1 
  && t2w1rwt4 < t2w1r && t2w1rwt4 < t2w1l && t2w1rwt4 < t2h1u && t2w1rwt4 < t2h1d && t2w1rwt4 <t2w1rwt && t2w1rwt4 <t2w1lwt && t2w1rwt4 < t2h1uwt && t2w1rwt4 < t2h1dwt
  && t2w1rwt4 < t2w1r1 && t2w1rwt4 < t2w1l1 && t2w1rwt4 < t2h1u1 && t2w1rwt4 < t2h1d1 && t2w1rwt4 <t2w1rwt1 && t2w1rwt4 <t2w1lwt1 && t2w1rwt4 < t2h1uwt1 && t2w1rwt4 < t2h1dwt1
  && t2w1rwt4 < t2w1r2 && t2w1rwt4 < t2w1l2 && t2w1rwt4 < t2h1u2 && t2w1rwt4 < t2h1d2 && t2w1rwt4 <t2w1rwt2 && t2w1rwt4 <t2w1lwt2 && t2w1rwt4 < t2h1uwt2 && t2w1rwt4 < t2h1dwt2
  && t2w1rwt4 < t2w1r3 && t2w1rwt4 < t2w1l3 && t2w1rwt4 < t2h1u3 && t2w1rwt4 < t2h1d3 && t2w1rwt4 <t2w1rwt3 && t2w1rwt4 <t2w1lwt3 && t2w1rwt4 < t2h1uwt3 && t2w1rwt4 < t2h1dwt3
  && t2w1rwt4 < t2w1r4 && t2w1rwt4 < t2w1l4 && t2w1rwt4 < t2h1u4 && t2w1rwt4 < t2h1d4 && t2w1rwt4 <t2w1lwt4 && t2w1rwt4 < t2h1uwt4 && t2w1rwt4 < t2h1dwt4
  && t2w1rwt4 < t2w1r5 && t2w1rwt4 < t2w1l5 && t2w1rwt4 < t2h1u5 && t2w1rwt4 < t2h1d5 && t2w1rwt4 <t2w1rwt5 && t2w1rwt4 <t2w1lwt5 && t2w1rwt4 < t2h1uwt5 && t2w1rwt4 < t2h1dwt5
  && t2w1rwt4 < t2w1r6 && t2w1rwt4 < t2w1l6 && t2w1rwt4 < t2h1u6 && t2w1rwt4 < t2h1d6 && t2w1rwt4 <t2w1rwt6 && t2w1rwt4 <t2w1lwt6 && t2w1rwt4 < t2h1uwt6 && t2w1rwt4 < t2h1dwt6
  && t2w1rwt4 < t2w1r7 && t2w1rwt4 < t2w1l7 && t2w1rwt4 < t2h1u7 && t2w1rwt4 < t2h1d7 && t2w1rwt4 <t2w1rwt7 && t2w1rwt4 <t2w1lwt7 && t2w1rwt4 < t2h1uwt7 && t2w1rwt4 < t2h1dwt7
  && t2w1rwt4 < t2w1r8 && t2w1rwt4 < t2w1l8 && t2w1rwt4 < t2h1u8 && t2w1rwt4 < t2h1d8 && t2w1rwt4 <t2w1rwt8 && t2w1rwt4 <t2w1lwt8 && t2w1rwt4 < t2h1uwt8 && t2w1rwt4 < t2h1dwt8
  && t2w1rwt4 < t2w1r9 && t2w1rwt4 < t2w1l9 && t2w1rwt4 < t2h1u9 && t2w1rwt4 < t2h1d9 && t2w1rwt4 <t2w1rwt9 && t2w1rwt4 <t2w1lwt9 && t2w1rwt4 < t2h1uwt9 && t2w1rwt4 < t2h1dwt9
  && t2w1rwt4 < t2w1r10 && t2w1rwt4 < t2w1l10 && t2w1rwt4 < t2h1u10 && t2w1rwt4 < t2h1d10 && t2w1rwt4 <t2w1rwt10 && t2w1rwt4 <t2w1lwt10 && t2w1rwt4 < t2h1uwt10 && t2w1rwt4 < t2h1dwt10)
{
	    if (mxrOW4 == 0) i =194;
    else{
	    if (mxrOW4 == -1) i= 198;
    else{
	    if (linwr4!=0 && loutwr4!=0) i= 182;
    else{
	    if ((loutwr4!=0 && linwr4==0) || (loutwr4==0 && linwr4!=0)) i = 183;
    else{
	    if (loutwr4==0 && linwr4==0) i= 184;
}}}}}

/* neutron interacts with the elliptic left OUTER wall - comments are analog to inner elliptic right wall*/

  if (t2w1lwt4 > 0 && t2w1lwt4 < t1 
  && t2w1lwt4 < t2w1r && t2w1lwt4 < t2w1l && t2w1lwt4 < t2h1u && t2w1lwt4 < t2h1d && t2w1lwt4 <t2w1rwt && t2w1lwt4 <t2w1lwt && t2w1lwt4 < t2h1uwt && t2w1lwt4 < t2h1dwt
  && t2w1lwt4 < t2w1r1 && t2w1lwt4 < t2w1l1 && t2w1lwt4 < t2h1u1 && t2w1lwt4 < t2h1d1 && t2w1lwt4 <t2w1rwt1 && t2w1lwt4 <t2w1lwt1 && t2w1lwt4 < t2h1uwt1 && t2w1lwt4 < t2h1dwt1
  && t2w1lwt4 < t2w1r2 && t2w1lwt4 < t2w1l2 && t2w1lwt4 < t2h1u2 && t2w1lwt4 < t2h1d2 && t2w1lwt4 <t2w1rwt2 && t2w1lwt4 <t2w1lwt2 && t2w1lwt4 < t2h1uwt2 && t2w1lwt4 < t2h1dwt2
  && t2w1lwt4 < t2w1r3 && t2w1lwt4 < t2w1l3 && t2w1lwt4 < t2h1u3 && t2w1lwt4 < t2h1d3 && t2w1lwt4 <t2w1rwt3 && t2w1lwt4 <t2w1lwt3 && t2w1lwt4 < t2h1uwt3 && t2w1lwt4 < t2h1dwt3
  && t2w1lwt4 < t2w1r4 && t2w1lwt4 < t2w1l4 && t2w1lwt4 < t2h1u4 && t2w1lwt4 < t2h1d4 && t2w1lwt4 <t2w1rwt4 && t2w1lwt4 < t2h1uwt4 && t2w1lwt4 < t2h1dwt4
  && t2w1lwt4 < t2w1r5 && t2w1lwt4 < t2w1l5 && t2w1lwt4 < t2h1u5 && t2w1lwt4 < t2h1d5 && t2w1lwt4 <t2w1rwt5 && t2w1lwt4 <t2w1lwt5 && t2w1lwt4 < t2h1uwt5 && t2w1lwt4 < t2h1dwt5
  && t2w1lwt4 < t2w1r6 && t2w1lwt4 < t2w1l6 && t2w1lwt4 < t2h1u6 && t2w1lwt4 < t2h1d6 && t2w1lwt4 <t2w1rwt6 && t2w1lwt4 <t2w1lwt6 && t2w1lwt4 < t2h1uwt6 && t2w1lwt4 < t2h1dwt6
  && t2w1lwt4 < t2w1r7 && t2w1lwt4 < t2w1l7 && t2w1lwt4 < t2h1u7 && t2w1lwt4 < t2h1d7 && t2w1lwt4 <t2w1rwt7 && t2w1lwt4 <t2w1lwt7 && t2w1lwt4 < t2h1uwt7 && t2w1lwt4 < t2h1dwt7
  && t2w1lwt4 < t2w1r8 && t2w1lwt4 < t2w1l8 && t2w1lwt4 < t2h1u8 && t2w1lwt4 < t2h1d8 && t2w1lwt4 <t2w1rwt8 && t2w1lwt4 <t2w1lwt8 && t2w1lwt4 < t2h1uwt8 && t2w1lwt4 < t2h1dwt8
  && t2w1lwt4 < t2w1r9 && t2w1lwt4 < t2w1l9 && t2w1lwt4 < t2h1u9 && t2w1lwt4 < t2h1d9 && t2w1lwt4 <t2w1rwt9 && t2w1lwt4 <t2w1lwt9 && t2w1lwt4 < t2h1uwt9 && t2w1lwt4 < t2h1dwt9
  && t2w1lwt4 < t2w1r10 && t2w1lwt4 < t2w1l10 && t2w1lwt4 < t2h1u10 && t2w1lwt4 < t2h1d10 && t2w1lwt4 <t2w1rwt10 && t2w1lwt4 <t2w1lwt10 && t2w1lwt4 < t2h1uwt10 && t2w1lwt4 < t2h1dwt10)
{
	    if (mxlOW4 == 0) i = 195;
    else{
	    if (mxlOW4 == -1) i = 199;
    else{
	    if (loutwl4 !=0 && linwl4!=0) i=185;
    else{
	    if ((loutwl4!=0 && linwl4==0) || (loutwl4==0 && linwl4!=0)) i = 186;
    else{
	    if (loutwl4 == 0 && linwl4 == 0) i =187;
}}}}}

/* neutron interacts with the elliptic top OUTER wall - comments are analog to inner elliptic right wall*/

  if (t2h1uwt4 > 0 && t2h1uwt4 < t1 
  && t2h1uwt4 < t2w1r && t2h1uwt4 < t2w1l && t2h1uwt4 < t2h1u && t2h1uwt4 < t2h1d && t2h1uwt4 < t2w1rwt && t2h1uwt4 < t2w1lwt && t2h1uwt4 < t2h1uwt && t2h1uwt4 < t2h1dwt 
  && t2h1uwt4 < t2w1r1 && t2h1uwt4 < t2w1l1 && t2h1uwt4 < t2h1u1 && t2h1uwt4 < t2h1d1 && t2h1uwt4 < t2w1rwt1 && t2h1uwt4 < t2w1lwt1 && t2h1uwt4 < t2h1uwt1 && t2h1uwt4 < t2h1dwt1
  && t2h1uwt4 < t2w1r2 && t2h1uwt4 < t2w1l2 && t2h1uwt4 < t2h1u2 && t2h1uwt4 < t2h1d2 && t2h1uwt4 < t2w1rwt2 && t2h1uwt4 < t2w1lwt2 && t2h1uwt4 < t2h1uwt2 && t2h1uwt4 < t2h1dwt2
  && t2h1uwt4 < t2w1r3 && t2h1uwt4 < t2w1l3 && t2h1uwt4 < t2h1u3 && t2h1uwt4 < t2h1d3 && t2h1uwt4 < t2w1rwt3 && t2h1uwt4 < t2w1lwt3 && t2h1uwt4 < t2h1uwt3 && t2h1uwt4 < t2h1dwt3
  && t2h1uwt4 < t2w1r4 && t2h1uwt4 < t2w1l4 && t2h1uwt4 < t2h1u4 && t2h1uwt4 < t2h1d4 && t2h1uwt4 < t2w1rwt4 && t2h1uwt4 < t2w1lwt4 && t2h1uwt4 < t2h1dwt4
  && t2h1uwt4 < t2w1r5 && t2h1uwt4 < t2w1l5 && t2h1uwt4 < t2h1u5 && t2h1uwt4 < t2h1d5 && t2h1uwt4 < t2w1rwt5 && t2h1uwt4 < t2w1lwt5 && t2h1uwt4 < t2h1uwt5 && t2h1uwt4 < t2h1dwt5
  && t2h1uwt4 < t2w1r6 && t2h1uwt4 < t2w1l6 && t2h1uwt4 < t2h1u6 && t2h1uwt4 < t2h1d6 && t2h1uwt4 < t2w1rwt6 && t2h1uwt4 < t2w1lwt6 && t2h1uwt4 < t2h1uwt6 && t2h1uwt4 < t2h1dwt6
  && t2h1uwt4 < t2w1r7 && t2h1uwt4 < t2w1l7 && t2h1uwt4 < t2h1u7 && t2h1uwt4 < t2h1d7 && t2h1uwt4 < t2w1rwt7 && t2h1uwt4 < t2w1lwt7 && t2h1uwt4 < t2h1uwt7 && t2h1uwt4 < t2h1dwt7
  && t2h1uwt4 < t2w1r8 && t2h1uwt4 < t2w1l8 && t2h1uwt4 < t2h1u8 && t2h1uwt4 < t2h1d8 && t2h1uwt4 < t2w1rwt8 && t2h1uwt4 < t2w1lwt8 && t2h1uwt4 < t2h1uwt8 && t2h1uwt4 < t2h1dwt8
  && t2h1uwt4 < t2w1r9 && t2h1uwt4 < t2w1l9 && t2h1uwt4 < t2h1u9 && t2h1uwt4 < t2h1d9 && t2h1uwt4 < t2w1rwt9 && t2h1uwt4 < t2w1lwt9 && t2h1uwt4 < t2h1uwt9 && t2h1uwt4 < t2h1dwt9
  && t2h1uwt4 < t2w1r10 && t2h1uwt4 < t2w1l10 && t2h1uwt4 < t2h1u10 && t2h1uwt4 < t2h1d10 && t2h1uwt4 < t2w1rwt10 && t2h1uwt4 < t2w1lwt10 && t2h1uwt4 < t2h1uwt10 && t2h1uwt4 < t2h1dwt10)
{
	    if (myuOW4 == 0) i = 196;
    else{
	    if (myuOW4 == -1) i = 200;
    else{
	    if (louthu4 !=0 && linhu4!=0) i=188;
    else{
	    if ((louthu4!=0 && linhu4==0) || (louthu4==0 && linhu4!=0)) i = 189;
    else{
	    if (louthu4 == 0 && linhu4 == 0) i =190;
}}}}}

/* neutron interacts with the elliptic down OUTER wall - comments are analog to inner elliptic right wall*/

  if (t2h1dwt4 > 0 && t2h1dwt4 < t1 
  && t2h1dwt4 < t2w1r && t2h1dwt4 < t2w1l && t2h1dwt4 < t2h1u && t2h1dwt4 < t2h1d && t2h1dwt4 < t2w1rwt && t2h1dwt4 < t2w1lwt && t2h1dwt4 < t2h1uwt && t2h1dwt4 < t2h1dwt 
  && t2h1dwt4 < t2w1r1 && t2h1dwt4 < t2w1l1 && t2h1dwt4 < t2h1u1 && t2h1dwt4 < t2h1d1 && t2h1dwt4 < t2w1rwt1 && t2h1dwt4 < t2w1lwt1 && t2h1dwt4 < t2h1uwt1 && t2h1dwt4 < t2h1dwt1
  && t2h1dwt4 < t2w1r2 && t2h1dwt4 < t2w1l2 && t2h1dwt4 < t2h1u2 && t2h1dwt4 < t2h1d2 && t2h1dwt4 < t2w1rwt2 && t2h1dwt4 < t2w1lwt2 && t2h1dwt4 < t2h1uwt2 && t2h1dwt4 < t2h1dwt2 
  && t2h1dwt4 < t2w1r3 && t2h1dwt4 < t2w1l3 && t2h1dwt4 < t2h1u3 && t2h1dwt4 < t2h1d3 && t2h1dwt4 < t2w1rwt3 && t2h1dwt4 < t2w1lwt3 && t2h1dwt4 < t2h1uwt3 && t2h1dwt4 < t2h1dwt3
  && t2h1dwt4 < t2w1r4 && t2h1dwt4 < t2w1l4 && t2h1dwt4 < t2h1u4 && t2h1dwt4 < t2h1d4 && t2h1dwt4 < t2w1rwt4 && t2h1dwt4 < t2w1lwt4 && t2h1dwt4 < t2h1uwt4 
  && t2h1dwt4 < t2w1r5 && t2h1dwt4 < t2w1l5 && t2h1dwt4 < t2h1u5 && t2h1dwt4 < t2h1d5 && t2h1dwt4 < t2w1rwt5 && t2h1dwt4 < t2w1lwt5 && t2h1dwt4 < t2h1uwt5 && t2h1dwt4 < t2h1dwt5
  && t2h1dwt4 < t2w1r6 && t2h1dwt4 < t2w1l6 && t2h1dwt4 < t2h1u6 && t2h1dwt4 < t2h1d6 && t2h1dwt4 < t2w1rwt6 && t2h1dwt4 < t2w1lwt6 && t2h1dwt4 < t2h1uwt6 && t2h1dwt4 < t2h1dwt6
  && t2h1dwt4 < t2w1r7 && t2h1dwt4 < t2w1l7 && t2h1dwt4 < t2h1u7 && t2h1dwt4 < t2h1d7 && t2h1dwt4 < t2w1rwt7 && t2h1dwt4 < t2w1lwt7 && t2h1dwt4 < t2h1uwt7 && t2h1dwt4 < t2h1dwt7 
  && t2h1dwt4 < t2w1r8 && t2h1dwt4 < t2w1l8 && t2h1dwt4 < t2h1u8 && t2h1dwt4 < t2h1d8 && t2h1dwt4 < t2w1rwt8 && t2h1dwt4 < t2w1lwt8 && t2h1dwt4 < t2h1uwt8 && t2h1dwt4 < t2h1dwt8
  && t2h1dwt4 < t2w1r9 && t2h1dwt4 < t2w1l9 && t2h1dwt4 < t2h1u9 && t2h1dwt4 < t2h1d9 && t2h1dwt4 < t2w1rwt9 && t2h1dwt4 < t2w1lwt9 && t2h1dwt4 < t2h1uwt9 && t2h1dwt4 < t2h1dwt9 
  && t2h1dwt4 < t2w1r10 && t2h1dwt4 < t2w1l10 && t2h1dwt4 < t2h1u10 && t2h1dwt4 < t2h1d10 && t2h1dwt4 < t2w1rwt10 && t2h1dwt4 < t2w1lwt10 && t2h1dwt4 < t2h1uwt10 && t2h1dwt4 < t2h1dwt10)
{
	    if ( mydOW4 == 0 ) i=197;
    else{
	    if ( mydOW4 == -1) i=201;
    else{
	    if (louthd4 !=0 && linhd4!=0)  i=191;
    else{
	    if ((louthd4 !=0 && linhd4==0) || (louthd4 ==0 && linhd4!=0)) i=192;
    else{
	    if (louthd4 == 0 && linhd4 == 0) i =193;
}}}}}


    /* FIFTH SHELL */

  if (t2w1r5 > 0 && t2w1r5 < t1 
     && t2w1r5 < t2w1r && t2w1r5 < t2w1l && t2w1r5 < t2h1u && t2w1r5 < t2h1d && t2w1r5 < t2w1rwt && t2w1r5 < t2w1lwt && t2w1r5 < t2h1uwt && t2w1r5 < t2h1dwt
     && t2w1r5 < t2w1r1 && t2w1r5 < t2w1l1 && t2w1r5 < t2h1u1 && t2w1r5 < t2h1d1 && t2w1r5 < t2w1rwt1 && t2w1r5 < t2w1lwt1 && t2w1r5 < t2h1uwt1 && t2w1r5 < t2h1dwt1
     && t2w1r5 < t2w1r2 && t2w1r5 < t2w1l2 && t2w1r5 < t2h1u2 && t2w1r5 < t2h1d2 && t2w1r5 < t2w1rwt2 && t2w1r5 < t2w1lwt2 && t2w1r5 < t2h1uwt2 && t2w1r5 < t2h1dwt2 
     && t2w1r5 < t2w1r3 && t2w1r5 < t2w1l3 && t2w1r5 < t2h1u3 && t2w1r5 < t2h1d3 && t2w1r5 < t2w1rwt3 && t2w1r5 < t2w1lwt3 && t2w1r5 < t2h1uwt3 && t2w1r5 < t2h1dwt3
     && t2w1r5 < t2w1r4 && t2w1r5 < t2w1l4 && t2w1r5 < t2h1u4 && t2w1r5 < t2h1d4 && t2w1r5 < t2w1rwt4 && t2w1r5 < t2w1lwt4 && t2w1r5 < t2h1uwt4 && t2w1r5 < t2h1dwt4
     && t2w1r5 < t2w1l5 && t2w1r5 < t2h1u5 && t2w1r5 < t2h1d5 && t2w1r5 < t2w1rwt5 && t2w1r5 < t2w1lwt5 && t2w1r5 < t2h1uwt5 && t2w1r5 < t2h1dwt5
     && t2w1r5 < t2w1r6 && t2w1r5 < t2w1l6 && t2w1r5 < t2h1u6 && t2w1r5 < t2h1d6 && t2w1r5 < t2w1rwt6 && t2w1r5 < t2w1lwt6 && t2w1r5 < t2h1uwt6 && t2w1r5 < t2h1dwt6
     && t2w1r5 < t2w1r7 && t2w1r5 < t2w1l7 && t2w1r5 < t2h1u7 && t2w1r5 < t2h1d7 && t2w1r5 < t2w1rwt7 && t2w1r5 < t2w1lwt7 && t2w1r5 < t2h1uwt7 && t2w1r5 < t2h1dwt7
     && t2w1r5 < t2w1r8 && t2w1r5 < t2w1l8 && t2w1r5 < t2h1u8 && t2w1r5 < t2h1d8 && t2w1r5 < t2w1rwt8 && t2w1r5 < t2w1lwt8 && t2w1r5 < t2h1uwt8 && t2w1r5 < t2h1dwt8
     && t2w1r5 < t2w1r9 && t2w1r5 < t2w1l9 && t2w1r5 < t2h1u9 && t2w1r5 < t2h1d9 && t2w1r5 < t2w1rwt9 && t2w1r5 < t2w1lwt9 && t2w1r5 < t2h1uwt9 && t2w1r5 < t2h1dwt9
     && t2w1r5 < t2w1r10 && t2w1r5 < t2w1l10 && t2w1r5 < t2h1u10 && t2w1r5 < t2h1d10 && t2w1r5 < t2w1rwt10 && t2w1r5 < t2w1lwt10 && t2w1r5 < t2h1uwt10 && t2w1r5 < t2h1dwt10)
{
	    if (mxr5 == 0) i =218;
    else{
	    if (mxr5 == -1) i= 214;
    else{
	    if (linwr5!=0 && loutwr5!=0) i= 202;
    else{
	    if ((loutwr5!=0 && linwr5==0) || (loutwr5==0 && linwr5!=0)) i = 203;
    else{
	    if (loutwr5==0 && linwr5==0) i= 204;
}}}}}


/* neutron interacts with the elliptic left INNER wall - comments are analog to inner elliptic right wall*/

  if (t2w1l5 > 0 && t2w1l5 < t1 
      && t2w1l5 < t2w1r && t2w1l5 < t2w1l && t2w1l5 < t2h1u && t2w1l5 < t2h1d && t2w1l5 < t2w1rwt && t2w1l5 < t2w1lwt && t2w1l5 < t2h1uwt && t2w1l5 < t2h1dwt
      && t2w1l5 < t2w1r1 && t2w1l5 < t2w1l1 && t2w1l5 < t2h1u1 && t2w1l5 < t2h1d1 && t2w1l5 < t2w1rwt1 && t2w1l5 < t2w1lwt1 && t2w1l5 < t2h1uwt1 && t2w1l5 < t2h1dwt1
      && t2w1l5 < t2w1r2 && t2w1l5 < t2w1l2 && t2w1l5 < t2h1u2 && t2w1l5 < t2h1d2 && t2w1l5 < t2w1rwt2 && t2w1l5 < t2w1lwt2 && t2w1l5 < t2h1uwt2 && t2w1l5 < t2h1dwt2
      && t2w1l5 < t2w1r3 && t2w1l5 < t2w1l3 && t2w1l5 < t2h1u3 && t2w1l5 < t2h1d3 && t2w1l5 < t2w1rwt3 && t2w1l5 < t2w1lwt3 && t2w1l5 < t2h1uwt3 && t2w1l5 < t2h1dwt3
      && t2w1l5 < t2w1r4 && t2w1l5 < t2w1l4 && t2w1l5 < t2h1u4 && t2w1l5 < t2h1d4 && t2w1l5 < t2w1rwt4 && t2w1l5 < t2w1lwt4 && t2w1l5 < t2h1uwt4 && t2w1l5 < t2h1dwt4
      && t2w1l5 < t2w1r5 && t2w1l5 < t2h1u5 && t2w1l5 < t2h1d5 && t2w1l5 < t2w1rwt5 && t2w1l5 < t2w1lwt5 && t2w1l5 < t2h1uwt5 && t2w1l5 < t2h1dwt5
      && t2w1l5 < t2w1r6 && t2w1l5 < t2w1l6 && t2w1l5 < t2h1u6 && t2w1l5 < t2h1d6 && t2w1l5 < t2w1rwt6 && t2w1l5 < t2w1lwt6 && t2w1l5 < t2h1uwt6 && t2w1l5 < t2h1dwt6
      && t2w1l5 < t2w1r7 && t2w1l5 < t2w1l7 && t2w1l5 < t2h1u7 && t2w1l5 < t2h1d7 && t2w1l5 < t2w1rwt7 && t2w1l5 < t2w1lwt7 && t2w1l5 < t2h1uwt7 && t2w1l5 < t2h1dwt7
      && t2w1l5 < t2w1r8 && t2w1l5 < t2w1l8 && t2w1l5 < t2h1u8 && t2w1l5 < t2h1d8 && t2w1l5 < t2w1rwt8 && t2w1l5 < t2w1lwt8 && t2w1l5 < t2h1uwt8 && t2w1l5 < t2h1dwt8
      && t2w1l5 < t2w1r9 && t2w1l5 < t2w1l9 && t2w1l5 < t2h1u9 && t2w1l5 < t2h1d9 && t2w1l5 < t2w1rwt9 && t2w1l5 < t2w1lwt9 && t2w1l5 < t2h1uwt9 && t2w1l5 < t2h1dwt9
      && t2w1l5 < t2w1r10 && t2w1l5 < t2w1l10 && t2w1l5 < t2h1u10 && t2w1l5 < t2h1d10 && t2w1l5 < t2w1rwt10 && t2w1l5 < t2w1lwt10 && t2w1l5 < t2h1uwt10 && t2w1l5 < t2h1dwt10)
{
	    if (mxl5 == 0) i = 219;
    else{
	    if (mxl5 == -1) i = 215;
    else{
	    if (linwl5!=0 && loutwl5!=0) i=205;
    else{
	    if ((loutwl5!=0 && linwl5==0) || (loutwl5==0 && linwl5!=0)) i= 206;
    else{
	    if (loutwl5==0 && linwl5==0) i=207;
}}}}}


/* neutron interacts with the elliptic top INNER wall - comments are analog to inner elliptic right wall*/

  if (t2h1u5 > 0 && t2h1u5 < t1 
  && t2h1u5 < t2w1r && t2h1u5 < t2w1l && t2h1u5 < t2h1u && t2h1u5 < t2h1d && t2h1u5 < t2w1rwt && t2h1u5 < t2w1lwt && t2h1u5 < t2h1uwt && t2h1u5 < t2h1dwt
  && t2h1u5 < t2w1r1 && t2h1u5 < t2w1l1 && t2h1u5 < t2h1u1 && t2h1u5 < t2h1d1 && t2h1u5 < t2w1rwt1 && t2h1u5 < t2w1lwt1 && t2h1u5 < t2h1uwt1 && t2h1u5 < t2h1dwt1
  && t2h1u5 < t2w1r2 && t2h1u5 < t2w1l2 && t2h1u5 < t2h1u2 && t2h1u5 < t2h1d2 && t2h1u5 < t2w1rwt2 && t2h1u5 < t2w1lwt2 && t2h1u5 < t2h1uwt2 && t2h1u5 < t2h1dwt2
  && t2h1u5 < t2w1r3 && t2h1u5 < t2w1l3 && t2h1u5 < t2h1u3 && t2h1u5 < t2h1d3 && t2h1u5 < t2w1rwt3 && t2h1u5 < t2w1lwt3 && t2h1u5 < t2h1uwt3 && t2h1u5 < t2h1dwt3
  && t2h1u5 < t2w1r4 && t2h1u5 < t2w1l4 && t2h1u5 < t2h1u4 && t2h1u5 < t2h1d4 && t2h1u5 < t2w1rwt4 && t2h1u5 < t2w1lwt4 && t2h1u5 < t2h1uwt4 && t2h1u5 < t2h1dwt4
  && t2h1u5 < t2w1r5 && t2h1u5 < t2w1l5 && t2h1u5 < t2h1d5 && t2h1u5 < t2w1rwt5 && t2h1u5 < t2w1lwt5 && t2h1u5 < t2h1uwt5 && t2h1u5 < t2h1dwt5
  && t2h1u5 < t2w1r6 && t2h1u5 < t2w1l6 && t2h1u5 < t2h1u6 && t2h1u5 < t2h1d6 && t2h1u5 < t2w1rwt6 && t2h1u5 < t2w1lwt6 && t2h1u5 < t2h1uwt6 && t2h1u5 < t2h1dwt6
  && t2h1u5 < t2w1r7 && t2h1u5 < t2w1l7 && t2h1u5 < t2h1u7 && t2h1u5 < t2h1d7 && t2h1u5 < t2w1rwt7 && t2h1u5 < t2w1lwt7 && t2h1u5 < t2h1uwt7 && t2h1u5 < t2h1dwt7
  && t2h1u5 < t2w1r8 && t2h1u5 < t2w1l8 && t2h1u5 < t2h1u8 && t2h1u5 < t2h1d8 && t2h1u5 < t2w1rwt8 && t2h1u5 < t2w1lwt8 && t2h1u5 < t2h1uwt8 && t2h1u5 < t2h1dwt8
  && t2h1u5 < t2w1r9 && t2h1u5 < t2w1l9 && t2h1u5 < t2h1u9 && t2h1u5 < t2h1d9 && t2h1u5 < t2w1rwt9 && t2h1u5 < t2w1lwt9 && t2h1u5 < t2h1uwt9 && t2h1u5 < t2h1dwt9
  && t2h1u5 < t2w1r10 && t2h1u5 < t2w1l10 && t2h1u5 < t2h1u10 && t2h1u5 < t2h1d10 && t2h1u5 < t2w1rwt10 && t2h1u5 < t2w1lwt10 && t2h1u5 < t2h1uwt10 && t2h1u5 < t2h1dwt10)
{
	    if (myu5 == 0) i = 220;
    else{
	    if (myu5 == -1) i = 216;
    else{
	    if (louthu5 !=0 && linhu5!=0) i=208;
    else{
	    if ((louthu5!=0 && linhu5==0) || (louthu5==0 && linhu5!=0)) i = 209;
    else{
	    if (louthu5 == 0 && linhu5 == 0) i =210;
}}}}}


/* neutron interacts with the elliptic down INNER wall - comments are analog to inner elliptic right wall*/

  if (t2h1d5 > 0 && t2h1d5 < t1 
  && t2h1d5 < t2w1r && t2h1d5 < t2w1l && t2h1d5 < t2h1u && t2h1d5 < t2h1d && t2h1d5 < t2w1rwt && t2h1d5 < t2w1lwt && t2h1d5 < t2h1uwt && t2h1d5 < t2h1dwt
  && t2h1d5 < t2w1r1 && t2h1d5 < t2w1l1 && t2h1d5 < t2h1u1 && t2h1d5 < t2h1d1 && t2h1d5 < t2w1rwt1 && t2h1d5 < t2w1lwt1 && t2h1d5 < t2h1uwt1 && t2h1d5 < t2h1dwt1
  && t2h1d5 < t2w1r2 && t2h1d5 < t2w1l2 && t2h1d5 < t2h1u2 && t2h1d5 < t2h1d2 && t2h1d5 < t2w1rwt2 && t2h1d5 < t2w1lwt2 && t2h1d5 < t2h1uwt2 && t2h1d5 < t2h1dwt2
  && t2h1d5 < t2w1r3 && t2h1d5 < t2w1l3 && t2h1d5 < t2h1u3 && t2h1d5 < t2h1d3 && t2h1d5 < t2w1rwt3 && t2h1d5 < t2w1lwt3 && t2h1d5 < t2h1uwt3 && t2h1d5 < t2h1dwt3
  && t2h1d5 < t2w1r4 && t2h1d5 < t2w1l4 && t2h1d5 < t2h1u4 && t2h1d5 < t2h1d4 && t2h1d5 < t2w1rwt4 && t2h1d5 < t2w1lwt4 && t2h1d5 < t2h1uwt4 && t2h1d5 < t2h1dwt4
  && t2h1d5 < t2w1r5 && t2h1d5 < t2w1l5 && t2h1d5 < t2h1u5 && t2h1d5 < t2w1rwt5 && t2h1d5 < t2w1lwt5 && t2h1d5 < t2h1uwt5 && t2h1d5 < t2h1dwt5
  && t2h1d5 < t2w1r6 && t2h1d5 < t2w1l6 && t2h1d5 < t2h1u6 && t2h1d5 < t2h1d6 && t2h1d5 < t2w1rwt6 && t2h1d5 < t2w1lwt6 && t2h1d5 < t2h1uwt6 && t2h1d5 < t2h1dwt6
  && t2h1d5 < t2w1r7 && t2h1d5 < t2w1l7 && t2h1d5 < t2h1u7 && t2h1d5 < t2h1d7 && t2h1d5 < t2w1rwt7 && t2h1d5 < t2w1lwt7 && t2h1d5 < t2h1uwt7 && t2h1d5 < t2h1dwt7
  && t2h1d5 < t2w1r8 && t2h1d5 < t2w1l8 && t2h1d5 < t2h1u8 && t2h1d5 < t2h1d8 && t2h1d5 < t2w1rwt8 && t2h1d5 < t2w1lwt8 && t2h1d5 < t2h1uwt8 && t2h1d5 < t2h1dwt8
  && t2h1d5 < t2w1r9 && t2h1d5 < t2w1l9 && t2h1d5 < t2h1u9 && t2h1d5 < t2h1d9 && t2h1d5 < t2w1rwt9 && t2h1d5 < t2w1lwt9 && t2h1d5 < t2h1uwt9 && t2h1d5 < t2h1dwt9
  && t2h1d5 < t2w1r10 && t2h1d5 < t2w1l10 && t2h1d5 < t2h1u10 && t2h1d5 < t2h1d10 && t2h1d5 < t2w1rwt10 && t2h1d5 < t2w1lwt10 && t2h1d5 < t2h1uwt10 && t2h1d5 < t2h1dwt10)
{
	    if ( myd5 == 0 ) i=221;
    else{
	    if ( myd5 == -1) i=217;
    else{
	    if (louthd5 !=0 && linhd5!=0)  i=211;
    else{
	    if ((louthd5 !=0 && linhd5==0) || (louthd5 ==0 && linhd5!=0)) i=212;
    else{
	    if (louthd5 == 0 && linhd5 == 0) i =213;
}}}}}

/* EVERTHING AGAIN FOR THE OUTER WALLS */

/* neutron interacts with the elliptic right OUTER wall - comments are analog to inner elliptic right wall*/

  if (t2w1rwt5 > 0 && t2w1rwt5 < t1 
  && t2w1rwt5 < t2w1r && t2w1rwt5 < t2w1l && t2w1rwt5 < t2h1u && t2w1rwt5 < t2h1d && t2w1rwt5 <t2w1rwt && t2w1rwt5 <t2w1lwt && t2w1rwt5 < t2h1uwt && t2w1rwt5 < t2h1dwt
  && t2w1rwt5 < t2w1r1 && t2w1rwt5 < t2w1l1 && t2w1rwt5 < t2h1u1 && t2w1rwt5 < t2h1d1 && t2w1rwt5 <t2w1rwt1 && t2w1rwt5 <t2w1lwt1 && t2w1rwt5 < t2h1uwt1 && t2w1rwt5 < t2h1dwt1
  && t2w1rwt5 < t2w1r2 && t2w1rwt5 < t2w1l2 && t2w1rwt5 < t2h1u2 && t2w1rwt5 < t2h1d2 && t2w1rwt5 <t2w1rwt2 && t2w1rwt5 <t2w1lwt2 && t2w1rwt5 < t2h1uwt2 && t2w1rwt5 < t2h1dwt2
  && t2w1rwt5 < t2w1r3 && t2w1rwt5 < t2w1l3 && t2w1rwt5 < t2h1u3 && t2w1rwt5 < t2h1d3 && t2w1rwt5 <t2w1rwt3 && t2w1rwt5 <t2w1lwt3 && t2w1rwt5 < t2h1uwt3 && t2w1rwt5 < t2h1dwt3
  && t2w1rwt5 < t2w1r4 && t2w1rwt5 < t2w1l4 && t2w1rwt5 < t2h1u4 && t2w1rwt5 < t2h1d4 && t2w1rwt5 <t2w1rwt4 && t2w1rwt5 <t2w1lwt4 && t2w1rwt5 < t2h1uwt4 && t2w1rwt5 < t2h1dwt4
  && t2w1rwt5 < t2w1r5 && t2w1rwt5 < t2w1l5 && t2w1rwt5 < t2h1u5 && t2w1rwt5 < t2h1d5 && t2w1rwt5 <t2w1lwt5 && t2w1rwt5 < t2h1uwt5 && t2w1rwt5 < t2h1dwt5
  && t2w1rwt5 < t2w1r6 && t2w1rwt5 < t2w1l6 && t2w1rwt5 < t2h1u6 && t2w1rwt5 < t2h1d6 && t2w1rwt5 <t2w1rwt6 && t2w1rwt5 <t2w1lwt6 && t2w1rwt5 < t2h1uwt6 && t2w1rwt5 < t2h1dwt6
  && t2w1rwt5 < t2w1r7 && t2w1rwt5 < t2w1l7 && t2w1rwt5 < t2h1u7 && t2w1rwt5 < t2h1d7 && t2w1rwt5 <t2w1rwt7 && t2w1rwt5 <t2w1lwt7 && t2w1rwt5 < t2h1uwt7 && t2w1rwt5 < t2h1dwt7
  && t2w1rwt5 < t2w1r8 && t2w1rwt5 < t2w1l8 && t2w1rwt5 < t2h1u8 && t2w1rwt5 < t2h1d8 && t2w1rwt5 <t2w1rwt8 && t2w1rwt5 <t2w1lwt8 && t2w1rwt5 < t2h1uwt8 && t2w1rwt5 < t2h1dwt8
  && t2w1rwt5 < t2w1r9 && t2w1rwt5 < t2w1l9 && t2w1rwt5 < t2h1u9 && t2w1rwt5 < t2h1d9 && t2w1rwt5 <t2w1rwt9 && t2w1rwt5 <t2w1lwt9 && t2w1rwt5 < t2h1uwt9 && t2w1rwt5 < t2h1dwt9
  && t2w1rwt5 < t2w1r10 && t2w1rwt5 < t2w1l10 && t2w1rwt5 < t2h1u10 && t2w1rwt5 < t2h1d10 && t2w1rwt5 <t2w1rwt10 && t2w1rwt5 <t2w1lwt10 && t2w1rwt5 < t2h1uwt10 && t2w1rwt5 < t2h1dwt10)
{
	    if (mxrOW5 == 0) i =234;
    else{
	    if (mxrOW5 == -1) i= 238;
    else{
	    if (linwr5!=0 && loutwr5!=0) i= 222;
    else{
	    if ((loutwr5!=0 && linwr5==0) || (loutwr5==0 && linwr5!=0)) i = 223;
    else{
	    if (loutwr5==0 && linwr5==0) i= 224;
}}}}}


/* neutron interacts with the parabolic left OUTER wall - comments are analog to inner elliptic right wall */

  if (t2w1lwt5 > 0 && t2w1lwt5 < t1 
  && t2w1lwt5 < t2w1r && t2w1lwt5 < t2w1l && t2w1lwt5 < t2h1u && t2w1lwt5 < t2h1d && t2w1lwt5 <t2w1rwt && t2w1lwt5 <t2w1lwt && t2w1lwt5 < t2h1uwt && t2w1lwt5 < t2h1dwt
  && t2w1lwt5 < t2w1r1 && t2w1lwt5 < t2w1l1 && t2w1lwt5 < t2h1u1 && t2w1lwt5 < t2h1d1 && t2w1lwt5 <t2w1rwt1 && t2w1lwt5 <t2w1lwt1 && t2w1lwt5 < t2h1uwt1 && t2w1lwt5 < t2h1dwt1
  && t2w1lwt5 < t2w1r2 && t2w1lwt5 < t2w1l2 && t2w1lwt5 < t2h1u2 && t2w1lwt5 < t2h1d2 && t2w1lwt5 <t2w1rwt2 && t2w1lwt5 <t2w1lwt2 && t2w1lwt5 < t2h1uwt2 && t2w1lwt5 < t2h1dwt2
  && t2w1lwt5 < t2w1r3 && t2w1lwt5 < t2w1l3 && t2w1lwt5 < t2h1u3 && t2w1lwt5 < t2h1d3 && t2w1lwt5 <t2w1rwt3 && t2w1lwt5 <t2w1lwt3 && t2w1lwt5 < t2h1uwt3 && t2w1lwt5 < t2h1dwt3
  && t2w1lwt5 < t2w1r4 && t2w1lwt5 < t2w1l4 && t2w1lwt5 < t2h1u4 && t2w1lwt5 < t2h1d4 && t2w1lwt5 <t2w1rwt4 && t2w1lwt5 <t2w1lwt4 && t2w1lwt5 < t2h1uwt4 && t2w1lwt5 < t2h1dwt4
  && t2w1lwt5 < t2w1r5 && t2w1lwt5 < t2w1l5 && t2w1lwt5 < t2h1u5 && t2w1lwt5 < t2h1d5 && t2w1lwt5 <t2w1rwt5 && t2w1lwt5 < t2h1uwt5 && t2w1lwt5 < t2h1dwt5
  && t2w1lwt5 < t2w1r6 && t2w1lwt5 < t2w1l6 && t2w1lwt5 < t2h1u6 && t2w1lwt5 < t2h1d6 && t2w1lwt5 <t2w1rwt6 && t2w1lwt5 <t2w1lwt6 && t2w1lwt5 < t2h1uwt6 && t2w1lwt5 < t2h1dwt6
  && t2w1lwt5 < t2w1r7 && t2w1lwt5 < t2w1l7 && t2w1lwt5 < t2h1u7 && t2w1lwt5 < t2h1d7 && t2w1lwt5 <t2w1rwt7 && t2w1lwt5 <t2w1lwt7 && t2w1lwt5 < t2h1uwt7 && t2w1lwt5 < t2h1dwt7
  && t2w1lwt5 < t2w1r8 && t2w1lwt5 < t2w1l8 && t2w1lwt5 < t2h1u8 && t2w1lwt5 < t2h1d8 && t2w1lwt5 <t2w1rwt8 && t2w1lwt5 <t2w1lwt8 && t2w1lwt5 < t2h1uwt8 && t2w1lwt5 < t2h1dwt8
  && t2w1lwt5 < t2w1r9 && t2w1lwt5 < t2w1l9 && t2w1lwt5 < t2h1u9 && t2w1lwt5 < t2h1d9 && t2w1lwt5 <t2w1rwt9 && t2w1lwt5 <t2w1lwt9 && t2w1lwt5 < t2h1uwt9 && t2w1lwt5 < t2h1dwt9
  && t2w1lwt5 < t2w1r10 && t2w1lwt5 < t2w1l10 && t2w1lwt5 < t2h1u10 && t2w1lwt5 < t2h1d10 && t2w1lwt5 <t2w1rwt10 && t2w1lwt5 <t2w1lwt10 && t2w1lwt5 < t2h1uwt10 && t2w1lwt5 < t2h1dwt10)
{
	    if (mxlOW5 == 0) i = 235;
    else{
	    if (mxlOW5 == -1) i = 239;
    else{
	    if (linwl5!=0 && loutwl5!=0) i=225;
    else{
	    if ((loutwl5!=0 && linwl5==0) || (loutwl5==0 && linwl5!=0)) i= 226;
    else{
	    if (loutwl5==0 && linwl5==0) i=227;
}}}}}

/* neutron interacts with the elliptic top OUTER wall - comments are analog to inner elliptic right wall*/

  if (t2h1uwt5 > 0 && t2h1uwt5 < t1 
  && t2h1uwt5 < t2w1r && t2h1uwt5 < t2w1l && t2h1uwt5 < t2h1u && t2h1uwt5 < t2h1d && t2h1uwt5 < t2w1rwt && t2h1uwt5 < t2w1lwt && t2h1uwt5 < t2h1uwt && t2h1uwt5 < t2h1dwt 
  && t2h1uwt5 < t2w1r1 && t2h1uwt5 < t2w1l1 && t2h1uwt5 < t2h1u1 && t2h1uwt5 < t2h1d1 && t2h1uwt5 < t2w1rwt1 && t2h1uwt5 < t2w1lwt1 && t2h1uwt5 < t2h1uwt1 && t2h1uwt5 < t2h1dwt1
  && t2h1uwt5 < t2w1r2 && t2h1uwt5 < t2w1l2 && t2h1uwt5 < t2h1u2 && t2h1uwt5 < t2h1d2 && t2h1uwt5 < t2w1rwt2 && t2h1uwt5 < t2w1lwt2 && t2h1uwt5 < t2h1uwt2 && t2h1uwt5 < t2h1dwt2
  && t2h1uwt5 < t2w1r3 && t2h1uwt5 < t2w1l3 && t2h1uwt5 < t2h1u3 && t2h1uwt5 < t2h1d3 && t2h1uwt5 < t2w1rwt3 && t2h1uwt5 < t2w1lwt3 && t2h1uwt5 < t2h1uwt3 && t2h1uwt5 < t2h1dwt3
  && t2h1uwt5 < t2w1r4 && t2h1uwt5 < t2w1l4 && t2h1uwt5 < t2h1u4 && t2h1uwt5 < t2h1d4 && t2h1uwt5 < t2w1rwt4 && t2h1uwt5 < t2w1lwt4 && t2h1uwt5 < t2h1uwt4 && t2h1uwt5 < t2h1dwt4
  && t2h1uwt5 < t2w1r5 && t2h1uwt5 < t2w1l5 && t2h1uwt5 < t2h1u5 && t2h1uwt5 < t2h1d5 && t2h1uwt5 < t2w1rwt5 && t2h1uwt5 < t2w1lwt5 && t2h1uwt5 < t2h1dwt5
  && t2h1uwt5 < t2w1r6 && t2h1uwt5 < t2w1l6 && t2h1uwt5 < t2h1u6 && t2h1uwt5 < t2h1d6 && t2h1uwt5 < t2w1rwt6 && t2h1uwt5 < t2w1lwt6 && t2h1uwt5 < t2h1uwt6 && t2h1uwt5 < t2h1dwt6
  && t2h1uwt5 < t2w1r7 && t2h1uwt5 < t2w1l7 && t2h1uwt5 < t2h1u7 && t2h1uwt5 < t2h1d7 && t2h1uwt5 < t2w1rwt7 && t2h1uwt5 < t2w1lwt7 && t2h1uwt5 < t2h1uwt7 && t2h1uwt5 < t2h1dwt7
  && t2h1uwt5 < t2w1r8 && t2h1uwt5 < t2w1l8 && t2h1uwt5 < t2h1u8 && t2h1uwt5 < t2h1d8 && t2h1uwt5 < t2w1rwt8 && t2h1uwt5 < t2w1lwt8 && t2h1uwt5 < t2h1uwt8 && t2h1uwt5 < t2h1dwt8
  && t2h1uwt5 < t2w1r9 && t2h1uwt5 < t2w1l9 && t2h1uwt5 < t2h1u9 && t2h1uwt5 < t2h1d9 && t2h1uwt5 < t2w1rwt9 && t2h1uwt5 < t2w1lwt9 && t2h1uwt5 < t2h1uwt9 && t2h1uwt5 < t2h1dwt9
  && t2h1uwt5 < t2w1r10 && t2h1uwt5 < t2w1l10 && t2h1uwt5 < t2h1u10 && t2h1uwt5 < t2h1d10 && t2h1uwt5 < t2w1rwt10 && t2h1uwt5 < t2w1lwt10 && t2h1uwt5 < t2h1uwt10 && t2h1uwt5 < t2h1dwt10)
{
	    if (myuOW5 == 0) i = 236;
    else{
	    if (myuOW5 == -1) i = 240;
    else{
	    if (louthu5 !=0 && linhu5!=0) i=228;
    else{
	    if ((louthu5!=0 && linhu5==0) || (louthu5==0 && linhu5!=0)) i = 229;
    else{
	    if (louthu5 == 0 && linhu5 == 0) i =230;
}}}}}


/* neutron interacts with the elliptic down OUTER wall - comments are analog to inner elliptic right wall*/

  if (t2h1dwt5 > 0 && t2h1dwt5 < t1 
  && t2h1dwt5 < t2w1r && t2h1dwt5 < t2w1l && t2h1dwt5 < t2h1u && t2h1dwt5 < t2h1d && t2h1dwt5 < t2w1rwt && t2h1dwt5 < t2w1lwt && t2h1dwt5 < t2h1uwt && t2h1dwt5 < t2h1dwt 
  && t2h1dwt5 < t2w1r1 && t2h1dwt5 < t2w1l1 && t2h1dwt5 < t2h1u1 && t2h1dwt5 < t2h1d1 && t2h1dwt5 < t2w1rwt1 && t2h1dwt5 < t2w1lwt1 && t2h1dwt5 < t2h1uwt1 && t2h1dwt5 < t2h1dwt1
  && t2h1dwt5 < t2w1r2 && t2h1dwt5 < t2w1l2 && t2h1dwt5 < t2h1u2 && t2h1dwt5 < t2h1d2 && t2h1dwt5 < t2w1rwt2 && t2h1dwt5 < t2w1lwt2 && t2h1dwt5 < t2h1uwt2 && t2h1dwt5 < t2h1dwt2 
  && t2h1dwt5 < t2w1r3 && t2h1dwt5 < t2w1l3 && t2h1dwt5 < t2h1u3 && t2h1dwt5 < t2h1d3 && t2h1dwt5 < t2w1rwt3 && t2h1dwt5 < t2w1lwt3 && t2h1dwt5 < t2h1uwt3 && t2h1dwt5 < t2h1dwt3
  && t2h1dwt5 < t2w1r4 && t2h1dwt5 < t2w1l4 && t2h1dwt5 < t2h1u4 && t2h1dwt5 < t2h1d4 && t2h1dwt5 < t2w1rwt4 && t2h1dwt5 < t2w1lwt4 && t2h1dwt5 < t2h1uwt4 && t2h1dwt5 < t2h1dwt4
  && t2h1dwt5 < t2w1r5 && t2h1dwt5 < t2w1l5 && t2h1dwt5 < t2h1u5 && t2h1dwt5 < t2h1d5 && t2h1dwt5 < t2w1rwt5 && t2h1dwt5 < t2w1lwt5 && t2h1dwt5 < t2h1uwt5 
  && t2h1dwt5 < t2w1r6 && t2h1dwt5 < t2w1l6 && t2h1dwt5 < t2h1u6 && t2h1dwt5 < t2h1d6 && t2h1dwt5 < t2w1rwt6 && t2h1dwt5 < t2w1lwt6 && t2h1dwt5 < t2h1uwt6 && t2h1dwt5 < t2h1dwt6
  && t2h1dwt5 < t2w1r7 && t2h1dwt5 < t2w1l7 && t2h1dwt5 < t2h1u7 && t2h1dwt5 < t2h1d7 && t2h1dwt5 < t2w1rwt7 && t2h1dwt5 < t2w1lwt7 && t2h1dwt5 < t2h1uwt7 && t2h1dwt5 < t2h1dwt7 
  && t2h1dwt5 < t2w1r8 && t2h1dwt5 < t2w1l8 && t2h1dwt5 < t2h1u8 && t2h1dwt5 < t2h1d8 && t2h1dwt5 < t2w1rwt8 && t2h1dwt5 < t2w1lwt8 && t2h1dwt5 < t2h1uwt8 && t2h1dwt5 < t2h1dwt8
  && t2h1dwt5 < t2w1r9 && t2h1dwt5 < t2w1l9 && t2h1dwt5 < t2h1u9 && t2h1dwt5 < t2h1d9 && t2h1dwt5 < t2w1rwt9 && t2h1dwt5 < t2w1lwt9 && t2h1dwt5 < t2h1uwt9 && t2h1dwt5 < t2h1dwt9 
  && t2h1dwt5 < t2w1r10 && t2h1dwt5 < t2w1l10 && t2h1dwt5 < t2h1u10 && t2h1dwt5 < t2h1d10 && t2h1dwt5 < t2w1rwt10 && t2h1dwt5 < t2w1lwt10 && t2h1dwt5 < t2h1uwt10 && t2h1dwt5 < t2h1dwt10)
{
	    if ( mydOW5 == 0 ) i=237;
    else{
	    if ( mydOW5 == -1) i=241;
    else{
	    if (louthd5 !=0 && linhd5!=0)  i=231;
    else{
	    if ((louthd5 !=0 && linhd5==0) || (louthd5 ==0 && linhd5!=0)) i=232;
    else{
	    if (louthd5 == 0 && linhd5 == 0) i =233;
}}}}}

    /*  SIXTH SHELL  */

  if (t2w1r6 > 0 && t2w1r6 < t1 
     && t2w1r6 < t2w1r && t2w1r6 < t2w1l && t2w1r6 < t2h1u && t2w1r6 < t2h1d && t2w1r6 < t2w1rwt && t2w1r6 < t2w1lwt && t2w1r6 < t2h1uwt && t2w1r6 < t2h1dwt
     && t2w1r6 < t2w1r1 && t2w1r6 < t2w1l1 && t2w1r6 < t2h1u1 && t2w1r6 < t2h1d1 && t2w1r6 < t2w1rwt1 && t2w1r6 < t2w1lwt1 && t2w1r6 < t2h1uwt1 && t2w1r6 < t2h1dwt1
     && t2w1r6 < t2w1r2 && t2w1r6 < t2w1l2 && t2w1r6 < t2h1u2 && t2w1r6 < t2h1d2 && t2w1r6 < t2w1rwt2 && t2w1r6 < t2w1lwt2 && t2w1r6 < t2h1uwt2 && t2w1r6 < t2h1dwt2 
     && t2w1r6 < t2w1r3 && t2w1r6 < t2w1l3 && t2w1r6 < t2h1u3 && t2w1r6 < t2h1d3 && t2w1r6 < t2w1rwt3 && t2w1r6 < t2w1lwt3 && t2w1r6 < t2h1uwt3 && t2w1r6 < t2h1dwt3
     && t2w1r6 < t2w1r4 && t2w1r6 < t2w1l4 && t2w1r6 < t2h1u4 && t2w1r6 < t2h1d4 && t2w1r6 < t2w1rwt4 && t2w1r6 < t2w1lwt4 && t2w1r6 < t2h1uwt4 && t2w1r6 < t2h1dwt4
     && t2w1r6 < t2w1r5 && t2w1r6 < t2w1l5 && t2w1r6 < t2h1u5 && t2w1r6 < t2h1d5 && t2w1r6 < t2w1rwt5 && t2w1r6 < t2w1lwt5 && t2w1r6 < t2h1uwt5 && t2w1r6 < t2h1dwt5
     && t2w1r6 < t2w1l6 && t2w1r6 < t2h1u6 && t2w1r6 < t2h1d6 && t2w1r6 < t2w1rwt6 && t2w1r6 < t2w1lwt6 && t2w1r6 < t2h1uwt6 && t2w1r6 < t2h1dwt6
     && t2w1r6 < t2w1r7 && t2w1r6 < t2w1l7 && t2w1r6 < t2h1u7 && t2w1r6 < t2h1d7 && t2w1r6 < t2w1rwt7 && t2w1r6 < t2w1lwt7 && t2w1r6 < t2h1uwt7 && t2w1r6 < t2h1dwt7
     && t2w1r6 < t2w1r8 && t2w1r6 < t2w1l8 && t2w1r6 < t2h1u8 && t2w1r6 < t2h1d8 && t2w1r6 < t2w1rwt8 && t2w1r6 < t2w1lwt8 && t2w1r6 < t2h1uwt8 && t2w1r6 < t2h1dwt8
     && t2w1r6 < t2w1r9 && t2w1r6 < t2w1l9 && t2w1r6 < t2h1u9 && t2w1r6 < t2h1d9 && t2w1r6 < t2w1rwt9 && t2w1r6 < t2w1lwt9 && t2w1r6 < t2h1uwt9 && t2w1r6 < t2h1dwt9
     && t2w1r6 < t2w1r10 && t2w1r6 < t2w1l10 && t2w1r6 < t2h1u10 && t2w1r6 < t2h1d10 && t2w1r6 < t2w1rwt10 && t2w1r6 < t2w1lwt10 && t2w1r6 < t2h1uwt10 && t2w1r6 < t2h1dwt10)
{
	    if (mxr6 == 0) i =258;
    else{
	    if (mxr6 == -1) i= 254;
    else{
	    if (linwr6!=0 && loutwr6!=0) i= 242;
    else{
	    if ((loutwr6!=0 && linwr6==0) || (loutwr6==0 && linwr6!=0)) i = 243;
    else{
	    if (loutwr6==0 && linwr6==0) i= 244;
}}}}}

/* neutron interacts with the elliptic left INNER wall - comments are analog to inner elliptic right wall*/

  if (t2w1l6 > 0 && t2w1l6 < t1 
      && t2w1l6 < t2w1r && t2w1l6 < t2w1l && t2w1l6 < t2h1u && t2w1l6 < t2h1d && t2w1l6 < t2w1rwt && t2w1l6 < t2w1lwt && t2w1l6 < t2h1uwt && t2w1l6 < t2h1dwt
      && t2w1l6 < t2w1r1 && t2w1l6 < t2w1l1 && t2w1l6 < t2h1u1 && t2w1l6 < t2h1d1 && t2w1l6 < t2w1rwt1 && t2w1l6 < t2w1lwt1 && t2w1l6 < t2h1uwt1 && t2w1l6 < t2h1dwt1
      && t2w1l6 < t2w1r2 && t2w1l6 < t2w1l2 && t2w1l6 < t2h1u2 && t2w1l6 < t2h1d2 && t2w1l6 < t2w1rwt2 && t2w1l6 < t2w1lwt2 && t2w1l6 < t2h1uwt2 && t2w1l6 < t2h1dwt2
      && t2w1l6 < t2w1r3 && t2w1l6 < t2w1l3 && t2w1l6 < t2h1u3 && t2w1l6 < t2h1d3 && t2w1l6 < t2w1rwt3 && t2w1l6 < t2w1lwt3 && t2w1l6 < t2h1uwt3 && t2w1l6 < t2h1dwt3
      && t2w1l6 < t2w1r4 && t2w1l6 < t2w1l4 && t2w1l6 < t2h1u4 && t2w1l6 < t2h1d4 && t2w1l6 < t2w1rwt4 && t2w1l6 < t2w1lwt4 && t2w1l6 < t2h1uwt4 && t2w1l6 < t2h1dwt4
      && t2w1l6 < t2w1r5 && t2w1l6 < t2w1l5 && t2w1l6 < t2h1u5 && t2w1l6 < t2h1d5 && t2w1l6 < t2w1rwt5 && t2w1l6 < t2w1lwt5 && t2w1l6 < t2h1uwt5 && t2w1l6 < t2h1dwt5
      && t2w1l6 < t2w1r6 && t2w1l6 < t2h1u6 && t2w1l6 < t2h1d6 && t2w1l6 < t2w1rwt6 && t2w1l6 < t2w1lwt6 && t2w1l6 < t2h1uwt6 && t2w1l6 < t2h1dwt6
      && t2w1l6 < t2w1r7 && t2w1l6 < t2w1l7 && t2w1l6 < t2h1u7 && t2w1l6 < t2h1d7 && t2w1l6 < t2w1rwt7 && t2w1l6 < t2w1lwt7 && t2w1l6 < t2h1uwt7 && t2w1l6 < t2h1dwt7
      && t2w1l6 < t2w1r8 && t2w1l6 < t2w1l8 && t2w1l6 < t2h1u8 && t2w1l6 < t2h1d8 && t2w1l6 < t2w1rwt8 && t2w1l6 < t2w1lwt8 && t2w1l6 < t2h1uwt8 && t2w1l6 < t2h1dwt8
      && t2w1l6 < t2w1r9 && t2w1l6 < t2w1l9 && t2w1l6 < t2h1u9 && t2w1l6 < t2h1d9 && t2w1l6 < t2w1rwt9 && t2w1l6 < t2w1lwt9 && t2w1l6 < t2h1uwt9 && t2w1l6 < t2h1dwt9
      && t2w1l6 < t2w1r10 && t2w1l6 < t2w1l10 && t2w1l6 < t2h1u10 && t2w1l6 < t2h1d10 && t2w1l6 < t2w1rwt10 && t2w1l6 < t2w1lwt10 && t2w1l6 < t2h1uwt10 && t2w1l6 < t2h1dwt10)
{
	    if (mxl6 == 0) i = 259;
    else{
	    if (mxl6 == -1) i = 255;
    else{
	    if (linwl6!=0 && loutwl6!=0) i=245;
    else{
	    if ((loutwl6!=0 && linwl6==0) || (loutwl6==0 && linwl6!=0)) i= 246;
    else{
	    if (loutwl6==0 && linwl6==0) i=247;
}}}}}


/* neutron interacts with the elliptic top INNER wall - comments are analog to inner elliptic right wall*/

  if (t2h1u6 > 0 && t2h1u6 < t1 
  && t2h1u6 < t2w1r && t2h1u6 < t2w1l && t2h1u6 < t2h1u && t2h1u6 < t2h1d && t2h1u6 < t2w1rwt && t2h1u6 < t2w1lwt && t2h1u6 < t2h1uwt && t2h1u6 < t2h1dwt
  && t2h1u6 < t2w1r1 && t2h1u6 < t2w1l1 && t2h1u6 < t2h1u1 && t2h1u6 < t2h1d1 && t2h1u6 < t2w1rwt1 && t2h1u6 < t2w1lwt1 && t2h1u6 < t2h1uwt1 && t2h1u6 < t2h1dwt1
  && t2h1u6 < t2w1r2 && t2h1u6 < t2w1l2 && t2h1u6 < t2h1u2 && t2h1u6 < t2h1d2 && t2h1u6 < t2w1rwt2 && t2h1u6 < t2w1lwt2 && t2h1u6 < t2h1uwt2 && t2h1u6 < t2h1dwt2
  && t2h1u6 < t2w1r3 && t2h1u6 < t2w1l3 && t2h1u6 < t2h1u3 && t2h1u6 < t2h1d3 && t2h1u6 < t2w1rwt3 && t2h1u6 < t2w1lwt3 && t2h1u6 < t2h1uwt3 && t2h1u6 < t2h1dwt3
  && t2h1u6 < t2w1r4 && t2h1u6 < t2w1l4 && t2h1u6 < t2h1u4 && t2h1u6 < t2h1d4 && t2h1u6 < t2w1rwt4 && t2h1u6 < t2w1lwt4 && t2h1u6 < t2h1uwt4 && t2h1u6 < t2h1dwt4
  && t2h1u6 < t2w1r5 && t2h1u6 < t2w1l5 && t2h1u6 < t2h1u5 && t2h1u6 < t2h1d5 && t2h1u6 < t2w1rwt5 && t2h1u6 < t2w1lwt5 && t2h1u6 < t2h1uwt5 && t2h1u6 < t2h1dwt5
  && t2h1u6 < t2w1r6 && t2h1u6 < t2w1l6 && t2h1u6 < t2h1d6 && t2h1u6 < t2w1rwt6 && t2h1u6 < t2w1lwt6 && t2h1u6 < t2h1uwt6 && t2h1u6 < t2h1dwt6
  && t2h1u6 < t2w1r7 && t2h1u6 < t2w1l7 && t2h1u6 < t2h1u7 && t2h1u6 < t2h1d7 && t2h1u6 < t2w1rwt7 && t2h1u6 < t2w1lwt7 && t2h1u6 < t2h1uwt7 && t2h1u6 < t2h1dwt7
  && t2h1u6 < t2w1r8 && t2h1u6 < t2w1l8 && t2h1u6 < t2h1u8 && t2h1u6 < t2h1d8 && t2h1u6 < t2w1rwt8 && t2h1u6 < t2w1lwt8 && t2h1u6 < t2h1uwt8 && t2h1u6 < t2h1dwt8
  && t2h1u6 < t2w1r9 && t2h1u6 < t2w1l9 && t2h1u6 < t2h1u9 && t2h1u6 < t2h1d9 && t2h1u6 < t2w1rwt9 && t2h1u6 < t2w1lwt9 && t2h1u6 < t2h1uwt9 && t2h1u6 < t2h1dwt9
  && t2h1u6 < t2w1r10 && t2h1u6 < t2w1l10 && t2h1u6 < t2h1u10 && t2h1u6 < t2h1d10 && t2h1u6 < t2w1rwt10 && t2h1u6 < t2w1lwt10 && t2h1u6 < t2h1uwt10 && t2h1u6 < t2h1dwt10)
{
	    if (myu6 == 0) i = 260;
    else{
	    if (myu6 == -1) i = 256;
    else{
	    if (louthu6 !=0 && linhu6!=0) i=248;
    else{
	    if ((louthu6!=0 && linhu6==0) || (louthu6==0 && linhu6!=0)) i = 249;
    else{
	    if (louthu6 == 0 && linhu6 == 0) i =250;
}}}}}

/* neutron interacts with the elliptic down INNER wall - comments are analog to inner elliptic right wall*/

  if (t2h1d6 > 0 && t2h1d6 < t1 
  && t2h1d6 < t2w1r && t2h1d6 < t2w1l && t2h1d6 < t2h1u && t2h1d6 < t2h1d && t2h1d6 < t2w1rwt && t2h1d6 < t2w1lwt && t2h1d6 < t2h1uwt && t2h1d6 < t2h1dwt
  && t2h1d6 < t2w1r1 && t2h1d6 < t2w1l1 && t2h1d6 < t2h1u1 && t2h1d6 < t2h1d1 && t2h1d6 < t2w1rwt1 && t2h1d6 < t2w1lwt1 && t2h1d6 < t2h1uwt1 && t2h1d6 < t2h1dwt1
  && t2h1d6 < t2w1r2 && t2h1d6 < t2w1l2 && t2h1d6 < t2h1u2 && t2h1d6 < t2h1d2 && t2h1d6 < t2w1rwt2 && t2h1d6 < t2w1lwt2 && t2h1d6 < t2h1uwt2 && t2h1d6 < t2h1dwt2
  && t2h1d6 < t2w1r3 && t2h1d6 < t2w1l3 && t2h1d6 < t2h1u3 && t2h1d6 < t2h1d3 && t2h1d6 < t2w1rwt3 && t2h1d6 < t2w1lwt3 && t2h1d6 < t2h1uwt3 && t2h1d6 < t2h1dwt3
  && t2h1d6 < t2w1r4 && t2h1d6 < t2w1l4 && t2h1d6 < t2h1u4 && t2h1d6 < t2h1d4 && t2h1d6 < t2w1rwt4 && t2h1d6 < t2w1lwt4 && t2h1d6 < t2h1uwt4 && t2h1d6 < t2h1dwt4
  && t2h1d6 < t2w1r5 && t2h1d6 < t2w1l5 && t2h1d6 < t2h1u5 && t2h1d6 < t2h1d5 && t2h1d6 < t2w1rwt5 && t2h1d6 < t2w1lwt5 && t2h1d6 < t2h1uwt5 && t2h1d6 < t2h1dwt5
  && t2h1d6 < t2w1r6 && t2h1d6 < t2w1l6 && t2h1d6 < t2h1u6 && t2h1d6 < t2w1rwt6 && t2h1d6 < t2w1lwt6 && t2h1d6 < t2h1uwt6 && t2h1d6 < t2h1dwt6
  && t2h1d6 < t2w1r7 && t2h1d6 < t2w1l7 && t2h1d6 < t2h1u7 && t2h1d6 < t2h1d7 && t2h1d6 < t2w1rwt7 && t2h1d6 < t2w1lwt7 && t2h1d6 < t2h1uwt7 && t2h1d6 < t2h1dwt7
  && t2h1d6 < t2w1r8 && t2h1d6 < t2w1l8 && t2h1d6 < t2h1u8 && t2h1d6 < t2h1d8 && t2h1d6 < t2w1rwt8 && t2h1d6 < t2w1lwt8 && t2h1d6 < t2h1uwt8 && t2h1d6 < t2h1dwt8
  && t2h1d6 < t2w1r9 && t2h1d6 < t2w1l9 && t2h1d6 < t2h1u9 && t2h1d6 < t2h1d9 && t2h1d6 < t2w1rwt9 && t2h1d6 < t2w1lwt9 && t2h1d6 < t2h1uwt9 && t2h1d6 < t2h1dwt9
  && t2h1d6 < t2w1r10 && t2h1d6 < t2w1l10 && t2h1d6 < t2h1u10 && t2h1d6 < t2h1d10 && t2h1d6 < t2w1rwt10 && t2h1d6 < t2w1lwt10 && t2h1d6 < t2h1uwt10 && t2h1d6 < t2h1dwt10)
{
	    if ( myd6 == 0 ) i=261;
    else{
	    if ( myd6 == -1) i=257;
    else{
	    if (louthd6 !=0 && linhd6!=0)  i=251;
    else{
	    if ((louthd6 !=0 && linhd6==0) || (louthd6 ==0 && linhd6!=0)) i=252;
    else{
	    if (louthd6 == 0 && linhd6 == 0) i =253;
}}}}}

/* EVERTHING AGAIN FOR THE OUTER WALLS */

/* neutron interacts with the elliptic right OUTER wall - comments are analog to inner elliptic right wall*/

  if (t2w1rwt6 > 0 && t2w1rwt6 < t1 
  && t2w1rwt6 < t2w1r && t2w1rwt6 < t2w1l && t2w1rwt6 < t2h1u && t2w1rwt6 < t2h1d && t2w1rwt6 <t2w1rwt && t2w1rwt6 <t2w1lwt && t2w1rwt6 < t2h1uwt && t2w1rwt6 < t2h1dwt
  && t2w1rwt6 < t2w1r1 && t2w1rwt6 < t2w1l1 && t2w1rwt6 < t2h1u1 && t2w1rwt6 < t2h1d1 && t2w1rwt6 <t2w1rwt1 && t2w1rwt6 <t2w1lwt1 && t2w1rwt6 < t2h1uwt1 && t2w1rwt6 < t2h1dwt1
  && t2w1rwt6 < t2w1r2 && t2w1rwt6 < t2w1l2 && t2w1rwt6 < t2h1u2 && t2w1rwt6 < t2h1d2 && t2w1rwt6 <t2w1rwt2 && t2w1rwt6 <t2w1lwt2 && t2w1rwt6 < t2h1uwt2 && t2w1rwt6 < t2h1dwt2
  && t2w1rwt6 < t2w1r3 && t2w1rwt6 < t2w1l3 && t2w1rwt6 < t2h1u3 && t2w1rwt6 < t2h1d3 && t2w1rwt6 <t2w1rwt3 && t2w1rwt6 <t2w1lwt3 && t2w1rwt6 < t2h1uwt3 && t2w1rwt6 < t2h1dwt3
  && t2w1rwt6 < t2w1r4 && t2w1rwt6 < t2w1l4 && t2w1rwt6 < t2h1u4 && t2w1rwt6 < t2h1d4 && t2w1rwt6 <t2w1rwt4 && t2w1rwt6 <t2w1lwt4 && t2w1rwt6 < t2h1uwt4 && t2w1rwt6 < t2h1dwt4
  && t2w1rwt6 < t2w1r5 && t2w1rwt6 < t2w1l5 && t2w1rwt6 < t2h1u5 && t2w1rwt6 < t2h1d5 && t2w1rwt6 <t2w1rwt5 && t2w1rwt6 <t2w1lwt5 && t2w1rwt6 < t2h1uwt5 && t2w1rwt6 < t2h1dwt5
  && t2w1rwt6 < t2w1r6 && t2w1rwt6 < t2w1l6 && t2w1rwt6 < t2h1u6 && t2w1rwt6 < t2h1d6 && t2w1rwt6 <t2w1lwt6 && t2w1rwt6 < t2h1uwt6 && t2w1rwt6 < t2h1dwt6
  && t2w1rwt6 < t2w1r7 && t2w1rwt6 < t2w1l7 && t2w1rwt6 < t2h1u7 && t2w1rwt6 < t2h1d7 && t2w1rwt6 <t2w1rwt7 && t2w1rwt6 <t2w1lwt7 && t2w1rwt6 < t2h1uwt7 && t2w1rwt6 < t2h1dwt7
  && t2w1rwt6 < t2w1r8 && t2w1rwt6 < t2w1l8 && t2w1rwt6 < t2h1u8 && t2w1rwt6 < t2h1d8 && t2w1rwt6 <t2w1rwt8 && t2w1rwt6 <t2w1lwt8 && t2w1rwt6 < t2h1uwt8 && t2w1rwt6 < t2h1dwt8
  && t2w1rwt6 < t2w1r9 && t2w1rwt6 < t2w1l9 && t2w1rwt6 < t2h1u9 && t2w1rwt6 < t2h1d9 && t2w1rwt6 <t2w1rwt9 && t2w1rwt6 <t2w1lwt9 && t2w1rwt6 < t2h1uwt9 && t2w1rwt6 < t2h1dwt9
  && t2w1rwt6 < t2w1r10 && t2w1rwt6 < t2w1l10 && t2w1rwt6 < t2h1u10 && t2w1rwt6 < t2h1d10 && t2w1rwt6 <t2w1rwt10 && t2w1rwt6 <t2w1lwt10 && t2w1rwt6 < t2h1uwt10 && t2w1rwt6 < t2h1dwt10)
{
	    if (mxrOW6 == 0) i =274;
    else{
	    if (mxrOW6 == -1) i= 278;
    else{
	    if (linwr6!=0 && loutwr6!=0) i= 262;
    else{
	    if ((loutwr6!=0 && linwr6==0) || (loutwr6==0 && linwr6!=0)) i = 263;
    else{
	    if (loutwr6==0 && linwr6==0) i= 264;
}}}}}

/* neutron interacts with the elliptic left OUTER wall - comments are analog to inner elliptic right wall*/

  if (t2w1lwt6 > 0 && t2w1lwt6 < t1 
  && t2w1lwt6 < t2w1r && t2w1lwt6 < t2w1l && t2w1lwt6 < t2h1u && t2w1lwt6 < t2h1d && t2w1lwt6 <t2w1rwt && t2w1lwt6 <t2w1lwt && t2w1lwt6 < t2h1uwt && t2w1lwt6 < t2h1dwt
  && t2w1lwt6 < t2w1r1 && t2w1lwt6 < t2w1l1 && t2w1lwt6 < t2h1u1 && t2w1lwt6 < t2h1d1 && t2w1lwt6 <t2w1rwt1 && t2w1lwt6 <t2w1lwt1 && t2w1lwt6 < t2h1uwt1 && t2w1lwt6 < t2h1dwt1
  && t2w1lwt6 < t2w1r2 && t2w1lwt6 < t2w1l2 && t2w1lwt6 < t2h1u2 && t2w1lwt6 < t2h1d2 && t2w1lwt6 <t2w1rwt2 && t2w1lwt6 <t2w1lwt2 && t2w1lwt6 < t2h1uwt2 && t2w1lwt6 < t2h1dwt2
  && t2w1lwt6 < t2w1r3 && t2w1lwt6 < t2w1l3 && t2w1lwt6 < t2h1u3 && t2w1lwt6 < t2h1d3 && t2w1lwt6 <t2w1rwt3 && t2w1lwt6 <t2w1lwt3 && t2w1lwt6 < t2h1uwt3 && t2w1lwt6 < t2h1dwt3
  && t2w1lwt6 < t2w1r4 && t2w1lwt6 < t2w1l4 && t2w1lwt6 < t2h1u4 && t2w1lwt6 < t2h1d4 && t2w1lwt6 <t2w1rwt4 && t2w1lwt6 <t2w1lwt4 && t2w1lwt6 < t2h1uwt4 && t2w1lwt6 < t2h1dwt4
  && t2w1lwt6 < t2w1r5 && t2w1lwt6 < t2w1l5 && t2w1lwt6 < t2h1u5 && t2w1lwt6 < t2h1d5 && t2w1lwt6 <t2w1rwt5 && t2w1lwt6 <t2w1lwt5 && t2w1lwt6 < t2h1uwt5 && t2w1lwt6 < t2h1dwt5
  && t2w1lwt6 < t2w1r6 && t2w1lwt6 < t2w1l6 && t2w1lwt6 < t2h1u6 && t2w1lwt6 < t2h1d6 && t2w1lwt6 <t2w1rwt6 && t2w1lwt6 < t2h1uwt6 && t2w1lwt6 < t2h1dwt6
  && t2w1lwt6 < t2w1r7 && t2w1lwt6 < t2w1l7 && t2w1lwt6 < t2h1u7 && t2w1lwt6 < t2h1d7 && t2w1lwt6 <t2w1rwt7 && t2w1lwt6 <t2w1lwt7 && t2w1lwt6 < t2h1uwt7 && t2w1lwt6 < t2h1dwt7
  && t2w1lwt6 < t2w1r8 && t2w1lwt6 < t2w1l8 && t2w1lwt6 < t2h1u8 && t2w1lwt6 < t2h1d8 && t2w1lwt6 <t2w1rwt8 && t2w1lwt6 <t2w1lwt8 && t2w1lwt6 < t2h1uwt8 && t2w1lwt6 < t2h1dwt8
  && t2w1lwt6 < t2w1r9 && t2w1lwt6 < t2w1l9 && t2w1lwt6 < t2h1u9 && t2w1lwt6 < t2h1d9 && t2w1lwt6 <t2w1rwt9 && t2w1lwt6 <t2w1lwt9 && t2w1lwt6 < t2h1uwt9 && t2w1lwt6 < t2h1dwt9
  && t2w1lwt6 < t2w1r10 && t2w1lwt6 < t2w1l10 && t2w1lwt6 < t2h1u10 && t2w1lwt6 < t2h1d10 && t2w1lwt6 <t2w1rwt10 && t2w1lwt6 <t2w1lwt10 && t2w1lwt6 < t2h1uwt10 && t2w1lwt6 < t2h1dwt10)
{
	    if (mxlOW6 == 0) i = 275;
    else{
	    if (mxlOW6 == -1) i = 278;
    else{
	    if (linwl6!=0 && loutwl6!=0) i=265;
    else{
	    if ((loutwl6!=0 && linwl6==0) || (loutwl6==0 && linwl6!=0)) i= 266;
    else{
	    if (loutwl6==0 && linwl6==0) i=267;
}}}}}

/* neutron interacts with the elliptic top OUTER wall - comments are analog to inner elliptic right wall*/

  if (t2h1uwt6 > 0 && t2h1uwt6 < t1 
  && t2h1uwt6 < t2w1r && t2h1uwt6 < t2w1l && t2h1uwt6 < t2h1u && t2h1uwt6 < t2h1d && t2h1uwt6 < t2w1rwt && t2h1uwt6 < t2w1lwt && t2h1uwt6 < t2h1uwt && t2h1uwt6 < t2h1dwt 
  && t2h1uwt6 < t2w1r1 && t2h1uwt6 < t2w1l1 && t2h1uwt6 < t2h1u1 && t2h1uwt6 < t2h1d1 && t2h1uwt6 < t2w1rwt1 && t2h1uwt6 < t2w1lwt1 && t2h1uwt6 < t2h1uwt1 && t2h1uwt6 < t2h1dwt1
  && t2h1uwt6 < t2w1r2 && t2h1uwt6 < t2w1l2 && t2h1uwt6 < t2h1u2 && t2h1uwt6 < t2h1d2 && t2h1uwt6 < t2w1rwt2 && t2h1uwt6 < t2w1lwt2 && t2h1uwt6 < t2h1uwt2 && t2h1uwt6 < t2h1dwt2
  && t2h1uwt6 < t2w1r3 && t2h1uwt6 < t2w1l3 && t2h1uwt6 < t2h1u3 && t2h1uwt6 < t2h1d3 && t2h1uwt6 < t2w1rwt3 && t2h1uwt6 < t2w1lwt3 && t2h1uwt6 < t2h1uwt3 && t2h1uwt6 < t2h1dwt3
  && t2h1uwt6 < t2w1r4 && t2h1uwt6 < t2w1l4 && t2h1uwt6 < t2h1u4 && t2h1uwt6 < t2h1d4 && t2h1uwt6 < t2w1rwt4 && t2h1uwt6 < t2w1lwt4 && t2h1uwt6 < t2h1uwt4 && t2h1uwt6 < t2h1dwt4
  && t2h1uwt6 < t2w1r5 && t2h1uwt6 < t2w1l5 && t2h1uwt6 < t2h1u5 && t2h1uwt6 < t2h1d5 && t2h1uwt6 < t2w1rwt5 && t2h1uwt6 < t2w1lwt5 && t2h1uwt6 < t2h1uwt5 && t2h1uwt6 < t2h1dwt5
  && t2h1uwt6 < t2w1r6 && t2h1uwt6 < t2w1l6 && t2h1uwt6 < t2h1u6 && t2h1uwt6 < t2h1d6 && t2h1uwt6 < t2w1rwt6 && t2h1uwt6 < t2w1lwt6 && t2h1uwt6 < t2h1dwt6
  && t2h1uwt6 < t2w1r7 && t2h1uwt6 < t2w1l7 && t2h1uwt6 < t2h1u7 && t2h1uwt6 < t2h1d7 && t2h1uwt6 < t2w1rwt7 && t2h1uwt6 < t2w1lwt7 && t2h1uwt6 < t2h1uwt7 && t2h1uwt6 < t2h1dwt7
  && t2h1uwt6 < t2w1r8 && t2h1uwt6 < t2w1l8 && t2h1uwt6 < t2h1u8 && t2h1uwt6 < t2h1d8 && t2h1uwt6 < t2w1rwt8 && t2h1uwt6 < t2w1lwt8 && t2h1uwt6 < t2h1uwt8 && t2h1uwt6 < t2h1dwt8
  && t2h1uwt6 < t2w1r9 && t2h1uwt6 < t2w1l9 && t2h1uwt6 < t2h1u9 && t2h1uwt6 < t2h1d9 && t2h1uwt6 < t2w1rwt9 && t2h1uwt6 < t2w1lwt9 && t2h1uwt6 < t2h1uwt9 && t2h1uwt6 < t2h1dwt9
  && t2h1uwt6 < t2w1r10 && t2h1uwt6 < t2w1l10 && t2h1uwt6 < t2h1u10 && t2h1uwt6 < t2h1d10 && t2h1uwt6 < t2w1rwt10 && t2h1uwt6 < t2w1lwt10 && t2h1uwt6 < t2h1uwt10 && t2h1uwt6 < t2h1dwt10)
{
	    if (myuOW6 == 0) i = 276;
    else{
	    if (myuOW6 == -1) i = 279;
    else{
	    if (louthu6 !=0 && linhu6!=0) i=268;
    else{
	    if ((louthu6!=0 && linhu6==0) || (louthu6==0 && linhu6!=0)) i = 269;
    else{
	    if (louthu6 == 0 && linhu6 == 0) i =270;
}}}}}


/* neutron interacts with the elliptic down OUTER wall - comments are analog to inner elliptic right wall*/

  if (t2h1dwt6 > 0 && t2h1dwt6 < t1 
  && t2h1dwt6 < t2w1r && t2h1dwt6 < t2w1l && t2h1dwt6 < t2h1u && t2h1dwt6 < t2h1d && t2h1dwt6 < t2w1rwt && t2h1dwt6 < t2w1lwt && t2h1dwt6 < t2h1uwt && t2h1dwt6 < t2h1dwt 
  && t2h1dwt6 < t2w1r1 && t2h1dwt6 < t2w1l1 && t2h1dwt6 < t2h1u1 && t2h1dwt6 < t2h1d1 && t2h1dwt6 < t2w1rwt1 && t2h1dwt6 < t2w1lwt1 && t2h1dwt6 < t2h1uwt1 && t2h1dwt6 < t2h1dwt1
  && t2h1dwt6 < t2w1r2 && t2h1dwt6 < t2w1l2 && t2h1dwt6 < t2h1u2 && t2h1dwt6 < t2h1d2 && t2h1dwt6 < t2w1rwt2 && t2h1dwt6 < t2w1lwt2 && t2h1dwt6 < t2h1uwt2 && t2h1dwt6 < t2h1dwt2 
  && t2h1dwt6 < t2w1r3 && t2h1dwt6 < t2w1l3 && t2h1dwt6 < t2h1u3 && t2h1dwt6 < t2h1d3 && t2h1dwt6 < t2w1rwt3 && t2h1dwt6 < t2w1lwt3 && t2h1dwt6 < t2h1uwt3 && t2h1dwt6 < t2h1dwt3
  && t2h1dwt6 < t2w1r4 && t2h1dwt6 < t2w1l4 && t2h1dwt6 < t2h1u4 && t2h1dwt6 < t2h1d4 && t2h1dwt6 < t2w1rwt4 && t2h1dwt6 < t2w1lwt4 && t2h1dwt6 < t2h1uwt4 && t2h1dwt6 < t2h1dwt4
  && t2h1dwt6 < t2w1r5 && t2h1dwt6 < t2w1l5 && t2h1dwt6 < t2h1u5 && t2h1dwt6 < t2h1d5 && t2h1dwt6 < t2w1rwt5 && t2h1dwt6 < t2w1lwt5 && t2h1dwt6 < t2h1uwt5 && t2h1dwt6 < t2h1dwt5
  && t2h1dwt6 < t2w1r6 && t2h1dwt6 < t2w1l6 && t2h1dwt6 < t2h1u6 && t2h1dwt6 < t2h1d6 && t2h1dwt6 < t2w1rwt6 && t2h1dwt6 < t2w1lwt6 && t2h1dwt6 < t2h1uwt6 
  && t2h1dwt6 < t2w1r7 && t2h1dwt6 < t2w1l7 && t2h1dwt6 < t2h1u7 && t2h1dwt6 < t2h1d7 && t2h1dwt6 < t2w1rwt7 && t2h1dwt6 < t2w1lwt7 && t2h1dwt6 < t2h1uwt7 && t2h1dwt6 < t2h1dwt7 
  && t2h1dwt6 < t2w1r8 && t2h1dwt6 < t2w1l8 && t2h1dwt6 < t2h1u8 && t2h1dwt6 < t2h1d8 && t2h1dwt6 < t2w1rwt8 && t2h1dwt6 < t2w1lwt8 && t2h1dwt6 < t2h1uwt8 && t2h1dwt6 < t2h1dwt8
  && t2h1dwt6 < t2w1r9 && t2h1dwt6 < t2w1l9 && t2h1dwt6 < t2h1u9 && t2h1dwt6 < t2h1d9 && t2h1dwt6 < t2w1rwt9 && t2h1dwt6 < t2w1lwt9 && t2h1dwt6 < t2h1uwt9 && t2h1dwt6 < t2h1dwt9 
  && t2h1dwt6 < t2w1r10 && t2h1dwt6 < t2w1l10 && t2h1dwt6 < t2h1u10 && t2h1dwt6 < t2h1d10 && t2h1dwt6 < t2w1rwt10 && t2h1dwt6 < t2w1lwt10 && t2h1dwt6 < t2h1uwt10 && t2h1dwt6 < t2h1dwt10)
{
	    if ( mydOW6 == 0 ) i=277;
    else{
	    if ( mydOW6 == -1) i=280;
    else{
	    if (louthd6 !=0 && linhd6!=0)  i=271;
    else{
	    if ((louthd6 !=0 && linhd6==0) || (louthd6 ==0 && linhd6!=0)) i=272;
    else{
	    if (louthd6 == 0 && linhd6 == 0) i =273;
}}}}}


 /* SEVENTH SHELL */

  if (t2w1r7 > 0 && t2w1r7 < t1 
     && t2w1r7 < t2w1r && t2w1r7 < t2w1l && t2w1r7 < t2h1u && t2w1r7 < t2h1d && t2w1r7 < t2w1rwt && t2w1r7 < t2w1lwt && t2w1r7 < t2h1uwt && t2w1r7 < t2h1dwt
     && t2w1r7 < t2w1r1 && t2w1r7 < t2w1l1 && t2w1r7 < t2h1u1 && t2w1r7 < t2h1d1 && t2w1r7 < t2w1rwt1 && t2w1r7 < t2w1lwt1 && t2w1r7 < t2h1uwt1 && t2w1r7 < t2h1dwt1
     && t2w1r7 < t2w1r2 && t2w1r7 < t2w1l2 && t2w1r7 < t2h1u2 && t2w1r7 < t2h1d2 && t2w1r7 < t2w1rwt2 && t2w1r7 < t2w1lwt2 && t2w1r7 < t2h1uwt2 && t2w1r7 < t2h1dwt2 
     && t2w1r7 < t2w1r3 && t2w1r7 < t2w1l3 && t2w1r7 < t2h1u3 && t2w1r7 < t2h1d3 && t2w1r7 < t2w1rwt3 && t2w1r7 < t2w1lwt3 && t2w1r7 < t2h1uwt3 && t2w1r7 < t2h1dwt3
     && t2w1r7 < t2w1r4 && t2w1r7 < t2w1l4 && t2w1r7 < t2h1u4 && t2w1r7 < t2h1d4 && t2w1r7 < t2w1rwt4 && t2w1r7 < t2w1lwt4 && t2w1r7 < t2h1uwt4 && t2w1r7 < t2h1dwt4
     && t2w1r7 < t2w1r5 && t2w1r7 < t2w1l5 && t2w1r7 < t2h1u5 && t2w1r7 < t2h1d5 && t2w1r7 < t2w1rwt5 && t2w1r7 < t2w1lwt5 && t2w1r7 < t2h1uwt5 && t2w1r7 < t2h1dwt5
     && t2w1r7 < t2w1r6 && t2w1r7 < t2w1l6 && t2w1r7 < t2h1u6 && t2w1r7 < t2h1d6 && t2w1r7 < t2w1rwt6 && t2w1r7 < t2w1lwt6 && t2w1r7 < t2h1uwt6 && t2w1r7 < t2h1dwt6
     && t2w1r7 < t2w1l7 && t2w1r7 < t2h1u7 && t2w1r7 < t2h1d7 && t2w1r7 < t2w1rwt7 && t2w1r7 < t2w1lwt7 && t2w1r7 < t2h1uwt7 && t2w1r7 < t2h1dwt7
     && t2w1r7 < t2w1r8 && t2w1r7 < t2w1l8 && t2w1r7 < t2h1u8 && t2w1r7 < t2h1d8 && t2w1r7 < t2w1rwt8 && t2w1r7 < t2w1lwt8 && t2w1r7 < t2h1uwt8 && t2w1r7 < t2h1dwt8
     && t2w1r7 < t2w1r9 && t2w1r7 < t2w1l9 && t2w1r7 < t2h1u9 && t2w1r7 < t2h1d9 && t2w1r7 < t2w1rwt9 && t2w1r7 < t2w1lwt9 && t2w1r7 < t2h1uwt9 && t2w1r7 < t2h1dwt9
     && t2w1r7 < t2w1r10 && t2w1r7 < t2w1l10 && t2w1r7 < t2h1u10 && t2w1r7 < t2h1d10 && t2w1r7 < t2w1rwt10 && t2w1r7 < t2w1lwt10 && t2w1r7 < t2h1uwt10 && t2w1r7 < t2h1dwt10) 
{
	    if (mxr7 == 0) i =298;
    else{
	    if (mxr7 == -1) i= 294;
    else{
	    if (linwr7!=0 && loutwr7!=0) i= 282;
    else{
	    if ((loutwr7!=0 && linwr7==0) || (loutwr7==0 && linwr7!=0)) i = 283;
    else{
	    if (loutwr7==0 && linwr7==0) i= 284;
}}}}}


/* neutron interacts with the elliptic left INNER wall - comments are analog to inner elliptic right wall*/

  if (t2w1l7 > 0 && t2w1l7 < t1 
      && t2w1l7 < t2w1r && t2w1l7 < t2w1l && t2w1l7 < t2h1u && t2w1l7 < t2h1d && t2w1l7 < t2w1rwt && t2w1l7 < t2w1lwt && t2w1l7 < t2h1uwt && t2w1l7 < t2h1dwt
      && t2w1l7 < t2w1r1 && t2w1l7 < t2w1l1 && t2w1l7 < t2h1u1 && t2w1l7 < t2h1d1 && t2w1l7 < t2w1rwt1 && t2w1l7 < t2w1lwt1 && t2w1l7 < t2h1uwt1 && t2w1l7 < t2h1dwt1
      && t2w1l7 < t2w1r2 && t2w1l7 < t2w1l2 && t2w1l7 < t2h1u2 && t2w1l7 < t2h1d2 && t2w1l7 < t2w1rwt2 && t2w1l7 < t2w1lwt2 && t2w1l7 < t2h1uwt2 && t2w1l7 < t2h1dwt2
      && t2w1l7 < t2w1r3 && t2w1l7 < t2w1l3 && t2w1l7 < t2h1u3 && t2w1l7 < t2h1d3 && t2w1l7 < t2w1rwt3 && t2w1l7 < t2w1lwt3 && t2w1l7 < t2h1uwt3 && t2w1l7 < t2h1dwt3
      && t2w1l7 < t2w1r4 && t2w1l7 < t2w1l4 && t2w1l7 < t2h1u4 && t2w1l7 < t2h1d4 && t2w1l7 < t2w1rwt4 && t2w1l7 < t2w1lwt4 && t2w1l7 < t2h1uwt4 && t2w1l7 < t2h1dwt4
      && t2w1l7 < t2w1r5 && t2w1l7 < t2w1l5 && t2w1l7 < t2h1u5 && t2w1l7 < t2h1d5 && t2w1l7 < t2w1rwt5 && t2w1l7 < t2w1lwt5 && t2w1l7 < t2h1uwt5 && t2w1l7 < t2h1dwt5
      && t2w1l7 < t2w1r6 && t2w1l7 < t2w1l6 && t2w1l7 < t2h1u6 && t2w1l7 < t2h1d6 && t2w1l7 < t2w1rwt6 && t2w1l7 < t2w1lwt6 && t2w1l7 < t2h1uwt6 && t2w1l7 < t2h1dwt6
      && t2w1l7 < t2w1r7 && t2w1l7 < t2h1u7 && t2w1l7 < t2h1d7 && t2w1l7 < t2w1rwt7 && t2w1l7 < t2w1lwt7 && t2w1l7 < t2h1uwt7 && t2w1l7 < t2h1dwt7
      && t2w1l7 < t2w1r8 && t2w1l7 < t2w1l8 && t2w1l7 < t2h1u8 && t2w1l7 < t2h1d8 && t2w1l7 < t2w1rwt8 && t2w1l7 < t2w1lwt8 && t2w1l7 < t2h1uwt8 && t2w1l7 < t2h1dwt8
      && t2w1l7 < t2w1r9 && t2w1l7 < t2w1l9 && t2w1l7 < t2h1u9 && t2w1l7 < t2h1d9 && t2w1l7 < t2w1rwt9 && t2w1l7 < t2w1lwt9 && t2w1l7 < t2h1uwt9 && t2w1l7 < t2h1dwt9
      && t2w1l7 < t2w1r10 && t2w1l7 < t2w1l10 && t2w1l7 < t2h1u10 && t2w1l7 < t2h1d10 && t2w1l7 < t2w1rwt10 && t2w1l7 < t2w1lwt10 && t2w1l7 < t2h1uwt10 && t2w1l7 < t2h1dwt10)
{
	    if (mxl7 == 0) i = 299;
    else{
	    if (mxl7 == -1) i = 295;
    else{
	    if (linwl7!=0 && loutwl7!=0) i=285;
    else{
	    if ((loutwl7!=0 && linwl7==0) || (loutwl7==0 && linwl7!=0)) i= 286;
    else{
	    if (loutwl7==0 && linwl7==0) i=287;
}}}}}

/* neutron interacts with the elliptic top INNER wall - comments are analog to inner elliptic right wall*/

  if (t2h1u7 > 0 && t2h1u7 < t1 
  && t2h1u7 < t2w1r && t2h1u7 < t2w1l && t2h1u7 < t2h1u && t2h1u7 < t2h1d && t2h1u7 < t2w1rwt && t2h1u7 < t2w1lwt && t2h1u7 < t2h1uwt && t2h1u7 < t2h1dwt
  && t2h1u7 < t2w1r1 && t2h1u7 < t2w1l1 && t2h1u7 < t2h1u1 && t2h1u7 < t2h1d1 && t2h1u7 < t2w1rwt1 && t2h1u7 < t2w1lwt1 && t2h1u7 < t2h1uwt1 && t2h1u7 < t2h1dwt1
  && t2h1u7 < t2w1r2 && t2h1u7 < t2w1l2 && t2h1u7 < t2h1u2 && t2h1u7 < t2h1d2 && t2h1u7 < t2w1rwt2 && t2h1u7 < t2w1lwt2 && t2h1u7 < t2h1uwt2 && t2h1u7 < t2h1dwt2
  && t2h1u7 < t2w1r3 && t2h1u7 < t2w1l3 && t2h1u7 < t2h1u3 && t2h1u7 < t2h1d3 && t2h1u7 < t2w1rwt3 && t2h1u7 < t2w1lwt3 && t2h1u7 < t2h1uwt3 && t2h1u7 < t2h1dwt3
  && t2h1u7 < t2w1r4 && t2h1u7 < t2w1l4 && t2h1u7 < t2h1u4 && t2h1u7 < t2h1d4 && t2h1u7 < t2w1rwt4 && t2h1u7 < t2w1lwt4 && t2h1u7 < t2h1uwt4 && t2h1u7 < t2h1dwt4
  && t2h1u7 < t2w1r5 && t2h1u7 < t2w1l5 && t2h1u7 < t2h1u5 && t2h1u7 < t2h1d5 && t2h1u7 < t2w1rwt5 && t2h1u7 < t2w1lwt5 && t2h1u7 < t2h1uwt5 && t2h1u7 < t2h1dwt5
  && t2h1u7 < t2w1r6 && t2h1u7 < t2w1l6 && t2h1u7 < t2h1u6 && t2h1u7 < t2h1d6 && t2h1u7 < t2w1rwt6 && t2h1u7 < t2w1lwt6 && t2h1u7 < t2h1uwt6 && t2h1u7 < t2h1dwt6
  && t2h1u7 < t2w1r7 && t2h1u7 < t2w1l7 && t2h1u7 < t2h1d7 && t2h1u7 < t2w1rwt7 && t2h1u7 < t2w1lwt7 && t2h1u7 < t2h1uwt7 && t2h1u7 < t2h1dwt7
  && t2h1u7 < t2w1r8 && t2h1u7 < t2w1l8 && t2h1u7 < t2h1u8 && t2h1u7 < t2h1d8 && t2h1u7 < t2w1rwt8 && t2h1u7 < t2w1lwt8 && t2h1u7 < t2h1uwt8 && t2h1u7 < t2h1dwt8
  && t2h1u7 < t2w1r9 && t2h1u7 < t2w1l9 && t2h1u7 < t2h1u9 && t2h1u7 < t2h1d9 && t2h1u7 < t2w1rwt9 && t2h1u7 < t2w1lwt9 && t2h1u7 < t2h1uwt9 && t2h1u7 < t2h1dwt9
  && t2h1u7 < t2w1r10 && t2h1u7 < t2w1l10 && t2h1u7 < t2h1u10 && t2h1u7 < t2h1d10 && t2h1u7 < t2w1rwt10 && t2h1u7 < t2w1lwt10 && t2h1u7 < t2h1uwt10 && t2h1u7 < t2h1dwt10)
{
	    if (myu7 == 0) i = 300;
    else{
	    if (myu7 == -1) i = 296;
    else{
	    if (louthu7 !=0 && linhu7!=0) i=288;
    else{
	    if ((louthu7!=0 && linhu7==0) || (louthu7==0 && linhu7!=0)) i = 289;
    else{
	    if (louthu7 == 0 && linhu7 == 0) i =290;
}}}}}

/* neutron interacts with the elliptic down INNER wall - comments are analog to inner elliptic right wall*/

  if (t2h1d7 > 0 && t2h1d7 < t1 
  && t2h1d7 < t2w1r && t2h1d7 < t2w1l && t2h1d7 < t2h1u && t2h1d7 < t2h1d && t2h1d7 < t2w1rwt && t2h1d7 < t2w1lwt && t2h1d7 < t2h1uwt && t2h1d7 < t2h1dwt
  && t2h1d7 < t2w1r1 && t2h1d7 < t2w1l1 && t2h1d7 < t2h1u1 && t2h1d7 < t2h1d1 && t2h1d7 < t2w1rwt1 && t2h1d7 < t2w1lwt1 && t2h1d7 < t2h1uwt1 && t2h1d7 < t2h1dwt1
  && t2h1d7 < t2w1r2 && t2h1d7 < t2w1l2 && t2h1d7 < t2h1u2 && t2h1d7 < t2h1d2 && t2h1d7 < t2w1rwt2 && t2h1d7 < t2w1lwt2 && t2h1d7 < t2h1uwt2 && t2h1d7 < t2h1dwt2
  && t2h1d7 < t2w1r3 && t2h1d7 < t2w1l3 && t2h1d7 < t2h1u3 && t2h1d7 < t2h1d3 && t2h1d7 < t2w1rwt3 && t2h1d7 < t2w1lwt3 && t2h1d7 < t2h1uwt3 && t2h1d7 < t2h1dwt3
  && t2h1d7 < t2w1r4 && t2h1d7 < t2w1l4 && t2h1d7 < t2h1u4 && t2h1d7 < t2h1d4 && t2h1d7 < t2w1rwt4 && t2h1d7 < t2w1lwt4 && t2h1d7 < t2h1uwt4 && t2h1d7 < t2h1dwt4
  && t2h1d7 < t2w1r5 && t2h1d7 < t2w1l5 && t2h1d7 < t2h1u5 && t2h1d7 < t2h1d5 && t2h1d7 < t2w1rwt5 && t2h1d7 < t2w1lwt5 && t2h1d7 < t2h1uwt5 && t2h1d7 < t2h1dwt5
  && t2h1d7 < t2w1r6 && t2h1d7 < t2w1l6 && t2h1d7 < t2h1u6 && t2h1d7 < t2h1d6 && t2h1d7 < t2w1rwt6 && t2h1d7 < t2w1lwt6 && t2h1d7 < t2h1uwt6 && t2h1d7 < t2h1dwt6
  && t2h1d7 < t2w1r7 && t2h1d7 < t2w1l7 && t2h1d7 < t2h1u7 && t2h1d7 < t2w1rwt7 && t2h1d7 < t2w1lwt7 && t2h1d7 < t2h1uwt7 && t2h1d7 < t2h1dwt7
  && t2h1d7 < t2w1r8 && t2h1d7 < t2w1l8 && t2h1d7 < t2h1u8 && t2h1d7 < t2h1d8 && t2h1d7 < t2w1rwt8 && t2h1d7 < t2w1lwt8 && t2h1d7 < t2h1uwt8 && t2h1d7 < t2h1dwt8
  && t2h1d7 < t2w1r9 && t2h1d7 < t2w1l9 && t2h1d7 < t2h1u9 && t2h1d7 < t2h1d9 && t2h1d7 < t2w1rwt9 && t2h1d7 < t2w1lwt9 && t2h1d7 < t2h1uwt9 && t2h1d7 < t2h1dwt9
  && t2h1d7 < t2w1r10 && t2h1d7 < t2w1l10 && t2h1d7 < t2h1u10 && t2h1d7 < t2h1d10 && t2h1d7 < t2w1rwt10 && t2h1d7 < t2w1lwt10 && t2h1d7 < t2h1uwt10 && t2h1d7 < t2h1dwt10)
{
	    if ( myd7 == 0 ) i=301;
    else{
	    if ( myd7 == -1) i=297;
    else{
	    if (louthd7 !=0 && linhd7!=0)  i=291;
    else{
	    if ((louthd7 !=0 && linhd7==0) || (louthd7 ==0 && linhd7!=0)) i=292;
    else{
	    if (louthd7 == 0 && linhd7 == 0) i =293;
}}}}}

/* EVERTHING AGAIN FOR THE OUTER WALLS */

/* neutron interacts with the elliptic right OUTER wall - comments are analog to inner elliptic right wall*/

  if (t2w1rwt7 > 0 && t2w1rwt7 < t1 
  && t2w1rwt7 < t2w1r && t2w1rwt7 < t2w1l && t2w1rwt7 < t2h1u && t2w1rwt7 < t2h1d && t2w1rwt7 <t2w1rwt && t2w1rwt7 <t2w1lwt && t2w1rwt7 < t2h1uwt && t2w1rwt7 < t2h1dwt
  && t2w1rwt7 < t2w1r1 && t2w1rwt7 < t2w1l1 && t2w1rwt7 < t2h1u1 && t2w1rwt7 < t2h1d1 && t2w1rwt7 <t2w1rwt1 && t2w1rwt7 <t2w1lwt1 && t2w1rwt7 < t2h1uwt1 && t2w1rwt7 < t2h1dwt1
  && t2w1rwt7 < t2w1r2 && t2w1rwt7 < t2w1l2 && t2w1rwt7 < t2h1u2 && t2w1rwt7 < t2h1d2 && t2w1rwt7 <t2w1rwt2 && t2w1rwt7 <t2w1lwt2 && t2w1rwt7 < t2h1uwt2 && t2w1rwt7 < t2h1dwt2
  && t2w1rwt7 < t2w1r3 && t2w1rwt7 < t2w1l3 && t2w1rwt7 < t2h1u3 && t2w1rwt7 < t2h1d3 && t2w1rwt7 <t2w1rwt3 && t2w1rwt7 <t2w1lwt3 && t2w1rwt7 < t2h1uwt3 && t2w1rwt7 < t2h1dwt3
  && t2w1rwt7 < t2w1r4 && t2w1rwt7 < t2w1l4 && t2w1rwt7 < t2h1u4 && t2w1rwt7 < t2h1d4 && t2w1rwt7 <t2w1rwt4 && t2w1rwt7 <t2w1lwt4 && t2w1rwt7 < t2h1uwt4 && t2w1rwt7 < t2h1dwt4
  && t2w1rwt7 < t2w1r5 && t2w1rwt7 < t2w1l5 && t2w1rwt7 < t2h1u5 && t2w1rwt7 < t2h1d5 && t2w1rwt7 <t2w1rwt5 && t2w1rwt7 <t2w1lwt5 && t2w1rwt7 < t2h1uwt5 && t2w1rwt7 < t2h1dwt5
  && t2w1rwt7 < t2w1r6 && t2w1rwt7 < t2w1l6 && t2w1rwt7 < t2h1u6 && t2w1rwt7 < t2h1d6 && t2w1rwt7 <t2w1rwt6 && t2w1rwt7 <t2w1lwt6 && t2w1rwt7 < t2h1uwt6 && t2w1rwt7 < t2h1dwt6
  && t2w1rwt7 < t2w1r7 && t2w1rwt7 < t2w1l7 && t2w1rwt7 < t2h1u7 && t2w1rwt7 < t2h1d7 && t2w1rwt7 <t2w1lwt7 && t2w1rwt7 < t2h1uwt7 && t2w1rwt7 < t2h1dwt7
  && t2w1rwt7 < t2w1r8 && t2w1rwt7 < t2w1l8 && t2w1rwt7 < t2h1u8 && t2w1rwt7 < t2h1d8 && t2w1rwt7 <t2w1rwt8 && t2w1rwt7 <t2w1lwt8 && t2w1rwt7 < t2h1uwt8 && t2w1rwt7 < t2h1dwt8
  && t2w1rwt7 < t2w1r9 && t2w1rwt7 < t2w1l9 && t2w1rwt7 < t2h1u9 && t2w1rwt7 < t2h1d9 && t2w1rwt7 <t2w1rwt9 && t2w1rwt7 <t2w1lwt9 && t2w1rwt7 < t2h1uwt9 && t2w1rwt7 < t2h1dwt9
  && t2w1rwt7 < t2w1r10 && t2w1rwt7 < t2w1l10 && t2w1rwt7 < t2h1u10 && t2w1rwt7 < t2h1d10 && t2w1rwt7 <t2w1rwt10 && t2w1rwt7 <t2w1lwt10 && t2w1rwt7 < t2h1uwt10 && t2w1rwt7 < t2h1dwt10)
{
	    if (mxrOW7 == 0) i =314;
    else{
	    if (mxrOW7 == -1) i= 318;
    else{
	    if (linwr7!=0 && loutwr7!=0) i= 302;
    else{
	    if ((loutwr7!=0 && linwr7==0) || (loutwr7==0 && linwr7!=0)) i = 303;
    else{
	    if (loutwr7==0 && linwr7==0) i= 304;
}}}}}

/* neutron interacts with the elliptic left OUTER wall - comments are analog to inner elliptic right wall*/

  if (t2w1lwt7 > 0 && t2w1lwt7 < t1 
  && t2w1lwt7 < t2w1r && t2w1lwt7 < t2w1l && t2w1lwt7 < t2h1u && t2w1lwt7 < t2h1d && t2w1lwt7 <t2w1rwt && t2w1lwt7 <t2w1lwt && t2w1lwt7 < t2h1uwt && t2w1lwt7 < t2h1dwt
  && t2w1lwt7 < t2w1r1 && t2w1lwt7 < t2w1l1 && t2w1lwt7 < t2h1u1 && t2w1lwt7 < t2h1d1 && t2w1lwt7 <t2w1rwt1 && t2w1lwt7 <t2w1lwt1 && t2w1lwt7 < t2h1uwt1 && t2w1lwt7 < t2h1dwt1
  && t2w1lwt7 < t2w1r2 && t2w1lwt7 < t2w1l2 && t2w1lwt7 < t2h1u2 && t2w1lwt7 < t2h1d2 && t2w1lwt7 <t2w1rwt2 && t2w1lwt7 <t2w1lwt2 && t2w1lwt7 < t2h1uwt2 && t2w1lwt7 < t2h1dwt2
  && t2w1lwt7 < t2w1r3 && t2w1lwt7 < t2w1l3 && t2w1lwt7 < t2h1u3 && t2w1lwt7 < t2h1d3 && t2w1lwt7 <t2w1rwt3 && t2w1lwt7 <t2w1lwt3 && t2w1lwt7 < t2h1uwt3 && t2w1lwt7 < t2h1dwt3
  && t2w1lwt7 < t2w1r4 && t2w1lwt7 < t2w1l4 && t2w1lwt7 < t2h1u4 && t2w1lwt7 < t2h1d4 && t2w1lwt7 <t2w1rwt4 && t2w1lwt7 <t2w1lwt4 && t2w1lwt7 < t2h1uwt4 && t2w1lwt7 < t2h1dwt4
  && t2w1lwt7 < t2w1r5 && t2w1lwt7 < t2w1l5 && t2w1lwt7 < t2h1u5 && t2w1lwt7 < t2h1d5 && t2w1lwt7 <t2w1rwt5 && t2w1lwt7 <t2w1lwt5 && t2w1lwt7 < t2h1uwt5 && t2w1lwt7 < t2h1dwt5
  && t2w1lwt7 < t2w1r6 && t2w1lwt7 < t2w1l6 && t2w1lwt7 < t2h1u6 && t2w1lwt7 < t2h1d6 && t2w1lwt7 <t2w1rwt6 && t2w1lwt7 <t2w1lwt6 && t2w1lwt7 < t2h1uwt6 && t2w1lwt7 < t2h1dwt6
  && t2w1lwt7 < t2w1r7 && t2w1lwt7 < t2w1l7 && t2w1lwt7 < t2h1u7 && t2w1lwt7 < t2h1d7 && t2w1lwt7 <t2w1rwt7 && t2w1lwt7 < t2h1uwt7 && t2w1lwt7 < t2h1dwt7
  && t2w1lwt7 < t2w1r8 && t2w1lwt7 < t2w1l8 && t2w1lwt7 < t2h1u8 && t2w1lwt7 < t2h1d8 && t2w1lwt7 <t2w1rwt8 && t2w1lwt7 <t2w1lwt8 && t2w1lwt7 < t2h1uwt8 && t2w1lwt7 < t2h1dwt8
  && t2w1lwt7 < t2w1r9 && t2w1lwt7 < t2w1l9 && t2w1lwt7 < t2h1u9 && t2w1lwt7 < t2h1d9 && t2w1lwt7 <t2w1rwt9 && t2w1lwt7 <t2w1lwt9 && t2w1lwt7 < t2h1uwt9 && t2w1lwt7 < t2h1dwt9
  && t2w1lwt7 < t2w1r10 && t2w1lwt7 < t2w1l10 && t2w1lwt7 < t2h1u10 && t2w1lwt7 < t2h1d10 && t2w1lwt7 <t2w1rwt10 && t2w1lwt7 <t2w1lwt10 && t2w1lwt7 < t2h1uwt10 && t2w1lwt7 < t2h1dwt10)
{
	    if (mxlOW7 == 0) i = 315;
    else{
	    if (mxlOW7 == -1) i = 319;
    else{
	    if (linwl7!=0 && loutwl7!=0) i=305;
    else{
	    if ((loutwl7!=0 && linwl7==0) || (loutwl7==0 && linwl7!=0)) i= 306;
    else{
	    if (loutwl7==0 && linwl7==0) i=307;
}}}}}


/* neutron interacts with the elliptic top OUTER wall - comments are analog to inner elliptic right wall*/

  if (t2h1uwt7 > 0 && t2h1uwt7 < t1 
  && t2h1uwt7 < t2w1r && t2h1uwt7 < t2w1l && t2h1uwt7 < t2h1u && t2h1uwt7 < t2h1d && t2h1uwt7 < t2w1rwt && t2h1uwt7 < t2w1lwt && t2h1uwt7 < t2h1uwt && t2h1uwt7 < t2h1dwt 
  && t2h1uwt7 < t2w1r1 && t2h1uwt7 < t2w1l1 && t2h1uwt7 < t2h1u1 && t2h1uwt7 < t2h1d1 && t2h1uwt7 < t2w1rwt1 && t2h1uwt7 < t2w1lwt1 && t2h1uwt7 < t2h1uwt1 && t2h1uwt7 < t2h1dwt1
  && t2h1uwt7 < t2w1r2 && t2h1uwt7 < t2w1l2 && t2h1uwt7 < t2h1u2 && t2h1uwt7 < t2h1d2 && t2h1uwt7 < t2w1rwt2 && t2h1uwt7 < t2w1lwt2 && t2h1uwt7 < t2h1uwt2 && t2h1uwt7 < t2h1dwt2
  && t2h1uwt7 < t2w1r3 && t2h1uwt7 < t2w1l3 && t2h1uwt7 < t2h1u3 && t2h1uwt7 < t2h1d3 && t2h1uwt7 < t2w1rwt3 && t2h1uwt7 < t2w1lwt3 && t2h1uwt7 < t2h1uwt3 && t2h1uwt7 < t2h1dwt3
  && t2h1uwt7 < t2w1r4 && t2h1uwt7 < t2w1l4 && t2h1uwt7 < t2h1u4 && t2h1uwt7 < t2h1d4 && t2h1uwt7 < t2w1rwt4 && t2h1uwt7 < t2w1lwt4 && t2h1uwt7 < t2h1uwt4 && t2h1uwt7 < t2h1dwt4
  && t2h1uwt7 < t2w1r5 && t2h1uwt7 < t2w1l5 && t2h1uwt7 < t2h1u5 && t2h1uwt7 < t2h1d5 && t2h1uwt7 < t2w1rwt5 && t2h1uwt7 < t2w1lwt5 && t2h1uwt7 < t2h1uwt5 && t2h1uwt7 < t2h1dwt5
  && t2h1uwt7 < t2w1r6 && t2h1uwt7 < t2w1l6 && t2h1uwt7 < t2h1u6 && t2h1uwt7 < t2h1d6 && t2h1uwt7 < t2w1rwt6 && t2h1uwt7 < t2w1lwt6 && t2h1uwt7 < t2h1uwt6 && t2h1uwt7 < t2h1dwt6
  && t2h1uwt7 < t2w1r7 && t2h1uwt7 < t2w1l7 && t2h1uwt7 < t2h1u7 && t2h1uwt7 < t2h1d7 && t2h1uwt7 < t2w1rwt7 && t2h1uwt7 < t2w1lwt7 && t2h1uwt7 < t2h1dwt7
  && t2h1uwt7 < t2w1r8 && t2h1uwt7 < t2w1l8 && t2h1uwt7 < t2h1u8 && t2h1uwt7 < t2h1d8 && t2h1uwt7 < t2w1rwt8 && t2h1uwt7 < t2w1lwt8 && t2h1uwt7 < t2h1uwt8 && t2h1uwt7 < t2h1dwt8
  && t2h1uwt7 < t2w1r9 && t2h1uwt7 < t2w1l9 && t2h1uwt7 < t2h1u9 && t2h1uwt7 < t2h1d9 && t2h1uwt7 < t2w1rwt9 && t2h1uwt7 < t2w1lwt9 && t2h1uwt7 < t2h1uwt9 && t2h1uwt7 < t2h1dwt9
  && t2h1uwt7 < t2w1r10 && t2h1uwt7 < t2w1l10 && t2h1uwt7 < t2h1u10 && t2h1uwt7 < t2h1d10 && t2h1uwt7 < t2w1rwt10 && t2h1uwt7 < t2w1lwt10 && t2h1uwt7 < t2h1uwt10 && t2h1uwt7 < t2h1dwt10)
{
	    if (myuOW7 == 0) i = 316;
    else{
	    if (myuOW7 == -1) i = 320;
    else{
	    if (louthu7 !=0 && linhu7!=0) i=308;
    else{
	    if ((louthu7!=0 && linhu7==0) || (louthu7==0 && linhu7!=0)) i = 309;
    else{
	    if (louthu7 == 0 && linhu7 == 0) i =310;
}}}}}

/* neutron interacts with the elliptic down OUTER wall - comments are analog to inner elliptic right wall*/

  if (t2h1dwt7 > 0 && t2h1dwt7 < t1 
  && t2h1dwt7 < t2w1r && t2h1dwt7 < t2w1l && t2h1dwt7 < t2h1u && t2h1dwt7 < t2h1d && t2h1dwt7 < t2w1rwt && t2h1dwt7 < t2w1lwt && t2h1dwt7 < t2h1uwt && t2h1dwt7 < t2h1dwt 
  && t2h1dwt7 < t2w1r1 && t2h1dwt7 < t2w1l1 && t2h1dwt7 < t2h1u1 && t2h1dwt7 < t2h1d1 && t2h1dwt7 < t2w1rwt1 && t2h1dwt7 < t2w1lwt1 && t2h1dwt7 < t2h1uwt1 && t2h1dwt7 < t2h1dwt1
  && t2h1dwt7 < t2w1r2 && t2h1dwt7 < t2w1l2 && t2h1dwt7 < t2h1u2 && t2h1dwt7 < t2h1d2 && t2h1dwt7 < t2w1rwt2 && t2h1dwt7 < t2w1lwt2 && t2h1dwt7 < t2h1uwt2 && t2h1dwt7 < t2h1dwt2 
  && t2h1dwt7 < t2w1r3 && t2h1dwt7 < t2w1l3 && t2h1dwt7 < t2h1u3 && t2h1dwt7 < t2h1d3 && t2h1dwt7 < t2w1rwt3 && t2h1dwt7 < t2w1lwt3 && t2h1dwt7 < t2h1uwt3 && t2h1dwt7 < t2h1dwt3
  && t2h1dwt7 < t2w1r4 && t2h1dwt7 < t2w1l4 && t2h1dwt7 < t2h1u4 && t2h1dwt7 < t2h1d4 && t2h1dwt7 < t2w1rwt4 && t2h1dwt7 < t2w1lwt4 && t2h1dwt7 < t2h1uwt4 && t2h1dwt7 < t2h1dwt4
  && t2h1dwt7 < t2w1r5 && t2h1dwt7 < t2w1l5 && t2h1dwt7 < t2h1u5 && t2h1dwt7 < t2h1d5 && t2h1dwt7 < t2w1rwt5 && t2h1dwt7 < t2w1lwt5 && t2h1dwt7 < t2h1uwt5 && t2h1dwt7 < t2h1dwt5
  && t2h1dwt7 < t2w1r6 && t2h1dwt7 < t2w1l6 && t2h1dwt7 < t2h1u6 && t2h1dwt7 < t2h1d6 && t2h1dwt7 < t2w1rwt6 && t2h1dwt7 < t2w1lwt6 && t2h1dwt7 < t2h1uwt6 && t2h1dwt7 < t2h1dwt6
  && t2h1dwt7 < t2w1r7 && t2h1dwt7 < t2w1l7 && t2h1dwt7 < t2h1u7 && t2h1dwt7 < t2h1d7 && t2h1dwt7 < t2w1rwt7 && t2h1dwt7 < t2w1lwt7 && t2h1dwt7 < t2h1uwt7 
  && t2h1dwt7 < t2w1r8 && t2h1dwt7 < t2w1l8 && t2h1dwt7 < t2h1u8 && t2h1dwt7 < t2h1d8 && t2h1dwt7 < t2w1rwt8 && t2h1dwt7 < t2w1lwt8 && t2h1dwt7 < t2h1uwt8 && t2h1dwt7 < t2h1dwt8
  && t2h1dwt7 < t2w1r9 && t2h1dwt7 < t2w1l9 && t2h1dwt7 < t2h1u9 && t2h1dwt7 < t2h1d9 && t2h1dwt7 < t2w1rwt9 && t2h1dwt7 < t2w1lwt9 && t2h1dwt7 < t2h1uwt9 && t2h1dwt7 < t2h1dwt9 
  && t2h1dwt7 < t2w1r10 && t2h1dwt7 < t2w1l10 && t2h1dwt7 < t2h1u10 && t2h1dwt7 < t2h1d10 && t2h1dwt7 < t2w1rwt10 && t2h1dwt7 < t2w1lwt10 && t2h1dwt7 < t2h1uwt10 && t2h1dwt7 < t2h1dwt10)
{
	    if ( mydOW7 == 0 ) i=317;
    else{
	    if ( mydOW7 == -1) i=321;
    else{
	    if (louthd7 !=0 && linhd7!=0)  i=311;
    else{
	    if ((louthd7 !=0 && linhd7==0) || (louthd7 ==0 && linhd7!=0)) i=312;
    else{
	    if (louthd7 == 0 && linhd7 == 0) i =313;
}}}}}


    /* EIGHT SHELL */

  if (t2w1r8 > 0 && t2w1r8 < t1 
     && t2w1r8 < t2w1r && t2w1r8 < t2w1l && t2w1r8 < t2h1u && t2w1r8 < t2h1d && t2w1r8 < t2w1rwt && t2w1r8 < t2w1lwt && t2w1r8 < t2h1uwt && t2w1r8 < t2h1dwt
     && t2w1r8 < t2w1r1 && t2w1r8 < t2w1l1 && t2w1r8 < t2h1u1 && t2w1r8 < t2h1d1 && t2w1r8 < t2w1rwt1 && t2w1r8 < t2w1lwt1 && t2w1r8 < t2h1uwt1 && t2w1r8 < t2h1dwt1
     && t2w1r8 < t2w1r2 && t2w1r8 < t2w1l2 && t2w1r8 < t2h1u2 && t2w1r8 < t2h1d2 && t2w1r8 < t2w1rwt2 && t2w1r8 < t2w1lwt2 && t2w1r8 < t2h1uwt2 && t2w1r8 < t2h1dwt2 
     && t2w1r8 < t2w1r3 && t2w1r8 < t2w1l3 && t2w1r8 < t2h1u3 && t2w1r8 < t2h1d3 && t2w1r8 < t2w1rwt3 && t2w1r8 < t2w1lwt3 && t2w1r8 < t2h1uwt3 && t2w1r8 < t2h1dwt3
     && t2w1r8 < t2w1r4 && t2w1r8 < t2w1l4 && t2w1r8 < t2h1u4 && t2w1r8 < t2h1d4 && t2w1r8 < t2w1rwt4 && t2w1r8 < t2w1lwt4 && t2w1r8 < t2h1uwt4 && t2w1r8 < t2h1dwt4
     && t2w1r8 < t2w1r5 && t2w1r8 < t2w1l5 && t2w1r8 < t2h1u5 && t2w1r8 < t2h1d5 && t2w1r8 < t2w1rwt5 && t2w1r8 < t2w1lwt5 && t2w1r8 < t2h1uwt5 && t2w1r8 < t2h1dwt5
     && t2w1r8 < t2w1r6 && t2w1r8 < t2w1l6 && t2w1r8 < t2h1u6 && t2w1r8 < t2h1d6 && t2w1r8 < t2w1rwt6 && t2w1r8 < t2w1lwt6 && t2w1r8 < t2h1uwt6 && t2w1r8 < t2h1dwt6
     && t2w1r8 < t2w1r7 && t2w1r8 < t2w1l7 && t2w1r8 < t2h1u7 && t2w1r8 < t2h1d7 && t2w1r8 < t2w1rwt7 && t2w1r8 < t2w1lwt7 && t2w1r8 < t2h1uwt7 && t2w1r8 < t2h1dwt7
     && t2w1r8 < t2w1l8 && t2w1r8 < t2h1u8 && t2w1r8 < t2h1d8 && t2w1r8 < t2w1rwt8 && t2w1r8 < t2w1lwt8 && t2w1r8 < t2h1uwt8 && t2w1r8 < t2h1dwt8
     && t2w1r8 < t2w1r9 && t2w1r8 < t2w1l9 && t2w1r8 < t2h1u9 && t2w1r8 < t2h1d9 && t2w1r8 < t2w1rwt9 && t2w1r8 < t2w1lwt9 && t2w1r8 < t2h1uwt9 && t2w1r8 < t2h1dwt9
     && t2w1r8 < t2w1r10 && t2w1r8 < t2w1l10 && t2w1r8 < t2h1u10 && t2w1r8 < t2h1d10 && t2w1r8 < t2w1rwt10 && t2w1r8 < t2w1lwt10 && t2w1r8 < t2h1uwt10 && t2w1r8 < t2h1dwt10)
{
	    if (mxr8 == 0) i =338;
    else{
	    if (mxr8 == -1) i= 334;
    else{
	    if (linwr8!=0 && loutwr8!=0) i= 322;
    else{
	    if ((loutwr8!=0 && linwr8==0) || (loutwr8==0 && linwr8!=0)) i = 323;
    else{
	    if (loutwr8==0 && linwr8==0) i= 324;
}}}}}

/* neutron interacts with the elliptic left INNER wall - comments are analog to inner elliptic right wall*/

  if (t2w1l8 > 0 && t2w1l8 < t1 
      && t2w1l8 < t2w1r && t2w1l8 < t2w1l && t2w1l8 < t2h1u && t2w1l8 < t2h1d && t2w1l8 < t2w1rwt && t2w1l8 < t2w1lwt && t2w1l8 < t2h1uwt && t2w1l8 < t2h1dwt
      && t2w1l8 < t2w1r1 && t2w1l8 < t2w1l1 && t2w1l8 < t2h1u1 && t2w1l8 < t2h1d1 && t2w1l8 < t2w1rwt1 && t2w1l8 < t2w1lwt1 && t2w1l8 < t2h1uwt1 && t2w1l8 < t2h1dwt1
      && t2w1l8 < t2w1r2 && t2w1l8 < t2w1l2 && t2w1l8 < t2h1u2 && t2w1l8 < t2h1d2 && t2w1l8 < t2w1rwt2 && t2w1l8 < t2w1lwt2 && t2w1l8 < t2h1uwt2 && t2w1l8 < t2h1dwt2
      && t2w1l8 < t2w1r3 && t2w1l8 < t2w1l3 && t2w1l8 < t2h1u3 && t2w1l8 < t2h1d3 && t2w1l8 < t2w1rwt3 && t2w1l8 < t2w1lwt3 && t2w1l8 < t2h1uwt3 && t2w1l8 < t2h1dwt3
      && t2w1l8 < t2w1r4 && t2w1l8 < t2w1l4 && t2w1l8 < t2h1u4 && t2w1l8 < t2h1d4 && t2w1l8 < t2w1rwt4 && t2w1l8 < t2w1lwt4 && t2w1l8 < t2h1uwt4 && t2w1l8 < t2h1dwt4
      && t2w1l8 < t2w1r5 && t2w1l8 < t2w1l5 && t2w1l8 < t2h1u5 && t2w1l8 < t2h1d5 && t2w1l8 < t2w1rwt5 && t2w1l8 < t2w1lwt5 && t2w1l8 < t2h1uwt5 && t2w1l8 < t2h1dwt5
      && t2w1l8 < t2w1r6 && t2w1l8 < t2w1l6 && t2w1l8 < t2h1u6 && t2w1l8 < t2h1d6 && t2w1l8 < t2w1rwt6 && t2w1l8 < t2w1lwt6 && t2w1l8 < t2h1uwt6 && t2w1l8 < t2h1dwt6
      && t2w1l8 < t2w1r7 && t2w1l8 < t2w1l7 && t2w1l8 < t2h1u7 && t2w1l8 < t2h1d7 && t2w1l8 < t2w1rwt7 && t2w1l8 < t2w1lwt7 && t2w1l8 < t2h1uwt7 && t2w1l8 < t2h1dwt7
      && t2w1l8 < t2w1r8 && t2w1l8 < t2h1u8 && t2w1l8 < t2h1d8 && t2w1l8 < t2w1rwt8 && t2w1l8 < t2w1lwt8 && t2w1l8 < t2h1uwt8 && t2w1l8 < t2h1dwt8
      && t2w1l8 < t2w1r9 && t2w1l8 < t2w1l9 && t2w1l8 < t2h1u9 && t2w1l8 < t2h1d9 && t2w1l8 < t2w1rwt9 && t2w1l8 < t2w1lwt9 && t2w1l8 < t2h1uwt9 && t2w1l8 < t2h1dwt9
      && t2w1l8 < t2w1r10 && t2w1l8 < t2w1l10 && t2w1l8 < t2h1u10 && t2w1l8 < t2h1d10 && t2w1l8 < t2w1rwt10 && t2w1l8 < t2w1lwt10 && t2w1l8 < t2h1uwt10 && t2w1l8 < t2h1dwt10)
{
	    if (mxl8 == 0) i = 339;
    else{
	    if (mxl8 == -1) i = 335;
    else{
	    if (linwl8!=0 && loutwl8!=0) i=325;
    else{
	    if ((loutwl8!=0 && linwl8==0) || (loutwl8==0 && linwl8!=0)) i= 326;
    else{
	    if (loutwl8==0 && linwl8==0) i=327;
}}}}}


/* neutron interacts with the elliptic top INNER wall - comments are analog to inner elliptic right wall*/

  if (t2h1u8 > 0 && t2h1u8 < t1 
  && t2h1u8 < t2w1r && t2h1u8 < t2w1l && t2h1u8 < t2h1u && t2h1u8 < t2h1d && t2h1u8 < t2w1rwt && t2h1u8 < t2w1lwt && t2h1u8 < t2h1uwt && t2h1u8 < t2h1dwt
  && t2h1u8 < t2w1r1 && t2h1u8 < t2w1l1 && t2h1u8 < t2h1u1 && t2h1u8 < t2h1d1 && t2h1u8 < t2w1rwt1 && t2h1u8 < t2w1lwt1 && t2h1u8 < t2h1uwt1 && t2h1u8 < t2h1dwt1
  && t2h1u8 < t2w1r2 && t2h1u8 < t2w1l2 && t2h1u8 < t2h1u2 && t2h1u8 < t2h1d2 && t2h1u8 < t2w1rwt2 && t2h1u8 < t2w1lwt2 && t2h1u8 < t2h1uwt2 && t2h1u8 < t2h1dwt2
  && t2h1u8 < t2w1r3 && t2h1u8 < t2w1l3 && t2h1u8 < t2h1u3 && t2h1u8 < t2h1d3 && t2h1u8 < t2w1rwt3 && t2h1u8 < t2w1lwt3 && t2h1u8 < t2h1uwt3 && t2h1u8 < t2h1dwt3
  && t2h1u8 < t2w1r4 && t2h1u8 < t2w1l4 && t2h1u8 < t2h1u4 && t2h1u8 < t2h1d4 && t2h1u8 < t2w1rwt4 && t2h1u8 < t2w1lwt4 && t2h1u8 < t2h1uwt4 && t2h1u8 < t2h1dwt4
  && t2h1u8 < t2w1r5 && t2h1u8 < t2w1l5 && t2h1u8 < t2h1u5 && t2h1u8 < t2h1d5 && t2h1u8 < t2w1rwt5 && t2h1u8 < t2w1lwt5 && t2h1u8 < t2h1uwt5 && t2h1u8 < t2h1dwt5
  && t2h1u8 < t2w1r6 && t2h1u8 < t2w1l6 && t2h1u8 < t2h1u6 && t2h1u8 < t2h1d6 && t2h1u8 < t2w1rwt6 && t2h1u8 < t2w1lwt6 && t2h1u8 < t2h1uwt6 && t2h1u8 < t2h1dwt6
  && t2h1u8 < t2w1r7 && t2h1u8 < t2w1l7 && t2h1u8 < t2h1u7 && t2h1u8 < t2h1d7 && t2h1u8 < t2w1rwt7 && t2h1u8 < t2w1lwt7 && t2h1u8 < t2h1uwt7 && t2h1u8 < t2h1dwt7
  && t2h1u8 < t2w1r8 && t2h1u8 < t2w1l8 && t2h1u8 < t2h1d8 && t2h1u8 < t2w1rwt8 && t2h1u8 < t2w1lwt8 && t2h1u8 < t2h1uwt8 && t2h1u8 < t2h1dwt8
  && t2h1u8 < t2w1r9 && t2h1u8 < t2w1l9 && t2h1u8 < t2h1u9 && t2h1u8 < t2h1d9 && t2h1u8 < t2w1rwt9 && t2h1u8 < t2w1lwt9 && t2h1u8 < t2h1uwt9 && t2h1u8 < t2h1dwt9
  && t2h1u8 < t2w1r10 && t2h1u8 < t2w1l10 && t2h1u8 < t2h1u10 && t2h1u8 < t2h1d10 && t2h1u8 < t2w1rwt10 && t2h1u8 < t2w1lwt10 && t2h1u8 < t2h1uwt10 && t2h1u8 < t2h1dwt10)
{
	    if (myu8 == 0) i = 340;
    else{
	    if (myu8 == -1) i = 336;
    else{
	    if (louthu8 !=0 && linhu8!=0) i=328;
    else{
	    if ((louthu8!=0 && linhu8==0) || (louthu8==0 && linhu8!=0)) i = 329;
    else{
	    if (louthu8 == 0 && linhu8 == 0) i =330;
}}}}}


/* neutron interacts with the elliptic down INNER wall - comments are analog to inner elliptic right wall*/

  if (t2h1d8 > 0 && t2h1d8 < t1 
  && t2h1d8 < t2w1r && t2h1d8 < t2w1l && t2h1d8 < t2h1u && t2h1d8 < t2h1d && t2h1d8 < t2w1rwt && t2h1d8 < t2w1lwt && t2h1d8 < t2h1uwt && t2h1d8 < t2h1dwt
  && t2h1d8 < t2w1r1 && t2h1d8 < t2w1l1 && t2h1d8 < t2h1u1 && t2h1d8 < t2h1d1 && t2h1d8 < t2w1rwt1 && t2h1d8 < t2w1lwt1 && t2h1d8 < t2h1uwt1 && t2h1d8 < t2h1dwt1
  && t2h1d8 < t2w1r2 && t2h1d8 < t2w1l2 && t2h1d8 < t2h1u2 && t2h1d8 < t2h1d2 && t2h1d8 < t2w1rwt2 && t2h1d8 < t2w1lwt2 && t2h1d8 < t2h1uwt2 && t2h1d8 < t2h1dwt2
  && t2h1d8 < t2w1r3 && t2h1d8 < t2w1l3 && t2h1d8 < t2h1u3 && t2h1d8 < t2h1d3 && t2h1d8 < t2w1rwt3 && t2h1d8 < t2w1lwt3 && t2h1d8 < t2h1uwt3 && t2h1d8 < t2h1dwt3
  && t2h1d8 < t2w1r4 && t2h1d8 < t2w1l4 && t2h1d8 < t2h1u4 && t2h1d8 < t2h1d4 && t2h1d8 < t2w1rwt4 && t2h1d8 < t2w1lwt4 && t2h1d8 < t2h1uwt4 && t2h1d8 < t2h1dwt4
  && t2h1d8 < t2w1r5 && t2h1d8 < t2w1l5 && t2h1d8 < t2h1u5 && t2h1d8 < t2h1d5 && t2h1d8 < t2w1rwt5 && t2h1d8 < t2w1lwt5 && t2h1d8 < t2h1uwt5 && t2h1d8 < t2h1dwt5
  && t2h1d8 < t2w1r6 && t2h1d8 < t2w1l6 && t2h1d8 < t2h1u6 && t2h1d8 < t2h1d6 && t2h1d8 < t2w1rwt6 && t2h1d8 < t2w1lwt6 && t2h1d8 < t2h1uwt6 && t2h1d8 < t2h1dwt6
  && t2h1d8 < t2w1r7 && t2h1d8 < t2w1l7 && t2h1d8 < t2h1u7 && t2h1d8 < t2h1d7 && t2h1d8 < t2w1rwt7 && t2h1d8 < t2w1lwt7 && t2h1d8 < t2h1uwt7 && t2h1d8 < t2h1dwt7
  && t2h1d8 < t2w1r8 && t2h1d8 < t2w1l8 && t2h1d8 < t2h1u8 && t2h1d8 < t2w1rwt8 && t2h1d8 < t2w1lwt8 && t2h1d8 < t2h1uwt8 && t2h1d8 < t2h1dwt8
  && t2h1d8 < t2w1r9 && t2h1d8 < t2w1l9 && t2h1d8 < t2h1u9 && t2h1d8 < t2h1d9 && t2h1d8 < t2w1rwt9 && t2h1d8 < t2w1lwt9 && t2h1d8 < t2h1uwt9 && t2h1d8 < t2h1dwt9
  && t2h1d8 < t2w1r10 && t2h1d8 < t2w1l10 && t2h1d8 < t2h1u10 && t2h1d8 < t2h1d10 && t2h1d8 < t2w1rwt10 && t2h1d8 < t2w1lwt10 && t2h1d8 < t2h1uwt10 && t2h1d8 < t2h1dwt10)
{
	    if ( myd8 == 0 ) i=341;
    else{
	    if ( myd8 == -1) i=336;
    else{
	    if (louthd8 !=0 && linhd8!=0)  i=331;
    else{
	    if ((louthd8 !=0 && linhd8==0) || (louthd8 ==0 && linhd8!=0)) i=332;
    else{
	    if (louthd8 == 0 && linhd8 == 0) i =333;
}}}}}


/* EVERTHING AGAIN FOR THE OUTER WALLS */

/* neutron interacts with the elliptic right OUTER wall - comments are analog to inner elliptic right wall*/

  if (t2w1rwt8 > 0 && t2w1rwt8 < t1 
  && t2w1rwt8 < t2w1r && t2w1rwt8 < t2w1l && t2w1rwt8 < t2h1u && t2w1rwt8 < t2h1d && t2w1rwt8 <t2w1rwt && t2w1rwt8 <t2w1lwt && t2w1rwt8 < t2h1uwt && t2w1rwt8 < t2h1dwt
  && t2w1rwt8 < t2w1r1 && t2w1rwt8 < t2w1l1 && t2w1rwt8 < t2h1u1 && t2w1rwt8 < t2h1d1 && t2w1rwt8 <t2w1rwt1 && t2w1rwt8 <t2w1lwt1 && t2w1rwt8 < t2h1uwt1 && t2w1rwt8 < t2h1dwt1
  && t2w1rwt8 < t2w1r2 && t2w1rwt8 < t2w1l2 && t2w1rwt8 < t2h1u2 && t2w1rwt8 < t2h1d2 && t2w1rwt8 <t2w1rwt2 && t2w1rwt8 <t2w1lwt2 && t2w1rwt8 < t2h1uwt2 && t2w1rwt8 < t2h1dwt2
  && t2w1rwt8 < t2w1r3 && t2w1rwt8 < t2w1l3 && t2w1rwt8 < t2h1u3 && t2w1rwt8 < t2h1d3 && t2w1rwt8 <t2w1rwt3 && t2w1rwt8 <t2w1lwt3 && t2w1rwt8 < t2h1uwt3 && t2w1rwt8 < t2h1dwt3
  && t2w1rwt8 < t2w1r4 && t2w1rwt8 < t2w1l4 && t2w1rwt8 < t2h1u4 && t2w1rwt8 < t2h1d4 && t2w1rwt8 <t2w1rwt4 && t2w1rwt8 <t2w1lwt4 && t2w1rwt8 < t2h1uwt4 && t2w1rwt8 < t2h1dwt4
  && t2w1rwt8 < t2w1r5 && t2w1rwt8 < t2w1l5 && t2w1rwt8 < t2h1u5 && t2w1rwt8 < t2h1d5 && t2w1rwt8 <t2w1rwt5 && t2w1rwt8 <t2w1lwt5 && t2w1rwt8 < t2h1uwt5 && t2w1rwt8 < t2h1dwt5
  && t2w1rwt8 < t2w1r6 && t2w1rwt8 < t2w1l6 && t2w1rwt8 < t2h1u6 && t2w1rwt8 < t2h1d6 && t2w1rwt8 <t2w1rwt6 && t2w1rwt8 <t2w1lwt6 && t2w1rwt8 < t2h1uwt6 && t2w1rwt8 < t2h1dwt6
  && t2w1rwt8 < t2w1r7 && t2w1rwt8 < t2w1l7 && t2w1rwt8 < t2h1u7 && t2w1rwt8 < t2h1d7 && t2w1rwt8 <t2w1rwt7 && t2w1rwt8 <t2w1lwt7 && t2w1rwt8 < t2h1uwt7 && t2w1rwt8 < t2h1dwt7
  && t2w1rwt8 < t2w1r8 && t2w1rwt8 < t2w1l8 && t2w1rwt8 < t2h1u8 && t2w1rwt8 < t2h1d8 && t2w1rwt8 <t2w1lwt8 && t2w1rwt8 < t2h1uwt8 && t2w1rwt8 < t2h1dwt8
  && t2w1rwt8 < t2w1r9 && t2w1rwt8 < t2w1l9 && t2w1rwt8 < t2h1u9 && t2w1rwt8 < t2h1d9 && t2w1rwt8 <t2w1rwt9 && t2w1rwt8 <t2w1lwt9 && t2w1rwt8 < t2h1uwt9 && t2w1rwt8 < t2h1dwt9
  && t2w1rwt8 < t2w1r10 && t2w1rwt8 < t2w1l10 && t2w1rwt8 < t2h1u10 && t2w1rwt8 < t2h1d10 && t2w1rwt8 <t2w1rwt10 && t2w1rwt8 <t2w1lwt10 && t2w1rwt8 < t2h1uwt10 && t2w1rwt8 < t2h1dwt10)
{
	    if (mxrOW8 == 0) i =354;
    else{
	    if (mxrOW8 == -1) i= 358;
    else{
	    if (linwr8!=0 && loutwr8!=0) i= 342;
    else{
	    if ((loutwr8!=0 && linwr8==0) || (loutwr8==0 && linwr8!=0)) i = 343;
    else{
	    if (loutwr8==0 && linwr8==0) i= 344;
}}}}}


/* neutron interacts with the elliptic left OUTER wall - comments are analog to inner elliptic right wall*/

  if (t2w1lwt8 > 0 && t2w1lwt8 < t1 
  && t2w1lwt8 < t2w1r && t2w1lwt8 < t2w1l && t2w1lwt8 < t2h1u && t2w1lwt8 < t2h1d && t2w1lwt8 <t2w1rwt && t2w1lwt8 <t2w1lwt && t2w1lwt8 < t2h1uwt && t2w1lwt8 < t2h1dwt
  && t2w1lwt8 < t2w1r1 && t2w1lwt8 < t2w1l1 && t2w1lwt8 < t2h1u1 && t2w1lwt8 < t2h1d1 && t2w1lwt8 <t2w1rwt1 && t2w1lwt8 <t2w1lwt1 && t2w1lwt8 < t2h1uwt1 && t2w1lwt8 < t2h1dwt1
  && t2w1lwt8 < t2w1r2 && t2w1lwt8 < t2w1l2 && t2w1lwt8 < t2h1u2 && t2w1lwt8 < t2h1d2 && t2w1lwt8 <t2w1rwt2 && t2w1lwt8 <t2w1lwt2 && t2w1lwt8 < t2h1uwt2 && t2w1lwt8 < t2h1dwt2
  && t2w1lwt8 < t2w1r3 && t2w1lwt8 < t2w1l3 && t2w1lwt8 < t2h1u3 && t2w1lwt8 < t2h1d3 && t2w1lwt8 <t2w1rwt3 && t2w1lwt8 <t2w1lwt3 && t2w1lwt8 < t2h1uwt3 && t2w1lwt8 < t2h1dwt3
  && t2w1lwt8 < t2w1r4 && t2w1lwt8 < t2w1l4 && t2w1lwt8 < t2h1u4 && t2w1lwt8 < t2h1d4 && t2w1lwt8 <t2w1rwt4 && t2w1lwt8 <t2w1lwt4 && t2w1lwt8 < t2h1uwt4 && t2w1lwt8 < t2h1dwt4
  && t2w1lwt8 < t2w1r5 && t2w1lwt8 < t2w1l5 && t2w1lwt8 < t2h1u5 && t2w1lwt8 < t2h1d5 && t2w1lwt8 <t2w1rwt5 && t2w1lwt8 <t2w1lwt5 && t2w1lwt8 < t2h1uwt5 && t2w1lwt8 < t2h1dwt5
  && t2w1lwt8 < t2w1r6 && t2w1lwt8 < t2w1l6 && t2w1lwt8 < t2h1u6 && t2w1lwt8 < t2h1d6 && t2w1lwt8 <t2w1rwt6 && t2w1lwt8 <t2w1lwt6 && t2w1lwt8 < t2h1uwt6 && t2w1lwt8 < t2h1dwt6
  && t2w1lwt8 < t2w1r7 && t2w1lwt8 < t2w1l7 && t2w1lwt8 < t2h1u7 && t2w1lwt8 < t2h1d7 && t2w1lwt8 <t2w1rwt7 && t2w1lwt8 <t2w1lwt7 && t2w1lwt8 < t2h1uwt7 && t2w1lwt8 < t2h1dwt7
  && t2w1lwt8 < t2w1r8 && t2w1lwt8 < t2w1l8 && t2w1lwt8 < t2h1u8 && t2w1lwt8 < t2h1d8 && t2w1lwt8 <t2w1rwt8 && t2w1lwt8 < t2h1uwt8 && t2w1lwt8 < t2h1dwt8
  && t2w1lwt8 < t2w1r9 && t2w1lwt8 < t2w1l9 && t2w1lwt8 < t2h1u9 && t2w1lwt8 < t2h1d9 && t2w1lwt8 <t2w1rwt9 && t2w1lwt8 <t2w1lwt9 && t2w1lwt8 < t2h1uwt9 && t2w1lwt8 < t2h1dwt9
  && t2w1lwt8 < t2w1r10 && t2w1lwt8 < t2w1l10 && t2w1lwt8 < t2h1u10 && t2w1lwt8 < t2h1d10 && t2w1lwt8 <t2w1rwt10 && t2w1lwt8 <t2w1lwt10 && t2w1lwt8 < t2h1uwt10 && t2w1lwt8 < t2h1dwt10)
{
	    if (mxlOW8 == 0) i = 355;
    else{
	    if (mxlOW8 == -1) i = 359;
    else{
	    if (linwl8!=0 && loutwl8!=0) i=345;
    else{
	    if ((loutwl8!=0 && linwl8==0) || (loutwl8==0 && linwl8!=0)) i= 346;
    else{
	    if (loutwl8==0 && linwl8==0) i=347;
}}}}}


/* neutron interacts with the elliptic top OUTER wall - comments are analog to inner elliptic right wall*/

  if (t2h1uwt8 > 0 && t2h1uwt8 < t1 
  && t2h1uwt8 < t2w1r && t2h1uwt8 < t2w1l && t2h1uwt8 < t2h1u && t2h1uwt8 < t2h1d && t2h1uwt8 < t2w1rwt && t2h1uwt8 < t2w1lwt && t2h1uwt8 < t2h1uwt && t2h1uwt8 < t2h1dwt 
  && t2h1uwt8 < t2w1r1 && t2h1uwt8 < t2w1l1 && t2h1uwt8 < t2h1u1 && t2h1uwt8 < t2h1d1 && t2h1uwt8 < t2w1rwt1 && t2h1uwt8 < t2w1lwt1 && t2h1uwt8 < t2h1uwt1 && t2h1uwt8 < t2h1dwt1
  && t2h1uwt8 < t2w1r2 && t2h1uwt8 < t2w1l2 && t2h1uwt8 < t2h1u2 && t2h1uwt8 < t2h1d2 && t2h1uwt8 < t2w1rwt2 && t2h1uwt8 < t2w1lwt2 && t2h1uwt8 < t2h1uwt2 && t2h1uwt8 < t2h1dwt2
  && t2h1uwt8 < t2w1r3 && t2h1uwt8 < t2w1l3 && t2h1uwt8 < t2h1u3 && t2h1uwt8 < t2h1d3 && t2h1uwt8 < t2w1rwt3 && t2h1uwt8 < t2w1lwt3 && t2h1uwt8 < t2h1uwt3 && t2h1uwt8 < t2h1dwt3
  && t2h1uwt8 < t2w1r4 && t2h1uwt8 < t2w1l4 && t2h1uwt8 < t2h1u4 && t2h1uwt8 < t2h1d4 && t2h1uwt8 < t2w1rwt4 && t2h1uwt8 < t2w1lwt4 && t2h1uwt8 < t2h1uwt4 && t2h1uwt8 < t2h1dwt4
  && t2h1uwt8 < t2w1r5 && t2h1uwt8 < t2w1l5 && t2h1uwt8 < t2h1u5 && t2h1uwt8 < t2h1d5 && t2h1uwt8 < t2w1rwt5 && t2h1uwt8 < t2w1lwt5 && t2h1uwt8 < t2h1uwt5 && t2h1uwt8 < t2h1dwt5
  && t2h1uwt8 < t2w1r6 && t2h1uwt8 < t2w1l6 && t2h1uwt8 < t2h1u6 && t2h1uwt8 < t2h1d6 && t2h1uwt8 < t2w1rwt6 && t2h1uwt8 < t2w1lwt6 && t2h1uwt8 < t2h1uwt6 && t2h1uwt8 < t2h1dwt6
  && t2h1uwt8 < t2w1r7 && t2h1uwt8 < t2w1l7 && t2h1uwt8 < t2h1u7 && t2h1uwt8 < t2h1d7 && t2h1uwt8 < t2w1rwt7 && t2h1uwt8 < t2w1lwt7 && t2h1uwt8 < t2h1uwt7 && t2h1uwt8 < t2h1dwt7
  && t2h1uwt8 < t2w1r8 && t2h1uwt8 < t2w1l8 && t2h1uwt8 < t2h1u8 && t2h1uwt8 < t2h1d8 && t2h1uwt8 < t2w1rwt8 && t2h1uwt8 < t2w1lwt8 && t2h1uwt8 < t2h1dwt8
  && t2h1uwt8 < t2w1r9 && t2h1uwt8 < t2w1l9 && t2h1uwt8 < t2h1u9 && t2h1uwt8 < t2h1d9 && t2h1uwt8 < t2w1rwt9 && t2h1uwt8 < t2w1lwt9 && t2h1uwt8 < t2h1uwt9 && t2h1uwt8 < t2h1dwt9
  && t2h1uwt8 < t2w1r10 && t2h1uwt8 < t2w1l10 && t2h1uwt8 < t2h1u10 && t2h1uwt8 < t2h1d10 && t2h1uwt8 < t2w1rwt10 && t2h1uwt8 < t2w1lwt10 && t2h1uwt8 < t2h1uwt10 && t2h1uwt8 < t2h1dwt10)
{
	    if (myuOW8 == 0) i = 356;
    else{
	    if (myuOW8 == -1) i = 360;
    else{
	    if (louthu8 !=0 && linhu8!=0) i=348;
    else{
	    if ((louthu8!=0 && linhu8==0) || (louthu8==0 && linhu8!=0)) i = 349;
    else{
	    if (louthu8 == 0 && linhu8 == 0) i =350;
}}}}}


/* neutron interacts with the elliptic down OUTER wall - comments are analog to inner elliptic right wall*/

  if (t2h1dwt8 > 0 && t2h1dwt8 < t1 
  && t2h1dwt8 < t2w1r && t2h1dwt8 < t2w1l && t2h1dwt8 < t2h1u && t2h1dwt8 < t2h1d && t2h1dwt8 < t2w1rwt && t2h1dwt8 < t2w1lwt && t2h1dwt8 < t2h1uwt && t2h1dwt8 < t2h1dwt 
  && t2h1dwt8 < t2w1r1 && t2h1dwt8 < t2w1l1 && t2h1dwt8 < t2h1u1 && t2h1dwt8 < t2h1d1 && t2h1dwt8 < t2w1rwt1 && t2h1dwt8 < t2w1lwt1 && t2h1dwt8 < t2h1uwt1 && t2h1dwt8 < t2h1dwt1
  && t2h1dwt8 < t2w1r2 && t2h1dwt8 < t2w1l2 && t2h1dwt8 < t2h1u2 && t2h1dwt8 < t2h1d2 && t2h1dwt8 < t2w1rwt2 && t2h1dwt8 < t2w1lwt2 && t2h1dwt8 < t2h1uwt2 && t2h1dwt8 < t2h1dwt2 
  && t2h1dwt8 < t2w1r3 && t2h1dwt8 < t2w1l3 && t2h1dwt8 < t2h1u3 && t2h1dwt8 < t2h1d3 && t2h1dwt8 < t2w1rwt3 && t2h1dwt8 < t2w1lwt3 && t2h1dwt8 < t2h1uwt3 && t2h1dwt8 < t2h1dwt3
  && t2h1dwt8 < t2w1r4 && t2h1dwt8 < t2w1l4 && t2h1dwt8 < t2h1u4 && t2h1dwt8 < t2h1d4 && t2h1dwt8 < t2w1rwt4 && t2h1dwt8 < t2w1lwt4 && t2h1dwt8 < t2h1uwt4 && t2h1dwt8 < t2h1dwt4
  && t2h1dwt8 < t2w1r5 && t2h1dwt8 < t2w1l5 && t2h1dwt8 < t2h1u5 && t2h1dwt8 < t2h1d5 && t2h1dwt8 < t2w1rwt5 && t2h1dwt8 < t2w1lwt5 && t2h1dwt8 < t2h1uwt5 && t2h1dwt8 < t2h1dwt5
  && t2h1dwt8 < t2w1r6 && t2h1dwt8 < t2w1l6 && t2h1dwt8 < t2h1u6 && t2h1dwt8 < t2h1d6 && t2h1dwt8 < t2w1rwt6 && t2h1dwt8 < t2w1lwt6 && t2h1dwt8 < t2h1uwt6 && t2h1dwt8 < t2h1dwt6
  && t2h1dwt8 < t2w1r7 && t2h1dwt8 < t2w1l7 && t2h1dwt8 < t2h1u7 && t2h1dwt8 < t2h1d7 && t2h1dwt8 < t2w1rwt7 && t2h1dwt8 < t2w1lwt7 && t2h1dwt8 < t2h1uwt7 && t2h1dwt8 < t2h1dwt7 
  && t2h1dwt8 < t2w1r8 && t2h1dwt8 < t2w1l8 && t2h1dwt8 < t2h1u8 && t2h1dwt8 < t2h1d8 && t2h1dwt8 < t2w1rwt8 && t2h1dwt8 < t2w1lwt8 && t2h1dwt8 < t2h1uwt8 
  && t2h1dwt8 < t2w1r9 && t2h1dwt8 < t2w1l9 && t2h1dwt8 < t2h1u9 && t2h1dwt8 < t2h1d9 && t2h1dwt8 < t2w1rwt9 && t2h1dwt8 < t2w1lwt9 && t2h1dwt8 < t2h1uwt9 && t2h1dwt8 < t2h1dwt9 
  && t2h1dwt8 < t2w1r10 && t2h1dwt8 < t2w1l10 && t2h1dwt8 < t2h1u10 && t2h1dwt8 < t2h1d10 && t2h1dwt8 < t2w1rwt10 && t2h1dwt8 < t2w1lwt10 && t2h1dwt8 < t2h1uwt10 && t2h1dwt8 < t2h1dwt10)
{
	    if ( mydOW8 == 0 ) i=357;
    else{
	    if ( mydOW8 == -1) i=361;
    else{
	    if (louthd8 !=0 && linhd8!=0)  i=351;
    else{
	    if ((louthd8 !=0 && linhd8==0) || (louthd8 ==0 && linhd8!=0)) i=352;
    else{
	    if (louthd8 == 0 && linhd8 == 0) i =353;
}}}}}

    /* NINETH SHELL  */

  if (t2w1r9 > 0 && t2w1r9 < t1 
     && t2w1r9 < t2w1r && t2w1r9 < t2w1l && t2w1r9 < t2h1u && t2w1r9 < t2h1d && t2w1r9 < t2w1rwt && t2w1r9 < t2w1lwt && t2w1r9 < t2h1uwt && t2w1r9 < t2h1dwt
     && t2w1r9 < t2w1r1 && t2w1r9 < t2w1l1 && t2w1r9 < t2h1u1 && t2w1r9 < t2h1d1 && t2w1r9 < t2w1rwt1 && t2w1r9 < t2w1lwt1 && t2w1r9 < t2h1uwt1 && t2w1r9 < t2h1dwt1
     && t2w1r9 < t2w1r2 && t2w1r9 < t2w1l2 && t2w1r9 < t2h1u2 && t2w1r9 < t2h1d2 && t2w1r9 < t2w1rwt2 && t2w1r9 < t2w1lwt2 && t2w1r9 < t2h1uwt2 && t2w1r9 < t2h1dwt2 
     && t2w1r9 < t2w1r3 && t2w1r9 < t2w1l3 && t2w1r9 < t2h1u3 && t2w1r9 < t2h1d3 && t2w1r9 < t2w1rwt3 && t2w1r9 < t2w1lwt3 && t2w1r9 < t2h1uwt3 && t2w1r9 < t2h1dwt3
     && t2w1r9 < t2w1r4 && t2w1r9 < t2w1l4 && t2w1r9 < t2h1u4 && t2w1r9 < t2h1d4 && t2w1r9 < t2w1rwt4 && t2w1r9 < t2w1lwt4 && t2w1r9 < t2h1uwt4 && t2w1r9 < t2h1dwt4
     && t2w1r9 < t2w1r5 && t2w1r9 < t2w1l5 && t2w1r9 < t2h1u5 && t2w1r9 < t2h1d5 && t2w1r9 < t2w1rwt5 && t2w1r9 < t2w1lwt5 && t2w1r9 < t2h1uwt5 && t2w1r9 < t2h1dwt5
     && t2w1r9 < t2w1r6 && t2w1r9 < t2w1l6 && t2w1r9 < t2h1u6 && t2w1r9 < t2h1d6 && t2w1r9 < t2w1rwt6 && t2w1r9 < t2w1lwt6 && t2w1r9 < t2h1uwt6 && t2w1r9 < t2h1dwt6
     && t2w1r9 < t2w1r7 && t2w1r9 < t2w1l7 && t2w1r9 < t2h1u7 && t2w1r9 < t2h1d7 && t2w1r9 < t2w1rwt7 && t2w1r9 < t2w1lwt7 && t2w1r9 < t2h1uwt7 && t2w1r9 < t2h1dwt7
     && t2w1r9 < t2w1r8 && t2w1r9 < t2w1l8 && t2w1r9 < t2h1u8 && t2w1r9 < t2h1d8 && t2w1r9 < t2w1rwt8 && t2w1r9 < t2w1lwt8 && t2w1r9 < t2h1uwt8 && t2w1r9 < t2h1dwt8
     && t2w1r9 < t2w1l9 && t2w1r9 < t2h1u9 && t2w1r9 < t2h1d9 && t2w1r9 < t2w1rwt9 && t2w1r9 < t2w1lwt9 && t2w1r9 < t2h1uwt9 && t2w1r9 < t2h1dwt9
     && t2w1r9 < t2w1r10 && t2w1r9 < t2w1l10 && t2w1r9 < t2h1u10 && t2w1r9 < t2h1d10 && t2w1r9 < t2w1rwt10 && t2w1r9 < t2w1lwt10 && t2w1r9 < t2h1uwt10 && t2w1r9 < t2h1dwt10)
{
	    if (mxr9 == 0) i =378;
    else{
	    if (mxr9 == -1) i= 374;
    else{
	    if (linwr9!=0 && loutwr9!=0) i= 362;
    else{
	    if ((loutwr9!=0 && linwr9==0) || (loutwr9==0 && linwr9!=0)) i = 363;
    else{
	    if (loutwr9==0 && linwr9==0) i= 364;
}}}}}


/* neutron interacts with the elliptic left INNER wall - comments are analog to inner elliptic right wall*/

  if (t2w1l9 > 0 && t2w1l9 < t1 
      && t2w1l9 < t2w1r && t2w1l9 < t2w1l && t2w1l9 < t2h1u && t2w1l9 < t2h1d && t2w1l9 < t2w1rwt && t2w1l9 < t2w1lwt && t2w1l9 < t2h1uwt && t2w1l9 < t2h1dwt
      && t2w1l9 < t2w1r1 && t2w1l9 < t2w1l1 && t2w1l9 < t2h1u1 && t2w1l9 < t2h1d1 && t2w1l9 < t2w1rwt1 && t2w1l9 < t2w1lwt1 && t2w1l9 < t2h1uwt1 && t2w1l9 < t2h1dwt1
      && t2w1l9 < t2w1r2 && t2w1l9 < t2w1l2 && t2w1l9 < t2h1u2 && t2w1l9 < t2h1d2 && t2w1l9 < t2w1rwt2 && t2w1l9 < t2w1lwt2 && t2w1l9 < t2h1uwt2 && t2w1l9 < t2h1dwt2
      && t2w1l9 < t2w1r3 && t2w1l9 < t2w1l3 && t2w1l9 < t2h1u3 && t2w1l9 < t2h1d3 && t2w1l9 < t2w1rwt3 && t2w1l9 < t2w1lwt3 && t2w1l9 < t2h1uwt3 && t2w1l9 < t2h1dwt3
      && t2w1l9 < t2w1r4 && t2w1l9 < t2w1l4 && t2w1l9 < t2h1u4 && t2w1l9 < t2h1d4 && t2w1l9 < t2w1rwt4 && t2w1l9 < t2w1lwt4 && t2w1l9 < t2h1uwt4 && t2w1l9 < t2h1dwt4
      && t2w1l9 < t2w1r5 && t2w1l9 < t2w1l5 && t2w1l9 < t2h1u5 && t2w1l9 < t2h1d5 && t2w1l9 < t2w1rwt5 && t2w1l9 < t2w1lwt5 && t2w1l9 < t2h1uwt5 && t2w1l9 < t2h1dwt5
      && t2w1l9 < t2w1r6 && t2w1l9 < t2w1l6 && t2w1l9 < t2h1u6 && t2w1l9 < t2h1d6 && t2w1l9 < t2w1rwt6 && t2w1l9 < t2w1lwt6 && t2w1l9 < t2h1uwt6 && t2w1l9 < t2h1dwt6
      && t2w1l9 < t2w1r7 && t2w1l9 < t2w1l7 && t2w1l9 < t2h1u7 && t2w1l9 < t2h1d7 && t2w1l9 < t2w1rwt7 && t2w1l9 < t2w1lwt7 && t2w1l9 < t2h1uwt7 && t2w1l9 < t2h1dwt7
      && t2w1l9 < t2w1r8 && t2w1l9 < t2w1l8 && t2w1l9 < t2h1u8 && t2w1l9 < t2h1d8 && t2w1l9 < t2w1rwt8 && t2w1l9 < t2w1lwt8 && t2w1l9 < t2h1uwt8 && t2w1l9 < t2h1dwt8
      && t2w1l9 < t2w1r9 && t2w1l9 < t2h1u9 && t2w1l9 < t2h1d9 && t2w1l9 < t2w1rwt9 && t2w1l9 < t2w1lwt9 && t2w1l9 < t2h1uwt9 && t2w1l9 < t2h1dwt9
      && t2w1l9 < t2w1r10 && t2w1l9 < t2w1l10 && t2w1l9 < t2h1u10 && t2w1l9 < t2h1d10 && t2w1l9 < t2w1rwt10 && t2w1l9 < t2w1lwt10 && t2w1l9 < t2h1uwt10 && t2w1l9 < t2h1dwt10)
{
	    if (mxl9 == 0) i = 379;
    else{
	    if (mxl9 == -1) i = 375;
    else{
	    if (linwl9!=0 && loutwl9!=0) i=365;
    else{
	    if ((loutwl9!=0 && linwl9==0) || (loutwl9==0 && linwl9!=0)) i= 366;
    else{
	    if (loutwl9==0 && linwl9==0) i=367;
}}}}}

/* neutron interacts with the elliptic top INNER wall - comments are analog to inner elliptic right wall*/

  if (t2h1u9 > 0 && t2h1u9 < t1 
  && t2h1u9 < t2w1r && t2h1u9 < t2w1l && t2h1u9 < t2h1u && t2h1u9 < t2h1d && t2h1u9 < t2w1rwt && t2h1u9 < t2w1lwt && t2h1u9 < t2h1uwt && t2h1u9 < t2h1dwt
  && t2h1u9 < t2w1r1 && t2h1u9 < t2w1l1 && t2h1u9 < t2h1u1 && t2h1u9 < t2h1d1 && t2h1u9 < t2w1rwt1 && t2h1u9 < t2w1lwt1 && t2h1u9 < t2h1uwt1 && t2h1u9 < t2h1dwt1
  && t2h1u9 < t2w1r2 && t2h1u9 < t2w1l2 && t2h1u9 < t2h1u2 && t2h1u9 < t2h1d2 && t2h1u9 < t2w1rwt2 && t2h1u9 < t2w1lwt2 && t2h1u9 < t2h1uwt2 && t2h1u9 < t2h1dwt2
  && t2h1u9 < t2w1r3 && t2h1u9 < t2w1l3 && t2h1u9 < t2h1u3 && t2h1u9 < t2h1d3 && t2h1u9 < t2w1rwt3 && t2h1u9 < t2w1lwt3 && t2h1u9 < t2h1uwt3 && t2h1u9 < t2h1dwt3
  && t2h1u9 < t2w1r4 && t2h1u9 < t2w1l4 && t2h1u9 < t2h1u4 && t2h1u9 < t2h1d4 && t2h1u9 < t2w1rwt4 && t2h1u9 < t2w1lwt4 && t2h1u9 < t2h1uwt4 && t2h1u9 < t2h1dwt4
  && t2h1u9 < t2w1r5 && t2h1u9 < t2w1l5 && t2h1u9 < t2h1u5 && t2h1u9 < t2h1d5 && t2h1u9 < t2w1rwt5 && t2h1u9 < t2w1lwt5 && t2h1u9 < t2h1uwt5 && t2h1u9 < t2h1dwt5
  && t2h1u9 < t2w1r6 && t2h1u9 < t2w1l6 && t2h1u9 < t2h1u6 && t2h1u9 < t2h1d6 && t2h1u9 < t2w1rwt6 && t2h1u9 < t2w1lwt6 && t2h1u9 < t2h1uwt6 && t2h1u9 < t2h1dwt6
  && t2h1u9 < t2w1r7 && t2h1u9 < t2w1l7 && t2h1u9 < t2h1u7 && t2h1u9 < t2h1d7 && t2h1u9 < t2w1rwt7 && t2h1u9 < t2w1lwt7 && t2h1u9 < t2h1uwt7 && t2h1u9 < t2h1dwt7
  && t2h1u9 < t2w1r8 && t2h1u9 < t2w1l8 && t2h1u9 < t2h1u8 && t2h1u9 < t2h1d8 && t2h1u9 < t2w1rwt8 && t2h1u9 < t2w1lwt8 && t2h1u9 < t2h1uwt8 && t2h1u9 < t2h1dwt8
  && t2h1u9 < t2w1r9 && t2h1u9 < t2w1l9 && t2h1u9 < t2h1d9 && t2h1u9 < t2w1rwt9 && t2h1u9 < t2w1lwt9 && t2h1u9 < t2h1uwt9 && t2h1u9 < t2h1dwt9
  && t2h1u9 < t2w1r10 && t2h1u9 < t2w1l10 && t2h1u9 < t2h1u10 && t2h1u9 < t2h1d10 && t2h1u9 < t2w1rwt10 && t2h1u9 < t2w1lwt10 && t2h1u9 < t2h1uwt10 && t2h1u9 < t2h1dwt10)
{
	    if (myu9 == 0) i = 380;
    else{
	    if (myu9 == -1) i = 376;
    else{
	    if (louthu9 !=0 && linhu9!=0) i=368;
    else{
	    if ((louthu9!=0 && linhu9==0) || (louthu9==0 && linhu9!=0)) i = 369;
    else{
	    if (louthu9 == 0 && linhu9 == 0) i =370;
}}}}}

/* neutron interacts with the elliptic down INNER wall - comments are analog to inner elliptic right wall*/

  if (t2h1d9 > 0 && t2h1d9 < t1 
  && t2h1d9 < t2w1r && t2h1d9 < t2w1l && t2h1d9 < t2h1u && t2h1d9 < t2h1d && t2h1d9 < t2w1rwt && t2h1d9 < t2w1lwt && t2h1d9 < t2h1uwt && t2h1d9 < t2h1dwt
  && t2h1d9 < t2w1r1 && t2h1d9 < t2w1l1 && t2h1d9 < t2h1u1 && t2h1d9 < t2h1d1 && t2h1d9 < t2w1rwt1 && t2h1d9 < t2w1lwt1 && t2h1d9 < t2h1uwt1 && t2h1d9 < t2h1dwt1
  && t2h1d9 < t2w1r2 && t2h1d9 < t2w1l2 && t2h1d9 < t2h1u2 && t2h1d9 < t2h1d2 && t2h1d9 < t2w1rwt2 && t2h1d9 < t2w1lwt2 && t2h1d9 < t2h1uwt2 && t2h1d9 < t2h1dwt2
  && t2h1d9 < t2w1r3 && t2h1d9 < t2w1l3 && t2h1d9 < t2h1u3 && t2h1d9 < t2h1d3 && t2h1d9 < t2w1rwt3 && t2h1d9 < t2w1lwt3 && t2h1d9 < t2h1uwt3 && t2h1d9 < t2h1dwt3
  && t2h1d9 < t2w1r4 && t2h1d9 < t2w1l4 && t2h1d9 < t2h1u4 && t2h1d9 < t2h1d4 && t2h1d9 < t2w1rwt4 && t2h1d9 < t2w1lwt4 && t2h1d9 < t2h1uwt4 && t2h1d9 < t2h1dwt4
  && t2h1d9 < t2w1r5 && t2h1d9 < t2w1l5 && t2h1d9 < t2h1u5 && t2h1d9 < t2h1d5 && t2h1d9 < t2w1rwt5 && t2h1d9 < t2w1lwt5 && t2h1d9 < t2h1uwt5 && t2h1d9 < t2h1dwt5
  && t2h1d9 < t2w1r6 && t2h1d9 < t2w1l6 && t2h1d9 < t2h1u6 && t2h1d9 < t2h1d6 && t2h1d9 < t2w1rwt6 && t2h1d9 < t2w1lwt6 && t2h1d9 < t2h1uwt6 && t2h1d9 < t2h1dwt6
  && t2h1d9 < t2w1r7 && t2h1d9 < t2w1l7 && t2h1d9 < t2h1u7 && t2h1d9 < t2h1d7 && t2h1d9 < t2w1rwt7 && t2h1d9 < t2w1lwt7 && t2h1d9 < t2h1uwt7 && t2h1d9 < t2h1dwt7
  && t2h1d9 < t2w1r8 && t2h1d9 < t2w1l8 && t2h1d9 < t2h1u8 && t2h1d9 < t2h1d8 && t2h1d9 < t2w1rwt8 && t2h1d9 < t2w1lwt8 && t2h1d9 < t2h1uwt8 && t2h1d9 < t2h1dwt8
  && t2h1d9 < t2w1r9 && t2h1d9 < t2w1l9 && t2h1d9 < t2h1u9 && t2h1d9 < t2w1rwt9 && t2h1d9 < t2w1lwt9 && t2h1d9 < t2h1uwt9 && t2h1d9 < t2h1dwt9
  && t2h1d9 < t2w1r10 && t2h1d9 < t2w1l10 && t2h1d9 < t2h1u10 && t2h1d9 < t2h1d10 && t2h1d9 < t2w1rwt10 && t2h1d9 < t2w1lwt10 && t2h1d9 < t2h1uwt10 && t2h1d9 < t2h1dwt10)
{
	    if ( myd9 == 0 ) i=381;
    else{
	    if ( myd9 == -1) i=377;
    else{
	    if (louthd9 !=0 && linhd9!=0)  i=371;
    else{
	    if ((louthd9 !=0 && linhd9==0) || (louthd9 ==0 && linhd9!=0)) i=372;
    else{
	    if (louthd9 == 0 && linhd9 == 0) i =373;
}}}}}


/* EVERTHING AGAIN FOR THE OUTER WALLS */

/* neutron interacts with the elliptic right OUTER wall - comments are analog to inner elliptic right wall*/

  if (t2w1rwt9 > 0 && t2w1rwt9 < t1 
  && t2w1rwt9 < t2w1r && t2w1rwt9 < t2w1l && t2w1rwt9 < t2h1u && t2w1rwt9 < t2h1d && t2w1rwt9 <t2w1rwt && t2w1rwt9 <t2w1lwt && t2w1rwt9 < t2h1uwt && t2w1rwt9 < t2h1dwt
  && t2w1rwt9 < t2w1r1 && t2w1rwt9 < t2w1l1 && t2w1rwt9 < t2h1u1 && t2w1rwt9 < t2h1d1 && t2w1rwt9 <t2w1rwt1 && t2w1rwt9 <t2w1lwt1 && t2w1rwt9 < t2h1uwt1 && t2w1rwt9 < t2h1dwt1
  && t2w1rwt9 < t2w1r2 && t2w1rwt9 < t2w1l2 && t2w1rwt9 < t2h1u2 && t2w1rwt9 < t2h1d2 && t2w1rwt9 <t2w1rwt2 && t2w1rwt9 <t2w1lwt2 && t2w1rwt9 < t2h1uwt2 && t2w1rwt9 < t2h1dwt2
  && t2w1rwt9 < t2w1r3 && t2w1rwt9 < t2w1l3 && t2w1rwt9 < t2h1u3 && t2w1rwt9 < t2h1d3 && t2w1rwt9 <t2w1rwt3 && t2w1rwt9 <t2w1lwt3 && t2w1rwt9 < t2h1uwt3 && t2w1rwt9 < t2h1dwt3
  && t2w1rwt9 < t2w1r4 && t2w1rwt9 < t2w1l4 && t2w1rwt9 < t2h1u4 && t2w1rwt9 < t2h1d4 && t2w1rwt9 <t2w1rwt4 && t2w1rwt9 <t2w1lwt4 && t2w1rwt9 < t2h1uwt4 && t2w1rwt9 < t2h1dwt4
  && t2w1rwt9 < t2w1r5 && t2w1rwt9 < t2w1l5 && t2w1rwt9 < t2h1u5 && t2w1rwt9 < t2h1d5 && t2w1rwt9 <t2w1rwt5 && t2w1rwt9 <t2w1lwt5 && t2w1rwt9 < t2h1uwt5 && t2w1rwt9 < t2h1dwt5
  && t2w1rwt9 < t2w1r6 && t2w1rwt9 < t2w1l6 && t2w1rwt9 < t2h1u6 && t2w1rwt9 < t2h1d6 && t2w1rwt9 <t2w1rwt6 && t2w1rwt9 <t2w1lwt6 && t2w1rwt9 < t2h1uwt6 && t2w1rwt9 < t2h1dwt6
  && t2w1rwt9 < t2w1r7 && t2w1rwt9 < t2w1l7 && t2w1rwt9 < t2h1u7 && t2w1rwt9 < t2h1d7 && t2w1rwt9 <t2w1rwt7 && t2w1rwt9 <t2w1lwt7 && t2w1rwt9 < t2h1uwt7 && t2w1rwt9 < t2h1dwt7
  && t2w1rwt9 < t2w1r8 && t2w1rwt9 < t2w1l8 && t2w1rwt9 < t2h1u8 && t2w1rwt9 < t2h1d8 && t2w1rwt9 <t2w1rwt8 && t2w1rwt9 <t2w1lwt8 && t2w1rwt9 < t2h1uwt8 && t2w1rwt9 < t2h1dwt8
  && t2w1rwt9 < t2w1r9 && t2w1rwt9 < t2w1l9 && t2w1rwt9 < t2h1u9 && t2w1rwt9 < t2h1d9 && t2w1rwt9 <t2w1lwt9 && t2w1rwt9 < t2h1uwt9 && t2w1rwt9 < t2h1dwt9
  && t2w1rwt9 < t2w1r10 && t2w1rwt9 < t2w1l10 && t2w1rwt9 < t2h1u10 && t2w1rwt9 < t2h1d10 && t2w1rwt9 <t2w1rwt10 && t2w1rwt9 <t2w1lwt10 && t2w1rwt9 < t2h1uwt10 && t2w1rwt9 < t2h1dwt10)
{
	    if (mxrOW9 == 0) i =394;
    else{
	    if (mxrOW9 == -1) i= 398;
    else{
	    if (linwr9!=0 && loutwr9!=0) i= 382;
    else{
	    if ((loutwr9!=0 && linwr9==0) || (loutwr9==0 && linwr9!=0)) i = 383;
    else{
	    if (loutwr9==0 && linwr9==0) i= 384;
}}}}}


/* neutron interacts with the elliptic left OUTER wall - comments are analog to inner elliptic right wall*/

  if (t2w1lwt9 > 0 && t2w1lwt9 < t1 
  && t2w1lwt9 < t2w1r && t2w1lwt9 < t2w1l && t2w1lwt9 < t2h1u && t2w1lwt9 < t2h1d && t2w1lwt9 <t2w1rwt && t2w1lwt9 <t2w1lwt && t2w1lwt9 < t2h1uwt && t2w1lwt9 < t2h1dwt
  && t2w1lwt9 < t2w1r1 && t2w1lwt9 < t2w1l1 && t2w1lwt9 < t2h1u1 && t2w1lwt9 < t2h1d1 && t2w1lwt9 <t2w1rwt1 && t2w1lwt9 <t2w1lwt1 && t2w1lwt9 < t2h1uwt1 && t2w1lwt9 < t2h1dwt1
  && t2w1lwt9 < t2w1r2 && t2w1lwt9 < t2w1l2 && t2w1lwt9 < t2h1u2 && t2w1lwt9 < t2h1d2 && t2w1lwt9 <t2w1rwt2 && t2w1lwt9 <t2w1lwt2 && t2w1lwt9 < t2h1uwt2 && t2w1lwt9 < t2h1dwt2
  && t2w1lwt9 < t2w1r3 && t2w1lwt9 < t2w1l3 && t2w1lwt9 < t2h1u3 && t2w1lwt9 < t2h1d3 && t2w1lwt9 <t2w1rwt3 && t2w1lwt9 <t2w1lwt3 && t2w1lwt9 < t2h1uwt3 && t2w1lwt9 < t2h1dwt3
  && t2w1lwt9 < t2w1r4 && t2w1lwt9 < t2w1l4 && t2w1lwt9 < t2h1u4 && t2w1lwt9 < t2h1d4 && t2w1lwt9 <t2w1rwt4 && t2w1lwt9 <t2w1lwt4 && t2w1lwt9 < t2h1uwt4 && t2w1lwt9 < t2h1dwt4
  && t2w1lwt9 < t2w1r5 && t2w1lwt9 < t2w1l5 && t2w1lwt9 < t2h1u5 && t2w1lwt9 < t2h1d5 && t2w1lwt9 <t2w1rwt5 && t2w1lwt9 <t2w1lwt5 && t2w1lwt9 < t2h1uwt5 && t2w1lwt9 < t2h1dwt5
  && t2w1lwt9 < t2w1r6 && t2w1lwt9 < t2w1l6 && t2w1lwt9 < t2h1u6 && t2w1lwt9 < t2h1d6 && t2w1lwt9 <t2w1rwt6 && t2w1lwt9 <t2w1lwt6 && t2w1lwt9 < t2h1uwt6 && t2w1lwt9 < t2h1dwt6
  && t2w1lwt9 < t2w1r7 && t2w1lwt9 < t2w1l7 && t2w1lwt9 < t2h1u7 && t2w1lwt9 < t2h1d7 && t2w1lwt9 <t2w1rwt7 && t2w1lwt9 <t2w1lwt7 && t2w1lwt9 < t2h1uwt7 && t2w1lwt9 < t2h1dwt7
  && t2w1lwt9 < t2w1r8 && t2w1lwt9 < t2w1l8 && t2w1lwt9 < t2h1u8 && t2w1lwt9 < t2h1d8 && t2w1lwt9 <t2w1rwt8 && t2w1lwt9 <t2w1lwt8 && t2w1lwt9 < t2h1uwt8 && t2w1lwt9 < t2h1dwt8
  && t2w1lwt9 < t2w1r9 && t2w1lwt9 < t2w1l9 && t2w1lwt9 < t2h1u9 && t2w1lwt9 < t2h1d9 && t2w1lwt9 <t2w1rwt9 && t2w1lwt9 < t2h1uwt9 && t2w1lwt9 < t2h1dwt9
  && t2w1lwt9 < t2w1r10 && t2w1lwt9 < t2w1l10 && t2w1lwt9 < t2h1u10 && t2w1lwt9 < t2h1d10 && t2w1lwt9 <t2w1rwt10 && t2w1lwt9 <t2w1lwt10 && t2w1lwt9 < t2h1uwt10 && t2w1lwt9 < t2h1dwt10) 
{
	    if (mxlOW9 == 0) i = 395;
    else{
	    if (mxlOW9 == -1) i = 399;
    else{
	    if (linwl9!=0 && loutwl9!=0) i=385;
    else{
	    if ((loutwl9!=0 && linwl9==0) || (loutwl9==0 && linwl9!=0)) i= 386;
    else{
	    if (loutwl9==0 && linwl9==0) i=387;
}}}}}

/* neutron interacts with the elliptic top OUTER wall - comments are analog to inner elliptic right wall*/

  if (t2h1uwt9 > 0 && t2h1uwt9 < t1 
  && t2h1uwt9 < t2w1r && t2h1uwt9 < t2w1l && t2h1uwt9 < t2h1u && t2h1uwt9 < t2h1d && t2h1uwt9 < t2w1rwt && t2h1uwt9 < t2w1lwt && t2h1uwt9 < t2h1uwt && t2h1uwt9 < t2h1dwt 
  && t2h1uwt9 < t2w1r1 && t2h1uwt9 < t2w1l1 && t2h1uwt9 < t2h1u1 && t2h1uwt9 < t2h1d1 && t2h1uwt9 < t2w1rwt1 && t2h1uwt9 < t2w1lwt1 && t2h1uwt9 < t2h1uwt1 && t2h1uwt9 < t2h1dwt1
  && t2h1uwt9 < t2w1r2 && t2h1uwt9 < t2w1l2 && t2h1uwt9 < t2h1u2 && t2h1uwt9 < t2h1d2 && t2h1uwt9 < t2w1rwt2 && t2h1uwt9 < t2w1lwt2 && t2h1uwt9 < t2h1uwt2 && t2h1uwt9 < t2h1dwt2
  && t2h1uwt9 < t2w1r3 && t2h1uwt9 < t2w1l3 && t2h1uwt9 < t2h1u3 && t2h1uwt9 < t2h1d3 && t2h1uwt9 < t2w1rwt3 && t2h1uwt9 < t2w1lwt3 && t2h1uwt9 < t2h1uwt3 && t2h1uwt9 < t2h1dwt3
  && t2h1uwt9 < t2w1r4 && t2h1uwt9 < t2w1l4 && t2h1uwt9 < t2h1u4 && t2h1uwt9 < t2h1d4 && t2h1uwt9 < t2w1rwt4 && t2h1uwt9 < t2w1lwt4 && t2h1uwt9 < t2h1uwt4 && t2h1uwt9 < t2h1dwt4
  && t2h1uwt9 < t2w1r5 && t2h1uwt9 < t2w1l5 && t2h1uwt9 < t2h1u5 && t2h1uwt9 < t2h1d5 && t2h1uwt9 < t2w1rwt5 && t2h1uwt9 < t2w1lwt5 && t2h1uwt9 < t2h1uwt5 && t2h1uwt9 < t2h1dwt5
  && t2h1uwt9 < t2w1r6 && t2h1uwt9 < t2w1l6 && t2h1uwt9 < t2h1u6 && t2h1uwt9 < t2h1d6 && t2h1uwt9 < t2w1rwt6 && t2h1uwt9 < t2w1lwt6 && t2h1uwt9 < t2h1uwt6 && t2h1uwt9 < t2h1dwt6
  && t2h1uwt9 < t2w1r7 && t2h1uwt9 < t2w1l7 && t2h1uwt9 < t2h1u7 && t2h1uwt9 < t2h1d7 && t2h1uwt9 < t2w1rwt7 && t2h1uwt9 < t2w1lwt7 && t2h1uwt9 < t2h1uwt7 && t2h1uwt9 < t2h1dwt7
  && t2h1uwt9 < t2w1r8 && t2h1uwt9 < t2w1l8 && t2h1uwt9 < t2h1u8 && t2h1uwt9 < t2h1d8 && t2h1uwt9 < t2w1rwt8 && t2h1uwt9 < t2w1lwt8 && t2h1uwt9 < t2h1uwt8 && t2h1uwt9 < t2h1dwt8
  && t2h1uwt9 < t2w1r9 && t2h1uwt9 < t2w1l9 && t2h1uwt9 < t2h1u9 && t2h1uwt9 < t2h1d9 && t2h1uwt9 < t2w1rwt9 && t2h1uwt9 < t2w1lwt9 && t2h1uwt9 < t2h1dwt9
  && t2h1uwt9 < t2w1r10 && t2h1uwt9 < t2w1l10 && t2h1uwt9 < t2h1u10 && t2h1uwt9 < t2h1d10 && t2h1uwt9 < t2w1rwt10 && t2h1uwt9 < t2w1lwt10 && t2h1uwt9 < t2h1uwt10 && t2h1uwt9 < t2h1dwt10)
{
	    if (myuOW9 == 0) i = 396;
    else{
	    if (myuOW9 == -1) i = 400;
    else{
	    if (louthu9 !=0 && linhu9!=0) i=388;
    else{
	    if ((louthu9!=0 && linhu9==0) || (louthu9==0 && linhu9!=0)) i = 389;
    else{
	    if (louthu9 == 0 && linhu9 == 0) i =390;
}}}}}


/* neutron interacts with the elliptic down OUTER wall - comments are analog to inner elliptic right wall*/

  if (t2h1dwt9 > 0 && t2h1dwt9 < t1 
  && t2h1dwt9 < t2w1r && t2h1dwt9 < t2w1l && t2h1dwt9 < t2h1u && t2h1dwt9 < t2h1d && t2h1dwt9 < t2w1rwt && t2h1dwt9 < t2w1lwt && t2h1dwt9 < t2h1uwt && t2h1dwt9 < t2h1dwt 
  && t2h1dwt9 < t2w1r1 && t2h1dwt9 < t2w1l1 && t2h1dwt9 < t2h1u1 && t2h1dwt9 < t2h1d1 && t2h1dwt9 < t2w1rwt1 && t2h1dwt9 < t2w1lwt1 && t2h1dwt9 < t2h1uwt1 && t2h1dwt9 < t2h1dwt1
  && t2h1dwt9 < t2w1r2 && t2h1dwt9 < t2w1l2 && t2h1dwt9 < t2h1u2 && t2h1dwt9 < t2h1d2 && t2h1dwt9 < t2w1rwt2 && t2h1dwt9 < t2w1lwt2 && t2h1dwt9 < t2h1uwt2 && t2h1dwt9 < t2h1dwt2 
  && t2h1dwt9 < t2w1r3 && t2h1dwt9 < t2w1l3 && t2h1dwt9 < t2h1u3 && t2h1dwt9 < t2h1d3 && t2h1dwt9 < t2w1rwt3 && t2h1dwt9 < t2w1lwt3 && t2h1dwt9 < t2h1uwt3 && t2h1dwt9 < t2h1dwt3
  && t2h1dwt9 < t2w1r4 && t2h1dwt9 < t2w1l4 && t2h1dwt9 < t2h1u4 && t2h1dwt9 < t2h1d4 && t2h1dwt9 < t2w1rwt4 && t2h1dwt9 < t2w1lwt4 && t2h1dwt9 < t2h1uwt4 && t2h1dwt9 < t2h1dwt4
  && t2h1dwt9 < t2w1r5 && t2h1dwt9 < t2w1l5 && t2h1dwt9 < t2h1u5 && t2h1dwt9 < t2h1d5 && t2h1dwt9 < t2w1rwt5 && t2h1dwt9 < t2w1lwt5 && t2h1dwt9 < t2h1uwt5 && t2h1dwt9 < t2h1dwt5
  && t2h1dwt9 < t2w1r6 && t2h1dwt9 < t2w1l6 && t2h1dwt9 < t2h1u6 && t2h1dwt9 < t2h1d6 && t2h1dwt9 < t2w1rwt6 && t2h1dwt9 < t2w1lwt6 && t2h1dwt9 < t2h1uwt6 && t2h1dwt9 < t2h1dwt6
  && t2h1dwt9 < t2w1r7 && t2h1dwt9 < t2w1l7 && t2h1dwt9 < t2h1u7 && t2h1dwt9 < t2h1d7 && t2h1dwt9 < t2w1rwt7 && t2h1dwt9 < t2w1lwt7 && t2h1dwt9 < t2h1uwt7 && t2h1dwt9 < t2h1dwt7 
  && t2h1dwt9 < t2w1r8 && t2h1dwt9 < t2w1l8 && t2h1dwt9 < t2h1u8 && t2h1dwt9 < t2h1d8 && t2h1dwt9 < t2w1rwt8 && t2h1dwt9 < t2w1lwt8 && t2h1dwt9 < t2h1uwt8 && t2h1dwt9 < t2h1dwt8
  && t2h1dwt9 < t2w1r9 && t2h1dwt9 < t2w1l9 && t2h1dwt9 < t2h1u9 && t2h1dwt9 < t2h1d9 && t2h1dwt9 < t2w1rwt9 && t2h1dwt9 < t2w1lwt9 && t2h1dwt9 < t2h1uwt9 
  && t2h1dwt9 < t2w1r10 && t2h1dwt9 < t2w1l10 && t2h1dwt9 < t2h1u10 && t2h1dwt9 < t2h1d10 && t2h1dwt9 < t2w1rwt10 && t2h1dwt9 < t2w1lwt10 && t2h1dwt9 < t2h1uwt10 && t2h1dwt9 < t2h1dwt10)
{
	    if ( mydOW9 == 0 ) i=397;
    else{
	    if ( mydOW9 == -1) i=401;
    else{
	    if (louthd9 !=0 && linhd9!=0)  i=391;
    else{
	    if ((louthd9 !=0 && linhd9==0) || (louthd9 ==0 && linhd9!=0)) i=392;
    else{
	    if (louthd9 == 0 && linhd9 == 0) i =393;
}}}}}

/* TENTH SHELL */

  if (t2w1r10 > 0 && t2w1r10 < t1 
     && t2w1r10 < t2w1r && t2w1r10 < t2w1l && t2w1r10 < t2h1u && t2w1r10 < t2h1d && t2w1r10 < t2w1rwt && t2w1r10 < t2w1lwt && t2w1r10 < t2h1uwt && t2w1r10 < t2h1dwt
     && t2w1r10 < t2w1r1 && t2w1r10 < t2w1l1 && t2w1r10 < t2h1u1 && t2w1r10 < t2h1d1 && t2w1r10 < t2w1rwt1 && t2w1r10 < t2w1lwt1 && t2w1r10 < t2h1uwt1 && t2w1r10 < t2h1dwt1
     && t2w1r10 < t2w1r2 && t2w1r10 < t2w1l2 && t2w1r10 < t2h1u2 && t2w1r10 < t2h1d2 && t2w1r10 < t2w1rwt2 && t2w1r10 < t2w1lwt2 && t2w1r10 < t2h1uwt2 && t2w1r10 < t2h1dwt2 
     && t2w1r10 < t2w1r3 && t2w1r10 < t2w1l3 && t2w1r10 < t2h1u3 && t2w1r10 < t2h1d3 && t2w1r10 < t2w1rwt3 && t2w1r10 < t2w1lwt3 && t2w1r10 < t2h1uwt3 && t2w1r10 < t2h1dwt3
     && t2w1r10 < t2w1r4 && t2w1r10 < t2w1l4 && t2w1r10 < t2h1u4 && t2w1r10 < t2h1d4 && t2w1r10 < t2w1rwt4 && t2w1r10 < t2w1lwt4 && t2w1r10 < t2h1uwt4 && t2w1r10 < t2h1dwt4
     && t2w1r10 < t2w1r5 && t2w1r10 < t2w1l5 && t2w1r10 < t2h1u5 && t2w1r10 < t2h1d5 && t2w1r10 < t2w1rwt5 && t2w1r10 < t2w1lwt5 && t2w1r10 < t2h1uwt5 && t2w1r10 < t2h1dwt5
     && t2w1r10 < t2w1r6 && t2w1r10 < t2w1l6 && t2w1r10 < t2h1u6 && t2w1r10 < t2h1d6 && t2w1r10 < t2w1rwt6 && t2w1r10 < t2w1lwt6 && t2w1r10 < t2h1uwt6 && t2w1r10 < t2h1dwt6
     && t2w1r10 < t2w1r7 && t2w1r10 < t2w1l7 && t2w1r10 < t2h1u7 && t2w1r10 < t2h1d7 && t2w1r10 < t2w1rwt7 && t2w1r10 < t2w1lwt7 && t2w1r10 < t2h1uwt7 && t2w1r10 < t2h1dwt7
     && t2w1r10 < t2w1r8 && t2w1r10 < t2w1l8 && t2w1r10 < t2h1u8 && t2w1r10 < t2h1d8 && t2w1r10 < t2w1rwt8 && t2w1r10 < t2w1lwt8 && t2w1r10 < t2h1uwt8 && t2w1r10 < t2h1dwt8
     && t2w1r10 < t2w1r9 && t2w1r10 < t2w1l9 && t2w1r10 < t2h1u9 && t2w1r10 < t2h1d9 && t2w1r10 < t2w1rwt9 && t2w1r10 < t2w1lwt9 && t2w1r10 < t2h1uwt9 && t2w1r10 < t2h1dwt9
     && t2w1r10 < t2w1l10 && t2w1r10 < t2h1u10 && t2w1r10 < t2h1d10 && t2w1r10 < t2w1rwt10 && t2w1r10 < t2w1lwt10 && t2w1r10 < t2h1uwt10 && t2w1r10 < t2h1dwt10)
{
	    if (mxr10 == 0) i =418;
    else{
	    if (mxr10 == -1) i= 414;
    else{
	    if (linwr10!=0 && loutwr10!=0) i= 402;
    else{
	    if ((loutwr10!=0 && linwr10==0) || (loutwr10==0 && linwr10!=0)) i = 403;
    else{
	    if (loutwr10==0 && linwr10==0) i= 404;
}}}}}


/* neutron interacts with the elliptic left INNER wall - comments are analog to inner elliptic right wall*/

  if (t2w1l10 > 0 && t2w1l10 < t1 
      && t2w1l10 < t2w1r && t2w1l10 < t2w1l && t2w1l10 < t2h1u && t2w1l10 < t2h1d && t2w1l10 < t2w1rwt && t2w1l10 < t2w1lwt && t2w1l10 < t2h1uwt && t2w1l10 < t2h1dwt
      && t2w1l10 < t2w1r1 && t2w1l10 < t2w1l1 && t2w1l10 < t2h1u1 && t2w1l10 < t2h1d1 && t2w1l10 < t2w1rwt1 && t2w1l10 < t2w1lwt1 && t2w1l10 < t2h1uwt1 && t2w1l10 < t2h1dwt1
      && t2w1l10 < t2w1r2 && t2w1l10 < t2w1l2 && t2w1l10 < t2h1u2 && t2w1l10 < t2h1d2 && t2w1l10 < t2w1rwt2 && t2w1l10 < t2w1lwt2 && t2w1l10 < t2h1uwt2 && t2w1l10 < t2h1dwt2
      && t2w1l10 < t2w1r3 && t2w1l10 < t2w1l3 && t2w1l10 < t2h1u3 && t2w1l10 < t2h1d3 && t2w1l10 < t2w1rwt3 && t2w1l10 < t2w1lwt3 && t2w1l10 < t2h1uwt3 && t2w1l10 < t2h1dwt3
      && t2w1l10 < t2w1r4 && t2w1l10 < t2w1l4 && t2w1l10 < t2h1u4 && t2w1l10 < t2h1d4 && t2w1l10 < t2w1rwt4 && t2w1l10 < t2w1lwt4 && t2w1l10 < t2h1uwt4 && t2w1l10 < t2h1dwt4
      && t2w1l10 < t2w1r5 && t2w1l10 < t2w1l5 && t2w1l10 < t2h1u5 && t2w1l10 < t2h1d5 && t2w1l10 < t2w1rwt5 && t2w1l10 < t2w1lwt5 && t2w1l10 < t2h1uwt5 && t2w1l10 < t2h1dwt5
      && t2w1l10 < t2w1r6 && t2w1l10 < t2w1l6 && t2w1l10 < t2h1u6 && t2w1l10 < t2h1d6 && t2w1l10 < t2w1rwt6 && t2w1l10 < t2w1lwt6 && t2w1l10 < t2h1uwt6 && t2w1l10 < t2h1dwt6
      && t2w1l10 < t2w1r7 && t2w1l10 < t2w1l7 && t2w1l10 < t2h1u7 && t2w1l10 < t2h1d7 && t2w1l10 < t2w1rwt7 && t2w1l10 < t2w1lwt7 && t2w1l10 < t2h1uwt7 && t2w1l10 < t2h1dwt7
      && t2w1l10 < t2w1r8 && t2w1l10 < t2w1l8 && t2w1l10 < t2h1u8 && t2w1l10 < t2h1d8 && t2w1l10 < t2w1rwt8 && t2w1l10 < t2w1lwt8 && t2w1l10 < t2h1uwt8 && t2w1l10 < t2h1dwt8
      && t2w1l10 < t2w1r9 && t2w1l10 < t2w1l9 && t2w1l10 < t2h1u9 && t2w1l10 < t2h1d9 && t2w1l10 < t2w1rwt9 && t2w1l10 < t2w1lwt9 && t2w1l10 < t2h1uwt9 && t2w1l10 < t2h1dwt9
      && t2w1l10 < t2w1r10 && t2w1l10 < t2h1u10 && t2w1l10 < t2h1d10 && t2w1l10 < t2w1rwt10 && t2w1l10 < t2w1lwt10 && t2w1l10 < t2h1uwt10 && t2w1l10 < t2h1dwt10)
{
	    if (mxl10 == 0) i = 419;
    else{
	    if (mxl10 == -1) i = 415;
    else{
	    if (linwl10!=0 && loutwl10!=0) i=405;
    else{
	    if ((loutwl10!=0 && linwl10==0) || (loutwl10==0 && linwl10!=0)) i= 406;
    else{
	    if (loutwl10==0 && linwl10==0) i=407;
}}}}}


/* neutron interacts with the elliptic top INNER wall - comments are analog to inner elliptic right wall*/

  if (t2h1u10 > 0 && t2h1u10 < t1 
  && t2h1u10 < t2w1r && t2h1u10 < t2w1l && t2h1u10 < t2h1u && t2h1u10 < t2h1d && t2h1u10 < t2w1rwt && t2h1u10 < t2w1lwt && t2h1u10 < t2h1uwt && t2h1u10 < t2h1dwt
  && t2h1u10 < t2w1r1 && t2h1u10 < t2w1l1 && t2h1u10 < t2h1u1 && t2h1u10 < t2h1d1 && t2h1u10 < t2w1rwt1 && t2h1u10 < t2w1lwt1 && t2h1u10 < t2h1uwt1 && t2h1u10 < t2h1dwt1
  && t2h1u10 < t2w1r2 && t2h1u10 < t2w1l2 && t2h1u10 < t2h1u2 && t2h1u10 < t2h1d2 && t2h1u10 < t2w1rwt2 && t2h1u10 < t2w1lwt2 && t2h1u10 < t2h1uwt2 && t2h1u10 < t2h1dwt2
  && t2h1u10 < t2w1r3 && t2h1u10 < t2w1l3 && t2h1u10 < t2h1u3 && t2h1u10 < t2h1d3 && t2h1u10 < t2w1rwt3 && t2h1u10 < t2w1lwt3 && t2h1u10 < t2h1uwt3 && t2h1u10 < t2h1dwt3
  && t2h1u10 < t2w1r4 && t2h1u10 < t2w1l4 && t2h1u10 < t2h1u4 && t2h1u10 < t2h1d4 && t2h1u10 < t2w1rwt4 && t2h1u10 < t2w1lwt4 && t2h1u10 < t2h1uwt4 && t2h1u10 < t2h1dwt4
  && t2h1u10 < t2w1r5 && t2h1u10 < t2w1l5 && t2h1u10 < t2h1u5 && t2h1u10 < t2h1d5 && t2h1u10 < t2w1rwt5 && t2h1u10 < t2w1lwt5 && t2h1u10 < t2h1uwt5 && t2h1u10 < t2h1dwt5
  && t2h1u10 < t2w1r6 && t2h1u10 < t2w1l6 && t2h1u10 < t2h1u6 && t2h1u10 < t2h1d6 && t2h1u10 < t2w1rwt6 && t2h1u10 < t2w1lwt6 && t2h1u10 < t2h1uwt6 && t2h1u10 < t2h1dwt6
  && t2h1u10 < t2w1r7 && t2h1u10 < t2w1l7 && t2h1u10 < t2h1u7 && t2h1u10 < t2h1d7 && t2h1u10 < t2w1rwt7 && t2h1u10 < t2w1lwt7 && t2h1u10 < t2h1uwt7 && t2h1u10 < t2h1dwt7
  && t2h1u10 < t2w1r8 && t2h1u10 < t2w1l8 && t2h1u10 < t2h1u8 && t2h1u10 < t2h1d8 && t2h1u10 < t2w1rwt8 && t2h1u10 < t2w1lwt8 && t2h1u10 < t2h1uwt8 && t2h1u10 < t2h1dwt8
  && t2h1u10 < t2w1r9 && t2h1u10 < t2w1l9 && t2h1u10 < t2h1u9 && t2h1u10 < t2h1d9 && t2h1u10 < t2w1rwt9 && t2h1u10 < t2w1lwt9 && t2h1u10 < t2h1uwt9 && t2h1u10 < t2h1dwt9
  && t2h1u10 < t2w1r10 && t2h1u10 < t2w1l10 && t2h1u10 < t2h1d10 && t2h1u10 < t2w1rwt10 && t2h1u10 < t2w1lwt10 && t2h1u10 < t2h1uwt10 && t2h1u10 < t2h1dwt10)
{
	    if (myu10 == 0) i = 420;
    else{
	    if (myu10 == -1) i = 416;
    else{
	    if (louthu10 !=0 && linhu10!=0) i=408;
    else{
	    if ((louthu10!=0 && linhu10==0) || (louthu10==0 && linhu10!=0)) i = 409;
    else{
	    if (louthu10 == 0 && linhu10 == 0) i =410;
}}}}}


/* neutron interacts with the elliptic down INNER wall - comments are analog to inner elliptic right wall*/

  if (t2h1d10 > 0 && t2h1d10 < t1 
  && t2h1d10 < t2w1r && t2h1d10 < t2w1l && t2h1d10 < t2h1u && t2h1d10 < t2h1d && t2h1d10 < t2w1rwt && t2h1d10 < t2w1lwt && t2h1d10 < t2h1uwt && t2h1d10 < t2h1dwt
  && t2h1d10 < t2w1r1 && t2h1d10 < t2w1l1 && t2h1d10 < t2h1u1 && t2h1d10 < t2h1d1 && t2h1d10 < t2w1rwt1 && t2h1d10 < t2w1lwt1 && t2h1d10 < t2h1uwt1 && t2h1d10 < t2h1dwt1
  && t2h1d10 < t2w1r2 && t2h1d10 < t2w1l2 && t2h1d10 < t2h1u2 && t2h1d10 < t2h1d2 && t2h1d10 < t2w1rwt2 && t2h1d10 < t2w1lwt2 && t2h1d10 < t2h1uwt2 && t2h1d10 < t2h1dwt2
  && t2h1d10 < t2w1r3 && t2h1d10 < t2w1l3 && t2h1d10 < t2h1u3 && t2h1d10 < t2h1d3 && t2h1d10 < t2w1rwt3 && t2h1d10 < t2w1lwt3 && t2h1d10 < t2h1uwt3 && t2h1d10 < t2h1dwt3
  && t2h1d10 < t2w1r4 && t2h1d10 < t2w1l4 && t2h1d10 < t2h1u4 && t2h1d10 < t2h1d4 && t2h1d10 < t2w1rwt4 && t2h1d10 < t2w1lwt4 && t2h1d10 < t2h1uwt4 && t2h1d10 < t2h1dwt4
  && t2h1d10 < t2w1r5 && t2h1d10 < t2w1l5 && t2h1d10 < t2h1u5 && t2h1d10 < t2h1d5 && t2h1d10 < t2w1rwt5 && t2h1d10 < t2w1lwt5 && t2h1d10 < t2h1uwt5 && t2h1d10 < t2h1dwt5
  && t2h1d10 < t2w1r6 && t2h1d10 < t2w1l6 && t2h1d10 < t2h1u6 && t2h1d10 < t2h1d6 && t2h1d10 < t2w1rwt6 && t2h1d10 < t2w1lwt6 && t2h1d10 < t2h1uwt6 && t2h1d10 < t2h1dwt6
  && t2h1d10 < t2w1r7 && t2h1d10 < t2w1l7 && t2h1d10 < t2h1u7 && t2h1d10 < t2h1d7 && t2h1d10 < t2w1rwt7 && t2h1d10 < t2w1lwt7 && t2h1d10 < t2h1uwt7 && t2h1d10 < t2h1dwt7
  && t2h1d10 < t2w1r8 && t2h1d10 < t2w1l8 && t2h1d10 < t2h1u8 && t2h1d10 < t2h1d8 && t2h1d10 < t2w1rwt8 && t2h1d10 < t2w1lwt8 && t2h1d10 < t2h1uwt8 && t2h1d10 < t2h1dwt8
  && t2h1d10 < t2w1r9 && t2h1d10 < t2w1l9 && t2h1d10 < t2h1u9 && t2h1d10 < t2h1d9 && t2h1d10 < t2w1rwt9 && t2h1d10 < t2w1lwt9 && t2h1d10 < t2h1uwt9 && t2h1d10 < t2h1dwt9
  && t2h1d10 < t2w1r10 && t2h1d10 < t2w1l10 && t2h1d10 < t2h1u10 && t2h1d10 < t2w1rwt10 && t2h1d10 < t2w1lwt10 && t2h1d10 < t2h1uwt10 && t2h1d10 < t2h1dwt10)
{
	    if ( myd10 == 0 ) i=421;
    else{
	    if ( myd10 == -1) i=417;
    else{
	    if (louthd10 !=0 && linhd10!=0)  i=411;
    else{
	    if ((louthd10 !=0 && linhd10==0) || (louthd10 ==0 && linhd10!=0)) i=412;
    else{
	    if (louthd10 == 0 && linhd10 == 0) i =413;
}}}}}


/* EVERTHING AGAIN FOR THE OUTER WALLS */

/* neutron interacts with the elliptic right OUTER wall - comments are analog to inner elliptic right wall*/

  if (t2w1rwt10 > 0 && t2w1rwt10 < t1 
  && t2w1rwt10 < t2w1r && t2w1rwt10 < t2w1l && t2w1rwt10 < t2h1u && t2w1rwt10 < t2h1d && t2w1rwt10 <t2w1rwt && t2w1rwt10 <t2w1lwt && t2w1rwt10 < t2h1uwt && t2w1rwt10 < t2h1dwt
  && t2w1rwt10 < t2w1r1 && t2w1rwt10 < t2w1l1 && t2w1rwt10 < t2h1u1 && t2w1rwt10 < t2h1d1 && t2w1rwt10 <t2w1rwt1 && t2w1rwt10 <t2w1lwt1 && t2w1rwt10 < t2h1uwt1 && t2w1rwt10 < t2h1dwt1
  && t2w1rwt10 < t2w1r2 && t2w1rwt10 < t2w1l2 && t2w1rwt10 < t2h1u2 && t2w1rwt10 < t2h1d2 && t2w1rwt10 <t2w1rwt2 && t2w1rwt10 <t2w1lwt2 && t2w1rwt10 < t2h1uwt2 && t2w1rwt10 < t2h1dwt2
  && t2w1rwt10 < t2w1r3 && t2w1rwt10 < t2w1l3 && t2w1rwt10 < t2h1u3 && t2w1rwt10 < t2h1d3 && t2w1rwt10 <t2w1rwt3 && t2w1rwt10 <t2w1lwt3 && t2w1rwt10 < t2h1uwt3 && t2w1rwt10 < t2h1dwt3
  && t2w1rwt10 < t2w1r4 && t2w1rwt10 < t2w1l4 && t2w1rwt10 < t2h1u4 && t2w1rwt10 < t2h1d4 && t2w1rwt10 <t2w1rwt4 && t2w1rwt10 <t2w1lwt4 && t2w1rwt10 < t2h1uwt4 && t2w1rwt10 < t2h1dwt4
  && t2w1rwt10 < t2w1r5 && t2w1rwt10 < t2w1l5 && t2w1rwt10 < t2h1u5 && t2w1rwt10 < t2h1d5 && t2w1rwt10 <t2w1rwt5 && t2w1rwt10 <t2w1lwt5 && t2w1rwt10 < t2h1uwt5 && t2w1rwt10 < t2h1dwt5
  && t2w1rwt10 < t2w1r6 && t2w1rwt10 < t2w1l6 && t2w1rwt10 < t2h1u6 && t2w1rwt10 < t2h1d6 && t2w1rwt10 <t2w1rwt6 && t2w1rwt10 <t2w1lwt6 && t2w1rwt10 < t2h1uwt6 && t2w1rwt10 < t2h1dwt6
  && t2w1rwt10 < t2w1r7 && t2w1rwt10 < t2w1l7 && t2w1rwt10 < t2h1u7 && t2w1rwt10 < t2h1d7 && t2w1rwt10 <t2w1rwt7 && t2w1rwt10 <t2w1lwt7 && t2w1rwt10 < t2h1uwt7 && t2w1rwt10 < t2h1dwt7
  && t2w1rwt10 < t2w1r8 && t2w1rwt10 < t2w1l8 && t2w1rwt10 < t2h1u8 && t2w1rwt10 < t2h1d8 && t2w1rwt10 <t2w1rwt8 && t2w1rwt10 <t2w1lwt8 && t2w1rwt10 < t2h1uwt8 && t2w1rwt10 < t2h1dwt8
  && t2w1rwt10 < t2w1r9 && t2w1rwt10 < t2w1l9 && t2w1rwt10 < t2h1u9 && t2w1rwt10 < t2h1d9 && t2w1rwt10 <t2w1rwt9 && t2w1rwt10 <t2w1lwt9 && t2w1rwt10 < t2h1uwt9 && t2w1rwt10 < t2h1dwt9
  && t2w1rwt10 < t2w1r10 && t2w1rwt10 < t2w1l10 && t2w1rwt10 < t2h1u10 && t2w1rwt10 < t2h1d10 && t2w1rwt10 <t2w1lwt10 && t2w1rwt10 < t2h1uwt10 && t2w1rwt10 < t2h1dwt10)
{
	    if (mxrOW10 == 0) i =434;
    else{
	    if (mxrOW10 == -1) i= 438;
    else{
	    if (linwr10!=0 && loutwr10!=0) i= 422;
    else{
	    if ((loutwr10!=0 && linwr10==0) || (loutwr10==0 && linwr10!=0)) i = 423;
    else{
	    if (loutwr10==0 && linwr10==0) i= 424;
}}}}}


/* neutron interacts with the elliptic left OUTER wall - comments are analog to inner elliptic right wall*/

  if (t2w1lwt10 > 0 && t2w1lwt10 < t1 
  && t2w1lwt10 < t2w1r && t2w1lwt10 < t2w1l && t2w1lwt10 < t2h1u && t2w1lwt10 < t2h1d && t2w1lwt10 <t2w1rwt && t2w1lwt10 <t2w1lwt && t2w1lwt10 < t2h1uwt && t2w1lwt10 < t2h1dwt
  && t2w1lwt10 < t2w1r1 && t2w1lwt10 < t2w1l1 && t2w1lwt10 < t2h1u1 && t2w1lwt10 < t2h1d1 && t2w1lwt10 <t2w1rwt1 && t2w1lwt10 <t2w1lwt1 && t2w1lwt10 < t2h1uwt1 && t2w1lwt10 < t2h1dwt1
  && t2w1lwt10 < t2w1r2 && t2w1lwt10 < t2w1l2 && t2w1lwt10 < t2h1u2 && t2w1lwt10 < t2h1d2 && t2w1lwt10 <t2w1rwt2 && t2w1lwt10 <t2w1lwt2 && t2w1lwt10 < t2h1uwt2 && t2w1lwt10 < t2h1dwt2
  && t2w1lwt10 < t2w1r3 && t2w1lwt10 < t2w1l3 && t2w1lwt10 < t2h1u3 && t2w1lwt10 < t2h1d3 && t2w1lwt10 <t2w1rwt3 && t2w1lwt10 <t2w1lwt3 && t2w1lwt10 < t2h1uwt3 && t2w1lwt10 < t2h1dwt3
  && t2w1lwt10 < t2w1r4 && t2w1lwt10 < t2w1l4 && t2w1lwt10 < t2h1u4 && t2w1lwt10 < t2h1d4 && t2w1lwt10 <t2w1rwt4 && t2w1lwt10 <t2w1lwt4 && t2w1lwt10 < t2h1uwt4 && t2w1lwt10 < t2h1dwt4
  && t2w1lwt10 < t2w1r5 && t2w1lwt10 < t2w1l5 && t2w1lwt10 < t2h1u5 && t2w1lwt10 < t2h1d5 && t2w1lwt10 <t2w1rwt5 && t2w1lwt10 <t2w1lwt5 && t2w1lwt10 < t2h1uwt5 && t2w1lwt10 < t2h1dwt5
  && t2w1lwt10 < t2w1r6 && t2w1lwt10 < t2w1l6 && t2w1lwt10 < t2h1u6 && t2w1lwt10 < t2h1d6 && t2w1lwt10 <t2w1rwt6 && t2w1lwt10 <t2w1lwt6 && t2w1lwt10 < t2h1uwt6 && t2w1lwt10 < t2h1dwt6
  && t2w1lwt10 < t2w1r7 && t2w1lwt10 < t2w1l7 && t2w1lwt10 < t2h1u7 && t2w1lwt10 < t2h1d7 && t2w1lwt10 <t2w1rwt7 && t2w1lwt10 <t2w1lwt7 && t2w1lwt10 < t2h1uwt7 && t2w1lwt10 < t2h1dwt7
  && t2w1lwt10 < t2w1r8 && t2w1lwt10 < t2w1l8 && t2w1lwt10 < t2h1u8 && t2w1lwt10 < t2h1d8 && t2w1lwt10 <t2w1rwt8 && t2w1lwt10 <t2w1lwt8 && t2w1lwt10 < t2h1uwt8 && t2w1lwt10 < t2h1dwt8
  && t2w1lwt10 < t2w1r9 && t2w1lwt10 < t2w1l9 && t2w1lwt10 < t2h1u9 && t2w1lwt10 < t2h1d9 && t2w1lwt10 <t2w1rwt9 && t2w1lwt10 <t2w1lwt9 && t2w1lwt10 < t2h1uwt9 && t2w1lwt10 < t2h1dwt9
  && t2w1lwt10 < t2w1r10 && t2w1lwt10 < t2w1l10 && t2w1lwt10 < t2h1u10 && t2w1lwt10 < t2h1d10 && t2w1lwt10 <t2w1rwt10 && t2w1lwt10 < t2h1uwt10 && t2w1lwt10 < t2h1dwt10)
{
	    if (mxlOW10 == 0) i = 435;
    else{
	    if (mxlOW10 == -1) i = 439;
    else{
	    if (linwl10!=0 && loutwl10!=0) i=425;
    else{
	    if ((loutwl10!=0 && linwl10==0) || (loutwl10==0 && linwl10!=0)) i= 426;
    else{
	    if (loutwl10==0 && linwl10==0) i=427;
}}}}}


/* neutron interacts with the elliptic top OUTER wall - comments are analog to inner elliptic right wall*/

  if (t2h1uwt10 > 0 && t2h1uwt10 < t1 
  && t2h1uwt10 < t2w1r && t2h1uwt10 < t2w1l && t2h1uwt10 < t2h1u && t2h1uwt10 < t2h1d && t2h1uwt10 < t2w1rwt && t2h1uwt10 < t2w1lwt && t2h1uwt10 < t2h1uwt && t2h1uwt10 < t2h1dwt 
  && t2h1uwt10 < t2w1r1 && t2h1uwt10 < t2w1l1 && t2h1uwt10 < t2h1u1 && t2h1uwt10 < t2h1d1 && t2h1uwt10 < t2w1rwt1 && t2h1uwt10 < t2w1lwt1 && t2h1uwt10 < t2h1uwt1 && t2h1uwt10 < t2h1dwt1
  && t2h1uwt10 < t2w1r2 && t2h1uwt10 < t2w1l2 && t2h1uwt10 < t2h1u2 && t2h1uwt10 < t2h1d2 && t2h1uwt10 < t2w1rwt2 && t2h1uwt10 < t2w1lwt2 && t2h1uwt10 < t2h1uwt2 && t2h1uwt10 < t2h1dwt2
  && t2h1uwt10 < t2w1r3 && t2h1uwt10 < t2w1l3 && t2h1uwt10 < t2h1u3 && t2h1uwt10 < t2h1d3 && t2h1uwt10 < t2w1rwt3 && t2h1uwt10 < t2w1lwt3 && t2h1uwt10 < t2h1uwt3 && t2h1uwt10 < t2h1dwt3
  && t2h1uwt10 < t2w1r4 && t2h1uwt10 < t2w1l4 && t2h1uwt10 < t2h1u4 && t2h1uwt10 < t2h1d4 && t2h1uwt10 < t2w1rwt4 && t2h1uwt10 < t2w1lwt4 && t2h1uwt10 < t2h1uwt4 && t2h1uwt10 < t2h1dwt4
  && t2h1uwt10 < t2w1r5 && t2h1uwt10 < t2w1l5 && t2h1uwt10 < t2h1u5 && t2h1uwt10 < t2h1d5 && t2h1uwt10 < t2w1rwt5 && t2h1uwt10 < t2w1lwt5 && t2h1uwt10 < t2h1uwt5 && t2h1uwt10 < t2h1dwt5
  && t2h1uwt10 < t2w1r6 && t2h1uwt10 < t2w1l6 && t2h1uwt10 < t2h1u6 && t2h1uwt10 < t2h1d6 && t2h1uwt10 < t2w1rwt6 && t2h1uwt10 < t2w1lwt6 && t2h1uwt10 < t2h1uwt6 && t2h1uwt10 < t2h1dwt6
  && t2h1uwt10 < t2w1r7 && t2h1uwt10 < t2w1l7 && t2h1uwt10 < t2h1u7 && t2h1uwt10 < t2h1d7 && t2h1uwt10 < t2w1rwt7 && t2h1uwt10 < t2w1lwt7 && t2h1uwt10 < t2h1uwt7 && t2h1uwt10 < t2h1dwt7
  && t2h1uwt10 < t2w1r8 && t2h1uwt10 < t2w1l8 && t2h1uwt10 < t2h1u8 && t2h1uwt10 < t2h1d8 && t2h1uwt10 < t2w1rwt8 && t2h1uwt10 < t2w1lwt8 && t2h1uwt10 < t2h1uwt8 && t2h1uwt10 < t2h1dwt8
  && t2h1uwt10 < t2w1r9 && t2h1uwt10 < t2w1l9 && t2h1uwt10 < t2h1u9 && t2h1uwt10 < t2h1d9 && t2h1uwt10 < t2w1rwt9 && t2h1uwt10 < t2w1lwt9 && t2h1uwt10 < t2h1uwt9 && t2h1uwt10 < t2h1dwt9
  && t2h1uwt10 < t2w1r10 && t2h1uwt10 < t2w1l10 && t2h1uwt10 < t2h1u10 && t2h1uwt10 < t2h1d10 && t2h1uwt10 < t2w1rwt10 && t2h1uwt10 < t2w1lwt10 && t2h1uwt10 < t2h1dwt10)
{
	    if (myuOW10 == 0) i = 436;
    else{
	    if (myuOW10 == -1) i = 440;
    else{
	    if (louthu10 !=0 && linhu10!=0) i=428;
    else{
	    if ((louthu10!=0 && linhu10==0) || (louthu10==0 && linhu10!=0)) i = 429;
    else{
	    if (louthu10 == 0 && linhu10 == 0) i =430;
}}}}}


/* neutron interacts with the elliptic down OUTER wall - comments are analog to inner elliptic right wall*/

  if (t2h1dwt10 > 0 && t2h1dwt10 < t1 
  && t2h1dwt10 < t2w1r && t2h1dwt10 < t2w1l && t2h1dwt10 < t2h1u && t2h1dwt10 < t2h1d && t2h1dwt10 < t2w1rwt && t2h1dwt10 < t2w1lwt && t2h1dwt10 < t2h1uwt && t2h1dwt10 < t2h1dwt 
  && t2h1dwt10 < t2w1r1 && t2h1dwt10 < t2w1l1 && t2h1dwt10 < t2h1u1 && t2h1dwt10 < t2h1d1 && t2h1dwt10 < t2w1rwt1 && t2h1dwt10 < t2w1lwt1 && t2h1dwt10 < t2h1uwt1 && t2h1dwt10 < t2h1dwt1
  && t2h1dwt10 < t2w1r2 && t2h1dwt10 < t2w1l2 && t2h1dwt10 < t2h1u2 && t2h1dwt10 < t2h1d2 && t2h1dwt10 < t2w1rwt2 && t2h1dwt10 < t2w1lwt2 && t2h1dwt10 < t2h1uwt2 && t2h1dwt10 < t2h1dwt2 
  && t2h1dwt10 < t2w1r3 && t2h1dwt10 < t2w1l3 && t2h1dwt10 < t2h1u3 && t2h1dwt10 < t2h1d3 && t2h1dwt10 < t2w1rwt3 && t2h1dwt10 < t2w1lwt3 && t2h1dwt10 < t2h1uwt3 && t2h1dwt10 < t2h1dwt3
  && t2h1dwt10 < t2w1r4 && t2h1dwt10 < t2w1l4 && t2h1dwt10 < t2h1u4 && t2h1dwt10 < t2h1d4 && t2h1dwt10 < t2w1rwt4 && t2h1dwt10 < t2w1lwt4 && t2h1dwt10 < t2h1uwt4 && t2h1dwt10 < t2h1dwt4
  && t2h1dwt10 < t2w1r5 && t2h1dwt10 < t2w1l5 && t2h1dwt10 < t2h1u5 && t2h1dwt10 < t2h1d5 && t2h1dwt10 < t2w1rwt5 && t2h1dwt10 < t2w1lwt5 && t2h1dwt10 < t2h1uwt5 && t2h1dwt10 < t2h1dwt5
  && t2h1dwt10 < t2w1r6 && t2h1dwt10 < t2w1l6 && t2h1dwt10 < t2h1u6 && t2h1dwt10 < t2h1d6 && t2h1dwt10 < t2w1rwt6 && t2h1dwt10 < t2w1lwt6 && t2h1dwt10 < t2h1uwt6 && t2h1dwt10 < t2h1dwt6
  && t2h1dwt10 < t2w1r7 && t2h1dwt10 < t2w1l7 && t2h1dwt10 < t2h1u7 && t2h1dwt10 < t2h1d7 && t2h1dwt10 < t2w1rwt7 && t2h1dwt10 < t2w1lwt7 && t2h1dwt10 < t2h1uwt7 && t2h1dwt10 < t2h1dwt7 
  && t2h1dwt10 < t2w1r8 && t2h1dwt10 < t2w1l8 && t2h1dwt10 < t2h1u8 && t2h1dwt10 < t2h1d8 && t2h1dwt10 < t2w1rwt8 && t2h1dwt10 < t2w1lwt8 && t2h1dwt10 < t2h1uwt8 && t2h1dwt10 < t2h1dwt8
  && t2h1dwt10 < t2w1r9 && t2h1dwt10 < t2w1l9 && t2h1dwt10 < t2h1u9 && t2h1dwt10 < t2h1d9 && t2h1dwt10 < t2w1rwt9 && t2h1dwt10 < t2w1lwt9 && t2h1dwt10 < t2h1uwt9 && t2h1dwt10 < t2h1dwt9 
  && t2h1dwt10 < t2w1r10 && t2h1dwt10 < t2w1l10 && t2h1dwt10 < t2h1u10 && t2h1dwt10 < t2h1d10 && t2h1dwt10 < t2w1rwt10 && t2h1dwt10 < t2w1lwt10 && t2h1dwt10 < t2h1uwt10)
{
	    if ( mydOW10 == 0 ) i=437;
    else{
	    if ( mydOW10 == -1) i=441;
    else{
	    if (louthd10 !=0 && linhd10!=0)  i=431;
    else{
	    if ((louthd10 !=0 && linhd10==0) || (louthd10 ==0 && linhd10!=0)) i=432;
    else{
	    if (louthd10 == 0 && linhd10 == 0) i =433;
}}}}}



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;
        ny=-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;

  case 122: 
        PROP_DT(t2w1r3);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-x;
        nz=-x*x/((a2wr3/(z+z0wr3))-(z0wr3+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 123: 
        PROP_DT(t2w1r3);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-x;
        nz=-0.5/pawr3;
        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 124: 
        PROP_DT(t2w1r3);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=l;
        nz=w2r3-w1r3;
        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 125: 
        PROP_DT(t2w1l3);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-x;
        nz=-x*x/((a2wl3/(z+z0wl3))-(z0wl3+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 126: 
        PROP_DT(t2w1l3);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-x;
        nz=-0.5/pawl3;
        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 127: 
        PROP_DT(t2w1l3);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-l;
        nz=w2l3-w1l3;
        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 128: 
        PROP_DT(t2h1u3);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-y;
        nz=-y*y/((a2hu3/(z+z0hu3))-(z0hu3+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 129: 
        PROP_DT(t2h1u3);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-y;
        nz=-0.5/pahu3;
        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 130: 
        PROP_DT(t2h1u3);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-l;
        nz=h2u3-h1u3;
        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 131: 
        PROP_DT(t2h1d3);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-y;
        nz=-y*y/((a2hd3/(z+z0hd3))-(z0hd3+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 132: 
        PROP_DT(t2h1d3);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-y;
        nz=-0.5/pahd3;
        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 133: 
        PROP_DT(t2h1d3);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=l;
        nz=h2d3-h1d3;
        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 134:										/* transperent walls - no interaction */
	 PROP_DT(t2w1r3);
         break;

  case 135:
	 PROP_DT(t2w1l3);
         break;

  case 136:
	 PROP_DT(t2h1u3);
         break;

  case 137:
	 PROP_DT(t2h1d3);
         break;
  
   case 138:										/* absorbing walls - neutrons are absorbed at interaction point*/
	 PROP_DT(t2w1r3);
         ABSORB;
         break;

  case 139:
	 PROP_DT(t2w1l3);
         ABSORB;
         break;

  case 140:
	 PROP_DT(t2h1u3);
         ABSORB;
         break;

  case 141:
	 PROP_DT(t2h1d3);
         ABSORB;
         break;

											/* OUTER WALLS - analog to inner walls, but sign of surface normal vector is changed */

  case 142: 
        PROP_DT(t2w1rwt3);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=x;
        nz=x*x/((a2wrwt3/(z+z0wr3))-(z0wr3+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 143: 
        PROP_DT(t2w1rwt3);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=x;
        nz=0.5/pawrwt3;
        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 144: 
        PROP_DT(t2w1rwt3);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-l;
        nz=-(w2r3-w1r3);
        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 145: 
        PROP_DT(t2w1lwt3);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=x;
        nz=x*x/((a2wlwt3/(z+z0wl3))-(z0wl3+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 146: 
        PROP_DT(t2w1lwt3);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=x;
        nz=0.5/pawlwt3;
        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 147: 
        PROP_DT(t2w1lwt3);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=l;
        nz=-(w2l3-w1l3);
        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 148: 
        PROP_DT(t2h1uwt3);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=y;
        nz=y*y/((a2huwt3/(z+z0hu3))-(z0hu3+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 149: 
        PROP_DT(t2h1uwt3);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=y;
        nz=0.5/pahuwt3;
        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 150: 
        PROP_DT(t2h1uwt3);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=l;
        nz=-(h2u3-h1u3);
        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 151: 
        PROP_DT(t2h1dwt3);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=y;
        nz=y*y/((a2hdwt3/(z+z0hd3))-(z0hd3+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 152: 
        PROP_DT(t2h1dwt3);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=y;
        nz=0.5/pahdwt3;
        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 153: 
        PROP_DT(t2h1dwt3);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-l;
        nz=-(h2d3-h1d3);
        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 154:
	 PROP_DT(t2w1rwt3);
         ABSORB;
         break;

  case 155:
	 PROP_DT(t2w1lwt3);
         ABSORB;
         break;

  case 156:
	 PROP_DT(t2h1uwt3);
         ABSORB;
         break;

  case 157:
	 PROP_DT(t2h1dwt3);
         ABSORB;
         break;

  case 158:
	 PROP_DT(t2w1rwt3);
         break;

  case 159:
	 PROP_DT(t2w1lwt3);
         break;

  case 160:
	 PROP_DT(t2h1uwt3);
         break;

  case 161:
	 PROP_DT(t2h1dwt3);
         break;


  case 162: 
        PROP_DT(t2w1r4);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-x;
        nz=-x*x/((a2wr4/(z+z0wr4))-(z0wr4+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 163: 
        PROP_DT(t2w1r4);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-x;
        nz=-0.5/pawr4;
        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 164: 
        PROP_DT(t2w1r4);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=l;
        nz=w2r4-w1r4;
        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 165: 
        PROP_DT(t2w1l4);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-x;
        nz=-x*x/((a2wl4/(z+z0wl4))-(z0wl4+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 166: 
        PROP_DT(t2w1l4);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-x;
        nz=-0.5/pawl4;
        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 167: 
        PROP_DT(t2w1l4);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-l;
        nz=w2l4-w1l4;
        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 168: 
        PROP_DT(t2h1u4);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-y;
        nz=-y*y/((a2hu4/(z+z0hu4))-(z0hu4+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 169: 
        PROP_DT(t2h1u4);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-y;
        nz=-0.5/pahu4;
        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 170: 
        PROP_DT(t2h1u4);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-l;
        nz=h2u4-h1u4;
        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 171: 
        PROP_DT(t2h1d4);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-y;
        nz=-y*y/((a2hd4/(z+z0hd4))-(z0hd4+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 172: 
        PROP_DT(t2h1d4);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-y;
        nz=-0.5/pahd4;
        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 173: 
        PROP_DT(t2h1d4);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=l;
        nz=h2d4-h1d4;
        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 174:										/* transperent walls - no interaction */
	 PROP_DT(t2w1r4);
         break;

  case 175:
	 PROP_DT(t2w1l4);
         break;

  case 176:
	 PROP_DT(t2h1u4);
         break;

  case 177:
	 PROP_DT(t2h1d4);
         break;
  
   case 178:										/* absorbing walls - neutrons are absorbed at interaction point*/
	 PROP_DT(t2w1r4);
         ABSORB;
         break;

  case 179:
	 PROP_DT(t2w1l4);
         ABSORB;
         break;

  case 180:
	 PROP_DT(t2h1u4);
         ABSORB;
         break;

  case 181:
	 PROP_DT(t2h1d4);
         ABSORB;
         break;

											/* OUTER WALLS - analog to inner walls, but sign of surface normal vector is changed */

case 182: 
        PROP_DT(t2w1rwt4);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=x;
        nz=x*x/((a2wrwt4/(z+z0wr4))-(z0wr4+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 183: 
        PROP_DT(t2w1rwt4);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=x;
        nz=0.5/pawrwt4;
        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 184: 
        PROP_DT(t2w1rwt4);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-l;
        nz=-(w2r4-w1r4);
        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 185: 
        PROP_DT(t2w1lwt4);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=x;
        nz=x*x/((a2wlwt4/(z+z0wl4))-(z0wl4+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 186: 
        PROP_DT(t2w1lwt4);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=x;
        nz=0.5/pawlwt4;
        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 187: 
        PROP_DT(t2w1lwt4);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=l;
        nz=-(w2l4-w1l4);
        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 188: 
        PROP_DT(t2h1uwt4);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=y;
        nz=y*y/((a2huwt4/(z+z0hu4))-(z0hu4+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 189: 
        PROP_DT(t2h1uwt4);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=y;
        nz=0.5/pahuwt4;
        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 190: 
        PROP_DT(t2h1uwt4);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=l;
        nz=-(h2u4-h1u4);
        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 191: 
        PROP_DT(t2h1dwt4);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=y;
        nz=y*y/((a2hdwt4/(z+z0hd4))-(z0hd4+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 192: 
        PROP_DT(t2h1dwt4);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=y;
        nz=0.5/pahdwt4;
        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 193: 
        PROP_DT(t2h1dwt4);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-l;
        nz=-(h2d4-h1d4);
        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 194:
	 PROP_DT(t2w1rwt4);
         ABSORB;
         break;

  case 195:
	 PROP_DT(t2w1lwt4);
         ABSORB;
         break;

  case 196:
	 PROP_DT(t2h1uwt4);
         ABSORB;
         break;

  case 197:
	 PROP_DT(t2h1dwt4);
         ABSORB;
         break;

  case 3198:
	 PROP_DT(t2w1rwt4);
         break;

  case 199:
	 PROP_DT(t2w1lwt4);
         break;

  case 200:
	 PROP_DT(t2h1uwt4);
         break;

  case 201:
	 PROP_DT(t2h1dwt4);
         break;


  case 202: 
        PROP_DT(t2w1r5);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-x;
        nz=-x*x/((a2wr5/(z+z0wr5))-(z0wr5+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 203: 
        PROP_DT(t2w1r5);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-x;
        nz=-0.5/pawr5;
        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 204: 
        PROP_DT(t2w1r5);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=l;
        nz=w2r5-w1r5;
        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 205: 
        PROP_DT(t2w1l5);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-x;
        nz=-x*x/((a2wl5/(z+z0wl5))-(z0wl5+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 206: 
        PROP_DT(t2w1l5);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-x;
        nz=-0.5/pawl5;
        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 207: 
        PROP_DT(t2w1l5);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-l;
        nz=w2l5-w1l5;
        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 208: 
        PROP_DT(t2h1u5);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-y;
        nz=-y*y/((a2hu5/(z+z0hu5))-(z0hu5+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 209: 
        PROP_DT(t2h1u5);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-y;
        nz=-0.5/pahu5;
        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 210: 
        PROP_DT(t2h1u5);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-l;
        nz=h2u5-h1u5;
        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 211: 
        PROP_DT(t2h1d5);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-y;
        nz=-y*y/((a2hd5/(z+z0hd5))-(z0hd5+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 212: 
        PROP_DT(t2h1d5);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-y;
        nz=-0.5/pahd5;
        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 213: 
        PROP_DT(t2h1d5);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=l;
        nz=h2d5-h1d5;
        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 214:										/* transperent walls - no interaction */
	 PROP_DT(t2w1r5);
         break;

  case 215:
	 PROP_DT(t2w1l5);
         break;

  case 216:
	 PROP_DT(t2h1u5);
         break;

  case 217:
	 PROP_DT(t2h1d5);
         break;
  
   case 218:										/* absorbing walls - neutrons are absorbed at interaction point*/
	 PROP_DT(t2w1r5);
         ABSORB;
         break;

  case 219:
	 PROP_DT(t2w1l5);
         ABSORB;
         break;

  case 220:
	 PROP_DT(t2h1u5);
         ABSORB;
         break;

  case 221:
	 PROP_DT(t2h1d5);
         ABSORB;
         break;

											/* OUTER WALLS - analog to inner walls, but sign of surface normal vector is changed */

  case 222: 
        PROP_DT(t2w1rwt5);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=x;
        nz=x*x/((a2wrwt5/(z+z0wr5))-(z0wr5+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 223: 
        PROP_DT(t2w1rwt5);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=x;
        nz=0.5/pawrwt5;
        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 224: 
        PROP_DT(t2w1rwt5);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-l;
        nz=-(w2rwt5-w1rwt5);
        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 225: 
        PROP_DT(t2w1lwt5);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=x;
        nz=x*x/((a2wlwt5/(z+z0wl5))-(z0wl5+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 226: 
        PROP_DT(t2w1lwt5);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=x;
        nz=0.5/pawlwt5;
        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 227: 
        PROP_DT(t2w1lwt5);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=l;
        nz=-(w2lwt5-w1lwt5);
        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 228: 
        PROP_DT(t2h1uwt5);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=y;
        nz=y*y/((a2huwt5/(z+z0hu5))-(z0hu5+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 229: 
        PROP_DT(t2h1uwt5);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=y;
        nz=0.5/pahuwt5;
        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 230: 
        PROP_DT(t2h1uwt5);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=l;
        nz=-(h2uwt5-h1uwt5);
        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 231: 
        PROP_DT(t2h1dwt5);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=y;
        nz=y*y/((a2hdwt5/(z+z0hd5))-(z0hd5+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 232: 
        PROP_DT(t2h1dwt5);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=y;
        nz=0.5/pahdwt5;
        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 233: 
        PROP_DT(t2h1dwt5);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-l;
        nz=-(h2dwt5-h1dwt5);
        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 234:
	 PROP_DT(t2w1rwt5);
         ABSORB;
         break;

  case 235:
	 PROP_DT(t2w1lwt5);
         ABSORB;
         break;

  case 236:
	 PROP_DT(t2h1uwt5);
         ABSORB;
         break;

  case 237:
	 PROP_DT(t2h1dwt5);
         ABSORB;
         break;

  case 238:
	 PROP_DT(t2w1rwt5);
         break;

  case 239:
	 PROP_DT(t2w1lwt5);
         break;

  case 240:
	 PROP_DT(t2h1uwt5);
         break;

  case 241:
	 PROP_DT(t2h1dwt5);
         break;

  case 242: 
        PROP_DT(t2w1r6);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-x;
        nz=-x*x/((a2wr6/(z+z0wr6))-(z0wr6+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 243: 
        PROP_DT(t2w1r6);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-x;
        nz=-0.5/pawr6;
        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 244: 
        PROP_DT(t2w1r6);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=l;
        nz=w2r6-w1r6;
        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 245: 
        PROP_DT(t2w1l6);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-x;
        nz=-x*x/((a2wl6/(z+z0wl6))-(z0wl6+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 246:
        PROP_DT(t2w1l6);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-l;
        nz=w2l6-w1l6;
        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 247: 
         PROP_DT(t2w1l6);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-l;
        nz=w2l6-w1l6;
        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 248: 
        PROP_DT(t2h1u6);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-y;
        nz=-y*y/((a2hu6/(z+z0hu6))-(z0hu6+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 249: 
        PROP_DT(t2h1u6);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-y;
        nz=-0.5/pahu6;
        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 250: 
        PROP_DT(t2h1u6);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-l;
        nz=h2u6-h1u6;
        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 251: 
        PROP_DT(t2h1d6);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-y;
        nz=-y*y/((a2hd6/(z+z0hd6))-(z0hd6+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 252: 
        PROP_DT(t2h1d6);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-y;
        nz=-0.5/pahd6;
        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 253: 
        PROP_DT(t2h1d6);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=l;
        nz=h2d6-h1d6;
        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 254:										/* transperent walls - no interaction */
	 PROP_DT(t2w1r6);
         break;

  case 255:
	 PROP_DT(t2w1l6);
         break;

  case 256:
	 PROP_DT(t2h1u6);
         break;

  case 257:
	 PROP_DT(t2h1d6);
         break;
  
   case 258:										/* absorbing walls - neutrons are absorbed at interaction point*/
	 PROP_DT(t2w1r6);
         ABSORB;
         break;

  case 259:
	 PROP_DT(t2w1l6);
         ABSORB;
         break;

  case 260:
	 PROP_DT(t2h1u6);
         ABSORB;
         break;

  case 261:
	 PROP_DT(t2h1d6);
         ABSORB;
         break;

											/* OUTER WALLS - analog to inner walls, but sign of surface normal vector is changed */

  case 262: 
        PROP_DT(t2w1rwt6);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=x;
        nz=x*x/((a2wrwt6/(z+z0wr6))-(z0wr6+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 263: 
        PROP_DT(t2w1rwt6);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=x;
        nz=0.5/pawrwt6;
        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 264: 
        PROP_DT(t2w1rwt6);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-l;
        nz=-(w2rwt6-w1rwt6);
        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 265: 
        PROP_DT(t2w1lwt6);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=x;
        nz=x*x/((a2wlwt6/(z+z0wl6))-(z0wl6+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 266: 
        PROP_DT(t2w1lwt6);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=x;
        nz=0.5/pawlwt6;
        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 267: 
        PROP_DT(t2w1lwt6);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=l;
        nz=-(w2l6-w1l6);
        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 268: 
        PROP_DT(t2h1uwt6);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=y;
        nz=y*y/((a2huwt6/(z+z0hu6))-(z0hu6+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 269: 
        PROP_DT(t2h1uwt6);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=y;
        nz=0.5/pahuwt6;
        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 270: 
        PROP_DT(t2h1uwt6);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=l;
        nz=-(h2u6-h1u6);
        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 271: 
        PROP_DT(t2h1dwt6);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=y;
        nz=y*y/((a2hdwt6/(z+z0hd6))-(z0hd6+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 272: 
        PROP_DT(t2h1dwt6);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=y;
        nz=0.5/pahdwt6;
        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 273: 
        PROP_DT(t2h1dwt6);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-l;
        nz=-(h2d6-h1d6);
        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 274:
	 PROP_DT(t2w1rwt6);
         ABSORB;
         break;

  case 275:
	 PROP_DT(t2w1lwt6);
         ABSORB;
         break;

  case 276:
	 PROP_DT(t2h1uwt6);
         ABSORB;
         break;

  case 277:
	 PROP_DT(t2h1dwt6);
         ABSORB;
         break;

  case 278:
	 PROP_DT(t2w1rwt6);
         break;

  case 279:
	 PROP_DT(t2w1lwt6);
         break;

  case 280:
	 PROP_DT(t2h1uwt6);
         break;

  case 281:
	 PROP_DT(t2h1dwt6);
         break;

 case 282: 
        PROP_DT(t2w1r7);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-x;
        nz=-x*x/((a2wr7/(z+z0wr7))-(z0wr7+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 283: 
        PROP_DT(t2w1r7);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-x;
        nz=-0.5/pawr7;
        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 284: 
        PROP_DT(t2w1r7);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=l;
        nz=w2r7-w1r7;
        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 285: 
        PROP_DT(t2w1l7);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-x;
        nz=-x*x/((a2wl7/(z+z0wl7))-(z0wl7+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 286: 
        PROP_DT(t2w1l7);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-x;
        nz=-0.5/pawl7;
        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 287: 
        PROP_DT(t2w1l7);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-l;
        nz=w2l7-w1l7;
        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 288: 
        PROP_DT(t2h1u7);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-y;
        nz=-y*y/((a2hu7/(z+z0hu7))-(z0hu7+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 289: 
        PROP_DT(t2h1u7);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-y;
        nz=-0.5/pahu7;
        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 290: 
        PROP_DT(t2h1u7);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-l;
        nz=h2u7-h1u7;
        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 291: 
        PROP_DT(t2h1d7);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-y;
        nz=-y*y/((a2hd7/(z+z0hd7))-(z0hd7+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 292: 
        PROP_DT(t2h1d7);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-y;
        nz=-0.5/pahd7;
        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 293: 
        PROP_DT(t2h1d7);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=l;
        nz=h2d7-h1d7;
        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 294:										/* transperent walls - no interaction */
	 PROP_DT(t2w1r7);
         break;

  case 295:
	 PROP_DT(t2w1l7);
         break;

  case 296:
	 PROP_DT(t2h1u7);
         break;

  case 297:
	 PROP_DT(t2h1d7);
         break;
  
   case 298:										/* absorbing walls - neutrons are absorbed at interaction point*/
	 PROP_DT(t2w1r7);
         ABSORB;
         break;

  case 299:
	 PROP_DT(t2w1l7);
         ABSORB;
         break;

  case 300:
	 PROP_DT(t2h1u7);
         ABSORB;
         break;

  case 301:
	 PROP_DT(t2h1d7);
         ABSORB;
         break;

											/* OUTER WALLS - analog to inner walls, but sign of surface normal vector is changed */

  case 302: 
        PROP_DT(t2w1rwt7);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=x;
        nz=x*x/((a2wrwt7/(z+z0wr7))-(z0wr7+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 303: 
        PROP_DT(t2w1rwt7);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=x;
        nz=0.5/pawrwt7;
        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 304: 
        PROP_DT(t2w1rwt7);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-l;
        nz=-(w2r7-w1r7);
        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 305: 
        PROP_DT(t2w1lwt7);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=x;
        nz=x*x/((a2wlwt7/(z+z0wl7))-(z0wl7+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 306: 
        PROP_DT(t2w1lwt7);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=x;
        nz=0.5/pawlwt7;
        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 307: 
        PROP_DT(t2w1lwt7);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=l;
        nz=-(w2l7-w1l7);
        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 308: 
        PROP_DT(t2h1uwt7);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=y;
        nz=y*y/((a2huwt7/(z+z0hu7))-(z0hu7+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 309: 
        PROP_DT(t2h1uwt7);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=y;
        nz=0.5/pahuwt7;
        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 310: 
        PROP_DT(t2h1uwt7);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=l;
        nz=-(h2u7-h1u7);
        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 311: 
        PROP_DT(t2h1dwt7);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=y;
        nz=y*y/((a2hdwt7/(z+z0hd7))-(z0hd7+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 312: 
        PROP_DT(t2h1dwt7);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=y;
        nz=0.5/pahdwt7;
        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 313: 
        PROP_DT(t2h1dwt7);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-l;
        nz=-(h2d7-h1d7);
        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 314:
	 PROP_DT(t2w1rwt7);
         ABSORB;
         break;

  case 315:
	 PROP_DT(t2w1lwt7);
         ABSORB;
         break;

  case 316:
	 PROP_DT(t2h1uwt7);
         ABSORB;
         break;

  case 317:
	 PROP_DT(t2h1dwt7);
         ABSORB;
         break;

  case 318:
	 PROP_DT(t2w1rwt7);
         break;

  case 319:
	 PROP_DT(t2w1lwt7);
         break;

  case 320:
	 PROP_DT(t2h1uwt7);
         break;

  case 321:
	 PROP_DT(t2h1dwt7);
         break;

  case 322: 
        PROP_DT(t2w1r8);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-x;
        nz=-x*x/((a2wr8/(z+z0wr8))-(z0wr8+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 323: 
        PROP_DT(t2w1r8);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-x;
        nz=-0.5/pawr8;
        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 324: 
        PROP_DT(t2w1r8);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=l;
        nz=w2r8-w1r8;
        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 325: 
        PROP_DT(t2w1l8);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-x;
        nz=-x*x/((a2wl8/(z+z0wl8))-(z0wl8+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 326: 
        PROP_DT(t2w1l8);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-x;
        nz=-0.5/pawl8;
        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 327: 
        PROP_DT(t2w1l8);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-l;
        nz=w2l8-w1l8;
        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 328: 
        PROP_DT(t2h1u8);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-y;
        nz=-y*y/((a2hu8/(z+z0hu8))-(z0hu8+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 329: 
        PROP_DT(t2h1u8);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-y;
        nz=-0.5/pahu8;
        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 330: 
        PROP_DT(t2h1u8);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-l;
        nz=h2u8-h1u8;
        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 331: 
        PROP_DT(t2h1d8);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-y;
        nz=-y*y/((a2hd8/(z+z0hd8))-(z0hd8+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 332: 
        PROP_DT(t2h1d8);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-y;
        nz=-0.5/pahd8;
        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 333: 
        PROP_DT(t2h1d8);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=l;
        nz=h2d8-h1d8;
        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 334:										/* transperent walls - no interaction */
	 PROP_DT(t2w1r8);
         break;

  case 335:
	 PROP_DT(t2w1l8);
         break;

  case 336:
	 PROP_DT(t2h1u8);
         break;

  case 337:
	 PROP_DT(t2h1d8);
         break;
  
   case 338:										/* absorbing walls - neutrons are absorbed at interaction point*/
	 PROP_DT(t2w1r8);
         ABSORB;
         break;

  case 339:
	 PROP_DT(t2w1l8);
         ABSORB;
         break;

  case 340:
	 PROP_DT(t2h1u8);
         ABSORB;
         break;

  case 341:
	 PROP_DT(t2h1d8);
         ABSORB;
         break;

											/* OUTER WALLS - analog to inner walls, but sign of surface normal vector is changed */

  case 342: 
        PROP_DT(t2w1rwt8);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=x;
        nz=x*x/((a2wrwt8/(z+z0wr8))-(z0wr8+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 343: 
        PROP_DT(t2w1rwt8);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=x;
        nz=0.5/pawrwt8;
        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 344: 
        PROP_DT(t2w1rwt8);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-l;
        nz=-(w2r8-w1r8);
        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 345: 
        PROP_DT(t2w1lwt8);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=x;
        nz=x*x/((a2wlwt8/(z+z0wl8))-(z0wl8+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 346: 
        PROP_DT(t2w1lwt8);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=x;
        nz=0.5/pawlwt8;
        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 347: 
        PROP_DT(t2w1lwt8);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=l;
        nz=-(w2l8-w1l8);
        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 348: 
        PROP_DT(t2h1uwt8);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=y;
        nz=y*y/((a2huwt8/(z+z0hu8))-(z0hu8+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 349: 
        PROP_DT(t2h1uwt8);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=y;
        nz=0.5/pahuwt8;
        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 350: 
        PROP_DT(t2h1uwt8);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=l;
        nz=-(h2u8-h1u8);
        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 351: 
        PROP_DT(t2h1dwt8);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=y;
        nz=y*y/((a2hdwt8/(z+z0hd8))-(z0hd8+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 352: 
        PROP_DT(t2h1dwt8);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=y;
        nz=0.5/pahdwt8;
        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 353: 
        PROP_DT(t2h1dwt8);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-l;
        nz=-(h2d8-h1d8);
        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 354:
	 PROP_DT(t2w1rwt8);
         ABSORB;
         break;

  case 355:
	 PROP_DT(t2w1lwt8);
         ABSORB;
         break;

  case 356:
	 PROP_DT(t2h1uwt8);
         ABSORB;
         break;

  case 357:
	 PROP_DT(t2h1dwt8);
         ABSORB;
         break;

  case 358:
	 PROP_DT(t2w1rwt8);
         break;

  case 359:
	 PROP_DT(t2w1lwt8);
         break;

  case 360:
	 PROP_DT(t2h1uwt8);
         break;

  case 361:
	 PROP_DT(t2h1dwt8);
         break;

case 362: 
        PROP_DT(t2w1r9);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-x;
        nz=-x*x/((a2wr9/(z+z0wr9))-(z0wr9+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 363: 
        PROP_DT(t2w1r9);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-x;
        nz=-0.5/pawr9;
        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 364: 
        PROP_DT(t2w1r9);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=l;
        nz=w2r9-w1r9;
        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 365: 
        PROP_DT(t2w1l9);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-x;
        nz=-x*x/((a2wl9/(z+z0wl9))-(z0wl9+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 366: 
        PROP_DT(t2w1l9);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-x;
        nz=-0.5/pawl9;
        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 367: 
        PROP_DT(t2w1l9);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-l;
        nz=w2l9-w1l9;
        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 368: 
        PROP_DT(t2h1u9);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-y;
        nz=-y*y/((a2hu9/(z+z0hu9))-(z0hu9+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 369: 
        PROP_DT(t2h1u9);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-y;
        nz=-0.5/pahu9;
        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 370: 
        PROP_DT(t2h1u9);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-l;
        nz=h2u9-h1u9;
        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 371: 
        PROP_DT(t2h1d9);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-y;
        nz=-y*y/((a2hd9/(z+z0hd9))-(z0hd9+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 372: 
        PROP_DT(t2h1d9);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-y;
        nz=-0.5/pahd9;
        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 373: 
        PROP_DT(t2h1d9);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=l;
        nz=h2d9-h1d9;
        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 374:										/* transperent walls - no interaction */
	 PROP_DT(t2w1r9);
         break;

  case 375:
	 PROP_DT(t2w1l9);
         break;

  case 376:
	 PROP_DT(t2h1u9);
         break;

  case 377:
	 PROP_DT(t2h1d9);
         break;
  
   case 378:										/* absorbing walls - neutrons are absorbed at interaction point*/
	 PROP_DT(t2w1r9);
         ABSORB;
         break;

  case 379:
	 PROP_DT(t2w1l9);
         ABSORB;
         break;

  case 380:
	 PROP_DT(t2h1u9);
         ABSORB;
         break;

  case 381:
	 PROP_DT(t2h1d9);
         ABSORB;
         break;

											/* OUTER WALLS - analog to inner walls, but sign of surface normal vector is changed */

  case 382: 
        PROP_DT(t2w1rwt9);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=x;
        nz=x*x/((a2wrwt9/(z+z0wr9))-(z0wr9+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 383: 
        PROP_DT(t2w1rwt9);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=x;
        nz=0.5/pawrwt9;
        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 384: 
        PROP_DT(t2w1rwt9);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-l;
        nz=-(w2r9-w1r9);
        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 385: 
        PROP_DT(t2w1lwt9);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=x;
        nz=x*x/((a2wlwt9/(z+z0wl9))-(z0wl9+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 386: 
        PROP_DT(t2w1lwt9);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=x;
        nz=0.5/pawlwt9;
        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 387: 
        PROP_DT(t2w1lwt9);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=l;
        nz=-(w2l9-w1l9);
        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 388: 
        PROP_DT(t2h1uwt9);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=y;
        nz=y*y/((a2huwt9/(z+z0hu9))-(z0hu9+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 389: 
        PROP_DT(t2h1uwt9);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=y;
        nz=0.5/pahuwt9;
        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 390: 
        PROP_DT(t2h1uwt9);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=l;
        nz=-(h2u9-h1u9);
        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 391: 
        PROP_DT(t2h1dwt9);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=y;
        nz=y*y/((a2hdwt9/(z+z0hd9))-(z0hd9+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 392: 
        PROP_DT(t2h1dwt9);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=y;
        nz=0.5/pahdwt9;
        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 393: 
        PROP_DT(t2h1dwt9);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-l;
        nz=-(h2d9-h1d9);
        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 394:
	 PROP_DT(t2w1rwt9);
         ABSORB;
         break;

  case 395:
	 PROP_DT(t2w1lwt9);
         ABSORB;
         break;

  case 396:
	 PROP_DT(t2h1uwt9);
         ABSORB;
         break;

  case 397:
	 PROP_DT(t2h1dwt9);
         ABSORB;
         break;

  case 398:
	 PROP_DT(t2w1rwt9);
         break;

  case 399:
	 PROP_DT(t2w1lwt9);
         break;

  case 400:
	 PROP_DT(t2h1uwt9);
         break;

  case 401:
	 PROP_DT(t2h1dwt9);
         break;

  case 402: 
        PROP_DT(t2w1r10);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-x;
        nz=-x*x/((a2wr10/(z+z0wr10))-(z0wr10+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 403: 
        PROP_DT(t2w1r10);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-x;
        nz=-0.5/pawr10;
        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 404: 
        PROP_DT(t2w1r10);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=l;
        nz=w2r10-w1r10;
        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 405: 
        PROP_DT(t2w1l10);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-x;
        nz=-x*x/((a2wl10/(z+z0wl10))-(z0wl10+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 406: 
        PROP_DT(t2w1l10);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-x;
        nz=-0.5/pawl10;
        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 407: 
        PROP_DT(t2w1l10);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-l;
        nz=w2l10-w1l10;
        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 408: 
        PROP_DT(t2h1u10);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-y;
        nz=-y*y/((a2hu10/(z+z0hu10))-(z0hu10+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 409: 
        PROP_DT(t2h1u10);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-y;
        nz=-0.5/pahu10;
        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 410: 
        PROP_DT(t2h1u10);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-l;
        nz=h2u10-h1u10;
        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 411: 
        PROP_DT(t2h1d10);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-y;
        nz=-y*y/((a2hd10/(z+z0hd10))-(z0hd10+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 412: 
        PROP_DT(t2h1d10);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-y;
        nz=-0.5/pahd10;
        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 413: 
        PROP_DT(t2h1d10);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=l;
        nz=h2d10-h1d10;
        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 414:										/* transperent walls - no interaction */
	 PROP_DT(t2w1r10);
         break;

  case 415:
	 PROP_DT(t2w1l10);
         break;

  case 416:
	 PROP_DT(t2h1u10);
         break;

  case 417:
	 PROP_DT(t2h1d10);
         break;
  
   case 418:										/* absorbing walls - neutrons are absorbed at interaction point*/
	 PROP_DT(t2w1r10);
         ABSORB;
         break;

  case 419:
	 PROP_DT(t2w1l10);
         ABSORB;
         break;

  case 420:
	 PROP_DT(t2h1u10);
         ABSORB;
         break;

  case 421:
	 PROP_DT(t2h1d10);
         ABSORB;
         break;

											/* OUTER WALLS - analog to inner walls, but sign of surface normal vector is changed */

  case 422: 
        PROP_DT(t2w1rwt10);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=x;
        nz=x*x/((a2wrwt10/(z+z0wr10))-(z0wr10+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 423: 
        PROP_DT(t2w1rwt10);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=x;
        nz=0.5/pawrwt10;
        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 424: 
        PROP_DT(t2w1rwt10);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=-l;
        nz=-(w2r10-w1r10);
        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 425: 
        PROP_DT(t2w1lwt10);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=x;
        nz=x*x/((a2wlwt10/(z+z0wl10))-(z0wl10+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 426: 
        PROP_DT(t2w1lwt10);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=x;
        nz=0.5/pawlwt10;
        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 427: 
        PROP_DT(t2w1lwt10);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        nx=l;
        nz=-(w2l10-w1l10);
        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 428: 
        PROP_DT(t2h1uwt10);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=y;
        nz=y*y/((a2huwt10/(z+z0hu10))-(z0hu10+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 429: 
        PROP_DT(t2h1uwt10);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=y;
        nz=0.5/pahuwt10;
        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 430: 
        PROP_DT(t2h1uwt10);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=l;
        nz=-(h2u10-h1u10);
        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 431: 
        PROP_DT(t2h1dwt10);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=y;
        nz=y*y/((a2hdwt10/(z+z0hd10))-(z0hd10+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 432: 
        PROP_DT(t2h1dwt10);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=y;
        nz=0.5/pahdwt10;
        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 433: 
        PROP_DT(t2h1dwt10);
        vxin=vx;
        vyin=vy;
        vzin=vz;
        ny=-l;
        nz=-(h2d10-h1d10);
        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 434:
	 PROP_DT(t2w1rwt10);
         ABSORB;
         break;

  case 435:
	 PROP_DT(t2w1lwt10);
         ABSORB;
         break;

  case 436:
	 PROP_DT(t2h1uwt10);
         ABSORB;
         break;

  case 437:
	 PROP_DT(t2h1dwt10);
         ABSORB;
         break;

  case 438:
	 PROP_DT(t2w1rwt10);
         break;

  case 439:
	 PROP_DT(t2w1lwt10);
         break;

  case 440:
	 PROP_DT(t2h1uwt10);
         break;

  case 441:
	 PROP_DT(t2h1dwt10);
         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;
                   }
                 }
           }



if (((i==122) ||(i==123) || (i == 124 ))){
          if (RIreflect3 && strlen(RIreflect3))
              {
               p=Table_Value(riTable3, q, 1);
              }else{
                 if(mxr3 > 0 && q > Qcxr3){
                 double arg = (q - mxr3*Qcxr3)/Wxr3;
                 if(arg<10){
                   p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxr3*(q-Qcxr3));
                 }else
                 ABSORB;
                }
              }
           }

  if (((i==142) ||(i==143) || (i==144 ))){	
          if (ROreflect3 && strlen(ROreflect3))
              {
               p=Table_Value(roTable3, q, 1);
              }else{
                 if(mxrOW3 > 0 && q > QcxrOW3){
                   double arg = (q - mxrOW3*QcxrOW3)/WxrOW3;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxrOW3*(q-QcxrOW3));
                   }
                   else
                   ABSORB;
                  }
               }
             }

  if (((i==125) ||(i==126) || (i == 127 ) ) ){
          if (LIreflect3 && strlen(LIreflect3))
              {
               p=Table_Value(liTable3, q, 1);
              }else{
                 if(mxl3 > 0 && q > Qcxl3){
                   double arg = (q - mxl3*Qcxl3)/Wxl3;
                   if(arg<10){
                     p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxl3*(q-Qcxl3));
                   }else
                   ABSORB;
                }
               }
          }

  if (((i==145) || (i==146) || (i==147 )) ){
         if (LOreflect3 && strlen(LOreflect3))
              {
               p=Table_Value(loTable3, q, 1);
              }else{
                 if(mxlOW3 > 0 && q > QcxlOW3){
                   double arg = (q - mxlOW3*QcxlOW3)/WxlOW3;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxlOW3*(q-QcxlOW3));
                   }
                   else
                   ABSORB;
                 }
               }
          }

  if (((i==128) ||(i==129) || (i == 130 ))){
	  if (UIreflect3 && strlen(UIreflect3))
              {
               p=Table_Value(uiTable3, q, 1);
              }else{
                 if(myu3 > 0 && q > Qcyu3){
                 double arg = (q - myu3*Qcyu3)/Wyu3;
                   if(arg<10){
                     p *= 0.5*(1.0-tanh(arg))*(1.0-alphayu3*(q-Qcyu3));
                   }else
                   ABSORB;
                 }
              }
            }

  if (((i==148) || (i==149) || (i==150 )) ){
	  if (UOreflect3 && strlen(UOreflect3))
              {
               p=Table_Value(uoTable3, q, 1);
              }else{
                 if(myuOW3 > 0 && q > QcyuOW3){
                   double arg = (q - myuOW3*QcyuOW3)/WyuOW3;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphayuOW3*(q-QcyuOW3));
                   }else
                   ABSORB;
                   }
               }
           }

  if (((i==131) ||(i==132) || (i == 133 ))){
          if (DIreflect3 && strlen(DIreflect3))
              {
               p=Table_Value(diTable3, q, 1);
              }else{
                 if(myd3 > 0 && q > Qcyd3){
                   double arg = (q - myd3*Qcyd3)/Wyd3;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphayd3*(q-Qcyd3));
                   }else
                   ABSORB;
                   }
               }
            }

   if (((i==151) || (i==152) || (i==153 )) ){
          if (DOreflect3 && strlen(DOreflect3))
              {
               p=Table_Value(doTable3, q, 1);
              }else{
                 if(mydOW3 > 0 && q > QcydOW3){
                   double arg = (q - mydOW3*QcydOW3)/WydOW3;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphaydOW3*(q-QcydOW3));
                   }else
                   ABSORB;
                   }
                 }
           }

   
if (((i==162) ||(i==163) || (i == 164 ))){
          if (RIreflect4 && strlen(RIreflect4))
              {
               p=Table_Value(riTable4, q, 1);
              }else{
                 if(mxr4 > 0 && q > Qcxr4){
                 double arg = (q - mxr4*Qcxr4)/Wxr4;
                 if(arg<10){
                   p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxr4*(q-Qcxr4));
                 }else
                 ABSORB;
                }
              }
           }

  if (((i==182) ||(i==183) || (i==184 ))){	
          if (ROreflect4 && strlen(ROreflect4))
              {
               p=Table_Value(roTable4, q, 1);
              }else{
                 if(mxrOW4 > 0 && q > QcxrOW4){
                   double arg = (q - mxrOW4*QcxrOW4)/WxrOW4;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxrOW4*(q-QcxrOW4));
                   }
                   else
                   ABSORB;
                  }
               }
             }

  if (((i==165) ||(i==166) || (i == 167 ) ) ){
          if (LIreflect4 && strlen(LIreflect4))
              {
               p=Table_Value(liTable4, q, 1);
              }else{
                 if(mxl4 > 0 && q > Qcxl4){
                   double arg = (q - mxl4*Qcxl4)/Wxl4;
                   if(arg<10){
                     p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxl4*(q-Qcxl4));
                   }else
                   ABSORB;
                }
               }
          }

  if (((i==185) || (i==186) || (i==177 )) ){
         if (LOreflect4 && strlen(LOreflect4))
              {
               p=Table_Value(loTable4, q, 1);
              }else{
                 if(mxlOW4 > 0 && q > QcxlOW4){
                   double arg = (q - mxlOW4*QcxlOW4)/WxlOW4;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxlOW4*(q-QcxlOW4));
                   }
                   else
                   ABSORB;
                 }
               }
          }

  if (((i==168) ||(i==169) || (i == 170 ))){
	  if (UIreflect4 && strlen(UIreflect4))
              {
               p=Table_Value(uiTable4, q, 1);
              }else{
                 if(myu4 > 0 && q > Qcyu4){
                 double arg = (q - myu4*Qcyu4)/Wyu4;
                   if(arg<10){
                     p *= 0.5*(1.0-tanh(arg))*(1.0-alphayu4*(q-Qcyu4));
                   }else
                   ABSORB;
                 }
              }
            }

  if (((i==188) || (i==189) || (i==190 ))){
	  if (UOreflect4 && strlen(UOreflect4))
              {
               p=Table_Value(uoTable4, q, 1);
              }else{
                 if(myuOW4 > 0 && q > QcyuOW4){
                   double arg = (q - myuOW4*QcyuOW4)/WyuOW4;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphayuOW4*(q-QcyuOW4));
                   }else
                   ABSORB;
                   }
               }
           }

  if (((i==171) ||(i==172) || (i == 173 ))){
          if (DIreflect4 && strlen(DIreflect4))
              {
               p=Table_Value(diTable4, q, 1);
              }else{
                 if(myd4 > 0 && q > Qcyd4){
                   double arg = (q - myd4*Qcyd4)/Wyd4;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphayd4*(q-Qcyd4));
                   }else
                   ABSORB;
                   }
               }
            }

   if (((i==191) || (i==192) || (i==193 )) ){
          if (DOreflect4 && strlen(DOreflect4))
              {
               p=Table_Value(doTable4, q, 1);
              }else{
                 if(mydOW4 > 0 && q > QcydOW4){
                   double arg = (q - mydOW4*QcydOW4)/WydOW4;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphaydOW4*(q-QcydOW4));
                   }else
                   ABSORB;
                   }
                 }
           }



  if (((i==202) ||(i==203) || (i == 204 ))){
          if (RIreflect5 && strlen(RIreflect5))
              {
               p=Table_Value(riTable5, q, 1);
              }else{
                 if(mxr5 > 0 && q > Qcxr5){
                 double arg = (q - mxr5*Qcxr5)/Wxr5;
                 if(arg<10){
                   p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxr5*(q-Qcxr5));
                 }else
                 ABSORB;
                }
              }
           }

  if (((i==222) ||(i==223) || (i==224 ))){	
          if (ROreflect5 && strlen(ROreflect5))
              {
               p=Table_Value(roTable5, q, 1);
              }else{
                 if(mxrOW5 > 0 && q > QcxrOW5){
                   double arg = (q - mxrOW5*QcxrOW5)/WxrOW5;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxrOW5*(q-QcxrOW5));
                   }
                   else
                   ABSORB;
                  }
               }
             }

  if (((i==205) ||(i==206) || (i == 207 ) ) ){
          if (LIreflect5 && strlen(LIreflect5))
              {
               p=Table_Value(liTable5, q, 1);
              }else{
                 if(mxl5 > 0 && q > Qcxl5){
                   double arg = (q - mxl5*Qcxl5)/Wxl5;
                   if(arg<10){
                     p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxl5*(q-Qcxl5));
                   }else
                   ABSORB;
                }
               }
          }

  if (((i==225) || (i==226) || (i==227 ))){
         if (LOreflect5 && strlen(LOreflect5))
              {
               p=Table_Value(loTable5, q, 1);
              }else{
                 if(mxlOW5 > 0 && q > QcxlOW5){
                   double arg = (q - mxlOW5*QcxlOW5)/WxlOW5;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxlOW5*(q-QcxlOW5));
                   }
                   else
                   ABSORB;
                 }
               }
          }

  if (((i==208) ||(i==209) || (i == 210 ))){
	  if (UIreflect5 && strlen(UIreflect5))
              {
               p=Table_Value(uiTable5, q, 1);
              }else{
                 if(myu5 > 0 && q > Qcyu5){
                 double arg = (q - myu5*Qcyu5)/Wyu5;
                   if(arg<10){
                     p *= 0.5*(1.0-tanh(arg))*(1.0-alphayu5*(q-Qcyu5));
                   }else
                   ABSORB;
                 }
              }
            }

  if (((i==228) || (i==229) || (i==230 )) ){
	  if (UOreflect5 && strlen(UOreflect5))
              {
               p=Table_Value(uoTable5, q, 1);
              }else{
                 if(myuOW5 > 0 && q > QcyuOW5){
                   double arg = (q - myuOW5*QcyuOW5)/WyuOW5;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphayuOW5*(q-QcyuOW5));
                   }else
                   ABSORB;
                   }
               }
           }

  if (((i==211) ||(i==212) || (i == 213 ))){
          if (DIreflect5 && strlen(DIreflect5))
              {
               p=Table_Value(diTable5, q, 1);
              }else{
                 if(myd5 > 0 && q > Qcyd5){
                   double arg = (q - myd5*Qcyd5)/Wyd5;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphayd5*(q-Qcyd5));
                   }else
                   ABSORB;
                   }
               }
            }

   if (((i==231) || (i==232) || (i==233 )) ){
          if (DOreflect5 && strlen(DOreflect5))
              {
               p=Table_Value(doTable5, q, 1);
              }else{
                 if(mydOW5 > 0 && q > QcydOW5){
                   double arg = (q - mydOW5*QcydOW5)/WydOW5;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphaydOW5*(q-QcydOW5));
                   }else
                   ABSORB;
                   }
                 }
           }

  if (((i==242) ||(i==243) || (i == 244 ))){
          if (RIreflect6 && strlen(RIreflect6))
              {
               p=Table_Value(riTable6, q, 1);
              }else{
                 if(mxr6 > 0 && q > Qcxr6){
                 double arg = (q - mxr6*Qcxr6)/Wxr6;
                 if(arg<10){
                   p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxr6*(q-Qcxr6));
                 }else
                 ABSORB;
                }
              }
           }

  if (((i==262) ||(i==263) || (i==264 ))){	
          if (ROreflect6 && strlen(ROreflect6))
              {
               p=Table_Value(roTable6, q, 1);
              }else{
                 if(mxrOW6 > 0 && q > QcxrOW6){
                   double arg = (q - mxrOW6*QcxrOW6)/WxrOW6;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxrOW6*(q-QcxrOW6));
                   }
                   else
                   ABSORB;
                  }
               }
             }

  if (((i==245) ||(i==246) || (i == 247 ) ) ){
          if (LIreflect6 && strlen(LIreflect6))
              {
               p=Table_Value(liTable6, q, 1);
              }else{
                 if(mxl6 > 0 && q > Qcxl6){
                   double arg = (q - mxl6*Qcxl6)/Wxl6;
                   if(arg<10){
                     p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxl6*(q-Qcxl6));
                   }else
                   ABSORB;
                }
               }
          }

  if (((i==265) || (i==266) || (i==267 ))){
         if (LOreflect6 && strlen(LOreflect6))
              {
               p=Table_Value(loTable6, q, 1);
              }else{
                 if(mxlOW6 > 0 && q > QcxlOW6){
                   double arg = (q - mxlOW6*QcxlOW6)/WxlOW6;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxlOW6*(q-QcxlOW6));
                   }
                   else
                   ABSORB;
                 }
               }
          }

  if (((i==248) ||(i==249) || (i == 250 ))){
	  if (UIreflect6 && strlen(UIreflect6))
              {
               p=Table_Value(uiTable6, q, 1);
              }else{
                 if(myu6 > 0 && q > Qcyu6){
                 double arg = (q - myu6*Qcyu6)/Wyu6;
                   if(arg<10){
                     p *= 0.5*(1.0-tanh(arg))*(1.0-alphayu6*(q-Qcyu6));
                   }else
                   ABSORB;
                 }
              }
            }

  if (((i==268) || (i==269) || (i==270 )) ){
	  if (UOreflect6 && strlen(UOreflect6))
              {
               p=Table_Value(uoTable6, q, 1);
              }else{
                 if(myuOW6 > 0 && q > QcyuOW6){
                   double arg = (q - myuOW6*QcyuOW6)/WyuOW6;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphayuOW6*(q-QcyuOW6));
                   }else
                   ABSORB;
                   }
               }
           }

  if (((i==251) ||(i==252) || (i == 253 ))){
          if (DIreflect6 && strlen(DIreflect6))
              {
               p=Table_Value(diTable6, q, 1);
              }else{
                 if(myd6 > 0 && q > Qcyd6){
                   double arg = (q - myd6*Qcyd6)/Wyd6;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphayd6*(q-Qcyd6));
                   }else
                   ABSORB;
                   }
               }
            }

   if (((i==271) || (i==272) || (i==273 )) ){
          if (DOreflect6 && strlen(DOreflect6))
              {
               p=Table_Value(doTable6, q, 1);
              }else{
                 if(mydOW6 > 0 && q > QcydOW6){
                   double arg = (q - mydOW6*QcydOW6)/WydOW6;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphaydOW6*(q-QcydOW6));
                   }else
                   ABSORB;
                   }
                 }
           }

 if (((i==282) ||(i==283) || (i == 284 ))){
          if (RIreflect7 && strlen(RIreflect7))
              {
               p=Table_Value(riTable7, q, 1);
              }else{
                 if(mxr7 > 0 && q > Qcxr7){
                 double arg = (q - mxr7*Qcxr7)/Wxr7;
                 if(arg<10){
                   p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxr7*(q-Qcxr7));
                 }else
                 ABSORB;
                }
              }
           }

  if (((i==302) ||(i==303) || (i==304 ))){	
          if (ROreflect7 && strlen(ROreflect7))
              {
               p=Table_Value(roTable7, q, 1);
              }else{
                 if(mxrOW7 > 0 && q > QcxrOW7){
                   double arg = (q - mxrOW7*QcxrOW7)/WxrOW7;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxrOW7*(q-QcxrOW7));
                   }
                   else
                   ABSORB;
                  }
               }
             }

  if (((i==285) ||(i==286) || (i == 287 ) ) ){
          if (LIreflect7 && strlen(LIreflect7))
              {
               p=Table_Value(liTable7, q, 1);
              }else{
                 if(mxl7 > 0 && q > Qcxl7){
                   double arg = (q - mxl7*Qcxl7)/Wxl7;
                   if(arg<10){
                     p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxl7*(q-Qcxl7));
                   }else
                   ABSORB;
                }
               }
          }

  if (((i==305) || (i==306) || (i==307 ))){
         if (LOreflect7 && strlen(LOreflect7))
              {
               p=Table_Value(loTable7, q, 1);
              }else{
                 if(mxlOW7 > 0 && q > QcxlOW7){
                   double arg = (q - mxlOW7*QcxlOW7)/WxlOW7;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxlOW7*(q-QcxlOW7));
                   }
                   else
                   ABSORB;
                 }
               }
          }

  if (((i==288) ||(i==289) || (i == 290 ))){
	  if (UIreflect7 && strlen(UIreflect7))
              {
               p=Table_Value(uiTable7, q, 1);
              }else{
                 if(myu7 > 0 && q > Qcyu7){
                 double arg = (q - myu7*Qcyu7)/Wyu7;
                   if(arg<10){
                     p *= 0.5*(1.0-tanh(arg))*(1.0-alphayu7*(q-Qcyu7));
                   }else
                   ABSORB;
                 }
              }
            }

  if (((i==308) || (i==309) || (i==310 )) ){
	  if (UOreflect7 && strlen(UOreflect7))
              {
               p=Table_Value(uoTable7, q, 1);
              }else{
                 if(myuOW7 > 0 && q > QcyuOW7){
                   double arg = (q - myuOW7*QcyuOW7)/WyuOW7;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphayuOW7*(q-QcyuOW7));
                   }else
                   ABSORB;
                   }
               }
           }

  if (((i==291) ||(i==292) || (i == 293 ))){
          if (DIreflect7 && strlen(DIreflect7))
              {
               p=Table_Value(diTable7, q, 1);
              }else{
                 if(myd7 > 0 && q > Qcyd7){
                   double arg = (q - myd7*Qcyd7)/Wyd7;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphayd7*(q-Qcyd7));
                   }else
                   ABSORB;
                   }
               }
            }

   if (((i==311) || (i==312) || (i==313 )) ){
          if (DOreflect7 && strlen(DOreflect7))
              {
               p=Table_Value(doTable7, q, 1);
              }else{
                 if(mydOW7 > 0 && q > QcydOW7){
                   double arg = (q - mydOW7*QcydOW7)/WydOW7;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphaydOW7*(q-QcydOW7));
                   }else
                   ABSORB;
                   }
                 }
           }


  if (((i==322) ||(i==323) || (i == 324 ))){
          if (RIreflect8 && strlen(RIreflect8))
              {
               p=Table_Value(riTable8, q, 1);
              }else{
                 if(mxr8 > 0 && q > Qcxr8){
                 double arg = (q - mxr8*Qcxr8)/Wxr8;
                 if(arg<10){
                   p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxr8*(q-Qcxr8));
                 }else
                 ABSORB;
                }
              }
           }

  if (((i==342) ||(i==343) || (i==344 ))){	
          if (ROreflect8 && strlen(ROreflect8))
              {
               p=Table_Value(roTable8, q, 1);
              }else{
                 if(mxrOW8 > 0 && q > QcxrOW8){
                   double arg = (q - mxrOW8*QcxrOW8)/WxrOW8;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxrOW8*(q-QcxrOW8));
                   }
                   else
                   ABSORB;
                  }
               }
             }

  if (((i==325) ||(i==326) || (i == 327 ) ) ){
          if (LIreflect8 && strlen(LIreflect8))
              {
               p=Table_Value(liTable8, q, 1);
              }else{
                 if(mxl8 > 0 && q > Qcxl8){
                   double arg = (q - mxl8*Qcxl8)/Wxl8;
                   if(arg<10){
                     p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxl8*(q-Qcxl8));
                   }else
                   ABSORB;
                }
               }
          }

  if (((i==345) || (i==346) || (i==347 ))){
         if (LOreflect8 && strlen(LOreflect8))
              {
               p=Table_Value(loTable8, q, 1);
              }else{
                 if(mxlOW8 > 0 && q > QcxlOW8){
                   double arg = (q - mxlOW8*QcxlOW8)/WxlOW8;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxlOW8*(q-QcxlOW8));
                   }
                   else
                   ABSORB;
                 }
               }
          }

  if (((i==328) ||(i==329) || (i == 330 ))){
	  if (UIreflect8 && strlen(UIreflect8))
              {
               p=Table_Value(uiTable8, q, 1);
              }else{
                 if(myu8 > 0 && q > Qcyu8){
                 double arg = (q - myu8*Qcyu8)/Wyu8;
                   if(arg<10){
                     p *= 0.5*(1.0-tanh(arg))*(1.0-alphayu8*(q-Qcyu8));
                   }else
                   ABSORB;
                 }
              }
            }

  if (((i==348) || (i==349) || (i==350 )) ){
	  if (UOreflect8 && strlen(UOreflect8))
              {
               p=Table_Value(uoTable8, q, 1);
              }else{
                 if(myuOW8 > 0 && q > QcyuOW8){
                   double arg = (q - myuOW8*QcyuOW8)/WyuOW8;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphayuOW8*(q-QcyuOW8));
                   }else
                   ABSORB;
                   }
               }
           }

  if (((i==331) ||(i==332) || (i == 333 ))){
          if (DIreflect8 && strlen(DIreflect8))
              {
               p=Table_Value(diTable8, q, 1);
              }else{
                 if(myd8 > 0 && q > Qcyd8){
                   double arg = (q - myd8*Qcyd8)/Wyd8;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphayd8*(q-Qcyd8));
                   }else
                   ABSORB;
                   }
               }
            }

   if (((i==351) || (i==352) || (i==353 )) ){
          if (DOreflect8 && strlen(DOreflect8))
              {
               p=Table_Value(doTable8, q, 1);
              }else{
                 if(mydOW8 > 0 && q > QcydOW8){
                   double arg = (q - mydOW8*QcydOW8)/WydOW8;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphaydOW8*(q-QcydOW8));
                   }else
                   ABSORB;
                   }
                 }
           }


if (((i==362) ||(i==363) || (i == 364 ))){
          if (RIreflect9 && strlen(RIreflect9))
              {
               p=Table_Value(riTable9, q, 1);
              }else{
                 if(mxr9 > 0 && q > Qcxr9){
                 double arg = (q - mxr9*Qcxr9)/Wxr9;
                 if(arg<10){
                   p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxr9*(q-Qcxr9));
                 }else
                 ABSORB;
                }
              }
           }

  if (((i==382) ||(i==383) || (i==384 ))){	
          if (ROreflect9 && strlen(ROreflect9))
              {
               p=Table_Value(roTable9, q, 1);
              }else{
                 if(mxrOW9 > 0 && q > QcxrOW9){
                   double arg = (q - mxrOW9*QcxrOW9)/WxrOW9;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxrOW9*(q-QcxrOW9));
                   }
                   else
                   ABSORB;
                  }
               }
             }

  if (((i==365) ||(i==366) || (i == 367 ) ) ){
          if (LIreflect9 && strlen(LIreflect9))
              {
               p=Table_Value(liTable9, q, 1);
              }else{
                 if(mxl9 > 0 && q > Qcxl9){
                   double arg = (q - mxl9*Qcxl9)/Wxl9;
                   if(arg<10){
                     p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxl9*(q-Qcxl9));
                   }else
                   ABSORB;
                }
               }
          }

  if (((i==385) || (i==386) || (i==387 ))){
         if (LOreflect9 && strlen(LOreflect9))
              {
               p=Table_Value(loTable9, q, 1);
              }else{
                 if(mxlOW9 > 0 && q > QcxlOW9){
                   double arg = (q - mxlOW9*QcxlOW9)/WxlOW9;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxlOW9*(q-QcxlOW9));
                   }
                   else
                   ABSORB;
                 }
               }
          }

  if (((i==368) ||(i==369) || (i == 370 ))){
	  if (UIreflect9 && strlen(UIreflect9))
              {
               p=Table_Value(uiTable9, q, 1);
              }else{
                 if(myu9 > 0 && q > Qcyu9){
                 double arg = (q - myu9*Qcyu9)/Wyu9;
                   if(arg<10){
                     p *= 0.5*(1.0-tanh(arg))*(1.0-alphayu9*(q-Qcyu9));
                   }else
                   ABSORB;
                 }
              }
            }

  if (((i==388) || (i==389) || (i==390 )) ){
	  if (UOreflect9 && strlen(UOreflect9))
              {
               p=Table_Value(uoTable9, q, 1);
              }else{
                 if(myuOW9 > 0 && q > QcyuOW9){
                   double arg = (q - myuOW9*QcyuOW9)/WyuOW9;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphayuOW9*(q-QcyuOW9));
                   }else
                   ABSORB;
                   }
               }
           }

  if (((i==371) ||(i==372) || (i == 373 ))){
          if (DIreflect9 && strlen(DIreflect9))
              {
               p=Table_Value(diTable9, q, 1);
              }else{
                 if(myd9 > 0 && q > Qcyd9){
                   double arg = (q - myd9*Qcyd9)/Wyd9;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphayd9*(q-Qcyd9));
                   }else
                   ABSORB;
                   }
               }
            }

   if (((i==391) || (i==392) || (i==393 )) ){
          if (DOreflect9 && strlen(DOreflect9))
              {
               p=Table_Value(doTable9, q, 1);
              }else{
                 if(mydOW9 > 0 && q > QcydOW9){
                   double arg = (q - mydOW9*QcydOW9)/WydOW9;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphaydOW9*(q-QcydOW9));
                   }else
                   ABSORB;
                   }
                 }
           }

  if (((i==402) ||(i==403) || (i == 404 ))){
          if (RIreflect10 && strlen(RIreflect10))
              {
               p=Table_Value(riTable10, q, 1);
              }else{
                 if(mxr10 > 0 && q > Qcxr10){
                 double arg = (q - mxr10*Qcxr10)/Wxr10;
                 if(arg<10){
                   p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxr10*(q-Qcxr10));
                 }else
                 ABSORB;
                }
              }
           }

  if (((i==422) ||(i==423) || (i==424 ))){	
          if (ROreflect10 && strlen(ROreflect10))
              {
               p=Table_Value(roTable10, q, 1);
              }else{
                 if(mxrOW10 > 0 && q > QcxrOW10){
                   double arg = (q - mxrOW10*QcxrOW10)/WxrOW10;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxrOW10*(q-QcxrOW10));
                   }
                   else
                   ABSORB;
                  }
               }
             }

  if (((i==405) ||(i==406) || (i == 407 ) ) ){
          if (LIreflect10 && strlen(LIreflect10))
              {
               p=Table_Value(liTable10, q, 1);
              }else{
                 if(mxl10 > 0 && q > Qcxl10){
                   double arg = (q - mxl10*Qcxl10)/Wxl10;
                   if(arg<10){
                     p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxl10*(q-Qcxl10));
                   }else
                   ABSORB;
                }
               }
          }

  if (((i==425) || (i==426) || (i==427 ))){
         if (LOreflect10 && strlen(LOreflect10))
              {
               p=Table_Value(loTable10, q, 1);
              }else{
                 if(mxlOW10 > 0 && q > QcxlOW10){
                   double arg = (q - mxlOW10*QcxlOW10)/WxlOW10;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphaxlOW10*(q-QcxlOW10));
                   }
                   else
                   ABSORB;
                 }
               }
          }

  if (((i==408) ||(i==409) || (i == 410 ))){
	  if (UIreflect10 && strlen(UIreflect10))
              {
               p=Table_Value(uiTable10, q, 1);
              }else{
                 if(myu10 > 0 && q > Qcyu10){
                 double arg = (q - myu10*Qcyu10)/Wyu10;
                   if(arg<10){
                     p *= 0.5*(1.0-tanh(arg))*(1.0-alphayu10*(q-Qcyu10));
                   }else
                   ABSORB;
                 }
              }
            }

  if (((i==428) || (i==429) || (i==430 )) ){
	  if (UOreflect10 && strlen(UOreflect10))
              {
               p=Table_Value(uoTable10, q, 1);
              }else{
                 if(myuOW10 > 0 && q > QcyuOW10){
                   double arg = (q - myuOW10*QcyuOW10)/WyuOW10;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphayuOW10*(q-QcyuOW10));
                   }else
                   ABSORB;
                   }
               }
           }

  if (((i==411) ||(i==412) || (i == 413 ))){
          if (DIreflect10 && strlen(DIreflect10))
              {
               p=Table_Value(diTable10, q, 1);
              }else{
                 if(myd10 > 0 && q > Qcyd10){
                   double arg = (q - myd10*Qcyd10)/Wyd10;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphayd10*(q-Qcyd10));
                   }else
                   ABSORB;
                   }
               }
            }

   if (((i==431) || (i==432) || (i==433 )) ){
          if (DOreflect10 && strlen(DOreflect10))
              {
               p=Table_Value(doTable10, q, 1);
              }else{
                 if(mydOW10 > 0 && q > QcydOW10){
                   double arg = (q - mydOW10*QcydOW10)/WydOW10;
                   if(arg<10){
                      p *= 0.5*(1.0-tanh(arg))*(1.0-alphaydOW10*(q-QcydOW10));
                   }else
                   ABSORB;
                   }
                 }
           }


  p *= R0;
  SCATTER;

} while (z<l);												/* repeat the interaction loop untill the neutron pass the end of guide */


  if(x <= -w2r && x >= -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;

  if(x <= -w2r3 && x >= -w2rwt3 && y <= mru23*x+nru23 && y >= mrd23*x+nrd23 && mxr3!=-1 && mxrOW3!=-1)
      ABSORB;
  if(x >=  w2l3 && x <=  w2lwt3 && y <= mlu23*x+nlu23 && y >= mld23*x+nld23 && mxl3!=-1 && mxlOW3!=-1) 
      ABSORB;
  if(y <= -h2d3 && y >= -h2dwt3 && x <= (y-nld23)/mld23 && x>= (y-nrd23)/mrd23 && myd3!=-1 && mydOW3!=-1) 
      ABSORB; 
  if(y >=  h2u3 && y <=  h2uwt3 && x <= (y-nlu23)/mlu23 && x>= (y-nru23)/mru23 && myu3!=-1 && myuOW3!=-1)
      ABSORB;

if(x <= -w2r4 && x >= -w2rwt4 && y <= mru24*x+nru24 && y >= mrd24*x+nrd24 && mxr4!=-1 && mxrOW4!=-1)
      ABSORB;
  if(x >=  w2l4 && x <=  w2lwt4 && y <= mlu24*x+nlu24 && y >= mld24*x+nld24 && mxl4!=-1 && mxlOW4!=-1) 
      ABSORB;
  if(y <= -h2d4 && y >= -h2dwt4 && x <= (y-nld24)/mld24 && x>= (y-nrd24)/mrd24 && myd4!=-1 && mydOW4!=-1) 
      ABSORB; 
  if(y >=  h2u4 && y <=  h2uwt4 && x <= (y-nlu24)/mlu24 && x>= (y-nru24)/mru24 && myu4!=-1 && myuOW4!=-1)
      ABSORB;

  if(x <= -w2r5 && x >= -w2rwt5 && y <= mru25*x+nru25 && y >= mrd25*x+nrd25 && mxr5!=-1 && mxrOW5!=-1)
      ABSORB;
  if(x >=  w2l5 && x <=  w2lwt5 && y <= mlu25*x+nlu25 && y >= mld25*x+nld25 && mxl5!=-1 && mxlOW5!=-1) 
      ABSORB;
  if(y <= -h2d5 && y >= -h2dwt5 && x <= (y-nld25)/mld25 && x>= (y-nrd25)/mrd25 && myd5!=-1 && mydOW5!=-1) 
      ABSORB; 
  if(y >=  h2u5 && y <=  h2uwt5 && x <= (y-nlu25)/mlu25 && x>= (y-nru25)/mru25 && myu5!=-1 && myuOW5!=-1)
      ABSORB;


  if(x <= -w2r6 && x >= -w2rwt6 && y <= mru26*x+nru26 && y >= mrd26*x+nrd26 && mxr6!=-1 && mxrOW6!=-1)
      ABSORB;
  if(x >=  w2l6 && x <=  w2lwt6 && y <= mlu26*x+nlu26 && y >= mld26*x+nld26 && mxl6!=-1 && mxlOW6!=-1) 
      ABSORB;
  if(y <= -h2d6 && y >= -h2dwt6 && x <= (y-nld26)/mld26 && x>= (y-nrd26)/mrd26 && myd6!=-1 && mydOW6!=-1) 
      ABSORB; 
  if(y >=  h2u6 && y <=  h2uwt6 && x <= (y-nlu26)/mlu26 && x>= (y-nru26)/mru26 && myu6!=-1 && myuOW6!=-1)
      ABSORB;

  if(x <= -w2r7 && x >= -w2rwt7 && y <= mru27*x+nru27 && y >= mrd27*x+nrd27 && mxr7!=-1 && mxrOW7!=-1)
      ABSORB;
  if(x >=  w2l7 && x <=  w2lwt7 && y <= mlu27*x+nlu27 && y >= mld27*x+nld27 && mxl7!=-1 && mxlOW7!=-1) 
      ABSORB;
  if(y <= -h2d7 && y >= -h2dwt7 && x <= (y-nld27)/mld27 && x>= (y-nrd27)/mrd27 && myd7!=-1 && mydOW7!=-1) 
      ABSORB; 
  if(y >=  h2u7 && y <=  h2uwt7 && x <= (y-nlu27)/mlu27 && x>= (y-nru27)/mru27 && myu7!=-1 && myuOW7!=-1)
      ABSORB;

  if(x <= -w2r8 && x >= -w2rwt8 && y <= mru28*x+nru28 && y >= mrd28*x+nrd28 && mxr8!=-1 && mxrOW8!=-1)
      ABSORB;
  if(x >=  w2l8 && x <=  w2lwt8 && y <= mlu28*x+nlu28 && y >= mld28*x+nld28 && mxl8!=-1 && mxlOW8!=-1) 
      ABSORB;
  if(y <= -h2d8 && y >= -h2dwt8 && x <= (y-nld28)/mld28 && x>= (y-nrd28)/mrd28 && myd8!=-1 && mydOW8!=-1) 
      ABSORB; 
  if(y >=  h2u8 && y <=  h2uwt8 && x <= (y-nlu28)/mlu28 && x>= (y-nru28)/mru28 && myu8!=-1 && myuOW8!=-1)
      ABSORB;

  if(x <= -w2r9 && x >= -w2rwt9 && y <= mru29*x+nru29 && y >= mrd29*x+nrd29 && mxr9!=-1 && mxrOW9!=-1)
      ABSORB;
  if(x >=  w2l9 && x <=  w2lwt9 && y <= mlu29*x+nlu29 && y >= mld29*x+nld29 && mxl9!=-1 && mxlOW9!=-1) 
      ABSORB;
  if(y <= -h2d9 && y >= -h2dwt9 && x <= (y-nld29)/mld29 && x>= (y-nrd29)/mrd29 && myd9!=-1 && mydOW9!=-1) 
      ABSORB; 
  if(y >=  h2u9 && y <=  h2uwt9 && x <= (y-nlu29)/mlu29 && x>= (y-nru29)/mru29 && myu9!=-1 && myuOW9!=-1)
      ABSORB;

  if(x <= -w2r10 && x >= -w2rwt10 && y <= mru210*x+nru210 && y >= mrd210*x+nrd210 && mxr10!=-1 && mxrOW10!=-1)
      ABSORB;
  if(x >=  w2l10 && x <=  w2lwt10 && y <= mlu210*x+nlu210 && y >= mld210*x+nld210 && mxl10!=-1 && mxlOW10!=-1) 
      ABSORB;
  if(y <= -h2d10 && y >= -h2dwt10 && x <= (y-nld210)/mld210 && x>= (y-nrd210)/mrd210 && myd10!=-1 && mydOW10!=-1) 
      ABSORB; 
  if(y >=  h2u10 && y <=  h2uwt10 && x <= (y-nlu210)/mlu210 && x>= (y-nru210)/mru210 && myu10!=-1 && myuOW10!=-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;

  double x13,y13,x23,y23,z13,z0wr3,z0wl3,z0hu3,z0hd3,xwt3,ywt3,x1wt3,y1wt3;
  double mr3,ml3,mu3,md3,nr13,nl13,nu13,nd13,nr23,nl23,nu23,nd23;
  double lbwl3,lbwr3,lbhu3,lbhd3;

  double x14,y14,x24,y24,z14,z0wr4,z0wl4,z0hu4,z0hd4,xwt4,ywt4,x1wt4,y1wt4;
  double mr4,ml4,mu4,md4,nr14,nl14,nu14,nd14,nr24,nl24,nu24,nd24;
  double lbwl4,lbwr4,lbhu4,lbhd4;

  double x15,y15,x25,y25,z15,z0wr5,z0wl5,z0hu5,z0hd5,xwt5,ywt5,x1wt5,y1wt5;
  double mr5,ml5,mu5,md5,nr15,nl15,nu15,nd15,nr25,nl25,nu25,nd25;
  double lbwl5,lbwr5,lbhu5,lbhd5;

  double x16,y16,x26,y26,z16,z0wr6,z0wl6,z0hu6,z0hd6,xwt6,ywt6,x1wt6,y1wt6;
  double mr6,ml6,mu6,md6,nr16,nl16,nu16,nd16,nr26,nl26,nu26,nd26;
  double lbwl6,lbwr6,lbhu6,lbhd6;

  double x17,y17,x27,y27,z17,z0wr7,z0wl7,z0hu7,z0hd7,xwt7,ywt7,x1wt7,y1wt7;
  double mr7,ml7,mu7,md7,nr17,nl17,nu17,nd17,nr27,nl27,nu27,nd27;
  double lbwl7,lbwr7,lbhu7,lbhd7;

  double x18,y18,x28,y28,z18,z0wr8,z0wl8,z0hu8,z0hd8,xwt8,ywt8,x1wt8,y1wt8;
  double mr8,ml8,mu8,md8,nr18,nl18,nu18,nd18,nr28,nl28,nu28,nd28;
  double lbwl8,lbwr8,lbhu8,lbhd8;

  double x19,y19,x29,y29,z19,z0wr9,z0wl9,z0hu9,z0hd9,xwt9,ywt9,x1wt9,y1wt9;
  double mr9,ml9,mu9,md9,nr19,nl19,nu19,nd19,nr29,nl29,nu29,nd29;
  double lbwl9,lbwr9,lbhu9,lbhd9;

  double x110,y110,x210,y210,z110,z0wr10,z0wl10,z0hu10,z0hd10,xwt10,ywt10,x1wt10,y1wt10;
  double mr10,ml10,mu10,md10,nr110,nl110,nu110,nd110,nr210,nl210,nu210,nd210;
  double lbwl10,lbwr10,lbhu10,lbhd10;

  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;

  lbwr3=linwr3+l+loutwr3;
  lbwl3=linwl3+l+loutwl3;
  lbhu3=linhu3+l+louthu3;
  lbhd3=linhd3+l+louthd3;

  lbwr4=linwr4+l+loutwr4;
  lbwl4=linwl4+l+loutwl4;
  lbhu4=linhu4+l+louthu4;
  lbhd4=linhd4+l+louthd4;

  lbwr5=linwr5+l+loutwr5;
  lbwl5=linwl5+l+loutwl5;
  lbhu5=linhu5+l+louthu5;
  lbhd5=linhd5+l+louthd5;

  lbwr6=linwr6+l+loutwr6;
  lbwl6=linwl6+l+loutwl6;
  lbhu6=linhu6+l+louthu6;
  lbhd6=linhd6+l+louthd6;

  lbwr7=linwr7+l+loutwr7;
  lbwl7=linwl7+l+loutwl7;
  lbhu7=linhu7+l+louthu7;
  lbhd7=linhd7+l+louthd7;

  lbwr8=linwr8+l+loutwr8;
  lbwl8=linwl8+l+loutwl8;
  lbhu8=linhu8+l+louthu8;
  lbhd8=linhd8+l+louthd8;

  lbwr9=linwr9+l+loutwr9;
  lbwl9=linwl9+l+loutwl9;
  lbhu9=linhu9+l+louthu9;
  lbhd9=linhd9+l+louthd9;

  lbwr10=linwr10+l+loutwr10;
  lbwl10=linwl10+l+loutwl10;
  lbhu10=linhu10+l+louthu10;
  lbhd10=linhd10+l+louthd10;

  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<imax;i++){											/* calculation of the points for the INNER LEFT BOTTOM line */
   z=i*l/imax;
   z1=(i+1)*l/imax;
  if(linwl==0 && loutwl == 0)
   {
     x1=ml*z+nl1;
     x2=ml*z1+nl1;
   }else{
      if(linwl!=0 && loutwl != 0)
      {
      x1=bwl*sqrt(1-((z0wl+z)*(z0wl+z))/(awl*awl));
      x2=bwl*sqrt(1-((z0wl+z1)*(z0wl+z1))/(awl*awl));
      }else{
      x1=sqrt((z-pbwl)/-pawl);
      x2=sqrt((z1-pbwl)/-pawl);
      }
   }
  if(linhd==0 && louthd==0)
   {
     y1=md*z+nd1;
     y2=md*z1+nd1;
    }else{
      if(linhd!=0 && louthd!=0)
      {
      y1=-bhd*sqrt(1-((z0hd+z)*(z0hd+z))/(ahd*ahd));
      y2=-bhd*sqrt(1-((z0hd+z1)*(z0hd+z1))/(ahd*ahd));
      }else{
      y1=-sqrt((z-pbhd)/-pahd);
      y2=-sqrt((z1-pbhd)/-pahd);
      }
   }
  if(mxl!=-1 || myd!=-1)line((double)x1, (double)y1, (double)z, (double)x2, (double)y2, (double)z1); 
 }

for(i=0;i<imax;i++){											/* calculation of the points for the INNER RIGHT BOTTOM line */
  z=i*l/imax;
  z1=(i+1)*l/imax;
  if(linwr==0 && loutwr==0)
  {
    x1=mr*z+nr1;
    x2=mr*z1+nr1;
  }else{
    if(linwr!=0 && loutwr!=0)
    {
    x1=-bwr*sqrt(1-((z0wr+z)*(z0wr+z))/(awr*awr));
    x2=-bwr*sqrt(1-((z0wr+z1)*(z0wr+z1))/(awr*awr));
    }else{
    x1=-sqrt((z-pbwr)/-pawr);
    x2=-sqrt((z1-pbwr)/-pawr);
    }
  }
  if(linhd==0 && louthd==0)
  {
    y1=md*z+nd1;
    y2=md*z1+nd1;
  }else{
    if(linhd!=0 && louthd!=0)
    {
    y1=-bhd*sqrt(1-((z0hd+z)*(z0hd+z))/(ahd*ahd));
    y2=-bhd*sqrt(1-((z0hd+z1)*(z0hd+z1))/(ahd*ahd));
    }else{
    y1=-sqrt((z-pbhd)/-pahd);
    y2=-sqrt((z1-pbhd)/-pahd);
    }
  }
  if(mxr!=-1 || myd!=-1) line((double)x1, (double)y1, (double)z, (double)x2, (double)y2, (double)z1); 
}


for(i=0;i<imax;i++){											/* calculation of the points for the INNER RIGHT TOP line */
  z=i*l/imax;
  z1=(i+1)*l/imax;
  if(linwr==0 && loutwr==0)
  {
    x1=mr*z+nr1;
    x2=mr*z1+nr1;
   }else{
     if(linwr!=0 && loutwr!=0){
     x1=-bwr*sqrt(1-((z0wr+z)*(z0wr+z))/(awr*awr));
     x2=-bwr*sqrt(1-((z0wr+z1)*(z0wr+z1))/(awr*awr));
     }else{
     x1=-sqrt((z-pbwr)/-pawr);
     x2=-sqrt((z1-pbwr)/-pawr);
     }
   }
   if(linhu==0 && louthu==0)
  {
    y1=mu*z+nu1;
    y2=mu*z1+nu1;
  }else{
    if(linhu!=0 && louthu!=0)
    {
    y1=bhu*sqrt(1-((z0hu+z)*(z0hu+z))/(ahu*ahu));
    y2=bhu*sqrt(1-((z0hu+z1)*(z0hu+z1))/(ahu*ahu));
    }else{
    y1=sqrt((z-pbhu)/-pahu);
    y2=sqrt((z1-pbhu)/-pahu);
    }
  }
  if(mxr!=-1 || myu!=-1)line((double)x1, (double)y1, (double)z, (double)x2, (double)y2, (double)z1); 
}

for(i=0;i<imax;i++){											/* calculation of the points for the INNER LEFT TOP line */
  z=i*l/imax;
  z1=(i+1)*l/imax;
  if(linwl==0 && loutwl==0)
  {
    x1=ml*z+nl1;
    x2=ml*z1+nl1;
   }else{
     if(linwl!=0 && loutwl!=0)
     {
     x1=bwl*sqrt(1-((z0wl+z)*(z0wl+z))/(awl*awl));
     x2=bwl*sqrt(1-((z0wl+z1)*(z0wl+z1))/(awl*awl));
     }else{
     x1=sqrt((z-pbwl)/-pawl);
     x2=sqrt((z1-pbwl)/-pawl);
     }
   }
   if(linhu==0 && louthu==0)
  {
    y1=mu*z+nu1;
    y2=mu*z1+nu1;
  }else{
    if(linhu!=0 && louthu!=0)
    {
    y1=bhu*sqrt(1-((z0hu+z)*(z0hu+z))/(ahu*ahu));
    y2=bhu*sqrt(1-((z0hu+z1)*(z0hu+z1))/(ahu*ahu));
    }else{
    y1=sqrt((z-pbhu)/-pahu);
    y2=sqrt((z1-pbhu)/-pahu);
    }
  }
  if(mxl!=-1 || myu!=-1)line((double)x1, (double)y1, (double)z, (double)x2, (double)y2, (double)z1); 
}																	/* END INNER LINES*/


for(i=0;i<imax;i++){											/* calculation of the points for the OUTER LEFT BOTTOM line */
   z=i*l/imax;
   z1=(i+1)*l/imax;
  if(linwl==0 && loutwl == 0)
   {
     xwt=ml*z+nl2;
     x1wt=ml*z1+nl2;
   }else{
      if(linwl!=0 && loutwl != 0)
      {
      xwt=bwlwt*sqrt(1-((z0wl+z)*(z0wl+z))/(awlwt*awlwt));
      x1wt=bwlwt*sqrt(1-((z0wl+z1)*(z0wl+z1))/(awlwt*awlwt));
      }else{
      xwt=sqrt((z-pbwlwt)/-pawlwt);
      x1wt=sqrt((z1-pbwlwt)/-pawlwt);
      }
   }
  if(linhd==0 && louthd==0)
   {
     ywt=md*z+nd2;
     y1wt=md*z1+nd2;
    }else{
      if(linhd!=0 && louthd!=0)
      {
      ywt=-bhdwt*sqrt(1-((z0hd+z)*(z0hd+z))/(ahdwt*ahdwt));
      y1wt=-bhdwt*sqrt(1-((z0hd+z1)*(z0hd+z1))/(ahdwt*ahdwt));
      }else{
      ywt=-sqrt((z-pbhdwt)/-pahdwt);
      y1wt=-sqrt((z1-pbhdwt)/-pahdwt);
      }
   }
  if(mxlOW!=-1 || mydOW!=-1)line((double)xwt, (double)ywt, (double)z, (double)x1wt, (double)y1wt, (double)z1); 
 }

for(i=0;i<imax;i++){											/* calculation of the points for the OUTER RIGHT BOTTOM line */
  z=i*l/imax;
  z1=(i+1)*l/imax;
  if(linwr==0 && loutwr==0)
  {
    xwt=mr*z+nr2;
    x1wt=mr*z1+nr2;
  }else{
    if(linwr!=0 && loutwr!=0)
    {
    xwt=-bwrwt*sqrt(1-((z0wr+z)*(z0wr+z))/(awrwt*awrwt));
    x1wt=-bwrwt*sqrt(1-((z0wr+z1)*(z0wr+z1))/(awrwt*awrwt));
    }else{
    xwt=-sqrt((z-pbwrwt)/-pawrwt);
    x1wt=-sqrt((z1-pbwrwt)/-pawrwt);
    }
  }
  if(linhd==0 && louthd==0)
  {
    ywt=md*z+nd2;
    y1wt=md*z1+nd2;
  }else{
    if(linhd!=0 && louthd!=0)
    {
    ywt=-bhdwt*sqrt(1-((z0hd+z)*(z0hd+z))/(ahdwt*ahdwt));
    y1wt=-bhdwt*sqrt(1-((z0hd+z1)*(z0hd+z1))/(ahdwt*ahdwt));
    }else{
    ywt=-sqrt((z-pbhdwt)/-pahdwt);
    y1wt=-sqrt((z1-pbhdwt)/-pahdwt);
    }
  }
  if(mxrOW!=-1 || mydOW!=-1) line((double)xwt, (double)ywt, (double)z, (double)x1wt, (double)y1wt, (double)z1); 
}


for(i=0;i<imax;i++){											/* calculation of the points for the OUTER RIGHT TOP line */
  z=i*l/imax;
  z1=(i+1)*l/imax;
  if(linwr==0 && loutwr==0)
  {
    xwt=mr*z+nr2;
    x1wt=mr*z1+nr2;
   }else{
     if(linwr!=0 && loutwr!=0){
     xwt=-bwrwt*sqrt(1-((z0wr+z)*(z0wr+z))/(awrwt*awrwt));
     x1wt=-bwrwt*sqrt(1-((z0wr+z1)*(z0wr+z1))/(awrwt*awrwt));
     }else{
     xwt=-sqrt((z-pbwrwt)/-pawrwt);
     x1wt=-sqrt((z1-pbwrwt)/-pawrwt);
     }
   }
   if(linhu==0 && louthu==0)
  {
    ywt=mu*z+nu2;
    y1wt=mu*z1+nu2;
  }else{
    if(linhu!=0 && louthu!=0)
    {
    ywt=bhuwt*sqrt(1-((z0hu+z)*(z0hu+z))/(ahuwt*ahuwt));
    y1wt=bhuwt*sqrt(1-((z0hu+z1)*(z0hu+z1))/(ahuwt*ahuwt));
    }else{
    ywt=sqrt((z-pbhuwt)/-pahuwt);
    y1wt=sqrt((z1-pbhuwt)/-pahuwt);
    }
  }
   if(mxrOW!=-1 || myuOW!=-1)line((double)xwt, (double)ywt, (double)z, (double)x1wt, (double)y1wt, (double)z1); 
}

for(i=0;i<imax;i++){											/* calculation of the points for the OUTER LEFT TOP line */
  z=i*l/imax;
  z1=(i+1)*l/imax;
  if(linwl==0 && loutwl==0)
  {
    xwt=ml*z+nl2;
    x1wt=ml*z1+nl2;
   }else{
     if(linwl!=0 && loutwl!=0)
     {
     xwt=bwlwt*sqrt(1-((z0wl+z)*(z0wl+z))/(awlwt*awlwt));
     x1wt=bwlwt*sqrt(1-((z0wl+z1)*(z0wl+z1))/(awlwt*awlwt));
     }else{
     xwt=sqrt((z-pbwlwt)/-pawlwt);
     x1wt=sqrt((z1-pbwlwt)/-pawlwt);
     }
   }
   if(linhu==0 && louthu==0)
  {
    ywt=mu*z+nu2;
    y1wt=mu*z1+nu2;
  }else{
    if(linhu!=0 && louthu!=0)
    {
    ywt=bhuwt*sqrt(1-((z0hu+z)*(z0hu+z))/(ahuwt*ahuwt));
    y1wt=bhuwt*sqrt(1-((z0hu+z1)*(z0hu+z1))/(ahuwt*ahuwt));
    }else{
    ywt=sqrt((z-pbhuwt)/-pahuwt);
    y1wt=sqrt((z1-pbhuwt)/-pahuwt);
    }
  }
  if(mxlOW!=-1 || myuOW!=-1)line((double)xwt, (double)ywt, (double)z, (double)x1wt, (double)y1wt, (double)z1); 
}



  if (linwr1==0 && loutwr1==0){
   mr1=(-w2r1+w1r1)/l;
   nr11=-w1r1;
   nr21=-(w1rwt1);
   }


if (linwl1==0 && loutwl1==0){
   ml1=(w2l1-w1l1)/l;
   nl11=w1l1;
   nl21=(w1lwt1);
   }


if (linhu1 == 0 && louthu1==0) 
  {
   mu1=(h2u1-h1u1)/l;
   nu11=h1u1;
   nu21=(h1uwt1);
  }


if (linhd1 == 0 && louthd1==0) 
  {
   md1=(-h2d1+h1d1)/l;
   nd11=-h1d1;
   nd21=-(h1dwt1);
  }

  z0wr1=(linwr1-l-loutwr1)/2.0;
  z0wl1=(linwl1-l-loutwl1)/2.0;
  z0hu1=lbhu1/2.0-l-louthu1;
  z0hd1=lbhd1/2.0-l-louthd1;

  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(myd1!=-1) line(w1l1, -h1d1, 0.0, -w1r1, -h1d1, 0.0);							/* entrance window given by the INNER walls*/
  if(myu1!=-1)line(w1l1, h1u1, 0.0, -w1r1, h1u1, 0.0);
  if(mxl1!=-1)line(w1l1, -h1d1, 0.0, w1l1, h1u1, 0.0);
  if(mxr1!=-1)line( -w1r1, h1u1, 0.0, -w1r1, -h1d1, 0.0);

  if(myd1!=-1)line(w2l1, -h2d1, l, -w2r1, -h2d1, l);								/* exit window given by the INNER walls*/
  if(myu1!=-1)line(w2l1, h2u1,  l, -w2r1, h2u1, l);
  if(mxl1!=-1)line(w2l1, -h2d1, l, w2l1, h2u1, l);
  if(mxr1!=-1)line( -w2r1, -h2d1,  l, -w2r1, h2u1, l);

  if(mydOW1!=-1) line((w1lwt1), -(h1dwt1), 0.0, -(w1rwt1), -(h1dwt1), 0.0);					/* entrance window given by the OUTER walls */
  if(myuOW1!=-1)line((w1lwt1), (h1uwt1), 0.0, -(w1rwt1), (h1uwt1), 0.0);
  if(mxlOW1!=-1)line((w1lwt1), -(h1dwt1), 0.0, (w1lwt1), (h1uwt1), 0.0);
  if(mxrOW1!=-1)line( -(w1rwt1), (h1uwt1), 0.0, -(w1rwt1), -(h1dwt1), 0.0);

  if(mydOW1!=-1)line((w2lwt1), -(h2dwt1), l, -(w2rwt1), -(h2dwt1), l);					/* exit windows given by the OUTER walls*/
  if(myuOW1!=-1)line((w2lwt1), (h2uwt1),  l, -(w2rwt1), (h2uwt1), l);
  if(mxlOW1!=-1)line((w2lwt1), -(h2dwt1), l, (w2lwt1), (h2uwt1), l);
  if(mxrOW1!=-1)line( -(w2rwt1), -(h2dwt1),  l, -(w2rwt1), (h2uwt1), l);

  if((myd1!=-1 && mydOW1!=-1) || (mxl1!=-1 && mxlOW1!=-1)) line(w1l1, -h1d1, 0.0, (w1lwt1), -(h1dwt1), 0.0);	/* corner connection lines for the entrance windows*/	
  if((myu1!=-1 && myuOW1!=-1) || (mxl1!=-1 && mxlOW1!=-1)) line(w1l1, h1u1, 0.0, (w1lwt1), (h1uwt1), 0.0);
  if((myd1!=-1 && mydOW1!=-1) || (mxr1!=-1 && mxrOW1!=-1)) line(-w1r1, -h1d1, 0.0,-(w1rwt1),  -(h1dwt1), 0.0);
  if((myu1!=-1 && myuOW1!=-1) || (mxr1!=-1 && mxrOW1!=-1)) line( -w1r1, h1u1, 0.0, -(w1rwt1), (h1uwt1), 0.0);

  if((myd1!=-1 && mydOW1!=-1) || (mxl1!=-1 && mxlOW1!=-1)) line(w2l1, -h2d1, l, (w2lwt1), -(h2dwt1), l);	/* corner connection lines for the exit windows*/
  if((myu1!=-1 && myuOW1!=-1) || (mxl1!=-1 && mxlOW1!=-1)) line(w2l1, h2u1, l, (w2lwt1), (h2uwt1), l);
  if((myd1!=-1 && mydOW1!=-1) || (mxr1!=-1 && mxrOW1!=-1)) line(-w2r1, -h2d1, l,-(w2rwt1),  -(h2dwt1), l);
  if((myu1!=-1 && myuOW1!=-1) || (mxr1!=-1 && mxrOW1!=-1)) line( -w2r1, h2u1, l, -(w2rwt1), (h2uwt1), l);

for(i=0;i<imax;i++){											/* calculation of the points for the INNER LEFT BOTTOM line */
   z=i*l/imax;
   z11=(i+1)*l/imax;
  if(linwl1==0 && loutwl1 == 0)
   {
     x11=ml1*z+nl11;
     x21=ml1*z11+nl11;
   }else{
      if(linwl1!=0 && loutwl1 != 0)
      {
      x11=bwl1*sqrt(1-((z0wl1+z)*(z0wl1+z))/(awl1*awl1));
      x21=bwl1*sqrt(1-((z0wl1+z11)*(z0wl1+z11))/(awl1*awl1));
      }else{
      x11=sqrt((z-pbwl1)/-pawl1);
      x21=sqrt((z11-pbwl1)/-pawl1);
      }
   }
  if(linhd1==0 && louthd1==0)
   {
     y11=md1*z+nd11;
     y21=md1*z11+nd11;
    }else{
      if(linhd1!=0 && louthd1!=0)
      {
      y11=-bhd1*sqrt(1-((z0hd1+z)*(z0hd1+z))/(ahd1*ahd1));
      y21=-bhd1*sqrt(1-((z0hd1+z11)*(z0hd1+z11))/(ahd1*ahd1));
      }else{
      y11=-sqrt((z-pbhd1)/-pahd1);
      y21=-sqrt((z11-pbhd1)/-pahd1);
      }
   }
  if(mxl1!=-1 || myd1!=-1)line((double)x11, (double)y11, (double)z, (double)x21, (double)y21, (double)z11); 
 }

for(i=0;i<imax;i++){											/* calculation of the points for the INNER RIGHT BOTTOM line */
  z=i*l/imax;
  z11=(i+1)*l/imax;
  if(linwr1==0 && loutwr1==0)
  {
    x11=mr1*z+nr11;
    x21=mr1*z11+nr11;
  }else{
    if(linwr1!=0 && loutwr1!=0)
    {
    x11=-bwr1*sqrt(1-((z0wr1+z)*(z0wr1+z))/(awr1*awr1));
    x21=-bwr1*sqrt(1-((z0wr1+z11)*(z0wr1+z11))/(awr1*awr1));
    }else{
    x11=-sqrt((z-pbwr1)/-pawr1);
    x21=-sqrt((z11-pbwr1)/-pawr1);
    }
  }
  if(linhd1==0 && louthd1==0)
  {
    y11=md1*z+nd11;
    y21=md1*z11+nd11;
  }else{
    if(linhd1!=0 && louthd1!=0)
    {
    y11=-bhd1*sqrt(1-((z0hd1+z)*(z0hd1+z))/(ahd1*ahd1));
    y21=-bhd1*sqrt(1-((z0hd1+z11)*(z0hd1+z11))/(ahd1*ahd1));
    }else{
    y11=-sqrt((z-pbhd1)/-pahd1);
    y21=-sqrt((z11-pbhd1)/-pahd1);
    }
  }
  if(mxr1!=-1 || myd1!=-1) line((double)x11, (double)y11, (double)z, (double)x21, (double)y21, (double)z11); 
}


for(i=0;i<imax;i++){											/* calculation of the points for the INNER RIGHT TOP line */
  z=i*l/imax;
  z11=(i+1)*l/imax;
  if(linwr1==0 && loutwr1==0)
  {
    x11=mr1*z+nr11;
    x21=mr1*z11+nr11;
   }else{
     if(linwr1!=0 && loutwr1!=0){
     x11=-bwr1*sqrt(1-((z0wr1+z)*(z0wr1+z))/(awr1*awr1));
     x21=-bwr1*sqrt(1-((z0wr1+z11)*(z0wr1+z11))/(awr1*awr1));
     }else{
     x11=-sqrt((z-pbwr1)/-pawr1);
     x21=-sqrt((z11-pbwr1)/-pawr1);
     }
   }
   if(linhu1==0 && louthu1==0)
  {
    y11=mu1*z+nu11;
    y21=mu1*z11+nu11;
  }else{
    if(linhu1!=0 && louthu1!=0)
    {
    y11=bhu1*sqrt(1-((z0hu1+z)*(z0hu1+z))/(ahu1*ahu1));
    y21=bhu1*sqrt(1-((z0hu1+z11)*(z0hu1+z11))/(ahu1*ahu1));
    }else{
    y11=sqrt((z-pbhu1)/-pahu1);
    y21=sqrt((z11-pbhu1)/-pahu1);
    }
  }
  if(mxr1!=-1 || myu1!=-1)line((double)x11, (double)y11, (double)z, (double)x21, (double)y21, (double)z11); 
}

for(i=0;i<imax;i++){											/* calculation of the points for the INNER LEFT TOP line */
  z=i*l/imax;
  z11=(i+1)*l/imax;
  if(linwl1==0 && loutwl1==0)
  {
    x11=ml1*z+nl11;
    x21=ml1*z11+nl11;
   }else{
     if(linwl1!=0 && loutwl1!=0)
     {
     x11=bwl1*sqrt(1-((z0wl1+z)*(z0wl1+z))/(awl1*awl1));
     x21=bwl1*sqrt(1-((z0wl1+z11)*(z0wl1+z11))/(awl1*awl1));
     }else{
     x11=sqrt((z-pbwl1)/-pawl1);
     x21=sqrt((z11-pbwl1)/-pawl1);
     }
   }
   if(linhu1==0 && louthu1==0)
  {
    y11=mu1*z+nu11;
    y21=mu1*z11+nu11;
  }else{
    if(linhu1!=0 && louthu1!=0)
    {
    y11=bhu1*sqrt(1-((z0hu1+z)*(z0hu1+z))/(ahu1*ahu1));
    y21=bhu1*sqrt(1-((z0hu1+z11)*(z0hu1+z11))/(ahu1*ahu1));
    }else{
    y11=sqrt((z-pbhu1)/-pahu1);
    y21=sqrt((z11-pbhu1)/-pahu1);
    }
  }
  if(mxl1!=-1 || myu1!=-1)line((double)x11, (double)y11, (double)z, (double)x21, (double)y21, (double)z11); 
}																	/* END INNER LINES*/


for(i=0;i<imax;i++){											/* calculation of the points for the OUTER LEFT BOTTOM line */
   z=i*l/imax;
   z11=(i+1)*l/imax;
  if(linwl1==0 && loutwl1 == 0)
   {
     xwt1=ml1*z+nl21;
     x1wt1=ml1*z11+nl21;
   }else{
      if(linwl1!=0 && loutwl1 != 0)
      {
      xwt1=bwlwt1*sqrt(1-((z0wl1+z)*(z0wl1+z))/(awlwt1*awlwt1));
      x1wt1=bwlwt1*sqrt(1-((z0wl1+z11)*(z0wl1+z11))/(awlwt1*awlwt1));
      }else{
      xwt1=sqrt((z-pbwlwt1)/-pawlwt1);
      x1wt1=sqrt((z11-pbwlwt1)/-pawlwt1);
      }
   }
  if(linhd1==0 && louthd1==0)
   {
     ywt1=md1*z+nd21;
     y1wt1=md1*z11+nd21;
    }else{
      if(linhd1!=0 && louthd1!=0)
      {
      ywt1=-bhdwt1*sqrt(1-((z0hd1+z)*(z0hd1+z))/(ahdwt1*ahdwt1));
      y1wt1=-bhdwt1*sqrt(1-((z0hd1+z11)*(z0hd1+z11))/(ahdwt1*ahdwt1));
      }else{
      ywt1=-sqrt((z-pbhdwt1)/-pahdwt1);
      y1wt1=-sqrt((z11-pbhdwt1)/-pahdwt1);
      }
   }
  if(mxlOW1!=-1 || mydOW1!=-1)line((double)xwt1, (double)ywt1, (double)z, (double)x1wt1, (double)y1wt1, (double)z11); 
 }

for(i=0;i<imax;i++){											/* calculation of the points for the OUTER RIGHT BOTTOM line */
  z=i*l/imax;
  z11=(i+1)*l/imax;
  if(linwr1==0 && loutwr1==0)
  {
    xwt1=mr1*z+nr21;
    x1wt1=mr1*z11+nr21;
  }else{
    if(linwr1!=0 && loutwr1!=0)
    {
    xwt1=-bwrwt1*sqrt(1-((z0wr1+z)*(z0wr1+z))/(awrwt1*awrwt1));
    x1wt1=-bwrwt1*sqrt(1-((z0wr1+z11)*(z0wr1+z11))/(awrwt1*awrwt1));
    }else{
    xwt1=-sqrt((z-pbwrwt1)/-pawrwt1);
    x1wt1=-sqrt((z11-pbwrwt1)/-pawrwt1);
    }
  }
  if(linhd1==0 && louthd1==0)
  {
    ywt1=md1*z+nd21;
    y1wt1=md1*z11+nd21;
  }else{
    if(linhd1!=0 && louthd1!=0)
    {
    ywt1=-bhdwt1*sqrt(1-((z0hd1+z)*(z0hd1+z))/(ahdwt1*ahdwt1));
    y1wt1=-bhdwt1*sqrt(1-((z0hd1+z11)*(z0hd1+z11))/(ahdwt1*ahdwt1));
    }else{
    ywt1=-sqrt((z-pbhdwt1)/-pahdwt1);
    y1wt1=-sqrt((z11-pbhdwt1)/-pahdwt1);
    }
  }
  if(mxrOW1!=-1 || mydOW1!=-1) line((double)xwt1, (double)ywt1, (double)z, (double)x1wt1, (double)y1wt1, (double)z11); 
}


for(i=0;i<imax;i++){											/* calculation of the points for the OUTER RIGHT TOP line */
  z=i*l/imax;
  z11=(i+1)*l/imax;
  if(linwr1==0 && loutwr1==0)
  {
    xwt1=mr1*z+nr21;
    x1wt1=mr1*z11+nr21;
   }else{
     if(linwr1!=0 && loutwr1!=0){
     xwt1=-bwrwt1*sqrt(1-((z0wr1+z)*(z0wr1+z))/(awrwt1*awrwt1));
     x1wt1=-bwrwt1*sqrt(1-((z0wr1+z11)*(z0wr1+z11))/(awrwt1*awrwt1));
     }else{
     xwt1=-sqrt((z-pbwrwt1)/-pawrwt1);
     x1wt1=-sqrt((z11-pbwrwt1)/-pawrwt1);
     }
   }
   if(linhu1==0 && louthu1==0)
  {
    ywt1=mu1*z+nu21;
    y1wt1=mu1*z11+nu21;
  }else{
    if(linhu1!=0 && louthu1!=0)
    {
    ywt1=bhuwt1*sqrt(1-((z0hu1+z)*(z0hu1+z))/(ahuwt1*ahuwt1));
    y1wt1=bhuwt1*sqrt(1-((z0hu1+z11)*(z0hu1+z11))/(ahuwt1*ahuwt1));
    }else{
    ywt1=sqrt((z-pbhuwt1)/-pahuwt1);
    y1wt1=sqrt((z11-pbhuwt1)/-pahuwt1);
    }
  }
   if(mxrOW1!=-1 || myuOW1!=-1)line((double)xwt1, (double)ywt1, (double)z, (double)x1wt1, (double)y1wt1, (double)z11); 
}

for(i=0;i<imax;i++){											/* calculation of the points for the OUTER LEFT TOP line */
  z=i*l/imax;
  z11=(i+1)*l/imax;
  if(linwl1==0 && loutwl1==0)
  {
    xwt1=ml1*z+nl21;
    x1wt1=ml1*z11+nl21;
   }else{
     if(linwl1!=0 && loutwl1!=0)
     {
     xwt1=bwlwt1*sqrt(1-((z0wl1+z)*(z0wl1+z))/(awlwt1*awlwt1));
     x1wt1=bwlwt1*sqrt(1-((z0wl1+z11)*(z0wl1+z11))/(awlwt1*awlwt1));
     }else{
     xwt1=sqrt((z-pbwlwt1)/-pawlwt1);
     x1wt1=sqrt((z11-pbwlwt1)/-pawlwt1);
     }
   }
   if(linhu1==0 && louthu1==0)
  {
    ywt1=mu1*z+nu21;
    y1wt1=mu1*z11+nu21;
  }else{
    if(linhu1!=0 && louthu1!=0)
    {
    ywt1=bhuwt1*sqrt(1-((z0hu1+z)*(z0hu1+z))/(ahuwt1*ahuwt1));
    y1wt1=bhuwt1*sqrt(1-((z0hu1+z11)*(z0hu1+z11))/(ahuwt1*ahuwt1));
    }else{
    ywt1=sqrt((z-pbhuwt1)/-pahuwt1);
    y1wt1=sqrt((z11-pbhuwt1)/-pahuwt1);
    }
  }
  if(mxlOW1!=-1 || myuOW1!=-1)line((double)xwt1, (double)ywt1, (double)z, (double)x1wt1, (double)y1wt1, (double)z11); 
}

 if (linwr2==0 && loutwr2==0){
   mr2=(-w2r2+w1r2)/l;
   nr12=-w1r2;
   nr22=-(w1rwt2);
   }


if (linwl2==0 && loutwl2==0){
   ml2=(w2l2-w1l2)/l;
   nl12=w1l2;
   nl22=(w1lwt2);
   }


if (linhu2 == 0 && louthu2==0) 
  {
   mu2=(h2u2-h1u2)/l;
   nu12=h1u2;
   nu22=(h1uwt2);
  }


if (linhd2 == 0 && louthd2==0) 
  {
   md2=(-h2d2+h1d2)/l;
   nd12=-h1d2;
   nd22=-(h1dwt2);
  }

  z0wr2=(linwr2-l-loutwr2)/2.0;
  z0wl2=(linwl2-l-loutwl2)/2.0;
  z0hu2=lbhu2/2.0-l-louthu2;
  z0hd2=lbhd2/2.0-l-louthd2;

  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(myd2!=-1) line(w1l2, -h1d2, 0.0, -w1r2, -h1d2, 0.0);							/* entrance window given by the INNER walls*/
  if(myu2!=-1)line(w1l2, h1u2, 0.0, -w1r2, h1u2, 0.0);
  if(mxl2!=-1)line(w1l2, -h1d2, 0.0, w1l2, h1u2, 0.0);
  if(mxr2!=-1)line( -w1r2, h1u2, 0.0, -w1r2, -h1d2, 0.0);

  if(myd2!=-1)line(w2l2, -h2d2, l, -w2r2, -h2d2, l);								/* exit window given by the INNER walls*/
  if(myu2!=-1)line(w2l2, h2u2,  l, -w2r2, h2u2, l);
  if(mxl2!=-1)line(w2l2, -h2d2, l, w2l2, h2u2, l);
  if(mxr2!=-1)line( -w2r2, -h2d2,  l, -w2r2, h2u2, l);

  if(mydOW2!=-1) line((w1lwt2), -(h1dwt2), 0.0, -(w1rwt2), -(h1dwt2), 0.0);					/* entrance window given by the OUTER walls */
  if(myuOW2!=-1)line((w1lwt2), (h1uwt2), 0.0, -(w1rwt2), (h1uwt2), 0.0);
  if(mxlOW2!=-1)line((w1lwt2), -(h1dwt2), 0.0, (w1lwt2), (h1uwt2), 0.0);
  if(mxrOW2!=-1)line( -(w1rwt2), (h1uwt2), 0.0, -(w1rwt2), -(h1dwt2), 0.0);

  if(mydOW2!=-1)line((w2lwt2), -(h2dwt2), l, -(w2rwt2), -(h2dwt2), l);					/* exit windows given by the OUTER walls*/
  if(myuOW2!=-1)line((w2lwt2), (h2uwt2),  l, -(w2rwt2), (h2uwt2), l);
  if(mxlOW2!=-1)line((w2lwt2), -(h2dwt2), l, (w2lwt2), (h2uwt2), l);
  if(mxrOW2!=-1)line( -(w2rwt2), -(h2dwt2),  l, -(w2rwt2), (h2uwt2), l);

  if((myd2!=-1 && mydOW2!=-1) || (mxl2!=-1 && mxlOW2!=-1)) line(w1l2, -h1d2, 0.0, (w1lwt2), -(h1dwt2), 0.0);	/* corner connection lines for the entrance windows*/	
  if((myu2!=-1 && myuOW2!=-1) || (mxl2!=-1 && mxlOW2!=-1)) line(w1l2, h1u2, 0.0, (w1lwt2), (h1uwt2), 0.0);
  if((myd2!=-1 && mydOW2!=-1) || (mxr2!=-1 && mxrOW2!=-1)) line(-w1r2, -h1d2, 0.0,-(w1rwt2),  -(h1dwt2), 0.0);
  if((myu2!=-1 && myuOW2!=-1) || (mxr2!=-1 && mxrOW2!=-1)) line( -w1r2, h1u2, 0.0, -(w1rwt2), (h1uwt2), 0.0);

  if((myd2!=-1 && mydOW2!=-1) || (mxl2!=-1 && mxlOW2!=-1)) line(w2l2, -h2d2, l, (w2lwt2), -(h2dwt2), l);	/* corner connection lines for the exit windows*/
  if((myu2!=-1 && myuOW2!=-1) || (mxl2!=-1 && mxlOW2!=-1)) line(w2l2, h2u2, l, (w2lwt2), (h2uwt2), l);
  if((myd2!=-1 && mydOW2!=-1) || (mxr2!=-1 && mxrOW2!=-1)) line(-w2r2, -h2d2, l,-(w2rwt2),  -(h2dwt2), l);
  if((myu2!=-1 && myuOW2!=-1) || (mxr2!=-1 && mxrOW2!=-1)) line( -w2r2, h2u2, l, -(w2rwt2), (h2uwt2), l);

for(i=0;i<imax;i++){											/* calculation of the points for the INNER LEFT BOTTOM line */
   z=i*l/imax;
   z12=(i+1)*l/imax;
  if(linwl2==0 && loutwl2 == 0)
   {
     x12=ml2*z+nl12;
     x22=ml2*z12+nl12;
   }else{
      if(linwl2!=0 && loutwl2 != 0)
      {
      x12=bwl2*sqrt(1-((z0wl2+z)*(z0wl2+z))/(awl2*awl2));
      x22=bwl2*sqrt(1-((z0wl2+z12)*(z0wl2+z12))/(awl2*awl2));
      }else{
      x12=sqrt((z-pbwl2)/-pawl2);
      x22=sqrt((z12-pbwl2)/-pawl2);
      }
   }
  if(linhd2==0 && louthd2==0)
   {
     y12=md2*z+nd12;
     y22=md2*z12+nd12;
    }else{
      if(linhd2!=0 && louthd2!=0)
      {
      y12=-bhd2*sqrt(1-((z0hd2+z)*(z0hd2+z))/(ahd2*ahd2));
      y22=-bhd2*sqrt(1-((z0hd2+z12)*(z0hd2+z12))/(ahd2*ahd2));
      }else{
      y12=-sqrt((z-pbhd2)/-pahd2);
      y22=-sqrt((z12-pbhd2)/-pahd2);
      }
   }
  if(mxl2!=-1 || myd2!=-1)line((double)x12, (double)y12, (double)z, (double)x22, (double)y22, (double)z12); 
 }

for(i=0;i<imax;i++){											/* calculation of the points for the INNER RIGHT BOTTOM line */
  z=i*l/imax;
  z12=(i+1)*l/imax;
  if(linwr2==0 && loutwr2==0)
  {
    x12=mr2*z+nr12;
    x22=mr2*z12+nr12;
  }else{
    if(linwr2!=0 && loutwr2!=0)
    {
    x12=-bwr2*sqrt(1-((z0wr2+z)*(z0wr2+z))/(awr2*awr2));
    x22=-bwr2*sqrt(1-((z0wr2+z12)*(z0wr2+z12))/(awr2*awr2));
    }else{
    x12=-sqrt((z-pbwr2)/-pawr2);
    x22=-sqrt((z12-pbwr2)/-pawr2);
    }
  }
  if(linhd2==0 && louthd2==0)
  {
    y12=md2*z+nd12;
    y22=md2*z12+nd12;
  }else{
    if(linhd2!=0 && louthd2!=0)
    {
    y12=-bhd2*sqrt(1-((z0hd2+z)*(z0hd2+z))/(ahd2*ahd2));
    y22=-bhd2*sqrt(1-((z0hd2+z12)*(z0hd2+z12))/(ahd2*ahd2));
    }else{
    y12=-sqrt((z-pbhd2)/-pahd2);
    y22=-sqrt((z12-pbhd2)/-pahd2);
    }
  }
  if(mxr2!=-1 || myd2!=-1) line((double)x12, (double)y12, (double)z, (double)x22, (double)y22, (double)z12); 
}


for(i=0;i<imax;i++){											/* calculation of the points for the INNER RIGHT TOP line */
  z=i*l/imax;
  z12=(i+1)*l/imax;
  if(linwr2==0 && loutwr2==0)
  {
    x12=mr2*z+nr12;
    x22=mr2*z12+nr12;
   }else{
     if(linwr2!=0 && loutwr2!=0){
     x12=-bwr2*sqrt(1-((z0wr2+z)*(z0wr2+z))/(awr2*awr2));
     x22=-bwr2*sqrt(1-((z0wr2+z12)*(z0wr2+z12))/(awr2*awr2));
     }else{
     x12=-sqrt((z-pbwr2)/-pawr2);
     x22=-sqrt((z12-pbwr2)/-pawr2);
     }
   }
   if(linhu2==0 && louthu2==0)
  {
    y12=mu2*z+nu12;
    y22=mu2*z12+nu12;
  }else{
    if(linhu2!=0 && louthu2!=0)
    {
    y12=bhu2*sqrt(1-((z0hu2+z)*(z0hu2+z))/(ahu2*ahu2));
    y22=bhu2*sqrt(1-((z0hu2+z12)*(z0hu2+z12))/(ahu2*ahu2));
    }else{
    y12=sqrt((z-pbhu2)/-pahu2);
    y22=sqrt((z12-pbhu2)/-pahu2);
    }
  }
  if(mxr2!=-1 || myu2!=-1)line((double)x12, (double)y12, (double)z, (double)x22, (double)y22, (double)z12); 
}

for(i=0;i<imax;i++){											/* calculation of the points for the INNER LEFT TOP line */
  z=i*l/imax;
  z12=(i+1)*l/imax;
  if(linwl2==0 && loutwl2==0)
  {
    x12=ml2*z+nl12;
    x22=ml2*z12+nl12;
   }else{
     if(linwl2!=0 && loutwl2!=0)
     {
     x12=bwl2*sqrt(1-((z0wl2+z)*(z0wl2+z))/(awl2*awl2));
     x22=bwl2*sqrt(1-((z0wl2+z12)*(z0wl2+z12))/(awl2*awl2));
     }else{
     x12=sqrt((z-pbwl2)/-pawl2);
     x22=sqrt((z12-pbwl2)/-pawl2);
     }
   }
   if(linhu2==0 && louthu2==0)
  {
    y12=mu2*z+nu12;
    y22=mu2*z12+nu12;
  }else{
    if(linhu2!=0 && louthu2!=0)
    {
    y12=bhu2*sqrt(1-((z0hu2+z)*(z0hu2+z))/(ahu2*ahu2));
    y22=bhu2*sqrt(1-((z0hu2+z12)*(z0hu2+z12))/(ahu2*ahu2));
    }else{
    y12=sqrt((z-pbhu2)/-pahu2);
    y22=sqrt((z12-pbhu2)/-pahu2);
    }
  }
  if(mxl2!=-1 || myu2!=-1)line((double)x12, (double)y12, (double)z, (double)x22, (double)y22, (double)z12); 
}																	/* END INNER LINES*/


for(i=0;i<imax;i++){											/* calculation of the points for the OUTER LEFT BOTTOM line */
   z=i*l/imax;
   z12=(i+1)*l/imax;
  if(linwl2==0 && loutwl2 == 0)
   {
     xwt2=ml2*z+nl22;
     x1wt2=ml2*z12+nl22;
   }else{
      if(linwl2!=0 && loutwl2 != 0)
      {
      xwt2=bwlwt2*sqrt(1-((z0wl2+z)*(z0wl2+z))/(awlwt2*awlwt2));
      x1wt2=bwlwt2*sqrt(1-((z0wl2+z12)*(z0wl2+z12))/(awlwt2*awlwt2));
      }else{
      xwt2=sqrt((z-pbwlwt2)/-pawlwt2);
      x1wt2=sqrt((z12-pbwlwt2)/-pawlwt2);
      }
   }
  if(linhd2==0 && louthd2==0)
   {
     ywt2=md2*z+nd22;
     y1wt2=md2*z12+nd22;
    }else{
      if(linhd2!=0 && louthd2!=0)
      {
      ywt2=-bhdwt2*sqrt(1-((z0hd2+z)*(z0hd2+z))/(ahdwt2*ahdwt2));
      y1wt2=-bhdwt2*sqrt(1-((z0hd2+z12)*(z0hd2+z12))/(ahdwt2*ahdwt2));
      }else{
      ywt2=-sqrt((z-pbhdwt2)/-pahdwt2);
      y1wt2=-sqrt((z12-pbhdwt2)/-pahdwt2);
      }
   }
  if(mxlOW2!=-1 || mydOW2!=-1)line((double)xwt2, (double)ywt2, (double)z, (double)x1wt2, (double)y1wt2, (double)z12); 
 }

for(i=0;i<imax;i++){											/* calculation of the points for the OUTER RIGHT BOTTOM line */
  z=i*l/imax;
  z12=(i+1)*l/imax;
  if(linwr2==0 && loutwr2==0)
  {
    xwt2=mr2*z+nr22;
    x1wt2=mr2*z12+nr22;
  }else{
    if(linwr2!=0 && loutwr2!=0)
    {
    xwt2=-bwrwt2*sqrt(1-((z0wr2+z)*(z0wr2+z))/(awrwt2*awrwt2));
    x1wt2=-bwrwt2*sqrt(1-((z0wr2+z12)*(z0wr2+z12))/(awrwt2*awrwt2));
    }else{
    xwt2=-sqrt((z-pbwrwt2)/-pawrwt2);
    x1wt2=-sqrt((z12-pbwrwt2)/-pawrwt2);
    }
  }
  if(linhd2==0 && louthd2==0)
  {
    ywt2=md2*z+nd22;
    y1wt2=md2*z12+nd22;
  }else{
    if(linhd2!=0 && louthd2!=0)
    {
    ywt2=-bhdwt2*sqrt(1-((z0hd2+z)*(z0hd2+z))/(ahdwt2*ahdwt2));
    y1wt2=-bhdwt2*sqrt(1-((z0hd2+z12)*(z0hd2+z12))/(ahdwt2*ahdwt2));
    }else{
    ywt2=-sqrt((z-pbhdwt2)/-pahdwt2);
    y1wt2=-sqrt((z12-pbhdwt2)/-pahdwt2);
    }
  }
  if(mxrOW2!=-1 || mydOW2!=-1) line((double)xwt2, (double)ywt2, (double)z, (double)x1wt2, (double)y1wt2, (double)z12); 
}


for(i=0;i<imax;i++){											/* calculation of the points for the OUTER RIGHT TOP line */
  z=i*l/imax;
  z12=(i+1)*l/imax;
  if(linwr2==0 && loutwr2==0)
  {
    xwt2=mr2*z+nr22;
    x1wt2=mr2*z12+nr22;
   }else{
     if(linwr2!=0 && loutwr2!=0){
     xwt2=-bwrwt2*sqrt(1-((z0wr2+z)*(z0wr2+z))/(awrwt2*awrwt2));
     x1wt2=-bwrwt2*sqrt(1-((z0wr2+z12)*(z0wr2+z12))/(awrwt2*awrwt2));
     }else{
     xwt2=-sqrt((z-pbwrwt2)/-pawrwt2);
     x1wt2=-sqrt((z12-pbwrwt2)/-pawrwt2);
     }
   }
   if(linhu2==0 && louthu2==0)
  {
    ywt2=mu2*z+nu22;
    y1wt2=mu2*z12+nu22;
  }else{
    if(linhu2!=0 && louthu2!=0)
    {
    ywt2=bhuwt2*sqrt(1-((z0hu2+z)*(z0hu2+z))/(ahuwt2*ahuwt2));
    y1wt2=bhuwt2*sqrt(1-((z0hu2+z12)*(z0hu2+z12))/(ahuwt2*ahuwt2));
    }else{
    ywt2=sqrt((z-pbhuwt2)/-pahuwt2);
    y1wt2=sqrt((z12-pbhuwt2)/-pahuwt2);
    }
  }
   if(mxrOW2!=-1 || myuOW2!=-1)line((double)xwt2, (double)ywt2, (double)z, (double)x1wt2, (double)y1wt2, (double)z12); 
}

for(i=0;i<imax;i++){											/* calculation of the points for the OUTER LEFT TOP line */
  z=i*l/imax;
  z12=(i+1)*l/imax;
  if(linwl2==0 && loutwl2==0)
  {
    xwt2=ml2*z+nl22;
    x1wt2=ml2*z12+nl22;
   }else{
     if(linwl2!=0 && loutwl2!=0)
     {
     xwt2=bwlwt2*sqrt(1-((z0wl2+z)*(z0wl2+z))/(awlwt2*awlwt2));
     x1wt2=bwlwt2*sqrt(1-((z0wl2+z12)*(z0wl2+z12))/(awlwt2*awlwt2));
     }else{
     xwt2=sqrt((z-pbwlwt2)/-pawlwt2);
     x1wt2=sqrt((z12-pbwlwt2)/-pawlwt2);
     }
   }
   if(linhu2==0 && louthu2==0)
  {
    ywt2=mu2*z+nu22;
    y1wt2=mu2*z12+nu22;
  }else{
    if(linhu2!=0 && louthu2!=0)
    {
    ywt2=bhuwt2*sqrt(1-((z0hu2+z)*(z0hu2+z))/(ahuwt2*ahuwt2));
    y1wt2=bhuwt2*sqrt(1-((z0hu2+z12)*(z0hu2+z12))/(ahuwt2*ahuwt2));
    }else{
    ywt2=sqrt((z-pbhuwt2)/-pahuwt2);
    y1wt2=sqrt((z12-pbhuwt2)/-pahuwt2);
    }
  }
  if(mxlOW2!=-1 || myuOW2!=-1)line((double)xwt2, (double)ywt2, (double)z, (double)x1wt2, (double)y1wt2, (double)z12); 
}


  if (linwr3==0 && loutwr3==0){
   mr3=(-w2r3+w1r3)/l;
   nr13=-w1r3;
   nr23=-(w1rwt3);
   }


if (linwl3==0 && loutwl3==0){
   ml3=(w2l3-w1l3)/l;
   nl13=w1l3;
   nl23=(w1lwt3);
   }


if (linhu3 == 0 && louthu3==0) 
  {
   mu3=(h2u3-h1u3)/l;
   nu13=h1u3;
   nu23=(h1uwt3);
  }


if (linhd3 == 0 && louthd3==0) 
  {
   md3=(-h2d3+h1d3)/l;
   nd13=-h1d3;
   nd23=-(h1dwt3);
  }

  z0wr3=(linwr3-l-loutwr3)/2.0;
  z0wl3=(linwl3-l-loutwl3)/2.0;
  z0hu3=lbhu3/2.0-l-louthu3;
  z0hd3=lbhd3/2.0-l-louthd3;

  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(myd3!=-1) line(w1l3, -h1d3, 0.0, -w1r3, -h1d3, 0.0);							/* entrance window given by the INNER walls*/
  if(myu3!=-1)line(w1l3, h1u3, 0.0, -w1r3, h1u3, 0.0);
  if(mxl3!=-1)line(w1l3, -h1d3, 0.0, w1l3, h1u3, 0.0);
  if(mxr3!=-1)line( -w1r3, h1u3, 0.0, -w1r3, -h1d3, 0.0);

  if(myd3!=-1)line(w2l3, -h2d3, l, -w2r3, -h2d3, l);								/* exit window given by the INNER walls*/
  if(myu3!=-1)line(w2l3, h2u3,  l, -w2r3, h2u3, l);
  if(mxl3!=-1)line(w2l3, -h2d3, l, w2l3, h2u3, l);
  if(mxr3!=-1)line( -w2r3, -h2d3,  l, -w2r3, h2u3, l);

  if(mydOW3!=-1) line((w1lwt3), -(h1dwt3), 0.0, -(w1rwt3), -(h1dwt3), 0.0);					/* entrance window given by the OUTER walls */
  if(myuOW3!=-1)line((w1lwt3), (h1uwt3), 0.0, -(w1rwt3), (h1uwt3), 0.0);
  if(mxlOW3!=-1)line((w1lwt3), -(h1dwt3), 0.0, (w1lwt3), (h1uwt3), 0.0);
  if(mxrOW3!=-1)line( -(w1rwt3), (h1uwt3), 0.0, -(w1rwt3), -(h1dwt3), 0.0);

  if(mydOW3!=-1)line((w2lwt3), -(h2dwt3), l, -(w2rwt3), -(h2dwt3), l);					/* exit windows given by the OUTER walls*/
  if(myuOW3!=-1)line((w2lwt3), (h2uwt3),  l, -(w2rwt3), (h2uwt3), l);
  if(mxlOW3!=-1)line((w2lwt3), -(h2dwt3), l, (w2lwt3), (h2uwt3), l);
  if(mxrOW3!=-1)line( -(w2rwt3), -(h2dwt3),  l, -(w2rwt3), (h2uwt3), l);

  if((myd3!=-1 && mydOW3!=-1) || (mxl3!=-1 && mxlOW3!=-1)) line(w1l3, -h1d3, 0.0, (w1lwt3), -(h1dwt3), 0.0);	/* corner connection lines for the entrance windows*/	
  if((myu3!=-1 && myuOW3!=-1) || (mxl3!=-1 && mxlOW3!=-1)) line(w1l3, h1u3, 0.0, (w1lwt3), (h1uwt3), 0.0);
  if((myd3!=-1 && mydOW3!=-1) || (mxr3!=-1 && mxrOW3!=-1)) line(-w1r3, -h1d3, 0.0,-(w1rwt3),  -(h1dwt3), 0.0);
  if((myu3!=-1 && myuOW3!=-1) || (mxr3!=-1 && mxrOW3!=-1)) line( -w1r3, h1u3, 0.0, -(w1rwt3), (h1uwt3), 0.0);

  if((myd3!=-1 && mydOW3!=-1) || (mxl3!=-1 && mxlOW3!=-1)) line(w2l3, -h2d3, l, (w2lwt3), -(h2dwt3), l);	/* corner connection lines for the exit windows*/
  if((myu3!=-1 && myuOW3!=-1) || (mxl3!=-1 && mxlOW3!=-1)) line(w2l3, h2u3, l, (w2lwt3), (h2uwt3), l);
  if((myd3!=-1 && mydOW3!=-1) || (mxr3!=-1 && mxrOW3!=-1)) line(-w2r3, -h2d3, l,-(w2rwt3),  -(h2dwt3), l);
  if((myu3!=-1 && myuOW3!=-1) || (mxr3!=-1 && mxrOW3!=-1)) line( -w2r3, h2u3, l, -(w2rwt3), (h2uwt3), l);

for(i=0;i<imax;i++){											/* calculation of the points for the INNER LEFT BOTTOM line */
   z=i*l/imax;
   z13=(i+1)*l/imax;
  if(linwl3==0 && loutwl3 == 0)
   {
     x13=ml3*z+nl13;
     x23=ml3*z13+nl13;
   }else{
      if(linwl3!=0 && loutwl3 != 0)
      {
      x13=bwl3*sqrt(1-((z0wl3+z)*(z0wl3+z))/(awl3*awl3));
      x23=bwl3*sqrt(1-((z0wl3+z13)*(z0wl3+z13))/(awl3*awl3));
      }else{
      x13=sqrt((z-pbwl3)/-pawl3);
      x23=sqrt((z13-pbwl3)/-pawl3);
      }
   }
  if(linhd3==0 && louthd3==0)
   {
     y13=md3*z+nd13;
     y23=md3*z13+nd13;
    }else{
      if(linhd3!=0 && louthd3!=0)
      {
      y13=-bhd3*sqrt(1-((z0hd3+z)*(z0hd3+z))/(ahd3*ahd3));
      y23=-bhd3*sqrt(1-((z0hd3+z13)*(z0hd3+z13))/(ahd3*ahd3));
      }else{
      y13=-sqrt((z-pbhd3)/-pahd3);
      y23=-sqrt((z13-pbhd3)/-pahd3);
      }
   }
  if(mxl3!=-1 || myd3!=-1)line((double)x13, (double)y13, (double)z, (double)x23, (double)y23, (double)z13); 
 }

for(i=0;i<imax;i++){											/* calculation of the points for the INNER RIGHT BOTTOM line */
  z=i*l/imax;
  z13=(i+1)*l/imax;
  if(linwr3==0 && loutwr3==0)
  {
    x13=mr3*z+nr13;
    x23=mr3*z13+nr13;
  }else{
    if(linwr3!=0 && loutwr3!=0)
    {
    x13=-bwr3*sqrt(1-((z0wr3+z)*(z0wr3+z))/(awr3*awr3));
    x23=-bwr3*sqrt(1-((z0wr3+z13)*(z0wr3+z13))/(awr3*awr3));
    }else{
    x13=-sqrt((z-pbwr3)/-pawr3);
    x23=-sqrt((z13-pbwr3)/-pawr3);
    }
  }
  if(linhd3==0 && louthd3==0)
  {
    y13=md3*z+nd13;
    y23=md3*z13+nd13;
  }else{
    if(linhd3!=0 && louthd3!=0)
    {
    y13=-bhd3*sqrt(1-((z0hd3+z)*(z0hd3+z))/(ahd3*ahd3));
    y23=-bhd3*sqrt(1-((z0hd3+z13)*(z0hd3+z13))/(ahd3*ahd3));
    }else{
    y13=-sqrt((z-pbhd3)/-pahd3);
    y23=-sqrt((z13-pbhd3)/-pahd3);
    }
  }
  if(mxr3!=-1 || myd3!=-1) line((double)x13, (double)y13, (double)z, (double)x23, (double)y23, (double)z13); 
}


for(i=0;i<imax;i++){											/* calculation of the points for the INNER RIGHT TOP line */
  z=i*l/imax;
  z13=(i+1)*l/imax;
  if(linwr3==0 && loutwr3==0)
  {
    x13=mr3*z+nr13;
    x23=mr3*z13+nr13;
   }else{
     if(linwr3!=0 && loutwr3!=0){
     x13=-bwr3*sqrt(1-((z0wr3+z)*(z0wr3+z))/(awr3*awr3));
     x23=-bwr3*sqrt(1-((z0wr3+z13)*(z0wr3+z13))/(awr3*awr3));
     }else{
     x13=-sqrt((z-pbwr3)/-pawr3);
     x23=-sqrt((z13-pbwr3)/-pawr3);
     }
   }
   if(linhu3==0 && louthu3==0)
  {
    y13=mu3*z+nu13;
    y23=mu3*z13+nu13;
  }else{
    if(linhu3!=0 && louthu3!=0)
    {
    y13=bhu3*sqrt(1-((z0hu3+z)*(z0hu3+z))/(ahu3*ahu3));
    y23=bhu3*sqrt(1-((z0hu3+z13)*(z0hu3+z13))/(ahu3*ahu3));
    }else{
    y13=sqrt((z-pbhu3)/-pahu3);
    y23=sqrt((z13-pbhu3)/-pahu3);
    }
  }
  if(mxr3!=-1 || myu3!=-1)line((double)x13, (double)y13, (double)z, (double)x23, (double)y23, (double)z13); 
}

for(i=0;i<imax;i++){											/* calculation of the points for the INNER LEFT TOP line */
  z=i*l/imax;
  z13=(i+1)*l/imax;
  if(linwl3==0 && loutwl3==0)
  {
    x13=ml3*z+nl13;
    x23=ml3*z13+nl13;
   }else{
     if(linwl3!=0 && loutwl3!=0)
     {
     x13=bwl3*sqrt(1-((z0wl3+z)*(z0wl3+z))/(awl3*awl3));
     x23=bwl3*sqrt(1-((z0wl3+z13)*(z0wl3+z13))/(awl3*awl3));
     }else{
     x13=sqrt((z-pbwl3)/-pawl3);
     x23=sqrt((z13-pbwl3)/-pawl3);
     }
   }
   if(linhu3==0 && louthu3==0)
  {
    y13=mu3*z+nu13;
    y23=mu3*z13+nu13;
  }else{
    if(linhu3!=0 && louthu3!=0)
    {
    y13=bhu3*sqrt(1-((z0hu3+z)*(z0hu3+z))/(ahu3*ahu3));
    y23=bhu3*sqrt(1-((z0hu3+z13)*(z0hu3+z13))/(ahu3*ahu3));
    }else{
    y13=sqrt((z-pbhu3)/-pahu3);
    y23=sqrt((z13-pbhu3)/-pahu3);
    }
  }
  if(mxl3!=-1 || myu3!=-1)line((double)x13, (double)y13, (double)z, (double)x23, (double)y23, (double)z13); 
}																	/* END INNER LINES*/


for(i=0;i<imax;i++){											/* calculation of the points for the OUTER LEFT BOTTOM line */
   z=i*l/imax;
   z13=(i+1)*l/imax;
  if(linwl3==0 && loutwl3 == 0)
   {
     xwt3=ml3*z+nl23;
     x1wt3=ml3*z13+nl23;
   }else{
      if(linwl3!=0 && loutwl3 != 0)
      {
      xwt3=bwlwt3*sqrt(1-((z0wl3+z)*(z0wl3+z))/(awlwt3*awlwt3));
      x1wt3=bwlwt3*sqrt(1-((z0wl3+z13)*(z0wl3+z13))/(awlwt3*awlwt3));
      }else{
      xwt3=sqrt((z-pbwlwt3)/-pawlwt3);
      x1wt3=sqrt((z13-pbwlwt3)/-pawlwt3);
      }
   }
  if(linhd3==0 && louthd3==0)
   {
     ywt3=md3*z+nd23;
     y1wt3=md3*z13+nd23;
    }else{
      if(linhd3!=0 && louthd3!=0)
      {
      ywt3=-bhdwt3*sqrt(1-((z0hd3+z)*(z0hd3+z))/(ahdwt3*ahdwt3));
      y1wt3=-bhdwt3*sqrt(1-((z0hd3+z13)*(z0hd3+z13))/(ahdwt3*ahdwt3));
      }else{
      ywt3=-sqrt((z-pbhdwt3)/-pahdwt3);
      y1wt3=-sqrt((z13-pbhdwt3)/-pahdwt3);
      }
   }
  if(mxlOW3!=-1 || mydOW3!=-1)line((double)xwt3, (double)ywt3, (double)z, (double)x1wt3, (double)y1wt3, (double)z13); 
 }

for(i=0;i<imax;i++){											/* calculation of the points for the OUTER RIGHT BOTTOM line */
  z=i*l/imax;
  z13=(i+1)*l/imax;
  if(linwr3==0 && loutwr3==0)
  {
    xwt3=mr3*z+nr23;
    x1wt3=mr3*z13+nr23;
  }else{
    if(linwr3!=0 && loutwr3!=0)
    {
    xwt3=-bwrwt3*sqrt(1-((z0wr3+z)*(z0wr3+z))/(awrwt3*awrwt3));
    x1wt3=-bwrwt3*sqrt(1-((z0wr3+z13)*(z0wr3+z13))/(awrwt3*awrwt3));
    }else{
    xwt3=-sqrt((z-pbwrwt3)/-pawrwt3);
    x1wt3=-sqrt((z13-pbwrwt3)/-pawrwt3);
    }
  }
  if(linhd3==0 && louthd3==0)
  {
    ywt3=md3*z+nd23;
    y1wt3=md3*z13+nd23;
  }else{
    if(linhd3!=0 && louthd3!=0)
    {
    ywt3=-bhdwt3*sqrt(1-((z0hd3+z)*(z0hd3+z))/(ahdwt3*ahdwt3));
    y1wt3=-bhdwt3*sqrt(1-((z0hd3+z13)*(z0hd3+z13))/(ahdwt3*ahdwt3));
    }else{
    ywt3=-sqrt((z-pbhdwt3)/-pahdwt3);
    y1wt3=-sqrt((z13-pbhdwt3)/-pahdwt3);
    }
  }
  if(mxrOW3!=-1 || mydOW3!=-1) line((double)xwt3, (double)ywt3, (double)z, (double)x1wt3, (double)y1wt3, (double)z13); 
}


for(i=0;i<imax;i++){											/* calculation of the points for the OUTER RIGHT TOP line */
  z=i*l/imax;
  z13=(i+1)*l/imax;
  if(linwr3==0 && loutwr3==0)
  {
    xwt3=mr3*z+nr23;
    x1wt3=mr3*z13+nr23;
   }else{
     if(linwr3!=0 && loutwr3!=0){
     xwt3=-bwrwt3*sqrt(1-((z0wr3+z)*(z0wr3+z))/(awrwt3*awrwt3));
     x1wt3=-bwrwt3*sqrt(1-((z0wr3+z13)*(z0wr3+z13))/(awrwt3*awrwt3));
     }else{
     xwt3=-sqrt((z-pbwrwt3)/-pawrwt3);
     x1wt3=-sqrt((z13-pbwrwt3)/-pawrwt3);
     }
   }
   if(linhu3==0 && louthu3==0)
  {
    ywt3=mu3*z+nu23;
    y1wt3=mu3*z13+nu23;
  }else{
    if(linhu3!=0 && louthu3!=0)
    {
    ywt3=bhuwt3*sqrt(1-((z0hu3+z)*(z0hu3+z))/(ahuwt3*ahuwt3));
    y1wt3=bhuwt3*sqrt(1-((z0hu3+z13)*(z0hu3+z13))/(ahuwt3*ahuwt3));
    }else{
    ywt3=sqrt((z-pbhuwt3)/-pahuwt3);
    y1wt3=sqrt((z13-pbhuwt3)/-pahuwt3);
    }
  }
   if(mxrOW3!=-1 || myuOW3!=-1)line((double)xwt3, (double)ywt3, (double)z, (double)x1wt3, (double)y1wt3, (double)z13); 
}

for(i=0;i<imax;i++){											/* calculation of the points for the OUTER LEFT TOP line */
  z=i*l/imax;
  z13=(i+1)*l/imax;
  if(linwl3==0 && loutwl3==0)
  {
    xwt3=ml3*z+nl23;
    x1wt3=ml3*z13+nl23;
   }else{
     if(linwl3!=0 && loutwl3!=0)
     {
     xwt3=bwlwt3*sqrt(1-((z0wl3+z)*(z0wl3+z))/(awlwt3*awlwt3));
     x1wt3=bwlwt3*sqrt(1-((z0wl3+z13)*(z0wl3+z13))/(awlwt3*awlwt3));
     }else{
     xwt3=sqrt((z-pbwlwt3)/-pawlwt3);
     x1wt3=sqrt((z13-pbwlwt3)/-pawlwt3);
     }
   }
   if(linhu3==0 && louthu3==0)
  {
    ywt3=mu3*z+nu23;
    y1wt3=mu3*z13+nu23;
  }else{
    if(linhu3!=0 && louthu3!=0)
    {
    ywt3=bhuwt3*sqrt(1-((z0hu3+z)*(z0hu3+z))/(ahuwt3*ahuwt3));
    y1wt3=bhuwt3*sqrt(1-((z0hu3+z13)*(z0hu3+z13))/(ahuwt3*ahuwt3));
    }else{
    ywt3=sqrt((z-pbhuwt3)/-pahuwt3);
    y1wt3=sqrt((z13-pbhuwt3)/-pahuwt3);
    }
  }
  if(mxlOW3!=-1 || myuOW3!=-1)line((double)xwt3, (double)ywt3, (double)z, (double)x1wt3, (double)y1wt3, (double)z13); 
}

 if (linwr4==0 && loutwr4==0){
   mr4=(-w2r4+w1r4)/l;
   nr14=-w1r4;
   nr24=-(w1rwt4);
   }


if (linwl4==0 && loutwl4==0){
   ml4=(w2l4-w1l4)/l;
   nl14=w1l4;
   nl24=(w1lwt4);
   }


if (linhu4 == 0 && louthu4==0) 
  {
   mu4=(h2u4-h1u4)/l;
   nu14=h1u4;
   nu24=(h1uwt4);
  }


if (linhd4 == 0 && louthd4==0) 
  {
   md4=(-h2d4+h1d4)/l;
   nd14=-h1d4;
   nd24=-(h1dwt4);
  }

  z0wr4=(linwr4-l-loutwr4)/2.0;
  z0wl4=(linwl4-l-loutwl4)/2.0;
  z0hu4=lbhu4/2.0-l-louthu4;
  z0hd4=lbhd4/2.0-l-louthd4;

  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(myd4!=-1) line(w1l4, -h1d4, 0.0, -w1r4, -h1d4, 0.0);							/* entrance window given by the INNER walls*/
  if(myu4!=-1)line(w1l4, h1u4, 0.0, -w1r4, h1u4, 0.0);
  if(mxl4!=-1)line(w1l4, -h1d4, 0.0, w1l4, h1u4, 0.0);
  if(mxr4!=-1)line( -w1r4, h1u4, 0.0, -w1r4, -h1d4, 0.0);

  if(myd4!=-1)line(w2l4, -h2d4, l, -w2r4, -h2d4, l);								/* exit window given by the INNER walls*/
  if(myu4!=-1)line(w2l4, h2u4,  l, -w2r4, h2u4, l);
  if(mxl4!=-1)line(w2l4, -h2d4, l, w2l4, h2u4, l);
  if(mxr4!=-1)line( -w2r4, -h2d4,  l, -w2r4, h2u4, l);

  if(mydOW4!=-1) line((w1lwt4), -(h1dwt4), 0.0, -(w1rwt4), -(h1dwt4), 0.0);					/* entrance window given by the OUTER walls */
  if(myuOW4!=-1)line((w1lwt4), (h1uwt4), 0.0, -(w1rwt4), (h1uwt4), 0.0);
  if(mxlOW4!=-1)line((w1lwt4), -(h1dwt4), 0.0, (w1lwt4), (h1uwt4), 0.0);
  if(mxrOW4!=-1)line( -(w1rwt4), (h1uwt4), 0.0, -(w1rwt4), -(h1dwt4), 0.0);

  if(mydOW4!=-1)line((w2lwt4), -(h2dwt4), l, -(w2rwt4), -(h2dwt4), l);					/* exit windows given by the OUTER walls*/
  if(myuOW4!=-1)line((w2lwt4), (h2uwt4),  l, -(w2rwt4), (h2uwt4), l);
  if(mxlOW4!=-1)line((w2lwt4), -(h2dwt4), l, (w2lwt4), (h2uwt4), l);
  if(mxrOW4!=-1)line( -(w2rwt4), -(h2dwt4),  l, -(w2rwt4), (h2uwt4), l);

  if((myd4!=-1 && mydOW4!=-1) || (mxl4!=-1 && mxlOW4!=-1)) line(w1l4, -h1d4, 0.0, (w1lwt4), -(h1dwt4), 0.0);	/* corner connection lines for the entrance windows*/	
  if((myu4!=-1 && myuOW4!=-1) || (mxl4!=-1 && mxlOW4!=-1)) line(w1l4, h1u4, 0.0, (w1lwt4), (h1uwt4), 0.0);
  if((myd4!=-1 && mydOW4!=-1) || (mxr4!=-1 && mxrOW4!=-1)) line(-w1r4, -h1d4, 0.0,-(w1rwt4),  -(h1dwt4), 0.0);
  if((myu4!=-1 && myuOW4!=-1) || (mxr4!=-1 && mxrOW4!=-1)) line( -w1r4, h1u4, 0.0, -(w1rwt4), (h1uwt4), 0.0);

  if((myd4!=-1 && mydOW4!=-1) || (mxl4!=-1 && mxlOW4!=-1)) line(w2l4, -h2d4, l, (w2lwt4), -(h2dwt4), l);	/* corner connection lines for the exit windows*/
  if((myu4!=-1 && myuOW4!=-1) || (mxl4!=-1 && mxlOW4!=-1)) line(w2l4, h2u4, l, (w2lwt4), (h2uwt4), l);
  if((myd4!=-1 && mydOW4!=-1) || (mxr4!=-1 && mxrOW4!=-1)) line(-w2r4, -h2d4, l,-(w2rwt4),  -(h2dwt4), l);
  if((myu4!=-1 && myuOW4!=-1) || (mxr4!=-1 && mxrOW4!=-1)) line( -w2r4, h2u4, l, -(w2rwt4), (h2uwt4), l);

for(i=0;i<imax;i++){											/* calculation of the points for the INNER LEFT BOTTOM line */
   z=i*l/imax;
   z14=(i+1)*l/imax;
  if(linwl4==0 && loutwl4 == 0)
   {
     x14=ml4*z+nl14;
     x24=ml4*z14+nl14;
   }else{
      if(linwl4!=0 && loutwl4 != 0)
      {
      x14=bwl4*sqrt(1-((z0wl4+z)*(z0wl4+z))/(awl4*awl4));
      x24=bwl4*sqrt(1-((z0wl4+z14)*(z0wl4+z14))/(awl4*awl4));
      }else{
      x14=sqrt((z-pbwl4)/-pawl4);
      x24=sqrt((z14-pbwl4)/-pawl4);
      }
   }
  if(linhd4==0 && louthd4==0)
   {
     y14=md4*z+nd14;
     y24=md4*z14+nd14;
    }else{
      if(linhd4!=0 && louthd4!=0)
      {
      y14=-bhd4*sqrt(1-((z0hd4+z)*(z0hd4+z))/(ahd4*ahd4));
      y24=-bhd4*sqrt(1-((z0hd4+z14)*(z0hd4+z14))/(ahd4*ahd4));
      }else{
      y14=-sqrt((z-pbhd4)/-pahd4);
      y24=-sqrt((z14-pbhd4)/-pahd4);
      }
   }
  if(mxl4!=-1 || myd4!=-1)line((double)x14, (double)y14, (double)z, (double)x24, (double)y24, (double)z14); 
 }

for(i=0;i<imax;i++){											/* calculation of the points for the INNER RIGHT BOTTOM line */
  z=i*l/imax;
  z14=(i+1)*l/imax;
  if(linwr4==0 && loutwr4==0)
  {
    x14=mr4*z+nr14;
    x24=mr4*z14+nr14;
  }else{
    if(linwr4!=0 && loutwr4!=0)
    {
    x14=-bwr4*sqrt(1-((z0wr4+z)*(z0wr4+z))/(awr4*awr4));
    x24=-bwr4*sqrt(1-((z0wr4+z14)*(z0wr4+z14))/(awr4*awr4));
    }else{
    x14=-sqrt((z-pbwr4)/-pawr4);
    x24=-sqrt((z14-pbwr4)/-pawr4);
    }
  }
  if(linhd4==0 && louthd4==0)
  {
    y14=md4*z+nd14;
    y24=md4*z14+nd14;
  }else{
    if(linhd4!=0 && louthd4!=0)
    {
    y14=-bhd4*sqrt(1-((z0hd4+z)*(z0hd4+z))/(ahd4*ahd4));
    y24=-bhd4*sqrt(1-((z0hd4+z14)*(z0hd4+z14))/(ahd4*ahd4));
    }else{
    y14=-sqrt((z-pbhd4)/-pahd4);
    y24=-sqrt((z14-pbhd4)/-pahd4);
    }
  }
  if(mxr4!=-1 || myd4!=-1) line((double)x14, (double)y14, (double)z, (double)x24, (double)y24, (double)z14); 
}


for(i=0;i<imax;i++){											/* calculation of the points for the INNER RIGHT TOP line */
  z=i*l/imax;
  z14=(i+1)*l/imax;
  if(linwr4==0 && loutwr4==0)
  {
    x14=mr4*z+nr14;
    x24=mr4*z14+nr14;
   }else{
     if(linwr4!=0 && loutwr4!=0){
     x14=-bwr4*sqrt(1-((z0wr4+z)*(z0wr4+z))/(awr4*awr4));
     x24=-bwr4*sqrt(1-((z0wr4+z14)*(z0wr4+z14))/(awr4*awr4));
     }else{
     x14=-sqrt((z-pbwr4)/-pawr4);
     x24=-sqrt((z14-pbwr4)/-pawr4);
     }
   }
   if(linhu4==0 && louthu4==0)
  {
    y14=mu4*z+nu14;
    y24=mu4*z14+nu14;
  }else{
    if(linhu4!=0 && louthu4!=0)
    {
    y14=bhu4*sqrt(1-((z0hu4+z)*(z0hu4+z))/(ahu4*ahu4));
    y24=bhu4*sqrt(1-((z0hu4+z14)*(z0hu4+z14))/(ahu4*ahu4));
    }else{
    y14=sqrt((z-pbhu4)/-pahu4);
    y24=sqrt((z14-pbhu4)/-pahu4);
    }
  }
  if(mxr4!=-1 || myu4!=-1)line((double)x14, (double)y14, (double)z, (double)x24, (double)y24, (double)z14); 
}

for(i=0;i<imax;i++){											/* calculation of the points for the INNER LEFT TOP line */
  z=i*l/imax;
  z14=(i+1)*l/imax;
  if(linwl4==0 && loutwl4==0)
  {
    x14=ml4*z+nl14;
    x24=ml4*z14+nl14;
   }else{
     if(linwl4!=0 && loutwl4!=0)
     {
     x14=bwl4*sqrt(1-((z0wl4+z)*(z0wl4+z))/(awl4*awl4));
     x24=bwl4*sqrt(1-((z0wl4+z14)*(z0wl4+z14))/(awl4*awl4));
     }else{
     x14=sqrt((z-pbwl4)/-pawl4);
     x24=sqrt((z14-pbwl4)/-pawl4);
     }
   }
   if(linhu4==0 && louthu4==0)
  {
    y14=mu4*z+nu14;
    y24=mu4*z14+nu14;
  }else{
    if(linhu4!=0 && louthu4!=0)
    {
    y14=bhu4*sqrt(1-((z0hu4+z)*(z0hu4+z))/(ahu4*ahu4));
    y24=bhu4*sqrt(1-((z0hu4+z14)*(z0hu4+z14))/(ahu4*ahu4));
    }else{
    y14=sqrt((z-pbhu4)/-pahu4);
    y24=sqrt((z14-pbhu4)/-pahu4);
    }
  }
  if(mxl4!=-1 || myu4!=-1)line((double)x14, (double)y14, (double)z, (double)x24, (double)y24, (double)z14); 
}																	/* END INNER LINES*/


for(i=0;i<imax;i++){											/* calculation of the points for the OUTER LEFT BOTTOM line */
   z=i*l/imax;
   z14=(i+1)*l/imax;
  if(linwl4==0 && loutwl4 == 0)
   {
     xwt4=ml4*z+nl24;
     x1wt4=ml4*z14+nl24;
   }else{
      if(linwl4!=0 && loutwl4 != 0)
      {
      xwt4=bwlwt4*sqrt(1-((z0wl4+z)*(z0wl4+z))/(awlwt4*awlwt4));
      x1wt4=bwlwt4*sqrt(1-((z0wl4+z14)*(z0wl4+z14))/(awlwt4*awlwt4));
      }else{
      xwt4=sqrt((z-pbwlwt4)/-pawlwt4);
      x1wt4=sqrt((z14-pbwlwt4)/-pawlwt4);
      }
   }
  if(linhd4==0 && louthd4==0)
   {
     ywt4=md4*z+nd24;
     y1wt4=md4*z14+nd24;
    }else{
      if(linhd4!=0 && louthd4!=0)
      {
      ywt4=-bhdwt4*sqrt(1-((z0hd4+z)*(z0hd4+z))/(ahdwt4*ahdwt4));
      y1wt4=-bhdwt4*sqrt(1-((z0hd4+z14)*(z0hd4+z14))/(ahdwt4*ahdwt4));
      }else{
      ywt4=-sqrt((z-pbhdwt4)/-pahdwt4);
      y1wt4=-sqrt((z14-pbhdwt4)/-pahdwt4);
      }
   }
  if(mxlOW4!=-1 || mydOW4!=-1)line((double)xwt4, (double)ywt4, (double)z, (double)x1wt4, (double)y1wt4, (double)z14); 
 }

for(i=0;i<imax;i++){											/* calculation of the points for the OUTER RIGHT BOTTOM line */
  z=i*l/imax;
  z14=(i+1)*l/imax;
  if(linwr4==0 && loutwr4==0)
  {
    xwt4=mr4*z+nr24;
    x1wt4=mr4*z14+nr24;
  }else{
    if(linwr4!=0 && loutwr4!=0)
    {
    xwt4=-bwrwt4*sqrt(1-((z0wr4+z)*(z0wr4+z))/(awrwt4*awrwt4));
    x1wt4=-bwrwt4*sqrt(1-((z0wr4+z14)*(z0wr4+z14))/(awrwt4*awrwt4));
    }else{
    xwt4=-sqrt((z-pbwrwt4)/-pawrwt4);
    x1wt4=-sqrt((z14-pbwrwt4)/-pawrwt4);
    }
  }
  if(linhd4==0 && louthd4==0)
  {
    ywt4=md4*z+nd24;
    y1wt4=md4*z14+nd24;
  }else{
    if(linhd4!=0 && louthd4!=0)
    {
    ywt4=-bhdwt4*sqrt(1-((z0hd4+z)*(z0hd4+z))/(ahdwt4*ahdwt4));
    y1wt4=-bhdwt4*sqrt(1-((z0hd4+z14)*(z0hd4+z14))/(ahdwt4*ahdwt4));
    }else{
    ywt4=-sqrt((z-pbhdwt4)/-pahdwt4);
    y1wt4=-sqrt((z14-pbhdwt4)/-pahdwt4);
    }
  }
  if(mxrOW4!=-1 || mydOW4!=-1) line((double)xwt4, (double)ywt4, (double)z, (double)x1wt4, (double)y1wt4, (double)z14); 
}


for(i=0;i<imax;i++){											/* calculation of the points for the OUTER RIGHT TOP line */
  z=i*l/imax;
  z14=(i+1)*l/imax;
  if(linwr4==0 && loutwr4==0)
  {
    xwt4=mr4*z+nr24;
    x1wt4=mr4*z14+nr24;
   }else{
     if(linwr4!=0 && loutwr4!=0){
     xwt4=-bwrwt4*sqrt(1-((z0wr4+z)*(z0wr4+z))/(awrwt4*awrwt4));
     x1wt4=-bwrwt4*sqrt(1-((z0wr4+z14)*(z0wr4+z14))/(awrwt4*awrwt4));
     }else{
     xwt4=-sqrt((z-pbwrwt4)/-pawrwt4);
     x1wt4=-sqrt((z14-pbwrwt4)/-pawrwt4);
     }
   }
   if(linhu4==0 && louthu4==0)
  {
    ywt4=mu4*z+nu24;
    y1wt4=mu4*z14+nu24;
  }else{
    if(linhu4!=0 && louthu4!=0)
    {
    ywt4=bhuwt4*sqrt(1-((z0hu4+z)*(z0hu4+z))/(ahuwt4*ahuwt4));
    y1wt4=bhuwt4*sqrt(1-((z0hu4+z14)*(z0hu4+z14))/(ahuwt4*ahuwt4));
    }else{
    ywt4=sqrt((z-pbhuwt4)/-pahuwt4);
    y1wt4=sqrt((z14-pbhuwt4)/-pahuwt4);
    }
  }
   if(mxrOW4!=-1 || myuOW4!=-1)line((double)xwt4, (double)ywt4, (double)z, (double)x1wt4, (double)y1wt4, (double)z14); 
}

for(i=0;i<imax;i++){											/* calculation of the points for the OUTER LEFT TOP line */
  z=i*l/imax;
  z14=(i+1)*l/imax;
  if(linwl4==0 && loutwl4==0)
  {
    xwt4=ml4*z+nl24;
    x1wt4=ml4*z14+nl24;
   }else{
     if(linwl4!=0 && loutwl4!=0)
     {
     xwt4=bwlwt4*sqrt(1-((z0wl4+z)*(z0wl4+z))/(awlwt4*awlwt4));
     x1wt4=bwlwt4*sqrt(1-((z0wl4+z14)*(z0wl4+z14))/(awlwt4*awlwt4));
     }else{
     xwt4=sqrt((z-pbwlwt4)/-pawlwt4);
     x1wt4=sqrt((z14-pbwlwt4)/-pawlwt4);
     }
   }
   if(linhu4==0 && louthu4==0)
  {
    ywt4=mu4*z+nu24;
    y1wt4=mu4*z14+nu24;
  }else{
    if(linhu4!=0 && louthu4!=0)
    {
    ywt4=bhuwt4*sqrt(1-((z0hu4+z)*(z0hu4+z))/(ahuwt4*ahuwt4));
    y1wt4=bhuwt4*sqrt(1-((z0hu4+z14)*(z0hu4+z14))/(ahuwt4*ahuwt4));
    }else{
    ywt4=sqrt((z-pbhuwt4)/-pahuwt4);
    y1wt4=sqrt((z14-pbhuwt4)/-pahuwt4);
    }
  }
  if(mxlOW4!=-1 || myuOW4!=-1)line((double)xwt4, (double)ywt4, (double)z, (double)x1wt4, (double)y1wt4, (double)z14); 
}

 if (linwr5==0 && loutwr5==0){
   mr5=(-w2r5+w1r5)/l;
   nr15=-w1r5;
   nr25=-(w1rwt5);
   }


if (linwl5==0 && loutwl5==0){
   ml5=(w2l5-w1l5)/l;
   nl15=w1l5;
   nl25=(w1lwt5);
   }


if (linhu5 == 0 && louthu5==0) 
  {
   mu5=(h2u5-h1u5)/l;
   nu15=h1u5;
   nu25=(h1uwt5);
  }


if (linhd5 == 0 && louthd5==0) 
  {
   md5=(-h2d5+h1d5)/l;
   nd15=-h1d5;
   nd25=-(h1dwt5);
  }

  z0wr5=(linwr5-l-loutwr5)/2.0;
  z0wl5=(linwl5-l-loutwl5)/2.0;
  z0hu5=lbhu5/2.0-l-louthu5;
  z0hd5=lbhd5/2.0-l-louthd5;

  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(myd5!=-1) line(w1l5, -h1d5, 0.0, -w1r5, -h1d5, 0.0);							/* entrance window given by the INNER walls*/
  if(myu5!=-1)line(w1l5, h1u5, 0.0, -w1r5, h1u5, 0.0);
  if(mxl5!=-1)line(w1l5, -h1d5, 0.0, w1l5, h1u5, 0.0);
  if(mxr5!=-1)line( -w1r5, h1u5, 0.0, -w1r5, -h1d5, 0.0);

  if(myd5!=-1)line(w2l5, -h2d5, l, -w2r5, -h2d5, l);								/* exit window given by the INNER walls*/
  if(myu5!=-1)line(w2l5, h2u5,  l, -w2r5, h2u5, l);
  if(mxl5!=-1)line(w2l5, -h2d5, l, w2l5, h2u5, l);
  if(mxr5!=-1)line( -w2r5, -h2d5,  l, -w2r5, h2u5, l);

  if(mydOW5!=-1) line((w1lwt5), -(h1dwt5), 0.0, -(w1rwt5), -(h1dwt5), 0.0);					/* entrance window given by the OUTER walls */
  if(myuOW5!=-1)line((w1lwt5), (h1uwt5), 0.0, -(w1rwt5), (h1uwt5), 0.0);
  if(mxlOW5!=-1)line((w1lwt5), -(h1dwt5), 0.0, (w1lwt5), (h1uwt5), 0.0);
  if(mxrOW5!=-1)line( -(w1rwt5), (h1uwt5), 0.0, -(w1rwt5), -(h1dwt5), 0.0);

  if(mydOW5!=-1)line((w2lwt5), -(h2dwt5), l, -(w2rwt5), -(h2dwt5), l);					/* exit windows given by the OUTER walls*/
  if(myuOW5!=-1)line((w2lwt5), (h2uwt5),  l, -(w2rwt5), (h2uwt5), l);
  if(mxlOW5!=-1)line((w2lwt5), -(h2dwt5), l, (w2lwt5), (h2uwt5), l);
  if(mxrOW5!=-1)line( -(w2rwt5), -(h2dwt5),  l, -(w2rwt5), (h2uwt5), l);

  if((myd5!=-1 && mydOW5!=-1) || (mxl5!=-1 && mxlOW5!=-1)) line(w1l5, -h1d5, 0.0, (w1lwt5), -(h1dwt5), 0.0);	/* corner connection lines for the entrance windows*/	
  if((myu5!=-1 && myuOW5!=-1) || (mxl5!=-1 && mxlOW5!=-1)) line(w1l5, h1u5, 0.0, (w1lwt5), (h1uwt5), 0.0);
  if((myd5!=-1 && mydOW5!=-1) || (mxr5!=-1 && mxrOW5!=-1)) line(-w1r5, -h1d5, 0.0,-(w1rwt5),  -(h1dwt5), 0.0);
  if((myu5!=-1 && myuOW5!=-1) || (mxr5!=-1 && mxrOW5!=-1)) line( -w1r5, h1u5, 0.0, -(w1rwt5), (h1uwt5), 0.0);

  if((myd5!=-1 && mydOW5!=-1) || (mxl5!=-1 && mxlOW5!=-1)) line(w2l5, -h2d5, l, (w2lwt5), -(h2dwt5), l);	/* corner connection lines for the exit windows*/
  if((myu5!=-1 && myuOW5!=-1) || (mxl5!=-1 && mxlOW5!=-1)) line(w2l5, h2u5, l, (w2lwt5), (h2uwt5), l);
  if((myd5!=-1 && mydOW5!=-1) || (mxr5!=-1 && mxrOW5!=-1)) line(-w2r5, -h2d5, l,-(w2rwt5),  -(h2dwt5), l);
  if((myu5!=-1 && myuOW5!=-1) || (mxr5!=-1 && mxrOW5!=-1)) line( -w2r5, h2u5, l, -(w2rwt5), (h2uwt5), l);

for(i=0;i<imax;i++){											/* calculation of the points for the INNER LEFT BOTTOM line */
   z=i*l/imax;
   z15=(i+1)*l/imax;
  if(linwl5==0 && loutwl5 == 0)
   {
     x15=ml5*z+nl15;
     x25=ml5*z15+nl15;
   }else{
      if(linwl5!=0 && loutwl5 != 0)
      {
      x15=bwl5*sqrt(1-((z0wl5+z)*(z0wl5+z))/(awl5*awl5));
      x25=bwl5*sqrt(1-((z0wl5+z15)*(z0wl5+z15))/(awl5*awl5));
      }else{
      x15=sqrt((z-pbwl5)/-pawl5);
      x25=sqrt((z15-pbwl5)/-pawl5);
      }
   }
  if(linhd5==0 && louthd5==0)
   {
     y15=md5*z+nd15;
     y25=md5*z15+nd15;
    }else{
      if(linhd5!=0 && louthd5!=0)
      {
      y15=-bhd5*sqrt(1-((z0hd5+z)*(z0hd5+z))/(ahd5*ahd5));
      y25=-bhd5*sqrt(1-((z0hd5+z15)*(z0hd5+z15))/(ahd5*ahd5));
      }else{
      y15=-sqrt((z-pbhd5)/-pahd5);
      y25=-sqrt((z15-pbhd5)/-pahd5);
      }
   }
  if(mxl5!=-1 || myd5!=-1)line((double)x15, (double)y15, (double)z, (double)x25, (double)y25, (double)z15); 
 }

for(i=0;i<imax;i++){											/* calculation of the points for the INNER RIGHT BOTTOM line */
  z=i*l/imax;
  z15=(i+1)*l/imax;
  if(linwr5==0 && loutwr5==0)
  {
    x15=mr5*z+nr15;
    x25=mr5*z15+nr15;
  }else{
    if(linwr5!=0 && loutwr5!=0)
    {
    x15=-bwr5*sqrt(1-((z0wr5+z)*(z0wr5+z))/(awr5*awr5));
    x25=-bwr5*sqrt(1-((z0wr5+z15)*(z0wr5+z15))/(awr5*awr5));
    }else{
    x15=-sqrt((z-pbwr5)/-pawr5);
    x25=-sqrt((z15-pbwr5)/-pawr5);
    }
  }
  if(linhd5==0 && louthd5==0)
  {
    y15=md5*z+nd15;
    y25=md5*z15+nd15;
  }else{
    if(linhd5!=0 && louthd5!=0)
    {
    y15=-bhd5*sqrt(1-((z0hd5+z)*(z0hd5+z))/(ahd5*ahd5));
    y25=-bhd5*sqrt(1-((z0hd5+z15)*(z0hd5+z15))/(ahd5*ahd5));
    }else{
    y15=-sqrt((z-pbhd5)/-pahd5);
    y25=-sqrt((z15-pbhd5)/-pahd5);
    }
  }
  if(mxr5!=-1 || myd5!=-1) line((double)x15, (double)y15, (double)z, (double)x25, (double)y25, (double)z15); 
}


for(i=0;i<imax;i++){											/* calculation of the points for the INNER RIGHT TOP line */
  z=i*l/imax;
  z15=(i+1)*l/imax;
  if(linwr5==0 && loutwr5==0)
  {
    x15=mr5*z+nr15;
    x25=mr5*z15+nr15;
   }else{
     if(linwr5!=0 && loutwr5!=0){
     x15=-bwr5*sqrt(1-((z0wr5+z)*(z0wr5+z))/(awr5*awr5));
     x25=-bwr5*sqrt(1-((z0wr5+z15)*(z0wr5+z15))/(awr5*awr5));
     }else{
     x15=-sqrt((z-pbwr5)/-pawr5);
     x25=-sqrt((z15-pbwr5)/-pawr5);
     }
   }
   if(linhu5==0 && louthu5==0)
  {
    y15=mu5*z+nu15;
    y25=mu5*z15+nu15;
  }else{
    if(linhu5!=0 && louthu5!=0)
    {
    y15=bhu5*sqrt(1-((z0hu5+z)*(z0hu5+z))/(ahu5*ahu5));
    y25=bhu5*sqrt(1-((z0hu5+z15)*(z0hu5+z15))/(ahu5*ahu5));
    }else{
    y15=sqrt((z-pbhu5)/-pahu5);
    y25=sqrt((z15-pbhu5)/-pahu5);
    }
  }
  if(mxr5!=-1 || myu5!=-1)line((double)x15, (double)y15, (double)z, (double)x25, (double)y25, (double)z15); 
}

for(i=0;i<imax;i++){											/* calculation of the points for the INNER LEFT TOP line */
  z=i*l/imax;
  z15=(i+1)*l/imax;
  if(linwl5==0 && loutwl5==0)
  {
    x15=ml5*z+nl15;
    x25=ml5*z15+nl15;
   }else{
     if(linwl5!=0 && loutwl5!=0)
     {
     x15=bwl5*sqrt(1-((z0wl5+z)*(z0wl5+z))/(awl5*awl5));
     x25=bwl5*sqrt(1-((z0wl5+z15)*(z0wl5+z15))/(awl5*awl5));
     }else{
     x15=sqrt((z-pbwl5)/-pawl5);
     x25=sqrt((z15-pbwl5)/-pawl5);
     }
   }
   if(linhu5==0 && louthu5==0)
  {
    y15=mu5*z+nu15;
    y25=mu5*z15+nu15;
  }else{
    if(linhu5!=0 && louthu5!=0)
    {
    y15=bhu5*sqrt(1-((z0hu5+z)*(z0hu5+z))/(ahu5*ahu5));
    y25=bhu5*sqrt(1-((z0hu5+z15)*(z0hu5+z15))/(ahu5*ahu5));
    }else{
    y15=sqrt((z-pbhu5)/-pahu5);
    y25=sqrt((z15-pbhu5)/-pahu5);
    }
  }
  if(mxl5!=-1 || myu5!=-1)line((double)x15, (double)y15, (double)z, (double)x25, (double)y25, (double)z15); 
}																	/* END INNER LINES*/


for(i=0;i<imax;i++){											/* calculation of the points for the OUTER LEFT BOTTOM line */
   z=i*l/imax;
   z15=(i+1)*l/imax;
  if(linwl5==0 && loutwl5 == 0)
   {
     xwt5=ml5*z+nl25;
     x1wt5=ml5*z15+nl25;
   }else{
      if(linwl5!=0 && loutwl5 != 0)
      {
      xwt5=bwlwt5*sqrt(1-((z0wl5+z)*(z0wl5+z))/(awlwt5*awlwt5));
      x1wt5=bwlwt5*sqrt(1-((z0wl5+z15)*(z0wl5+z15))/(awlwt5*awlwt5));
      }else{
      xwt5=sqrt((z-pbwlwt5)/-pawlwt5);
      x1wt5=sqrt((z15-pbwlwt5)/-pawlwt5);
      }
   }
  if(linhd5==0 && louthd5==0)
   {
     ywt5=md5*z+nd25;
     y1wt5=md5*z15+nd25;
    }else{
      if(linhd5!=0 && louthd5!=0)
      {
      ywt5=-bhdwt5*sqrt(1-((z0hd5+z)*(z0hd5+z))/(ahdwt5*ahdwt5));
      y1wt5=-bhdwt5*sqrt(1-((z0hd5+z15)*(z0hd5+z15))/(ahdwt5*ahdwt5));
      }else{
      ywt5=-sqrt((z-pbhdwt5)/-pahdwt5);
      y1wt5=-sqrt((z15-pbhdwt5)/-pahdwt5);
      }
   }
  if(mxlOW5!=-1 || mydOW5!=-1)line((double)xwt5, (double)ywt5, (double)z, (double)x1wt5, (double)y1wt5, (double)z15); 
 }

for(i=0;i<imax;i++){											/* calculation of the points for the OUTER RIGHT BOTTOM line */
  z=i*l/imax;
  z15=(i+1)*l/imax;
  if(linwr5==0 && loutwr5==0)
  {
    xwt5=mr5*z+nr25;
    x1wt5=mr5*z15+nr25;
  }else{
    if(linwr5!=0 && loutwr5!=0)
    {
    xwt5=-bwrwt5*sqrt(1-((z0wr5+z)*(z0wr5+z))/(awrwt5*awrwt5));
    x1wt5=-bwrwt5*sqrt(1-((z0wr5+z15)*(z0wr5+z15))/(awrwt5*awrwt5));
    }else{
    xwt5=-sqrt((z-pbwrwt5)/-pawrwt5);
    x1wt5=-sqrt((z15-pbwrwt5)/-pawrwt5);
    }
  }
  if(linhd5==0 && louthd5==0)
  {
    ywt5=md5*z+nd25;
    y1wt5=md5*z15+nd25;
  }else{
    if(linhd5!=0 && louthd5!=0)
    {
    ywt5=-bhdwt5*sqrt(1-((z0hd5+z)*(z0hd5+z))/(ahdwt5*ahdwt5));
    y1wt5=-bhdwt5*sqrt(1-((z0hd5+z15)*(z0hd5+z15))/(ahdwt5*ahdwt5));
    }else{
    ywt5=-sqrt((z-pbhdwt5)/-pahdwt5);
    y1wt5=-sqrt((z15-pbhdwt5)/-pahdwt5);
    }
  }
  if(mxrOW5!=-1 || mydOW5!=-1) line((double)xwt5, (double)ywt5, (double)z, (double)x1wt5, (double)y1wt5, (double)z15); 
}


for(i=0;i<imax;i++){											/* calculation of the points for the OUTER RIGHT TOP line */
  z=i*l/imax;
  z15=(i+1)*l/imax;
  if(linwr5==0 && loutwr5==0)
  {
    xwt5=mr5*z+nr25;
    x1wt5=mr5*z15+nr25;
   }else{
     if(linwr5!=0 && loutwr5!=0){
     xwt5=-bwrwt5*sqrt(1-((z0wr5+z)*(z0wr5+z))/(awrwt5*awrwt5));
     x1wt5=-bwrwt5*sqrt(1-((z0wr5+z15)*(z0wr5+z15))/(awrwt5*awrwt5));
     }else{
     xwt5=-sqrt((z-pbwrwt5)/-pawrwt5);
     x1wt5=-sqrt((z15-pbwrwt5)/-pawrwt5);
     }
   }
   if(linhu5==0 && louthu5==0)
  {
    ywt5=mu5*z+nu25;
    y1wt5=mu5*z15+nu25;
  }else{
    if(linhu5!=0 && louthu5!=0)
    {
    ywt5=bhuwt5*sqrt(1-((z0hu5+z)*(z0hu5+z))/(ahuwt5*ahuwt5));
    y1wt5=bhuwt5*sqrt(1-((z0hu5+z15)*(z0hu5+z15))/(ahuwt5*ahuwt5));
    }else{
    ywt5=sqrt((z-pbhuwt5)/-pahuwt5);
    y1wt5=sqrt((z15-pbhuwt5)/-pahuwt5);
    }
  }
   if(mxrOW5!=-1 || myuOW5!=-1)line((double)xwt5, (double)ywt5, (double)z, (double)x1wt5, (double)y1wt5, (double)z15); 
}

for(i=0;i<imax;i++){											/* calculation of the points for the OUTER LEFT TOP line */
  z=i*l/imax;
  z15=(i+1)*l/imax;
  if(linwl5==0 && loutwl5==0)
  {
    xwt5=ml5*z+nl25;
    x1wt5=ml5*z15+nl25;
   }else{
     if(linwl5!=0 && loutwl5!=0)
     {
     xwt5=bwlwt5*sqrt(1-((z0wl5+z)*(z0wl5+z))/(awlwt5*awlwt5));
     x1wt5=bwlwt5*sqrt(1-((z0wl5+z15)*(z0wl5+z15))/(awlwt5*awlwt5));
     }else{
     xwt5=sqrt((z-pbwlwt5)/-pawlwt5);
     x1wt5=sqrt((z15-pbwlwt5)/-pawlwt5);
     }
   }
   if(linhu5==0 && louthu5==0)
  {
    ywt5=mu5*z+nu25;
    y1wt5=mu5*z15+nu25;
  }else{
    if(linhu5!=0 && louthu5!=0)
    {
    ywt5=bhuwt5*sqrt(1-((z0hu5+z)*(z0hu5+z))/(ahuwt5*ahuwt5));
    y1wt5=bhuwt5*sqrt(1-((z0hu5+z15)*(z0hu5+z15))/(ahuwt5*ahuwt5));
    }else{
    ywt5=sqrt((z-pbhuwt5)/-pahuwt5);
    y1wt5=sqrt((z15-pbhuwt5)/-pahuwt5);
    }
  }
  if(mxlOW5!=-1 || myuOW5!=-1)line((double)xwt5, (double)ywt5, (double)z, (double)x1wt5, (double)y1wt5, (double)z15); 
}

  if (linwr6==0 && loutwr6==0){
   mr6=(-w2r6+w1r6)/l;
   nr16=-w1r6;
   nr26=-(w1rwt6);
   }


if (linwl6==0 && loutwl6==0){
   ml6=(w2l6-w1l6)/l;
   nl16=w1l6;
   nl26=(w1lwt6);
   }


if (linhu6 == 0 && louthu6==0) 
  {
   mu6=(h2u6-h1u6)/l;
   nu16=h1u6;
   nu26=(h1uwt6);
  }


if (linhd6 == 0 && louthd6==0) 
  {
   md6=(-h2d6+h1d6)/l;
   nd16=-h1d6;
   nd26=-(h1dwt6);
  }

  z0wr6=(linwr6-l-loutwr6)/2.0;
  z0wl6=(linwl6-l-loutwl6)/2.0;
  z0hu6=lbhu6/2.0-l-louthu6;
  z0hd6=lbhd6/2.0-l-louthd6;

  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(myd6!=-1) line(w1l6, -h1d6, 0.0, -w1r6, -h1d6, 0.0);							/* entrance window given by the INNER walls*/
  if(myu6!=-1)line(w1l6, h1u6, 0.0, -w1r6, h1u6, 0.0);
  if(mxl6!=-1)line(w1l6, -h1d6, 0.0, w1l6, h1u6, 0.0);
  if(mxr6!=-1)line( -w1r6, h1u6, 0.0, -w1r6, -h1d6, 0.0);

  if(myd6!=-1)line(w2l6, -h2d6, l, -w2r6, -h2d6, l);								/* exit window given by the INNER walls*/
  if(myu6!=-1)line(w2l6, h2u6,  l, -w2r6, h2u6, l);
  if(mxl6!=-1)line(w2l6, -h2d6, l, w2l6, h2u6, l);
  if(mxr6!=-1)line( -w2r6, -h2d6,  l, -w2r6, h2u6, l);

  if(mydOW6!=-1) line((w1lwt6), -(h1dwt6), 0.0, -(w1rwt6), -(h1dwt6), 0.0);					/* entrance window given by the OUTER walls */
  if(myuOW6!=-1)line((w1lwt6), (h1uwt6), 0.0, -(w1rwt6), (h1uwt6), 0.0);
  if(mxlOW6!=-1)line((w1lwt6), -(h1dwt6), 0.0, (w1lwt6), (h1uwt6), 0.0);
  if(mxrOW6!=-1)line( -(w1rwt6), (h1uwt6), 0.0, -(w1rwt6), -(h1dwt6), 0.0);

  if(mydOW6!=-1)line((w2lwt6), -(h2dwt6), l, -(w2rwt6), -(h2dwt6), l);					/* exit windows given by the OUTER walls*/
  if(myuOW6!=-1)line((w2lwt6), (h2uwt6),  l, -(w2rwt6), (h2uwt6), l);
  if(mxlOW6!=-1)line((w2lwt6), -(h2dwt6), l, (w2lwt6), (h2uwt6), l);
  if(mxrOW6!=-1)line( -(w2rwt6), -(h2dwt6),  l, -(w2rwt6), (h2uwt6), l);

  if((myd6!=-1 && mydOW6!=-1) || (mxl6!=-1 && mxlOW6!=-1)) line(w1l6, -h1d6, 0.0, (w1lwt6), -(h1dwt6), 0.0);	/* corner connection lines for the entrance windows*/	
  if((myu6!=-1 && myuOW6!=-1) || (mxl6!=-1 && mxlOW6!=-1)) line(w1l6, h1u6, 0.0, (w1lwt6), (h1uwt6), 0.0);
  if((myd6!=-1 && mydOW6!=-1) || (mxr6!=-1 && mxrOW6!=-1)) line(-w1r6, -h1d6, 0.0,-(w1rwt6),  -(h1dwt6), 0.0);
  if((myu6!=-1 && myuOW6!=-1) || (mxr6!=-1 && mxrOW6!=-1)) line( -w1r6, h1u6, 0.0, -(w1rwt6), (h1uwt6), 0.0);

  if((myd6!=-1 && mydOW6!=-1) || (mxl6!=-1 && mxlOW6!=-1)) line(w2l6, -h2d6, l, (w2lwt6), -(h2dwt6), l);	/* corner connection lines for the exit windows*/
  if((myu6!=-1 && myuOW6!=-1) || (mxl6!=-1 && mxlOW6!=-1)) line(w2l6, h2u6, l, (w2lwt6), (h2uwt6), l);
  if((myd6!=-1 && mydOW6!=-1) || (mxr6!=-1 && mxrOW6!=-1)) line(-w2r6, -h2d6, l,-(w2rwt6),  -(h2dwt6), l);
  if((myu6!=-1 && myuOW6!=-1) || (mxr6!=-1 && mxrOW6!=-1)) line( -w2r6, h2u6, l, -(w2rwt6), (h2uwt6), l);

for(i=0;i<imax;i++){											/* calculation of the points for the INNER LEFT BOTTOM line */
   z=i*l/imax;
   z16=(i+1)*l/imax;
  if(linwl6==0 && loutwl6 == 0)
   {
     x16=ml6*z+nl16;
     x26=ml6*z16+nl16;
   }else{
      if(linwl6!=0 && loutwl6 != 0)
      {
      x16=bwl6*sqrt(1-((z0wl6+z)*(z0wl6+z))/(awl6*awl6));
      x26=bwl6*sqrt(1-((z0wl6+z16)*(z0wl6+z16))/(awl6*awl6));
      }else{
      x16=sqrt((z-pbwl6)/-pawl6);
      x26=sqrt((z16-pbwl6)/-pawl6);
      }
   }
  if(linhd6==0 && louthd6==0)
   {
     y16=md6*z+nd16;
     y26=md6*z16+nd16;
    }else{
      if(linhd6!=0 && louthd6!=0)
      {
      y16=-bhd6*sqrt(1-((z0hd6+z)*(z0hd6+z))/(ahd6*ahd6));
      y26=-bhd6*sqrt(1-((z0hd6+z16)*(z0hd6+z16))/(ahd6*ahd6));
      }else{
      y16=-sqrt((z-pbhd6)/-pahd6);
      y26=-sqrt((z16-pbhd6)/-pahd6);
      }
   }
  if(mxl6!=-1 || myd6!=-1)line((double)x16, (double)y16, (double)z, (double)x26, (double)y26, (double)z16); 
 }

for(i=0;i<imax;i++){											/* calculation of the points for the INNER RIGHT BOTTOM line */
  z=i*l/imax;
  z16=(i+1)*l/imax;
  if(linwr6==0 && loutwr6==0)
  {
    x16=mr6*z+nr16;
    x26=mr6*z16+nr16;
  }else{
    if(linwr6!=0 && loutwr6!=0)
    {
    x16=-bwr6*sqrt(1-((z0wr6+z)*(z0wr6+z))/(awr6*awr6));
    x26=-bwr6*sqrt(1-((z0wr6+z16)*(z0wr6+z16))/(awr6*awr6));
    }else{
    x16=-sqrt((z-pbwr6)/-pawr6);
    x26=-sqrt((z16-pbwr6)/-pawr6);
    }
  }
  if(linhd6==0 && louthd6==0)
  {
    y16=md6*z+nd16;
    y26=md6*z16+nd16;
  }else{
    if(linhd6!=0 && louthd6!=0)
    {
    y16=-bhd6*sqrt(1-((z0hd6+z)*(z0hd6+z))/(ahd6*ahd6));
    y26=-bhd6*sqrt(1-((z0hd6+z16)*(z0hd6+z16))/(ahd6*ahd6));
    }else{
    y16=-sqrt((z-pbhd6)/-pahd6);
    y26=-sqrt((z16-pbhd6)/-pahd6);
    }
  }
  if(mxr6!=-1 || myd6!=-1) line((double)x16, (double)y16, (double)z, (double)x26, (double)y26, (double)z16); 
}


for(i=0;i<imax;i++){											/* calculation of the points for the INNER RIGHT TOP line */
  z=i*l/imax;
  z16=(i+1)*l/imax;
  if(linwr6==0 && loutwr6==0)
  {
    x16=mr6*z+nr16;
    x26=mr6*z16+nr16;
   }else{
     if(linwr6!=0 && loutwr6!=0){
     x16=-bwr6*sqrt(1-((z0wr6+z)*(z0wr6+z))/(awr6*awr6));
     x26=-bwr6*sqrt(1-((z0wr6+z16)*(z0wr6+z16))/(awr6*awr6));
     }else{
     x16=-sqrt((z-pbwr6)/-pawr6);
     x26=-sqrt((z16-pbwr6)/-pawr6);
     }
   }
   if(linhu6==0 && louthu6==0)
  {
    y16=mu6*z+nu16;
    y26=mu6*z16+nu16;
  }else{
    if(linhu6!=0 && louthu6!=0)
    {
    y16=bhu6*sqrt(1-((z0hu6+z)*(z0hu6+z))/(ahu6*ahu6));
    y26=bhu6*sqrt(1-((z0hu6+z16)*(z0hu6+z16))/(ahu6*ahu6));
    }else{
    y16=sqrt((z-pbhu6)/-pahu6);
    y26=sqrt((z16-pbhu6)/-pahu6);
    }
  }
  if(mxr6!=-1 || myu6!=-1)line((double)x16, (double)y16, (double)z, (double)x26, (double)y26, (double)z16); 
}

for(i=0;i<imax;i++){											/* calculation of the points for the INNER LEFT TOP line */
  z=i*l/imax;
  z16=(i+1)*l/imax;
  if(linwl6==0 && loutwl6==0)
  {
    x16=ml6*z+nl16;
    x26=ml6*z16+nl16;
   }else{
     if(linwl6!=0 && loutwl6!=0)
     {
     x16=bwl6*sqrt(1-((z0wl6+z)*(z0wl6+z))/(awl6*awl6));
     x26=bwl6*sqrt(1-((z0wl6+z16)*(z0wl6+z16))/(awl6*awl6));
     }else{
     x16=sqrt((z-pbwl6)/-pawl6);
     x26=sqrt((z16-pbwl6)/-pawl6);
     }
   }
   if(linhu6==0 && louthu6==0)
  {
    y16=mu6*z+nu16;
    y26=mu6*z16+nu16;
  }else{
    if(linhu6!=0 && louthu6!=0)
    {
    y16=bhu6*sqrt(1-((z0hu6+z)*(z0hu6+z))/(ahu6*ahu6));
    y26=bhu6*sqrt(1-((z0hu6+z16)*(z0hu6+z16))/(ahu6*ahu6));
    }else{
    y16=sqrt((z-pbhu6)/-pahu6);
    y26=sqrt((z16-pbhu6)/-pahu6);
    }
  }
  if(mxl6!=-1 || myu6!=-1)line((double)x16, (double)y16, (double)z, (double)x26, (double)y26, (double)z16); 
}																	/* END INNER LINES*/


for(i=0;i<imax;i++){											/* calculation of the points for the OUTER LEFT BOTTOM line */
   z=i*l/imax;
   z16=(i+1)*l/imax;
  if(linwl6==0 && loutwl6 == 0)
   {
     xwt6=ml6*z+nl26;
     x1wt6=ml6*z16+nl26;
   }else{
      if(linwl6!=0 && loutwl6 != 0)
      {
      xwt6=bwlwt6*sqrt(1-((z0wl6+z)*(z0wl6+z))/(awlwt6*awlwt6));
      x1wt6=bwlwt6*sqrt(1-((z0wl6+z16)*(z0wl6+z16))/(awlwt6*awlwt6));
      }else{
      xwt6=sqrt((z-pbwlwt6)/-pawlwt6);
      x1wt6=sqrt((z16-pbwlwt6)/-pawlwt6);
      }
   }
  if(linhd6==0 && louthd6==0)
   {
     ywt6=md6*z+nd26;
     y1wt6=md6*z16+nd26;
    }else{
      if(linhd6!=0 && louthd6!=0)
      {
      ywt6=-bhdwt6*sqrt(1-((z0hd6+z)*(z0hd6+z))/(ahdwt6*ahdwt6));
      y1wt6=-bhdwt6*sqrt(1-((z0hd6+z16)*(z0hd6+z16))/(ahdwt6*ahdwt6));
      }else{
      ywt6=-sqrt((z-pbhdwt6)/-pahdwt6);
      y1wt6=-sqrt((z16-pbhdwt6)/-pahdwt6);
      }
   }
  if(mxlOW6!=-1 || mydOW6!=-1)line((double)xwt6, (double)ywt6, (double)z, (double)x1wt6, (double)y1wt6, (double)z16); 
 }

for(i=0;i<imax;i++){											/* calculation of the points for the OUTER RIGHT BOTTOM line */
  z=i*l/imax;
  z16=(i+1)*l/imax;
  if(linwr6==0 && loutwr6==0)
  {
    xwt6=mr6*z+nr26;
    x1wt6=mr6*z16+nr26;
  }else{
    if(linwr6!=0 && loutwr6!=0)
    {
    xwt6=-bwrwt6*sqrt(1-((z0wr6+z)*(z0wr6+z))/(awrwt6*awrwt6));
    x1wt6=-bwrwt6*sqrt(1-((z0wr6+z16)*(z0wr6+z16))/(awrwt6*awrwt6));
    }else{
    xwt6=-sqrt((z-pbwrwt6)/-pawrwt6);
    x1wt6=-sqrt((z16-pbwrwt6)/-pawrwt6);
    }
  }
  if(linhd6==0 && louthd6==0)
  {
    ywt6=md6*z+nd26;
    y1wt6=md6*z16+nd26;
  }else{
    if(linhd6!=0 && louthd6!=0)
    {
    ywt6=-bhdwt6*sqrt(1-((z0hd6+z)*(z0hd6+z))/(ahdwt6*ahdwt6));
    y1wt6=-bhdwt6*sqrt(1-((z0hd6+z16)*(z0hd6+z16))/(ahdwt6*ahdwt6));
    }else{
    ywt6=-sqrt((z-pbhdwt6)/-pahdwt6);
    y1wt6=-sqrt((z16-pbhdwt6)/-pahdwt6);
    }
  }
  if(mxrOW6!=-1 || mydOW6!=-1) line((double)xwt6, (double)ywt6, (double)z, (double)x1wt6, (double)y1wt6, (double)z16); 
}


for(i=0;i<imax;i++){											/* calculation of the points for the OUTER RIGHT TOP line */
  z=i*l/imax;
  z16=(i+1)*l/imax;
  if(linwr6==0 && loutwr6==0)
  {
    xwt6=mr6*z+nr26;
    x1wt6=mr6*z16+nr26;
   }else{
     if(linwr6!=0 && loutwr6!=0){
     xwt6=-bwrwt6*sqrt(1-((z0wr6+z)*(z0wr6+z))/(awrwt6*awrwt6));
     x1wt6=-bwrwt6*sqrt(1-((z0wr6+z16)*(z0wr6+z16))/(awrwt6*awrwt6));
     }else{
     xwt6=-sqrt((z-pbwrwt6)/-pawrwt6);
     x1wt6=-sqrt((z16-pbwrwt6)/-pawrwt6);
     }
   }
   if(linhu6==0 && louthu6==0)
  {
    ywt6=mu6*z+nu26;
    y1wt6=mu6*z16+nu26;
  }else{
    if(linhu6!=0 && louthu6!=0)
    {
    ywt6=bhuwt6*sqrt(1-((z0hu6+z)*(z0hu6+z))/(ahuwt6*ahuwt6));
    y1wt6=bhuwt6*sqrt(1-((z0hu6+z16)*(z0hu6+z16))/(ahuwt6*ahuwt6));
    }else{
    ywt6=sqrt((z-pbhuwt6)/-pahuwt6);
    y1wt6=sqrt((z16-pbhuwt6)/-pahuwt6);
    }
  }
   if(mxrOW6!=-1 || myuOW6!=-1)line((double)xwt6, (double)ywt6, (double)z, (double)x1wt6, (double)y1wt6, (double)z16); 
}

for(i=0;i<imax;i++){											/* calculation of the points for the OUTER LEFT TOP line */
  z=i*l/imax;
  z16=(i+1)*l/imax;
  if(linwl6==0 && loutwl6==0)
  {
    xwt6=ml6*z+nl26;
    x1wt6=ml6*z16+nl26;
   }else{
     if(linwl6!=0 && loutwl6!=0)
     {
     xwt6=bwlwt6*sqrt(1-((z0wl6+z)*(z0wl6+z))/(awlwt6*awlwt6));
     x1wt6=bwlwt6*sqrt(1-((z0wl6+z16)*(z0wl6+z16))/(awlwt6*awlwt6));
     }else{
     xwt6=sqrt((z-pbwlwt6)/-pawlwt6);
     x1wt6=sqrt((z16-pbwlwt6)/-pawlwt6);
     }
   }
   if(linhu6==0 && louthu6==0)
  {
    ywt6=mu6*z+nu26;
    y1wt6=mu6*z16+nu26;
  }else{
    if(linhu6!=0 && louthu6!=0)
    {
    ywt6=bhuwt6*sqrt(1-((z0hu6+z)*(z0hu6+z))/(ahuwt6*ahuwt6));
    y1wt6=bhuwt6*sqrt(1-((z0hu6+z16)*(z0hu6+z16))/(ahuwt6*ahuwt6));
    }else{
    ywt6=sqrt((z-pbhuwt6)/-pahuwt6);
    y1wt6=sqrt((z16-pbhuwt6)/-pahuwt6);
    }
  }
  if(mxlOW6!=-1 || myuOW6!=-1)line((double)xwt6, (double)ywt6, (double)z, (double)x1wt6, (double)y1wt6, (double)z16); 
}

 if (linwr7==0 && loutwr7==0){
   mr7=(-w2r7+w1r7)/l;
   nr17=-w1r7;
   nr27=-(w1rwt7);
   }


if (linwl7==0 && loutwl7==0){
   ml7=(w2l7-w1l7)/l;
   nl17=w1l7;
   nl27=(w1lwt7);
   }


if (linhu7 == 0 && louthu7==0) 
  {
   mu7=(h2u7-h1u7)/l;
   nu17=h1u7;
   nu27=(h1uwt7);
  }


if (linhd7 == 0 && louthd7==0) 
  {
   md7=(-h2d7+h1d7)/l;
   nd17=-h1d7;
   nd27=-(h1dwt7);
  }

  z0wr7=(linwr7-l-loutwr7)/2.0;
  z0wl7=(linwl7-l-loutwl7)/2.0;
  z0hu7=lbhu7/2.0-l-louthu7;
  z0hd7=lbhd7/2.0-l-louthd7;

  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(myd7!=-1) line(w1l7, -h1d7, 0.0, -w1r7, -h1d7, 0.0);							/* entrance window given by the INNER walls*/
  if(myu7!=-1)line(w1l7, h1u7, 0.0, -w1r7, h1u7, 0.0);
  if(mxl7!=-1)line(w1l7, -h1d7, 0.0, w1l7, h1u7, 0.0);
  if(mxr7!=-1)line( -w1r7, h1u7, 0.0, -w1r7, -h1d7, 0.0);

  if(myd7!=-1)line(w2l7, -h2d7, l, -w2r7, -h2d7, l);								/* exit window given by the INNER walls*/
  if(myu7!=-1)line(w2l7, h2u7,  l, -w2r7, h2u7, l);
  if(mxl7!=-1)line(w2l7, -h2d7, l, w2l7, h2u7, l);
  if(mxr7!=-1)line( -w2r7, -h2d7,  l, -w2r7, h2u7, l);

  if(mydOW7!=-1) line((w1lwt7), -(h1dwt7), 0.0, -(w1rwt7), -(h1dwt7), 0.0);					/* entrance window given by the OUTER walls */
  if(myuOW7!=-1)line((w1lwt7), (h1uwt7), 0.0, -(w1rwt7), (h1uwt7), 0.0);
  if(mxlOW7!=-1)line((w1lwt7), -(h1dwt7), 0.0, (w1lwt7), (h1uwt7), 0.0);
  if(mxrOW7!=-1)line( -(w1rwt7), (h1uwt7), 0.0, -(w1rwt7), -(h1dwt7), 0.0);

  if(mydOW7!=-1)line((w2lwt7), -(h2dwt7), l, -(w2rwt7), -(h2dwt7), l);					/* exit windows given by the OUTER walls*/
  if(myuOW7!=-1)line((w2lwt7), (h2uwt7),  l, -(w2rwt7), (h2uwt7), l);
  if(mxlOW7!=-1)line((w2lwt7), -(h2dwt7), l, (w2lwt7), (h2uwt7), l);
  if(mxrOW7!=-1)line( -(w2rwt7), -(h2dwt7),  l, -(w2rwt7), (h2uwt7), l);

  if((myd7!=-1 && mydOW7!=-1) || (mxl7!=-1 && mxlOW7!=-1)) line(w1l7, -h1d7, 0.0, (w1lwt7), -(h1dwt7), 0.0);	/* corner connection lines for the entrance windows*/	
  if((myu7!=-1 && myuOW7!=-1) || (mxl7!=-1 && mxlOW7!=-1)) line(w1l7, h1u7, 0.0, (w1lwt7), (h1uwt7), 0.0);
  if((myd7!=-1 && mydOW7!=-1) || (mxr7!=-1 && mxrOW7!=-1)) line(-w1r7, -h1d7, 0.0,-(w1rwt7),  -(h1dwt7), 0.0);
  if((myu7!=-1 && myuOW7!=-1) || (mxr7!=-1 && mxrOW7!=-1)) line( -w1r7, h1u7, 0.0, -(w1rwt7), (h1uwt7), 0.0);

  if((myd7!=-1 && mydOW7!=-1) || (mxl7!=-1 && mxlOW7!=-1)) line(w2l7, -h2d7, l, (w2lwt7), -(h2dwt7), l);	/* corner connection lines for the exit windows*/
  if((myu7!=-1 && myuOW7!=-1) || (mxl7!=-1 && mxlOW7!=-1)) line(w2l7, h2u7, l, (w2lwt7), (h2uwt7), l);
  if((myd7!=-1 && mydOW7!=-1) || (mxr7!=-1 && mxrOW7!=-1)) line(-w2r7, -h2d7, l,-(w2rwt7),  -(h2dwt7), l);
  if((myu7!=-1 && myuOW7!=-1) || (mxr7!=-1 && mxrOW7!=-1)) line( -w2r7, h2u7, l, -(w2rwt7), (h2uwt7), l);

for(i=0;i<imax;i++){											/* calculation of the points for the INNER LEFT BOTTOM line */
   z=i*l/imax;
   z17=(i+1)*l/imax;
  if(linwl7==0 && loutwl7 == 0)
   {
     x17=ml7*z+nl17;
     x27=ml7*z17+nl17;
   }else{
      if(linwl7!=0 && loutwl7 != 0)
      {
      x17=bwl7*sqrt(1-((z0wl7+z)*(z0wl7+z))/(awl7*awl7));
      x27=bwl7*sqrt(1-((z0wl7+z17)*(z0wl7+z17))/(awl7*awl7));
      }else{
      x17=sqrt((z-pbwl7)/-pawl7);
      x27=sqrt((z17-pbwl7)/-pawl7);
      }
   }
  if(linhd7==0 && louthd7==0)
   {
     y17=md7*z+nd17;
     y27=md7*z17+nd17;
    }else{
      if(linhd7!=0 && louthd7!=0)
      {
      y17=-bhd7*sqrt(1-((z0hd7+z)*(z0hd7+z))/(ahd7*ahd7));
      y27=-bhd7*sqrt(1-((z0hd7+z17)*(z0hd7+z17))/(ahd7*ahd7));
      }else{
      y17=-sqrt((z-pbhd7)/-pahd7);
      y27=-sqrt((z17-pbhd7)/-pahd7);
      }
   }
  if(mxl7!=-1 || myd7!=-1)line((double)x17, (double)y17, (double)z, (double)x27, (double)y27, (double)z17); 
 }

for(i=0;i<imax;i++){											/* calculation of the points for the INNER RIGHT BOTTOM line */
  z=i*l/imax;
  z17=(i+1)*l/imax;
  if(linwr7==0 && loutwr7==0)
  {
    x17=mr7*z+nr17;
    x27=mr7*z17+nr17;
  }else{
    if(linwr7!=0 && loutwr7!=0)
    {
    x17=-bwr7*sqrt(1-((z0wr7+z)*(z0wr7+z))/(awr7*awr7));
    x27=-bwr7*sqrt(1-((z0wr7+z17)*(z0wr7+z17))/(awr7*awr7));
    }else{
    x17=-sqrt((z-pbwr7)/-pawr7);
    x27=-sqrt((z17-pbwr7)/-pawr7);
    }
  }
  if(linhd7==0 && louthd7==0)
  {
    y17=md7*z+nd17;
    y27=md7*z17+nd17;
  }else{
    if(linhd7!=0 && louthd7!=0)
    {
    y17=-bhd7*sqrt(1-((z0hd7+z)*(z0hd7+z))/(ahd7*ahd7));
    y27=-bhd7*sqrt(1-((z0hd7+z17)*(z0hd7+z17))/(ahd7*ahd7));
    }else{
    y17=-sqrt((z-pbhd7)/-pahd7);
    y27=-sqrt((z17-pbhd7)/-pahd7);
    }
  }
  if(mxr7!=-1 || myd7!=-1) line((double)x17, (double)y17, (double)z, (double)x27, (double)y27, (double)z17); 
}


for(i=0;i<imax;i++){											/* calculation of the points for the INNER RIGHT TOP line */
  z=i*l/imax;
  z17=(i+1)*l/imax;
  if(linwr7==0 && loutwr7==0)
  {
    x17=mr7*z+nr17;
    x27=mr7*z17+nr17;
   }else{
     if(linwr7!=0 && loutwr7!=0){
     x17=-bwr7*sqrt(1-((z0wr7+z)*(z0wr7+z))/(awr7*awr7));
     x27=-bwr7*sqrt(1-((z0wr7+z17)*(z0wr7+z17))/(awr7*awr7));
     }else{
     x17=-sqrt((z-pbwr7)/-pawr7);
     x27=-sqrt((z17-pbwr7)/-pawr7);
     }
   }
   if(linhu7==0 && louthu7==0)
  {
    y17=mu7*z+nu17;
    y27=mu7*z17+nu17;
  }else{
    if(linhu7!=0 && louthu7!=0)
    {
    y17=bhu7*sqrt(1-((z0hu7+z)*(z0hu7+z))/(ahu7*ahu7));
    y27=bhu7*sqrt(1-((z0hu7+z17)*(z0hu7+z17))/(ahu7*ahu7));
    }else{
    y17=sqrt((z-pbhu7)/-pahu7);
    y27=sqrt((z17-pbhu7)/-pahu7);
    }
  }
  if(mxr7!=-1 || myu7!=-1)line((double)x17, (double)y17, (double)z, (double)x27, (double)y27, (double)z17); 
}

for(i=0;i<imax;i++){											/* calculation of the points for the INNER LEFT TOP line */
  z=i*l/imax;
  z17=(i+1)*l/imax;
  if(linwl7==0 && loutwl7==0)
  {
    x17=ml7*z+nl17;
    x27=ml7*z17+nl17;
   }else{
     if(linwl7!=0 && loutwl7!=0)
     {
     x17=bwl7*sqrt(1-((z0wl7+z)*(z0wl7+z))/(awl7*awl7));
     x27=bwl7*sqrt(1-((z0wl7+z17)*(z0wl7+z17))/(awl7*awl7));
     }else{
     x17=sqrt((z-pbwl7)/-pawl7);
     x27=sqrt((z17-pbwl7)/-pawl7);
     }
   }
   if(linhu7==0 && louthu7==0)
  {
    y17=mu7*z+nu17;
    y27=mu7*z17+nu17;
  }else{
    if(linhu7!=0 && louthu7!=0)
    {
    y17=bhu7*sqrt(1-((z0hu7+z)*(z0hu7+z))/(ahu7*ahu7));
    y27=bhu7*sqrt(1-((z0hu7+z17)*(z0hu7+z17))/(ahu7*ahu7));
    }else{
    y17=sqrt((z-pbhu7)/-pahu7);
    y27=sqrt((z17-pbhu7)/-pahu7);
    }
  }
  if(mxl7!=-1 || myu7!=-1)line((double)x17, (double)y17, (double)z, (double)x27, (double)y27, (double)z17); 
}																	/* END INNER LINES*/


for(i=0;i<imax;i++){											/* calculation of the points for the OUTER LEFT BOTTOM line */
   z=i*l/imax;
   z17=(i+1)*l/imax;
  if(linwl7==0 && loutwl7 == 0)
   {
     xwt7=ml7*z+nl27;
     x1wt7=ml7*z17+nl27;
   }else{
      if(linwl7!=0 && loutwl7 != 0)
      {
      xwt7=bwlwt7*sqrt(1-((z0wl7+z)*(z0wl7+z))/(awlwt7*awlwt7));
      x1wt7=bwlwt7*sqrt(1-((z0wl7+z17)*(z0wl7+z17))/(awlwt7*awlwt7));
      }else{
      xwt7=sqrt((z-pbwlwt7)/-pawlwt7);
      x1wt7=sqrt((z17-pbwlwt7)/-pawlwt7);
      }
   }
  if(linhd7==0 && louthd7==0)
   {
     ywt7=md7*z+nd27;
     y1wt7=md7*z17+nd27;
    }else{
      if(linhd7!=0 && louthd7!=0)
      {
      ywt7=-bhdwt7*sqrt(1-((z0hd7+z)*(z0hd7+z))/(ahdwt7*ahdwt7));
      y1wt7=-bhdwt7*sqrt(1-((z0hd7+z17)*(z0hd7+z17))/(ahdwt7*ahdwt7));
      }else{
      ywt7=-sqrt((z-pbhdwt7)/-pahdwt7);
      y1wt7=-sqrt((z17-pbhdwt7)/-pahdwt7);
      }
   }
  if(mxlOW7!=-1 || mydOW7!=-1)line((double)xwt7, (double)ywt7, (double)z, (double)x1wt7, (double)y1wt7, (double)z17); 
 }

for(i=0;i<imax;i++){											/* calculation of the points for the OUTER RIGHT BOTTOM line */
  z=i*l/imax;
  z17=(i+1)*l/imax;
  if(linwr7==0 && loutwr7==0)
  {
    xwt7=mr7*z+nr27;
    x1wt7=mr7*z17+nr27;
  }else{
    if(linwr7!=0 && loutwr7!=0)
    {
    xwt7=-bwrwt7*sqrt(1-((z0wr7+z)*(z0wr7+z))/(awrwt7*awrwt7));
    x1wt7=-bwrwt7*sqrt(1-((z0wr7+z17)*(z0wr7+z17))/(awrwt7*awrwt7));
    }else{
    xwt7=-sqrt((z-pbwrwt7)/-pawrwt7);
    x1wt7=-sqrt((z17-pbwrwt7)/-pawrwt7);
    }
  }
  if(linhd7==0 && louthd7==0)
  {
    ywt7=md7*z+nd27;
    y1wt7=md7*z17+nd27;
  }else{
    if(linhd7!=0 && louthd7!=0)
    {
    ywt7=-bhdwt7*sqrt(1-((z0hd7+z)*(z0hd7+z))/(ahdwt7*ahdwt7));
    y1wt7=-bhdwt7*sqrt(1-((z0hd7+z17)*(z0hd7+z17))/(ahdwt7*ahdwt7));
    }else{
    ywt7=-sqrt((z-pbhdwt7)/-pahdwt7);
    y1wt7=-sqrt((z17-pbhdwt7)/-pahdwt7);
    }
  }
  if(mxrOW7!=-1 || mydOW7!=-1) line((double)xwt7, (double)ywt7, (double)z, (double)x1wt7, (double)y1wt7, (double)z17); 
}


for(i=0;i<imax;i++){											/* calculation of the points for the OUTER RIGHT TOP line */
  z=i*l/imax;
  z17=(i+1)*l/imax;
  if(linwr7==0 && loutwr7==0)
  {
    xwt7=mr7*z+nr27;
    x1wt7=mr7*z17+nr27;
   }else{
     if(linwr7!=0 && loutwr7!=0){
     xwt7=-bwrwt7*sqrt(1-((z0wr7+z)*(z0wr7+z))/(awrwt7*awrwt7));
     x1wt7=-bwrwt7*sqrt(1-((z0wr7+z17)*(z0wr7+z17))/(awrwt7*awrwt7));
     }else{
     xwt7=-sqrt((z-pbwrwt7)/-pawrwt7);
     x1wt7=-sqrt((z17-pbwrwt7)/-pawrwt7);
     }
   }
   if(linhu7==0 && louthu7==0)
  {
    ywt7=mu7*z+nu27;
    y1wt7=mu7*z17+nu27;
  }else{
    if(linhu7!=0 && louthu7!=0)
    {
    ywt7=bhuwt7*sqrt(1-((z0hu7+z)*(z0hu7+z))/(ahuwt7*ahuwt7));
    y1wt7=bhuwt7*sqrt(1-((z0hu7+z17)*(z0hu7+z17))/(ahuwt7*ahuwt7));
    }else{
    ywt7=sqrt((z-pbhuwt7)/-pahuwt7);
    y1wt7=sqrt((z17-pbhuwt7)/-pahuwt7);
    }
  }
   if(mxrOW7!=-1 || myuOW7!=-1)line((double)xwt7, (double)ywt7, (double)z, (double)x1wt7, (double)y1wt7, (double)z17); 
}

for(i=0;i<imax;i++){											/* calculation of the points for the OUTER LEFT TOP line */
  z=i*l/imax;
  z17=(i+1)*l/imax;
  if(linwl7==0 && loutwl7==0)
  {
    xwt7=ml7*z+nl27;
    x1wt7=ml7*z17+nl27;
   }else{
     if(linwl7!=0 && loutwl7!=0)
     {
     xwt7=bwlwt7*sqrt(1-((z0wl7+z)*(z0wl7+z))/(awlwt7*awlwt7));
     x1wt7=bwlwt7*sqrt(1-((z0wl7+z17)*(z0wl7+z17))/(awlwt7*awlwt7));
     }else{
     xwt7=sqrt((z-pbwlwt7)/-pawlwt7);
     x1wt7=sqrt((z17-pbwlwt7)/-pawlwt7);
     }
   }
   if(linhu7==0 && louthu7==0)
  {
    ywt7=mu7*z+nu27;
    y1wt7=mu7*z17+nu27;
  }else{
    if(linhu7!=0 && louthu7!=0)
    {
    ywt7=bhuwt7*sqrt(1-((z0hu7+z)*(z0hu7+z))/(ahuwt7*ahuwt7));
    y1wt7=bhuwt7*sqrt(1-((z0hu7+z17)*(z0hu7+z17))/(ahuwt7*ahuwt7));
    }else{
    ywt7=sqrt((z-pbhuwt7)/-pahuwt7);
    y1wt7=sqrt((z17-pbhuwt7)/-pahuwt7);
    }
  }
  if(mxlOW7!=-1 || myuOW7!=-1)line((double)xwt7, (double)ywt7, (double)z, (double)x1wt7, (double)y1wt7, (double)z17); 
}

  if (linwr8==0 && loutwr8==0){
   mr8=(-w2r8+w1r8)/l;
   nr18=-w1r8;
   nr28=-(w1rwt8);
   }


if (linwl8==0 && loutwl8==0){
   ml8=(w2l8-w1l8)/l;
   nl18=w1l8;
   nl28=(w1lwt8);
   }


if (linhu8 == 0 && louthu8==0) 
  {
   mu8=(h2u8-h1u8)/l;
   nu18=h1u8;
   nu28=(h1uwt8);
  }


if (linhd8 == 0 && louthd8==0) 
  {
   md8=(-h2d8+h1d8)/l;
   nd18=-h1d8;
   nd28=-(h1dwt8);
  }

  z0wr8=(linwr8-l-loutwr8)/2.0;
  z0wl8=(linwl8-l-loutwl8)/2.0;
  z0hu8=lbhu8/2.0-l-louthu8;
  z0hd8=lbhd8/2.0-l-louthd8;

  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(myd8!=-1) line(w1l8, -h1d8, 0.0, -w1r8, -h1d8, 0.0);							/* entrance window given by the INNER walls*/
  if(myu8!=-1)line(w1l8, h1u8, 0.0, -w1r8, h1u8, 0.0);
  if(mxl8!=-1)line(w1l8, -h1d8, 0.0, w1l8, h1u8, 0.0);
  if(mxr8!=-1)line( -w1r8, h1u8, 0.0, -w1r8, -h1d8, 0.0);

  if(myd8!=-1)line(w2l8, -h2d8, l, -w2r8, -h2d8, l);								/* exit window given by the INNER walls*/
  if(myu8!=-1)line(w2l8, h2u8,  l, -w2r8, h2u8, l);
  if(mxl8!=-1)line(w2l8, -h2d8, l, w2l8, h2u8, l);
  if(mxr8!=-1)line( -w2r8, -h2d8,  l, -w2r8, h2u8, l);

  if(mydOW8!=-1) line((w1lwt8), -(h1dwt8), 0.0, -(w1rwt8), -(h1dwt8), 0.0);					/* entrance window given by the OUTER walls */
  if(myuOW8!=-1)line((w1lwt8), (h1uwt8), 0.0, -(w1rwt8), (h1uwt8), 0.0);
  if(mxlOW8!=-1)line((w1lwt8), -(h1dwt8), 0.0, (w1lwt8), (h1uwt8), 0.0);
  if(mxrOW8!=-1)line( -(w1rwt8), (h1uwt8), 0.0, -(w1rwt8), -(h1dwt8), 0.0);

  if(mydOW8!=-1)line((w2lwt8), -(h2dwt8), l, -(w2rwt8), -(h2dwt8), l);					/* exit windows given by the OUTER walls*/
  if(myuOW8!=-1)line((w2lwt8), (h2uwt8),  l, -(w2rwt8), (h2uwt8), l);
  if(mxlOW8!=-1)line((w2lwt8), -(h2dwt8), l, (w2lwt8), (h2uwt8), l);
  if(mxrOW8!=-1)line( -(w2rwt8), -(h2dwt8),  l, -(w2rwt8), (h2uwt8), l);

  if((myd8!=-1 && mydOW8!=-1) || (mxl8!=-1 && mxlOW8!=-1)) line(w1l8, -h1d8, 0.0, (w1lwt8), -(h1dwt8), 0.0);	/* corner connection lines for the entrance windows*/	
  if((myu8!=-1 && myuOW8!=-1) || (mxl8!=-1 && mxlOW8!=-1)) line(w1l8, h1u8, 0.0, (w1lwt8), (h1uwt8), 0.0);
  if((myd8!=-1 && mydOW8!=-1) || (mxr8!=-1 && mxrOW8!=-1)) line(-w1r8, -h1d8, 0.0,-(w1rwt8),  -(h1dwt8), 0.0);
  if((myu8!=-1 && myuOW8!=-1) || (mxr8!=-1 && mxrOW8!=-1)) line( -w1r8, h1u8, 0.0, -(w1rwt8), (h1uwt8), 0.0);

  if((myd8!=-1 && mydOW8!=-1) || (mxl8!=-1 && mxlOW8!=-1)) line(w2l8, -h2d8, l, (w2lwt8), -(h2dwt8), l);	/* corner connection lines for the exit windows*/
  if((myu8!=-1 && myuOW8!=-1) || (mxl8!=-1 && mxlOW8!=-1)) line(w2l8, h2u8, l, (w2lwt8), (h2uwt8), l);
  if((myd8!=-1 && mydOW8!=-1) || (mxr8!=-1 && mxrOW8!=-1)) line(-w2r8, -h2d8, l,-(w2rwt8),  -(h2dwt8), l);
  if((myu8!=-1 && myuOW8!=-1) || (mxr8!=-1 && mxrOW8!=-1)) line( -w2r8, h2u8, l, -(w2rwt8), (h2uwt8), l);

for(i=0;i<imax;i++){											/* calculation of the points for the INNER LEFT BOTTOM line */
   z=i*l/imax;
   z18=(i+1)*l/imax;
  if(linwl8==0 && loutwl8 == 0)
   {
     x18=ml8*z+nl18;
     x28=ml8*z18+nl18;
   }else{
      if(linwl8!=0 && loutwl8 != 0)
      {
      x18=bwl8*sqrt(1-((z0wl8+z)*(z0wl8+z))/(awl8*awl8));
      x28=bwl8*sqrt(1-((z0wl8+z18)*(z0wl8+z18))/(awl8*awl8));
      }else{
      x18=sqrt((z-pbwl8)/-pawl8);
      x28=sqrt((z18-pbwl8)/-pawl8);
      }
   }
  if(linhd8==0 && louthd8==0)
   {
     y18=md8*z+nd18;
     y28=md8*z18+nd18;
    }else{
      if(linhd8!=0 && louthd8!=0)
      {
      y18=-bhd8*sqrt(1-((z0hd8+z)*(z0hd8+z))/(ahd8*ahd8));
      y28=-bhd8*sqrt(1-((z0hd8+z18)*(z0hd8+z18))/(ahd8*ahd8));
      }else{
      y18=-sqrt((z-pbhd8)/-pahd8);
      y28=-sqrt((z18-pbhd8)/-pahd8);
      }
   }
  if(mxl8!=-1 || myd8!=-1)line((double)x18, (double)y18, (double)z, (double)x28, (double)y28, (double)z18); 
 }

for(i=0;i<imax;i++){											/* calculation of the points for the INNER RIGHT BOTTOM line */
  z=i*l/imax;
  z18=(i+1)*l/imax;
  if(linwr8==0 && loutwr8==0)
  {
    x18=mr8*z+nr18;
    x28=mr8*z18+nr18;
  }else{
    if(linwr8!=0 && loutwr8!=0)
    {
    x18=-bwr8*sqrt(1-((z0wr8+z)*(z0wr8+z))/(awr8*awr8));
    x28=-bwr8*sqrt(1-((z0wr8+z18)*(z0wr8+z18))/(awr8*awr8));
    }else{
    x18=-sqrt((z-pbwr8)/-pawr8);
    x28=-sqrt((z18-pbwr8)/-pawr8);
    }
  }
  if(linhd8==0 && louthd8==0)
  {
    y18=md8*z+nd18;
    y28=md8*z18+nd18;
  }else{
    if(linhd8!=0 && louthd8!=0)
    {
    y18=-bhd8*sqrt(1-((z0hd8+z)*(z0hd8+z))/(ahd8*ahd8));
    y28=-bhd8*sqrt(1-((z0hd8+z18)*(z0hd8+z18))/(ahd8*ahd8));
    }else{
    y18=-sqrt((z-pbhd8)/-pahd8);
    y28=-sqrt((z18-pbhd8)/-pahd8);
    }
  }
  if(mxr8!=-1 || myd8!=-1) line((double)x18, (double)y18, (double)z, (double)x28, (double)y28, (double)z18); 
}


for(i=0;i<imax;i++){											/* calculation of the points for the INNER RIGHT TOP line */
  z=i*l/imax;
  z18=(i+1)*l/imax;
  if(linwr8==0 && loutwr8==0)
  {
    x18=mr8*z+nr18;
    x28=mr8*z18+nr18;
   }else{
     if(linwr8!=0 && loutwr8!=0){
     x18=-bwr8*sqrt(1-((z0wr8+z)*(z0wr8+z))/(awr8*awr8));
     x28=-bwr8*sqrt(1-((z0wr8+z18)*(z0wr8+z18))/(awr8*awr8));
     }else{
     x18=-sqrt((z-pbwr8)/-pawr8);
     x28=-sqrt((z18-pbwr8)/-pawr8);
     }
   }
   if(linhu8==0 && louthu8==0)
  {
    y18=mu8*z+nu18;
    y28=mu8*z18+nu18;
  }else{
    if(linhu8!=0 && louthu8!=0)
    {
    y18=bhu8*sqrt(1-((z0hu8+z)*(z0hu8+z))/(ahu8*ahu8));
    y28=bhu8*sqrt(1-((z0hu8+z18)*(z0hu8+z18))/(ahu8*ahu8));
    }else{
    y18=sqrt((z-pbhu8)/-pahu8);
    y28=sqrt((z18-pbhu8)/-pahu8);
    }
  }
  if(mxr8!=-1 || myu8!=-1)line((double)x18, (double)y18, (double)z, (double)x28, (double)y28, (double)z18); 
}

for(i=0;i<imax;i++){											/* calculation of the points for the INNER LEFT TOP line */
  z=i*l/imax;
  z18=(i+1)*l/imax;
  if(linwl8==0 && loutwl8==0)
  {
    x18=ml8*z+nl18;
    x28=ml8*z18+nl18;
   }else{
     if(linwl8!=0 && loutwl8!=0)
     {
     x18=bwl8*sqrt(1-((z0wl8+z)*(z0wl8+z))/(awl8*awl8));
     x28=bwl8*sqrt(1-((z0wl8+z18)*(z0wl8+z18))/(awl8*awl8));
     }else{
     x18=sqrt((z-pbwl8)/-pawl8);
     x28=sqrt((z18-pbwl8)/-pawl8);
     }
   }
   if(linhu8==0 && louthu8==0)
  {
    y18=mu8*z+nu18;
    y28=mu8*z18+nu18;
  }else{
    if(linhu8!=0 && louthu8!=0)
    {
    y18=bhu8*sqrt(1-((z0hu8+z)*(z0hu8+z))/(ahu8*ahu8));
    y28=bhu8*sqrt(1-((z0hu8+z18)*(z0hu8+z18))/(ahu8*ahu8));
    }else{
    y18=sqrt((z-pbhu8)/-pahu8);
    y28=sqrt((z18-pbhu8)/-pahu8);
    }
  }
  if(mxl8!=-1 || myu8!=-1)line((double)x18, (double)y18, (double)z, (double)x28, (double)y28, (double)z18); 
}																	/* END INNER LINES*/


for(i=0;i<imax;i++){											/* calculation of the points for the OUTER LEFT BOTTOM line */
   z=i*l/imax;
   z18=(i+1)*l/imax;
  if(linwl8==0 && loutwl8 == 0)
   {
     xwt8=ml8*z+nl28;
     x1wt8=ml8*z18+nl28;
   }else{
      if(linwl8!=0 && loutwl8 != 0)
      {
      xwt8=bwlwt8*sqrt(1-((z0wl8+z)*(z0wl8+z))/(awlwt8*awlwt8));
      x1wt8=bwlwt8*sqrt(1-((z0wl8+z18)*(z0wl8+z18))/(awlwt8*awlwt8));
      }else{
      xwt8=sqrt((z-pbwlwt8)/-pawlwt8);
      x1wt8=sqrt((z18-pbwlwt8)/-pawlwt8);
      }
   }
  if(linhd8==0 && louthd8==0)
   {
     ywt8=md8*z+nd28;
     y1wt8=md8*z18+nd28;
    }else{
      if(linhd8!=0 && louthd8!=0)
      {
      ywt8=-bhdwt8*sqrt(1-((z0hd8+z)*(z0hd8+z))/(ahdwt8*ahdwt8));
      y1wt8=-bhdwt8*sqrt(1-((z0hd8+z18)*(z0hd8+z18))/(ahdwt8*ahdwt8));
      }else{
      ywt8=-sqrt((z-pbhdwt8)/-pahdwt8);
      y1wt8=-sqrt((z18-pbhdwt8)/-pahdwt8);
      }
   }
  if(mxlOW8!=-1 || mydOW8!=-1)line((double)xwt8, (double)ywt8, (double)z, (double)x1wt8, (double)y1wt8, (double)z18); 
 }

for(i=0;i<imax;i++){											/* calculation of the points for the OUTER RIGHT BOTTOM line */
  z=i*l/imax;
  z18=(i+1)*l/imax;
  if(linwr8==0 && loutwr8==0)
  {
    xwt8=mr8*z+nr28;
    x1wt8=mr8*z18+nr28;
  }else{
    if(linwr8!=0 && loutwr8!=0)
    {
    xwt8=-bwrwt8*sqrt(1-((z0wr8+z)*(z0wr8+z))/(awrwt8*awrwt8));
    x1wt8=-bwrwt8*sqrt(1-((z0wr8+z18)*(z0wr8+z18))/(awrwt8*awrwt8));
    }else{
    xwt8=-sqrt((z-pbwrwt8)/-pawrwt8);
    x1wt8=-sqrt((z18-pbwrwt8)/-pawrwt8);
    }
  }
  if(linhd8==0 && louthd8==0)
  {
    ywt8=md8*z+nd28;
    y1wt8=md8*z18+nd28;
  }else{
    if(linhd8!=0 && louthd8!=0)
    {
    ywt8=-bhdwt8*sqrt(1-((z0hd8+z)*(z0hd8+z))/(ahdwt8*ahdwt8));
    y1wt8=-bhdwt8*sqrt(1-((z0hd8+z18)*(z0hd8+z18))/(ahdwt8*ahdwt8));
    }else{
    ywt8=-sqrt((z-pbhdwt8)/-pahdwt8);
    y1wt8=-sqrt((z18-pbhdwt8)/-pahdwt8);
    }
  }
  if(mxrOW8!=-1 || mydOW8!=-1) line((double)xwt8, (double)ywt8, (double)z, (double)x1wt8, (double)y1wt8, (double)z18); 
}


for(i=0;i<imax;i++){											/* calculation of the points for the OUTER RIGHT TOP line */
  z=i*l/imax;
  z18=(i+1)*l/imax;
  if(linwr8==0 && loutwr8==0)
  {
    xwt8=mr8*z+nr28;
    x1wt8=mr8*z18+nr28;
   }else{
     if(linwr8!=0 && loutwr8!=0){
     xwt8=-bwrwt8*sqrt(1-((z0wr8+z)*(z0wr8+z))/(awrwt8*awrwt8));
     x1wt8=-bwrwt8*sqrt(1-((z0wr8+z18)*(z0wr8+z18))/(awrwt8*awrwt8));
     }else{
     xwt8=-sqrt((z-pbwrwt8)/-pawrwt8);
     x1wt8=-sqrt((z18-pbwrwt8)/-pawrwt8);
     }
   }
   if(linhu8==0 && louthu8==0)
  {
    ywt8=mu8*z+nu28;
    y1wt8=mu8*z18+nu28;
  }else{
    if(linhu8!=0 && louthu8!=0)
    {
    ywt8=bhuwt8*sqrt(1-((z0hu8+z)*(z0hu8+z))/(ahuwt8*ahuwt8));
    y1wt8=bhuwt8*sqrt(1-((z0hu8+z18)*(z0hu8+z18))/(ahuwt8*ahuwt8));
    }else{
    ywt8=sqrt((z-pbhuwt8)/-pahuwt8);
    y1wt8=sqrt((z18-pbhuwt8)/-pahuwt8);
    }
  }
   if(mxrOW8!=-1 || myuOW8!=-1)line((double)xwt8, (double)ywt8, (double)z, (double)x1wt8, (double)y1wt8, (double)z18); 
}

for(i=0;i<imax;i++){											/* calculation of the points for the OUTER LEFT TOP line */
  z=i*l/imax;
  z18=(i+1)*l/imax;
  if(linwl8==0 && loutwl8==0)
  {
    xwt8=ml8*z+nl28;
    x1wt8=ml8*z18+nl28;
   }else{
     if(linwl8!=0 && loutwl8!=0)
     {
     xwt8=bwlwt8*sqrt(1-((z0wl8+z)*(z0wl8+z))/(awlwt8*awlwt8));
     x1wt8=bwlwt8*sqrt(1-((z0wl8+z18)*(z0wl8+z18))/(awlwt8*awlwt8));
     }else{
     xwt8=sqrt((z-pbwlwt8)/-pawlwt8);
     x1wt8=sqrt((z18-pbwlwt8)/-pawlwt8);
     }
   }
   if(linhu8==0 && louthu8==0)
  {
    ywt8=mu8*z+nu28;
    y1wt8=mu8*z18+nu28;
  }else{
    if(linhu8!=0 && louthu8!=0)
    {
    ywt8=bhuwt8*sqrt(1-((z0hu8+z)*(z0hu8+z))/(ahuwt8*ahuwt8));
    y1wt8=bhuwt8*sqrt(1-((z0hu8+z18)*(z0hu8+z18))/(ahuwt8*ahuwt8));
    }else{
    ywt8=sqrt((z-pbhuwt8)/-pahuwt8);
    y1wt8=sqrt((z18-pbhuwt8)/-pahuwt8);
    }
  }
  if(mxlOW8!=-1 || myuOW8!=-1)line((double)xwt8, (double)ywt8, (double)z, (double)x1wt8, (double)y1wt8, (double)z18); 
}

  if (linwr9==0 && loutwr9==0){
   mr9=(-w2r9+w1r9)/l;
   nr19=-w1r9;
   nr29=-(w1rwt9);
   }


if (linwl9==0 && loutwl9==0){
   ml9=(w2l9-w1l9)/l;
   nl19=w1l9;
   nl29=(w1lwt9);
   }


if (linhu9 == 0 && louthu9==0) 
  {
   mu9=(h2u9-h1u9)/l;
   nu19=h1u9;
   nu29=(h1uwt9);
  }


if (linhd9 == 0 && louthd9==0) 
  {
   md9=(-h2d9+h1d9)/l;
   nd19=-h1d9;
   nd29=-(h1dwt9);
  }

  z0wr9=(linwr9-l-loutwr9)/2.0;
  z0wl9=(linwl9-l-loutwl9)/2.0;
  z0hu9=lbhu9/2.0-l-louthu9;
  z0hd9=lbhd9/2.0-l-louthd9;

  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(myd9!=-1) line(w1l9, -h1d9, 0.0, -w1r9, -h1d9, 0.0);							/* entrance window given by the INNER walls*/
  if(myu9!=-1)line(w1l9, h1u9, 0.0, -w1r9, h1u9, 0.0);
  if(mxl9!=-1)line(w1l9, -h1d9, 0.0, w1l9, h1u9, 0.0);
  if(mxr9!=-1)line( -w1r9, h1u9, 0.0, -w1r9, -h1d9, 0.0);

  if(myd9!=-1)line(w2l9, -h2d9, l, -w2r9, -h2d9, l);								/* exit window given by the INNER walls*/
  if(myu9!=-1)line(w2l9, h2u9,  l, -w2r9, h2u9, l);
  if(mxl9!=-1)line(w2l9, -h2d9, l, w2l9, h2u9, l);
  if(mxr9!=-1)line( -w2r9, -h2d9,  l, -w2r9, h2u9, l);

  if(mydOW9!=-1) line((w1lwt9), -(h1dwt9), 0.0, -(w1rwt9), -(h1dwt9), 0.0);					/* entrance window given by the OUTER walls */
  if(myuOW9!=-1)line((w1lwt9), (h1uwt9), 0.0, -(w1rwt9), (h1uwt9), 0.0);
  if(mxlOW9!=-1)line((w1lwt9), -(h1dwt9), 0.0, (w1lwt9), (h1uwt9), 0.0);
  if(mxrOW9!=-1)line( -(w1rwt9), (h1uwt9), 0.0, -(w1rwt9), -(h1dwt9), 0.0);

  if(mydOW9!=-1)line((w2lwt9), -(h2dwt9), l, -(w2rwt9), -(h2dwt9), l);					/* exit windows given by the OUTER walls*/
  if(myuOW9!=-1)line((w2lwt9), (h2uwt9),  l, -(w2rwt9), (h2uwt9), l);
  if(mxlOW9!=-1)line((w2lwt9), -(h2dwt9), l, (w2lwt9), (h2uwt9), l);
  if(mxrOW9!=-1)line( -(w2rwt9), -(h2dwt9),  l, -(w2rwt9), (h2uwt9), l);

  if((myd9!=-1 && mydOW9!=-1) || (mxl9!=-1 && mxlOW9!=-1)) line(w1l9, -h1d9, 0.0, (w1lwt9), -(h1dwt9), 0.0);	/* corner connection lines for the entrance windows*/	
  if((myu9!=-1 && myuOW9!=-1) || (mxl9!=-1 && mxlOW9!=-1)) line(w1l9, h1u9, 0.0, (w1lwt9), (h1uwt9), 0.0);
  if((myd9!=-1 && mydOW9!=-1) || (mxr9!=-1 && mxrOW9!=-1)) line(-w1r9, -h1d9, 0.0,-(w1rwt9),  -(h1dwt9), 0.0);
  if((myu9!=-1 && myuOW9!=-1) || (mxr9!=-1 && mxrOW9!=-1)) line( -w1r9, h1u9, 0.0, -(w1rwt9), (h1uwt9), 0.0);

  if((myd9!=-1 && mydOW9!=-1) || (mxl9!=-1 && mxlOW9!=-1)) line(w2l9, -h2d9, l, (w2lwt9), -(h2dwt9), l);	/* corner connection lines for the exit windows*/
  if((myu9!=-1 && myuOW9!=-1) || (mxl9!=-1 && mxlOW9!=-1)) line(w2l9, h2u9, l, (w2lwt9), (h2uwt9), l);
  if((myd9!=-1 && mydOW9!=-1) || (mxr9!=-1 && mxrOW9!=-1)) line(-w2r9, -h2d9, l,-(w2rwt9),  -(h2dwt9), l);
  if((myu9!=-1 && myuOW9!=-1) || (mxr9!=-1 && mxrOW9!=-1)) line( -w2r9, h2u9, l, -(w2rwt9), (h2uwt9), l);

for(i=0;i<imax;i++){											/* calculation of the points for the INNER LEFT BOTTOM line */
   z=i*l/imax;
   z19=(i+1)*l/imax;
  if(linwl9==0 && loutwl9 == 0)
   {
     x19=ml9*z+nl19;
     x29=ml9*z19+nl19;
   }else{
      if(linwl9!=0 && loutwl9 != 0)
      {
      x19=bwl9*sqrt(1-((z0wl9+z)*(z0wl9+z))/(awl9*awl9));
      x29=bwl9*sqrt(1-((z0wl9+z19)*(z0wl9+z19))/(awl9*awl9));
      }else{
      x19=sqrt((z-pbwl9)/-pawl9);
      x29=sqrt((z19-pbwl9)/-pawl9);
      }
   }
  if(linhd9==0 && louthd9==0)
   {
     y19=md9*z+nd19;
     y29=md9*z19+nd19;
    }else{
      if(linhd9!=0 && louthd9!=0)
      {
      y19=-bhd9*sqrt(1-((z0hd9+z)*(z0hd9+z))/(ahd9*ahd9));
      y29=-bhd9*sqrt(1-((z0hd9+z19)*(z0hd9+z19))/(ahd9*ahd9));
      }else{
      y19=-sqrt((z-pbhd9)/-pahd9);
      y29=-sqrt((z19-pbhd9)/-pahd9);
      }
   }
  if(mxl9!=-1 || myd9!=-1)line((double)x19, (double)y19, (double)z, (double)x29, (double)y29, (double)z19); 
 }

for(i=0;i<imax;i++){											/* calculation of the points for the INNER RIGHT BOTTOM line */
  z=i*l/imax;
  z19=(i+1)*l/imax;
  if(linwr9==0 && loutwr9==0)
  {
    x19=mr9*z+nr19;
    x29=mr9*z19+nr19;
  }else{
    if(linwr9!=0 && loutwr9!=0)
    {
    x19=-bwr9*sqrt(1-((z0wr9+z)*(z0wr9+z))/(awr9*awr9));
    x29=-bwr9*sqrt(1-((z0wr9+z19)*(z0wr9+z19))/(awr9*awr9));
    }else{
    x19=-sqrt((z-pbwr9)/-pawr9);
    x29=-sqrt((z19-pbwr9)/-pawr9);
    }
  }
  if(linhd9==0 && louthd9==0)
  {
    y19=md9*z+nd19;
    y29=md9*z19+nd19;
  }else{
    if(linhd9!=0 && louthd9!=0)
    {
    y19=-bhd9*sqrt(1-((z0hd9+z)*(z0hd9+z))/(ahd9*ahd9));
    y29=-bhd9*sqrt(1-((z0hd9+z19)*(z0hd9+z19))/(ahd9*ahd9));
    }else{
    y19=-sqrt((z-pbhd9)/-pahd9);
    y29=-sqrt((z19-pbhd9)/-pahd9);
    }
  }
  if(mxr9!=-1 || myd9!=-1) line((double)x19, (double)y19, (double)z, (double)x29, (double)y29, (double)z19); 
}


for(i=0;i<imax;i++){											/* calculation of the points for the INNER RIGHT TOP line */
  z=i*l/imax;
  z19=(i+1)*l/imax;
  if(linwr9==0 && loutwr9==0)
  {
    x19=mr9*z+nr19;
    x29=mr9*z19+nr19;
   }else{
     if(linwr9!=0 && loutwr9!=0){
     x19=-bwr9*sqrt(1-((z0wr9+z)*(z0wr9+z))/(awr9*awr9));
     x29=-bwr9*sqrt(1-((z0wr9+z19)*(z0wr9+z19))/(awr9*awr9));
     }else{
     x19=-sqrt((z-pbwr9)/-pawr9);
     x29=-sqrt((z19-pbwr9)/-pawr9);
     }
   }
   if(linhu9==0 && louthu9==0)
  {
    y19=mu9*z+nu19;
    y29=mu9*z19+nu19;
  }else{
    if(linhu9!=0 && louthu9!=0)
    {
    y19=bhu9*sqrt(1-((z0hu9+z)*(z0hu9+z))/(ahu9*ahu9));
    y29=bhu9*sqrt(1-((z0hu9+z19)*(z0hu9+z19))/(ahu9*ahu9));
    }else{
    y19=sqrt((z-pbhu9)/-pahu9);
    y29=sqrt((z19-pbhu9)/-pahu9);
    }
  }
  if(mxr9!=-1 || myu9!=-1)line((double)x19, (double)y19, (double)z, (double)x29, (double)y29, (double)z19); 
}

for(i=0;i<imax;i++){											/* calculation of the points for the INNER LEFT TOP line */
  z=i*l/imax;
  z19=(i+1)*l/imax;
  if(linwl9==0 && loutwl9==0)
  {
    x19=ml9*z+nl19;
    x29=ml9*z19+nl19;
   }else{
     if(linwl9!=0 && loutwl9!=0)
     {
     x19=bwl9*sqrt(1-((z0wl9+z)*(z0wl9+z))/(awl9*awl9));
     x29=bwl9*sqrt(1-((z0wl9+z19)*(z0wl9+z19))/(awl9*awl9));
     }else{
     x19=sqrt((z-pbwl9)/-pawl9);
     x29=sqrt((z19-pbwl9)/-pawl9);
     }
   }
   if(linhu9==0 && louthu9==0)
  {
    y19=mu9*z+nu19;
    y29=mu9*z19+nu19;
  }else{
    if(linhu9!=0 && louthu9!=0)
    {
    y19=bhu9*sqrt(1-((z0hu9+z)*(z0hu9+z))/(ahu9*ahu9));
    y29=bhu9*sqrt(1-((z0hu9+z19)*(z0hu9+z19))/(ahu9*ahu9));
    }else{
    y19=sqrt((z-pbhu9)/-pahu9);
    y29=sqrt((z19-pbhu9)/-pahu9);
    }
  }
  if(mxl9!=-1 || myu9!=-1)line((double)x19, (double)y19, (double)z, (double)x29, (double)y29, (double)z19); 
}																	/* END INNER LINES*/


for(i=0;i<imax;i++){											/* calculation of the points for the OUTER LEFT BOTTOM line */
   z=i*l/imax;
   z19=(i+1)*l/imax;
  if(linwl9==0 && loutwl9 == 0)
   {
     xwt9=ml9*z+nl29;
     x1wt9=ml9*z19+nl29;
   }else{
      if(linwl9!=0 && loutwl9 != 0)
      {
      xwt9=bwlwt9*sqrt(1-((z0wl9+z)*(z0wl9+z))/(awlwt9*awlwt9));
      x1wt9=bwlwt9*sqrt(1-((z0wl9+z19)*(z0wl9+z19))/(awlwt9*awlwt9));
      }else{
      xwt9=sqrt((z-pbwlwt9)/-pawlwt9);
      x1wt9=sqrt((z19-pbwlwt9)/-pawlwt9);
      }
   }
  if(linhd9==0 && louthd9==0)
   {
     ywt9=md9*z+nd29;
     y1wt9=md9*z19+nd29;
    }else{
      if(linhd9!=0 && louthd9!=0)
      {
      ywt9=-bhdwt9*sqrt(1-((z0hd9+z)*(z0hd9+z))/(ahdwt9*ahdwt9));
      y1wt9=-bhdwt9*sqrt(1-((z0hd9+z19)*(z0hd9+z19))/(ahdwt9*ahdwt9));
      }else{
      ywt9=-sqrt((z-pbhdwt9)/-pahdwt9);
      y1wt9=-sqrt((z19-pbhdwt9)/-pahdwt9);
      }
   }
  if(mxlOW9!=-1 || mydOW9!=-1)line((double)xwt9, (double)ywt9, (double)z, (double)x1wt9, (double)y1wt9, (double)z19); 
 }

for(i=0;i<imax;i++){											/* calculation of the points for the OUTER RIGHT BOTTOM line */
  z=i*l/imax;
  z19=(i+1)*l/imax;
  if(linwr9==0 && loutwr9==0)
  {
    xwt9=mr9*z+nr29;
    x1wt9=mr9*z19+nr29;
  }else{
    if(linwr9!=0 && loutwr9!=0)
    {
    xwt9=-bwrwt9*sqrt(1-((z0wr9+z)*(z0wr9+z))/(awrwt9*awrwt9));
    x1wt9=-bwrwt9*sqrt(1-((z0wr9+z19)*(z0wr9+z19))/(awrwt9*awrwt9));
    }else{
    xwt9=-sqrt((z-pbwrwt9)/-pawrwt9);
    x1wt9=-sqrt((z19-pbwrwt9)/-pawrwt9);
    }
  }
  if(linhd9==0 && louthd9==0)
  {
    ywt9=md9*z+nd29;
    y1wt9=md9*z19+nd29;
  }else{
    if(linhd9!=0 && louthd9!=0)
    {
    ywt9=-bhdwt9*sqrt(1-((z0hd9+z)*(z0hd9+z))/(ahdwt9*ahdwt9));
    y1wt9=-bhdwt9*sqrt(1-((z0hd9+z19)*(z0hd9+z19))/(ahdwt9*ahdwt9));
    }else{
    ywt9=-sqrt((z-pbhdwt9)/-pahdwt9);
    y1wt9=-sqrt((z19-pbhdwt9)/-pahdwt9);
    }
  }
  if(mxrOW9!=-1 || mydOW9!=-1) line((double)xwt9, (double)ywt9, (double)z, (double)x1wt9, (double)y1wt9, (double)z19); 
}


for(i=0;i<imax;i++){											/* calculation of the points for the OUTER RIGHT TOP line */
  z=i*l/imax;
  z19=(i+1)*l/imax;
  if(linwr9==0 && loutwr9==0)
  {
    xwt9=mr9*z+nr29;
    x1wt9=mr9*z19+nr29;
   }else{
     if(linwr9!=0 && loutwr9!=0){
     xwt9=-bwrwt9*sqrt(1-((z0wr9+z)*(z0wr9+z))/(awrwt9*awrwt9));
     x1wt9=-bwrwt9*sqrt(1-((z0wr9+z19)*(z0wr9+z19))/(awrwt9*awrwt9));
     }else{
     xwt9=-sqrt((z-pbwrwt9)/-pawrwt9);
     x1wt9=-sqrt((z19-pbwrwt9)/-pawrwt9);
     }
   }
   if(linhu9==0 && louthu9==0)
  {
    ywt9=mu9*z+nu29;
    y1wt9=mu9*z19+nu29;
  }else{
    if(linhu9!=0 && louthu9!=0)
    {
    ywt9=bhuwt9*sqrt(1-((z0hu9+z)*(z0hu9+z))/(ahuwt9*ahuwt9));
    y1wt9=bhuwt9*sqrt(1-((z0hu9+z19)*(z0hu9+z19))/(ahuwt9*ahuwt9));
    }else{
    ywt9=sqrt((z-pbhuwt9)/-pahuwt9);
    y1wt9=sqrt((z19-pbhuwt9)/-pahuwt9);
    }
  }
   if(mxrOW9!=-1 || myuOW9!=-1)line((double)xwt9, (double)ywt9, (double)z, (double)x1wt9, (double)y1wt9, (double)z19); 
}

for(i=0;i<imax;i++){											/* calculation of the points for the OUTER LEFT TOP line */
  z=i*l/imax;
  z19=(i+1)*l/imax;
  if(linwl9==0 && loutwl9==0)
  {
    xwt9=ml9*z+nl29;
    x1wt9=ml9*z19+nl29;
   }else{
     if(linwl9!=0 && loutwl9!=0)
     {
     xwt9=bwlwt9*sqrt(1-((z0wl9+z)*(z0wl9+z))/(awlwt9*awlwt9));
     x1wt9=bwlwt9*sqrt(1-((z0wl9+z19)*(z0wl9+z19))/(awlwt9*awlwt9));
     }else{
     xwt9=sqrt((z-pbwlwt9)/-pawlwt9);
     x1wt9=sqrt((z19-pbwlwt9)/-pawlwt9);
     }
   }
   if(linhu9==0 && louthu9==0)
  {
    ywt9=mu9*z+nu29;
    y1wt9=mu9*z19+nu29;
  }else{
    if(linhu9!=0 && louthu9!=0)
    {
    ywt9=bhuwt9*sqrt(1-((z0hu9+z)*(z0hu9+z))/(ahuwt9*ahuwt9));
    y1wt9=bhuwt9*sqrt(1-((z0hu9+z19)*(z0hu9+z19))/(ahuwt9*ahuwt9));
    }else{
    ywt9=sqrt((z-pbhuwt9)/-pahuwt9);
    y1wt9=sqrt((z19-pbhuwt9)/-pahuwt9);
    }
  }
  if(mxlOW9!=-1 || myuOW9!=-1)line((double)xwt9, (double)ywt9, (double)z, (double)x1wt9, (double)y1wt9, (double)z19); 
}

  if (linwr10==0 && loutwr10==0){
   mr10=(-w2r10+w1r10)/l;
   nr110=-w1r10;
   nr210=-(w1rwt10);
   }


if (linwl10==0 && loutwl10==0){
   ml10=(w2l10-w1l10)/l;
   nl110=w1l10;
   nl210=(w1lwt10);
   }


if (linhu10 == 0 && louthu10==0) 
  {
   mu10=(h2u10-h1u10)/l;
   nu110=h1u10;
   nu210=(h1uwt10);
  }


if (linhd10 == 0 && louthd10==0) 
  {
   md10=(-h2d10+h1d10)/l;
   nd110=-h1d10;
   nd210=-(h1dwt10);
  }

  z0wr10=(linwr10-l-loutwr10)/2.0;
  z0wl10=(linwl10-l-loutwl10)/2.0;
  z0hu10=lbhu10/2.0-l-louthu10;
  z0hd10=lbhd10/2.0-l-louthd10;

  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(myd10!=-1) line(w1l10, -h1d10, 0.0, -w1r10, -h1d10, 0.0);							/* entrance window given by the INNER walls*/
  if(myu10!=-1)line(w1l10, h1u10, 0.0, -w1r10, h1u10, 0.0);
  if(mxl10!=-1)line(w1l10, -h1d10, 0.0, w1l10, h1u10, 0.0);
  if(mxr10!=-1)line( -w1r10, h1u10, 0.0, -w1r10, -h1d10, 0.0);

  if(myd10!=-1)line(w2l10, -h2d10, l, -w2r10, -h2d10, l);								/* exit window given by the INNER walls*/
  if(myu10!=-1)line(w2l10, h2u10,  l, -w2r10, h2u10, l);
  if(mxl10!=-1)line(w2l10, -h2d10, l, w2l10, h2u10, l);
  if(mxr10!=-1)line( -w2r10, -h2d10,  l, -w2r10, h2u10, l);

  if(mydOW10!=-1) line((w1lwt10), -(h1dwt10), 0.0, -(w1rwt10), -(h1dwt10), 0.0);					/* entrance window given by the OUTER walls */
  if(myuOW10!=-1)line((w1lwt10), (h1uwt10), 0.0, -(w1rwt10), (h1uwt10), 0.0);
  if(mxlOW10!=-1)line((w1lwt10), -(h1dwt10), 0.0, (w1lwt10), (h1uwt10), 0.0);
  if(mxrOW10!=-1)line( -(w1rwt10), (h1uwt10), 0.0, -(w1rwt10), -(h1dwt10), 0.0);

  if(mydOW10!=-1)line((w2lwt10), -(h2dwt10), l, -(w2rwt10), -(h2dwt10), l);					/* exit windows given by the OUTER walls*/
  if(myuOW10!=-1)line((w2lwt10), (h2uwt10),  l, -(w2rwt10), (h2uwt10), l);
  if(mxlOW10!=-1)line((w2lwt10), -(h2dwt10), l, (w2lwt10), (h2uwt10), l);
  if(mxrOW10!=-1)line( -(w2rwt10), -(h2dwt10),  l, -(w2rwt10), (h2uwt10), l);

  if((myd10!=-1 && mydOW10!=-1) || (mxl10!=-1 && mxlOW10!=-1)) line(w1l10, -h1d10, 0.0, (w1lwt10), -(h1dwt10), 0.0);	/* corner connection lines for the entrance windows*/	
  if((myu10!=-1 && myuOW10!=-1) || (mxl10!=-1 && mxlOW10!=-1)) line(w1l10, h1u10, 0.0, (w1lwt10), (h1uwt10), 0.0);
  if((myd10!=-1 && mydOW10!=-1) || (mxr10!=-1 && mxrOW10!=-1)) line(-w1r10, -h1d10, 0.0,-(w1rwt10),  -(h1dwt10), 0.0);
  if((myu10!=-1 && myuOW10!=-1) || (mxr10!=-1 && mxrOW10!=-1)) line( -w1r10, h1u10, 0.0, -(w1rwt10), (h1uwt10), 0.0);

  if((myd10!=-1 && mydOW10!=-1) || (mxl10!=-1 && mxlOW10!=-1)) line(w2l10, -h2d10, l, (w2lwt10), -(h2dwt10), l);	/* corner connection lines for the exit windows*/
  if((myu10!=-1 && myuOW10!=-1) || (mxl10!=-1 && mxlOW10!=-1)) line(w2l10, h2u10, l, (w2lwt10), (h2uwt10), l);
  if((myd10!=-1 && mydOW10!=-1) || (mxr10!=-1 && mxrOW10!=-1)) line(-w2r10, -h2d10, l,-(w2rwt10),  -(h2dwt10), l);
  if((myu10!=-1 && myuOW10!=-1) || (mxr10!=-1 && mxrOW10!=-1)) line( -w2r10, h2u10, l, -(w2rwt10), (h2uwt10), l);

for(i=0;i<imax;i++){											/* calculation of the points for the INNER LEFT BOTTOM line */
   z=i*l/imax;
   z110=(i+1)*l/imax;
  if(linwl10==0 && loutwl10 == 0)
   {
     x110=ml10*z+nl110;
     x210=ml10*z110+nl110;
   }else{
      if(linwl10!=0 && loutwl10 != 0)
      {
      x110=bwl10*sqrt(1-((z0wl10+z)*(z0wl10+z))/(awl10*awl10));
      x210=bwl10*sqrt(1-((z0wl10+z110)*(z0wl10+z110))/(awl10*awl10));
      }else{
      x110=sqrt((z-pbwl10)/-pawl10);
      x210=sqrt((z110-pbwl10)/-pawl10);
      }
   }
  if(linhd10==0 && louthd10==0)
   {
     y110=md10*z+nd110;
     y210=md10*z110+nd110;
    }else{
      if(linhd10!=0 && louthd10!=0)
      {
      y110=-bhd10*sqrt(1-((z0hd10+z)*(z0hd10+z))/(ahd10*ahd10));
      y210=-bhd10*sqrt(1-((z0hd10+z110)*(z0hd10+z110))/(ahd10*ahd10));
      }else{
      y110=-sqrt((z-pbhd10)/-pahd10);
      y210=-sqrt((z110-pbhd10)/-pahd10);
      }
   }
  if(mxl10!=-1 || myd10!=-1)line((double)x110, (double)y110, (double)z, (double)x210, (double)y210, (double)z110); 
 }

for(i=0;i<imax;i++){											/* calculation of the points for the INNER RIGHT BOTTOM line */
  z=i*l/imax;
  z110=(i+1)*l/imax;
  if(linwr10==0 && loutwr10==0)
  {
    x110=mr10*z+nr110;
    x210=mr10*z110+nr110;
  }else{
    if(linwr10!=0 && loutwr10!=0)
    {
    x110=-bwr10*sqrt(1-((z0wr10+z)*(z0wr10+z))/(awr10*awr10));
    x210=-bwr10*sqrt(1-((z0wr10+z110)*(z0wr10+z110))/(awr10*awr10));
    }else{
    x110=-sqrt((z-pbwr10)/-pawr10);
    x210=-sqrt((z110-pbwr10)/-pawr10);
    }
  }
  if(linhd10==0 && louthd10==0)
  {
    y110=md10*z+nd110;
    y210=md10*z110+nd110;
  }else{
    if(linhd10!=0 && louthd10!=0)
    {
    y110=-bhd10*sqrt(1-((z0hd10+z)*(z0hd10+z))/(ahd10*ahd10));
    y210=-bhd10*sqrt(1-((z0hd10+z110)*(z0hd10+z110))/(ahd10*ahd10));
    }else{
    y110=-sqrt((z-pbhd10)/-pahd10);
    y210=-sqrt((z110-pbhd10)/-pahd10);
    }
  }
  if(mxr10!=-1 || myd10!=-1) line((double)x110, (double)y110, (double)z, (double)x210, (double)y210, (double)z110); 
}


for(i=0;i<imax;i++){											/* calculation of the points for the INNER RIGHT TOP line */
  z=i*l/imax;
  z110=(i+1)*l/imax;
  if(linwr10==0 && loutwr10==0)
  {
    x110=mr10*z+nr110;
    x210=mr10*z110+nr110;
   }else{
     if(linwr10!=0 && loutwr10!=0){
     x110=-bwr10*sqrt(1-((z0wr10+z)*(z0wr10+z))/(awr10*awr10));
     x210=-bwr10*sqrt(1-((z0wr10+z110)*(z0wr10+z110))/(awr10*awr10));
     }else{
     x110=-sqrt((z-pbwr10)/-pawr10);
     x210=-sqrt((z110-pbwr10)/-pawr10);
     }
   }
   if(linhu10==0 && louthu10==0)
  {
    y110=mu10*z+nu110;
    y210=mu10*z110+nu110;
  }else{
    if(linhu10!=0 && louthu10!=0)
    {
    y110=bhu10*sqrt(1-((z0hu10+z)*(z0hu10+z))/(ahu10*ahu10));
    y210=bhu10*sqrt(1-((z0hu10+z110)*(z0hu10+z110))/(ahu10*ahu10));
    }else{
    y110=sqrt((z-pbhu10)/-pahu10);
    y210=sqrt((z110-pbhu10)/-pahu10);
    }
  }
  if(mxr10!=-1 || myu10!=-1)line((double)x110, (double)y110, (double)z, (double)x210, (double)y210, (double)z110); 
}

for(i=0;i<imax;i++){											/* calculation of the points for the INNER LEFT TOP line */
  z=i*l/imax;
  z110=(i+1)*l/imax;
  if(linwl10==0 && loutwl10==0)
  {
    x110=ml10*z+nl110;
    x210=ml10*z110+nl110;
   }else{
     if(linwl10!=0 && loutwl10!=0)
     {
     x110=bwl10*sqrt(1-((z0wl10+z)*(z0wl10+z))/(awl10*awl10));
     x210=bwl10*sqrt(1-((z0wl10+z110)*(z0wl10+z110))/(awl10*awl10));
     }else{
     x110=sqrt((z-pbwl10)/-pawl10);
     x210=sqrt((z110-pbwl10)/-pawl10);
     }
   }
   if(linhu10==0 && louthu10==0)
  {
    y110=mu10*z+nu110;
    y210=mu10*z110+nu110;
  }else{
    if(linhu10!=0 && louthu10!=0)
    {
    y110=bhu10*sqrt(1-((z0hu10+z)*(z0hu10+z))/(ahu10*ahu10));
    y210=bhu10*sqrt(1-((z0hu10+z110)*(z0hu10+z110))/(ahu10*ahu10));
    }else{
    y110=sqrt((z-pbhu10)/-pahu10);
    y210=sqrt((z110-pbhu10)/-pahu10);
    }
  }
  if(mxl10!=-1 || myu10!=-1)line((double)x110, (double)y110, (double)z, (double)x210, (double)y210, (double)z110); 
}																	/* END INNER LINES*/


for(i=0;i<imax;i++){											/* calculation of the points for the OUTER LEFT BOTTOM line */
   z=i*l/imax;
   z110=(i+1)*l/imax;
  if(linwl10==0 && loutwl10 == 0)
   {
     xwt10=ml10*z+nl210;
     x1wt10=ml10*z110+nl210;
   }else{
      if(linwl10!=0 && loutwl10 != 0)
      {
      xwt10=bwlwt10*sqrt(1-((z0wl10+z)*(z0wl10+z))/(awlwt10*awlwt10));
      x1wt10=bwlwt10*sqrt(1-((z0wl10+z110)*(z0wl10+z110))/(awlwt10*awlwt10));
      }else{
      xwt10=sqrt((z-pbwlwt10)/-pawlwt10);
      x1wt10=sqrt((z110-pbwlwt10)/-pawlwt10);
      }
   }
  if(linhd10==0 && louthd10==0)
   {
     ywt10=md10*z+nd210;
     y1wt10=md10*z110+nd210;
    }else{
      if(linhd10!=0 && louthd10!=0)
      {
      ywt10=-bhdwt10*sqrt(1-((z0hd10+z)*(z0hd10+z))/(ahdwt10*ahdwt10));
      y1wt10=-bhdwt10*sqrt(1-((z0hd10+z110)*(z0hd10+z110))/(ahdwt10*ahdwt10));
      }else{
      ywt10=-sqrt((z-pbhdwt10)/-pahdwt10);
      y1wt10=-sqrt((z110-pbhdwt10)/-pahdwt10);
      }
   }
  if(mxlOW10!=-1 || mydOW10!=-1)line((double)xwt10, (double)ywt10, (double)z, (double)x1wt10, (double)y1wt10, (double)z110); 
 }

for(i=0;i<imax;i++){											/* calculation of the points for the OUTER RIGHT BOTTOM line */
  z=i*l/imax;
  z110=(i+1)*l/imax;
  if(linwr10==0 && loutwr10==0)
  {
    xwt10=mr10*z+nr210;
    x1wt10=mr10*z110+nr210;
  }else{
    if(linwr10!=0 && loutwr10!=0)
    {
    xwt10=-bwrwt10*sqrt(1-((z0wr10+z)*(z0wr10+z))/(awrwt10*awrwt10));
    x1wt10=-bwrwt10*sqrt(1-((z0wr10+z110)*(z0wr10+z110))/(awrwt10*awrwt10));
    }else{
    xwt10=-sqrt((z-pbwrwt10)/-pawrwt10);
    x1wt10=-sqrt((z110-pbwrwt10)/-pawrwt10);
    }
  }
  if(linhd10==0 && louthd10==0)
  {
    ywt10=md10*z+nd210;
    y1wt10=md10*z110+nd210;
  }else{
    if(linhd10!=0 && louthd10!=0)
    {
    ywt10=-bhdwt10*sqrt(1-((z0hd10+z)*(z0hd10+z))/(ahdwt10*ahdwt10));
    y1wt10=-bhdwt10*sqrt(1-((z0hd10+z110)*(z0hd10+z110))/(ahdwt10*ahdwt10));
    }else{
    ywt10=-sqrt((z-pbhdwt10)/-pahdwt10);
    y1wt10=-sqrt((z110-pbhdwt10)/-pahdwt10);
    }
  }
  if(mxrOW10!=-1 || mydOW10!=-1) line((double)xwt10, (double)ywt10, (double)z, (double)x1wt10, (double)y1wt10, (double)z110); 
}


for(i=0;i<imax;i++){											/* calculation of the points for the OUTER RIGHT TOP line */
  z=i*l/imax;
  z110=(i+1)*l/imax;
  if(linwr10==0 && loutwr10==0)
  {
    xwt10=mr10*z+nr210;
    x1wt10=mr10*z110+nr210;
   }else{
     if(linwr10!=0 && loutwr10!=0){
     xwt10=-bwrwt10*sqrt(1-((z0wr10+z)*(z0wr10+z))/(awrwt10*awrwt10));
     x1wt10=-bwrwt10*sqrt(1-((z0wr10+z110)*(z0wr10+z110))/(awrwt10*awrwt10));
     }else{
     xwt10=-sqrt((z-pbwrwt10)/-pawrwt10);
     x1wt10=-sqrt((z110-pbwrwt10)/-pawrwt10);
     }
   }
   if(linhu10==0 && louthu10==0)
  {
    ywt10=mu10*z+nu210;
    y1wt10=mu10*z110+nu210;
  }else{
    if(linhu10!=0 && louthu10!=0)
    {
    ywt10=bhuwt10*sqrt(1-((z0hu10+z)*(z0hu10+z))/(ahuwt10*ahuwt10));
    y1wt10=bhuwt10*sqrt(1-((z0hu10+z110)*(z0hu10+z110))/(ahuwt10*ahuwt10));
    }else{
    ywt10=sqrt((z-pbhuwt10)/-pahuwt10);
    y1wt10=sqrt((z110-pbhuwt10)/-pahuwt10);
    }
  }
   if(mxrOW10!=-1 || myuOW10!=-1)line((double)xwt10, (double)ywt10, (double)z, (double)x1wt10, (double)y1wt10, (double)z110); 
}

for(i=0;i<imax;i++){											/* calculation of the points for the OUTER LEFT TOP line */
  z=i*l/imax;
  z110=(i+1)*l/imax;
  if(linwl10==0 && loutwl10==0)
  {
    xwt10=ml10*z+nl210;
    x1wt10=ml10*z110+nl210;
   }else{
     if(linwl10!=0 && loutwl10!=0)
     {
     xwt10=bwlwt10*sqrt(1-((z0wl10+z)*(z0wl10+z))/(awlwt10*awlwt10));
     x1wt10=bwlwt10*sqrt(1-((z0wl10+z110)*(z0wl10+z110))/(awlwt10*awlwt10));
     }else{
     xwt10=sqrt((z-pbwlwt10)/-pawlwt10);
     x1wt10=sqrt((z110-pbwlwt10)/-pawlwt10);
     }
   }
   if(linhu10==0 && louthu10==0)
  {
    ywt10=mu10*z+nu210;
    y1wt10=mu10*z110+nu210;
  }else{
    if(linhu10!=0 && louthu10!=0)
    {
    ywt10=bhuwt10*sqrt(1-((z0hu10+z)*(z0hu10+z))/(ahuwt10*ahuwt10));
    y1wt10=bhuwt10*sqrt(1-((z0hu10+z110)*(z0hu10+z110))/(ahuwt10*ahuwt10));
    }else{
    ywt10=sqrt((z-pbhuwt10)/-pahuwt10);
    y1wt10=sqrt((z110-pbhuwt10)/-pahuwt10);
    }
  }
  if(mxlOW10!=-1 || myuOW10!=-1)line((double)xwt10, (double)ywt10, (double)z, (double)x1wt10, (double)y1wt10, (double)z110); 
}



%}

END


