Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mantidproject
mantid
Commits
5b8daaff
Commit
5b8daaff
authored
13 years ago
by
Dennis Mikkelson
Browse files
Options
Downloads
Patches
Plain Diff
Added test for IndexPeaks algorithm.
refs #3580
parent
040a0c15
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Code/Mantid/Framework/Crystal/CMakeLists.txt
+1
-0
1 addition, 0 deletions
Code/Mantid/Framework/Crystal/CMakeLists.txt
Code/Mantid/Framework/Crystal/test/IndexPeaksTest.h
+117
-0
117 additions, 0 deletions
Code/Mantid/Framework/Crystal/test/IndexPeaksTest.h
with
118 additions
and
0 deletions
Code/Mantid/Framework/Crystal/CMakeLists.txt
+
1
−
0
View file @
5b8daaff
...
@@ -43,6 +43,7 @@ set ( TEST_FILES
...
@@ -43,6 +43,7 @@ set ( TEST_FILES
test/FindUBUsingLatticeParametersTest.h
test/FindUBUsingLatticeParametersTest.h
test/FindUBUsingMinMaxDTest.h
test/FindUBUsingMinMaxDTest.h
test/FindUBUsingIndexedPeaksTest.h
test/FindUBUsingIndexedPeaksTest.h
test/IndexPeaksTest.h
test/IntegratePeakTimeSlicesTest.h
test/IntegratePeakTimeSlicesTest.h
test/LoadIsawUBTest.h
test/LoadIsawUBTest.h
test/LoadPeaksFileTest.h
test/LoadPeaksFileTest.h
...
...
This diff is collapsed.
Click to expand it.
Code/Mantid/Framework/Crystal/test/IndexPeaksTest.h
0 → 100644
+
117
−
0
View file @
5b8daaff
#ifndef MANTID_CRYSTAL_INDEX_PEAKS_TEST_H_
#define MANTID_CRYSTAL_INDEX_PEAKS_TEST_H_
#include
<cxxtest/TestSuite.h>
#include
"MantidKernel/Timer.h"
#include
"MantidKernel/System.h"
#include
<iostream>
#include
<iomanip>
#include
"MantidCrystal/IndexPeaks.h"
#include
"MantidCrystal/LoadPeaksFile.h"
#include
"MantidGeometry/Crystal/IndexingUtils.h"
#include
"MantidGeometry/Crystal/OrientedLattice.h"
#include
"MantidCrystal/LoadIsawUB.h"
using
namespace
Mantid
;
using
namespace
Mantid
::
Crystal
;
using
namespace
Mantid
::
API
;
using
namespace
Mantid
::
DataObjects
;
using
namespace
Mantid
::
Kernel
;
using
namespace
Mantid
::
Geometry
;
class
IndexPeaksTest
:
public
CxxTest
::
TestSuite
{
public:
void
test_Init
()
{
IndexPeaks
alg
;
TS_ASSERT_THROWS_NOTHING
(
alg
.
initialize
()
)
TS_ASSERT
(
alg
.
isInitialized
()
)
}
void
test_exec
()
{
// Name of the output workspace.
std
::
string
WSName
(
"peaks"
);
LoadPeaksFile
loader
;
TS_ASSERT_THROWS_NOTHING
(
loader
.
initialize
()
);
TS_ASSERT
(
loader
.
isInitialized
()
);
loader
.
setPropertyValue
(
"Filename"
,
"TOPAZ_3007.peaks"
);
loader
.
setPropertyValue
(
"OutputWorkspace"
,
WSName
);
TS_ASSERT
(
loader
.
execute
()
);
TS_ASSERT
(
loader
.
isExecuted
()
);
PeaksWorkspace_sptr
ws
;
TS_ASSERT_THROWS_NOTHING
(
ws
=
boost
::
dynamic_pointer_cast
<
PeaksWorkspace
>
(
AnalysisDataService
::
Instance
().
retrieve
(
WSName
)
)
);
TS_ASSERT
(
ws
);
// clear all the peak indexes
std
::
vector
<
Peak
>
&
peaks
=
ws
->
getPeaks
();
size_t
n_peaks
=
ws
->
getNumberPeaks
();
for
(
size_t
i
=
0
;
i
<
n_peaks
;
i
++
)
{
peaks
[
i
].
setHKL
(
V3D
(
0
,
0
,
0
)
);
}
// now set a proper UB in the
// oriented lattice
V3D
row_0
(
-
0.0122354
,
0.00480056
,
-
0.0860404
);
V3D
row_1
(
0.1165450
,
0.00178145
,
0.0045884
);
V3D
row_2
(
0.0273738
,
-
0.08973560
,
0.0252595
);
Matrix
<
double
>
UB
(
3
,
3
,
false
);
UB
.
setRow
(
0
,
row_0
);
UB
.
setRow
(
1
,
row_1
);
UB
.
setRow
(
2
,
row_2
);
OrientedLattice
o_lattice
;
o_lattice
.
setUB
(
UB
);
ws
->
mutableSample
().
setOrientedLattice
(
new
OrientedLattice
(
o_lattice
)
);
// index the peaks with the new UB
IndexPeaks
alg
;
TS_ASSERT_THROWS_NOTHING
(
alg
.
initialize
()
)
TS_ASSERT
(
alg
.
isInitialized
()
)
TS_ASSERT_THROWS_NOTHING
(
alg
.
setPropertyValue
(
"PeaksWorkspace"
,
WSName
)
);
TS_ASSERT_THROWS_NOTHING
(
alg
.
setPropertyValue
(
"tolerance"
,
"0.1"
)
);
TS_ASSERT_THROWS_NOTHING
(
alg
.
execute
();
);
TS_ASSERT
(
alg
.
isExecuted
()
);
double
tolerance
=
alg
.
getProperty
(
"tolerance"
);
// Check that the peaks were all indexed
for
(
size_t
i
=
0
;
i
<
n_peaks
;
i
++
)
{
TS_ASSERT
(
IndexingUtils
::
ValidIndex
(
peaks
[
i
].
getHKL
(),
tolerance
)
);
}
// spot check a few peaks
V3D
peak_0_hkl
(
-
4
,
-
1
,
-
6
);
// first peak
V3D
peak_1_hkl
(
-
3
,
1
,
-
4
);
V3D
peak_2_hkl
(
-
4
,
1
,
-
5
);
V3D
peak_10_hkl
(
-
3
,
0
,
-
7
);
V3D
peak_42_hkl
(
-
2
,
4
,
-
7
);
// last peak
V3D
error
=
peak_0_hkl
-
peaks
[
0
].
getHKL
();
TS_ASSERT_DELTA
(
error
.
norm
(),
0.0
,
0.1
);
error
=
peak_1_hkl
-
peaks
[
1
].
getHKL
();
TS_ASSERT_DELTA
(
error
.
norm
(),
0.0
,
0.1
);
error
=
peak_2_hkl
-
peaks
[
2
].
getHKL
();
TS_ASSERT_DELTA
(
error
.
norm
(),
0.0
,
0.1
);
error
=
peak_10_hkl
-
peaks
[
10
].
getHKL
();
TS_ASSERT_DELTA
(
error
.
norm
(),
0.0
,
0.1
);
error
=
peak_42_hkl
-
peaks
[
42
].
getHKL
();
TS_ASSERT_DELTA
(
error
.
norm
(),
0.0
,
0.1
);
// Remove workspace from the data service.
AnalysisDataService
::
Instance
().
remove
(
WSName
);
}
};
#endif
/* MANTID_CRYSTAL_INDEX_PEAKS_TEST_H_ */
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment