Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 28 additions & 6 deletions optika/rulings/_rulings.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,21 +593,43 @@ def efficiency(
grating, :math:`\lambda` is the free-space wavelength of the incident
light, and :math:`\theta` is the angle of incidence inside the medium.
"""
i = self.diffraction_order
d = self.depth

normal_rulings = self.spacing_(rays.position, normal).normalized
spacing = self.spacing_(rays.position, normal)

L = spacing.length
normal_rulings = spacing.normalized

parallel_rulings = normal.cross(normal_rulings).normalized

direction = rays.direction
direction = direction - direction @ parallel_rulings

wavelength = rays.wavelength
cos_theta = -direction @ normal
amplitude = np.pi / 2
d = self.depth / amplitude
i = self.diffraction_order
wavelength = rays.wavelength
cos_alpha = -direction @ normal
# alpha = np.arccos(cos_alpha)
# print(f"{alpha.to(u.deg)=}")
# sin_theta = np.sin(alpha)
# sin_beta = i * wavelength / L - sin_theta
# beta = np.arcsin(sin_beta)
# print(f"{beta.to(u.deg)=}")
# cos_beta = np.cos(beta)
# n1 = (1 + cos_beta) / (np.pi)
n1 = 1 / amplitude

cos_theta = optika.materials.snells_law_scalar(
cos_incidence=cos_alpha,
index_refraction=rays.index_refraction,
index_refraction_new=rays.index_refraction + n1,
)
# cos_theta = cos_alpha

gamma = np.pi * d / (wavelength * cos_theta)
print(f"{cos_theta=}")

gamma = np.pi * d * n1 / (wavelength * cos_theta)
print(f"{gamma=}")

result = np.square(np.sin(np.pi * gamma * u.rad) / (np.pi * (gamma + i)))

Expand Down
Loading