Skip to content
Snippets Groups Projects
Commit 1065a8b5 authored by Nick Draper's avatar Nick Draper
Browse files

refs #7358 Fix the test failures

Specifically, one of the ouput properies was not being set.
Unit tests checks of the output properties have been added.
The failure of the example was due to a change made by Pete in a previous ticket, but I've update the help text.
parent ab0ebabd
No related branches found
No related tags found
No related merge requests found
......@@ -14,8 +14,8 @@ Neutron scattering lengths and cross sections of the elements and their isotopes
=====Setting the sample by a more complex formula=====
SetSampleMaterial(InputWorkspace='IRS26173',ChemicalFormula='Al2-O3', UnitCellVolume='253.54', ZParameter='6')
=====Setting the sample by specific values (all three must be specified)=====
SetSampleMaterial(InputWorkspace='IRS26173',AttenuationXSection=2.56,ScatteringXSection=11.62,SampleNumberDensity=0.0849106)
=====Setting the sample by specific values=====
SetSampleMaterial(InputWorkspace='IRS26173',AtomicNumber=26,AttenuationXSection=2.56,ScatteringXSection=11.62,SampleNumberDensity=0.0849106)
=====Extracting the set values out by python=====
sam = ws.sample()
......@@ -312,7 +312,8 @@ namespace DataHandling
<< " Incoherent " << mat->incohScatterXSection() << " barns\n"
<< " Total " << mat->totalScatterXSection() << " barns\n"
<< " Absorption " << mat->absorbXSection() << " barns\n";
setProperty("IncoherentXSectionResult", mat->incohScatterXSection()); // in barns
setProperty("CoherentXSectionResult", mat->cohScatterXSection()); // in barns
setProperty("IncoherentXSectionResult", mat->incohScatterXSection()); // in barns
setProperty("TotalXSectionResult",mat->totalScatterXSection()); // in barns
setProperty("AbsorptionXSectionResult",mat->absorbXSection()); // in barns
setProperty("ReferenceWavelength",NeutronAtom::ReferenceLambda); // in Angstroms
......
......@@ -40,7 +40,7 @@ public:
void testExec()
{
std::string wsName = "SetSampleMaterialTestWS";
std::string wsName = "SetSampleMaterialTestWS";
IAlgorithm* setmat = Mantid::API::FrameworkManager::Instance().createAlgorithm("SetSampleMaterial");
if ( !setmat->isInitialized() ) setmat->initialize();
......@@ -52,7 +52,7 @@ public:
// Register the workspace in the data service
AnalysisDataService::Instance().add(wsName, testWS);
TS_ASSERT_THROWS_NOTHING( setmat->setPropertyValue("InputWorkspace", wsName) );
TS_ASSERT_THROWS_NOTHING( setmat->setPropertyValue("InputWorkspace", wsName) );
TS_ASSERT_THROWS_NOTHING( setmat->setPropertyValue("ChemicalFormula","Al2-O3") );
TS_ASSERT_THROWS_NOTHING( setmat->setPropertyValue("SampleNumberDensity","0.0236649") );
TS_ASSERT_THROWS_NOTHING( setmat->setPropertyValue("ScatteringXSection","15.7048") );
......@@ -66,7 +66,9 @@ public:
TS_ASSERT_DELTA( m_sampleMaterial->totalScatterXSection(NeutronAtom::ReferenceLambda), 15.7048, 0.0001);
TS_ASSERT_DELTA( m_sampleMaterial->absorbXSection(NeutronAtom::ReferenceLambda), 0.46257, 0.0001);
AnalysisDataService::Instance().remove(wsName);
checkOutputProperties(setmat,m_sampleMaterial);
AnalysisDataService::Instance().remove(wsName);
}
void testExecMat_Formula()
......@@ -95,10 +97,27 @@ public:
TS_ASSERT_DELTA( m_sampleMaterial->numberDensity(), 0.0236649, 0.0001 );
TS_ASSERT_DELTA( m_sampleMaterial->totalScatterXSection(NeutronAtom::ReferenceLambda), 3.1404, 0.0001);
TS_ASSERT_DELTA( m_sampleMaterial->absorbXSection(NeutronAtom::ReferenceLambda), 0.0925, 0.0001);
checkOutputProperties(setmat,m_sampleMaterial);
AnalysisDataService::Instance().remove(wsName);
}
void checkOutputProperties(const IAlgorithm* alg,const Material *material)
{
//test output properties
double testvalue = alg->getProperty("AbsorptionXSectionResult");
TS_ASSERT_DELTA(material->absorbXSection(), testvalue, 0.0001);
testvalue = alg->getProperty("CoherentXSectionResult");
TS_ASSERT_DELTA(material->cohScatterXSection(), testvalue, 0.0001);
testvalue = alg->getProperty("IncoherentXSectionResult");
TS_ASSERT_DELTA(material->incohScatterXSection(), testvalue, 0.0001);
testvalue = alg->getProperty("TotalXSectionResult");
TS_ASSERT_DELTA(material->totalScatterXSection(), testvalue, 0.0001);
testvalue = alg->getProperty("SampleNumberDensityResult");
TS_ASSERT_DELTA(material->numberDensity(), testvalue, 0.0001);
}
};
#endif /*SetSampleMaterialTEST_H_*/
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment