Changeset 7b4e67


Ignore:
Timestamp:
Apr 10, 2018, 6:43:30 AM (7 years ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
AutomationFragmentation_failures, Candidate_v1.6.1, ChemicalSpaceEvaluator, Exclude_Hydrogens_annealWithBondGraph, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_contraction-expansion, Gui_displays_atomic_force_velocity, PythonUI_with_named_parameters, StoppableMakroAction, TremoloParser_IncreasedPrecision
Children:
f433ec
Parents:
c1c6cb
git-author:
Frederik Heber <frederik.heber@…> (06/29/17 15:46:02)
git-committer:
Frederik Heber <frederik.heber@…> (04/10/18 06:43:30)
Message:

Added failing weights test case to BondVectors.

Location:
src/Dynamics/unittests
Files:
3 edited

Legend:

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

    rc1c6cb r7b4e67  
    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}
  • src/Dynamics/unittests/BondVectorsUnitTest.hpp

    rc1c6cb r7b4e67  
    3535    CPPUNIT_TEST ( weights_rightangleTest );
    3636    CPPUNIT_TEST ( weights_triangleTest );
     37    CPPUNIT_TEST ( weights_complexTest );
    3738    CPPUNIT_TEST_SUITE_END();
    3839
     
    4546      void weights_rightangleTest();
    4647      void weights_triangleTest();
     48      void weights_complexTest();
    4749
    4850private:
  • src/Dynamics/unittests/Makefile.am

    rc1c6cb r7b4e67  
    1010DYNAMICSTESTS = \
    1111  BondVectorsUnitTest
     12
     13XFAIL_TESTS += BondVectorsUnitTest
    1214 
    1315TESTS += $(DYNAMICSTESTS)
Note: See TracChangeset for help on using the changeset viewer.