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)
Ejemplo n.º 2
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 test_initial_action(self):
     cl,args = init.setup_opencl(['rays.py','run'])
     xp = np.array([[
         [0,0,0,0,1,0,0,1],
         [0,-self.bdx,0,0,1,0,0,1],
         [0,+self.bdx,0,0,1,0,0,1],
         [0,0,-self.bdx,0,1,0,0,1],
         [0,0,+self.bdx,0,1,0,0,1],
         [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,0,0,1],
         [1,0,0,1],
         [1,0,0,1],
         [1,0,0,1],
         [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)
Ejemplo n.º 4
0
    if not os.path.exists(output_path):
        print('INFO: creating output directory', output_path)
        os.mkdir(output_path)

    print('\nSetting up optics...\n')
    for opt_dict in inputs.optics[irun]:
        print('Initializing', opt_dict['object'].name)
        opt_dict['object'].Initialize(opt_dict)
        opt_dict['object'].InitializeCL(cl, opt_dict)

    print('\nSetting up rays and orbits...')
    xp, eikonal, vg = ray_kernel.init(inputs.wave[irun], inputs.ray[irun])
    orbit_dict = ray_kernel.setup_orbits(xp, eikonal, inputs.ray[irun],
                                         inputs.diagnostics[irun],
                                         inputs.optics[irun])
    micro_action_0 = ray_kernel.GetMicroAction(xp, eikonal, vg)
    xp0 = np.copy(xp)
    eikonal0 = np.copy(eikonal)

    print('\nStart propagation...\n')
    print('Initial micro-action = {:.3g}\n'.format(micro_action_0))

    for opt_dict in inputs.optics[irun]:
        opt_dict['object'].Propagate(xp, eikonal, vg, orb=orbit_dict)

    print('\nStart diagnostic reports...\n')

    if len(inputs.sim) > 1:
        basename = inputs.diagnostics[irun]['base filename'] + '_' + str(i)
    else:
        basename = inputs.diagnostics[irun]['base filename']