Mantid
Loading...
Searching...
No Matches
MaterialBuilder.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2016 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#include "MantidKernel/DllConfig.h"
11#include <boost/optional/optional.hpp>
12
13namespace Mantid {
14// Forward declare
15namespace PhysicalConstants {
16struct NeutronAtom;
17}
18
19namespace Kernel {
20
24class MANTID_KERNEL_DLL MaterialBuilder {
25public:
26 enum class NumberDensityUnit { Atoms, FormulaUnits };
28
29 MaterialBuilder &setName(const std::string &name);
30
31 MaterialBuilder &setFormula(const std::string &formula);
32 MaterialBuilder &setAtomicNumber(int atomicNumber);
33 MaterialBuilder &setMassNumber(int massNumber);
34
35 MaterialBuilder &setNumberDensity(double rho);
36 MaterialBuilder &setNumberDensityUnit(NumberDensityUnit unit);
37 MaterialBuilder &setEffectiveNumberDensity(double rho_eff);
38 MaterialBuilder &setPackingFraction(double fraction);
39 MaterialBuilder &setZParameter(double zparam);
40 MaterialBuilder &setUnitCellVolume(double cellVolume);
41 MaterialBuilder &setMassDensity(double massDensity);
42
43 MaterialBuilder &setTotalScatterXSection(double xsec);
44 MaterialBuilder &setCoherentXSection(double xsec);
45 MaterialBuilder &setIncoherentXSection(double xsec);
46 MaterialBuilder &setAbsorptionXSection(double xsec);
47 MaterialBuilder &setAttenuationProfileFilename(std::string filename);
48 MaterialBuilder &setXRayAttenuationProfileFilename(std::string filename);
49
50 void setAttenuationSearchPath(std::string path);
51
52 Material build() const;
53
54private:
55 using Composition = std::tuple<PhysicalConstants::NeutronAtom, double>;
56
57 bool hasOverrideNeutronProperties() const;
58 void overrideNeutronProperties(PhysicalConstants::NeutronAtom &neutron) const;
59 PhysicalConstants::NeutronAtom generateCustomNeutron() const;
60
61 // Material::ChemicalFormula createCompositionFromFormula() const;
62 Material::ChemicalFormula createCompositionFromAtomicNumber() const;
63
68 };
69 density_packing getOrCalculateRhoAndPacking(const Material::ChemicalFormula &formula) const;
70
71 std::string m_name;
73 boost::optional<int> m_atomicNo;
75 boost::optional<double> m_numberDensity, m_packingFraction;
76 boost::optional<double> m_numberDensityEff;
77 boost::optional<double> m_zParam, m_cellVol, m_massDensity;
78 boost::optional<double> m_totalXSection, m_cohXSection, m_incXSection, m_absSection;
80 boost::optional<std::string> m_attenuationProfileFileName;
81 boost::optional<std::string> m_xRayAttenuationProfileFileName;
83};
84
85} // namespace Kernel
86} // namespace Mantid
Create a material from a set of user defined options.
boost::optional< int > m_atomicNo
Material::ChemicalFormula m_formula
boost::optional< double > m_cellVol
std::tuple< PhysicalConstants::NeutronAtom, double > Composition
boost::optional< double > m_absSection
NumberDensityUnit m_numberDensityUnit
boost::optional< std::string > m_attenuationProfileFileName
boost::optional< std::string > m_xRayAttenuationProfileFileName
boost::optional< double > m_numberDensity
boost::optional< double > m_numberDensityEff
A material is defined as being composed of a given element, defined as a PhysicalConstants::NeutronAt...
Definition: Material.h:50
std::vector< FormulaUnit > ChemicalFormula
Definition: Material.h:60
A namespace containing physical constants that are required by algorithms and unit routines.
Definition: Atom.h:14
Helper class which provides the Collimation Length for SANS instruments.
Structure to store neutronic scattering information for the various elements.
Definition: NeutronAtom.h:22