35using namespace Kernel;
43 "The workspace with which to associate the sample ");
44 declareProperty(
"ChemicalFormula",
"",
"The chemical formula, see examples in documentation");
46 declareProperty(
"MassNumber", 0,
"Mass number if ion (use 0 for default mass number)");
47 auto mustBePositive = std::make_shared<BoundedValidator<double>>();
48 mustBePositive->setLower(0.0);
50 "This number density of the sample in number of "
51 "atoms or formula units per cubic Angstrom will be used instead of "
54 "Defines the effective number density of the sample, which is "
55 "related to the number density and packing fraction.");
57 "Defines the packing fraction of the sample which can be used "
58 "to calculate the number density and the effective number density");
61 "Unit cell volume in Angstoms^3. Will be calculated from the "
62 "OrientedLattice if not supplied.");
64 "This coherent cross-section for the sample "
65 "material in barns will be used instead of tabulated");
67 "This incoherent cross-section for the sample "
68 "material in barns will be used instead of tabulated");
70 "This absorption cross-section for the sample "
71 "material in barns will be used instead of tabulated");
73 "Optional: This total scattering cross-section (coherent + "
74 "incoherent) for the sample material in barns will be used "
75 "instead of tabulated");
76 const std::vector<std::string> extensions{
".DAT"};
78 "The path name of the file containing the attenuation profile");
81 "The path name of the file containing the Xray attenuation profile");
84 "Measured mass density in g/cubic cm of the sample "
85 "to be used to calculate the effective number density.");
87 "Measured mass in g of the sample. This is used with the SampleVolume "
88 "to calculate the number density.");
90 "Measured volume in gm^3 of the sample. This is used with the SampleMass "
91 "to calculate the number density.");
92 const std::vector<std::string> units({
"Atoms",
"Formula Units"});
93 declareProperty(
"NumberDensityUnit", units.front(), std::make_shared<StringListValidator>(units),
94 "Choose which units SampleNumberDensity referes to.");
97 std::string formulaGrp(
"By Formula or Atomic Number");
102 std::string densityGrp(
"Sample Density");
113 std::string specificValuesGrp(
"Override Cross Section Values");
125 std::make_unique<Kernel::EnabledWhenProperty>(
"ChemicalFormula",
Kernel::IS_DEFAULT));
127 std::make_unique<Kernel::EnabledWhenProperty>(
"ChemicalFormula",
Kernel::IS_DEFAULT));
150 const std::string numberDensityUnit =
getProperty(
"NumberDensityUnit");
151 if (numberDensityUnit ==
"Atoms") {
191 throw std::runtime_error(
"InputWorkspace does not have a sample object");
202 const double bcoh_avg_sq = material->cohScatterLengthSqrd();
203 const double btot_sq_avg = material->totalScatterLengthSqrd();
204 double normalizedLaue = (btot_sq_avg - bcoh_avg_sq) / bcoh_avg_sq;
205 if (btot_sq_avg == bcoh_avg_sq)
209 auto shapeObject = std::shared_ptr<Geometry::IObject>(expInfo->sample().getShape().cloneWithMaterial(*material));
210 expInfo->mutableSample().setShape(shapeObject);
212 if (
isEmpty(material->numberDensity())) {
215 g_log.
information() <<
"= " << material->numberDensity() <<
" atoms/Angstrom^3\n";
218 <<
" Coherent " << material->cohScatterXSection() <<
" barns\n"
219 <<
" Incoherent " << material->incohScatterXSection() <<
" barns\n"
220 <<
" Total " << material->totalScatterXSection() <<
" barns\n"
221 <<
" Absorption " << material->absorbXSection() <<
" barns\n"
223 <<
" <b_coh>^2 = " << bcoh_avg_sq <<
"\n"
224 <<
" <b_tot^2> = " << btot_sq_avg <<
"\n"
225 <<
" L = " << normalizedLaue <<
"\n";
230 const double rho = material->numberDensity();
231 double smu = material->totalScatterXSection() *
rho;
234 <<
"Anvred LinearAbsorptionCoef = " << amu <<
" 1/cm\n";
#define DECLARE_ALGORITHM(classname)
IPeaksWorkspace_sptr workspace
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
void progress(double p, const std::string &msg="", double estimatedTime=0.0, int progressPrecision=0)
Sends ProgressNotification.
bool isDefault(const std::string &name) const
static bool isEmpty(const NumT toCheck)
checks that the value was not set by users, uses the value in empty double/int.
@ OptionalLoad
to specify a file to read but the file doesn't have to exist
A property class for workspaces.
This class contains code for interpreting a material input for SetSampleMaterial, validating the para...
std::unique_ptr< Kernel::Material > buildMaterial()
Construct the material,.
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.
This class allows the shape of the sample to be defined by using the allowed XML expressions.
void exec() override
Execution code.
ReadMaterial::MaterialParameters params
std::map< std::string, std::string > validateInputs() override
Perform validation of ALL the input properties of the algorithm.
void init() override
Initialisation code.
void fixNeutron(PhysicalConstants::NeutronAtom &neutron, double coh_xs, double inc_xs, double abs_xs, double tot_xs)
Print out the list of information for the material.
int version() const override
Algorithm's version.
const std::string category() const override
Algorithm's category for identification.
void setPropertySettings(const std::string &name, std::unique_ptr< IPropertySettings > settings)
void setPropertyGroup(const std::string &name, const std::string &group)
Set the group for a given property.
void information(const std::string &msg)
Logs at information level.
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
std::shared_ptr< ExperimentInfo > ExperimentInfo_sptr
Shared pointer to ExperimentInfo.
A namespace containing physical constants that are required by algorithms and unit routines.
constexpr double EMPTY_DBL() noexcept
Returns what we consider an "empty" double within a property.
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.
@ InOut
Both an input & output workspace.
Structure to store neutronic scattering information for the various elements.
double inc_scatt_xs
The incoherent scattering cross section in barns.
double tot_scatt_xs
The total scattering cross section in barns.
double abs_scatt_xs
The absorption cross section for 2200m/s neutrons in barns.
double coh_scatt_xs
The coherent scattering cross section in barns.
static const double ReferenceLambda
The reference wavelength value for absorption cross sections.