def test_ballistic_propagation(self):
     cl,args = init.setup_opencl(['rays.py','run'])
     divAngle = 0.5
     sq = np.sin(divAngle)
     cq = np.cos(divAngle)
     ds = np.array([[6.0,6.0,6.0,6.0,6.0,6.0,6.0]]).astype(np.double)
     xp = np.array([[
         [0,0,0,0,1,0,0,1],
         [0,-self.bdx,0,0,1,-sq,0,cq],
         [0,+self.bdx,0,0,1,+sq,0,cq],
         [0,0,-self.bdx,0,1,0,-sq,cq],
         [0,0,+self.bdx,0,1,0,+sq,cq],
         [0,0,0,-self.bdx,1,0,0,1],
         [0,0,0,+self.bdx,1,0,0,1],
     ]]).astype(np.double)
     vg = np.array([[
         [1,0,0,1],
         [1,-sq,0,cq],
         [1,+sq,0,cq],
         [1,0,-sq,cq],
         [1,0,+sq,cq],
         [1,0,0,1],
         [1,0,0,1],
     ]]).astype(np.double)
     eikonal = np.array([[0,1,0,0]]).astype(np.double)
     assert ray_kernel.GetMicroAction(xp,eikonal,vg) == pytest.approx(8*self.bdx**3,1e-4)
     ray_kernel.FullStep(ds,xp,eikonal,vg)
     for i in range(1,4):
         assert xp[0,:,i] == pytest.approx(vg[0,:,i]*ds[0,:],1e-4)
     assert ray_kernel.GetMicroAction(xp,eikonal,vg) == pytest.approx(8*self.bdx**3,1e-4)
    def Propagate(self, xp, eikonal, vg, orb={'idx': 0}, vol_obj=0):
        '''The main function to propagate ray bundles through the surface.
		Rays are left slightly downstream of the surface.'''
        self.RaysGlobalToLocal(xp, eikonal, vg)
        dt, impact = self.Detect(xp, vg)
        if impact.shape[0] > 0:
            dts = dt[impact, ...]
            xps, eiks, vgs = ray_kernel.ExtractRays(impact, xp, eikonal, vg)
            ray_kernel.FullStep(dts, xps, eiks, vgs)
            self.Deflect(xps, eiks, vgs, vol_obj)
            self.SafetyNudge(xps, vgs)
            ray_kernel.UpdateRays(impact, xp, eikonal, vg, xps, eiks, vgs)
        self.RaysLocalToGlobal(xp, eikonal, vg)
        self.UpdateOrbits(xp, eikonal, orb)
        return impact.shape[0]
 def Propagate(self, xp, eikonal, vg, orb={'idx': 0}):
     self.RaysGlobalToLocal(xp, eikonal, vg)
     dt, impact = self.Detect(xp, vg)
     xps, eiks, vgs = ray_kernel.ExtractRays(impact, xp, eikonal, vg)
     ray_kernel.FullStep(dt[impact, ...], xps, eiks, vgs)
     ray_kernel.UpdateRays(impact, xp, eikonal, vg, xps, eiks, vgs)
     # Frequency filtering
     sel = np.intersect1d(self.SelectBand(xp), impact)
     self.xps = np.copy(xp[sel, 0, :])
     self.eiks = np.copy(eikonal[sel, ...])
     self.micro_action = ray_kernel.GetMicroAction(xp, eikonal, vg)
     self.transversality = ray_kernel.GetTransversality(xp, eikonal)
     self.hits = impact.shape[0]
     self.filtered_hits = sel.shape[0]
     self.RaysLocalToGlobal(xp, eikonal, vg)
     self.UpdateOrbits(xp, eikonal, orb)
     return impact.shape[0]
 def Propagate(self, xp, eikonal, vg, orb={'idx': 0}, vol_obj=0):
     '''Propagate rays through a surface mesh.  The medium on either side must be uniform.'''
     self.RaysGlobalToLocal(xp, eikonal, vg)
     dt, impact = self.Detect(xp, vg)
     dts = dt[impact, ...]
     simps = self.simplices[impact]
     xps, eiks, vgs = ray_kernel.ExtractRays(impact, xp, eikonal, vg)
     # propagate bundles one at a time
     for bundle in range(xps.shape[0]):
         dt1 = dts[[bundle], ...]
         xp1, eik1, vg1 = ray_kernel.ExtractRays([bundle], xps, eiks, vgs)
         ray_kernel.FullStep(dt1, xp1, eik1, vg1)
         simplex = self.GetTriangle(simps[bundle])
         simplex.RaysGlobalToLocal(xp1, eik1, vg1)
         simplex.Deflect(xp1, eik1, vg1, vol_obj)
         simplex.SafetyNudge(xp1, vg1)
         simplex.RaysLocalToGlobal(xp1, eik1, vg1)
         ray_kernel.UpdateRays([bundle], xps, eiks, vgs, xp1, eik1, vg1)
     ray_kernel.UpdateRays(impact, xp, eikonal, vg, xps, eiks, vgs)
     self.RaysLocalToGlobal(xp, eikonal, vg)
     self.UpdateOrbits(xp, eikonal, orb)