Changeset cd77fc


Ignore:
Timestamp:
Nov 15, 2012, 3:12:54 PM (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:
fb69e9
Parents:
092be05
git-author:
Frederik Heber <heber@…> (07/26/12 10:17:56)
git-committer:
Frederik Heber <heber@…> (11/15/12 15:12:54)
Message:

Positions and charges of nuclei are also contained in MPQCData and used by VMGJob and InterfaceVMGJob, respectively.

  • this is a temporary solution until we finally create the fragments and send prepare the MPQCJobs in one go. I.e. for now mpqc has to fill in the vacant MPQCData entries of positions and charges to be used by the VMGJob created from this information.
  • Using CommSerial/MPI in ImportRightHandSide() to getParticleGrid().
Location:
src
Files:
6 edited

Legend:

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

    r092be05 rcd77fc  
    517517    LOG(1, "INFO: Creating VMGJob.");
    518518    FragmentJob::ptr testJob(
    519         new VMGJob(next_id, iter->sampled_grid) );
     519        new VMGJob(next_id, iter->sampled_grid, iter->positions, iter->charges) );
    520520    jobs.push_back(testJob);
    521521  }
     
    533533        "createLongRangeJobs() - current domain matrix "+toString(M)+" is not cubic.");
    534534    const SamplingGrid full_sampled_grid(begin, size, level, full_sample);
     535    const std::vector< std::vector<double> > positions;
     536    const std::vector<double> charges;
    535537    const JobId_t next_id = controller.getAvailableId();
    536538    FragmentJob::ptr testJob(
    537         new VMGJob(next_id, full_sampled_grid) );
     539        new VMGJob(next_id, full_sampled_grid, positions, charges) );
    538540    jobs.push_back(testJob);
    539541  }
  • src/Jobs/InterfaceVMGJob.cpp

    r092be05 rcd77fc  
    3232#endif
    3333
     34#ifdef HAVE_MPI
     35#include "mpi.h"
     36#endif
     37
    3438#include "CodePatterns/MemDebug.hpp"
    3539
     
    4044
    4145#include "base/vector.hpp"
     46#include "base/math.hpp"
     47#ifdef HAVE_MPI
     48#include "comm/comm_mpi.hpp"
     49#else
     50#include "comm/comm_serial.hpp"
     51#endif
    4252#include "grid/grid.hpp"
    4353#include "grid/multigrid.hpp"
     
    4858using VMGInterfaces::InterfaceVMGJob;
    4959
     60InterfaceVMGJob::InterfaceVMGJob(const std::vector< double > &_sampled_input,
     61    std::vector< double > &_sampled_output,
     62    const std::vector< std::vector<double> > &_particle_positions,
     63    const std::vector< double > &_particle_charges,
     64    VMG::Boundary boundary,
     65    int levelMin,
     66    int levelMax,
     67    const VMG::Vector &box_begin,
     68    vmg_float box_end,
     69    const int& near_field_cells,
     70    int coarseningSteps,
     71    double alpha) :
     72  VMG::Interface(boundary, levelMin, levelMax,
     73      box_begin, box_end, coarseningSteps, alpha),
     74  spl(near_field_cells, Extent(MaxLevel()).MeshWidth().Max()),
     75  sampled_input(_sampled_input),
     76  sampled_output(_sampled_output),
     77  level(levelMax)
     78{
     79  std::vector< std::vector<double> >::const_iterator positer = _particle_positions.begin();
     80  std::vector<double>::const_iterator chargeiter = _particle_charges.begin();
     81  double pos[3];
     82  for (; positer != _particle_positions.end(); ++positer, ++chargeiter) {
     83    ASSERT( (*positer).size() == 3,
     84        "InterfaceVMGJob::InterfaceVMGJob() - particle "
     85        +toString(distance(_particle_positions.begin(), positer))+" has not exactly 3 coordinates.");
     86    for (size_t i=0;i<3;++i)
     87      pos[i] = (*positer)[i];
     88    particles.push_back(Particle::Particle(pos, *chargeiter));
     89  }
     90}
     91
     92InterfaceVMGJob::~InterfaceVMGJob()
     93{}
     94
    5095void InterfaceVMGJob::ImportRightHandSide(Multigrid& multigrid)
    5196{
    5297  Index i;
    5398  Vector pos;
    54 
    55 //  VMG::TempGrid *temp_grid = new VMG::TempGrid(129, 0, 0., 1.);
     99  //  VMG::TempGrid *temp_grid = new VMG::TempGrid(129, 0, 0., 1.);
    56100
    57101  Grid& grid = multigrid(multigrid.MaxLevel());
    58102  grid.ClearBoundary();
     103
     104  /// 1. assign nuclei as smeared-out charges to the grid
     105
     106  /*
     107   * Charge assignment on the grid
     108   */
     109#ifdef HAVE_MPI
     110  CommMPI& comm = *dynamic_cast<CommMPI*>(VMG::MG::GetComm());
     111#else
     112  CommSerial& comm = *dynamic_cast<CommSerial*>(VMG::MG::GetComm());
     113#endif
     114  Grid& particle_grid = comm.GetParticleGrid();
     115
     116  particle_grid.Clear();
     117
     118  assert(particle_grid.Global().LocalSize().IsComponentwiseGreater(
     119      VMG::MG::GetFactory().GetObjectStorageVal<int>("PARTICLE_NEAR_FIELD_CELLS")));
     120
     121  for (std::list<Particle::Particle>::iterator iter = particles.begin();
     122      iter != particles.end(); ++iter)
     123    spl.SetSpline(particle_grid, *iter);
     124
     125  // Communicate charges over halo
     126  comm.CommFromGhosts(particle_grid);
     127
     128  // Assign charge values to the right hand side
     129  for (int i=0; i<grid.Local().Size().X(); ++i)
     130    for (int j=0; j<grid.Local().Size().Y(); ++j)
     131      for (int k=0; k<grid.Local().Size().Z(); ++k)
     132  grid(grid.Local().Begin().X() + i,
     133       grid.Local().Begin().Y() + j,
     134       grid.Local().Begin().Z() + k) = 4.0 * VMG::Math::pi *
     135    particle_grid.GetVal(particle_grid.Local().Begin().X() + i,
     136             particle_grid.Local().Begin().Y() + j,
     137             particle_grid.Local().Begin().Z() + k);
     138
     139  /// 2. add sampled electron density to the grid
    59140
    60141  const Index begin_local = grid.Global().LocalBegin() - grid.Local().HaloSize1();
     
    71152      << "Z in [" << grid.Local().Begin().Z() << "," << grid.Local().End().Z() << "].");
    72153
     154  const double element_volume =
     155      grid.Extent().MeshWidth().X() * grid.Extent().MeshWidth().Y() * grid.Extent().MeshWidth().Z();
    73156  std::vector<double>::const_iterator sample_iter = sampled_input.begin();
    74157  for (i.X()=grid.Local().Begin().X(); i.X()<grid.Local().End().X(); ++i.X())
    75158    for (i.Y()=grid.Local().Begin().Y(); i.Y()<grid.Local().End().Y(); ++i.Y())
    76       for (i.Z()=grid.Local().Begin().Z(); i.Z()<grid.Local().End().Z(); ++i.Z()) {
    77         pos = grid.Extent().MeshWidth() * static_cast<Vector>(begin_local + i);
    78 //        R.x() = pos.X();
    79 //        R.y() = pos.Y();
    80 //        R.z() = pos.Z();
    81         grid(i) = *sample_iter; //temp_grid(i);
    82         ++sample_iter;
    83       }
     159      for (i.Z()=grid.Local().Begin().Z(); i.Z()<grid.Local().End().Z(); ++i.Z())
     160        grid(i) -= (*sample_iter++) * element_volume; //temp_grid(i);
    84161  assert( sample_iter == sampled_input.end() );
    85162
  • src/Jobs/InterfaceVMGJob.hpp

    r092be05 rcd77fc  
    1717#include "base/interface.hpp"
    1818#include "base/vector.hpp"
     19#include "units/particle/bspline.hpp"
     20#include "units/particle/particle.hpp"
    1921
    2022namespace VMG
     
    3234  InterfaceVMGJob(const std::vector< double > &_sampled_input,
    3335      std::vector< double > &_sampled_output,
     36      const std::vector< std::vector< double > > &_particle_positions,
     37      const std::vector< double > &_particle_charges,
    3438      VMG::Boundary boundary,
    3539      int levelMin,
     
    3741      const VMG::Vector &box_begin,
    3842      vmg_float box_end,
     43      const int& near_field_cells,
    3944      int coarseningSteps=0,
    40       double alpha=1.6) :
    41     VMG::Interface(boundary, levelMin, levelMax,
    42                    box_begin, box_end, coarseningSteps, alpha),
    43                    sampled_input(_sampled_input),
    44        sampled_output(_sampled_output),
    45                    level(levelMax)
    46   {}
     45      double alpha=1.6);
    4746
    48   virtual ~InterfaceVMGJob() {}
     47  virtual ~InterfaceVMGJob();
    4948
    5049  void ImportRightHandSide(VMG::Multigrid& multigrid);
    5150  void ExportSolution(VMG::Grid& grid);
    5251
     52protected:
     53  VMG::Particle::BSpline spl;
     54
    5355private:
     56  //!> sampled density on the grid as input
    5457  const std::vector< double > sampled_input;
     58  //!> sampled potential on the grid as output
    5559  std::vector< double > &sampled_output;
     60  //!> number of grid points per axis as \f$2^{\text{level}}\f$
    5661  const int level;
     62  //!> nuclei charges
     63  std::list<VMG::Particle::Particle> particles;
    5764};
    5865
  • src/Jobs/MPQCData.hpp

    r092be05 rcd77fc  
    8282  SamplingGrid sampled_grid;
    8383
     84  // nuclei positions and charges
     85  std::vector< std::vector<double> > positions;
     86  std::vector<double> charges;
     87
    8488  /// Timing structure
    8589  struct times_t {
     
    111115    ar & forces;
    112116    ar & sampled_grid;
     117    ar & positions;
     118    ar & charges;
    113119    ar & times.walltime;
    114120    ar & times.cputime;
  • src/Jobs/VMGJob.cpp

    r092be05 rcd77fc  
    7676VMGJob::VMGJob(
    7777    const JobId_t _JobId,
    78     const SamplingGrid _density_grid) :
     78    const SamplingGrid &_density_grid,
     79    const std::vector< std::vector< double > > &_particle_positions,
     80    const std::vector< double > &_particle_charges) :
    7981  FragmentJob(_JobId),
    8082  density_grid(_density_grid),
    81   potential_grid(static_cast<const SamplingGridProperties &>(_density_grid))
     83  potential_grid(static_cast<const SamplingGridProperties &>(_density_grid)),
     84  particle_positions(_particle_positions),
     85  particle_charges(_particle_charges)
    8286{}
    8387
     
    125129  // TODO: As a matter of fact should use open boundary conditions
    126130  const Boundary boundary(Periodic, Periodic, Periodic);
    127 //  int near_field_cells = 10;
     131  int near_field_cells = 10;
    128132
    129133  /*
     
    139143      density_grid.sampled_grid,
    140144      potential_grid.sampled_grid,
     145      particle_positions,
     146      particle_charges,
    141147      boundary,
    142148      2,
    143149      density_grid.level,
    144150      Vector(density_grid.begin),
    145       density_grid.size);
     151      density_grid.size,
     152      near_field_cells);
    146153  new LevelOperatorCS(Stencils::RestrictionFullWeight, Stencils::InterpolationTrilinear);
    147154  new Givens<SolverSingular>();
     
    157164  new ObjectStorage<vmg_float>("PRECISION", 1.0e-10);
    158165  new ObjectStorage<int>("MAX_ITERATION", 15);
    159 //  new ObjectStorage<int>("PARTICLE_NEAR_FIELD_CELLS", near_field_cells);
    160 //  new ObjectStorage<int>("PARTICLE_INTERPOLATION_DEGREE", 3);
     166  new ObjectStorage<int>("PARTICLE_NEAR_FIELD_CELLS", near_field_cells);
     167  new ObjectStorage<int>("PARTICLE_INTERPOLATION_DEGREE", 3);
    161168
    162169  /*
  • src/Jobs/VMGJob.hpp

    r092be05 rcd77fc  
    4141   */
    4242  VMGJob(const JobId_t _JobId,
    43       const SamplingGrid density_grid);
     43      const SamplingGrid &density_grid,
     44      const std::vector< std::vector< double > > &_particle_positions,
     45      const std::vector< double > &_particle_charges);
    4446  virtual ~VMGJob();
    4547
     
    5456  //!> sampled potential as output of the job
    5557  SamplingGrid potential_grid;
     58  //!> positions of all nuclei
     59  const std::vector< std::vector< double > > particle_positions;
     60  //!> charges of all nuclei
     61  const std::vector< double > particle_charges;
    5662
    5763private:
     
    6874    ar & const_cast< SamplingGrid &>(density_grid);
    6975    ar & potential_grid;
     76    ar & const_cast< std::vector< std::vector< double > > &>(particle_positions);
     77    ar & const_cast< std::vector< double > &>(particle_charges);
    7078  }
    7179};
Note: See TracChangeset for help on using the changeset viewer.