Mantid
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
Mantid::Kernel::MaterialBuilder Class Reference

Create a material from a set of user defined options. More...

#include <MaterialBuilder.h>

Classes

struct  density_packing
 

Public Types

enum class  NumberDensityUnit { Atoms , FormulaUnits }
 

Public Member Functions

Material build () const
 Build the new Material object from the current set of options. More...
 
 MaterialBuilder ()
 Constructor. More...
 
MaterialBuildersetAbsorptionXSection (double xsec)
 Set a value for the absorption cross section. More...
 
MaterialBuildersetAtomicNumber (int atomicNumber)
 Set the type of atom by its atomic number. More...
 
MaterialBuildersetAttenuationProfileFilename (std::string filename)
 Set a value for the attenuation profile filename. More...
 
void setAttenuationSearchPath (std::string path)
 Set a value for the attenuation profile search path. More...
 
MaterialBuildersetCoherentXSection (double xsec)
 Set a value for the coherent scattering cross section. More...
 
MaterialBuildersetEffectiveNumberDensity (double rho_eff)
 Set the effective number density of the sample in atoms or formula units / Angstrom^3. More...
 
MaterialBuildersetFormula (const std::string &formula)
 Set the chemical formula of the material. More...
 
MaterialBuildersetIncoherentXSection (double xsec)
 Set a value for the incoherent scattering cross section. More...
 
MaterialBuildersetMassDensity (double massDensity)
 Set the mass density of the sample in g / cc. More...
 
MaterialBuildersetMassNumber (int massNumber)
 Set the isotope by mass number. More...
 
MaterialBuildersetName (const std::string &name)
 Set the string name given to the material. More...
 
MaterialBuildersetNumberDensity (double rho)
 Set the number density of the sample in atoms or formula units / Angstrom^3. More...
 
MaterialBuildersetNumberDensityUnit (NumberDensityUnit unit)
 Set the unit for number density. More...
 
MaterialBuildersetPackingFraction (double fraction)
 Set the packing fraction of the material (default is 1). More...
 
MaterialBuildersetTotalScatterXSection (double xsec)
 Set a value for the total scattering cross section. More...
 
MaterialBuildersetUnitCellVolume (double cellVolume)
 Set the volume of unit cell. More...
 
MaterialBuildersetXRayAttenuationProfileFilename (std::string filename)
 Set a value for the attenuation profile filename. More...
 
MaterialBuildersetZParameter (double zparam)
 Set the number of formula units in the unit cell. More...
 

Private Types

using Composition = std::tuple< PhysicalConstants::NeutronAtom, double >
 

Private Member Functions

Material::ChemicalFormula createCompositionFromAtomicNumber () const
 Create the NeutronAtom object from the atomic number. More...
 
PhysicalConstants::NeutronAtom generateCustomNeutron () const
 
density_packing getOrCalculateRhoAndPacking (const Material::ChemicalFormula &formula) const
 Return the manually set density or calculate it from other parameters. More...
 
bool hasOverrideNeutronProperties () const
 
void overrideNeutronProperties (PhysicalConstants::NeutronAtom &neutron) const
 Override default neutron properties with those supplied. More...
 

Private Attributes

boost::optional< double > m_absSection
 
boost::optional< int > m_atomicNo
 
std::string m_attenuationFileSearchPath
 
boost::optional< std::string > m_attenuationProfileFileName
 
boost::optional< double > m_cellVol
 
boost::optional< double > m_cohXSection
 
Material::ChemicalFormula m_formula
 
boost::optional< double > m_incXSection
 
boost::optional< double > m_massDensity
 
int m_massNo
 
std::string m_name
 
boost::optional< double > m_numberDensity
 
boost::optional< double > m_numberDensityEff
 
NumberDensityUnit m_numberDensityUnit
 
boost::optional< double > m_packingFraction
 
boost::optional< double > m_totalXSection
 
boost::optional< std::string > m_xRayAttenuationProfileFileName
 
boost::optional< double > m_zParam
 

Detailed Description

Create a material from a set of user defined options.

Definition at line 24 of file MaterialBuilder.h.

Member Typedef Documentation

◆ Composition

Definition at line 55 of file MaterialBuilder.h.

Member Enumeration Documentation

◆ NumberDensityUnit

Enumerator
Atoms 
FormulaUnits 

Definition at line 26 of file MaterialBuilder.h.

Constructor & Destructor Documentation

◆ MaterialBuilder()

Mantid::Kernel::MaterialBuilder::MaterialBuilder ( )

Constructor.

Definition at line 30 of file MaterialBuilder.cpp.

Member Function Documentation

◆ build()

Material Mantid::Kernel::MaterialBuilder::build ( ) const

◆ createCompositionFromAtomicNumber()

