Changeset d56e21
- Timestamp:
- Sep 14, 2016, 6:42:53 PM (8 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_StructOpt_integration_tests, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, 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_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, 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, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, 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, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, Ubuntu_1604_changes, stable
- Children:
- 6a5eb2
- Parents:
- 91e7658
- git-author:
- Frederik Heber <heber@…> (05/26/16 15:36:26)
- git-committer:
- Frederik Heber <heber@…> (09/14/16 18:42:53)
- Location:
- src/Fragmentation/Summation/SetValues
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Fragmentation/Summation/SetValues/SamplingGrid.cpp
r91e7658 rd56e21 780 780 } 781 781 782 void SamplingGrid::padWithZerosForEvenNumberedSamples() 783 { 784 size_t wbegin_index[NDIM]; 785 size_t wend_index[NDIM]; 786 size_t wlength_index[NDIM]; 787 getDiscreteWindowIndices(wbegin_index, wlength_index, wend_index); 788 789 // calculate new window (always extend it such that both indices are even) 790 bool changed = false; 791 size_t wnewbegin_index[NDIM]; 792 size_t wnewend_index[NDIM]; 793 for(size_t i=0;i<NDIM;++i) { 794 // We require begin and end of window on even indices (and inside grid). 795 wnewbegin_index[i] = wbegin_index[i]; 796 if ((wnewbegin_index[i] % (size_t)2) != 0) { 797 if (wnewbegin_index[i] > 0) 798 --wnewbegin_index[i]; 799 else 800 wnewbegin_index[i] = 0; 801 changed = true; 802 } 803 wnewend_index[i] = wend_index[i]; 804 if ((wnewend_index[i] % (size_t)2) != 0) { 805 if (wnewend_index[i] < getGridPointsPerAxis()) 806 ++wnewend_index[i]; 807 else 808 wnewend_index[i] = getGridPointsPerAxis(); 809 changed = true; 810 } 811 ASSERT( (wbegin_index[i] >= 0) && (wend_index[i] <= getGridPointsPerAxis()), 812 "SamplingGrid::padWithZerosForEvenNumberedSamples() - indices " 813 +toString(wbegin_index[i])+" and "+toString(wend_index[i])+" larger than grid " 814 +toString(getGridPointsPerAxis())+"."); 815 } 816 if (changed) { 817 double begin_newwindow[NDIM]; 818 double end_newwindow[NDIM]; 819 for(size_t i=0;i<NDIM;++i) { 820 const double delta = getDeltaPerAxis(i); 821 begin_newwindow[i] = begin[i]+delta*wnewbegin_index[i]; 822 end_newwindow[i] = begin[i]+delta*wnewend_index[i]; 823 } 824 // extend window 825 extendWindow(begin_newwindow, end_newwindow); 826 } 827 ASSERT( getWindowGridPoints() % (size_t)8 == 0, 828 "SamplingGrid::padWithZerosForEvenNumberedSamples() - new size " 829 +toString(getWindowGridPoints())+" is still not divisible by 8."); 830 } 831 782 832 void SamplingGrid::downsample( 783 833 SamplingGrid& instance, -
src/Fragmentation/Summation/SetValues/SamplingGrid.hpp
r91e7658 rd56e21 289 289 290 290 private: 291 /** Extend the window such that the number of sample points stored is an 292 * even number per axis. This is used by downsample() 293 */ 294 void padWithZerosForEvenNumberedSamples(); 295 291 296 /** Sets the size of the domain. 292 297 * -
src/Fragmentation/Summation/SetValues/unittests/SamplingGridUnitTest.cpp
r91e7658 rd56e21 581 581 returnthreshold *= third_two; 582 582 return returnthreshold; 583 } 584 585 /** UnitTest for padWithZerosForEvenNumberedSamples() 586 * 587 */ 588 void SamplingGridTest::padWithZerosForEvenNumberedSamplesTest() 589 { 590 const double begin[NDIM] = { 0., 0., 0. }; 591 const double end[NDIM] = { 2., 2., 2. }; 592 593 // we check for window of odd numbers 594 { 595 // LOG(2, "Checking with difference " << grid_difference); 596 const int gridpoints = 1*2*2; 597 const int extended_gridpoints = 2*4*4; 598 SamplingGrid::sampledvalues_t values(gridpoints, 1.); // length in one axis is odd 599 SamplingGrid::sampledvalues_t checkvalues(extended_gridpoints, 0.); 600 { 601 int N[NDIM]; 602 int index = 0; 603 for (N[0]=2;N[0]<3;++N[0]) { 604 for (N[1]=0;N[1]<1;++N[1]) { 605 for (N[2]=0;N[2]<4;++N[2]) { 606 checkvalues[index++] = 0.; 607 } 608 } 609 for (N[1]=1;N[1]<3;++N[1]) { 610 checkvalues[index++] = 0.; 611 for (N[2]=1;N[2]<3;++N[2]) { 612 checkvalues[index++] = 1.; 613 } 614 checkvalues[index++] = 0.; 615 } 616 for (N[1]=3;N[1]<4;++N[1]) { 617 for (N[2]=0;N[2]<4;++N[2]) { 618 checkvalues[index++] = 0.; 619 } 620 } 621 } 622 for (N[0]=3;N[0]<4;++N[0]) { 623 for (N[1]=0;N[1]<4;++N[1]) { 624 for (N[2]=0;N[2]<4;++N[2]) { 625 checkvalues[index++] = 0.; 626 } 627 } 628 } 629 } 630 631 /** Here, we must initialize the larger grid with zero window first and 632 * then add the values into the smaller window. 633 */ 634 SamplingGrid grid(begin, end, 2); 635 const double window_begin[NDIM] = { 636 grid.getNearestHigherGridPoint(1.0, 0), // index 2 637 grid.getNearestHigherGridPoint(0.5, 1), // index 1 -> 0 638 grid.getNearestHigherGridPoint(0.5, 2) }; // index 1 -> 0 639 const double window_end[NDIM] = { 640 grid.getNearestLowerGridPoint(1.5, 0), // index 3 -> 4 641 grid.getNearestLowerGridPoint(1.5, 1), // index 3 -> 4 642 grid.getNearestLowerGridPoint(1.5, 2) }; // index 3 -> 4 643 grid.setWindow(window_begin, window_end); 644 grid.addOntoWindow(window_begin, window_end, values, +1.); 645 grid.padWithZerosForEvenNumberedSamples(); 646 647 SamplingGrid checkgrid(begin, end, 2); 648 const double check_window_begin[NDIM] = { 649 checkgrid.getNearestHigherGridPoint(1., 0), 650 checkgrid.getNearestHigherGridPoint(0., 1), 651 checkgrid.getNearestHigherGridPoint(0., 2) }; 652 const double check_window_end[NDIM] = { 653 checkgrid.getNearestHigherGridPoint(2., 0), 654 checkgrid.getNearestHigherGridPoint(2., 1), 655 checkgrid.getNearestHigherGridPoint(2., 2) }; 656 checkgrid.setWindow(check_window_begin, check_window_end); 657 checkgrid.addOntoWindow(check_window_begin, check_window_end, checkvalues, +1.); 658 659 std::cout << " grid value " << grid.sampled_grid << std::endl; 660 std::cout << " checkgrid value " << checkgrid.sampled_grid << std::endl; 661 CPPUNIT_ASSERT_EQUAL( checkgrid.sampled_grid.size(), grid.sampled_grid.size()); 662 CPPUNIT_ASSERT_EQUAL( checkgrid, grid ); 663 } 583 664 } 584 665 -
src/Fragmentation/Summation/SetValues/unittests/SamplingGridUnitTest.hpp
r91e7658 rd56e21 38 38 CPPUNIT_TEST ( equality_Test ); 39 39 CPPUNIT_TEST ( serializeTest ); 40 CPPUNIT_TEST ( padWithZerosForEvenNumberedSamplesTest ); 40 41 CPPUNIT_TEST ( downsample_gridTest ); 41 42 CPPUNIT_TEST ( downsample_smallerwindowTest ); … … 59 60 void equality_Test(); 60 61 void serializeTest(); 62 void padWithZerosForEvenNumberedSamplesTest(); 61 63 void downsample_gridTest(); 62 64 void downsample_smallerwindowTest();
Note:
See TracChangeset
for help on using the changeset viewer.