diff options
Diffstat (limited to 'beam_tracing/python/fresnelReflection.py')
-rw-r--r-- | beam_tracing/python/fresnelReflection.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/beam_tracing/python/fresnelReflection.py b/beam_tracing/python/fresnelReflection.py new file mode 100644 index 0000000..2e4d4bc --- /dev/null +++ b/beam_tracing/python/fresnelReflection.py @@ -0,0 +1,33 @@ +import numpy as np
+
+def fresnelReflection(n1, n2, thetaInc):
+# calculates intensity reflection coefficient for s and p polarizations
+# for light travelling from material with index of refraction n1 to
+# material with n2
+# theta_i - incident angle in medium 1 with respect to normal, could be a vector
+# R - coefficients of reflection array [Rs, Rp]
+# theta_t - transmitted/refracted angle in medium 2 with respect to normal
+
+ #if np.size(thetaInc, axis=0) != 1:
+ # error('thetaInc must be a vector or scalar')
+
+ # see http://en.wikipedia.org/wiki/Fresnel_equations
+ # refraction angle or angle of transmitted beam with respect to normal
+ sinThetaTrans = n1 / n2 * np.sin(thetaInc)
+
+ # special cases: total internal reflection
+ if abs(sinThetaTrans) >= 1:
+ sinThetaTrans = np.copysign(1, sinThetaTrans)
+ thetaTrans = np.arcsin(sinThetaTrans) # angle of refraction
+
+
+ cosThetaTrans = np.cos(thetaTrans)
+ cosThetaInc = np.cos(thetaInc)
+
+ Rs = ((n1 * cosThetaInc - n2 * cosThetaTrans) /\
+ (n1 * cosThetaInc + n2 * cosThetaTrans)) ** 2
+ Rp = ((n1 * cosThetaTrans - n2 * cosThetaInc) /\
+ (n1 * cosThetaTrans + n2 * cosThetaInc)) ** 2
+ R = np.array([[Rs], [Rp]])
+
+ return [R, thetaTrans]
\ No newline at end of file |