Material::ChemicalFormula Mantid::Kernel::MaterialBuilder::createCompositionFromAtomicNumber ( ) const
private

Create the NeutronAtom object from the atomic number.

Returns
A new NeutronAtom object with the defined proprties

Definition at line 291 of file MaterialBuilder.cpp.

References m_atomicNo, and m_massNo.

Referenced by build().

◆ generateCustomNeutron()

PhysicalConstants::NeutronAtom Mantid::Kernel::MaterialBuilder::generateCustomNeutron ( ) const
private

◆ getOrCalculateRhoAndPacking()

MaterialBuilder::density_packing Mantid::Kernel::MaterialBuilder::getOrCalculateRhoAndPacking ( const Material::ChemicalFormula formula) const
private

Return the manually set density or calculate it from other parameters.

Parameters
formulaThe chemical formula to calculate the number density from
Returns
The number density in atoms / Angstrom^3

Definition at line 307 of file MaterialBuilder.cpp.

References count, FormulaUnits, m_cellVol, m_massDensity, m_numberDensity, m_numberDensityEff, m_numberDensityUnit, m_packingFraction, m_zParam, n, Mantid::PhysicalConstants::N_A, and Mantid::Kernel::MaterialBuilder::density_packing::packing_fraction.

Referenced by build().

◆ hasOverrideNeutronProperties()

bool Mantid::Kernel::MaterialBuilder::hasOverrideNeutronProperties ( ) const
private

Definition at line 387 of file MaterialBuilder.cpp.

References m_absSection, m_cohXSection, m_incXSection, and m_totalXSection.

Referenced by build().

◆ overrideNeutronProperties()

void Mantid::Kernel::MaterialBuilder::overrideNeutronProperties ( PhysicalConstants::NeutronAtom neutron) const
private

◆ setAbsorptionXSection()

MaterialBuilder & Mantid::Kernel::MaterialBuilder::setAbsorptionXSection ( double  xsec)

Set a value for the absorption cross section.

Parameters
xsecValue of the cross section
Returns
A reference to the this object to allow chaining

Definition at line 209 of file MaterialBuilder.cpp.

References m_absSection.

Referenced by export_MaterialBuilder(), and Mantid::DataHandling::ReadMaterial::setScatteringInfo().

◆ setAtomicNumber()

MaterialBuilder & Mantid::Kernel::MaterialBuilder::setAtomicNumber ( int  atomicNumber)

Set the type of atom by its atomic number.

Parameters
atomicNumberZ-number of the atom
Returns
A reference to the this object to allow chaining

Definition at line 80 of file MaterialBuilder.cpp.

References m_atomicNo, and m_formula.

Referenced by export_MaterialBuilder(), and Mantid::DataHandling::ReadMaterial::setMaterial().

◆ setAttenuationProfileFilename()

MaterialBuilder & Mantid::Kernel::MaterialBuilder::setAttenuationProfileFilename ( std::string  filename)

Set a value for the attenuation profile filename.

Parameters
filenameName of the file containing the attenuation profile
Returns
A reference to the this object to allow chaining

Definition at line 219 of file MaterialBuilder.cpp.

References m_attenuationProfileFileName.

Referenced by Mantid::DataHandling::ReadMaterial::setScatteringInfo().

◆ setAttenuationSearchPath()

void Mantid::Kernel::MaterialBuilder::setAttenuationSearchPath ( std::string  path)

Set a value for the attenuation profile search path.

Parameters
pathPath to search

Definition at line 242 of file MaterialBuilder.cpp.

References m_attenuationFileSearchPath.

Referenced by Mantid::Kernel::MaterialXMLParser::parse().

◆ setCoherentXSection()

MaterialBuilder & Mantid::Kernel::MaterialBuilder::setCoherentXSection ( double  xsec)

Set a value for the coherent scattering cross section.

Parameters
xsecValue of the cross section
Returns
A reference to the this object to allow chaining

Definition at line 189 of file MaterialBuilder.cpp.

References m_cohXSection.

Referenced by export_MaterialBuilder(), and Mantid::DataHandling::ReadMaterial::setScatteringInfo().

◆ setEffectiveNumberDensity()

MaterialBuilder & Mantid::Kernel::MaterialBuilder::setEffectiveNumberDensity ( double  rho_eff)

Set the effective number density of the sample in atoms or formula units / Angstrom^3.

Parameters
rho_effeffective density of the sample in atoms or formula units / Angstrom^3
Returns
A reference to the this object to allow chaining

Definition at line 127 of file MaterialBuilder.cpp.

References Mantid::EMPTY_DBL(), and m_numberDensityEff.

Referenced by Mantid::DataHandling::ReadMaterial::setNumberDensity().

◆ setFormula()

MaterialBuilder & Mantid::Kernel::MaterialBuilder::setFormula ( const std::string &  formula)

Set the chemical formula of the material.

