Skip to content

Commit 410ef16

Browse files
committed
Test OPTIMIZED evaluation with type masking.
1 parent c56cb45 commit 410ef16

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/tests/TestPQEvaluator.hpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@
2424

2525
#include <diffpy/srreal/PQEvaluator.hpp>
2626
#include <diffpy/srreal/AtomicStructureAdapter.hpp>
27+
#include <diffpy/srreal/PeriodicStructureAdapter.hpp>
2728
#include <diffpy/srreal/PDFCalculator.hpp>
2829
#include <diffpy/srreal/OverlapCalculator.hpp>
30+
#include "test_helpers.hpp"
2931

3032
namespace diffpy {
3133
namespace srreal {
@@ -145,6 +147,34 @@ class TestPQEvaluator : public CxxTest::TestSuite
145147
}
146148

147149

150+
void test_PDF_type_mask()
151+
{
152+
mpdfcb.setTypeMask("O2-", "all", false);
153+
mpdfco.setTypeMask("O2-", "all", false);
154+
PeriodicStructureAdapterPtr litao =
155+
boost::dynamic_pointer_cast<PeriodicStructureAdapter>(
156+
loadTestPeriodicStructure("LiTaO3.stru"));
157+
TS_ASSERT_EQUALS(mzeros, this->pdfcdiff(litao));
158+
TS_ASSERT_EQUALS(BASIC, mpdfco.getEvaluatorTypeUsed());
159+
QuantityType gb0 = mpdfcb.getPDF();
160+
// change masked-away oxygen
161+
Atom& o29 = litao->at(29);
162+
TS_ASSERT_EQUALS("O2-", o29.atomtype);
163+
o29.xyz_cartn = R3::Vector(0.1, 0.2, 0.3);
164+
TS_ASSERT_EQUALS(mzeros, this->pdfcdiff(litao));
165+
TS_ASSERT_EQUALS(OPTIMIZED, mpdfco.getEvaluatorTypeUsed());
166+
QuantityType gb1 = mpdfcb.getPDF();
167+
TS_ASSERT_EQUALS(gb0, gb1);
168+
// change active lithium
169+
Atom& li0 = litao->at(0);
170+
li0.occupancy = 0.1;
171+
TS_ASSERT(allclose(mzeros, this->pdfcdiff(litao)));
172+
TS_ASSERT_EQUALS(OPTIMIZED, mpdfco.getEvaluatorTypeUsed());
173+
QuantityType gb2 = mpdfcb.getPDF();
174+
TS_ASSERT(!allclose(gb0, gb2));
175+
}
176+
177+
148178
void test_optimized_unsupported()
149179
{
150180
OverlapCalculator olc;

0 commit comments

Comments
 (0)