ThinFilm.h
Go to the documentation of this file.
1 /*
2  Implementation of Fresnel equations for thin film optical properties
3 
4  Copyright (C) 2010 Darko Veberic, darko.veberic@kit.edu
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef _ThinFilm_h_
21 #define _ThinFilm_h_
22 
23 #include <complex>
24 
25 
26 namespace TelescopeSimulatorLX {
27 
28  class ThinFilm {
29 
30  private:
31  typedef std::complex<double> dcomplex;
32 
33  struct Etas {
34  double fEta1;
37  };
38 
39  public:
40  static
41  double
42  GetReflectance(const double nIndex1,
43  const dcomplex& nIndex2,
44  const double nIndex3,
45  const double sinTheta1,
46  const double thickness,
47  const double wavelength)
48  {
49  return GetXtance<GetReflectance2>(nIndex1, nIndex2, nIndex3,
50  sinTheta1, thickness, wavelength);
51  }
52 
53  static
54  double
55  GetTransmittance(const double nIndex1,
56  const dcomplex& nIndex2,
57  const double nIndex3,
58  const double sinTheta1,
59  const double thickness,
60  const double wavelength)
61  {
62  return GetXtance<GetTransmittance2>(nIndex1, nIndex2, nIndex3,
63  sinTheta1, thickness, wavelength);
64  }
65 
66  static
67  double
68  GetAbsorptance(const double nIndex1,
69  const dcomplex& nIndex2,
70  const double nIndex3,
71  const double sinTheta1,
72  const double thickness,
73  const double wavelength)
74  {
75  return GetXtance<GetAbsorptance2>(nIndex1, nIndex2, nIndex3,
76  sinTheta1, thickness, wavelength);
77  }
78 
79  static
80  std::pair<double, double>
81  GetReflectanceAbsorptance(const double nIndex1,
82  const dcomplex& nIndex2,
83  const double nIndex3,
84  const double sinTheta1,
85  const double thickness,
86  const double wavelength)
87  {
88  const double n1sinTheta1 = nIndex1 * sinTheta1;
89  const dcomplex phase2 =
90  GetPhase(nIndex2, n1sinTheta1, thickness, wavelength);
91  const Etas etasS = GetAllEtasS(nIndex1, nIndex2, nIndex3, n1sinTheta1);
92  const std::pair<dcomplex, dcomplex> bcS =
93  GetNormalizedFields(etasS, phase2);
94  const Etas etasP = GetAllEtasP(nIndex1, nIndex2, nIndex3, n1sinTheta1);
95  const std::pair<dcomplex, dcomplex> bcP =
96  GetNormalizedFields(etasP, phase2);
97  return
98  std::make_pair(
99  0.5 * (GetReflectance3(etasS, bcS) + GetReflectance3(etasP, bcP)),
100  0.5 * (GetAbsorptance2(etasS, phase2) + GetAbsorptance2(etasP, phase2))
101  );
102  }
103 
104  private:
105  template<double Xtance(const Etas&, const dcomplex&)>
106  static
107  double
108  GetXtance(const double nIndex1,
109  const dcomplex& nIndex2,
110  const double nIndex3,
111  const double sinTheta1,
112  const double thickness,
113  const double wavelength)
114  {
115  const double n1sinTheta1 = nIndex1 * sinTheta1;
116  const dcomplex phase2 =
117  GetPhase(nIndex2, n1sinTheta1, thickness, wavelength);
118  const Etas etasS = GetAllEtasS(nIndex1, nIndex2, nIndex3, n1sinTheta1);
119  const Etas etasP = GetAllEtasP(nIndex1, nIndex2, nIndex3, n1sinTheta1);
120  return 0.5 * (Xtance(etasS, phase2) + Xtance(etasP, phase2));
121  }
122 
123  template<typename T>
124  static T GetSnellNCosTheta(const T& nIndex, const double n1sinTheta1)
125  { return std::sqrt(nIndex*nIndex - n1sinTheta1*n1sinTheta1); }
126 
127  template<typename T>
128  static T GetEtaS(const T& nIndex, const double n1sinTheta1)
129  { return GetSnellNCosTheta(nIndex, n1sinTheta1); }
130 
131  template<typename T>
132  static T GetEtaP(const T& nIndex, const double n1sinTheta1)
133  { return nIndex*nIndex / GetEtaS(nIndex, n1sinTheta1); }
134 
135  static
136  Etas
137  GetAllEtasS(const double nIndex1,
138  const dcomplex& nIndex2,
139  const double nIndex3,
140  const double n1sinTheta1)
141  {
142  const Etas etas = {
143  GetEtaS<double>(nIndex1, n1sinTheta1),
144  GetEtaS<dcomplex>(nIndex2, n1sinTheta1),
145  GetEtaS<dcomplex>(nIndex3, n1sinTheta1)
146  };
147  return etas;
148  }
149 
150  static
151  Etas
152  GetAllEtasP(const double nIndex1,
153  const dcomplex& nIndex2,
154  const double nIndex3,
155  const double n1sinTheta1)
156  {
157  const Etas etas = {
158  GetEtaP<double>(nIndex1, n1sinTheta1),
159  GetEtaP<dcomplex>(nIndex2, n1sinTheta1),
160  GetEtaP<dcomplex>(nIndex3, n1sinTheta1)
161  };
162  return etas;
163  }
164 
165  static
166  dcomplex
167  GetPhase(const dcomplex& nIndex, const double n1sinTheta1,
168  const double thickness, const double wavelength)
169  {
170  return (2*M_PI) * thickness / wavelength *
171  GetSnellNCosTheta(nIndex, n1sinTheta1);
172  }
173 
174  static
175  std::pair<dcomplex, dcomplex>
176  GetNormalizedFields(const Etas& etas, const dcomplex& phase)
177  {
178  const dcomplex cosPhase = std::cos(phase);
179  const dcomplex isinPhase = dcomplex(0, 1) * std::sin(phase);
180  return std::make_pair(cosPhase + isinPhase * etas.fEta3 / etas.fEta2,
181  isinPhase * etas.fEta2 + cosPhase * etas.fEta3);
182  }
183 
184  static
185  double
186  GetReflectance2(const Etas& etas, const dcomplex& phase)
187  {
188  const std::pair<dcomplex, dcomplex> bc = GetNormalizedFields(etas, phase);
189  return GetReflectance3(etas, bc);
190  }
191 
192  static
193  double
194  GetReflectance3(const Etas& etas, const std::pair<dcomplex, dcomplex>& bc)
195  {
196  const dcomplex eta1b = etas.fEta1 * bc.first;
197  const dcomplex rho = (eta1b - bc.second) / (eta1b + bc.second);
198  return std::norm(rho);
199  }
200 
201  static
202  double
203  GetTransmittance2(const Etas& etas, const dcomplex& phase)
204  {
205  const std::pair<dcomplex, dcomplex> bc = GetNormalizedFields(etas, phase);
206  const dcomplex x = etas.fEta1 * bc.first + bc.second;
207  return 4 * etas.fEta1 * std::real(etas.fEta3) / std::norm(x);
208  }
209 
210  static
211  double
212  GetAbsorptance2(const Etas& etas, const dcomplex& phase)
213  {
214  const std::pair<dcomplex, dcomplex> bc = GetNormalizedFields(etas, phase);
215  return GetAbsorptance3(etas, bc);
216  }
217 
218  static
219  double
220  GetAbsorptance3(const Etas& etas, const std::pair<dcomplex, dcomplex>& bc)
221  {
222  const dcomplex x = etas.fEta1 * bc.first + bc.second;
223  return 4 * etas.fEta1 *
224  std::real(bc.first * conj(bc.second) - etas.fEta3) / std::norm(x);
225  }
226 
227  };
228 
229 }
230 
231 
232 #endif
static T GetEtaP(const T &nIndex, const double n1sinTheta1)
Definition: ThinFilm.h:132
static std::pair< double, double > GetReflectanceAbsorptance(const double nIndex1, const dcomplex &nIndex2, const double nIndex3, const double sinTheta1, const double thickness, const double wavelength)
Definition: ThinFilm.h:81
static double GetTransmittance2(const Etas &etas, const dcomplex &phase)
Definition: ThinFilm.h:203
static double GetAbsorptance2(const Etas &etas, const dcomplex &phase)
Definition: ThinFilm.h:212
static double GetReflectance2(const Etas &etas, const dcomplex &phase)
Definition: ThinFilm.h:186
static std::pair< dcomplex, dcomplex > GetNormalizedFields(const Etas &etas, const dcomplex &phase)
Definition: ThinFilm.h:176
static Etas GetAllEtasP(const double nIndex1, const dcomplex &nIndex2, const double nIndex3, const double n1sinTheta1)
Definition: ThinFilm.h:152
static double GetAbsorptance(const double nIndex1, const dcomplex &nIndex2, const double nIndex3, const double sinTheta1, const double thickness, const double wavelength)
Definition: ThinFilm.h:68
static double GetReflectance3(const Etas &etas, const std::pair< dcomplex, dcomplex > &bc)
Definition: ThinFilm.h:194
static double GetTransmittance(const double nIndex1, const dcomplex &nIndex2, const double nIndex3, const double sinTheta1, const double thickness, const double wavelength)
Definition: ThinFilm.h:55
double norm(utl::Vector x)
static double GetXtance(const double nIndex1, const dcomplex &nIndex2, const double nIndex3, const double sinTheta1, const double thickness, const double wavelength)
Definition: ThinFilm.h:108
std::complex< double > dcomplex
Definition: ThinFilm.h:31
static double GetReflectance(const double nIndex1, const dcomplex &nIndex2, const double nIndex3, const double sinTheta1, const double thickness, const double wavelength)
Definition: ThinFilm.h:42
static Etas GetAllEtasS(const double nIndex1, const dcomplex &nIndex2, const double nIndex3, const double n1sinTheta1)
Definition: ThinFilm.h:137
static T GetEtaS(const T &nIndex, const double n1sinTheta1)
Definition: ThinFilm.h:128
static double GetAbsorptance3(const Etas &etas, const std::pair< dcomplex, dcomplex > &bc)
Definition: ThinFilm.h:220
static T GetSnellNCosTheta(const T &nIndex, const double n1sinTheta1)
Definition: ThinFilm.h:124
static dcomplex GetPhase(const dcomplex &nIndex, const double n1sinTheta1, const double thickness, const double wavelength)
Definition: ThinFilm.h:167

, generated on Tue Sep 26 2023.