26 if (!chemicalSymbol && !atomicNumber) {
28 result[
"CoherentXSection"] =
"The cross section must be specified when "
29 "no ChemicalFormula or AtomicNumber is "
33 result[
"IncoherentXSection"] =
"The cross section must be specified when "
34 "no ChemicalFormula or AtomicNumber is "
38 result[
"AttenuationXSection"] =
"The cross section must be specified "
39 "when no ChemicalFormula or AtomicNumber "
43 result[
"ScatteringXSection"] =
"The cross section must be specified when "
44 "no ChemicalFormula or AtomicNumber is "
49 result[
"NumberDensity"] =
"The number density or effective number density or Z Parameter\\Unit Cell Volume must "
50 " be specified with a user-defined material";
53 }
else if (chemicalSymbol && atomicNumber) {
54 result[
"AtomicNumber"] =
"Cannot specify both ChemicalFormula and AtomicNumber";
58 result[
"NumberDensity"] =
"Number Density cannot be determined when "
59 "both the effective number density and "
60 "packing fraction are set. Only two can "
61 "be specified at most.";
68 result[
"PackingFraction"] =
"Cannot set packing fraction when both the number density "
69 "and effective number density are determined from "
70 "the mass density and cell volume + zParameter.";
78 result[
"EffectiveNumberDensity"] =
"Cannot set effective number density when the mass density "
79 "is specified. The value specified will be overwritten "
80 "because it will be computed from the mass density.";
87 result[
"PackingFraction"] =
"Cannot have a packing fraction larger than 2";
89 result[
"PackingFraction"] =
"Cannot have a packing fraction less than 0";
94 result[
"AtomicNumber"] =
"Specified MassNumber without AtomicNumber";
98 result[
"UnitCellVolume"] =
"UnitCellVolume must be provided with ZParameter";
133 return std::make_unique<Kernel::Material>(
builder.
build());
137 if (!chemicalSymbol.empty()) {
139 }
else if (atomicNumber != 0) {
147 const double unitCellVolume) {
169 double scatteringXSection, std::string attenuationProfileFileName,
170 std::string xRayAttenuationProfileFileName) {
std::unique_ptr< Kernel::Material > buildMaterial()
Construct the material,.
void setNumberDensity(const double rho_m, const double rho, const double rho_eff, const double pFrac, const Kernel::MaterialBuilder::NumberDensityUnit rhoUnit, const double zParameter, const double unitCellVolume)
void setMaterial(const std::string &chemicalSymbol, const int atomicNumber, const int massNumber)
void setScatteringInfo(double coherentXSection, double incoherentXSection, double attenuationXSection, double scatteringXSection, std::string attenuationProfileFileName, std::string xRayAttenuationProfileFileName)
void setMaterialParameters(const MaterialParameters ¶ms)
Set the parameters to build the material to the builder, taking into account which values were and we...
static ValidationErrors validateInputs(const MaterialParameters ¶ms)
Validate the parameters to build the material from, this returns any errors in the inputs.
static bool isEmpty(const double toCheck)
Kernel::MaterialBuilder builder
The builder used to construct the material.
MaterialBuilder & setMassDensity(double massDensity)
Set the mass density of the sample in g / cc.
MaterialBuilder & setAttenuationProfileFilename(std::string filename)
Set a value for the attenuation profile filename.
Material build() const
Build the new Material object from the current set of options.
MaterialBuilder & setEffectiveNumberDensity(double rho_eff)
Set the effective number density of the sample in atoms or formula units / Angstrom^3.
MaterialBuilder & setMassNumber(int massNumber)
Set the isotope by mass number.
MaterialBuilder & setFormula(const std::string &formula)
Set the chemical formula of the material.
MaterialBuilder & setZParameter(double zparam)
Set the number of formula units in the unit cell.
MaterialBuilder & setPackingFraction(double fraction)
Set the packing fraction of the material (default is 1).
MaterialBuilder & setTotalScatterXSection(double xsec)
Set a value for the total scattering cross section.
MaterialBuilder & setUnitCellVolume(double cellVolume)
Set the volume of unit cell.
MaterialBuilder & setAbsorptionXSection(double xsec)
Set a value for the absorption cross section.
MaterialBuilder & setNumberDensityUnit(NumberDensityUnit unit)
Set the unit for number density.
MaterialBuilder & setCoherentXSection(double xsec)
Set a value for the coherent scattering cross section.
MaterialBuilder & setIncoherentXSection(double xsec)
Set a value for the incoherent scattering cross section.
MaterialBuilder & setNumberDensity(double rho)
Set the number density of the sample in atoms or formula units / Angstrom^3.
MaterialBuilder & setAtomicNumber(int atomicNumber)
Set the type of atom by its atomic number.
MaterialBuilder & setXRayAttenuationProfileFilename(std::string filename)
Set a value for the attenuation profile filename.
std::map< std::string, std::string > ValidationErrors
constexpr double EMPTY_DBL() noexcept
Returns what we consider an "empty" double within a property.
This struct contains the parameters for constructing a material, and gives them a default value for e...
double numberDensity
The sample number density to set, defaults to EMPTY_DBL()
double coherentXSection
The coherent scattering cross section to set, defaults to EMPTY_DBL()
int massNumber
The mass number to set, defaults to 0.
double mass
The sample mass to set, defaults to EMPTY_DBL()
double packingFraction
The sample packing fraction.
double attenuationXSection
The absorption cross section to set, defaults to EMPTY_DBL()
Kernel::MaterialBuilder::NumberDensityUnit numberDensityUnit
A flag indicating the unit of sampleNumberDensity.
double volume
The sample volume to set, defaults to EMPTY_DBL()
double massDensity
The sample mass density to set, defaults to EMPTY_DBL()
double scatteringXSection
The total scattering cross section to set, defaults to EMPTY_DBL()
double incoherentXSection
The incoherent scattering cross section to set, defaults to EMPTY_DBL()
double zParameter
The zParameter to set, defaults to EMPTY_DBL()
std::string chemicalSymbol
The chemical formula to set, defaults to the empty string.
double numberDensityEffective
The sample effective number density.
std::string xRayAttenuationProfileFileName
The name or path of a file containing an x ray attenuation profile.
double unitCellVolume
The unit cell volume to set, defaults to EMPTY_DBL()
int atomicNumber
The atomic number to set, defaults to 0.
std::string attenuationProfileFileName
The name or path of a file containing an attenuation profile.