- Timestamp:
- Feb 27, 2013, 12:39:03 PM (12 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:
- e36ba2
- Parents:
- 775dd1a
- git-author:
- Frederik Heber <heber@…> (12/07/12 15:01:07)
- git-committer:
- Frederik Heber <heber@…> (02/27/13 12:39:03)
- Location:
- src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/LevMartester.cpp
r775dd1a r0dad5f 369 369 370 370 SaturationPotential saturation(types); 371 saturation.setTriplefunction(2.5, triplefunction); 371 // saturation has internal triplefunction now 372 // saturation.setTriplefunction(2.5, triplefunction); 372 373 FunctionModel &model = saturation; 373 374 FunctionApproximation approximator(TersoffData, model); // CH4 has 5 atoms, hence 5*4/2 distances -
src/Potentials/Specifics/SaturationPotential.cpp
r775dd1a r0dad5f 176 176 } 177 177 178 std::vector<FunctionModel::arguments_t> 179 triplefunction( 180 const argument_t &argument, 181 const FunctionModel::arguments_t& args) 182 { 183 const size_t firstindex = argument.indices.first; 184 const size_t secondindex = argument.indices.second; 185 // LOG(2, "DEBUG: first index is " << firstindex << ", second index is " << secondindex << "."); 186 187 // place all arguments that share either index into a lookup map 188 typedef std::map< size_t, FunctionModel::arguments_t::const_iterator > IndexLookup_t; 189 IndexLookup_t LookuptoFirst; 190 IndexLookup_t LookuptoSecond; 191 for (FunctionModel::arguments_t::const_iterator iter = args.begin(); 192 iter != args.end(); 193 ++iter) { 194 if (((*iter).indices.first == argument.indices.first) 195 && ((*iter).indices.second == argument.indices.second)) 196 continue; 197 if (firstindex == (*iter).indices.first) { 198 LookuptoFirst.insert( std::make_pair( (*iter).indices.second, iter) ); 199 } 200 else if (firstindex == (*iter).indices.second) { 201 LookuptoFirst.insert( std::make_pair( (*iter).indices.first, iter) ); 202 } 203 if (secondindex == (*iter).indices.first) { 204 LookuptoSecond.insert( std::make_pair( (*iter).indices.second, iter) ); 205 } 206 else if (secondindex == (*iter).indices.second) { 207 LookuptoSecond.insert( std::make_pair((*iter).indices.first, iter) ); 208 } 209 } 210 // { 211 // std::stringstream lookupstream; 212 // for (IndexLookup_t::const_iterator iter = LookuptoFirst.begin(); 213 // iter != LookuptoFirst.end(); 214 // ++iter) { 215 // lookupstream << "(" << iter->first << "," << *(iter->second) << ") "; 216 // } 217 // LOG(2, "DEBUG: LookupToFirst is " << lookupstream.str() << "."); 218 // } 219 // { 220 // std::stringstream lookupstream; 221 // for (IndexLookup_t::const_iterator iter = LookuptoSecond.begin(); 222 // iter != LookuptoSecond.end(); 223 // ++iter) { 224 // lookupstream << "(" << iter->first << "," << *(iter->second) << ") "; 225 // } 226 // LOG(2, "DEBUG: LookuptoSecond is " << lookupstream.str() << "."); 227 // } 228 229 // now go through the first lookup as the second argument and pick the 230 // corresponding third argument by the matching index 231 std::vector<FunctionModel::arguments_t> results; 232 for (IndexLookup_t::const_iterator iter = LookuptoFirst.begin(); 233 iter != LookuptoFirst.end(); 234 ++iter) { 235 IndexLookup_t::const_iterator otheriter = LookuptoSecond.find(iter->first); 236 ASSERT( otheriter != LookuptoSecond.end(), 237 "triplefunction() - cannot find index "+toString(iter->first) 238 +" in LookupToSecond"); 239 FunctionModel::arguments_t result(1, argument); 240 result.reserve(3); 241 result.push_back(*(iter->second)); 242 result.push_back(*(otheriter->second)); 243 results.push_back(result); 244 } 245 246 return results; 247 } 248 178 249 SaturationPotential::results_t 179 250 SaturationPotential::operator()( … … 197 268 if (result != result) 198 269 ELOG(1, "result is NAN."); 199 } 200 } 201 { 202 // Angle contribution 203 const double tmp = angle(arguments)[0]; // as we have all distances we get both jk and kj 204 // LOG(2, "DEBUG: angle yields " << tmp << " for << " << arguments << "."); 205 result += tmp; 206 if (result != result) 207 ELOG(1, "result is NAN."); 270 271 // Angle contribution 272 { 273 typedef std::vector<FunctionModel::arguments_t> tripleargs_t; 274 tripleargs_t tripleargs = 275 triplefunction(r_ij, arguments); 276 for (tripleargs_t::const_iterator iter = tripleargs.begin(); 277 iter != tripleargs.end(); 278 ++iter) { 279 FunctionModel::arguments_t tempargs = 280 Extractors::reorderArgumentsByParticleTypes(*iter, angle.getParticleTypes()); 281 const double tmp = angle(tempargs)[0]; // as we have all distances we get both jk and kj 282 // LOG(2, "DEBUG: angle yields " << tmp << " for << " << arguments << "."); 283 result += tmp; 284 if (result != result) 285 ELOG(1, "result is NAN."); 286 } 287 } 288 } 208 289 } 209 290 return std::vector<result_t>(1, energy_offset + result); … … 228 309 { 229 310 double result = 0.; 230 switch (index) { 231 case all_energy_offset: 232 { 233 result = 1.; 234 break; 235 } 236 case morse_spring_constant: 237 case morse_equilibrium_distance: 238 case morse_dissociation_energy: 239 { 240 const ParticleTypes_t &morse_types = morse.getParticleTypes(); 241 for(arguments_t::const_iterator argiter = arguments.begin(); 242 argiter != arguments.end(); 243 ++argiter) { 244 const argument_t &r_ij = *argiter; 245 if (((r_ij.types.first == morse_types[0]) && (r_ij.types.second == morse_types[1])) 246 || ((r_ij.types.first == morse_types[1]) && (r_ij.types.second == morse_types[0]))) { 247 arguments_t args(1, r_ij); 248 switch (index) { 249 case morse_spring_constant: 250 result += morse.parameter_derivative(args, PairPotential_Morse::spring_constant)[0]; 251 break; 252 case morse_equilibrium_distance: 253 result += morse.parameter_derivative(args, PairPotential_Morse::equilibrium_distance)[0]; 254 break; 255 case morse_dissociation_energy: 256 result += morse.parameter_derivative(args, PairPotential_Morse::dissociation_energy)[0]; 257 break; 258 default: 259 ASSERT( 0, "SaturationPotential::parameter_derivative() - impossible to get here."); 260 break; 311 if (index == all_energy_offset) { 312 result = 1.; 313 } else { 314 const ParticleTypes_t &morse_types = morse.getParticleTypes(); 315 for(arguments_t::const_iterator argiter = arguments.begin(); 316 argiter != arguments.end(); 317 ++argiter) { 318 const argument_t &r_ij = *argiter; 319 if (((r_ij.types.first == morse_types[0]) && (r_ij.types.second == morse_types[1])) 320 || ((r_ij.types.first == morse_types[1]) && (r_ij.types.second == morse_types[0]))) { 321 arguments_t args(1, r_ij); 322 323 switch (index) { 324 case morse_spring_constant: 325 result += morse.parameter_derivative(args, PairPotential_Morse::spring_constant)[0]; 326 break; 327 case morse_equilibrium_distance: 328 result += morse.parameter_derivative(args, PairPotential_Morse::equilibrium_distance)[0]; 329 break; 330 case morse_dissociation_energy: 331 result += morse.parameter_derivative(args, PairPotential_Morse::dissociation_energy)[0]; 332 break; 333 case angle_spring_constant: 334 case angle_equilibrium_distance: 335 { 336 typedef std::vector<FunctionModel::arguments_t> tripleargs_t; 337 tripleargs_t tripleargs = 338 triplefunction(r_ij, arguments); 339 for (tripleargs_t::const_iterator iter = tripleargs.begin(); 340 iter != tripleargs.end(); 341 ++iter) { 342 FunctionModel::arguments_t tempargs = 343 Extractors::reorderArgumentsByParticleTypes(*iter, angle.getParticleTypes()); 344 if (index == angle_spring_constant) 345 result += angle.parameter_derivative(tempargs, PairPotential_Angle::spring_constant)[0]; 346 else if (index == angle_equilibrium_distance) 347 result += angle.parameter_derivative(tempargs, PairPotential_Angle::equilibrium_distance)[0]; 348 // LOG(2, "DEBUG: angle yields " << tmp << " for << " << arguments << "."); 349 // result += tmp; 350 if (result != result) 351 ELOG(1, "result is NAN."); 352 } 261 353 } 354 break; 355 default: 356 ASSERT( 0, "SaturationPotential::parameter_derivative() - impossible to get here."); 357 break; 262 358 } 263 359 } 264 break; 265 } 266 case angle_spring_constant: 267 { 268 result = angle.parameter_derivative(arguments, PairPotential_Angle::spring_constant)[0]; 269 break; 270 } 271 case angle_equilibrium_distance: 272 { 273 result = angle.parameter_derivative(arguments, PairPotential_Angle::equilibrium_distance)[0]; 274 break; 275 } 276 default: 277 ELOG(1, "SaturationPotential::parameter_derivative() - index " << index << " invalid."); 278 break; 360 } 279 361 } 280 362 return SaturationPotential::results_t(1, result); … … 333 415 // Finally, we also need to arrange them in correct order 334 416 // (for PairPotentiale_Angle). 335 charges_t firstpair(2, boost::cref(charges[0])); 417 //charges_t firstpair(2, boost::cref(charges[0])); 418 // only that saturation potential never has its middle element twice! 419 // hence, we skip the firstpair but keep the code for later generalization 336 420 charges_t secondpair(2, boost::cref(charges[1])); 337 421 const charges_t &thirdpair = charges; 338 422 returnfunction = 339 boost::bind(&Extractors::reorderArgumentsByParticleTypes,423 // boost::bind(&Extractors::reorderArgumentsByParticleTypes, 340 424 boost::bind(&Extractors::combineArguments, 341 boost::bind(&Extractors::combineArguments,342 boost::bind(&Extractors::gatherAllDistancesFromFragment,343 boost::bind(&Fragment::getPositions, _1),344 boost::bind(&Fragment::getCharges, _1),345 firstpair, // no crefs here as are temporaries!346 _2),425 // boost::bind(&Extractors::combineArguments, 426 // boost::bind(&Extractors::gatherAllDistancesFromFragment, 427 // boost::bind(&Fragment::getPositions, _1), 428 // boost::bind(&Fragment::getCharges, _1), 429 // firstpair, // no crefs here as are temporaries! 430 // _2), 347 431 boost::bind(&Extractors::gatherAllDistancesFromFragment, 348 432 boost::bind(&Fragment::getPositions, _1), 349 433 boost::bind(&Fragment::getCharges, _1), 350 434 secondpair, // no crefs here as are temporaries! 351 _2) 352 ),435 _2), 436 // ), 353 437 boost::bind(&Extractors::gatherAllDistancesFromFragment, 354 438 boost::bind(&Fragment::getPositions, _1), … … 356 440 boost::cref(thirdpair), // only the last one is no temporary 357 441 _2) 358 ) ,359 boost::cref(angle.getParticleTypes())360 );442 ); 443 // boost::cref(angle.getParticleTypes()) 444 // ); 361 445 } 362 446 return returnfunction; -
src/Potentials/Specifics/SaturationPotential.hpp
r775dd1a r0dad5f 90 90 /** Sets the magic triple function that we use for getting angle distances. 91 91 * 92 * \note does nothing as we have an internal triplefunction 93 * 92 94 * \param _saturation_cutoff cutoff for the triplefunction 93 95 * @param _triplefunction function that returns a list of triples (i.e. the … … 100 102 ) 101 103 { 102 saturation_cutoff = _saturation_cutoff;103 triplefunction = _triplefunction;104 104 } 105 105 … … 207 207 double energy_offset; 208 208 209 //!> bound function that obtains the triples for the internal coordinationb summation.210 boost::function< std::vector< arguments_t >(const argument_t &, const double)> triplefunction;211 double saturation_cutoff;212 213 209 //!> static definitions of the parameter name for this potential 214 210 static const ParameterNames_t ParameterNames;
Note:
See TracChangeset
for help on using the changeset viewer.