Ignore:
Timestamp:
Nov 21, 2012, 10:03:23 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:
c74fdb
Parents:
94d530f
git-author:
Frederik Heber <heber@…> (08/08/12 13:17:44)
git-committer:
Frederik Heber <heber@…> (11/21/12 10:03:23)
Message:

Created new function sumUpChargeDensity() that just sums up the grid.

  • this is mostly just taken from printReceivedMPQCResults().
File:
1 edited

Legend:

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

    r94d530f r849cd8  
    6565#include "Jobs/MPQCData.hpp"
    6666#include "Jobs/MPQCData_printKeyNames.hpp"
     67#include "Jobs/Grid/SamplingGrid.hpp"
    6768#include "LinearAlgebra/RealSpaceMatrix.hpp"
    6869#ifdef HAVE_VMG
     
    428429 * @param KeySetFilename filename with keysets to associate forces correctly
    429430 * @param NoAtoms total number of atoms
     431 * @param full_sample summed up charge from fragments on return
     432 */
     433bool sumUpChargeDensity(
     434    const std::vector<FragmentResult::ptr> &results,
     435    const std::vector<MPQCData> &fragmentData,
     436    const std::string &KeySetFilename,
     437    SamplingGrid &full_sample)
     438{
     439  // create lookup from job nr to fragment number
     440  std::map< JobId_t, size_t > MatrixNrLookup;
     441  size_t FragmentCounter = 0;
     442  createMatrixNrLookup(results, MatrixNrLookup, FragmentCounter);
     443
     444  // initialise keysets
     445  KeySetsContainer KeySet;
     446  {
     447    // else needs keysets without hydrogens
     448    std::stringstream filename;
     449    filename << FRAGMENTPREFIX << KEYSETFILE;
     450    if (!KeySet.ParseKeySets(KeySetFilename, filename.str(), FragmentCounter)) return false;
     451  }
     452
     453  /// prepare for OrthogonalSummation
     454
     455  // convert KeySetContainer to IndexSetContainer
     456  IndexSetContainer::ptr container(new IndexSetContainer(KeySet));
     457  // create the map of all keysets
     458  SubsetMap::ptr subsetmap(new SubsetMap(*container));
     459
     460  // create a vector of all job ids
     461  std::vector<JobId_t> jobids(results.size(), JobId::IllegalJob);
     462  std::transform(results.begin(), results.end(), jobids.begin(),
     463      boost::bind(&FragmentResult::getId,
     464          boost::bind(&FragmentResult::ptr::operator->, _1)));
     465
     466  /// convert all MPQCData to MPQCDataMap_t
     467  std::vector<MPQCDataGridMap_t> Result_Grid_fused(
     468    SumUpPerLevel<MPQCDataGridMap_t, MPQCDataGridVector_t>(
     469        fragmentData, jobids, MatrixNrLookup, container, subsetmap));
     470  // obtain full grid
     471  full_sample = boost::fusion::at_key<MPQCDataFused::sampled_grid>(Result_Grid_fused.back());
     472
     473  return true;
     474}
     475
     476
     477/** Print MPQCData from received results.
     478 *
     479 * @param results results with ids to associate with fragment number
     480 * @param fragmentData MPQCData resulting from the jobs
     481 * @param KeySetFilename filename with keysets to associate forces correctly
     482 * @param NoAtoms total number of atoms
     483 * @param full_sample summed up charge from fragments on return
    430484 */
    431485bool printReceivedMPQCResults(
     
    433487    const std::vector<MPQCData> &fragmentData,
    434488    const std::string &KeySetFilename,
    435     size_t NoAtoms)
     489    size_t NoAtoms,
     490    SamplingGrid &full_sample)
    436491{
    437492  // create lookup from job nr to fragment number
     
    507562                Result_Force_fused);
    508563    boost::mpl::for_each<MPQCDataForceVector_t>(boost::ref(forceSummer));
     564
     565    // obtain full grid
     566    full_sample = boost::fusion::at_key<MPQCDataFused::sampled_grid>(Result_Grid_fused.back());
    509567
    510568    // print tables (without eigenvalues, they go extra)
     
    614672    FragmentController &controller,
    615673    const FragmentationFragmentationAutomationAction::FragmentationFragmentationAutomationParameters &params,
    616     const std::vector<MPQCData> &fragmentData)
     674    const std::vector<MPQCData> &fragmentData,
     675    const SamplingGrid &full_sampled_grid)
    617676{
    618677  std::vector<FragmentJob::ptr> jobs;
     
    629688  }
    630689
    631   // add one more job for the full calculation
    632   // TODO: Here, we actually have to combine all the other sampled_grids
    633690  {
    634     const int level = LEVEL;
    635     const int GRID = pow(2, level);
    636     std::vector<double> full_sample(GRID*GRID*GRID, 0.);
    637     double begin[NDIM] = { 0., 0., 0. };
    638     const RealSpaceMatrix& M = World::getInstance().getDomain().getM();
    639     const double size = M.at(0,0);
    640     ASSERT( M.determinant() == size*size*size,
    641         "createLongRangeJobs() - current domain matrix "+toString(M)+" is not cubic.");
    642     const SamplingGrid full_sampled_grid(begin, size, level, full_sample);
     691//    const int level = LEVEL;
     692//    const int GRID = pow(2, level);
     693//    double begin[NDIM] = { 0., 0., 0. };
     694//    const RealSpaceMatrix& M = World::getInstance().getDomain().getM();
     695//    const double size = M.at(0,0);
     696//    ASSERT( M.determinant() == size*size*size,
     697//        "createLongRangeJobs() - current domain matrix "+toString(M)+" is not cubic.");
    643698    const std::vector< std::vector<double> > positions;
    644699    const std::vector<double> charges;
    645700    const JobId_t next_id = controller.getAvailableId();
    646     LOG(1, "INFO: Creating full VMGJob with " << full_sample.size()
     701    LOG(1, "INFO: Creating full VMGJob with " << full_sampled_grid.sampled_grid.size()
    647702        << " gridpoints and " << charges.size() << " particle charges.");
    648703    FragmentJob::ptr testJob(
     
    706761  ConvertFragmentResultToMPQCData(MPQCresults, fragmentData);
    707762
    708   // print intermediate short-range results
    709   {
    710     LOG(1, "INFO: Parsing fragment files from " << params.path.get() << ".");
    711     printReceivedMPQCResults(
    712         MPQCresults,
    713         fragmentData,
    714         params.path.get(),
    715         getNoAtomsFromAdjacencyFile(params.path.get()));
    716   }
    717 
    718763#ifdef HAVE_VMG
    719764  if (params.DoLongrange.get()) {
     765  // obtain combined charge density
     766  LOG(1, "INFO: Parsing fragment files from " << params.path.get() << ".");
     767  SamplingGrid full_sample;
     768  sumUpChargeDensity(
     769      MPQCresults,
     770      fragmentData,
     771      params.path.get(),
     772      full_sample);
     773
    720774  // Phase Four: obtain more ids
    721775  requestIds(controller, params, fragmentData.size()+1);
     
    723777
    724778  // Phase Five: create VMGJobs
    725   if (!createLongRangeJobs(controller, params, fragmentData))
     779  if (!createLongRangeJobs(controller, params, fragmentData, full_sample))
    726780    return Action::failure;
    727781  RunService(io_service, "Adding VMGJobs");
     
    742796        fragmentData,
    743797        params.path.get(),
    744         getNoAtomsFromAdjacencyFile(params.path.get()));
     798        getNoAtomsFromAdjacencyFile(params.path.get()),
     799        full_sample);
    745800  }
    746801  }
Note: See TracChangeset for help on using the changeset viewer.