Parameters
formulaHuman-readable name of the material
Returns
A reference to the this object to allow chaining

Definition at line 53 of file MaterialBuilder.cpp.

References m_atomicNo, m_formula, m_name, and Mantid::Kernel::Material::parseChemicalFormula().

Referenced by export_MaterialBuilder(), and Mantid::DataHandling::ReadMaterial::setMaterial().

◆ setIncoherentXSection()

MaterialBuilder & Mantid::Kernel::MaterialBuilder::setIncoherentXSection ( double  xsec)

Set a value for the incoherent scattering cross section.

Parameters
xsecValue of the cross section
Returns
A reference to the this object to allow chaining

Definition at line 199 of file MaterialBuilder.cpp.

References m_incXSection.

Referenced by export_MaterialBuilder(), and Mantid::DataHandling::ReadMaterial::setScatteringInfo().

◆ setMassDensity()

MaterialBuilder & Mantid::Kernel::MaterialBuilder::setMassDensity ( double  massDensity)

Set the mass density of the sample in g / cc.

Parameters
massDensityThe mass density in g / cc
Returns
A reference to the this object to allow chaining

Definition at line 168 of file MaterialBuilder.cpp.

References m_massDensity.

Referenced by export_MaterialBuilder(), and Mantid::DataHandling::ReadMaterial::setNumberDensity().

◆ setMassNumber()

MaterialBuilder & Mantid::Kernel::MaterialBuilder::setMassNumber ( int  massNumber)

Set the isotope by mass number.

Parameters
massNumberIsotope number of the atom
Returns
A reference to the this object to allow chaining

Definition at line 94 of file MaterialBuilder.cpp.

References m_massNo.

Referenced by export_MaterialBuilder(), and Mantid::DataHandling::ReadMaterial::setMaterial().

◆ setName()

MaterialBuilder & Mantid::Kernel::MaterialBuilder::setName ( const std::string &  name)

Set the string name given to the material.

Parameters
nameHuman-readable name of the material. Empty string not allowed
Returns
A reference to the this object to allow chaining

Definition at line 40 of file MaterialBuilder.cpp.

References m_name.

Referenced by export_MaterialBuilder(), and Mantid::Kernel::MaterialXMLParser::parse().

◆ setNumberDensity()

MaterialBuilder & Mantid::Kernel::MaterialBuilder::setNumberDensity ( double  rho)

Set the number density of the sample in atoms or formula units / Angstrom^3.

Parameters
rhodensity of the sample in atoms or formula units / Angstrom^3
Returns
A reference to the this object to allow chaining

Definition at line 104 of file MaterialBuilder.cpp.

References Mantid::EMPTY_DBL(), m_numberDensity, and rho.

Referenced by export_MaterialBuilder(), and Mantid::DataHandling::ReadMaterial::setNumberDensity().

◆ setNumberDensityUnit()

MaterialBuilder & Mantid::Kernel::MaterialBuilder::setNumberDensityUnit ( NumberDensityUnit  unit)

Set the unit for number density.

Parameters
unitatoms or formula units / Anstrom^3
Returns
A reference to this object to allow chaining

Definition at line 115 of file MaterialBuilder.cpp.

References m_numberDensityUnit.

Referenced by export_MaterialBuilder(), and Mantid::DataHandling::ReadMaterial::setNumberDensity().

◆ setPackingFraction()

MaterialBuilder & Mantid::Kernel::MaterialBuilder::setPackingFraction ( double  fraction)

Set the packing fraction of the material (default is 1).

This is used to infer the effective number density

Definition at line 137 of file MaterialBuilder.cpp.

References Mantid::EMPTY_DBL(), and m_packingFraction.

Referenced by export_MaterialBuilder(), and Mantid::DataHandling::ReadMaterial::setNumberDensity().

◆ setTotalScatterXSection()

MaterialBuilder & Mantid::Kernel::MaterialBuilder::setTotalScatterXSection ( double  xsec)

Set a value for the total scattering cross section.

Parameters
xsecValue of the cross section
Returns
A reference to the this object to allow chaining

Definition at line 178 of file MaterialBuilder.cpp.

References Mantid::EMPTY_DBL(), and m_totalXSection.

Referenced by export_MaterialBuilder(), and Mantid::DataHandling::ReadMaterial::setScatteringInfo().

◆ setUnitCellVolume()

MaterialBuilder & Mantid::Kernel::MaterialBuilder::setUnitCellVolume ( double  cellVolume)

Set the volume of unit cell.

Parameters
cellVolumeThe volume of the unit cell
Returns
A reference to the this object to allow chaining

Definition at line 158 of file MaterialBuilder.cpp.

References m_cellVol.

Referenced by export_MaterialBuilder(), and Mantid::DataHandling::ReadMaterial::setNumberDensity().

