% The generic transport kernel for a combinatorial geometry % r: region number t0 = physics(...); % Sample the distance to a phase-space changing event due to % the physics of the situation ri = r; % Current region number ns = Ns(r); % Region r has ns bounding surfaces for s = 1:ns [hit,t,rNext] = ... comgeom ( st(r,s), ... % The s'th boundy surf type in r sp(r,s), ... % Associated surface parameters (linked lists are best) x, u, ... % The particle's position and direction io(r,s) ... % In region r, the particle is either inside or outside s ) if (hit & t < t0)) % A bounding surface is struck r = rRnext; % The next region number t0 = t; % Transport the particle tally('before transport', ri, ...) x = x + u*t0; tally('after transport', rNext, ...) else % A physics event occurs inside the current elemental subvolume % Transport the particle tally('before transport', ri, ...) x = x + u*t0; tally('after transport', ...) tally('before physics', ...) [...] = ApplyPhysics(...); % Scattering, absorption, creation ... tally('after physics', ...) end