Commit 937d71af authored by Kendrick, Coleman's avatar Kendrick, Coleman
Browse files

Added packing fraction to SetSampleMaterial

parent 9ed07a41
......@@ -98,7 +98,7 @@ private:
const int massNumber);
void
setNumberDensity(const double rho_m, const double rho,
setNumberDensity(const double rho_m, const double rho, const double pFrac,
const Kernel::MaterialBuilder::NumberDensityUnit rhoUnit,
const double zParameter, const double unitCellVolume);
void setScatteringInfo(double coherentXSection, double incoherentXSection,
......
......@@ -131,7 +131,7 @@ void ReadMaterial::setMaterialParameters(const MaterialParameters &params) {
massDensity = params.mass / params.volume;
}
setNumberDensity(massDensity, params.numberDensity, params.numberDensityUnit,
setNumberDensity(massDensity, params.numberDensity, params.packingFraction, params.numberDensityUnit,
params.zParameter, params.unitCellVolume);
setScatteringInfo(params.coherentXSection, params.incoherentXSection,
params.attenuationXSection, params.scatteringXSection,
......@@ -158,20 +158,24 @@ void ReadMaterial::setMaterial(const std::string &chemicalSymbol,
}
void ReadMaterial::setNumberDensity(
const double rho_m, const double rho,
const double rho_m, const double rho, const double pFrac,
Kernel::MaterialBuilder::NumberDensityUnit rhoUnit, const double zParameter,
const double unitCellVolume) {
if (!isEmpty(rho_m))
builder.setMassDensity(rho_m);
if (isEmpty(rho)) {
if (!isEmpty(zParameter)) {
builder.setZParameter(zParameter);
builder.setUnitCellVolume(unitCellVolume);
}
} else {
// These can be specified even if mass density set
if (!isEmpty(zParameter)) {
builder.setZParameter(zParameter);
builder.setUnitCellVolume(unitCellVolume);
}
if(!isEmpty(rho)) {
builder.setNumberDensity(rho);
builder.setNumberDensityUnit(rhoUnit);
}
if(!isEmpty(pFrac)) {
builder.setPackingFraction(pFrac);
}
}
void ReadMaterial::setScatteringInfo(double coherentXSection,
......
......@@ -57,6 +57,17 @@ void SetSampleMaterial::init() {
"This number density of the sample in number of "
"atoms or formula units per cubic Angstrom will be used instead of "
"calculated");
declareProperty("SampleEffectiveNumberDensity", EMPTY_DBL(), mustBePositive,
"Defines the effective number density of the sample, which is "
"related to the number density and packing fraction.");
auto packingValidator = std::make_shared<BoundedValidator<double>>();
// Make sure packing fraction is within [0, 2)
packingValidator->setLower(0.0);
packingValidator->setUpper(2.0);
packingValidator->setUpperExclusive(false);
declareProperty("SamplePackingFraction", 1.0, packingValidator,
"Defines the packing fraction of the sample which can be used "
"to calculate the number density and the effective number density");
declareProperty("ZParameter", EMPTY_DBL(), mustBePositive,
"Number of formula units in unit cell");
declareProperty("UnitCellVolume", EMPTY_DBL(), mustBePositive,
......@@ -104,6 +115,8 @@ void SetSampleMaterial::init() {
std::string densityGrp("Sample Density");
setPropertyGroup("SampleNumberDensity", densityGrp);
setPropertyGroup("SampleEffectiveNumberDensity", densityGrp);
setPropertyGroup("SamplePackingFraction", densityGrp);
setPropertyGroup("NumberDensityUnit", densityGrp);
setPropertyGroup("ZParameter", densityGrp);
setPropertyGroup("UnitCellVolume", densityGrp);
......@@ -138,6 +151,8 @@ std::map<std::string, std::string> SetSampleMaterial::validateInputs() {
params.atomicNumber = getProperty("AtomicNumber");
params.massNumber = getProperty("MassNumber");
params.numberDensity = getProperty("SampleNumberDensity");
params.numberDensityEffective = getProperty("SampleEffectiveNumberDensity");
params.packingFraction = getProperty("SamplePackingFraction");
params.zParameter = getProperty("ZParameter");
params.unitCellVolume = getProperty("UnitCellVolume");
params.massDensity = getProperty("SampleMassDensity");
......
......@@ -159,10 +159,9 @@ public:
auto result = ReadMaterial::validateInputs(params);
TS_ASSERT_EQUALS(result.size(), 1)
TS_ASSERT_EQUALS(
result["NumberDensity"],
"The number density or effective number density must "
" be specified with a user-defined material")
TS_ASSERT_EQUALS(result["NumberDensity"],
"The number density or effective number density must "
" be specified with a user-defined material")
}
void testSuccessfullValidateInputsSampleNumber() {
......@@ -528,7 +527,8 @@ private:
material.chemicalFormula();
TS_ASSERT_EQUALS(material.numberDensity(), check.numberDensity());
TS_ASSERT_EQUALS(material.numberDensityEffective(), check.numberDensityEffective())
TS_ASSERT_EQUALS(material.numberDensityEffective(),
check.numberDensityEffective())
TS_ASSERT_EQUALS(material.packingFraction(), check.packingFraction())
TS_ASSERT_DELTA(material.cohScatterXSection(), check.cohScatterXSection(),
PRECISION);
......
......@@ -70,6 +70,8 @@ public:
// can get away with holding pointer as it is an inout ws property
const auto sampleMaterial = testWS->sample().getMaterial();
TS_ASSERT_DELTA(sampleMaterial.numberDensity(), 0.1183245, 0.0001);
TS_ASSERT_EQUALS(sampleMaterial.numberDensityEffective(), sampleMaterial.numberDensity())
TS_ASSERT_EQUALS(sampleMaterial.packingFraction(), 1.0)
TS_ASSERT_DELTA(sampleMaterial.totalScatterXSection(), 3.1404, 0.0001);
TS_ASSERT_DELTA(sampleMaterial.absorbXSection(NeutronAtom::ReferenceLambda),
0.0925, 0.0001);
......@@ -115,6 +117,8 @@ public:
// can get away with holding pointer as it is an inout ws property
const auto sampleMaterial = testWS->sample().getMaterial();
TS_ASSERT_DELTA(sampleMaterial.numberDensity(), 0.1183245, 0.0001);
TS_ASSERT_EQUALS(sampleMaterial.numberDensityEffective(), sampleMaterial.numberDensity())
TS_ASSERT_EQUALS(sampleMaterial.packingFraction(), 1.0)
TS_ASSERT_DELTA(sampleMaterial.totalScatterXSection(), 3.1404, 0.0001);
TS_ASSERT_DELTA(sampleMaterial.absorbXSection(NeutronAtom::ReferenceLambda),
0.0925, 0.0001);
......@@ -152,6 +156,8 @@ public:
// can get away with holding pointer as it is an inout ws property
const auto sampleMaterial = testWS->sample().getMaterial();
TS_ASSERT_DELTA(sampleMaterial.numberDensity(), 0.1183245, 0.0001);
TS_ASSERT_EQUALS(sampleMaterial.numberDensityEffective(), sampleMaterial.numberDensity())
TS_ASSERT_EQUALS(sampleMaterial.packingFraction(), 1.0)
TS_ASSERT_DELTA(sampleMaterial.totalScatterXSection(), 4.0852, 0.0001);
TS_ASSERT_DELTA(sampleMaterial.absorbXSection(NeutronAtom::ReferenceLambda),
1.4381, 0.0001);
......@@ -194,6 +200,8 @@ public:
const auto sampleMaterial = testWS->sample().getMaterial();
TS_ASSERT_DELTA(sampleMaterial.numberDensity(), 0.1183245, 0.0001);
TS_ASSERT_EQUALS(sampleMaterial.numberDensityEffective(), sampleMaterial.numberDensity())
TS_ASSERT_EQUALS(sampleMaterial.packingFraction(), 1.0)
TS_ASSERT_DELTA(sampleMaterial.totalScatterXSection(), 3.1404, 0.0001);
TS_ASSERT_DELTA(sampleMaterial.absorbXSection(NeutronAtom::ReferenceLambda),
0.0925, 0.0001);
......@@ -232,6 +240,8 @@ public:
const auto sampleMaterial = testWS->sample().getMaterial();
TS_ASSERT_DELTA(sampleMaterial.numberDensity(), 0.0913375, 0.0001);
TS_ASSERT_EQUALS(sampleMaterial.numberDensityEffective(), sampleMaterial.numberDensity())
TS_ASSERT_EQUALS(sampleMaterial.packingFraction(), 1.0)
TS_ASSERT_DELTA(sampleMaterial.totalScatterXSection(), 18.5, 0.0001);
TS_ASSERT_DELTA(sampleMaterial.absorbXSection(NeutronAtom::ReferenceLambda),
4.49, 0.0001);
......
......@@ -142,6 +142,8 @@ public:
const auto &material = inputWS->sample().getMaterial();
TS_ASSERT_EQUALS("V", material.name());
TS_ASSERT_DELTA(0.0722, material.numberDensity(), 1e-04);
TS_ASSERT_EQUALS(material.numberDensityEffective(), material.numberDensity())
TS_ASSERT_EQUALS(material.packingFraction(), 1.0)
}
void test_Setting_Container_Material() {
......@@ -156,6 +158,8 @@ public:
const auto &material = container.material();
TS_ASSERT_EQUALS("V", material.name());
TS_ASSERT_DELTA(0.0722, material.numberDensity(), 1e-04);
TS_ASSERT_EQUALS(material.numberDensityEffective(), material.numberDensity())
TS_ASSERT_EQUALS(material.packingFraction(), 1.0)
}
void test_Setting_Geometry_With_Material_Already_Set_Keeps_Material() {
......@@ -182,6 +186,8 @@ public:
const auto &material = inputWS->sample().getMaterial();
TS_ASSERT_EQUALS("Al", material.name());
TS_ASSERT_DELTA(2.6989, material.numberDensity(), 1e-04);
TS_ASSERT_EQUALS(material.numberDensityEffective(), material.numberDensity())
TS_ASSERT_EQUALS(material.packingFraction(), 1.0)
}
void test_Setting_Environment_No_Geometry_Overrides() {
......@@ -679,6 +685,8 @@ public:
const auto &material = inputWS->sample().getMaterial();
TS_ASSERT_EQUALS("V", material.name());
TS_ASSERT_DELTA(0.0722, material.numberDensity(), 1e-04);
TS_ASSERT_EQUALS(material.numberDensityEffective(), material.numberDensity())
TS_ASSERT_EQUALS(material.packingFraction(), 1.0)
}
void test_Setting_Geometry_As_HollowCylinder() {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment