Changeset 21c017 for src/molecules.cpp
- Timestamp:
- Jul 10, 2009, 12:48:05 PM (16 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:
- 5466f3
- Parents:
- a37350
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecules.cpp
ra37350 r21c017 629 629 /** Centers the molecule in the box whose lengths are defined by vector \a *BoxLengths. 630 630 * \param *out output stream for debugging 631 * \param *BoxLengths box lengths 632 */ 633 bool molecule::CenterInBox(ofstream *out, Vector *BoxLengths) 631 */ 632 bool molecule::CenterInBox(ofstream *out) 634 633 { 635 634 bool status = true; 636 635 atom *ptr = NULL; 637 Vector *min = new Vector; 638 Vector *max = new Vector; 639 640 // gather min and max for each axis 641 ptr = start->next; // start at first in list 642 if (ptr != end) { //list not empty? 643 for (int i=NDIM;i--;) { 644 max->x[i] = ptr->x.x[i]; 645 min->x[i] = ptr->x.x[i]; 646 } 647 while (ptr->next != end) { // continue with second if present 648 ptr = ptr->next; 649 //ptr->Output(1,1,out); 650 for (int i=NDIM;i--;) { 651 max->x[i] = (max->x[i] < ptr->x.x[i]) ? ptr->x.x[i] : max->x[i]; 652 min->x[i] = (min->x[i] > ptr->x.x[i]) ? ptr->x.x[i] : min->x[i]; 653 } 654 } 655 } 656 // sanity check 657 for(int i=NDIM;i--;) { 658 if (max->x[i] - min->x[i] > BoxLengths->x[i]) 659 status = false; 660 } 661 // warn if check failed 662 if (!status) 663 *out << "WARNING: molecule is bigger than defined box!" << endl; 664 else { // else center in box 665 max->AddVector(min); 666 max->Scale(-1.); 667 max->AddVector(BoxLengths); 668 max->Scale(0.5); 669 Translate(max); 670 } 671 672 // free and exit 673 delete(min); 674 delete(max); 636 Vector x; 637 double *M = ReturnFullMatrixforSymmetric(cell_size); 638 double *Minv = x.InverseMatrix(M); 639 double value; 640 641 // cout << "The box matrix is :" << endl; 642 // for (int i=0;i<NDIM;++i) { 643 // for (int j=0;j<NDIM;++j) 644 // cout << M[i*NDIM+j] << "\t"; 645 // cout << endl; 646 // } 647 // cout << "And its inverse is :" << endl; 648 // for (int i=0;i<NDIM;++i) { 649 // for (int j=0;j<NDIM;++j) 650 // cout << Minv[i*NDIM+j] << "\t"; 651 // cout << endl; 652 // } 653 // go through all atoms 654 ptr = start->next; // start at first in list 655 if (ptr != end) { //list not empty? 656 while (ptr->next != end) { // continue with second if present 657 ptr = ptr->next; 658 //ptr->Output(1,1,out); 659 // multiply its vector with matrix inverse 660 x.CopyVector(&ptr->x); 661 x.MatrixMultiplication(Minv); 662 // truncate to [0,1] for each axis 663 for (int i=0;i<NDIM;i++) { 664 value = floor(x.x[i]); // next lower integer 665 if (x.x[i] >=0) { 666 x.x[i] -= value; 667 } else { 668 x.x[i] += value+1; 669 } 670 } 671 // matrix multiply 672 x.MatrixMultiplication(M); 673 ptr->x.CopyVector(&x); 674 } 675 } 676 delete(M); 677 delete(Minv); 675 678 return status; 676 679 }; … … 836 839 } 837 840 }; 841 842 /** Translate the molecule periodically in the box. 843 * \param trans[] translation vector. 844 */ 845 void molecule::TranslatePeriodically(const Vector *trans) 846 { 847 atom *ptr = NULL; 848 Vector x; 849 double *M = ReturnFullMatrixforSymmetric(cell_size); 850 double *Minv = x.InverseMatrix(M); 851 double value; 852 853 // go through all atoms 854 ptr = start->next; // start at first in list 855 if (ptr != end) { //list not empty? 856 while (ptr->next != end) { // continue with second if present 857 ptr = ptr->next; 858 //ptr->Output(1,1,out); 859 // multiply its vector with matrix inverse 860 x.CopyVector(&ptr->x); 861 x.Translate(trans); 862 x.MatrixMultiplication(Minv); 863 // truncate to [0,1] for each axis 864 for (int i=0;i<NDIM;i++) { 865 value = floor(fabs(x.x[i])); // next lower integer 866 if (x.x[i] >=0) { 867 x.x[i] -= value; 868 } else { 869 x.x[i] += value+1; 870 } 871 } 872 // matrix multiply 873 x.MatrixMultiplication(M); 874 ptr->x.CopyVector(&x); 875 for (int j=0;j<MDSteps;j++) { 876 x.CopyVector(&Trajectories[ptr].R.at(j)); 877 x.Translate(trans); 878 x.MatrixMultiplication(Minv); 879 // truncate to [0,1] for each axis 880 for (int i=0;i<NDIM;i++) { 881 value = floor(x.x[i]); // next lower integer 882 if (x.x[i] >=0) { 883 x.x[i] -= value; 884 } else { 885 x.x[i] += value+1; 886 } 887 } 888 // matrix multiply 889 x.MatrixMultiplication(M); 890 Trajectories[ptr].R.at(j).CopyVector(&x); 891 } 892 } 893 } 894 delete(M); 895 delete(Minv); 896 }; 897 838 898 839 899 /** Mirrors all atoms against a given plane. … … 4130 4190 matrix[0] = symm[0]; 4131 4191 matrix[1] = symm[1]; 4132 matrix[2] = symm[ 3];4192 matrix[2] = symm[2]; 4133 4193 matrix[3] = symm[1]; 4134 matrix[4] = symm[ 2];4194 matrix[4] = symm[3]; 4135 4195 matrix[5] = symm[4]; 4136 matrix[6] = symm[ 3];4196 matrix[6] = symm[2]; 4137 4197 matrix[7] = symm[4]; 4138 4198 matrix[8] = symm[5];
Note:
See TracChangeset
for help on using the changeset viewer.