Changeset d67150


Ignore:
Timestamp:
Apr 8, 2009, 11:27:50 AM (16 years ago)
Author:
Frederik Heber <heber@…>
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
Message:

Lots of bugfixes, some name changes and new functions

BUGFIX:

  • molecule::molecule did not initialise IndexNr and ActiveFlag
  • molecule::SetNameFromFilename() was missing terminal \0 at end of constructed name
  • molecule::CenterInBox() translates and zeros Center
  • molecule::CenterEdge() also zeros Center
  • molecule::CenterOrigin(): dropped parameter *center as molecule::Center is now used, translated and center then set to zero

Changes:

New:

  • molecule:CenterAtVector() adds given vector to molecule::Center
Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/molecules.cpp

    r3af1f0 rd67150  
    6363        cell_size[1] = cell_size[3] = cell_size[4]= 0.;
    6464        strcpy(name,"none");
     65        IndexNr  = -1;
     66        ActiveFlag = false;
    6567};
    6668
     
    602604 * \param *filename filename
    603605 */
    604 void molecule::SetNameFromFilename(char *filename)
     606void molecule::SetNameFromFilename(const char *filename)
    605607{
    606608  int length = 0;
    607609  char *molname = strrchr(filename, '/')+sizeof(char);  // search for filename without dirs
    608   char *endname = strrchr(filename, '.');
     610  char *endname = strchr(molname, '.');
    609611  if ((endname == NULL) || (endname < molname))
    610612    length = strlen(molname);
     
    612614    length = strlen(molname) - strlen(endname);
    613615  strncpy(name, molname, length);
     616  name[length]='\0';
    614617};
    615618
     
    667670                max->AddVector(BoxLengths);
    668671                max->Scale(0.5);
    669                 Translate(max);
     672    Translate(max);
     673    Center.Zero();
    670674        }
    671675
     
    707711                max->AddVector(min);
    708712                Translate(min);
     713                Center.Zero();
    709714        }
    710715        delete(min);
     
    716721 * \param *center return vector for translation vector
    717722 */
    718 void molecule::CenterOrigin(ofstream *out, Vector *center)
     723void molecule::CenterOrigin(ofstream *out)
    719724{
    720725        int Num = 0;
    721726        atom *ptr = start->next;        // start at first in list
    722727
    723         for(int i=NDIM;i--;) // zero center vector
    724                 center->x[i] = 0.;
     728        Center.Zero();
    725729
    726730        if (ptr != end) {        //list not empty?
     
    728732                        ptr = ptr->next;
    729733                        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();
    734739        }
    735740};
     
    796801 * \param *center return vector for translation vector
    797802 */
    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         }
     803void 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 */
     812void molecule::CenterAtVector(ofstream *out, Vector *newcenter)
     813{
     814  Center.CopyVector(newcenter);
    807815};
    808816
     
    853861
    854862/** Determines center of molecule (yet not considering atom masses).
    855  * \param Center reference to return vector
    856  */
    857 void molecule::DetermineCenter(Vector &Center)
     863 * \param center reference to return vector
     864 */
     865void molecule::DeterminePeriodicCenter(Vector &center)
    858866{
    859867        atom *Walker = start;
     
    865873
    866874        do {
    867                 Center.Zero();
     875                center.Zero();
    868876                flag = true;
    869877                while (Walker->next != end) {
     
    892900                                Testvector.AddVector(&Translationvector);
    893901                                Testvector.MatrixMultiplication(matrix);
    894                                 Center.AddVector(&Testvector);
     902                                center.AddVector(&Testvector);
    895903                                cout << Verbose(1) << "vector is: ";
    896904                                Testvector.Output((ofstream *)&cout);
     
    905913                                                Testvector.AddVector(&Translationvector);
    906914                                                Testvector.MatrixMultiplication(matrix);
    907                                                 Center.AddVector(&Testvector);
     915                                                center.AddVector(&Testvector);
    908916                                                cout << Verbose(1) << "Hydrogen vector is: ";
    909917                                                Testvector.Output((ofstream *)&cout);
     
    916924        } while (!flag);
    917925        Free((void **)&matrix, "molecule::DetermineCenter: *matrix");
    918         Center.Scale(1./(double)AtomCount);
     926        center.Scale(1./(double)AtomCount);
    919927};
    920928
     
    929937        Vector *CenterOfGravity = DetermineCenterOfGravity(out);
    930938
    931         CenterGravity(out, CenterOfGravity);
     939        CenterAtVector(out, CenterOfGravity);
    932940
    933941        // reset inertia tensor
     
    44944502        if (result) {
    44954503                *out << Verbose(5) << "Calculating Centers of Gravity" << endl;
    4496                 DetermineCenter(CenterOfGravity);
    4497                 OtherMolecule->DetermineCenter(OtherCenterOfGravity);
     4504                DeterminePeriodicCenter(CenterOfGravity);
     4505                OtherMolecule->DeterminePeriodicCenter(OtherCenterOfGravity);
    44984506                *out << Verbose(5) << "Center of Gravity: ";
    44994507                CenterOfGravity.Output(out);
  • src/molecules.hpp

    r3af1f0 rd67150  
    251251        bool CenterInBox(ofstream *out, Vector *BoxLengths);
    252252        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);
    255256        void Translate(const Vector *x);
    256257        void Mirror(const Vector *x);
    257258        void Align(Vector *n);
    258259        void Scale(double **factor);
    259         void DetermineCenter(Vector &center);
     260        void DeterminePeriodicCenter(Vector &center);
    260261        Vector * DetermineCenterOfGravity(ofstream *out);
    261262        Vector * DetermineCenterOfAll(ofstream *out);
    262         void SetNameFromFilename(char *filename);
     263        void SetNameFromFilename(const char *filename);
    263264        void SetBoxDimension(Vector *dim);
    264265        double * ReturnFullMatrixforSymmetric(double *cell_size);
Note: See TracChangeset for help on using the changeset viewer.