Mantid
Loading...
Searching...
No Matches
Material.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2007 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
9//------------------------------------------------------------------------------
10// Includes
11//------------------------------------------------------------------------------
15#include <boost/optional/optional.hpp>
16#include <memory>
17#include <string>
18#include <vector>
19
20// Forward Declares
21namespace NeXus {
22class File;
23}
24
25namespace Mantid {
26
27namespace PhysicalConstants {
28class Atom;
29}
30
31namespace Kernel {
32
33class AttenuationProfile;
34
50class MANTID_KERNEL_DLL Material final {
51public:
53 struct FormulaUnit final {
54 std::shared_ptr<PhysicalConstants::Atom> atom;
56 FormulaUnit(std::shared_ptr<PhysicalConstants::Atom> atom, const double multiplicity);
57 FormulaUnit(const PhysicalConstants::Atom &atom, const double multiplicity);
58 };
59
60 using ChemicalFormula = std::vector<FormulaUnit>;
61
62 static ChemicalFormula parseChemicalFormula(const std::string &chemicalSymbol);
63
66 Material();
67
70 explicit Material(std::string name, const ChemicalFormula &formula, const double numberDensity,
71 const double packingFraction = 1, const double temperature = 300,
72 const double pressure = PhysicalConstants::StandardAtmosphere);
73 explicit Material(std::string name, const PhysicalConstants::NeutronAtom &atom, const double numberDensity,
74 const double packingFraction = 1, const double temperature = 300,
75 const double pressure = PhysicalConstants::StandardAtmosphere);
77 virtual ~Material() = default;
78
81 void setAttenuationProfile(AttenuationProfile attenuationOverride);
82 void setXRayAttenuationProfile(AttenuationProfile attenuationProfile);
83
85 const std::string &name() const;
86 const Material::ChemicalFormula &chemicalFormula() const;
87
91 double numberDensity() const;
93 double numberDensityEffective() const;
95 double packingFraction() const;
97 double totalAtoms() const;
99 double temperature() const;
101 double pressure() const;
103 double cohScatterXSection() const;
105 double incohScatterXSection() const;
107 double totalScatterXSection() const;
109 double absorbXSection(const double lambda = PhysicalConstants::NeutronAtom::ReferenceLambda) const;
110 double attenuationCoefficient(const double lambda) const;
112 double attenuation(const double distance,
113 const double lambda = PhysicalConstants::NeutronAtom::ReferenceLambda) const;
115 double xRayAttenuation(const double distance, const double energy) const;
116
122 double linearAbsorpCoef(const double lambda = PhysicalConstants::NeutronAtom::ReferenceLambda) const;
123
129 std::vector<double> linearAbsorpCoef(std::vector<double>::const_iterator lambdaBegin,
130 std::vector<double>::const_iterator lambdaEnd) const;
131
133 double cohScatterLength(const double lambda = PhysicalConstants::NeutronAtom::ReferenceLambda) const;
135 double incohScatterLength(const double lambda = PhysicalConstants::NeutronAtom::ReferenceLambda) const;
137 double totalScatterLength(const double lambda = PhysicalConstants::NeutronAtom::ReferenceLambda) const;
138
140 double cohScatterLengthReal(const double lambda = PhysicalConstants::NeutronAtom::ReferenceLambda) const;
142 double cohScatterLengthImg(const double lambda = PhysicalConstants::NeutronAtom::ReferenceLambda) const;
144 double incohScatterLengthReal(const double lambda = PhysicalConstants::NeutronAtom::ReferenceLambda) const;
146 double incohScatterLengthImg(const double lambda = PhysicalConstants::NeutronAtom::ReferenceLambda) const;
147
153 double cohScatterLengthSqrd(const double lambda = PhysicalConstants::NeutronAtom::ReferenceLambda) const;
154
159 double incohScatterLengthSqrd(const double lambda = PhysicalConstants::NeutronAtom::ReferenceLambda) const;
160
166 double totalScatterLengthSqrd(const double lambda = PhysicalConstants::NeutronAtom::ReferenceLambda) const;
168
169 void saveNexus(::NeXus::File *file, const std::string &group) const;
170 void loadNexus(::NeXus::File *file, const std::string &group);
171
172 bool hasValidXRayAttenuationProfile();
173
174private:
176 void countAtoms();
178 void calculateLinearAbsorpXSectionByWL();
180 void calculateTotalScatterXSection();
181
183 std::string m_name;
198
199 boost::optional<AttenuationProfile> m_attenuationOverride;
200 boost::optional<AttenuationProfile> m_xRayAttenuationProfile;
201};
202
204using Material_sptr = std::shared_ptr<Material>;
206using Material_const_sptr = std::shared_ptr<const Material>;
207} // namespace Kernel
208} // namespace Mantid
const std::vector< double > * lambda
double energy
Definition: GetAllEi.cpp:157
A material is defined as being composed of a given element, defined as a PhysicalConstants::NeutronAt...
Definition: Material.h:50
ChemicalFormula m_chemicalFormula
The normalized chemical formula.
Definition: Material.h:185
double m_temperature
Temperature.
Definition: Material.h:193
std::vector< FormulaUnit > ChemicalFormula
Definition: Material.h:60
virtual ~Material()=default
Virtual destructor.
double m_packingFraction
Packing fraction should be between 0 and 2.
Definition: Material.h:191
double m_atomTotal
Total number of atoms.
Definition: Material.h:187
boost::optional< AttenuationProfile > m_attenuationOverride
Definition: Material.h:199
std::string m_name
Material name.
Definition: Material.h:183
double m_linearAbsorpXSectionByWL
Definition: Material.h:196
double m_pressure
Pressure.
Definition: Material.h:195
boost::optional< AttenuationProfile > m_xRayAttenuationProfile
Definition: Material.h:200
double m_numberDensity
Number density in atoms per A^-3.
Definition: Material.h:189
Struture to hold the common information for an atom.
Definition: Atom.h:20
std::shared_ptr< const Material > Material_const_sptr
Typedef for a shared pointer to a const object.
Definition: Material.h:206
std::shared_ptr< Material > Material_sptr
Typedef for a shared pointer.
Definition: Material.h:204
A namespace containing physical constants that are required by algorithms and unit routines.
Definition: Atom.h:14
static constexpr double StandardAtmosphere
Standard atmospheric pressure in kPa.
Helper class which provides the Collimation Length for SANS instruments.
Structure to hold the information for a parsed chemical formula.
Definition: Material.h:53
std::shared_ptr< PhysicalConstants::Atom > atom
Definition: Material.h:54
Structure to store neutronic scattering information for the various elements.
Definition: NeutronAtom.h:22