Changeset 6829d2 for src/Fragmentation
- Timestamp:
- Nov 4, 2016, 9:37:49 AM (8 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_StructOpt_integration_tests, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_ChronosMutex, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, GeometryObjects, Gui_displays_atomic_force_velocity, IndependentFragmentGrids_IntegrationTest, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, RotateToPrincipalAxisSystem_UndoRedo, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, ThirdParty_MPQC_rebuilt_buildsystem, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, Ubuntu_1604_changes, stable
- Children:
- 16c6f7
- Parents:
- 95304c
- git-author:
- Frederik Heber <heber@…> (10/02/16 13:24:41)
- git-committer:
- Frederik Heber <heber@…> (11/04/16 09:37:49)
- Location:
- src/Fragmentation
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Fragmentation/Homology/unittests/HomologyContainerUnitTest.cpp
r95304c r6829d2 93 93 Fragment::position_t pos(3, 0.); 94 94 Fragment::positions_t positions(1, pos); 95 Fragment::atomicnumbers_t atomicnumbers(1,1.); 95 96 Fragment::charges_t charges(1,1.); 96 Fragment dummy(positions, charges);97 Fragment dummy(positions, atomicnumbers, charges); 97 98 charges[0] = 6.; 98 99 positions[0][0] = 1.; 99 Fragment dummy1(positions, charges);100 Fragment dummy1(positions, atomicnumbers, charges); 100 101 positions[0][0] = 2.; 101 Fragment dummy2(positions, charges);102 Fragment dummy2(positions, atomicnumbers, charges); 102 103 HomologyContainer::value_t value1; 103 104 value1.fragment = dummy1; … … 133 134 Fragment::position_t pos(3, 0.); 134 135 Fragment::positions_t positions(1, pos); 136 Fragment::atomicnumbers_t atomicnumbers(1,1.); 135 137 Fragment::charges_t charges(1,1.); 136 Fragment dummy(positions, charges);138 Fragment dummy(positions, atomicnumbers, charges); 137 139 HomologyContainer::value_t value; 138 140 value.fragment = dummy; … … 158 160 Fragment::position_t pos(3, 0.); 159 161 Fragment::positions_t positions(1, pos); 162 Fragment::atomicnumbers_t atomicnumbers(1,1.); 160 163 Fragment::charges_t charges(1,1.); 161 Fragment dummy(positions, charges);164 Fragment dummy(positions, atomicnumbers, charges); 162 165 HomologyContainer::value_t value; 163 166 value.fragment = dummy; -
src/Fragmentation/Homology/unittests/stubs/FragmentStub.cpp
r95304c r6829d2 56 56 * 57 57 * @param _positions given positions 58 * @param _atomicnumbers given atomic numbers 58 59 * @param _charges given charges 59 60 */ 60 Fragment::Fragment(const positions_t &_positions, const charges_t &_charges) 61 Fragment::Fragment( 62 const positions_t &_positions, 63 const atomicnumbers_t &_atomicnumbers, 64 const charges_t &_charges) 61 65 {} 62 66 … … 94 98 Fragment::positions_t Fragment::getPositions() const 95 99 { return positions_t(); } 100 101 /** Getter for all stored atomic numbers. 102 * 103 * @return vector of atomic numbers 104 */ 105 Fragment::atomicnumbers_t Fragment::getAtomicNumbers() const 106 { return atomicnumbers_t(); } 96 107 97 108 /** Getter for all stored charges. -
src/Fragmentation/Summation/Containers/MPQCData.cpp
r95304c r6829d2 139 139 +toString(instance.sampled_grid.getWindowGridPoints())+" and was "+toString(window_gridpoints)); 140 140 instance.positions = other.positions; 141 instance.atomicnumbers = other.atomicnumbers; 141 142 instance.charges = other.charges; 142 143 instance.times = other.times; -
src/Fragmentation/Summation/Containers/MPQCData.hpp
r95304c r6829d2 110 110 SamplingGrid sampled_grid; 111 111 112 // nuclei positions and charges112 // nuclei positions, atomic numbers and charges 113 113 std::vector< std::vector<double> > positions; 114 std::vector< unsigned int > atomicnumbers; 114 115 std::vector<double> charges; 115 116 … … 161 162 ar & positions; 162 163 ar & charges; 164 if (version > 3) 165 ar & atomicnumbers; 163 166 ar & times.total_walltime; 164 167 ar & times.total_cputime; … … 174 177 }; 175 178 176 BOOST_CLASS_VERSION(MPQCData, 3)179 BOOST_CLASS_VERSION(MPQCData, 4) 177 180 178 181 std::ostream & operator<<(std::ostream &ost, const MPQCData &data); -
src/Fragmentation/Summation/Converter/DataConverter.hpp
r95304c r6829d2 175 175 MPQCDataFragmentMap_t instance; 176 176 boost::fusion::at_key<MPQCDataFused::fragment>(instance) = 177 Fragment(extractedData.positions, extractedData. charges);177 Fragment(extractedData.positions, extractedData.atomicnumbers, extractedData.charges); 178 178 MPQCData_Fragment_fused.insert( std::make_pair(dataiter->first, instance) ); 179 179 } -
src/Fragmentation/Summation/SetValues/Fragment.cpp
r95304c r6829d2 54 54 {} 55 55 56 Fragment::Fragment(const positions_t &_positions, const charges_t &_charges) 56 Fragment::Fragment( 57 const positions_t &_positions, 58 const atomicnumbers_t &_atomicnumbers, 59 const charges_t &_charges) 57 60 { 58 61 ASSERT( _positions.size() == _charges.size(), 59 62 "Fragment::Fragment() - given charges and positions don't match in size."); 60 63 positions_t::const_iterator piter = _positions.begin(); 64 atomicnumbers_t::const_iterator aiter = _atomicnumbers.begin(); 61 65 charges_t::const_iterator citer = _charges.begin(); 62 for (;piter != _positions.end(); ++piter, ++ citer)63 nuclei.push_back( make_pair( *piter, *citer) );66 for (;piter != _positions.end(); ++piter, ++aiter, ++citer) 67 nuclei.push_back( createNucleus(*piter, *aiter, *citer) ); 64 68 } 65 69 … … 121 125 } 122 126 127 Fragment::atomicnumbers_t Fragment::getAtomicNumbers() const 128 { 129 atomicnumbers_t positions; 130 for (nuclei_t::const_iterator iter = nuclei.begin(); 131 iter != nuclei.end(); ++iter) 132 positions.push_back(iter->second.first); 133 return positions; 134 } 135 123 136 Fragment::charges_t Fragment::getCharges() const 124 137 { … … 126 139 for (nuclei_t::const_iterator iter = nuclei.begin(); 127 140 iter != nuclei.end(); ++iter) 128 charges.push_back(iter->second );141 charges.push_back(iter->second.second); 129 142 return charges; 130 143 } 131 144 132 Fragment::nucleus_t Fragment::createNucleus(const position_t &position, const double charge) 133 { 134 return nucleus_t( make_pair( position, charge ) ); 145 Fragment::nucleus_t Fragment::createNucleus( 146 const position_t &position, 147 const atomicNumber_t &atomicnumber, 148 const double charge) 149 { 150 return nucleus_t( make_pair( position, std::make_pair(atomicnumber, charge) ) ); 135 151 } 136 152 … … 174 190 std::ostream & operator<<(std::ostream &ost, const Fragment::nucleus_t &n) 175 191 { 176 ost << n.first << " with charge " << n.second;192 ost << n.first << " with Z of " << n.second.first << " charge " << n.second.second; 177 193 return ost; 178 194 } … … 183 199 // check positions 184 200 status &= Fragment::isPositionEqual(a.first, b.first); 185 status &= fabs(a.second - b.second) < std::numeric_limits<double>::epsilon(); 201 status &= (a.second.first == b.second.first); 202 status &= fabs(a.second.second - b.second.second) < std::numeric_limits<double>::epsilon(); 186 203 return status; 187 204 } … … 190 207 { 191 208 Fragment::positions_t positions; 209 Fragment::atomicnumbers_t atomicnumbers; 192 210 Fragment::charges_t charges; 193 Fragment returnvalue(positions, charges);211 Fragment returnvalue(positions, atomicnumbers, charges); 194 212 return returnvalue; 195 213 } -
src/Fragmentation/Summation/SetValues/Fragment.hpp
r95304c r6829d2 34 34 typedef double charge_t; 35 35 typedef std::vector< charge_t > charges_t; 36 typedef std::pair< position_t, charge_t> nucleus_t; 36 typedef unsigned int atomicNumber_t; // typedef is copied 37 typedef std::vector< atomicNumber_t > atomicnumbers_t; 38 typedef std::pair< position_t, std::pair<atomicNumber_t, charge_t> > nucleus_t; 37 39 typedef std::vector< nucleus_t > nuclei_t; 38 40 … … 52 54 * 53 55 * @param _positions given positions 56 * @param _atomicnumbers given atomic numbers 54 57 * @param _charges given charges 55 58 */ 56 Fragment(const positions_t &_positions, const charges_t &_charges); 59 Fragment( 60 const positions_t &_positions, 61 const atomicnumbers_t &_atomicnumbers, 62 const charges_t &_charges); 57 63 58 64 /** Adding another fragment onto this one. … … 86 92 positions_t getPositions() const; 87 93 94 /** Getter for all stored atomic numbers. 95 * 96 * @return vector of atomic numbers 97 */ 98 atomicnumbers_t getAtomicNumbers() const; 99 88 100 /** Getter for all stored charges. 89 101 * … … 107 119 * 108 120 * @param position position of nucleus to create 121 * @param atomicnumber atomic number of nucleus to create 109 122 * @param charge charge of nucleus to create 110 123 * @return nucleus with given \a position and \a charge 111 124 */ 112 static nucleus_t createNucleus(const position_t &position, const double charge); 125 static nucleus_t createNucleus( 126 const position_t &position, 127 const atomicNumber_t &atomicnumber, 128 const double charge); 113 129 114 130 /** Helper function to check whether two positions are equal. -
src/Fragmentation/Summation/SetValues/unittests/FragmentUnitTest.cpp
r95304c r6829d2 81 81 pos[2] = 1.; 82 82 positions += pos; 83 atomicnumbers += 1, 2, 3, 4; 83 84 charges += 1., 2., 3., 4.; 84 85 CPPUNIT_ASSERT_EQUAL( (size_t)3, pos.size() ); 85 86 CPPUNIT_ASSERT( positions.size() == charges.size() ); 86 87 fragment = new Fragment(positions, charges); 87 CPPUNIT_ASSERT( atomicnumbers.size() == charges.size() ); 88 89 fragment = new Fragment(positions, atomicnumbers, charges); 88 90 } 89 91 … … 110 112 } 111 113 114 static Fragment::nuclei_t createNucleiFromTriple( 115 const Fragment::positions_t &_positions, 116 const Fragment::atomicnumbers_t &_atomicnumbers, 117 const Fragment::charges_t &_charges 118 ) 119 { 120 Fragment::nuclei_t returnnuclei; 121 Fragment::positions_t::const_iterator piter = _positions.begin(); 122 Fragment::atomicnumbers_t::const_iterator aiter = _atomicnumbers.begin(); 123 Fragment::charges_t::const_iterator citer = _charges.begin(); 124 for (;piter != _positions.end(); ++piter) 125 returnnuclei.push_back( Fragment::createNucleus(*piter, *aiter, *citer) ); 126 return returnnuclei; 127 } 112 128 113 129 /** UnitTest for containsNuclei() … … 117 133 { 118 134 // tests present ones for containment 119 Fragment::nuclei_t validnuclei(positions.size()); 120 std::transform(positions.begin(), positions.end(), 121 charges.begin(), validnuclei.begin(), Fragment::createNucleus); 135 Fragment::nuclei_t validnuclei( createNucleiFromTriple(positions, atomicnumbers, charges) ); 122 136 BOOST_FOREACH( Fragment::nucleus_t nucleus, validnuclei) { 123 137 CPPUNIT_ASSERT( fragment->containsNuclei(nucleus) ); … … 129 143 Fragment::nuclei_t invalidnuclei; 130 144 Fragment::position_t pos(3, -1.); 131 invalidnuclei += Fragment::createNucleus(pos, 1 .);145 invalidnuclei += Fragment::createNucleus(pos, 1, 1.); 132 146 pos[0] = 0.; 133 invalidnuclei += Fragment::createNucleus(pos, 1 .);147 invalidnuclei += Fragment::createNucleus(pos, 1, 1.); 134 148 pos[1] = 0.; 135 invalidnuclei += Fragment::createNucleus(pos, 1 .);149 invalidnuclei += Fragment::createNucleus(pos, 1, 1.); 136 150 pos[2] = -std::numeric_limits<double>::epsilon()*1e+4; 137 invalidnuclei += Fragment::createNucleus(pos, 1 .);151 invalidnuclei += Fragment::createNucleus(pos, 1, 1.); 138 152 BOOST_FOREACH( Fragment::nucleus_t nucleus, invalidnuclei) { 139 153 CPPUNIT_ASSERT( !fragment->containsNuclei(nucleus) ); … … 149 163 // tests present ones for removal 150 164 size_t size = fragment->nuclei.size(); 151 Fragment::nuclei_t validnuclei(positions.size()); 152 std::transform(positions.begin(), positions.end(), 153 charges.begin(), validnuclei.begin(), Fragment::createNucleus); 165 Fragment::nuclei_t validnuclei( createNucleiFromTriple(positions, atomicnumbers, charges) ); 154 166 BOOST_FOREACH( Fragment::nucleus_t nucleus, validnuclei) { 155 167 CPPUNIT_ASSERT_NO_THROW( fragment->removeNuclei(nucleus) ); … … 161 173 Fragment::nuclei_t invalidnuclei; 162 174 Fragment::position_t pos(3, -1.); 163 invalidnuclei += Fragment::createNucleus(pos, 1 .);175 invalidnuclei += Fragment::createNucleus(pos, 1, 1.); 164 176 pos[0] = 0; 165 invalidnuclei += Fragment::createNucleus(pos, 1 .);177 invalidnuclei += Fragment::createNucleus(pos, 1, 1.); 166 178 pos[1] = 0; 167 invalidnuclei += Fragment::createNucleus(pos, 1 .);179 invalidnuclei += Fragment::createNucleus(pos, 1, 1.); 168 180 pos[2] = -std::numeric_limits<double>::epsilon()*1e+4; 169 invalidnuclei += Fragment::createNucleus(pos, 1 .);181 invalidnuclei += Fragment::createNucleus(pos, 1, 1.); 170 182 BOOST_FOREACH( Fragment::nucleus_t nucleus, invalidnuclei) { 171 183 CPPUNIT_ASSERT_NO_THROW( fragment->removeNuclei(nucleus) ); … … 178 190 void FragmentTest::equalityNucleus_Test() 179 191 { 180 Fragment::nuclei_t validnuclei(positions.size()); 181 std::transform(positions.begin(), positions.end(), 182 charges.begin(), validnuclei.begin(), Fragment::createNucleus); 192 Fragment::nuclei_t validnuclei( createNucleiFromTriple(positions, atomicnumbers, charges) ); 183 193 { 184 194 // create some nuclei … … 191 201 // create nucleus at other position 192 202 Fragment::position_t pos(3, 2.); 193 Fragment::nucleus_t unequalposnucleus( pos, 1.);203 Fragment::nucleus_t unequalposnucleus( Fragment::createNucleus(pos, 1, 1.) ); 194 204 BOOST_FOREACH( Fragment::nucleus_t nucleus, validnuclei) { 195 205 CPPUNIT_ASSERT( nucleus != unequalposnucleus ); … … 200 210 // create nucleus with different charge 201 211 Fragment::position_t pos(3, 1.); 202 Fragment::nucleus_t unequalchargenucleus( pos, 5.);212 Fragment::nucleus_t unequalchargenucleus( Fragment::createNucleus(pos, 5, 5.) ); 203 213 BOOST_FOREACH( Fragment::nucleus_t nucleus, validnuclei) { 204 214 CPPUNIT_ASSERT( nucleus != unequalchargenucleus ); … … 219 229 otherpos[1] = 0.; 220 230 otherpositions += otherpos; 231 Fragment::atomicnumbers_t otheratomicnumbers; 232 otheratomicnumbers += 1, 2, 3; 221 233 Fragment::charges_t othercharges; 222 234 othercharges += 1., 2., 3.; 223 Fragment otherfragment(otherpositions, other charges);235 Fragment otherfragment(otherpositions, otheratomicnumbers, othercharges); 224 236 225 237 CPPUNIT_ASSERT( !(*fragment == otherfragment) ); … … 253 265 otherpos[1] = 0.; 254 266 otherpositions += otherpos; 267 Fragment::atomicnumbers_t otheratomicnumbers; 268 otheratomicnumbers += 1, 2, 3; 255 269 Fragment::charges_t othercharges; 256 270 othercharges += 1., 2., 3.; 257 Fragment otherfragment(otherpositions, other charges);271 Fragment otherfragment(otherpositions, otheratomicnumbers, othercharges); 258 272 259 273 // check for inequality … … 282 296 otherpos[1] = 0.; 283 297 otherpositions += otherpos; 298 Fragment::atomicnumbers_t otheratomicnumbers; 299 otheratomicnumbers += 1, 2, 3; 284 300 Fragment::charges_t othercharges; 285 301 othercharges += 1., 2., 3.; 286 Fragment otherfragment(otherpositions, other charges);302 Fragment otherfragment(otherpositions, otheratomicnumbers, othercharges); 287 303 const size_t othersize = otherfragment.nuclei.size(); 288 304 const size_t size = fragment->nuclei.size(); … … 292 308 { 293 309 // tests all for containment 294 Fragment::nuclei_t validnuclei(positions.size()+otherpositions.size()); 295 Fragment::nuclei_t::iterator iter = 296 std::transform(positions.begin(), positions.end(), 297 charges.begin(), validnuclei.begin(), Fragment::createNucleus); 298 std::transform(otherpositions.begin(), otherpositions.end(), 299 othercharges.begin(), iter, Fragment::createNucleus); 310 Fragment::nuclei_t validnuclei( createNucleiFromTriple(positions, atomicnumbers, charges) ); 311 Fragment::nuclei_t othervalidnuclei( createNucleiFromTriple(otherpositions, otheratomicnumbers, othercharges) ); 312 validnuclei.insert(validnuclei.end(), othervalidnuclei.begin(), othervalidnuclei.end()); 300 313 BOOST_FOREACH( Fragment::nucleus_t nucleus, validnuclei) { 301 314 CPPUNIT_ASSERT( fragment->containsNuclei(nucleus) ); … … 304 317 { 305 318 // tests positions for no containment in otherfragment 306 Fragment::nuclei_t invalidnuclei(positions.size()); 307 std::transform(positions.begin(), positions.end(), 308 charges.begin(), invalidnuclei.begin(), Fragment::createNucleus); 319 Fragment::nuclei_t invalidnuclei( createNucleiFromTriple(positions, atomicnumbers, charges) ); 309 320 BOOST_FOREACH( Fragment::nucleus_t nucleus, invalidnuclei) { 310 321 CPPUNIT_ASSERT( !otherfragment.containsNuclei(nucleus) ); … … 313 324 { 314 325 // tests otherpositions for containment in otherfragment 315 Fragment::nuclei_t validnuclei(otherpositions.size()); 316 std::transform(otherpositions.begin(), otherpositions.end(), 317 othercharges.begin(), validnuclei.begin(), Fragment::createNucleus); 326 Fragment::nuclei_t validnuclei( createNucleiFromTriple(otherpositions, otheratomicnumbers, othercharges) ); 318 327 BOOST_FOREACH( Fragment::nucleus_t nucleus, validnuclei) { 319 328 CPPUNIT_ASSERT( otherfragment.containsNuclei(nucleus) ); … … 336 345 otherpos[1] = 2.; 337 346 otherpositions += otherpos; 347 Fragment::atomicnumbers_t otheratomicnumbers; 348 otheratomicnumbers += 1, 2, 3; 338 349 Fragment::charges_t othercharges; 339 350 othercharges += 1., 2., 3.; 340 Fragment otherfragment(otherpositions, other charges);351 Fragment otherfragment(otherpositions, otheratomicnumbers, othercharges); 341 352 const size_t othersize = otherfragment.nuclei.size(); 342 353 const size_t size = fragment->nuclei.size(); … … 346 357 { 347 358 // tests all for containment 348 Fragment::nuclei_t validnuclei(positions.size()+otherpositions.size()); 349 Fragment::nuclei_t::iterator iter = 350 std::transform(positions.begin(), positions.end(), 351 charges.begin(), validnuclei.begin(), Fragment::createNucleus); 352 std::transform(otherpositions.begin(), otherpositions.end(), 353 othercharges.begin(), iter, Fragment::createNucleus); 359 Fragment::nuclei_t validnuclei( createNucleiFromTriple(positions, atomicnumbers, charges) ); 360 Fragment::nuclei_t othervalidnuclei( createNucleiFromTriple(otherpositions, otheratomicnumbers, othercharges) ); 361 validnuclei.insert(validnuclei.end(), othervalidnuclei.begin(), othervalidnuclei.end()); 354 362 BOOST_FOREACH( Fragment::nucleus_t nucleus, validnuclei) { 355 363 CPPUNIT_ASSERT( fragment->containsNuclei(nucleus) ); … … 358 366 { 359 367 // tests positions for no containment in otherfragment (but last) 360 Fragment::nuclei_t invalidnuclei(positions.size()-1); 361 std::transform(positions.begin(), --positions.end(), 362 charges.begin(), invalidnuclei.begin(), Fragment::createNucleus); 368 Fragment::positions_t lesspositions(positions.begin(), --positions.end()); 369 Fragment::atomicnumbers_t lessatomicnumbers(atomicnumbers.begin(), --atomicnumbers.end()); 370 Fragment::charges_t lesscharges(charges.begin(), --charges.end()); 371 Fragment::nuclei_t invalidnuclei( createNucleiFromTriple(lesspositions, lessatomicnumbers, lesscharges) ); 363 372 BOOST_FOREACH( Fragment::nucleus_t nucleus, invalidnuclei) { 364 373 CPPUNIT_ASSERT( !otherfragment.containsNuclei(nucleus) ); … … 367 376 { 368 377 // tests otherpositions for containment in otherfragment 369 Fragment::nuclei_t validnuclei(otherpositions.size()); 370 std::transform(otherpositions.begin(), otherpositions.end(), 371 othercharges.begin(), validnuclei.begin(), Fragment::createNucleus); 378 Fragment::nuclei_t validnuclei( createNucleiFromTriple(otherpositions, otheratomicnumbers, othercharges) ); 372 379 BOOST_FOREACH( Fragment::nucleus_t nucleus, validnuclei) { 373 380 CPPUNIT_ASSERT( otherfragment.containsNuclei(nucleus) ); … … 390 397 otherpos[1] = 0.; 391 398 otherpositions += otherpos; 399 Fragment::atomicnumbers_t otheratomicnumbers; 400 otheratomicnumbers += 1, 2, 3; 392 401 Fragment::charges_t othercharges; 393 402 othercharges += 1., 2., 3.; 394 Fragment otherfragment(otherpositions, other charges);403 Fragment otherfragment(otherpositions, otheratomicnumbers, othercharges); 395 404 const size_t othersize = otherfragment.nuclei.size(); 396 405 const size_t size = fragment->nuclei.size(); … … 400 409 { 401 410 // tests positions for containment 402 Fragment::nuclei_t validnuclei(positions.size()); 403 std::transform(positions.begin(), positions.end(), 404 charges.begin(), validnuclei.begin(), Fragment::createNucleus); 411 Fragment::nuclei_t validnuclei( createNucleiFromTriple(positions, atomicnumbers, charges) ); 405 412 BOOST_FOREACH( Fragment::nucleus_t nucleus, validnuclei) { 406 413 CPPUNIT_ASSERT( fragment->containsNuclei(nucleus) ); … … 409 416 { 410 417 // tests otherpositions for no containment 411 Fragment::nuclei_t invalidnuclei(otherpositions.size()); 412 std::transform(otherpositions.begin(), otherpositions.end(), 413 othercharges.begin(), invalidnuclei.begin(), Fragment::createNucleus); 418 Fragment::nuclei_t invalidnuclei( createNucleiFromTriple(otherpositions, otheratomicnumbers, othercharges) ); 414 419 BOOST_FOREACH( Fragment::nucleus_t nucleus, invalidnuclei) { 415 420 CPPUNIT_ASSERT( !fragment->containsNuclei(nucleus) ); … … 418 423 { 419 424 // tests positions for no containment in otherfragment 420 Fragment::nuclei_t invalidnuclei(positions.size()); 421 std::transform(positions.begin(), positions.end(), 422 charges.begin(), invalidnuclei.begin(), Fragment::createNucleus); 425 Fragment::nuclei_t invalidnuclei( createNucleiFromTriple(positions, atomicnumbers, charges) ); 423 426 BOOST_FOREACH( Fragment::nucleus_t nucleus, invalidnuclei) { 424 427 CPPUNIT_ASSERT( !otherfragment.containsNuclei(nucleus) ); … … 427 430 { 428 431 // tests otherpositions for containment in otherfragment 429 Fragment::nuclei_t validnuclei(otherpositions.size()); 430 std::transform(otherpositions.begin(), otherpositions.end(), 431 othercharges.begin(), validnuclei.begin(), Fragment::createNucleus); 432 Fragment::nuclei_t validnuclei( createNucleiFromTriple(otherpositions, otheratomicnumbers, othercharges) ); 432 433 BOOST_FOREACH( Fragment::nucleus_t nucleus, validnuclei) { 433 434 CPPUNIT_ASSERT( otherfragment.containsNuclei(nucleus) ); … … 450 451 otherpos[1] = 2.; 451 452 otherpositions += otherpos; 453 Fragment::atomicnumbers_t otheratomicnumbers; 454 otheratomicnumbers += 1, 2, 3; 452 455 Fragment::charges_t othercharges; 453 456 othercharges += 1., 2., 3.; 454 Fragment otherfragment(otherpositions, other charges);457 Fragment otherfragment(otherpositions, otheratomicnumbers, othercharges); 455 458 const size_t othersize = otherfragment.nuclei.size(); 456 459 const size_t size = fragment->nuclei.size(); … … 461 464 { 462 465 // tests all but last for containment 463 Fragment::nuclei_t validnuclei(positions.size()); 464 std::transform(positions.begin(), positions.end(), 465 charges.begin(), validnuclei.begin(), Fragment::createNucleus); 466 Fragment::nuclei_t validnuclei( createNucleiFromTriple(positions, atomicnumbers, charges) ); 466 467 BOOST_FOREACH( Fragment::nucleus_t nucleus, validnuclei) { 467 468 if (Fragment::isPositionEqual(nucleus.first, otherpositions[0])) // only test position … … 473 474 { 474 475 // tests positions for no containment in otherfragment 475 Fragment::nuclei_t invalidnuclei(positions.size()-1); 476 std::transform(positions.begin(), --positions.end(), 477 charges.begin(), invalidnuclei.begin(), Fragment::createNucleus); 476 Fragment::positions_t lesspositions(positions.begin(), --positions.end()); 477 Fragment::atomicnumbers_t lessatomicnumbers(atomicnumbers.begin(), --atomicnumbers.end()); 478 Fragment::charges_t lesscharges(charges.begin(), --charges.end()); 479 Fragment::nuclei_t invalidnuclei( createNucleiFromTriple(lesspositions, lessatomicnumbers, lesscharges) ); 478 480 BOOST_FOREACH( Fragment::nucleus_t nucleus, invalidnuclei) { 479 481 CPPUNIT_ASSERT( !otherfragment.containsNuclei(nucleus) ); … … 482 484 { 483 485 // tests otherpositions for containment in otherfragment 484 Fragment::nuclei_t validnuclei(otherpositions.size()); 485 std::transform(otherpositions.begin(), otherpositions.end(), 486 othercharges.begin(), validnuclei.begin(), Fragment::createNucleus); 486 Fragment::nuclei_t validnuclei( createNucleiFromTriple(otherpositions, otheratomicnumbers, othercharges) ); 487 487 BOOST_FOREACH( Fragment::nucleus_t nucleus, validnuclei) { 488 488 CPPUNIT_ASSERT( otherfragment.containsNuclei(nucleus) ); -
src/Fragmentation/Summation/SetValues/unittests/FragmentUnitTest.hpp
r95304c r6829d2 55 55 Fragment *fragment; 56 56 Fragment::positions_t positions; 57 Fragment::atomicnumbers_t atomicnumbers; 57 58 Fragment::charges_t charges; 58 59 };
Note:
See TracChangeset
for help on using the changeset viewer.