Changeset d74077 for src/molecule_geometry.cpp
- Timestamp:
- Jul 31, 2010, 3:23:10 PM (15 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:
- 8f4df1
- Parents:
- 5fbaeb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecule_geometry.cpp
r5fbaeb rd74077 45 45 46 46 // go through all atoms 47 ActOnAllVectors( &Vector::SubtractVector, *Center);48 ActOnAllVectors( &Vector::SubtractVector, *CenterBox);49 47 BOOST_FOREACH(atom* iter, atoms){ 50 *iter->node = domain.WrapPeriodically(*iter->node); 48 *iter -= *Center; 49 *iter -= *CenterBox; 50 iter->setPosition(domain.WrapPeriodically(iter->getPosition())); 51 51 } 52 52 … … 67 67 // go through all atoms 68 68 BOOST_FOREACH(atom* iter, atoms){ 69 *iter->node = domain.WrapPeriodically(*iter->node);69 iter->setPosition(domain.WrapPeriodically(iter->getPosition())); 70 70 } 71 71 … … 85 85 if (iter != end()) { //list not empty? 86 86 for (int i=NDIM;i--;) { 87 max->at(i) = (*iter)-> x[i];88 min->at(i) = (*iter)-> x[i];87 max->at(i) = (*iter)->at(i); 88 min->at(i) = (*iter)->at(i); 89 89 } 90 90 for (; iter != end(); ++iter) {// continue with second if present 91 91 //(*iter)->Output(1,1,out); 92 92 for (int i=NDIM;i--;) { 93 max->at(i) = (max->at(i) < (*iter)-> x[i]) ? (*iter)->x[i]: max->at(i);94 min->at(i) = (min->at(i) > (*iter)-> x[i]) ? (*iter)->x[i]: min->at(i);93 max->at(i) = (max->at(i) < (*iter)->at(i)) ? (*iter)->at(i) : max->at(i); 94 min->at(i) = (min->at(i) > (*iter)->at(i)) ? (*iter)->at(i) : min->at(i); 95 95 } 96 96 } … … 123 123 for (; iter != end(); ++iter) { // continue with second if present 124 124 Num++; 125 Center += (*iter)-> x;125 Center += (*iter)->getPosition(); 126 126 } 127 127 Center.Scale(-1./(double)Num); // divide through total number (and sign for direction) … … 145 145 for (; iter != end(); ++iter) { // continue with second if present 146 146 Num++; 147 (*a) += (*iter)-> x;147 (*a) += (*iter)->getPosition(); 148 148 } 149 149 a->Scale(1./(double)Num); // divide through total mass (and sign for direction) … … 178 178 if (iter != end()) { //list not empty? 179 179 for (; iter != end(); ++iter) { // continue with second if present 180 Num += (*iter)-> type->mass;181 tmp = (*iter)-> type->mass * (*iter)->x;180 Num += (*iter)->getType()->mass; 181 tmp = (*iter)->getType()->mass * (*iter)->getPosition(); 182 182 (*a) += tmp; 183 183 } … … 223 223 for (int j=0;j<MDSteps;j++) 224 224 (*iter)->Trajectory.R.at(j).ScaleAll(*factor); 225 (*iter)-> x.ScaleAll(*factor);225 (*iter)->ScaleAll(*factor); 226 226 } 227 227 }; … … 235 235 for (int j=0;j<MDSteps;j++) 236 236 (*iter)->Trajectory.R.at(j) += (*trans); 237 (*iter)->x+= (*trans);237 *(*iter) += (*trans); 238 238 } 239 239 }; … … 248 248 249 249 // go through all atoms 250 ActOnAllVectors( &Vector::AddVector, *trans);251 250 BOOST_FOREACH(atom* iter, atoms){ 252 *iter->node = domain.WrapPeriodically(*iter->node); 251 *iter += *trans; 252 iter->setPosition(domain.WrapPeriodically(iter->getPosition())); 253 253 } 254 254 … … 264 264 Plane p(*n,0); 265 265 BOOST_FOREACH(atom* iter, atoms ){ 266 (*iter->node) = p.mirrorVector(*iter->node);266 iter->setPosition(p.mirrorVector(iter->getPosition())); 267 267 } 268 268 }; … … 284 284 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 285 285 #ifdef ADDHYDROGEN 286 if ((*iter)-> type->Z != 1) {286 if ((*iter)->getType()->Z != 1) { 287 287 #endif 288 Testvector = inversematrix * (*iter)-> x;288 Testvector = inversematrix * (*iter)->getPosition(); 289 289 Translationvector.Zero(); 290 290 for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) { 291 291 if ((*iter)->nr < (*Runner)->GetOtherAtom((*iter))->nr) // otherwise we shift one to, the other fro and gain nothing 292 292 for (int j=0;j<NDIM;j++) { 293 tmp = (*iter)-> x[j] - (*Runner)->GetOtherAtom(*iter)->x[j];293 tmp = (*iter)->at(j) - (*Runner)->GetOtherAtom(*iter)->at(j); 294 294 if ((fabs(tmp)) > BondDistance) { 295 295 flag = false; … … 309 309 // now also change all hydrogens 310 310 for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) { 311 if ((*Runner)->GetOtherAtom((*iter))-> type->Z == 1) {312 Testvector = inversematrix * (*Runner)->GetOtherAtom((*iter))-> x;311 if ((*Runner)->GetOtherAtom((*iter))->getType()->Z == 1) { 312 Testvector = inversematrix * (*Runner)->GetOtherAtom((*iter))->getPosition(); 313 313 Testvector += Translationvector; 314 314 Testvector *= matrix; … … 343 343 // sum up inertia tensor 344 344 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 345 Vector x = (*iter)-> x;345 Vector x = (*iter)->getPosition(); 346 346 //x.SubtractVector(CenterOfGravity); 347 InertiaTensor[0] += (*iter)-> type->mass*(x[1]*x[1] + x[2]*x[2]);348 InertiaTensor[1] += (*iter)-> type->mass*(-x[0]*x[1]);349 InertiaTensor[2] += (*iter)-> type->mass*(-x[0]*x[2]);350 InertiaTensor[3] += (*iter)-> type->mass*(-x[1]*x[0]);351 InertiaTensor[4] += (*iter)-> type->mass*(x[0]*x[0] + x[2]*x[2]);352 InertiaTensor[5] += (*iter)-> type->mass*(-x[1]*x[2]);353 InertiaTensor[6] += (*iter)-> type->mass*(-x[2]*x[0]);354 InertiaTensor[7] += (*iter)-> type->mass*(-x[2]*x[1]);355 InertiaTensor[8] += (*iter)-> type->mass*(x[0]*x[0] + x[1]*x[1]);347 InertiaTensor[0] += (*iter)->getType()->mass*(x[1]*x[1] + x[2]*x[2]); 348 InertiaTensor[1] += (*iter)->getType()->mass*(-x[0]*x[1]); 349 InertiaTensor[2] += (*iter)->getType()->mass*(-x[0]*x[2]); 350 InertiaTensor[3] += (*iter)->getType()->mass*(-x[1]*x[0]); 351 InertiaTensor[4] += (*iter)->getType()->mass*(x[0]*x[0] + x[2]*x[2]); 352 InertiaTensor[5] += (*iter)->getType()->mass*(-x[1]*x[2]); 353 InertiaTensor[6] += (*iter)->getType()->mass*(-x[2]*x[0]); 354 InertiaTensor[7] += (*iter)->getType()->mass*(-x[2]*x[1]); 355 InertiaTensor[8] += (*iter)->getType()->mass*(x[0]*x[0] + x[1]*x[1]); 356 356 } 357 357 // print InertiaTensor for debugging … … 383 383 // the eigenvectors specify the transformation matrix 384 384 Matrix M = Matrix(evec->data); 385 Vector tempVector; 385 386 BOOST_FOREACH(atom* iter, atoms){ 386 (*iter->node) *= M; 387 tempVector = iter->getPosition(); 388 tempVector *= M; 389 iter->setPosition(tempVector); 387 390 } 388 391 DoLog(0) && (Log() << Verbose(0) << "done." << endl); … … 395 398 // sum up inertia tensor 396 399 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 397 Vector x = (*iter)-> x;398 InertiaTensor[0] += (*iter)-> type->mass*(x[1]*x[1] + x[2]*x[2]);399 InertiaTensor[1] += (*iter)-> type->mass*(-x[0]*x[1]);400 InertiaTensor[2] += (*iter)-> type->mass*(-x[0]*x[2]);401 InertiaTensor[3] += (*iter)-> type->mass*(-x[1]*x[0]);402 InertiaTensor[4] += (*iter)-> type->mass*(x[0]*x[0] + x[2]*x[2]);403 InertiaTensor[5] += (*iter)-> type->mass*(-x[1]*x[2]);404 InertiaTensor[6] += (*iter)-> type->mass*(-x[2]*x[0]);405 InertiaTensor[7] += (*iter)-> type->mass*(-x[2]*x[1]);406 InertiaTensor[8] += (*iter)-> type->mass*(x[0]*x[0] + x[1]*x[1]);400 Vector x = (*iter)->getPosition(); 401 InertiaTensor[0] += (*iter)->getType()->mass*(x[1]*x[1] + x[2]*x[2]); 402 InertiaTensor[1] += (*iter)->getType()->mass*(-x[0]*x[1]); 403 InertiaTensor[2] += (*iter)->getType()->mass*(-x[0]*x[2]); 404 InertiaTensor[3] += (*iter)->getType()->mass*(-x[1]*x[0]); 405 InertiaTensor[4] += (*iter)->getType()->mass*(x[0]*x[0] + x[2]*x[2]); 406 InertiaTensor[5] += (*iter)->getType()->mass*(-x[1]*x[2]); 407 InertiaTensor[6] += (*iter)->getType()->mass*(-x[2]*x[0]); 408 InertiaTensor[7] += (*iter)->getType()->mass*(-x[2]*x[1]); 409 InertiaTensor[8] += (*iter)->getType()->mass*(x[0]*x[0] + x[1]*x[1]); 407 410 } 408 411 // print InertiaTensor for debugging … … 439 442 DoLog(1) && (Log() << Verbose(1) << "Z-X-angle: " << alpha << " ... "); 440 443 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 441 tmp = (*iter)-> x[0];442 (*iter)-> x[0] = cos(alpha) * tmp + sin(alpha) * (*iter)->x[2];443 (*iter)-> x[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->x[2];444 tmp = (*iter)->at(0); 445 (*iter)->set(0, cos(alpha) * tmp + sin(alpha) * (*iter)->at(2)); 446 (*iter)->set(2, -sin(alpha) * tmp + cos(alpha) * (*iter)->at(2)); 444 447 for (int j=0;j<MDSteps;j++) { 445 448 tmp = (*iter)->Trajectory.R.at(j)[0]; … … 458 461 DoLog(1) && (Log() << Verbose(1) << "Z-Y-angle: " << alpha << " ... "); 459 462 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 460 tmp = (*iter)-> x[1];461 (*iter)-> x[1] = cos(alpha) * tmp + sin(alpha) * (*iter)->x[2];462 (*iter)-> x[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->x[2];463 tmp = (*iter)->at(1); 464 (*iter)->set(1, cos(alpha) * tmp + sin(alpha) * (*iter)->at(2)); 465 (*iter)->set(2, -sin(alpha) * tmp + cos(alpha) * (*iter)->at(2)); 463 466 for (int j=0;j<MDSteps;j++) { 464 467 tmp = (*iter)->Trajectory.R.at(j)[1]; … … 498 501 // go through all atoms 499 502 for (molecule::const_iterator iter = par->mol->begin(); iter != par->mol->end(); ++iter) { 500 if ((*iter)-> type== ((struct lsq_params *)params)->type) { // for specific type501 c = (*iter)-> x- a;503 if ((*iter)->getType() == ((struct lsq_params *)params)->type) { // for specific type 504 c = (*iter)->getPosition() - a; 502 505 t = c.ScalarProduct(b); // get direction parameter 503 506 d = t*b; // and create vector
Note:
See TracChangeset
for help on using the changeset viewer.