void test_bondCountWurtzite() { StructureAdapterPtr stru = loadTestPeriodicStructure("ZnS_wurtzite.stru"); BaseBondGeneratorPtr bnds = stru->createBondGenerator(); TS_ASSERT_EQUALS(4, stru->countSites()); bnds->selectAnchorSite(0); bnds->selectSiteRange(0, 4); bnds->setRmin(0); // there should be no bond below the ZnS distance 2.31 bnds->setRmax(2.2); TS_ASSERT_EQUALS(0, countBonds(*bnds)); // z-neighbor is slightly more distant than 3 in the lower plane bnds->setRmax(2.35); TS_ASSERT_EQUALS(3, countBonds(*bnds)); bnds->setRmax(2.5); TS_ASSERT_EQUALS(4, countBonds(*bnds)); // there are 12 second nearest neighbors at 3.81 bnds->setRmin(3.7); bnds->setRmax(3.82); TS_ASSERT_EQUALS(12, countBonds(*bnds)); // and one more at 3.83 bnds->setRmax(3.85); TS_ASSERT_EQUALS(13, countBonds(*bnds)); // making the total 17 bnds->setRmin(0); TS_ASSERT_EQUALS(17, countBonds(*bnds)); // and the same happens for all other sites bnds->selectAnchorSite(1); TS_ASSERT_EQUALS(17, countBonds(*bnds)); bnds->selectAnchorSite(2); TS_ASSERT_EQUALS(17, countBonds(*bnds)); bnds->selectAnchorSite(3); TS_ASSERT_EQUALS(17, countBonds(*bnds)); }
void test_countSites() { TS_ASSERT_EQUALS(4, m_ni->countSites()); TS_ASSERT_EQUALS(23, m_kbise->countSites()); TS_ASSERT_EQUALS(20, m_catio3->countSites()); TS_ASSERT_EQUALS(56, m_pswt->countSites()); }
void test_numberDensity() { const double eps = 1.0e-7; TS_ASSERT_DELTA(0.0914114, m_ni->numberDensity(), eps); TS_ASSERT_DELTA(0.0335565, m_kbise->numberDensity(), eps); TS_ASSERT_DELTA(0.0894566, m_catio3->numberDensity(), eps); TS_ASSERT_DELTA(0.0760332, m_pswt->numberDensity(), eps); }
void test_totalOccupancy() { const double eps = 10 * diffpy::mathutils::DOUBLE_EPS; TS_ASSERT_EQUALS(4.0, m_ni->totalOccupancy()); TS_ASSERT_EQUALS(23.0, m_kbise->totalOccupancy()); TS_ASSERT_EQUALS(20.0, m_catio3->totalOccupancy()); TS_ASSERT_DELTA(40.0, m_pswt->totalOccupancy(), eps); }
void test_siteAtomType() { TS_ASSERT_EQUALS(string("Ni"), m_ni->siteAtomType(0)); TS_ASSERT_EQUALS(string("Ni"), m_ni->siteAtomType(3)); TS_ASSERT_EQUALS(string("K1+"), m_kbise->siteAtomType(0)); TS_ASSERT_EQUALS(string("Bi3+"), m_kbise->siteAtomType(2)); TS_ASSERT_EQUALS(string("Se"), m_kbise->siteAtomType(10)); TS_ASSERT_EQUALS(string("Se"), m_kbise->siteAtomType(22)); }
void test_siteAnisotropy() { for (int i = 0; i < m_ni->countSites(); ++i) { TS_ASSERT_EQUALS(false, m_ni->siteAnisotropy(i)); } for (int i = 0; i < m_catio3->countSites(); ++i) { TS_ASSERT_EQUALS(true, m_catio3->siteAnisotropy(i)); } }
void test_serialization() { StructureAdapterPtr kbise1 = dumpandload(m_kbise); TS_ASSERT_DIFFERS(m_kbise.get(), kbise1.get()); const double eps = 1.0e-7; TS_ASSERT_EQUALS(23, kbise1->countSites()); TS_ASSERT_EQUALS(23.0, kbise1->totalOccupancy()); TS_ASSERT_DELTA(0.0335565, kbise1->numberDensity(), eps); TS_ASSERT_EQUALS(string("K1+"), kbise1->siteAtomType(0)); TS_ASSERT_EQUALS(string("Bi3+"), kbise1->siteAtomType(2)); TS_ASSERT_EQUALS(string("Se"), kbise1->siteAtomType(10)); TS_ASSERT_EQUALS(string("Se"), kbise1->siteAtomType(22)); PeriodicStructureAdapterPtr pkbise = boost::dynamic_pointer_cast<PeriodicStructureAdapter>(m_kbise); PeriodicStructureAdapterPtr pkbise1 = boost::dynamic_pointer_cast<PeriodicStructureAdapter>(kbise1); const Lattice& L = pkbise->getLattice(); const Lattice& L1 = pkbise1->getLattice(); TS_ASSERT_EQUALS(L.a(), L1.a()); TS_ASSERT_EQUALS(L.b(), L1.b()); TS_ASSERT_EQUALS(L.c(), L1.c()); TS_ASSERT_EQUALS(L.alpha(), L1.alpha()); TS_ASSERT_EQUALS(L.beta(), L1.beta()); TS_ASSERT_EQUALS(L.gamma(), L1.gamma()); }
void test_NaCl_gradient() { using namespace boost; molc->eval(mnacl); // default gradients are all zero std::vector<R3::Vector> g = molc->gradients(); TS_ASSERT_EQUALS(8u, g.size()); for (int i = 0; i < 8; ++i) { TS_ASSERT_DELTA(0.0, R3::norm(g[i]), meps); } StructureAdapterPtr nacl1 = mnacl->clone(); PeriodicStructureAdapter& nacl1ref = static_cast<PeriodicStructureAdapter&>(*nacl1); R3::Vector& xyzc0 = nacl1ref[0].xyz_cartn; xyzc0 = R3::Vector(0.02, 0.03, 0.07); molc->eval(nacl1); double c0 = molc->totalSquareOverlap(); R3::Vector g0 = molc->gradients()[0]; TS_ASSERT(R3::norm(g0) > meps); R3::Vector g0n; const double dx = 1e-8; for (int i = 0; i < R3::Ndim; ++i) { xyzc0[i] += dx; molc->eval(nacl1); g0n[i] = (molc->totalSquareOverlap() - c0) / dx; xyzc0[i] -= dx; } TS_ASSERT_DELTA(0.0, R3::norm(g0 - g0n), 1e-6); }
void test_siteCartesianUij() { // nickel should have all Uij equal zero. TS_ASSERT_EQUALS(R3::zeromatrix(), m_ni->siteCartesianUij(0)); // check CaTiO3 values const R3::Matrix& UO2 = m_catio3->siteCartesianUij(12); const double eps = 1e-8; TS_ASSERT_DELTA(0.0065, UO2(0,0), eps); TS_ASSERT_DELTA(0.0060, UO2(1,1), eps); TS_ASSERT_DELTA(0.0095, UO2(2,2), eps); TS_ASSERT_DELTA(0.0020, UO2(0,1), eps); TS_ASSERT_DELTA(0.0020, UO2(1,0), eps); TS_ASSERT_DELTA(-0.0008, UO2(0,2), eps); TS_ASSERT_DELTA(-0.0008, UO2(2,0), eps); TS_ASSERT_DELTA(-0.0010, UO2(1,2), eps); TS_ASSERT_DELTA(-0.0010, UO2(2,1), eps); }
void test_siteCartesianPosition() { const double eps = 1.0e-5; R3::Vector rCa = m_catio3->siteCartesianPosition(4); TS_ASSERT_DELTA(0.03486, rCa[0], eps); TS_ASSERT_DELTA(0.19366, rCa[1], eps); TS_ASSERT_DELTA(1.90975, rCa[2], eps); }
void test_empty_instance() { TS_ASSERT_EQUALS(0, mstru->countSites()); TS_ASSERT_EQUALS(mstru.get(), mstru->clone().get()); TS_ASSERT_EQUALS(mstru, emptyStructureAdapter()); TS_ASSERT_THROWS(mstru->siteAtomType(0), std::out_of_range); TS_ASSERT_THROWS(mstru->siteCartesianPosition(0), std::out_of_range); TS_ASSERT_THROWS(mstru->siteMultiplicity(0), std::out_of_range); TS_ASSERT_THROWS(mstru->siteOccupancy(0), std::out_of_range); TS_ASSERT_THROWS(mstru->siteAnisotropy(0), std::out_of_range); TS_ASSERT_THROWS(mstru->siteCartesianPosition(0), std::out_of_range); }
NoMetaStructureAdapter::NoMetaStructureAdapter( StructureAdapterPtr srcstructure) { boost::shared_ptr<NoMetaStructureAdapter> nmptr = boost::dynamic_pointer_cast<NoMetaStructureAdapter>(srcstructure); if (nmptr) srcstructure = nmptr->getSourceStructure(); msrcstructure = srcstructure.get() ? srcstructure : emptyStructureAdapter(); }
void setUp() { CxxTest::setAbortTestOnFail(true); if (!m_ni) { m_ni = loadTestPeriodicStructure("Ni.stru"); } m_nibnds = m_ni->createBondGenerator(); CxxTest::setAbortTestOnFail(false); }
void test_serialization() { StructureAdapterPtr stru1; stru1 = dumpandload(mstru); AtomicStructureAdapterPtr astru1 = boost::dynamic_pointer_cast<AtomicStructureAdapter>(stru1); TS_ASSERT(!astru1); TS_ASSERT_EQUALS(0, stru1->countSites()); TS_ASSERT_EQUALS(stru1, stru1->clone()); TS_ASSERT_THROWS(mstru->siteAtomType(0), std::out_of_range); }
void test_LiTaO3() { const string lithium = "Li1+"; const string tantalum = "Ta5+"; const string oxygen = "O2-"; const double epsu = 1e-5; StructureAdapterPtr stru = loadTestPeriodicStructure("LiTaO3.stru"); TS_ASSERT_EQUALS(30, stru->countSites()); BaseBondGeneratorPtr bnds = stru->createBondGenerator(); bnds->selectAnchorSite(0); bnds->selectSiteRange(0, 30); // there are 3 oxygen neighbors at 2.065 bnds->setRmax(2.1); TS_ASSERT_EQUALS(3, countBonds(*bnds)); // Li at site 0 is isotropic, oxygens have equal msd-s towards Li for (bnds->rewind(); !bnds->finished(); bnds->next()) { TS_ASSERT_EQUALS(lithium, stru->siteAtomType(bnds->site0())); TS_ASSERT_EQUALS(oxygen, stru->siteAtomType(bnds->site1())); TS_ASSERT_DELTA(0.00265968, testmsd0(stru, bnds), epsu); TS_ASSERT_DELTA(0.00710945, testmsd1(stru, bnds), epsu); } // there are 3 oxygen neighbors at 2.26 bnds->setRmin(2.2); bnds->setRmax(2.3); TS_ASSERT_EQUALS(3, countBonds(*bnds)); for (bnds->rewind(); !bnds->finished(); bnds->next()) { TS_ASSERT_EQUALS(oxygen, stru->siteAtomType(bnds->site1())); TS_ASSERT_DELTA(0.00265968, testmsd0(stru, bnds), epsu); TS_ASSERT_DELTA(0.00824319, testmsd1(stru, bnds), epsu); } // finally there are 4 Ta neighbors between 2.8 and 3.1 bnds->setRmin(2.8); bnds->setRmax(3.1); TS_ASSERT_EQUALS(4, countBonds(*bnds)); for (bnds->rewind(); !bnds->finished(); bnds->next()) { TS_ASSERT_DELTA(0.00265968, testmsd0(stru, bnds), epsu); TS_ASSERT_EQUALS(tantalum, stru->siteAtomType(bnds->site1())); R3::Vector r01xy = bnds->r01(); r01xy[2] = 0.0; // for the tantalum above Li the msd equals U33 if (R3::norm(r01xy) < 0.1) { TS_ASSERT_DELTA(0.00356, testmsd1(stru, bnds), epsu); } // other 3 tantalums are related by tripple axis and // have the same msd towards the central Li else { TS_ASSERT_DELTA(0.00486942, testmsd1(stru, bnds), epsu); } } }