Bayeux  3.4.1
Core Foundation library for SuperNEMO
refractive_index.h
Go to the documentation of this file.
1 //
4 // Copyright (c) 2016 by François Mauger <mauger@lpccaen.in2p3.fr>
5 
6 #ifndef MATERIALS_REFRACTIVE_INDEX_H
7 #define MATERIALS_REFRACTIVE_INDEX_H
8 
9 // Standard library:
10 #include <string>
11 #include <map>
12 #include <memory>
13 #include <limits>
14 
15 // Bayeux:
16 #include <datatools/properties.h>
17 #include <datatools/real_range.h>
18 #include <mygsl/i_unary_function.h>
20 
21 namespace materials {
22 
32  {
33  public:
34 
46  // FORMULA_DISPERSION_RII_RETRO = 18,
47  // FORMULA_DISPERSION_RII_EXOTIC = 19
48  };
49 
52  EVAL_N = 0,
53  EVAL_K = 1
54  };
55 
57  typedef std::map<std::size_t, double> coeff_dict_type;
58 
61 
63  virtual ~refractive_index();
64 
66  bool is_eval_n() const;
67 
69  bool is_eval_k() const;
70 
72  void set_eval_n();
73 
75  void set_eval_k();
76 
78  bool has_lambda_range() const;
79 
81  void set_lambda_range(const double lambda_min_, const double lambda_max_);
82 
84  void set_lambda_range(const datatools::real_range & lr_);
85 
88 
91  void make_constant(const double n_,
92  const double k_ = std::numeric_limits<double>::quiet_NaN());
93 
95  void make_tabulated(const std::string & n_tab_, const std::string & k_tab_ = "");
96 
98  void make_dispersion_rii(const dispersion_formula_type formula_,
99  const coeff_dict_type & coeffs_,
100  const std::string & k_tab_ = "");
101 
103  bool has_rii_coeff(const std::size_t) const;
104 
106  double get_rii_coeff(const std::size_t) const;
107 
109  double eval_refractive_index(const double lambda_) const;
110 
112  double eval_extinction_coefficient(const double lambda_) const;
113 
115  double eval_attenuation_coefficient(const double lambda_) const;
116 
118  double eval_penetration_depth(const double lambda_) const;
119 
121  double compute_principal_dispersion() const;
122 
124  double compute_abbe_number() const;
125 
127  double compute_abbe_number_e() const;
128 
130  virtual bool has_explicit_domain_of_definition() const;
131 
133  virtual bool is_in_domain_of_definition(const double x_) const;
134 
136  bool is_initialized() const;
137 
139  void initialize(const datatools::properties & config_,
140  const mygsl::unary_function_dict_type & /* functors_ */);
141 
143  void reset();
144 
145  protected:
146 
147  virtual double _eval(double) const;
148 
149  double _eval_n(double) const;
150 
151  double _eval_k(double) const;
152 
153  void _build_n_tabfunc();
154 
155  void _build_k_tabfunc();
156 
157  private:
158 
160  eval_mode_type _eval_mode_ = EVAL_N;
161 
162  // Constant and simple formula:
163  double _n0_;
164  double _k0_;
165 
166  // Tabulated:
167  std::string _n_table_;
168  std::string _k_table_;
169 
170  // Coefficients and validity range for RII formula (https://en.wikipedia.org/wiki/Sellmeier_equation):
171  datatools::real_range _lambda_range_;
172  coeff_dict_type _rii_c_;
173 
174  // Work data:
175  std::shared_ptr<mygsl::tabulated_function> _n_tabfunc_;
176  std::shared_ptr<mygsl::tabulated_function> _k_tabfunc_;
177 
178  };
179 
180 } // namespace materials
181 
182 #endif // MATERIALS_REFRACTIVE_INDEX_H
183 
184 // Local Variables: --
185 // Mode: c++ --
186 // c-file-style: "gnu" --
187 // tab-width: 2 --
188 // End: --
Tabulated dispersion.
Definition: refractive_index.h:38
double eval_attenuation_coefficient(const double lambda_) const
Compute the attenuation coefficient from the vacuum wavelength.
Sellmeier formula (alternative)
Definition: refractive_index.h:40
virtual bool is_in_domain_of_definition(const double x_) const
Check if a value is in the domain of definition.
bool is_eval_n() const
Check the refractive index evaluation mode.
Definition: refractive_index.h:53
Compute the refractive index or the extinction coefficient for a given medium.
Definition: refractive_index.h:30
bool has_lambda_range() const
Check if validity range of lambda is set.
bool has_rii_coeff(const std::size_t) const
Check if a RII coeff is set.
void set_eval_k()
Set to extinction coefficient evaluation mode.
void set_eval_n()
Set to refractive index evaluation mode.
double _eval_k(double) const
bool is_initialized() const
Check initialization status.
Sellmeier formula (preferred)
Definition: refractive_index.h:39
double compute_abbe_number_e() const
Compute the Abbe number (from Fraunhofer Cd, Hg spectral lines)
virtual bool has_explicit_domain_of_definition() const
Check if a domain of definition is set.
double eval_extinction_coefficient(const double lambda_) const
Compute the extinction coefficient from the vacuum wavelength.
std::map< std::size_t, double > coeff_dict_type
Type alias for a dictionry of parameters.
Definition: refractive_index.h:57
double get_rii_coeff(const std::size_t) const
Return the RII coeff at given rank.
void initialize(const datatools::properties &config_, const mygsl::unary_function_dict_type &)
Initialize from properties.
const datatools::real_range & get_lambda_range() const
Return the validity range of lambda.
void set_lambda_range(const double lambda_min_, const double lambda_max_)
Set the validity range of lambda.
void make_tabulated(const std::string &n_tab_, const std::string &k_tab_="")
Use a tabulated refractive index and extension coefficient.
Abstract interface for unary functions : R -> R.
Definition: i_unary_function.h:44
double _eval_n(double) const
double eval_penetration_depth(const double lambda_) const
Compute the penetration depth from the vacuum wavelength.
void make_constant(const double n_, const double k_=std::numeric_limits< double >::quiet_NaN())
refractive_index()
Default constructor.
eval_mode_type
Evaluation mode.
Definition: refractive_index.h:51
double compute_abbe_number() const
Compute the Abbe number (from Fraunhofer D-, F-, C-spectral lines)
bool is_eval_k() const
Check the extinction coefficient evaluation mode.
A class representing an interval of real (double precision) values with support of embedded units.
Definition: real_range.h:45
virtual ~refractive_index()
Destructor.
std::map< std::string, unary_function_handle_type > unary_function_dict_type
Alias for dictionary of handles to unary function objects.
Definition: unary_function_utils.h:30
void make_dispersion_rii(const dispersion_formula_type formula_, const coeff_dict_type &coeffs_, const std::string &k_tab_="")
Use a RII dispersion formula refractive index.
double compute_principal_dispersion() const
Compute the principal dispersion (from Fraunhofer F-, C-spectral lines)
Invalid formula.
Definition: refractive_index.h:36
virtual double _eval(double) const
The function evaluation abstract method.
Definition: refractive_index.h:52
No dispersion (constant refractive index)
Definition: refractive_index.h:37
dispersion_formula_type
Definition: refractive_index.h:35
double eval_refractive_index(const double lambda_) const
Compute the refractive index from the vacuum wavelength (where E = hc/lambda)
Top-level namespace of the Bayeux/materials module library.
Definition: geom_manager_utils.h:14
A dictionary of arbitrary properties.
Definition: properties.h:125