Changeset 321470 for src


Ignore:
Timestamp:
Aug 12, 2013, 11:30:31 AM (11 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:
57ba6f
Parents:
3e93bd4
git-author:
Frederik Heber <heber@…> (07/12/13 14:59:19)
git-committer:
Frederik Heber <heber@…> (08/12/13 11:30:31)
Message:

FIX: Fragmentation's OrderAtSite was written per molecule and with local ids.

Location:
src
Files:
3 edited

Legend:

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

    r3e93bd4 r321470  
    176176  }
    177177  LOG(0, "STATUS: There are " << TotalGraph.size() << " fragments.");
     178
     179  {
     180    // remove OrderAtSite file
     181    std::string line;
     182    std::ofstream file;
     183    line = params.prefix.get() + ORDERATSITEFILE;
     184    file.open(line.c_str(), std::ofstream::out | std::ofstream::trunc);
     185    file << "";
     186    file.close();
     187  }
    178188
    179189  // now add interfragments
  • src/Fragmentation/Fragmentation.cpp

    r3e93bd4 r321470  
    3333#endif
    3434
     35#include <boost/bimap.hpp>
     36
    3537#include "CodePatterns/MemDebug.hpp"
    3638
     
    3941#include "CodePatterns/Assert.hpp"
    4042#include "CodePatterns/Info.hpp"
     43#include "CodePatterns/IteratorAdaptors.hpp"
    4144#include "CodePatterns/Log.hpp"
    4245
     
    127130  // ===== 1. Check whether bond structure is same as stored in files ====
    128131
     132  // create a lookup global <-> local id for atomic ids valid in World and in molecule
     133  Global_local_bimap_t Global_local_bimap;
     134  for (std::vector<local_t>::const_iterator iter = atomids.begin();
     135      iter != atomids.end();
     136      ++iter) {
     137    const atom * _atom = mol->FindAtom(*iter);
     138    ASSERT( _atom != NULL,
     139        "Fragmentation::FragmentMolecule() - could not find atom "+toString(*iter)+".");
     140    Global_local_bimap.insert(
     141        idpair_t(
     142            (global_t)(_atom->getId()), (local_t)(*iter)
     143            )
     144        );
     145  }
     146
    129147  // === compare it with adjacency file ===
    130148  {
    131     const std::vector<atomId_t> globalids = getGlobalIdsFromLocalIds(*mol, atomids);
     149    const std::vector<atomId_t> globalids(
     150        MapKeyConstIterator<Global_local_bimap_t::left_const_iterator>(Global_local_bimap.left.begin()),
     151        MapKeyConstIterator<Global_local_bimap_t::left_const_iterator>(Global_local_bimap.left.end())
     152        );
    132153    AdjacencyList WorldAdjacency(globalids);
    133154    FragmentationToDo = FragmentationToDo && (FileChecker > WorldAdjacency);
     
    143164
    144165  // ===== 4. check globally whether there's something to do actually (first adaptivity check)
    145   FragmentationToDo = FragmentationToDo && ParseOrderAtSiteFromFile(atomids, prefix);
     166  FragmentationToDo = FragmentationToDo && ParseOrderAtSiteFromFile(atomids, prefix, Global_local_bimap);
    146167
    147168  // =================================== Begin of FRAGMENTATION ===============================
     
    398419 * \return true - file writable, false - not writable
    399420 */
    400 bool Fragmentation::StoreOrderAtSiteFile(const std::string &path)
     421bool Fragmentation::StoreOrderAtSiteFile(
     422    const std::string &path)
    401423{
    402424  string line;
     
    404426
    405427  line = path + ORDERATSITEFILE;
    406   file.open(line.c_str());
     428  file.open(line.c_str(), std::ofstream::out | std::ofstream::app);
    407429  std::stringstream output;
    408430  output << "INFO: Writing OrderAtSite " << ORDERATSITEFILE << " ... ";
    409431  if (file.good()) {
    410     for_each(mol->begin(),mol->end(),bind2nd(mem_fun(&atom::OutputOrder), &file));
     432    for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     433      file << (*iter)->getId()
     434          << "\t" << (int)(*iter)->AdaptiveOrder
     435          << "\t" << (int)(*iter)->MaxOrder << std::endl;
     436    }
    411437    file.close();
    412438    output << "done.";
     
    423449 * Atoms not present in the file get "0".
    424450 * \param atomids atoms to fragment, used in AtomMask
    425  * \param &path path to file ORDERATSITEFILEe
     451 * \param &path path to file ORDERATSITEFILE
     452 * \param global_local_bimap translate global to local id
    426453 * \return true - file found and scanned, false - file not found
    427454 * \sa ParseKeySetFile() and CheckAdjacencyFileAgainstMolecule() as this is meant to be used in conjunction with the two
    428455 */
    429 bool Fragmentation::ParseOrderAtSiteFromFile(const std::vector<atomId_t> &atomids, const std::string &path)
     456bool Fragmentation::ParseOrderAtSiteFromFile(
     457    const std::vector<atomId_t> &atomids,
     458    const std::string &path,
     459    const Global_local_bimap_t &global_local_bimap)
    430460{
    431461//  Info FunctionInfo(__func__);
     
    435465  AtomMask_t MaxArray(atomids);
    436466  bool status;
    437   int AtomNr, value;
     467  int AtomNr, ordervalue, maxvalue;
    438468  string line;
    439469  ifstream file;
     
    445475      AtomNr = -1;
    446476      file >> AtomNr;
     477      file >> ordervalue;
     478      file >> maxvalue;
    447479      if (AtomNr != -1) {   // test whether we really parsed something (this is necessary, otherwise last atom is set twice and to 0 on second time)
    448         file >> value;
    449         OrderArray[AtomNr] = value;
    450         file >> value;
    451         MaxArray.setValue(AtomNr, (bool)value);
    452         //LOG(2, "AtomNr " << AtomNr << " with order " << (int)OrderArray[AtomNr] << " and max order set to " << (int)MaxArray[AtomNr] << ".");
     480        // parsed id is global, must be translated to local id
     481        Global_local_bimap_t::left_const_iterator iter = global_local_bimap.left.find(AtomNr);
     482        // skip global ids we don't know about, must be in other molecule
     483        if (iter != global_local_bimap.left.end()) {
     484          const int LocalId = iter->second;
     485          OrderArray[LocalId] = ordervalue;
     486          MaxArray.setValue(LocalId, (bool)maxvalue);
     487          //LOG(2, "AtomNr " << LocalId << " with order " << (int)OrderArray[LocalId] << " and max order set to " << (int)MaxArray[LocalId] << ".");
     488        }
    453489      }
    454490    }
  • src/Fragmentation/Fragmentation.hpp

    r3e93bd4 r321470  
    2525#include <vector>
    2626
     27#include <boost/bimap.hpp>
     28
    2729class atom;
    2830class AtomMask_t;
     
    3335class Fragmentation
    3436{
     37  // some typedefs for intermediat global id <-> local id bimap
     38  typedef atomId_t global_t;
     39  typedef atomId_t local_t;
     40  typedef boost::bimap< global_t, local_t > Global_local_bimap_t;
     41  typedef Global_local_bimap_t::value_type idpair_t;
    3542public:
    3643  Fragmentation(
     
    5461  bool CheckOrderAtSite(AtomMask_t &AtomMask, const Graph &GlobalKeySetList, int Order, const std::string &path, bool LoopDoneAlready);
    5562  bool StoreOrderAtSiteFile(const std::string &path);
    56   bool ParseOrderAtSiteFromFile(const std::vector<atomId_t> &atomids, const std::string &path);
     63  bool ParseOrderAtSiteFromFile(const std::vector<atomId_t> &atomids, const std::string &path, const Global_local_bimap_t &global_local_bimap);
    5764
    5865  // storing fragments
Note: See TracChangeset for help on using the changeset viewer.