Changeset ad6485


Ignore:
Timestamp:
Sep 30, 2016, 3:51:12 PM (9 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Add_FitFragmentPartialChargesAction, Fix_ChargeSampling_PBC, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ParseParticles_split_forward_backward_Actions
Children:
89c71f
Parents:
097535
git-author:
Frederik Heber <heber@…> (09/20/16 11:06:47)
git-committer:
Frederik Heber <heber@…> (09/30/16 15:51:12)
Message:

FIX: ASSERTs in SamplingGrid did not take numerical rounding into account.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Fragmentation/Summation/SetValues/SamplingGrid.cpp

    r097535 rad6485  
    5555#include "LinearAlgebra/Vector.hpp"
    5656
     57#define MYSAMPLINGGRIDEPSILON (1e2*std::numeric_limits<double>::epsilon())
     58
    5759// static instances
    5860const double SamplingGrid::zeroOffset[NDIM] = { 0., 0., 0. };
     
    313315  for (size_t index=0;index<NDIM;++index) {
    314316    begin_window[index] = getNearestLowerGridPoint(_begin_window[index], index);
    315     ASSERT( begin_window[index] >= begin[index],
     317    ASSERT( (begin_window[index] - begin[index]) > -MYSAMPLINGGRIDEPSILON,
    316318        "SamplingGrid::setWindowSize() - window starts earlier than domain on "
    317319        +toString(index)+"th component.");
    318320    end_window[index] = getNearestHigherGridPoint(_end_window[index], index);
    319     ASSERT( end_window[index] <= end[index],
     321    ASSERT( (end_window[index] - end[index]) < MYSAMPLINGGRIDEPSILON,
    320322        "SamplingGrid::setWindowSize() - window ends later than domain on "
    321323        +toString(index)+"th component.");
     
    350352  for(size_t index=0;index < NDIM; ++index) {
    351353    // check that we truly have to extend the window
    352     ASSERT ( begin_window[index] >= _begin_window[index],
     354    ASSERT ( (begin_window[index] - _begin_window[index]) > -MYSAMPLINGGRIDEPSILON,
    353355        "SamplingGrid::extendWindow() - component "+toString(index)+
    354356        " of window start is greater than old value.");
    355     ASSERT ( end_window[index] <= _end_window[index],
     357    ASSERT ( (end_window[index] - _end_window[index]) < MYSAMPLINGGRIDEPSILON,
    356358        "SamplingGrid::extendWindow() - component "+toString(index)+
    357359        " of window end is less than old value.");
    358360
    359361    // check that we are still less than domain
    360     ASSERT ( _begin_window[index] >= begin[index],
     362    ASSERT ( (_begin_window[index] - begin[index]) > -MYSAMPLINGGRIDEPSILON,
    361363        "SamplingGrid::extendWindow() - component "+toString(index)+
    362364        " of window start is less than domain start.");
    363     ASSERT ( _end_window[index] <= end[index],
     365    ASSERT ( (_end_window[index] - end[index]) < MYSAMPLINGGRIDEPSILON,
    364366        "SamplingGrid::extendWindow() - component "+toString(index)+
    365367        " of window end is greater than domain end.");
     
    388390  for(size_t index=0;index < NDIM; ++index) {
    389391    // check that we truly have to shrink the window
    390     ASSERT ( begin_window[index] <= _begin_window[index],
     392    ASSERT ( (begin_window[index] - _begin_window[index]) > -MYSAMPLINGGRIDEPSILON,
    391393        "SamplingGrid::shrinkWindow() - component "+toString(index)+
    392394        " of window start is less than old value.");
    393     ASSERT ( end_window[index] >= _end_window[index],
     395    ASSERT ( (end_window[index] - _end_window[index]) < MYSAMPLINGGRIDEPSILON,
    394396        "SamplingGrid::shrinkWindow() - component "+toString(index)+
    395397        " of window end is greater than old value.");
    396398
    397399    // check that we are still less than domain
    398     ASSERT ( _begin_window[index] >= begin[index],
     400    ASSERT ( (_begin_window[index] - begin[index]) > -MYSAMPLINGGRIDEPSILON,
    399401        "SamplingGrid::shrinkWindow() - component "+toString(index)+
    400402        " of window start is less than domain start.");
    401     ASSERT ( _end_window[index] <= end[index],
     403    ASSERT ( (_end_window[index] - end[index]) < MYSAMPLINGGRIDEPSILON,
    402404        "SamplingGrid::shrinkWindow() - component "+toString(index)+
    403405        " of window end is greater than domain end.");
     
    485487    }
    486488    // total is used as safe-guard against loss due to discrete conversion
    487     ASSERT( (_wend[index] - _wbegin[index]) == _wlength[index],
     489    ASSERT( fabs(_wend[index] - _wbegin[index] - _wlength[index]) < MYSAMPLINGGRIDEPSILON,
    488490        "SamplingGrid::getDiscreteWindowCopyIndices() - end - begin is not equal to length for "
    489491        +toString(index)+"th component.");
     
    573575#ifndef NDEBUG
    574576  for(size_t index=0;index<NDIM;++index) {
    575     ASSERT( smaller_wbegin[index] >= larger_wbegin[index],
     577    ASSERT( (smaller_wbegin[index] - larger_wbegin[index]) > -MYSAMPLINGGRIDEPSILON,
    576578        "SamplingGrid::addWindowOntoWindow() - given smaller window starts earlier than larger window in component "
    577579        +toString(index)+".");
    578     ASSERT( smaller_wend[index] <= larger_wend[index],
     580    ASSERT( (smaller_wend[index] - larger_wend[index]) < MYSAMPLINGGRIDEPSILON,
    579581        "SamplingGrid::addWindowOntoWindow() - given smaller window ends later than larger window in component "
    580582        +toString(index)+".");
Note: See TracChangeset for help on using the changeset viewer.