21using namespace Kernel;
23using namespace Geometry;
30 auto mustBePositive = std::make_shared<BoundedValidator<double>>();
31 mustBePositive->setLower(0.0);
33 "The ABSORPTION cross-section for the sample material in "
34 "barns if not set with SetSampleMaterial");
36 "The scattering cross-section (coherent + incoherent) for "
37 "the sample material in barns if not set with "
40 "The number density of the sample in number of atoms per "
41 "cubic angstrom if not set with SetSampleMaterial");
43 "The thickness of the sample in cm. Common values are 0.2, "
46 auto positiveInt = std::make_shared<BoundedValidator<int64_t>>();
47 positiveInt->setLower(1);
49 "The number of wavelength points for which the numerical integral is\n"
50 "calculated (default: all points)");
52 std::vector<std::string> exp_options{
"Normal",
"FastApprox"};
53 declareProperty(
"ExpMethod",
"Normal", std::make_shared<StringListValidator>(exp_options),
54 "Select the method to use to calculate exponentials, normal or a\n"
55 "fast approximation (default: Normal)");
57 auto moreThanZero = std::make_shared<BoundedValidator<double>>();
58 moreThanZero->setLower(0.001);
59 declareProperty(
"ElementSize", 1.0, moreThanZero,
"The size of one side of an integration element cube in mm");
84 const double vanWinThickness = 0.000125;
85 const double vanRho = 0.07192 * 100;
86 const double vanRefAtten = -5.08 * vanRho / 1.798;
87 const double vanScat = -5.1 * vanRho;
89 const size_t numHists =
workspace->getNumberHistograms();
90 const size_t specSize =
workspace->blocksize();
92 const auto &spectrumInfo =
workspace->spectrumInfo();
94 for (
size_t i = 0; i < numHists; ++i) {
96 if (!spectrumInfo.hasDetectors(i)) {
102 V3D detectorPos = spectrumInfo.position(i);
104 const int detID = spectrumInfo.detector(i).getID();
107 if (detID < 900000) {
108 double theta = detectorPos.
angle(
V3D(0.0, 0.0, 1.0));
109 angleFactor = 1.0 / std::abs(cos(theta));
113 double theta = detectorPos.
angle(
V3D(1.0, 0.0, 0.0));
114 angleFactor = 1.0 / std::abs(cos(theta));
118 const auto lambdas =
workspace->points(i);
119 for (
size_t j = 0; j < specSize; ++j) {
120 const double lambda = lambdas[j];
123 Y[j] *= exp(vanWinThickness * ((vanRefAtten *
lambda) + vanScat));
126 if (detID > 900000) {
128 Y[j] *= exp(-angleFactor * 0.011 * 6.02 * ((0.231 *
lambda / 1.798) + 1.503));
131 Y[j] *= exp(angleFactor * vanWinThickness * ((vanRefAtten *
lambda) + vanScat));
143 double sigma_atten =
getProperty(
"SampleAttenuationXSection");
144 double sigma_s =
getProperty(
"SampleScatteringXSection");
146 const Material &sampleMaterial = m_inputWS->sample().getMaterial();
156 NeutronAtom neutron(0, 0, 0.0, 0.0, sigma_s, 0.0, sigma_s, sigma_atten);
157 auto shape = std::shared_ptr<IObject>(
158 m_inputWS->sample().getShape().cloneWithMaterial(
Material(
"SetInSphericalAbsorption", neutron,
rho)));
159 m_inputWS->mutableSample().setShape(shape);
166 childAlg->setProperty<
double>(
"AttenuationXSection", sigma_atten);
167 childAlg->setProperty<
double>(
"ScatteringXSection", sigma_s);
168 childAlg->setProperty<
double>(
"SampleNumberDensity",
rho);
169 childAlg->setProperty<int64_t>(
"NumberOfWavelengthPoints",
getProperty(
"NumberOfWavelengthPoints"));
170 childAlg->setProperty<std::string>(
"ExpMethod",
getProperty(
"ExpMethod"));
171 childAlg->setProperty<
double>(
"ElementSize",
getProperty(
"ElementSize"));
173 const double HRPDCanHeight = 2.3;
174 const double HRPDCanWidth = 1.8;
175 childAlg->setProperty(
"SampleHeight", HRPDCanHeight);
176 childAlg->setProperty(
"SampleWidth", HRPDCanWidth);
178 childAlg->setProperty(
"SampleThickness", thickness);
179 childAlg->executeAsChildAlg();
180 return childAlg->getProperty(
"OutputWorkspace");
#define DECLARE_ALGORITHM(classname)
const std::vector< double > * lambda
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.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
virtual std::shared_ptr< Algorithm > createChildAlgorithm(const std::string &name, const double startProgress=-1., const double endProgress=-1., const bool enableLogging=true, const int &version=-1)
Create a Child Algorithm.
void progress(double p, const std::string &msg="", double estimatedTime=0.0, int progressPrecision=0)
Sends ProgressNotification.
Helper class for reporting progress from algorithms.
A property class for workspaces.
void init() override
Initialisation code.
void exec() override
Execution code.
API::MatrixWorkspace_sptr runFlatPlateAbsorption()
runs the flat plate absorption
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
A material is defined as being composed of a given element, defined as a PhysicalConstants::NeutronAt...
double numberDensity() const
Get the number density.
double absorbXSection(const double lambda=PhysicalConstants::NeutronAtom::ReferenceLambda) const
Get the absorption cross section at a given wavelength in barns.
double totalScatterXSection() const
Return the total scattering cross section for a given wavelength in barns.
double angle(const V3D &) const
Angle between this and another vector.
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
A namespace containing physical constants that are required by algorithms and unit routines.
constexpr int EMPTY_INT() noexcept
Returns what we consider an "empty" integer within a property.
constexpr double EMPTY_DBL() noexcept
Returns what we consider an "empty" double within a property.
@ Input
An input workspace.
@ Output
An output workspace.
Structure to store neutronic scattering information for the various elements.
static const double ReferenceLambda
The reference wavelength value for absorption cross sections.