-
Notifications
You must be signed in to change notification settings - Fork 37
Fresnel coefficients #255
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
Fresnel coefficients #255
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #255 +/- ##
==========================================
+ Coverage 83.11% 83.14% +0.03%
==========================================
Files 104 104
Lines 7765 7779 +14
==========================================
+ Hits 6454 6468 +14
Misses 1311 1311 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
92b9917 to
d843923
Compare
|
Small test script: import hcipy
import matplotlib.pyplot as plt
import numpy as np
n1 = 1.5
n2 = 1
angle_deg = np.linspace(0, 90, 1000)
angle = np.radians(angle_deg)
rs, rp = hcipy.fresnel_reflection_coefficients(n1, n2, angle)
ts, tp = hcipy.fresnel_transmission_coefficients(n1, n2, angle)
# Magnitudes and phases
def mag_phase(x):
return np.abs(x), np.unwrap(np.angle(x))
mag_rs, phase_rs = mag_phase(rs)
mag_rp, phase_rp = mag_phase(rp)
mag_ts, phase_ts = mag_phase(ts)
mag_tp, phase_tp = mag_phase(tp)
# Plotting
fig, axs = plt.subplots(2, 2, figsize=(12, 8), sharex=True)
axs[0, 0].plot(angle_deg, mag_rs, label='|r_s|')
axs[0, 0].plot(angle_deg, mag_rp, label='|r_p|')
axs[0, 0].set_ylabel('Reflection Coefficient Magnitude')
axs[0, 0].legend()
axs[0, 0].grid()
axs[0, 1].plot(angle_deg, np.degrees(phase_rs), label='arg(r_s)')
axs[0, 1].plot(angle_deg, np.degrees(phase_rp), label='arg(r_p)')
axs[0, 1].set_ylabel('Reflection Coefficient Phase (deg)')
axs[0, 1].legend()
axs[0, 1].grid()
axs[1, 0].plot(angle_deg, mag_ts, label='|t_s|')
axs[1, 0].plot(angle_deg, mag_tp, label='|t_p|')
axs[1, 0].set_xlabel('Angle of Incidence (deg)')
axs[1, 0].set_ylabel('Transmission Coefficient Magnitude')
axs[1, 0].legend()
axs[1, 0].grid()
axs[1, 1].plot(angle_deg, np.degrees(phase_ts), label='arg(t_s)')
axs[1, 1].plot(angle_deg, np.degrees(phase_tp), label='arg(t_p)')
axs[1, 1].set_xlabel('Angle of Incidence (deg)')
axs[1, 1].set_ylabel('Transmission Coefficient Phase (deg)')
axs[1, 1].legend()
axs[1, 1].grid()
plt.tight_layout()
plt.show() |
|
@syhaffert Does this look correct? |
|
I checked for power conservation using the following code block in your script. And the power is conserved to machine precision. I also see the correct behavior when we travel from lower density to higher density (n1 =1 and n2=1.5). So, yes I think everything is correct. |
0bdf4ba to
d73be96
Compare
I added code to calculate the Fresnel transmission and reflection coefficients for isotropic media.