Computes properties of the incident and reflected planewave. Args: theta_deg: angle of incident planewave. use_bfast: whether to use the same angle for the incident planewave for all frequencies. If False, the incident angle is frequency dependent
(
self, theta_deg: float, use_bfast: bool
)
| 30 | cls.num_freq = 11 |
| 31 | |
| 32 | def reflectance_angular( |
| 33 | self, theta_deg: float, use_bfast: bool |
| 34 | ) -> Tuple[List, List, np.ndarray]: |
| 35 | """Computes properties of the incident and reflected planewave. |
| 36 | |
| 37 | Args: |
| 38 | theta_deg: angle of incident planewave. |
| 39 | use_bfast: whether to use the same angle for the incident planewave |
| 40 | for all frequencies. If False, the incident angle is frequency |
| 41 | dependent. |
| 42 | |
| 43 | Returns: |
| 44 | A 3-tuple comprising the frequencies of the incident planewave, |
| 45 | angles of the incident planewave, and the reflectance. |
| 46 | """ |
| 47 | theta_rad = math.radians(theta_deg) |
| 48 | |
| 49 | if use_bfast: |
| 50 | bfast_scaled_k = (self.n1 * np.sin(theta_rad), 0, 0) |
| 51 | |
| 52 | Courant = (1 - bfast_scaled_k[0]) / 3**0.5 |
| 53 | |
| 54 | k = mp.Vector3() |
| 55 | else: |
| 56 | bfast_scaled_k = (0, 0, 0) |
| 57 | |
| 58 | Courant = 0.5 |
| 59 | |
| 60 | # Wavevector in source medium with refractive index n1. |
| 61 | # Plane of incidence is XZ. Rotation is counter clockwise about |
| 62 | # Y axis. A rotation angle of zero is the +Z axis. |
| 63 | k = ( |
| 64 | mp.Vector3(0, 0, 1) |
| 65 | .rotate(mp.Vector3(0, 1, 0), theta_rad) |
| 66 | .scale(self.n1 * self.frequency_min) |
| 67 | ) |
| 68 | |
| 69 | dimensions = 1 if theta_deg == 0 else 3 |
| 70 | cell_size = mp.Vector3(z=self.size_z) |
| 71 | pml_layers = [mp.PML(self.t_pml)] |
| 72 | |
| 73 | # P polarization. |
| 74 | source_component = mp.Ex |
| 75 | |
| 76 | sources = [ |
| 77 | mp.Source( |
| 78 | mp.GaussianSource(self.frequency_center, fwidth=self.frequency_width), |
| 79 | component=source_component, |
| 80 | center=mp.Vector3(z=-0.5 * self.size_z + self.t_pml), |
| 81 | ) |
| 82 | ] |
| 83 | |
| 84 | sim = mp.Simulation( |
| 85 | resolution=self.resolution, |
| 86 | cell_size=cell_size, |
| 87 | dimensions=dimensions, |
| 88 | default_material=mp.Medium(index=self.n1), |
| 89 | sources=sources, |
no test coverage detected