Ignore:
Timestamp:
May 3, 2013, 9:46:45 AM (12 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, 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_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
a86666
Parents:
5281ff
git-author:
Frederik Heber <heber@…> (04/05/13 15:09:16)
git-committer:
Frederik Heber <heber@…> (05/03/13 09:46:45)
Message:

Split long-range calculations into two parts to overcome E-N-potential problems.

The general problem is that smeared-out nuclei charges cannot interact with
electron charge densities as they always overlap, hence we always make a large
error. The idea then is - as the potential energy is symmetric both
densities - to flip from N-E to E-N, i.\,e. to take the electron potential and
evaluate at nuclei positions instead of smeared-out nuclei charges with
eletronic charge distribution. However, then we need to make two calculations
for the four contributions: E-E, E-N and N-N, N-E (=E-N).

  • new enums SampleParticles_t eventually tells InterfaceVMGJob whether to sample the nuclei charges onto the grid or not.
  • TreatGrid_t tells InterfaceVMGJob whether to actually add the electronic charge onto the grid (this was added but is actually not required anymore).
  • FragmentationAutomationAction::performCall() now creates twice as many long-range jobs. This requires two variables in VMGData for storing integrated long-range energy: electron_long, nuclei_long, as both calculations are combined into a single VMGData instance per fragment.
  • Summation of long-range contributions is split into three instead of formerly two parts: electron (E-E), nuclei (N-N), and mixed (E-N). This allows to easierly check their cancellation. This needs new member in fusion map and name in printKeyNames.
  • naturally, the enums have to be passed a long way: VMGFragmentController, VMGJob, VMGData.
  • VMGData now has serialization version 1 due to new entry.
  • we enhanced documentation in FragmentationLongRangeResults::operator()() of how and what is summed per level.
  • FIX: InterfaceVMGJob::ImportRightHandSide() subtracted grid instead of adding it. Now, we set correct sign of electron charge distribution in MPQC.
  • TESTFIX: Regression test AnalyseFragmentResults now has short- and long-range part. Long-range part is only diff'ed when the compiled code has the capabilities.
Location:
src/Fragmentation/Summation/Containers
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/Fragmentation/Summation/Containers/FragmentationLongRangeResults.cpp

    r5281ff re2925fd  
    129129      boost::fusion::at_key<VMGDataFused::electron_longrange>(instance) = 0.;
    130130      boost::fusion::at_key<VMGDataFused::electron_shortrange>(instance) = 0.;
     131      boost::fusion::at_key<VMGDataFused::mixed_longrange>(instance) = 0.;
     132      boost::fusion::at_key<VMGDataFused::mixed_shortrange>(instance) = 0.;
    131133      boost::fusion::at_key<VMGDataFused::nuclei_longrange>(instance) = 0.;
    132134      boost::fusion::at_key<VMGDataFused::nuclei_shortrange>(instance) = 0.;
     
    136138    }
    137139    for (size_t level = 2; level <= MaxLevel; ++level) {
    138       // we have to fill in the remainder values in the LongRangeMap by hand
    139       // weight times correct charge density of the same level
     140      // We have calculated three different contributions: e-e, e-n+n-n, and n-n.
     141      // And we want to have e-e+e-n, n-n+n-e (where e-n = n-e).
     142      // For each of these three contributions we have a full solution and summed
     143      // up short range solutions.
     144
     145      // first we obtain the full e-e energy as potential times charge on the
     146      // respective level.
     147      // \note that sampled_potential starts at level 2 because we do not calculate
     148      // for level 1 as there saturated hydrogens are still present, leaving the
     149      // result to be nonsense.
    140150      const SamplingGrid &charge_weight =
    141151          boost::fusion::at_key<MPQCDataFused::sampled_grid>(Result_Grid_fused[level-1]);
    142152      SamplingGrid full_sample_solution = fullsolutionData[level-2].sampled_potential;
    143153      full_sample_solution *= charge_weight;
     154      double electron_solution_energy = full_sample_solution.integral();
     155
     156      // then we subtract the summed-up short-range e-e interaction energy from
     157      // the full solution.
    144158      const SamplingGrid &short_range_correction =
    145159          boost::fusion::at_key<VMGDataFused::sampled_potential>(Result_LongRange_fused[level-1]);
     160      double electron_short_range_energy = short_range_correction.integral();
    146161      full_sample_solution -= short_range_correction;
    147       double full_solution_energy = fullsolutionData[level-2].e_long;
    148       const double short_range_energy =
    149           boost::fusion::at_key<VMGDataFused::energy_long>(Result_LongRange_fused[level-1]);
    150       full_solution_energy -= short_range_energy;
    151 
    152       // multiply element-wise with charge distribution
     162      electron_solution_energy -= electron_short_range_energy;
     163      ASSERT( fabs(electron_solution_energy - full_sample_solution.integral()) < 1e-7,
     164          "FragmentationLongRangeResults::operator() - integral and energy are not exchangeable.");
     165
     166      // then, we obtain the e-n+n-n full solution in the same way
     167      double nuclei_solution_energy = fullsolutionData[level-2].nuclei_long;
     168      double nuclei_short_range_energy =
     169          boost::fusion::at_key<VMGDataFused::nuclei_long>(Result_LongRange_fused[level-1]);
     170      nuclei_solution_energy -= nuclei_short_range_energy;
     171
     172      // and also the e-n full solution
     173      double both_solution_energy = fullsolutionData[level-2].electron_long;
     174      double both_short_range_energy =
     175          boost::fusion::at_key<VMGDataFused::electron_long>(Result_LongRange_fused[level-1]);
     176      both_solution_energy -= both_short_range_energy;
     177
     178      // energies from interpolation at nuclei position has factor of 1/2 already
     179      electron_solution_energy *= .5;
     180      electron_short_range_energy *= .5;
     181
     182      // At last, we subtract e-n from n-n+e-n for full solution and short-range
     183      // correction.
     184      nuclei_solution_energy -= both_solution_energy;
     185      nuclei_short_range_energy -= both_short_range_energy;
     186
    153187      VMGDataLongRangeMap_t instance;
    154       boost::fusion::at_key<VMGDataFused::electron_longrange>(instance) = .5*full_sample_solution.integral();
     188      boost::fusion::at_key<VMGDataFused::electron_longrange>(instance) = electron_solution_energy;
    155189//      LOG(0, "Remaining long-range potential integral of level " << level << " is "
    156190//          << full_sample_solution.integral() << ".");
    157       boost::fusion::at_key<VMGDataFused::electron_shortrange>(instance) = .5*short_range_correction.integral();
     191      boost::fusion::at_key<VMGDataFused::electron_shortrange>(instance) = electron_short_range_energy;
    158192//      LOG(0, "Short-range correction potential integral of level " << level << " is "
    159193//          << short_range_correction.integral() << ".");
    160       boost::fusion::at_key<VMGDataFused::nuclei_longrange>(instance) = full_solution_energy;
     194      boost::fusion::at_key<VMGDataFused::mixed_longrange>(instance) = both_solution_energy;
    161195//      LOG(0, "Remaining long-range energy from potential integral of level " << level << " is "
    162196//          << full_solution_energy << ".");
    163       boost::fusion::at_key<VMGDataFused::nuclei_shortrange>(instance) = short_range_energy;
     197      boost::fusion::at_key<VMGDataFused::mixed_shortrange>(instance) = both_short_range_energy;
     198//      LOG(0, "Short-range correction energy from potential integral of level " << level << " is "
     199//          << short_range_energy << ".");
     200      boost::fusion::at_key<VMGDataFused::nuclei_longrange>(instance) = nuclei_solution_energy;
     201//      LOG(0, "Remaining long-range energy from potential integral of level " << level << " is "
     202//          << full_solution_energy << ".");
     203      boost::fusion::at_key<VMGDataFused::nuclei_shortrange>(instance) = nuclei_short_range_energy;
    164204//      LOG(0, "Short-range correction energy from potential integral of level " << level << " is "
    165205//          << short_range_energy << ".");
    166206      boost::fusion::at_key<VMGDataFused::total_longrange>(instance) =
    167           boost::fusion::at_key<VMGDataFused::electron_longrange>(instance) - full_solution_energy;
     207          boost::fusion::at_key<VMGDataFused::electron_longrange>(instance)
     208          + 2.*boost::fusion::at_key<VMGDataFused::mixed_longrange>(instance)
     209          + boost::fusion::at_key<VMGDataFused::nuclei_longrange>(instance);
    168210      boost::fusion::at_key<VMGDataFused::total_shortrange>(instance) =
    169           boost::fusion::at_key<VMGDataFused::electron_shortrange>(instance) - short_range_energy;
     211          boost::fusion::at_key<VMGDataFused::electron_shortrange>(instance)
     212          + 2.*boost::fusion::at_key<VMGDataFused::mixed_shortrange>(instance)
     213          + boost::fusion::at_key<VMGDataFused::nuclei_shortrange>(instance);
    170214      Result_LongRangeIntegrated_fused.push_back(instance);
    171215    }
  • src/Fragmentation/Summation/Containers/VMGData.cpp

    r5281ff re2925fd  
    4242VMGData::VMGData(const SamplingGridProperties &_props) :
    4343  sampled_potential(_props),
    44   e_long(0.)
     44  nuclei_long(0.),
     45  electron_long(0.)
    4546{}
    4647
     
    5051std::ostream & operator<<(std::ostream &ost, const VMGData &data)
    5152{
    52   ost << "Long-Range energy: " << data.e_long << std::endl;
     53  ost << "Nuclei long-Range energy: " << data.nuclei_long << std::endl;
     54  ost << "Electron long-Range energy: " << data.electron_long << std::endl;
    5355  return ost;
    5456}
  • src/Fragmentation/Summation/Containers/VMGData.hpp

    r5281ff re2925fd  
    4242  //!> sampled potential on the grid as output
    4343  SamplingGrid sampled_potential;
    44   //!> long-range contribution to energy
    45   double e_long;
     44  //!> nuclei long-range contribution to energy
     45  double nuclei_long;
     46  //!> electron long-range contribution to energy
     47  double electron_long;
    4648
    4749private:
     
    5254  {
    5355    ar & sampled_potential;
    54     ar & e_long;
     56    if (version > 0)
     57      ar & nuclei_long;
     58    ar & electron_long;
    5559  }
    5660};
     61
     62BOOST_CLASS_VERSION(VMGData, 1)
    5763
    5864std::ostream & operator<<(std::ostream &ost, const VMGData &data);
  • src/Fragmentation/Summation/Containers/VMGDataFused.hpp

    r5281ff re2925fd  
    2727  struct sampled_potential {};
    2828  struct energy_potential {};
    29   struct energy_long {};
     29  struct nuclei_long {};
     30  struct electron_long {};
    3031
    3132  // keys for longrange
     
    3536  struct nuclei_longrange {};
    3637  struct nuclei_shortrange {};
     38  struct mixed_longrange {};
     39  struct mixed_shortrange {};
    3740  struct total_longrange {};
    3841  struct total_shortrange {};
  • src/Fragmentation/Summation/Containers/VMGDataMap.hpp

    r5281ff re2925fd  
    3232    boost::fusion::pair<VMGDataFused::sampled_potential, SamplingGrid >,
    3333    boost::fusion::pair<VMGDataFused::energy_potential, double >,
    34     boost::fusion::pair<VMGDataFused::energy_long, double >
     34    boost::fusion::pair<VMGDataFused::nuclei_long, double >,
     35    boost::fusion::pair<VMGDataFused::electron_long, double >
    3536> VMGDataMap_t;
    3637
     
    3839    VMGDataFused::sampled_potential,
    3940    VMGDataFused::energy_potential,
    40     VMGDataFused::energy_long
     41    VMGDataFused::nuclei_long,
     42    VMGDataFused::electron_long
    4143> VMGDataVector_t;
    4244
     
    5153    boost::fusion::pair<VMGDataFused::electron_longrange, double >,
    5254    boost::fusion::pair<VMGDataFused::electron_shortrange, double >,
     55    boost::fusion::pair<VMGDataFused::mixed_longrange, double >,
     56    boost::fusion::pair<VMGDataFused::mixed_shortrange, double >,
    5357    boost::fusion::pair<VMGDataFused::nuclei_longrange, double >,
    5458    boost::fusion::pair<VMGDataFused::nuclei_shortrange, double >,
     
    6064    VMGDataFused::electron_longrange,
    6165    VMGDataFused::electron_shortrange,
     66    VMGDataFused::mixed_longrange,
     67    VMGDataFused::mixed_shortrange,
    6268    VMGDataFused::nuclei_longrange,
    6369    VMGDataFused::nuclei_shortrange,
  • src/Fragmentation/Summation/Containers/VMGData_printKeyNames.hpp

    r5281ff re2925fd  
    3636        (sampled_potential) \
    3737  (energy_potential) \
    38   (energy_long) \
     38  (nuclei_long) \
     39  (electron_long) \
    3940  (electron_longrange) \
    4041  (electron_shortrange) \
     42  (mixed_longrange) \
     43  (mixed_shortrange) \
    4144  (nuclei_longrange) \
    4245  (nuclei_shortrange) \
Note: See TracChangeset for help on using the changeset viewer.