gVirtualXRay  2.0.10
VirtualX-RayImagingLibraryonGPU
AtomicElement.inl
Go to the documentation of this file.
1 /*
2 
3 Copyright (c) 2014, Dr Franck P. Vidal (franck.p.vidal@fpvidal.net),
4 http://www.fpvidal.net/
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without modification,
8 are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11 this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation and/or
15 other materials provided with the distribution.
16 
17 3. Neither the name of the Bangor University nor the names of its contributors
18 may be used to endorse or promote products derived from this software without
19 specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 
32 */
33 
34 
62 //******************************************************************************
63 // Include
64 //******************************************************************************
65 #include <cmath>
66 #include <xraylib.h>
67 
68 #ifndef __OutOfBoundsException_h
70 #endif
71 
72 #ifndef __Units_h
73 #include "gVirtualXRay/Units.h"
74 #endif
75 
76 
77 //******************************************************************************
78 // namespace
79 //******************************************************************************
80 namespace gVirtualXRay {
81 
82 
83 //-------------------------------------------------------------
84 inline AtomicElement::AtomicElement(const std::string& aName,
85  const std::string& aSymbol,
86  unsigned short aZNumber,
87  double aMolarMass,
88  double aDensity,
89  const std::string& aState):
90 //-------------------------------------------------------------
91  m_name(aName),
92  m_symbol(aSymbol),
93  m_atomic_number(aZNumber),
94  m_molar_mass(aMolarMass),
95  m_density(aDensity),
96  m_state(aState)
97 //-------------------------------------------------------------
98 {
99 }
100 
101 
102 //------------------------------------------------------------------
104 //------------------------------------------------------------------
105  m_name(anElement.m_name),
106  m_symbol(anElement.m_symbol),
107  m_atomic_number(anElement.m_atomic_number),
108  m_molar_mass(anElement.m_molar_mass),
109  m_density(anElement.m_density),
110  m_state(anElement.m_state),
111  m_p_energy_set(anElement.m_p_energy_set),
112  m_p_mass_attenuation_coefficient_set(anElement.m_p_mass_attenuation_coefficient_set)//,
113  // m_p_coherent_scattering_set(anElement.m_p_coherent_scattering_set),
114  // m_p_incoherent_scattering_set(anElement.m_p_incoherent_scattering_set),
115  // m_p_photo_electric_absorption_set(anElement.m_p_photo_electric_absorption_set),
116  // m_p_pair_production_in_nuclear_field_set(anElement.m_p_pair_production_in_nuclear_field_set),
117  // m_p_pair_production_in_electron_field_set(anElement.m_p_pair_production_in_electron_field_set),
118  // m_p_total_attenuation_without_coherent_scattering(anElement.m_p_total_attenuation_without_coherent_scattering)
119 //------------------------------------------------------------------
120 {
121 }
122 
123 
124 //------------------------------------
126 //------------------------------------
127 {
128 }
129 
130 
131 //----------------------------------------------------------
132 inline void AtomicElement::setName(const std::string& aName)
133 //----------------------------------------------------------
134 {
135  m_name = aName;
136 }
137 
138 
139 //--------------------------------------------------------------
140 inline void AtomicElement::setSymbol(const std::string& aSymbol)
141 //--------------------------------------------------------------
142 {
143  m_symbol = aSymbol;
144 }
145 
146 
147 //-----------------------------------------------------------------
148 inline void AtomicElement::setAtomicNumber(unsigned short aZNumber)
149 //-----------------------------------------------------------------
150 {
151  m_atomic_number = aZNumber;
152 }
153 
154 
155 //--------------------------------------------------------
156 inline void AtomicElement::setMolarMass(double aMolarMass)
157 //--------------------------------------------------------
158 {
159  m_molar_mass = aMolarMass;
160 }
161 
162 
163 //----------------------------------------------------
164 inline void AtomicElement::setDensity(double aDensity)
165 //----------------------------------------------------
166 {
167  m_density = aDensity;
168 }
169 
170 
171 //------------------------------------------------------------
172 inline void AtomicElement::setState(const std::string& aState)
173 //------------------------------------------------------------
174 {
175  m_state = aState;
176 }
177 
178 
179 //-------------------------------------------------
180 inline double AtomicElement::getMU(double anEnergy)
181 //-------------------------------------------------
182 {
183  return (getMassAttenuationTotal(anEnergy) * m_density);
184 }
185 
186 
187 //-------------------------------------------------------------------
188 inline double AtomicElement::getMassAttenuationTotal(double anEnergy)
189 //-------------------------------------------------------------------
190 {
191  return CS_Total(m_atomic_number, anEnergy / keV, 0) * (cm2 / g);
192 }
193 
194 
195 //------------------------------------------------------
196 inline const std::string& AtomicElement::getName() const
197 //------------------------------------------------------
198 {
199  return (m_name);
200 }
201 
202 
203 //--------------------------------------------------------
204 inline const std::string& AtomicElement::getSymbol() const
205 //--------------------------------------------------------
206 {
207  return (m_symbol);
208 }
209 
210 
211 //----------------------------------------------------------
212 inline unsigned short AtomicElement::getAtomicNumber() const
213 //----------------------------------------------------------
214 {
215  return (m_atomic_number);
216 }
217 
218 
219 //-----------------------------------------------
220 inline unsigned short AtomicElement::getZ() const
221 //-----------------------------------------------
222 {
223  return (m_atomic_number);
224 }
225 
226 
227 //--------------------------------------------
228 inline unsigned short AtomicElement::Z() const
229 //--------------------------------------------
230 {
231  return (m_atomic_number);
232 }
233 
234 
235 //-----------------------------------------------
236 inline double AtomicElement::getMolarMass() const
237 //-----------------------------------------------
238 {
239  return (m_molar_mass);
240 }
241 
242 
243 //---------------------------------------------
244 inline double AtomicElement::getDensity() const
245 //---------------------------------------------
246 {
247  return (m_density);
248 }
249 
250 
251 //-------------------------------------------------------
252 inline const std::string& AtomicElement::getState() const
253 //-------------------------------------------------------
254 {
255  return (m_state);
256 }
257 
258 
259 //---------------------------------------------------------------
260 inline unsigned int AtomicElement::getEnergyChannelNumber() const
261 //---------------------------------------------------------------
262 {
263  return (m_p_energy_set.size());
264 }
265 
266 
267 //----------------------------------------------------------------------------
269 //----------------------------------------------------------------------------
270 {
271  m_name = anElement.m_name;
272  m_symbol = anElement.m_symbol;
273  m_atomic_number = anElement.m_atomic_number;
274  m_molar_mass = anElement.m_molar_mass;
275  m_density = anElement.m_density;
276  m_state = anElement.m_state;
277 
278  m_p_energy_set = anElement.m_p_energy_set;
280  // m_p_coherent_scattering_set = anElement.m_p_coherent_scattering_set;
281  // m_p_incoherent_scattering_set = anElement.m_p_incoherent_scattering_set;
282  // m_p_photo_electric_absorption_set = anElement.m_p_photo_electric_absorption_set;
283  // m_p_pair_production_in_nuclear_field_set = anElement.m_p_pair_production_in_nuclear_field_set;
284  // m_p_pair_production_in_electron_field_set = anElement.m_p_pair_production_in_electron_field_set;
285  // m_p_total_attenuation_without_coherent_scattering = anElement.m_p_total_attenuation_without_coherent_scattering;
286 
287  return (*this);
288 }
289 
290 
291  inline double AtomicElement::getEnergyChannel(unsigned int i) const
292  {
293  if (i >= m_p_energy_set.size())
294  {
295  throw OutOfBoundsException(__FILE__, __FUNCTION__, __LINE__);
296  }
297 
298  return m_p_energy_set[i];
299  }
300 
301 
302  inline double AtomicElement::getMassAttenuationCoefficientChannel(unsigned int i) const
303  {
304  if (i >= m_p_mass_attenuation_coefficient_set.size())
305  {
306  throw OutOfBoundsException(__FILE__, __FUNCTION__, __LINE__);
307  }
308 
309 
311  }
312 
313 
314 } // namespace gVirtualXRay
void setDensity(double aDensity)
Set the density of the element.
double getDensity() const
Accessor on the density of the element.
std::vector< double > m_p_mass_attenuation_coefficient_set
The mass attenuation coefficient set corresponding to the energy set.
double m_density
The density of the element.
void setName(const std::string &aName)
Set the name of the element.
unsigned short m_atomic_number
The atomic number of the element.
std::vector< double > m_p_energy_set
The energy set.
double getMU(double anEnergy)
void setAtomicNumber(unsigned short aZNumber)
Set the atomic number (Z) of the element.
unsigned short getAtomicNumber() const
Accessor on the atomic number (Z) of the element.
double getEnergyChannel(unsigned int i) const
std::string m_name
The name of the element.
unsigned short Z() const
Accessor on the atomic number (Z) of the element.
void setSymbol(const std::string &aSymbol)
Set the symbol of the element.
void setMolarMass(double aMolarMass)
Set the molar mass of the element.
std::string m_symbol
The symbol of the element.
double getMolarMass() const
Accessor on the molar mass of the element.
double getMassAttenuationCoefficientChannel(unsigned int i) const
std::string m_state
The state of the element.
const std::string & getName() const
Accessor on the name of the element.
const double keV
kiloelectron volt
Definition: Units.h:133
AtomicElement is a class to manage elements in material.
unsigned int getEnergyChannelNumber() const
double getMassAttenuationTotal(double anEnergy)
AtomicElement(const std::string &aName="", const std::string &aSymbol="", unsigned short aZNumber=0, double aMolarMass=0, double aDensity=0, const std::string &aState="")
Default Constructor.
void setState(const std::string &aState)
Set the state of the element.
Units, such as meters, etc.
double m_molar_mass
The molar mass of the element.
const std::string & getSymbol() const
Accessor on the symbol of the element.
Class to handle exceptions when accessing an array cell that is not accessible, i.e. out of bounds memory access.
const double g
gram
Definition: Units.h:148
const std::string & getState() const
Accessor on the state of the element.
AtomicElement & operator=(const AtomicElement &anElement)
Copy operator.
const double cm2
square centimeter
Definition: Units.h:115
unsigned short getZ() const
Accessor on the atomic number (Z) of the element.