Bayeux  3.4.1
Core Foundation library for SuperNEMO
material.h
Go to the documentation of this file.
1 /* Author(s) : Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date: 2010-09-22
4  * Last modified: 2014-06-13
5  *
6  * License:
7  *
8  * Description:
9  *
10  * A simple class to handle "abstract" material and their basic properties
11  *
12  * Note:
13  * Some useful data here:
14  * http://www.nucsafe.com/cms/Selecting+Gamma+Detector/43.html
15  *
16  */
17 
18 #ifndef MATERIALS_MATERIAL_H
19 #define MATERIALS_MATERIAL_H
20 
21 // Standard Library:
22 #include <iostream>
23 #include <string>
24 #include <map>
25 
26 // Third Party:
27 // - Bayeux/datatools:
28 #include <datatools/i_tree_dump.h>
29 #include <datatools/properties.h>
30 
31 namespace materials {
32 
33  // Forward declarations:
34  class material;
35  class element;
36 
39  {
40  public:
41 
44 
47 
49  bool is_valid() const;
50 
52  bool has_element() const;
53 
55  bool has_material() const;
56 
58  bool is_owned() const;
59 
61  bool has_weight() const;
62 
64  bool has_number_of_atoms() const;
65 
67  double get_weight() const;
68 
70  void set_weight(double);
71 
73  int get_number_of_atoms() const;
74 
76  void set_number_of_atoms(int);
77 
79  void set_element(const element & elt_, bool owned_ = false);
80 
82  void set_material(const material & mat_, bool owned_ = false);
83 
85  void set_element(const element * elt_, bool owned_ = true);
86 
88  void set_material(const material * mat_, bool owned_ = true);
89 
91  const element & get_element() const;
92 
94  const material & get_material() const;
95 
97  void reset();
98 
100  void reset_compound();
101 
102  private:
103 
104  bool _owned_;
105  const element * _elt_ptr_;
106  const material * _mat_ptr_;
107  double _weight_;
108  int _nb_of_atoms_;
109 
110  };
111 
113  typedef std::map<std::string, compound_entry> composition_map_type;
114 
117  {
118 
119  public:
120 
122  enum state_type {
124  STATE_GAS = 1,
127  };
128 
130  static std::string state_to_label(state_type);
131 
133  static state_type label_to_state(const std::string &);
134 
136 
140  KP_ATOM = 0,
142  KP_MASS = 1,
144  KP_ZA = 2,
145  MEAN_ZA = 2
146  };
147 
152  };
153 
155  static double g_per_cm3();
156 
158  material();
159 
161 
164  explicit material(const std::string & name_);
165 
167 
170  explicit material(const char * name_);
171 
173  virtual ~material();
174 
176  bool is_composed_by_mean_z_a() const;
177 
179  bool is_composed_by_number_of_atoms() const;
180 
182  bool is_composed_by_fraction_mass() const;
183 
185  const composition_map_type & get_composition() const;
186 
188  const std::string & get_name() const;
189 
191  void set_name(const std::string &);
192 
194  double get_mean_z() const;
195 
197  double get_mean_a() const;
198 
200  void set_mean_z_a(double z_, double a_);
201 
203  bool has_state() const;
204 
206  void set_state(state_type state_);
207 
209  state_type get_state() const;
210 
212  bool has_density() const;
213 
215  double get_density() const;
216 
218  void set_density(double);
219 
221  bool has_pressure() const;
222 
224  void set_pressure(double);
225 
227  double get_pressure() const;
228 
230  bool has_temperature() const;
231 
233  void set_temperature(double);
234 
236  double get_temperature() const;
237 
239  void add_element_by_mass(const element & elt_ref_ , double weight_ , bool owned_ = false);
240 
242  void add_element_by_mass(const element * elt_ptr_ , double weight_ );
243 
245  void add_element_by_nb_of_atoms(const element & elt_ref_ , int nb_of_atoms_ , bool owned_ = false);
246 
248  void add_element_by_nb_of_atoms(const element * elt_ptr_ , int nb_of_atoms_ );
249 
251  void add_material_by_mass(const material & mat_ref_ , double weight_ , bool owned_ = false);
252 
254  void add_material_by_mass(const material * mat_ptr_ , double weight_ );
255 
257  void build(unsigned int build_flags_ = 0);
258 
260  bool is_locked() const;
261 
263  void lock();
264 
266  void unlock();
267 
269  const datatools::properties & get_properties() const;
270 
273 
275  void reset();
276 
278  virtual void tree_dump(std::ostream & out_ = std::clog,
279  const std::string & title_ = "",
280  const std::string & indent_ = "",
281  bool inherit_ = false) const;
282 
283  protected:
284 
286  void _set_defaults();
287 
288  private :
289 
291  void _compute_molar_mass_();
292 
294  void _set_mean_z_(double);
295 
297  void _set_mean_a_(double);
298 
300  void _normalize_weights_();
301 
302  private:
303 
304  bool _locked_;
305  std::string _name_;
306  double _density_;
307  state_type _state_;
308  double _pressure_;
309  double _temperature_;
310  double _mean_z_;
311  double _mean_a_;
312  datatools::properties _properties_;
313  proportion_unit_type _proportion_unit_;
314  composition_map_type _composition_;
315 
316  };
317 
318 } // end of namespace materials
319 
320 #endif // MATERIALS_MATERIAL_H
321 
322 /*
323 ** Local Variables: --
324 ** mode: c++ --
325 ** c-file-style: "gnu" --
326 ** tab-width: 2 --
327 ** End: --
328 */
void set_temperature(double)
Set the temperature of the material.
void reset_compound()
Reset the compound.
double get_weight() const
Return the weight.
void set_state(state_type state_)
Set the state.
void set_density(double)
Set the density of the material.
double get_density() const
Return the density of the material.
bool has_pressure() const
Check if pressure is defined.
bool is_composed_by_mean_z_a() const
Check if the material is composed by mean Z and A.
Proportion by number of atoms.
Definition: material.h:140
void build(unsigned int build_flags_=0)
Build the material : compute molar mass and lock (or not).
build_flag_type
Build flags.
Definition: material.h:149
void reset()
Reset.
An interface with utilities for printable objects.
Definition: i_tree_dump.h:36
bool has_weight() const
Check the weight.
const element & get_element() const
Return the compound element.
static state_type label_to_state(const std::string &)
Return state value associated to a label.
bool has_density() const
Check density.
double get_mean_a() const
Return the mean A (atomic mass)
Proportion by fraction of mass.
Definition: material.h:143
void set_material(const material &mat_, bool owned_=false)
Set the material.
static std::string state_to_label(state_type)
Return label associated to a state value.
void add_element_by_mass(const element &elt_ref_, double weight_, bool owned_=false)
Add an element with weight in KP_MASS proportion unit.
~compound_entry()
Destructor.
void reset()
Reset.
void set_number_of_atoms(int)
Set the number of atoms.
void unlock()
Unlock the material data structure.
const material & get_material() const
Return the compound material.
state_type get_state() const
Return the state.
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
Proportion by mean Z, A.
Definition: material.h:144
static const uint32_t bit31
Definition: bit_mask.h:58
bool is_valid() const
Check validity.
bool has_temperature() const
Check if temperature is defined.
Undefined.
Definition: material.h:139
bool has_state() const
Check state.
bool is_locked() const
Return true if composition is valid, weights are normalized and molar mass is computed.
std::map< std::string, compound_entry > composition_map_type
Dictionary of material compounds.
Definition: material.h:113
proportion_unit_type
Define the proportion units :
Definition: material.h:138
bool has_material() const
Check for a material compound.
Proportion by number of atoms.
Definition: material.h:141
void set_name(const std::string &)
Set the material name.
const composition_map_type & get_composition() const
Return the composition map.
static double g_per_cm3()
Default density unit.
compound_entry()
Constructor.
Proportion by mean Z, A.
Definition: material.h:145
Liquid.
Definition: material.h:125
void set_element(const element &elt_, bool owned_=false)
Set the element.
void lock()
Lock the material data structure.
Gas.
Definition: material.h:124
Solid.
Definition: material.h:126
datatools::properties & grab_properties()
Get reference of auxiliary properties.
Unknown state.
Definition: material.h:123
const datatools::properties & get_properties() const
Get reference of auxiliary properties.
state_type
State of the material.
Definition: material.h:122
void add_element_by_nb_of_atoms(const element &elt_ref_, int nb_of_atoms_, bool owned_=false)
Add an element in KP_ATOM proportion unit.
void _set_defaults()
Set default values.
Material compound entry.
Definition: material.h:38
int get_number_of_atoms() const
Return the number of atoms.
void set_weight(double)
Set the weight.
bool has_number_of_atoms() const
Check the number of atoms.
Lock after building.
Definition: material.h:151
Proportion by fraction of mass.
Definition: material.h:142
void add_material_by_mass(const material &mat_ref_, double weight_, bool owned_=false)
Add an material with weight in KP_MASS proportion unit.
double get_pressure() const
Return the pressure of the material.
bool is_composed_by_fraction_mass() const
Check if the material is composed by fraction of mass.
void set_pressure(double)
Set the pressure of the material.
virtual ~material()
Destructor.
const std::string & get_name() const
Return the material name.
material()
Defaut Constructor.
bool has_element() const
Check for a element compound.
bool is_owned() const
Check for an owned compound.
void set_mean_z_a(double z_, double a_)
Set the mean Z and A.
Extract mass excess and mass from tabulated isotopes.
Definition: material.h:150
double get_mean_z() const
Return the mean Z (atomic number)
static const uint32_t bit00
Definition: bit_mask.h:27
double get_temperature() const
Return the pressure of the material.
The description of a material.
Definition: material.h:116
The description of an element.
Definition: element.h:93
bool is_composed_by_number_of_atoms() const
Check if the material is composed by number of atoms.
Top-level namespace of the Bayeux/materials module library.
Definition: geom_manager_utils.h:14
A dictionary of arbitrary properties.
Definition: properties.h:125