-- $Id: postcollimator_01.lua,v 1.2 1996/10/21 22:47:14 dj Exp $ -- File : postcollimator.lua (is) -- Last rev. 10-17-96 (is) -- -------------------------------------------------------------- -- Parameters used for rigid body motion: -- mvx, mvy, mvz, mvazmis, mvelmis, mvclock -- -------------------------------------------------------------- -- PREVIOUS INFO: -- -------------- -- Postcollimator model containing all plates for shells 1,3,4,6 -- This module may be used directly, in which case the front of the -- CAP has a z value of 0.0. -- It may also be dofile'd from a lua program which sets z_0 to -- another value before invoking this file. -- All lenghts are in mm; angles are in degrees -- This is the version using 'override()' to select a shell -- (Based on modules from T. Gaetz and on postcollimator.lua by D. Jerius) -- ---------------------------------------------------------------------- $debug -- --------------------------------------------------------------------- -- Setup all shells (1,3,4,6) first. deg2rad = 3.14159265358979/180.0 inch2mm = 25.4 mm2inch = 1.0/25.4 z_capfront = -10081.0736 -- (in T.Casey coordinates) -- Set some default values : -- shell = 1 -- plate_id = 1 first_plate = 1 last_plate = 6 if ( nil == debug_plate ) then debug_plate = 0 end strut_width = 0.5 * 25.4 -- width of struts in mm -- --------------------------------------------------------------------------- -- translation and rotation parameters mvx = 0.0 mvy = 0.0 mvz = 0.0 mvazmis = 0.0 mvelmis = 0.0 mvclock = 0.0 -- --------------------------------------------------------------------------- -- used to select a shell and set other parameters (is) override() -- --------------------------------------------------------------------------- -- in case z_0 wasn't set, set it to the preferred coordinate system if ( nil == z_0 ) then z_0 = 0.0 end -- --------------------------------------------------------------------------- -- The functions below set up all the geometric and motion data structures -- ==== 1 ================================================================ function setup_basedata(shell) --------------------------------- -- This function assigns values for annulus radii, for each plate in each shell -- Last rev. 10-17-96 (is) -- ******************* -- SHELL 1 ALL PLATES -- ******************* if (shell == 1) then -- Record: Plates 1-6; z - axial coordinate, ri - inner radius, ro - outer radius plate_data = {{z = -9031.0668, ri = 534.123, ro = 553.948}, {z = -8982.8068, ri = 528.345, ro = 553.769}, {z = -8939.6268, ri = 525.447, ro = 551.337}, {z = -8896.4468, ri = 522.550, ro = 548.904}, {z = -8853.2668, ri = 519.653, ro = 546.472}, {z = -8810.0868, ri = 519.295, ro = 541.499}} -- END OF SHELL 1 elseif (shell == 3) then -- ******************* -- SHELL 3 ALL PLATES -- ******************* -- Record: Plates 1-6; z - axial coordinate, ri - inner radius, ro - outer radius plate_data = {{z = -9031.0668, ri = 427.061, ro = 446.124}, {z = -8982.8068, ri = 421.751, ro = 446.521}, {z = -8939.6268, ri = 419.273, ro = 444.605}, {z = -8896.4468, ri = 416.795, ro = 442.688}, {z = -8853.2668, ri = 414.316, ro = 440.771}, {z = -8810.0868, ri = 414.378, ro = 436.314}} -- END OF SHELL 3 elseif (shell == 4) then -- ******************* -- SHELL 4 ALL PLATES -- ******************* -- Record: Plates 1-6; z - axial coordinate, ri - inner radius, ro - outer radius plate_data = {{z = -9031.0668, ri = 374.981, ro = 394.038}, {z = -8982.8068, ri = 369.949, ro = 394.714}, {z = -8939.6268, ri = 367.719, ro = 393.046}, {z = -8896.4468, ri = 365.488, ro = 391.378}, {z = -8853.2668, ri = 363.258, ro = 389.710}, {z = -8810.0868, ri = 363.568, ro = 385.502}} -- END OF SHELL 4 elseif (shell == 6) then -- ******************* -- SHELL 6 ALL PLATES -- ******************* -- Record: Plates 1-6; z - axial coordinate, ri - inner radius, ro - outer radius plate_data = {{z = -9031.0668, ri = 277.724, ro = 293.319}, {z = -8982.8068, ri = 273.311, ro = 294.533}, {z = -8939.6268, ri = 271.636, ro = 293.347}, {z = -8896.4468, ri = 269.960, ro = 292.161}, {z = -8853.2668, ri = 268.284, ro = 290.974}, {z = -8810.0868, ri = 269.149, ro = 287.248}} -- END OF SHELL 6 else error("LUA: Shell does not exist\n") end -- End of shell selection branching -- Now make Z positions to be relative to the body center -- ( This is the Body Center Coordinate System used by OSAC v7) -- Calculate first the distance between fronts of plates 1 and 6 -- With T.Casey values, this should be negative for postcollimator -- z of the postcollimator center in T.Casey coordinates: -- for the data above 'zpostco_center' should be -8920.4768 zpostco_center = (plate_data[first_plate].z + plate_data[last_plate].z)/2.0 pid = first_plate while pid <= last_plate do plate_data[pid].z = plate_data[pid].z - zpostco_center pid = pid + 1 end end -- End set_basedata() function -- ==== 2 =============================================================== function set_tolerances( shell ) ----------------------------------- -- This function assigns machining tolerance values for annulus radii, -- for each plate in each shell -- Last rev. 6-27-96 (is) -- ******************* -- SHELL 1 ALL PLATES -- ******************* if (shell == 1) then -- Record: Plates 1-6; z - axial coordinate, ri - inner radius, ro - outer radius delta_radius = {{dri = 0.0, dro = 0.0}, {dri = 0.0, dro = 0.0}, {dri = 0.0, dro = 0.0}, {dri = 0.0, dro = 0.0}, {dri = 0.0, dro = 0.0}, {dri = 0.0, dro = 0.0}} -- delta_radius = -- {{dri = 1.270, dro = 1.270}, -- {dri = 1.270, dro = 1.270}, -- {dri = 1.270, dro = 1.270}, -- {dri = 1.270, dro = 1.270}, -- {dri = 1.270, dro = 1.270}, -- {dri = 1.270, dro = 1.270}} -- END OF SHELL 1 elseif (shell == 3) then -- ******************* -- SHELL 3 ALL PLATES -- ******************* -- Record: Plates 1-6; z - axial coordinate, ri - inner radius, ro - outer radius delta_radius = {{dri = 0.0, dro = 0.0}, {dri = 0.0, dro = 0.0}, {dri = 0.0, dro = 0.0}, {dri = 0.0, dro = 0.0}, {dri = 0.0, dro = 0.0}, {dri = 0.0, dro = 0.0}} -- delta_radius = -- {{dri = 1.270, dro = 1.270}, -- {dri = 1.270, dro = 1.270}, -- {dri = 1.270, dro = 1.270}, -- {dri = 1.270, dro = 1.270}, -- {dri = 1.270, dro = 1.270}, -- {dri = 1.270, dro = 1.270}} -- END OF SHELL 3 elseif (shell == 4) then -- ******************* -- SHELL 4 ALL PLATES -- ******************* -- Record: Plates 1-6; z - axial coordinate, ri - inner radius, ro - outer radius delta_radius = {{dri = 0.0, dro = 0.0}, {dri = 0.0, dro = 0.0}, {dri = 0.0, dro = 0.0}, {dri = 0.0, dro = 0.0}, {dri = 0.0, dro = 0.0}, {dri = 0.0, dro = 0.0}} -- delta_radius = -- {{dri = 1.270, dro = 1.270}, -- {dri = 1.270, dro = 1.270}, -- {dri = 1.270, dro = 1.270}, -- {dri = 1.270, dro = 1.270}, -- {dri = 1.270, dro = 1.270}, -- {dri = 1.270, dro = 1.270}} -- END OF SHELL 4 elseif (shell == 6) then -- ******************* -- SHELL 6 ALL PLATES -- ******************* -- Record: Plates 1-6; z - axial coordinate, ri - inner radius, ro - outer radius delta_radius = {{dri = 0.0, dro = 0.0}, {dri = 0.0, dro = 0.0}, {dri = 0.0, dro = 0.0}, {dri = 0.0, dro = 0.0}, {dri = 0.0, dro = 0.0}, {dri = 0.0, dro = 0.0}} -- delta_radius = -- {{dri = 1.270, dro = 1.270}, -- {dri = 1.270, dro = 1.270}, -- {dri = 1.270, dro = 1.270}, -- {dri = 1.270, dro = 1.270}, -- {dri = 1.270, dro = 1.270}, -- {dri = 1.270, dro = 1.270}} -- END OF SHELL 6 else error("LUA: Shell does not exist\n") end -- End of shell selection branching -- Now add machining tolerances to annulus radii pid = first_plate while pid <= last_plate do plate_data[pid].ri = plate_data[pid].ri + delta_radius[pid].dri plate_data[pid].ro = plate_data[pid].ro + delta_radius[pid].dro pid = pid + 1 end end -- end of function: 'set_tolerances()' -- ==== 3 =============================================================== function set_plate_displacements( ) ------------------------------------ -- This function sets the local motion parameters (tweaks) for each -- plate in postcollimator. The 'tweak' values are given with respect -- to the 'proper' coordinate system of each plate. -- Last rev. 6-27-96 (is) plate_tweak = {{x = 0, y = 0, z = 0, azmis = 0, elmis = 0, clock = 0}, {x = 0, y = 0, z = 0, azmis = 0, elmis = 0, clock = 0}, {x = 0, y = 0, z = 0, azmis = 0, elmis = 0, clock = 0}, {x = 0, y = 0, z = 0, azmis = 0, elmis = 0, clock = 0}, {x = 0, y = 0, z = 0, azmis = 0, elmis = 0, clock = 0}, {x = 0, y = 0, z = 0, azmis = 0, elmis = 0, clock = 0}} end -- End of function 'set_plate_displacements()' -- ==== 4 =============================================================== function move_body( ) ---------------------- -- Last rev. 6-27-96 (is) -- Motion should happen in the Body Centered Coordinate System (OSAC v7 p4-4, BCS) -- NOTE: angles need to be in radians for standard 'Aperture' package routines. -- NOTE: distances are in mm. -- Variable 'motion' : function name performing -- ================ -------- ---- ---------- -- decenter mvx, mvy X, Y translations -- despace mvz Z translation -- tilt mvazmis, mvelims azims, elims rotations -- clock mvclock clock rotation around Z -- Still TB checked : for the right order: OSAC requires : -- 1) Rotate around old OY with azmis -- 2) Rotate around old OX with elmis -- 3) Rotate around new OZ with clock (TG) rotate_y( mvazmis * deg2rad ) -- This rotation should be around 'old' OX axis -- push_ctm() -- (push current transformation matrix) rotate_x( mvelmis * deg2rad ) -- pop_ctm() -- (pop current transformation matrix) -- This rotation should be around 'new' OZ axis (clock) rotate_z(mvclock * deg2rad) -- This translation should be along 'old' OX OY axes (decenter) -- push_ctm() -- (push current transformation matrix) translate( mvx, mvy, 0 ) -- pop_ctm() -- (pop current transformation matrix) -- This translation should be along 'old' OZ axis (despace) -- push_ctm() -- (push current transformation matrix) translate( 0, 0, mvz ) -- pop_ctm() -- (pop current transformation matrix) end -- end of function 'move_body()' -- ==== 5 =============================================================== function move_plate( pid ) -------------------------- -- Apply tweaks to a specified plate -- Last rev. 6-27-96 (is) local id id = pid -- Decenter, X, Y translations -- Despace, Z translation -- Tilt, azims, elims rotations -- Clock rotation around Z axis set_plate_displacements( ) mvx = plate_tweak[id].x mvy = plate_tweak[id].y mvz = plate_tweak[id].z mvazmis = plate_tweak[id].azmis mvelmis = plate_tweak[id].elmis mvclock = plate_tweak[id].clock move_body( ) end -- end of function: move_plate( ) -- ==== 6 =============================================================== function do_struts( ) --------------------- -- Standard function to do the struts -- Last rev. 6-27-96 (is) local theta = 0 local dtheta = 30 begin_subassembly( ) while theta < 180 do strut( strut_width, 1, 0 ) rotate_z ( dtheta * deg2rad ) theta = theta + dtheta end end_subassembly( ) end -- ==== 7 =============================================================== function do_plate( pid ) ------------------------ -- Standard function to do a plate -- Last rev. 10-17-96 (is) begin_subassembly() translate( 0, 0, plate_data[pid].z) if ( pid == debug_plate ) then print_photon( 'raw_project' ) end annulus( plate_data[pid].ri, plate_data[pid].ro, 0, 0 ) do_struts( ) end_subassembly( ) end -- ==== 8 ============================================================== function postcollimator( shell, z_origin ) ------------------------------------------ -- Postcollimator assembly function -- Last rev. 10-17-96 (is) local id begin_assembly("pass") setup_basedata(shell) -- setup the shell to be used set_tolerances(shell) -- add tolerances -- the postcollimator is specified in body centered coordinates -- move it to the correct position in raytrace coordinates. -- note that zpostco_center is the position of the body -- center in EKC coordinates, and z_origin is the position -- of the raytrace coordinate origin in EKC coordinates translate(0,0, zpostco_center - z_origin ) --> move_body( ) -- move : for test only ..... -- print_xfrm( ) -- for tests only id = first_plate while id <= last_plate do --> pushctm() move_plate( id ) -- tweak the plate do_plate( id ) --> popctm() id = id + 1 end end_assembly( ) end -- end of postcollimator as 'rigid body' -- ==== 9 ============================================================== -- Now run the postcollimator for the given shell ------------------------------------------------- -- push_ctm() -- push current transformation matrix -- print_xfrm( ) -- for test only move_body( ) -- Move it as needed; all parameters are applied -- pop_ctm() -- push current transformation matrix -- print_xfrm( ) -- for test only -- print_xfrm( ) -- for test only -- translate the postcollimator using the z offset below -- this is the actual value for the offset from 'datum A' (cap front) postcollimator(shell, z_capfront ) -- create the postcollimator assembly -- print_xfrm( ) -- for test only