This is a cubic room of 2x2x2 meters. The source is placed at [0.5,0.5, 1] and the receiver at [1.5, 1.5, 1]. A ray is launched towards [1, 0, 1] so that the first receiver hit is after travel distance of 2*sqrt(2) and each subsequent hit travels a further 4*sqrt(2)
(self)
| 54 | |
| 55 | class TestRayEnergy(unittest.TestCase): |
| 56 | def test_square_room(self): |
| 57 | """ |
| 58 | This is a cubic room of 2x2x2 meters. The source is placed at [0.5,0.5, 1] |
| 59 | and the receiver at [1.5, 1.5, 1]. A ray is launched towards [1, 0, 1] so that |
| 60 | the first receiver hit is after travel distance of 2*sqrt(2) and each subsequent |
| 61 | hit travels a further 4*sqrt(2) until the threshold energy is reached. |
| 62 | """ |
| 63 | |
| 64 | energy_absorption = 0.07 |
| 65 | round_trip = 4 * np.sqrt(2) |
| 66 | energy_thresh = 1e-7 |
| 67 | detector_radius = 0.15 |
| 68 | hist_bin_size = 0.004 # resolution of histogram [s] |
| 69 | |
| 70 | histogram_gt = SimpleHistogram(hist_bin_size * pra.constants.get("c")) |
| 71 | |
| 72 | # Create the groundtruth list of energy and travel time |
| 73 | initial_energy = 2.0 # defined in libroom.Room.get_rir_entries |
| 74 | transmitted = 1.0 * (1.0 - energy_absorption) ** 2 * initial_energy |
| 75 | distance = round_trip / 2.0 |
| 76 | |
| 77 | while transmitted / distance > energy_thresh: |
| 78 | r_sq = distance**2 |
| 79 | p_hit = 1.0 - np.sqrt(1.0 - detector_radius**2 / r_sq) |
| 80 | histogram_gt.add(distance, transmitted / (r_sq * p_hit)) |
| 81 | transmitted *= (1.0 - energy_absorption) ** 4 # 4 wall hits |
| 82 | distance += round_trip |
| 83 | |
| 84 | print("Creating the python room (polyhedral)") |
| 85 | walls_corners = [ |
| 86 | np.array([[0, 2, 2, 0], [0, 0, 0, 0], [0, 0, 2, 2]]), # front |
| 87 | np.array([[0, 0, 2, 2], [2, 2, 2, 2], [0, 2, 2, 0]]), # back |
| 88 | np.array([[0, 0, 0, 0], [0, 2, 2, 0], [0, 0, 2, 2]]), # left` |
| 89 | np.array([[2, 2, 2, 2], [0, 0, 2, 2], [0, 2, 2, 0]]), # right |
| 90 | np.array( |
| 91 | [ |
| 92 | [0, 2, 2, 0], |
| 93 | [0, 0, 2, 2], |
| 94 | [0, 0, 0, 0], |
| 95 | ] |
| 96 | ), # floor |
| 97 | np.array( |
| 98 | [ |
| 99 | [0, 0, 2, 2], |
| 100 | [0, 2, 2, 0], |
| 101 | [2, 2, 2, 2], |
| 102 | ] |
| 103 | ), # ceiling |
| 104 | ] |
| 105 | walls = [pra.wall_factory(c, [energy_absorption], [0.0]) for c in walls_corners] |
| 106 | room_poly = pra.Room(walls, fs=16000) |
| 107 | # room = pra.Room(walls, fs=16000) |
| 108 | room_poly.add_source([0.5, 0.5, 1]) |
| 109 | room_poly.add_microphone_array( |
| 110 | pra.MicrophoneArray(np.c_[[1.5, 1.5, 1.0]], room_poly.fs) |
| 111 | ) |
| 112 | |
| 113 | room_poly.room_engine.set_params( |
nothing calls this directly
no test coverage detected