- Timestamp:
- Aug 12, 2013, 11:30:31 AM (11 years ago)
- 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)
- Location:
- src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/FragmentationAction/FragmentationAction.cpp
r3e93bd4 r321470 176 176 } 177 177 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 } 178 188 179 189 // now add interfragments -
src/Fragmentation/Fragmentation.cpp
r3e93bd4 r321470 33 33 #endif 34 34 35 #include <boost/bimap.hpp> 36 35 37 #include "CodePatterns/MemDebug.hpp" 36 38 … … 39 41 #include "CodePatterns/Assert.hpp" 40 42 #include "CodePatterns/Info.hpp" 43 #include "CodePatterns/IteratorAdaptors.hpp" 41 44 #include "CodePatterns/Log.hpp" 42 45 … … 127 130 // ===== 1. Check whether bond structure is same as stored in files ==== 128 131 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 129 147 // === compare it with adjacency file === 130 148 { 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 ); 132 153 AdjacencyList WorldAdjacency(globalids); 133 154 FragmentationToDo = FragmentationToDo && (FileChecker > WorldAdjacency); … … 143 164 144 165 // ===== 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); 146 167 147 168 // =================================== Begin of FRAGMENTATION =============================== … … 398 419 * \return true - file writable, false - not writable 399 420 */ 400 bool Fragmentation::StoreOrderAtSiteFile(const std::string &path) 421 bool Fragmentation::StoreOrderAtSiteFile( 422 const std::string &path) 401 423 { 402 424 string line; … … 404 426 405 427 line = path + ORDERATSITEFILE; 406 file.open(line.c_str() );428 file.open(line.c_str(), std::ofstream::out | std::ofstream::app); 407 429 std::stringstream output; 408 430 output << "INFO: Writing OrderAtSite " << ORDERATSITEFILE << " ... "; 409 431 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 } 411 437 file.close(); 412 438 output << "done."; … … 423 449 * Atoms not present in the file get "0". 424 450 * \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 426 453 * \return true - file found and scanned, false - file not found 427 454 * \sa ParseKeySetFile() and CheckAdjacencyFileAgainstMolecule() as this is meant to be used in conjunction with the two 428 455 */ 429 bool Fragmentation::ParseOrderAtSiteFromFile(const std::vector<atomId_t> &atomids, const std::string &path) 456 bool Fragmentation::ParseOrderAtSiteFromFile( 457 const std::vector<atomId_t> &atomids, 458 const std::string &path, 459 const Global_local_bimap_t &global_local_bimap) 430 460 { 431 461 // Info FunctionInfo(__func__); … … 435 465 AtomMask_t MaxArray(atomids); 436 466 bool status; 437 int AtomNr, value;467 int AtomNr, ordervalue, maxvalue; 438 468 string line; 439 469 ifstream file; … … 445 475 AtomNr = -1; 446 476 file >> AtomNr; 477 file >> ordervalue; 478 file >> maxvalue; 447 479 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 } 453 489 } 454 490 } -
src/Fragmentation/Fragmentation.hpp
r3e93bd4 r321470 25 25 #include <vector> 26 26 27 #include <boost/bimap.hpp> 28 27 29 class atom; 28 30 class AtomMask_t; … … 33 35 class Fragmentation 34 36 { 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; 35 42 public: 36 43 Fragmentation( … … 54 61 bool CheckOrderAtSite(AtomMask_t &AtomMask, const Graph &GlobalKeySetList, int Order, const std::string &path, bool LoopDoneAlready); 55 62 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); 57 64 58 65 // storing fragments
Note:
See TracChangeset
for help on using the changeset viewer.