Changeset 9b68fc for src/Actions
- Timestamp:
- Jun 27, 2014, 9:32:55 PM (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:
- 31bd9c
- Parents:
- 550f2a
- git-author:
- Frederik Heber <heber@…> (03/05/14 22:12:01)
- git-committer:
- Frederik Heber <heber@…> (06/27/14 21:32:55)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/PotentialAction/FitParticleChargesAction.cpp
r550f2a r9b68fc 47 47 #include <boost/foreach.hpp> 48 48 #include <algorithm> 49 #include <functional> 49 50 #include <iostream> 50 51 #include <string> … … 128 129 return Action::failure; 129 130 } 131 132 // average partial charges over all fragments 130 133 HomologyContainer::const_iterator iter = range.first; 131 if (!iter->second.containsGrids) { 132 ELOG(2, "This HomologyGraph does not contain sampled grids,\ndid you forget to add '--store-grids 1' to AnalyseFragmentResults."); 133 return Action::failure; 134 PartialNucleiChargeFitter::charges_t averaged_charges; 135 averaged_charges.resize(iter->second.fragment.getCharges().size(), 0.); 136 size_t NoFragments = 0; 137 for (; 138 iter != range.second; ++iter, ++NoFragments) { 139 if (!iter->second.containsGrids) { 140 ELOG(2, "This HomologyGraph does not contain sampled grids,\ndid you forget to add '--store-grids 1' to AnalyseFragmentResults."); 141 return Action::failure; 142 } 143 const Fragment &fragment = iter->second.fragment; 144 // const double &energy = iter->second.energy; 145 // const SamplingGrid &charge = iter->second.charge_distribution; 146 const SamplingGrid &potential = iter->second.potential_distribution; 147 if ((potential.level == 0) 148 || ((potential.begin[0] == potential.end[0]) 149 && (potential.begin[1] == potential.end[1]) 150 && (potential.begin[2] == potential.end[2]))) { 151 ELOG(1, "Sampled grid contains grid made of zero points."); 152 return Action::failure; 153 } 154 155 // then we extract positions from fragment 156 PartialNucleiChargeFitter::positions_t positions; 157 Fragment::positions_t fragmentpositions = fragment.getPositions(); 158 positions.reserve(fragmentpositions.size()); 159 BOOST_FOREACH( Fragment::position_t pos, fragmentpositions) { 160 positions.push_back( Vector(pos[0], pos[1], pos[2]) ); 161 } 162 PartialNucleiChargeFitter fitter(potential, positions, params.radius.get()); 163 fitter(); 164 PartialNucleiChargeFitter::charges_t return_charges = fitter.getSolutionAsCharges_t(); 165 std::transform( 166 return_charges.begin(), return_charges.end(), 167 averaged_charges.begin(), 168 averaged_charges.begin(), 169 std::plus<PartialNucleiChargeFitter::charge_t>()); 134 170 } 135 const Fragment &fragment = iter->second.fragment; 136 // const double &energy = iter->second.energy; 137 // const SamplingGrid &charge = iter->second.charge_distribution; 138 const SamplingGrid &potential = iter->second.potential_distribution; 139 if ((potential.level == 0) 140 || ((potential.begin[0] == potential.end[0]) 141 && (potential.begin[1] == potential.end[1]) 142 && (potential.begin[2] == potential.end[2]))) { 143 ELOG(1, "Sampled grid contains grid made of zero points."); 144 return Action::failure; 145 } 171 std::transform(averaged_charges.begin(),averaged_charges.end(), 172 averaged_charges.begin(), 173 std::bind1st(std::multiplies<PartialNucleiChargeFitter::charge_t>(),1./NoFragments) 174 ); 146 175 147 // then we extract positions from fragment148 PartialNucleiChargeFitter::positions_t positions;149 Fragment::positions_t fragmentpositions = fragment.getPositions();150 positions.reserve(fragmentpositions.size());151 BOOST_FOREACH( Fragment::position_t pos, fragmentpositions) {152 positions.push_back( Vector(pos[0], pos[1], pos[2]) );153 }154 PartialNucleiChargeFitter fitter(potential, positions, params.radius.get());155 fitter();156 PartialNucleiChargeFitter::charges_t return_charges = fitter.getSolutionAsCharges_t();157 176 158 177 // output fitted charges 159 LOG(0, "STATUS: We have fitted the following charges " << return_charges << "."); 178 LOG(0, "STATUS: We have fitted the following charges " << averaged_charges 179 << ", averaged over " << NoFragments << " fragments."); 160 180 161 181 return Action::success;
Note:
See TracChangeset
for help on using the changeset viewer.