Ignore:
Timestamp:
Jul 20, 2017, 9:38:38 AM (8 years ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
ForceAnnealing_with_BondGraph_continued
Children:
6d7c73
Parents:
d3d964
git-author:
Frederik Heber <frederik.heber@…> (06/29/17 15:46:02)
git-committer:
Frederik Heber <frederik.heber@…> (07/20/17 09:38:38)
Message:

tempcommit: Added failing weights test case to BondVectors.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Dynamics/unittests/BondVectorsUnitTest.cpp

    rd3d964 rc9f4a0  
    6767  // failing asserts should be thrown
    6868  ASSERT_DO(Assert::Throw);
     69
     70  setVerbosity(4);
    6971
    7072  // create an atom
     
    258260  // calculate weights
    259261  BondVectors::weights_t weights = bv->getWeightsForAtomAtStep(*atoms[center], WorldTime::getTime());
    260   LOG(2, "DEBUG: triangle weights are " << weights);
     262  LOG(2, "DEBUG: Triangle weights are " << weights);
    261263  // check number of weights
    262264  CPPUNIT_ASSERT_EQUAL( weights.size(), (size_t)3 );
     
    265267  CPPUNIT_ASSERT( fabs(weight_sum - 2.) < 1e-10 );
    266268}
     269
     270/** Test whether calculating weights works on complex config
     271 *
     272 */
     273void BondVectorsTest::weights_complexTest()
     274{
     275  // gather atoms
     276  atomvector += atoms[center], atoms[left], atoms[right], atoms[top], atoms[topright], atoms [bottomright];
     277  // create bonds
     278  bondvector +=
     279      atoms[center]->addBond(atoms[left]),
     280      atoms[center]->addBond(atoms[right]),
     281      atoms[center]->addBond(atoms[top]),
     282      atoms[center]->addBond(atoms[topright]),
     283      atoms[center]->addBond(atoms[bottomright]);
     284  // prepare bondvectors
     285  bv->setFromAtomRange< std::vector<atom *> >(atomvector.begin(), atomvector.end(), WorldTime::getTime());
     286  // calculate weights
     287  BondVectors::weights_t weights = bv->getWeightsForAtomAtStep(*atoms[center], WorldTime::getTime());
     288  LOG(2, "DEBUG: Complex weights are " << weights);
     289  // check number of weights
     290  CPPUNIT_ASSERT_EQUAL( weights.size(), (size_t)5 );
     291  // check sum of weights: one linear independent, two dependent vectors = 1 + 2*0.5
     292  const double weight_sum = std::accumulate(weights.begin(), weights.end(), 0.);
     293  CPPUNIT_ASSERT( fabs(weight_sum - 2.) < 1e-10 );
     294}
Note: See TracChangeset for help on using the changeset viewer.