Changeset a8961d


Ignore:
Timestamp:
Jun 21, 2017, 8:01:27 AM (8 years ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
IndependentFragmentGrids_Sole_NN_Calculation
Parents:
3fb9ab
git-author:
Frederik Heber <heber@…> (08/19/16 05:27:39)
git-committer:
Frederik Heber <frederik.heber@…> (06/21/17 08:01:27)
Message:

Fixing long-range energy calculations and contribution summation.

  • we now calculate e-e+e-n and n-n separately. From the sampled_potential we recover e-e, and vmg delivers e-n. The second calculation yields n-n.
  • we need to sum forces from electronic contribution and from second run with nuclei contribution.
  • we need to sum the potentials for later fitting partial charges.
Location:
src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/FragmentationAction/AnalyseFragmentationResultsAction.cpp

    r3fb9ab ra8961d  
    392392      value.potential_distribution =
    393393          boost::fusion::at_key<VMGDataFused::both_sampled_potential>(potentialiter->second.second); // contributions
    394 //      // and re-average to zero (integral is times volume_element which we don't need here)
    395 //      const double sum =
    396 //          std::accumulate(
    397 //              value.potential_distribution.sampled_grid.begin(),
    398 //              value.potential_distribution.sampled_grid.end(),
    399 //              0.);
    400 //      const double offset = sum/(double)value.potential_distribution.sampled_grid.size();
    401 //      for (SamplingGrid::sampledvalues_t::iterator iter = value.potential_distribution.sampled_grid.begin();
    402 //          iter != value.potential_distribution.sampled_grid.end();
    403 //          ++iter)
    404 //        *iter -= offset;
     394      value.potential_distribution +=
     395          boost::fusion::at_key<VMGDataFused::sampled_potential>(potentialiter->second.second); // contributions
     396      // and re-average to zero (integral is times volume_element which we don't need here)
     397      const double sum =
     398          std::accumulate(
     399              value.potential_distribution.sampled_grid.begin(),
     400              value.potential_distribution.sampled_grid.end(),
     401              0.);
     402      const double offset = sum/(double)value.potential_distribution.sampled_grid.size();
     403      for (SamplingGrid::sampledvalues_t::iterator iter = value.potential_distribution.sampled_grid.begin();
     404          iter != value.potential_distribution.sampled_grid.end();
     405          ++iter)
     406        *iter -= offset;
    405407#else
    406408      ELOG(2, "Long-range information in homology desired but long-range analysis capability not compiled in.");
  • src/Actions/FragmentationAction/FragmentationAutomationAction.cpp

    r3fb9ab ra8961d  
    170170    )
    171171{
    172   ASSERT( _shortrangedata.size() == _longrangedata.size(),
    173       "calculateNucleiNucleiLongRangeContribution() - shortrange and longrange data have inequal size.");
     172  // we assume here that the fragmentjobs in short- and longrange case are in the
     173  // same order and that the full jobs per level are appended to the end of
     174  // longrangedata
    174175  std::map<JobId_t, VMGData>::iterator longrangeiter = _longrangedata.begin();
    175176  std::map<JobId_t, MPQCData>::const_iterator iter = _shortrangedata.begin();
     
    178179    VMGData &longrange_data = longrangeiter->second;
    179180    // set long-range contributions to zero
     181    const double old_energy = longrange_data.nuclei_long;
    180182    longrange_data.nuclei_long = 0.;
    181183    longrange_data.forces.clear();
    182     longrange_data.forces.resize(data.positions.size(), FragmentForces::force_t(3,0.));
     184    longrange_data.forces.resize(data.positions.size(), FragmentForces::force_t(NDIM,0.));
    183185    longrange_data.hasForces = true;
    184186    // go through positions and evaluate sum naively
     
    206208        const Vector otherposition((*otherpositer)[0], (*otherpositer)[1], (*otherpositer)[2]);
    207209        const Vector distance = position - otherposition;
    208         const double invsqrdist = 1./distance.Norm();
    209         const double factor = (*otherchargeiter)*invsqrdist*invsqrdist*invsqrdist;
     210        const double invdist = 1./distance.Norm();
     211        const double factor = (*otherchargeiter)*invdist*invdist*invdist;
    210212        (*forceiter)[0] = factor*distance[0];
    211213        (*forceiter)[1] = factor*distance[1];
    212214        (*forceiter)[2] = factor*distance[2];
    213         longrange_data.nuclei_long += 0.5*(*chargeiter)*(*otherchargeiter)*invsqrdist;
    214       }
    215     }
     215        longrange_data.nuclei_long += 0.5*(*chargeiter)*(*otherchargeiter)*invdist;
     216      }
     217    }
     218    LOG(2, "DEBUG: fragment #" << longrangeiter->first << ": old is " << old_energy
     219        << ", new is " << longrange_data.nuclei_long);
    216220  }
    217221}
     
    423427          interpolation_degree,
    424428          VMGFragmentController::DoSampleParticles,
    425           VMGFragmentController::DoTreatGrid,
     429          VMGFragmentController::DontTreatGrid,
    426430          params.DoValenceOnly.get() ? MPQCData::DoSampleValenceOnly : MPQCData::DontSampleValenceOnly,
    427431          params.DoPrintDebug.get(),
     
    468472        destiter->second.both_sampled_potential = srciter->second.sampled_potential;
    469473        destiter->second.nuclei_long = srciter->second.nuclei_long;
    470         destiter->second.forces = srciter->second.forces;
    471         destiter->second.hasForces = srciter->second.hasForces;
     474        destiter->second.forces += srciter->second.forces;
     475        destiter->second.hasForces &= srciter->second.hasForces;
    472476      }
    473477    }
  • src/Fragmentation/Summation/Containers/FragmentationLongRangeResults.cpp

    r3fb9ab ra8961d  
    121121        Result_perIndexSet_Grid);
    122122
    123     // multiply each short-range potential with the respective charge
     123    // multiply each short-range e-e potential with the respective charge
    124124    std::map<JobId_t,MPQCData>::const_iterator mpqciter = fragmentData.begin();
    125125    std::map<JobId_t,VMGData>::iterator vmgiter = longrangeData.begin();
     
    214214#endif
    215215
    216       // then, we obtain the e-n+n-n full solution in the same way
     216      // then, we obtain the n-n full solution directly
    217217      double nuclei_solution_energy = fullsolutionData[level-1].nuclei_long;
    218218      double nuclei_short_range_energy =
     
    229229      electron_solution_energy *= .5;
    230230      electron_short_range_energy *= .5;
    231 
    232       // At last, we subtract e-n from n-n+e-n for full solution and short-range
    233       // correction.
    234       nuclei_solution_energy -= both_solution_energy;
    235       nuclei_short_range_energy -= both_short_range_energy;
    236231
    237232      VMGDataLongRangeMap_t instance;
  • src/Jobs/InterfaceVMGJob.cpp

    r3fb9ab ra8961d  
    116116
    117117  Grid& grid = multigrid(multigrid.MaxLevel());
    118   grid.Clear();
    119   //grid.ClearBoundary(); // we don't have a boundary under periodic boundary conditions
     118//  grid.Clear();
     119//  grid.ClearBoundary(); // we don't have a boundary under periodic boundary conditions
    120120
    121121  // print debugging info on grid size
     
    393393  comm.PrintOnce(Debug, "E_total*:       %e", e_long + e_short_peak + e_short_spline - e_self);
    394394
    395   returndata.nuclei_long = e_long;
    396   returndata.electron_long = e_long;
     395  returndata.nuclei_long = e;   // nuclei needs self-energy subtracted, ...
     396  returndata.electron_long = e_long;  // charge grid gets only long-range interaction
    397397
    398398  // calculate residual
Note: See TracChangeset for help on using the changeset viewer.