Ignore:
Timestamp:
Sep 14, 2016, 6:42:53 PM (8 years ago)
Author:
Frederik Heber <heber@…>
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)
Message:

Added padWithZerosForEvenNumberedSamples(), required by downsample().

  • added unit test function.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Fragmentation/Summation/SetValues/unittests/SamplingGridUnitTest.cpp

    r91e7658 rd56e21  
    581581      returnthreshold *= third_two;
    582582  return returnthreshold;
     583}
     584
     585/** UnitTest for padWithZerosForEvenNumberedSamples()
     586 *
     587 */
     588void 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  }
    583664}
    584665
Note: See TracChangeset for help on using the changeset viewer.