Last active
March 26, 2025 23:41
-
-
Save daguiam/af082206b1f80da3fc14742f57025967 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def blazed_profile(XX,YY, grating_pitch, wavelength, n1, n0=1, m=1, direction="right", blaze_arrow_angle=0, round_decimals=7): | |
""" | |
Returns the height profile of a blazed gratin | |
Args: | |
:XX: x array from meshgrid | |
:YY: y array from meshgrid | |
:grating_pitch: pitch of the grating, that sets the diffraction angle and blaze angle | |
:wavelength: wavelength of design | |
:n1: refractive index of the material | |
:n0: refractive index of the background | |
:m: diffraction order | |
""" | |
diffraction_angle = np.arcsin(m*wavelength/grating_pitch) | |
blaze_angle = diffraction_angle | |
groove_angle = np.arctan(np.sin(blaze_angle)/(n1/n0 - np.cos(blaze_angle))) | |
XX -= XX.min() | |
YY -= YY.min() | |
coordinates = np.cos(blaze_arrow_angle)*XX + np.sin(blaze_arrow_angle)*YY | |
coordinates = np.round(coordinates, round_decimals) | |
critical_angle = np.arcsin(n0/n1) | |
if blaze_angle > critical_angle: | |
print("Blaze angle is greater than critical angle! Will result in total internal reflection") | |
if direction == "right": | |
height = np.tan(groove_angle)*(np.mod(coordinates, grating_pitch) ) | |
elif direction == "left": | |
height = np.tan(groove_angle)*(np.mod(-coordinates, grating_pitch)) | |
# height = np.tan(groove_angle)*(np.mod(XX- grating_pitch/2, grating_pitch) ) | |
print("Order m %d, Groove angle: %0.3f deg, Blaze angle: %0.3f deg, height %0.3e"%(m, np.degrees(groove_angle), np.degrees(blaze_angle), height.max())) | |
return height | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment