Changeset d67150
- Timestamp:
- Apr 8, 2009, 11:27:50 AM (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:
- 63f06e
- Parents:
- 3af1f0
- Location:
- src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecules.cpp
r3af1f0 rd67150 63 63 cell_size[1] = cell_size[3] = cell_size[4]= 0.; 64 64 strcpy(name,"none"); 65 IndexNr = -1; 66 ActiveFlag = false; 65 67 }; 66 68 … … 602 604 * \param *filename filename 603 605 */ 604 void molecule::SetNameFromFilename(c har *filename)606 void molecule::SetNameFromFilename(const char *filename) 605 607 { 606 608 int length = 0; 607 609 char *molname = strrchr(filename, '/')+sizeof(char); // search for filename without dirs 608 char *endname = str rchr(filename, '.');610 char *endname = strchr(molname, '.'); 609 611 if ((endname == NULL) || (endname < molname)) 610 612 length = strlen(molname); … … 612 614 length = strlen(molname) - strlen(endname); 613 615 strncpy(name, molname, length); 616 name[length]='\0'; 614 617 }; 615 618 … … 667 670 max->AddVector(BoxLengths); 668 671 max->Scale(0.5); 669 Translate(max); 672 Translate(max); 673 Center.Zero(); 670 674 } 671 675 … … 707 711 max->AddVector(min); 708 712 Translate(min); 713 Center.Zero(); 709 714 } 710 715 delete(min); … … 716 721 * \param *center return vector for translation vector 717 722 */ 718 void molecule::CenterOrigin(ofstream *out , Vector *center)723 void molecule::CenterOrigin(ofstream *out) 719 724 { 720 725 int Num = 0; 721 726 atom *ptr = start->next; // start at first in list 722 727 723 for(int i=NDIM;i--;) // zero center vector 724 center->x[i] = 0.; 728 Center.Zero(); 725 729 726 730 if (ptr != end) { //list not empty? … … 728 732 ptr = ptr->next; 729 733 Num++; 730 center->AddVector(&ptr->x); 731 } 732 center->Scale(-1./Num); // divide through total number (and sign for direction) 733 Translate(center); 734 Center.AddVector(&ptr->x); 735 } 736 Center.Scale(-1./Num); // divide through total number (and sign for direction) 737 Translate(&Center); 738 Center.Zero(); 734 739 } 735 740 }; … … 796 801 * \param *center return vector for translation vector 797 802 */ 798 void molecule::CenterGravity(ofstream *out, Vector *center) 799 { 800 if (center == NULL) { 801 DetermineCenter(*center); 802 Translate(center); 803 delete(center); 804 } else { 805 Translate(center); 806 } 803 void molecule::CenterPeriodic(ofstream *out) 804 { 805 DeterminePeriodicCenter(Center); 806 }; 807 808 /** Centers the center of gravity of the atoms at (0,0,0). 809 * \param *out output stream for debugging 810 * \param *center return vector for translation vector 811 */ 812 void molecule::CenterAtVector(ofstream *out, Vector *newcenter) 813 { 814 Center.CopyVector(newcenter); 807 815 }; 808 816 … … 853 861 854 862 /** Determines center of molecule (yet not considering atom masses). 855 * \param Center reference to return vector856 */ 857 void molecule::Determine Center(Vector &Center)863 * \param center reference to return vector 864 */ 865 void molecule::DeterminePeriodicCenter(Vector ¢er) 858 866 { 859 867 atom *Walker = start; … … 865 873 866 874 do { 867 Center.Zero();875 center.Zero(); 868 876 flag = true; 869 877 while (Walker->next != end) { … … 892 900 Testvector.AddVector(&Translationvector); 893 901 Testvector.MatrixMultiplication(matrix); 894 Center.AddVector(&Testvector);902 center.AddVector(&Testvector); 895 903 cout << Verbose(1) << "vector is: "; 896 904 Testvector.Output((ofstream *)&cout); … … 905 913 Testvector.AddVector(&Translationvector); 906 914 Testvector.MatrixMultiplication(matrix); 907 Center.AddVector(&Testvector);915 center.AddVector(&Testvector); 908 916 cout << Verbose(1) << "Hydrogen vector is: "; 909 917 Testvector.Output((ofstream *)&cout); … … 916 924 } while (!flag); 917 925 Free((void **)&matrix, "molecule::DetermineCenter: *matrix"); 918 Center.Scale(1./(double)AtomCount);926 center.Scale(1./(double)AtomCount); 919 927 }; 920 928 … … 929 937 Vector *CenterOfGravity = DetermineCenterOfGravity(out); 930 938 931 Center Gravity(out, CenterOfGravity);939 CenterAtVector(out, CenterOfGravity); 932 940 933 941 // reset inertia tensor … … 4494 4502 if (result) { 4495 4503 *out << Verbose(5) << "Calculating Centers of Gravity" << endl; 4496 Determine Center(CenterOfGravity);4497 OtherMolecule->Determine Center(OtherCenterOfGravity);4504 DeterminePeriodicCenter(CenterOfGravity); 4505 OtherMolecule->DeterminePeriodicCenter(OtherCenterOfGravity); 4498 4506 *out << Verbose(5) << "Center of Gravity: "; 4499 4507 CenterOfGravity.Output(out); -
src/molecules.hpp
r3af1f0 rd67150 251 251 bool CenterInBox(ofstream *out, Vector *BoxLengths); 252 252 void CenterEdge(ofstream *out, Vector *max); 253 void CenterOrigin(ofstream *out, Vector *max); 254 void CenterGravity(ofstream *out, Vector *max); 253 void CenterOrigin(ofstream *out); 254 void CenterPeriodic(ofstream *out); 255 void CenterAtVector(ofstream *out, Vector *newcenter); 255 256 void Translate(const Vector *x); 256 257 void Mirror(const Vector *x); 257 258 void Align(Vector *n); 258 259 void Scale(double **factor); 259 void Determine Center(Vector ¢er);260 void DeterminePeriodicCenter(Vector ¢er); 260 261 Vector * DetermineCenterOfGravity(ofstream *out); 261 262 Vector * DetermineCenterOfAll(ofstream *out); 262 void SetNameFromFilename(c har *filename);263 void SetNameFromFilename(const char *filename); 263 264 void SetBoxDimension(Vector *dim); 264 265 double * ReturnFullMatrixforSymmetric(double *cell_size);
Note:
See TracChangeset
for help on using the changeset viewer.