Changeset a3d08c


Ignore:
Timestamp:
Mar 24, 2017, 10:12:22 AM (8 years ago)
Author:
Frederik Heber <heber@…>
Branches:
FitPartialCharges_GlobalError
Children:
e6a2ef
Parents:
2f9faf
git-author:
Frederik Heber <heber@…> (10/10/16 12:34:08)
git-committer:
Frederik Heber <heber@…> (03/24/17 10:12:22)
Message:

Extracted VMGFragmentController::getFullPositions().

Location:
src/Fragmentation/Automation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Fragmentation/Automation/VMGFragmentController.cpp

    r2f9faf ra3d08c  
    8888    increased_nfc = 3;
    8989  return increased_nfc;
     90}
     91
     92void VMGFragmentController::getFullPositions(
     93    std::vector< std::vector<double> > &positions,
     94    std::vector<double> &charges,
     95    const bool _UseImplicitCharges,
     96    const bool _DoValenceOnly)
     97{
     98  /// \note we cannot use the summed up Fragment here, as the saturation hydrogens
     99  /// are in the way and cannot be sorted out properly/in a simple fashion.
     100  const World &world = const_cast<const World &>(World::getInstance());
     101  const ParticleRegistry &registry = const_cast<const ParticleRegistry &>(ParticleRegistry::getInstance());
     102  {
     103    const World::ConstAtomComposite &atoms = world.getAllAtoms();
     104    positions.reserve(atoms.size());
     105    charges.reserve(atoms.size());
     106    std::vector<double> position(3, 0.);
     107    for (World::ConstAtomComposite::const_iterator iter = atoms.begin();
     108        iter != atoms.end(); ++iter) {
     109      // set position for this atom
     110      const Vector &pos = (*iter)->getPosition();
     111      // convert positions to atomic length units
     112      for (size_t i=0;i<3;++i)
     113        position[i] = pos[i]/AtomicLengthToAngstroem;
     114
     115      // use partial charges ...
     116      const atomId_t atomid = (*iter)->getId();
     117      if ((!world.isAtomSelected(atomid)) && (_UseImplicitCharges)) {
     118        // ... for all unselected particles ...
     119        std::string particlename = (*iter)->getParticleName();
     120        if (particlename.empty())
     121          particlename = (*iter)->getElement().getSymbol();
     122        if (registry.isPresentByName(particlename)) {
     123          // ... that are present in ParticleRegistry
     124          const Particle * const particle = registry.getByName(particlename);
     125          LOG(3, "DEBUG: Using implicit charge " << particle->charge << " of particle "
     126              << particle->getName() << " for atom " << atomid);
     127          positions.push_back(position);
     128          charges.push_back(particle->charge);
     129        }
     130      } else {
     131        double charge = (*iter)->getElement().getAtomicNumber();
     132        // subtract core electron charge from nuclei charge if only valence sampled
     133        if (_DoValenceOnly == MPQCData::DoSampleValenceOnly)
     134          charge -= getCoreElectrons(charge);
     135        positions.push_back(position);
     136        charges.push_back((double)charge);
     137      }
     138    }
     139  }
    90140}
    91141
     
    141191
    142192  /// prepare positions and charges of full system
    143   /// \note we cannot use the summed up Fragment here, as the saturation hydrogens
    144   /// are in the way and cannot be sorted out properly/in a simple fashion.
    145193  std::vector< std::vector<double> > positions;
    146194  std::vector<double> charges;
    147   const World &world = const_cast<const World &>(World::getInstance());
    148   const ParticleRegistry &registry = const_cast<const ParticleRegistry &>(ParticleRegistry::getInstance());
    149   {
    150     const World::ConstAtomComposite &atoms = world.getAllAtoms();
    151     positions.reserve(atoms.size());
    152     charges.reserve(atoms.size());
    153     std::vector<double> position(3, 0.);
    154     for (World::ConstAtomComposite::const_iterator iter = atoms.begin();
    155         iter != atoms.end(); ++iter) {
    156       // set position for this atom
    157       const Vector &pos = (*iter)->getPosition();
    158       // convert positions to atomic length units
    159       for (size_t i=0;i<3;++i)
    160         position[i] = pos[i]/AtomicLengthToAngstroem;
    161 
    162       // use partial charges ...
    163       const atomId_t atomid = (*iter)->getId();
    164       if ((!world.isAtomSelected(atomid)) && (_UseImplicitCharges)) {
    165         // ... for all unselected particles ...
    166         std::string particlename = (*iter)->getParticleName();
    167         if (particlename.empty())
    168           particlename = (*iter)->getElement().getSymbol();
    169         if (registry.isPresentByName(particlename)) {
    170           // ... that are present in ParticleRegistry
    171           const Particle * const particle = registry.getByName(particlename);
    172           LOG(3, "DEBUG: Using implicit charge " << particle->charge << " of particle "
    173               << particle->getName() << " for atom " << atomid);
    174           positions.push_back(position);
    175           charges.push_back(particle->charge);
    176         }
    177       } else {
    178         double charge = (*iter)->getElement().getAtomicNumber();
    179         // subtract core electron charge from nuclei charge if only valence sampled
    180         if (_DoValenceOnly == MPQCData::DoSampleValenceOnly)
    181           charge -= getCoreElectrons(charge);
    182         positions.push_back(position);
    183         charges.push_back((double)charge);
    184       }
    185     }
    186   }
     195  getFullPositions(positions, charges, _UseImplicitCharges, _DoValenceOnly);
     196
    187197  /// and submit full job
    188198  for(std::vector<SamplingGrid>::const_iterator iter = full_sampled_grid.begin();
  • src/Fragmentation/Automation/VMGFragmentController.hpp

    r2f9faf ra3d08c  
    9292  }
    9393
     94  /** Helper function to get at the whole set of nuclei positions.
     95   *
     96   * \param positions contains positions on return
     97   * \param charges contains charges on return
     98   * \param _UseImplicitCharges whether to use implicit charges or not
     99   * \param _DoValenceOnly whether just valency has been sampled
     100   */
     101  static void getFullPositions(
     102      std::vector< std::vector<double> > &positions,
     103      std::vector<double> &charges,
     104      const bool _UseImplicitCharges,
     105      const bool _DoValenceOnly);
     106
    94107private:
    95108  //!> type-specific result container
Note: See TracChangeset for help on using the changeset viewer.