Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a bug in the child classes of optika.rulings.AbstractRulings where the optical path difference was not being calculated correctly. #115

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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