diff options
author | Eugeniy Mikhailov <evgmik@gmail.com> | 2013-02-28 14:59:55 -0500 |
---|---|---|
committer | Eugeniy Mikhailov <evgmik@gmail.com> | 2013-02-28 14:59:55 -0500 |
commit | e4360a48435cc762855d356b208b5544e6f40c4b (patch) | |
tree | 71c6c83c247cb07495265b93ec062eefc3e928a8 /beam_tracing/python/fresnelReflection.py | |
parent | a08ed173692ce16b79002733003049ec32a02485 (diff) | |
download | wgmr-e4360a48435cc762855d356b208b5544e6f40c4b.tar.gz wgmr-e4360a48435cc762855d356b208b5544e6f40c4b.zip |
Added python version of mode-matching code by Bain Bronner
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 |