Ignore:
Timestamp:
Dec 10, 2012, 10:10:57 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:
447481
Parents:
238868
git-author:
Frederik Heber <heber@…> (08/31/12 12:31:11)
git-committer:
Frederik Heber <heber@…> (12/10/12 10:10:57)
Message:

We now create one full potential VMGJob of each summed up grid per level.

  • i.e. we now have a vector of full_sample and full_sample_solution.
  • new fusion map VMGLongRangeMap_t and VMGLongRangeVector to print the summed up grids via writeTable<>.
File:
1 edited

Legend:

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

    r238868 ra2295a  
    247247    const std::map<JobId_t,MPQCData> &fragmentData,
    248248    const std::string &KeySetFilename,
    249     SamplingGrid &full_sample,
     249    std::vector<SamplingGrid> &full_sample,
    250250    Fragment &full_fragment)
    251251{
     
    286286        fragmentData, MatrixNrLookup, container, subsetmap));
    287287  // obtain full grid
    288   full_sample = boost::fusion::at_key<MPQCDataFused::sampled_grid>(Result_Grid_fused.back());
     288  full_sample.clear();
     289  full_sample.reserve(Result_Grid_fused.size());
     290  for (std::vector<MPQCDataGridMap_t>::const_iterator iter = ++Result_Grid_fused.begin();
     291      iter !=Result_Grid_fused.end();
     292      ++iter)
     293    full_sample.push_back(boost::fusion::at_key<MPQCDataFused::sampled_grid>((*iter)));
    289294  full_fragment = boost::fusion::at_key<MPQCDataFused::fragment>(Result_Fragment_fused.back());
    290295
     
    459464 * @param fragmentData MPQCData resulting from the jobs
    460465 * @param longrangeData VMGData resulting from long-range jobs
    461  * @param fullsolutionData VMGData resulting from long-range of full problem
     466 * @param fullsolutionData VMGData resulting from long-range of full problem from level 2 onward
    462467 * @param KeySetFilename filename with keysets to associate forces correctly
    463468 * @param NoAtoms total number of atoms
     
    467472    const std::map<JobId_t,MPQCData> &fragmentData,
    468473    const std::map<JobId_t,VMGData> &longrangeData,
    469     const VMGData &fullsolutionData,
     474    const std::vector<VMGData> &fullsolutionData,
    470475    const std::string &KeySetFilename,
    471476    size_t NoAtoms,
    472     SamplingGrid &full_sample)
     477    std::vector<SamplingGrid> &full_sample)
    473478{
    474479  // create lookup from job nr to fragment number
     
    550555                VMGMatrixNrLookup);
    551556    epotentialSummer(subsetmap->getMaximumSubsetLevel());
    552     SamplingGrid full_sample_solution = fullsolutionData.sampled_potential;
    553 //    LOG(0, "Remaining long-range energy from energy_potential is " << full_sample_solution.integral()-epotentialSummer.getFullContribution() << ".");
    554     full_sample_solution -= potentialSummer.getFullContribution();
    555     // multiply element-wise with charge distribution
    556     LOG(0, "Remaining long-range potential integral is " << full_sample_solution.integral() << ".");
    557     full_sample_solution *= full_sample;
    558     LOG(0, "Remaining long-range energy from potential integral is " << full_sample_solution.integral() << ".");
     557
     558    std::vector<VMGDataLongRangeMap_t> Result_LongRange_fused;
     559    Result_LongRange_fused.reserve(subsetmap->getMaximumSubsetLevel());
     560    for (size_t level = 1; level <= subsetmap->getMaximumSubsetLevel(); ++level) {
     561      // weight times correct charge density of the same level
     562      // NOTE: potential for level 1 is not calculated as saturation hydrogen
     563      // are not removed on this level yet
     564      const size_t potentiallevel = level < 2 ? 0 : (level-2);
     565      SamplingGrid charge_weight = boost::fusion::at_key<MPQCDataFused::sampled_grid>(Result_Grid_fused[level-1]);
     566      SamplingGrid full_sample_solution = fullsolutionData[potentiallevel].sampled_potential;
     567      SamplingGrid short_range_correction = potentialSummer(level);
     568  //    LOG(0, "Remaining long-range energy from energy_potential is " << full_sample_solution.integral()-epotentialSummer.getFullContribution() << ".");
     569      full_sample_solution -= short_range_correction;
     570      // multiply element-wise with charge distribution
     571      VMGDataLongRangeMap_t instance;
     572      boost::fusion::at_key<VMGDataFused::potential_longrange>(instance) = full_sample_solution.integral();
     573      LOG(0, "Remaining long-range potential integral of level " << level << " is "
     574          << full_sample_solution.integral() << ".");
     575      boost::fusion::at_key<VMGDataFused::potential_shortrange>(instance) = short_range_correction.integral();
     576      LOG(0, "Short-range correction potential integral of level " << level << " is "
     577          << short_range_correction.integral() << ".");
     578      boost::fusion::at_key<VMGDataFused::energy_longrange>(instance) = full_sample_solution.integral(charge_weight);
     579      LOG(0, "Remaining long-range energy from potential integral of level " << level << " is "
     580          << full_sample_solution.integral(charge_weight) << ".");
     581      boost::fusion::at_key<VMGDataFused::energy_shortrange>(instance) = short_range_correction.integral(charge_weight);
     582      LOG(0, "Short-range correction energy from potential integral of level " << level << " is "
     583          << short_range_correction.integral(charge_weight) << ".");
     584      Result_LongRange_fused.push_back(instance);
     585    }
     586    {
     587      //    LOG(0, "Remaining long-range energy from energy_potential is " << full_sample_solution.integral()-epotentialSummer.getFullContribution() << ".");
     588      SamplingGrid full_sample_solution = fullsolutionData.back().sampled_potential;
     589      SamplingGrid short_range_correction = potentialSummer.getFullContribution();
     590      full_sample_solution -= short_range_correction;
     591      // multiply element-wise with charge distribution
     592      LOG(0, "Remaining long-range potential integral is " << full_sample_solution.integral() << ".");
     593      LOG(0, "Short-range correction potential integral of level is " << short_range_correction.integral() << ".");
     594      LOG(0, "Remaining long-range energy from potential integral is "
     595          << full_sample_solution.integral(full_sample.back()) << ".");
     596      LOG(0, "Short-range correction energy from potential integral is "
     597          << short_range_correction.integral(full_sample.back()) << ".");
     598    }
    559599
    560600    // TODO: Extract long-range corrections to forces
     
    567607                VMGMatrixNrLookup);
    568608    elongSummer(subsetmap->getMaximumSubsetLevel());
    569     double e_long = fullsolutionData.e_long;
     609    double e_long = fullsolutionData.back().e_long;
    570610    e_long -= elongSummer.getFullContribution();
    571611    LOG(0, "Remaining long-range energy is " << e_long << ".");
     
    577617            Result_Energy_fused, MaxLevel);
    578618    LOG(0, "Energy table is \n" << energyresult);
     619
     620    const std::string gridresult =
     621        writeTable<VMGDataLongRangeMap_t, VMGDataLongRangeVector_t >()(
     622            Result_LongRange_fused, MaxLevel);
     623    LOG(0, "LongRange table is \n" << gridresult);
     624
    579625    const std::string eigenvalueresult;
    580 
    581626    LOG(0, "Eigenvalue table is \n" << eigenvalueresult);
     627
    582628    const std::string forceresult =
    583629        writeTable<MPQCDataForceMap_t, MPQCDataForceVector_t>()(
     
    635681  // obtain combined charge density
    636682  LOG(1, "INFO: Parsing fragment files from " << params.path.get() << ".");
    637   SamplingGrid full_sample;
     683  std::vector<SamplingGrid> full_sample; // have charges from level 2 onward summed up
    638684  Fragment full_fragment;
    639685  sumUpChargeDensity(
     
    644690
    645691  // Phase Four: obtain more ids
    646   vmgcontroller.requestIds(fragmentData.size()+1);
     692  vmgcontroller.requestIds(fragmentData.size()+full_sample.size());
    647693
    648694  // Phase Five: create VMGJobs
     
    652698
    653699  // Phase Six: calculate result
    654   vmgcontroller.waitforResults(fragmentData.size()+1);
     700  vmgcontroller.waitforResults(fragmentData.size()+full_sample.size());
    655701  std::map<JobId_t, VMGData> longrangeData;
    656702  vmgcontroller.getResults(longrangeData);
    657   ASSERT( fragmentData.size()+1 == longrangeData.size(),
    658       "FragmentationFragmentationAutomationAction::performCall() - number of MPQCresults+1 "
    659       +toString(fragmentData.size()+1)+" and VMGresults "+toString(longrangeData.size())+" don't match.");
    660 
    661   // remove full solution from map (must be highest id), has to be treated extra
    662   VMGData fullsolutionData = (--longrangeData.end())->second;
    663   longrangeData.erase(--longrangeData.end());
     703  ASSERT( fragmentData.size()+full_sample.size() == longrangeData.size(),
     704      "FragmentationFragmentationAutomationAction::performCall() - number of MPQCresults+"
     705      +toString(full_sample.size())+" "+toString(fragmentData.size()+full_sample.size())
     706      +" and VMGresults "+toString(longrangeData.size())+" don't match.");
     707
     708  // remove full solution corresponding to full_sample from map (must be highest ids), has to be treated extra
     709  std::map<JobId_t, VMGData>::iterator iter = longrangeData.end();
     710  for (size_t i=0;i<full_sample.size();++i)
     711    --iter;
     712  std::map<JobId_t, VMGData>::iterator remove_iter = iter;
     713  std::vector<VMGData> fullsolutionData;
     714  for (; iter != longrangeData.end(); ++iter)
     715    fullsolutionData.push_back(iter->second);
     716  longrangeData.erase(remove_iter, longrangeData.end());
    664717
    665718  // Final phase: print result
     
    674727        full_sample);
    675728
    676     // create debug jobs to print the summed-up potential to vtk files
    677     debugcontroller.requestIds(1);
    678     if (!debugcontroller.createDebugJobs(std::vector<SamplingGrid>(1,full_sample)))
    679       return Action::failure;
    680     debugcontroller.waitforResults(1);
    681     std::map<JobId_t, std::string> debugData;
    682     debugcontroller.getResults(debugData);
     729    if (!full_sample.empty()) {
     730      // create debug jobs to print the summed-up potential to vtk files
     731      debugcontroller.requestIds(full_sample.size());
     732      if (!debugcontroller.createDebugJobs(full_sample))
     733        return Action::failure;
     734      debugcontroller.waitforResults(full_sample.size());
     735      std::map<JobId_t, std::string> debugData;
     736      debugcontroller.getResults(debugData);
     737    }
    683738  }
    684739  }
Note: See TracChangeset for help on using the changeset viewer.