def test_FFT_single_detector(grid): detector = BlockDetector() grid[4, 4, 4] = detector grid.run(100) # detector.E[:][0][0][0] = np.sin().tolist() # tolist required for accurate test of existing multiple-dimension fr = FrequencyRoutines(grid, detector) spectrum_freqs, spectrum = fr.FFT()
def test_CurrentDetector_shape(grid): edetector = BlockDetector() cdetector = CurrentDetector() grid[4, 4, 4] = cdetector grid[4, 4, 5] = edetector grid.run(10) # at the moment, edetector has an extra dimension for polarization # which isn't included in cdetector. assert bd.array(cdetector.I).shape[0:2] == bd.array(edetector.E).shape[0:2] assert bd.array(cdetector.I).shape[0] == 10
def test_antenna_impedance(): fdtd.set_backend("torch.cuda.float32") # a very slow test distance_from_edge = bd.array([0.0,0.25,0.35,0.50,0.67,1.00]) samaras_FDTD_R = bd.array([169,136,106,72,32,0]) grid, source, simulation_steps = create_patch_antenna(0) for idx, d in enumerate(distance_from_edge): grid, source, _ = create_patch_antenna(d) grid.run(simulation_steps) fr = FrequencyRoutines(grid, source) fr.impedance()
def test_SAPS_detector_register(grid): detector = SoftArbitraryPointSource(bd.zeros(1), impedance=50.0) grid[4, 4, 4] = detector grid.run(100) assert isinstance(grid.detectors[0], CurrentDetector)
def test_SAPS_impedance(grid): detector = SoftArbitraryPointSource(np.zeros(1), impedance=50.0) grid[4, 4, 4] = detector grid.run(100) fr = FrequencyRoutines(grid, detector) fr.impedance()