Ignore:
Timestamp:
Apr 2, 2009, 4:12:54 PM (17 years ago)
Author:
Frederik Heber <heber@…>
Children:
3021d93
Parents:
451d7a
Message:

Basic implementation of Multiple molecules.

builder.cpp:

molecules.hpp:

moleculelist.cpp:

  • replaced listofmolecules array by STL list everywhere (only smaller changes necessary)
  • new merging function: SimpleMerge, SimpleAdd, SimpleMultiMerge, SimpleMultiAdd, (EmbedMerge, ScatterMerge ... both not finished). Add does not while merge does delete the src molecules.
  • new function: Enumerate(). Output of all molecules with number of atoms and chemical formula
  • new function: NumberOfActiveMolecules(). Counts the number of molecules in the list with ActiveFlag set.
  • new function: insert(). Inserts a molecule into the list with a unique index

molecules.cpp:

  • new function: SetNameFromFilename. Takes basename of a filename and sets name accordingly.
  • new function: UnlinkAtom. Only removes atom from list, does not delete it from memory.

atom.cpp:

  • Output() also accepts specific comment instead of "# molecule nr ..."
File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/molecules.hpp

    r451d7a rc830e8e  
    6868#define DistanceMultiMap multimap <double, pair < PointMap::iterator, PointMap::iterator> >
    6969#define DistanceMultiMapPair pair <double, pair < PointMap::iterator, PointMap::iterator> >
     70
     71#define MoleculeList list <molecule *>
     72#define MoleculeListTest pair <MoleculeList::iterator, bool>
    7073
    7174/******************************** Some small functions and/or structures **********************************/
     
    142145        ~atom();
    143146
    144         bool Output(int ElementNo, int AtomNo, ofstream *out) const;
     147        bool Output(int ElementNo, int AtomNo, ofstream *out, const char *comment = NULL) const;
    145148        bool OutputXYZLine(ofstream *out) const;
    146149        atom *GetTrueFather();
     
    216219                int NoCyclicBonds;      //!< number of cyclic bonds in molecule, by DepthFirstSearchAnalysis()
    217220                double BondDistance;    //!< typical bond distance used in CreateAdjacencyList() and furtheron
     221                bool ActiveFlag;    //!< in a MoleculeListClass used to discern active from inactive molecules
     222                Vector Center;      //!< Center of molecule in a global box
     223                char name[MAXSTRINGSIZE];         //!< arbitrary name
     224                int IndexNr;        //!< index of molecule in a MoleculeListClass
    218225
    219226        molecule(periodentafel *teil);
     
    223230        bool AddAtom(atom *pointer);
    224231        bool RemoveAtom(atom *pointer);
     232        bool UnlinkAtom(atom *pointer);
    225233        bool CleanupMolecule();
    226234
     
    252260        Vector * DetermineCenterOfGravity(ofstream *out);
    253261        Vector * DetermineCenterOfAll(ofstream *out);
     262        void SetNameFromFilename(char *filename);
    254263        void SetBoxDimension(Vector *dim);
    255264        double * ReturnFullMatrixforSymmetric(double *cell_size);
     
    326335class MoleculeListClass {
    327336        public:
    328                 molecule **ListOfMolecules;      //!< pointer list of fragment molecules to check for equality
    329                 int NumberOfMolecules;                          //!< Number of entries in \a **FragmentList and of to be returned one.
    330                 int NumberOfTopAtoms;                            //!< Number of atoms in the molecule from which all fragments originate
     337          MoleculeList ListOfMolecules; //!< List of the contained molecules
     338          int MaxIndex;
    331339
    332340        MoleculeListClass();
    333         MoleculeListClass(int Num, int NumAtoms);
    334341        ~MoleculeListClass();
    335342
    336         /// Output configs.
    337343        bool AddHydrogenCorrection(ofstream *out, char *path);
    338344        bool StoreForcesFile(ofstream *out, char *path, int *SortIndex);
     345        bool insert(molecule *mol);
     346        molecule * ReturnIndex(int index);
    339347        bool OutputConfigForListOfFragments(ofstream *out, config *configuration, int *SortIndex);
     348        int NumberOfActiveMolecules();
     349        void Enumerate(ofstream *out);
    340350        void Output(ofstream *out);
     351
     352        // merging of molecules
     353  bool SimpleMerge(molecule *mol, molecule *srcmol);
     354  bool SimpleAdd(molecule *mol, molecule *srcmol);
     355  bool SimpleMultiMerge(molecule *mol, int *src, int N);
     356  bool SimpleMultiAdd(molecule *mol, int *src, int N);
     357  bool ScatterMerge(molecule *mol, int *src, int N);
     358  bool EmbedMerge(molecule *mol, molecule *srcmol);
    341359
    342360        private:
     
    454472        bool Save(const char *filename, periodentafel *periode, molecule *mol) const;
    455473        bool SaveMPQC(const char *filename, molecule *mol) const;
    456         void Edit(molecule *mol);
     474        void Edit();
    457475        bool GetIsAngstroem() const;
    458476        char *GetDefaultPath() const;
Note: See TracChangeset for help on using the changeset viewer.