Changeset 698308 for src/Dynamics
- Timestamp:
- Jul 20, 2017, 9:38:38 AM (8 years ago)
- Branches:
- ForceAnnealing_with_BondGraph_continued
- Children:
- 12d20c
- Parents:
- b7fe6e
- git-author:
- Frederik Heber <frederik.heber@…> (06/27/17 21:17:18)
- git-committer:
- Frederik Heber <frederik.heber@…> (07/20/17 09:38:38)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Dynamics/ForceAnnealing.hpp
rb7fe6e r698308 441 441 const double &bondforce = projected_forces[0][side][index]; 442 442 const double &oldbondforce = projected_forces[1][side][index]; 443 const double bondforcedifference = (bondforce - oldbondforce); 443 const double bondforcedifference = fabs(bondforce - oldbondforce); 444 LOG(4, "DEBUG: bondforce for " << (side == leftside ? "left" : "right") 445 << " side of bond is " << bondforce); 446 LOG(4, "DEBUG: oldbondforce for " << (side == leftside ? "left" : "right") 447 << " side of bond is " << oldbondforce); 444 448 // if difference or bondforce itself is zero, do nothing 445 449 if ((fabs(bondforce) < MYEPSILON) || (fabs(bondforcedifference) < MYEPSILON)) 446 450 continue; 451 452 // get BondVector to bond 447 453 const BondVectors::mapped_t::const_iterator bviter = 448 454 bondvectors.find(current_bond); 449 455 ASSERT( bviter != bondvectors.end(), 450 456 "ForceAnnealing() - cannot find current_bond ?"); 457 ASSERT( fabs(bviter->second.Norm() -1.) < MYEPSILON, 458 "ForceAnnealing() - norm of BondVector is not one"); 451 459 const Vector &BondVector = bviter->second; 452 const Vector &oldPosition = bondatom[side]->getPositionAtStep(CurrentTimeStep-1 >= 0 ? CurrentTimeStep - 1 : 0); 453 const Vector ¤tPosition = bondatom[side]->getPosition(); 454 const double stepwidth = 455 fabs((currentPosition - oldPosition).ScalarProduct(BondVector))/bondforcedifference; 456 Vector PositionUpdate = stepwidth * BondVector; 460 461 // calculate gradient and position differences for stepwidth 462 const Vector currentGradient = bondforce * BondVector; 463 LOG(4, "DEBUG: current projected gradient for " 464 << (side == leftside ? "left" : "right") << " side of bond is " << currentGradient); 465 const Vector &oldPosition = bondatom[side]->getPositionAtStep(CurrentTimeStep-2 >= 0 ? CurrentTimeStep - 2 : 0); 466 const Vector ¤tPosition = bondatom[side]->getPositionAtStep(currentStep); 467 const Vector PositionDifference = currentPosition - oldPosition; 468 LOG(4, "DEBUG: old position is " << oldPosition); 469 LOG(4, "DEBUG: current position is " << currentPosition); 470 LOG(4, "DEBUG: difference in position is " << PositionDifference); 471 LOG(4, "DEBUG: abs. difference in forces is " << bondforcedifference); 472 LOG(4, "DEBUG: bondvector is " << BondVector); 473 474 // calculate step width 475 double stepwidth = 476 fabs(PositionDifference.ScalarProduct(BondVector))/bondforcedifference; 457 477 if (fabs(stepwidth) < 1e-10) { 458 478 // dont' warn in first step, deltat usage normal 459 479 if (currentStep != 1) 460 480 ELOG(1, "INFO: Barzilai-Borwein stepwidth is zero, using deltat " << currentDeltat << " instead."); 461 PositionUpdate = currentDeltat * BondVector;481 stepwidth = currentDeltat; 462 482 } 463 LOG(3, "DEBUG: Update would be " << PositionUpdate); 483 Vector PositionUpdate = stepwidth * currentGradient; 484 LOG(3, "DEBUG: Update would be " << stepwidth << "*" << currentGradient << " = " << PositionUpdate); 464 485 465 486 // add PositionUpdate for all nodes in the bondside_set … … 470 491 ASSERT( diter != distance_map[side].end(), 471 492 "ForceAnnealing() - could not find distance to an atom."); 472 const double factor = pow(damping_factor, diter->second );493 const double factor = pow(damping_factor, diter->second+1); 473 494 LOG(3, "DEBUG: Update for atom #" << *setiter << " will be " 474 495 << factor << "*" << PositionUpdate);
Note:
See TracChangeset
for help on using the changeset viewer.