Commit ca504086 authored by Kendrick, Coleman's avatar Kendrick, Coleman
Browse files

Formatting, adding properties to SetSample

parent 937d71af
......@@ -131,8 +131,9 @@ void ReadMaterial::setMaterialParameters(const MaterialParameters &params) {
massDensity = params.mass / params.volume;
}
setNumberDensity(massDensity, params.numberDensity, params.packingFraction, params.numberDensityUnit,
params.zParameter, params.unitCellVolume);
setNumberDensity(massDensity, params.numberDensity, params.packingFraction,
params.numberDensityUnit, params.zParameter,
params.unitCellVolume);
setScatteringInfo(params.coherentXSection, params.incoherentXSection,
params.attenuationXSection, params.scatteringXSection,
params.attenuationProfileFileName);
......@@ -169,11 +170,11 @@ void ReadMaterial::setNumberDensity(
builder.setZParameter(zParameter);
builder.setUnitCellVolume(unitCellVolume);
}
if(!isEmpty(rho)) {
if (!isEmpty(rho)) {
builder.setNumberDensity(rho);
builder.setNumberDensityUnit(rhoUnit);
}
if(!isEmpty(pFrac)) {
if (!isEmpty(pFrac)) {
builder.setPackingFraction(pFrac);
}
}
......
......@@ -724,6 +724,14 @@ void SetSample::setMaterial(ReadMaterial::MaterialParameters &materialParams,
if (materialArgs.existsProperty("MassDensity")) {
materialParams.massDensity = materialArgs.getProperty("MassDensity");
}
if (materialArgs.existsProperty("NumberDensityEffective")) {
materialParams.numberDensityEffective =
materialArgs.getProperty("numberDensityEffective");
}
if (materialArgs.existsProperty("PackingFraction")) {
materialParams.packingFraction =
materialArgs.getProperty("packingFraction");
}
if (materialArgs.existsProperty("Mass")) {
materialParams.mass = materialArgs.getProperty("Mass");
}
......
......@@ -57,7 +57,8 @@ 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,
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>>();
......@@ -65,7 +66,8 @@ void SetSampleMaterial::init() {
packingValidator->setLower(0.0);
packingValidator->setUpper(2.0);
packingValidator->setUpperExclusive(false);
declareProperty("SamplePackingFraction", 1.0, packingValidator,
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,
......
......@@ -70,7 +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.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),
......@@ -117,7 +118,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.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),
......@@ -156,7 +158,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.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),
......@@ -200,7 +203,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.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),
......@@ -240,7 +244,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.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),
......
......@@ -142,7 +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.numberDensityEffective(),
material.numberDensity())
TS_ASSERT_EQUALS(material.packingFraction(), 1.0)
}
......@@ -158,7 +159,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.numberDensityEffective(),
material.numberDensity())
TS_ASSERT_EQUALS(material.packingFraction(), 1.0)
}
......@@ -186,7 +188,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.numberDensityEffective(),
material.numberDensity())
TS_ASSERT_EQUALS(material.packingFraction(), 1.0)
}
......@@ -685,7 +688,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.numberDensityEffective(),
material.numberDensity())
TS_ASSERT_EQUALS(material.packingFraction(), 1.0)
}
......
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