Bayeux  3.4.1
Core Foundation library for SuperNEMO
element.h
Go to the documentation of this file.
1 /* Author (s) : Benoit Guillon <guillon@lpccaen.in2p3.fr>
3  * Creation date: 2010-03-14
4  * Last modified: 2010-03-14
5  *
6  * Description: A simple class to handle "abstract" chemical elements and their basic properties.
7  */
8 
19 #ifndef MATERIALS_ELEMENT_H
20 #define MATERIALS_ELEMENT_H 1
21 
22 // Standard Library:
23 #include <string>
24 #include <map>
25 
26 // Third Party:
27 // - Bayeux/datatools:
28 #include <datatools/properties.h>
29 #include <datatools/i_tree_dump.h>
30 
32 namespace materials {
33 
34  // Forward declaration:
35  class isotope;
36 
38  class iso_entry
39  {
40  public:
41 
43  iso_entry();
44 
46  ~iso_entry();
47 
49  bool is_valid() const;
50 
52  bool is_owned() const;
53 
55  bool has_isotope() const;
56 
58  bool has_weight() const;
59 
61  double get_weight() const;
62 
64  void set_weight(double);
65 
67  void set_isotope(const isotope & iso_, bool owned_ = false);
68 
70  void set_isotope(const isotope * iso_, bool owned_ = true);
71 
73  const isotope & get_isotope() const;
74 
76  void reset();
77 
79  void reset_iso();
80 
81  private:
82 
83  bool _owned_;
84  const isotope * _iso_ptr_;
85  double _weight_;
86 
87  };
88 
90  typedef std::map<std::string, iso_entry> isotope_weight_map_type;
91 
94  {
95  public:
96 
97  static const int Z_UNDEFINED = -1;
98 
103  };
104 
106  element();
107 
109 
114  explicit element(const std::string & name_, int z_, unsigned int build_flags_ = 0);
115 
117 
122  explicit element(const char * name_, int z_, unsigned int build_flags_ = 0);
123 
125 
131  explicit element(const std::string & name_, int z_, double molar_mass_, unsigned int build_flags_ = 0);
132 
134 
140  explicit element(const char * name_, int z_, double molar_mass_, unsigned int build_flags_ = 0);
141 
143 
148  explicit element(const std::string & name_, const std::string & symbol_ = "", unsigned int build_flags_ = 0);
149 
151 
156  explicit element(const char * name_, const char * symbol_ = "", unsigned int build_flags_ = 0);
157 
159  virtual ~element();
160 
162  bool is_built_by_isotopic_composition () const;
163 
165  void set_name(const std::string & name_);
166 
168  void set_z(int z_);
169 
171  void set_z(const std::string & symbol_);
172 
174 
186  void set_molar_mass(double molar_mass_);
187 
189  void add_isotope(const isotope & iso_ref_ , double weight_ = 1.0, bool owned_ = false);
190 
192  void add_isotope(const isotope * iso_ptr_ , double weight_ = 1.0);
193 
195  void build(unsigned int build_flags_ = 0);
196 
198  void build_from_nist();
199 
201  const std::string & get_name() const;
202 
204  const std::string & get_symbol() const;
205 
207  int get_z() const;
208 
210 
218  double get_molar_mass() const;
219 
221  bool is_locked() const;
222 
224  void lock();
225 
227  void unlock();
228 
231 
233  const datatools::properties & get_properties() const;
234 
237 
239  void reset();
240 
242  virtual void tree_dump(std::ostream & out_ = std::clog,
243  const std::string & title_ = "",
244  const std::string & indent_ = "",
245  bool inherit_ = false) const;
246 
247  protected:
248 
250  void _set_defaults();
251 
252  private :
253 
255  void _norm_weights_();
256 
258  void _compute_molar_mass_();
259 
261  void _set_molar_mass_(double molar_mass_);
262 
263  private :
264 
265  bool _locked_;
266  std::string _name_;
267  std::string _symbol_;
268  int _z_;
269  isotope_weight_map_type _composition_;
270  double _molar_mass_;
271  datatools::properties _properties_;
272 
273  }; // end of class element
274 
275 } // end of namespace materials
276 
277 #endif // MATERIALS_ELEMENT_H
278 
279 /*
280 ** Local Variables: --
281 ** mode: c++ --
282 ** c-file-style: "gnu" --
283 ** tab-width: 2 --
284 ** End: --
285 */
void build(unsigned int build_flags_=0)
Build the element : norm weights, compute molar mass.
void reset_iso()
Reset the compound isotope.
bool is_valid() const
Check validity.
const std::string & get_symbol() const
Return the chemical symbol.
bool is_owned() const
Check for an owned compound.
bool is_locked() const
Return true if composition is valid, weights are normalized and molar mass is computed.
An interface with utilities for printable objects.
Definition: i_tree_dump.h:36
iso_entry()
Constructor.
const isotope & get_isotope() const
Return the compound isotope.
const std::string & get_name() const
Return the name.
virtual void tree_dump(std::ostream &out_=std::clog, const std::string &title_="", const std::string &indent_="", bool inherit_=false) const
Smart print.
void unlock()
Unlock the element data structure.
void build_from_nist()
Build the element using NIST composition data, then normalize weights, compute molar mass.
const datatools::properties & get_properties() const
Get reference of auxiliary properties.
static const uint32_t bit31
Definition: bit_mask.h:58
void reset()
Reset.
element()
Defaut Constructor.
double get_weight() const
Return the weight.
Build from the NIST table.
Definition: element.h:101
const isotope_weight_map_type & get_composition() const
Return the isotopic composition of the element.
~iso_entry()
Destructor.
void reset()
Reset.
void set_weight(double)
Set the weight.
bool has_weight() const
Check the weight.
void set_z(int z_)
Set the Z (number of protons) & the chemical symbol of the element.
std::map< std::string, iso_entry > isotope_weight_map_type
Dictionary of isotope composition entries.
Definition: element.h:90
bool is_built_by_isotopic_composition() const
Return true if the element is built by isotopic composition.
void _set_defaults()
Set default values.
void set_name(const std::string &name_)
Set the name of the element.
static const int Z_UNDEFINED
Definition: element.h:97
A simple class to handle known isotopes (ZAI) and their basic properties (mass & decays).
Definition: isotope.h:60
double get_molar_mass() const
Return the molar mass [g/mol].
datatools::properties & grab_properties()
Get reference of auxiliary properties.
void add_isotope(const isotope &iso_ref_, double weight_=1.0, bool owned_=false)
Add an isotope with weight.
Lock after building.
Definition: element.h:102
void lock()
Lock the element data structure.
void set_molar_mass(double molar_mass_)
Set the molar mass of the element [g/mol].
static const uint32_t bit00
Definition: bit_mask.h:27
bool has_isotope() const
Check for an isotope compound.
Isotope composition entry.
Definition: element.h:38
build_flag_type
Build flags.
Definition: element.h:100
virtual ~element()
Destructor.
int get_z() const
Return the number of protons (Z).
The description of an element.
Definition: element.h:93
void set_isotope(const isotope &iso_, bool owned_=false)
Set the isotope.
Top-level namespace of the Bayeux/materials module library.
Definition: geom_manager_utils.h:14
A dictionary of arbitrary properties.
Definition: properties.h:125