◆ setXRayAttenuationProfileFilename()

MaterialBuilder & Mantid::Kernel::MaterialBuilder::setXRayAttenuationProfileFilename ( std::string  filename)

Set a value for the attenuation profile filename.

Parameters
filenameName of the file containing the attenuation profile
Returns
A reference to the this object to allow chaining

Definition at line 231 of file MaterialBuilder.cpp.

References m_xRayAttenuationProfileFileName.

Referenced by Mantid::DataHandling::ReadMaterial::setScatteringInfo().

◆ setZParameter()

MaterialBuilder & Mantid::Kernel::MaterialBuilder::setZParameter ( double  zparam)

Set the number of formula units in the unit cell.

Parameters
zparamNumber of formula units
Returns
A reference to the this object to allow chaining

Definition at line 148 of file MaterialBuilder.cpp.

References m_zParam.

Referenced by export_MaterialBuilder(), and Mantid::DataHandling::ReadMaterial::setNumberDensity().

Member Data Documentation

◆ m_absSection

boost::optional<double> Mantid::Kernel::MaterialBuilder::m_absSection
private

◆ m_atomicNo

boost::optional<int> Mantid::Kernel::MaterialBuilder::m_atomicNo
private

◆ m_attenuationFileSearchPath

std::string Mantid::Kernel::MaterialBuilder::m_attenuationFileSearchPath
private

Definition at line 82 of file MaterialBuilder.h.

Referenced by build(), and setAttenuationSearchPath().

◆ m_attenuationProfileFileName

boost::optional<std::string> Mantid::Kernel::MaterialBuilder::m_attenuationProfileFileName
private

Definition at line 80 of file MaterialBuilder.h.

Referenced by build(), and setAttenuationProfileFilename().

◆ m_cellVol

boost::optional<double> Mantid::Kernel::MaterialBuilder::m_cellVol
private

Definition at line 77 of file MaterialBuilder.h.

Referenced by getOrCalculateRhoAndPacking(), and setUnitCellVolume().

◆ m_cohXSection

boost::optional<double> Mantid::Kernel::MaterialBuilder::m_cohXSection
private

◆ m_formula

Material::ChemicalFormula Mantid::Kernel::MaterialBuilder::m_formula
private

Definition at line 72 of file MaterialBuilder.h.

Referenced by build(), generateCustomNeutron(), setAtomicNumber(), and setFormula().

◆ m_incXSection

boost::optional<double> Mantid::Kernel::MaterialBuilder::m_incXSection
private

◆ m_massDensity

boost::optional<double> Mantid::Kernel::MaterialBuilder::m_massDensity
private

Definition at line 77 of file MaterialBuilder.h.

Referenced by getOrCalculateRhoAndPacking(), and setMassDensity().

◆ m_massNo

int Mantid::Kernel::MaterialBuilder::m_massNo
private

◆ m_name

std::string Mantid::Kernel::MaterialBuilder::m_name
private

Definition at line 71 of file MaterialBuilder.h.

Referenced by build(), setFormula(), and setName().

◆ m_numberDensity

boost::optional<double> Mantid::Kernel::MaterialBuilder::m_numberDensity
private

Definition at line 75 of file MaterialBuilder.h.

Referenced by build(), getOrCalculateRhoAndPacking(), and setNumberDensity().

◆ m_numberDensityEff

boost::optional<double> Mantid::Kernel::MaterialBuilder::m_numberDensityEff
private

Definition at line 76 of file MaterialBuilder.h.

Referenced by getOrCalculateRhoAndPacking(), and setEffectiveNumberDensity().

◆ m_numberDensityUnit

NumberDensityUnit Mantid::Kernel::MaterialBuilder::m_numberDensityUnit
private

Definition at line 79 of file MaterialBuilder.h.

Referenced by getOrCalculateRhoAndPacking(), and setNumberDensityUnit().

◆ m_packingFraction

boost::optional<double> Mantid::Kernel::MaterialBuilder::m_packingFraction
private

Definition at line 75 of file MaterialBuilder.h.

Referenced by getOrCalculateRhoAndPacking(), and setPackingFraction().

◆ m_totalXSection

boost::optional<double> Mantid::Kernel::MaterialBuilder::m_totalXSection
private

◆ m_xRayAttenuationProfileFileName

boost::optional<std::string> Mantid::Kernel::MaterialBuilder::m_xRayAttenuationProfileFileName
private

Definition at line 81 of file MaterialBuilder.h.

Referenced by build(), and setXRayAttenuationProfileFilename().

◆ m_zParam

boost::optional<double> Mantid::Kernel::MaterialBuilder::m_zParam
private

Definition at line 77 of file MaterialBuilder.h.

Referenced by getOrCalculateRhoAndPacking(), and setZParameter().


The documentation for this class was generated from the following files: