source: molecuilder/src/atom.hpp@ 872b51

Last change on this file since 872b51 was 872b51, checked in by Frederik Heber <heber@…>, 16 years ago

Huge refactoring: molecule::ListOfBondsPerAtom and molecule::NumberOfBondsPerAtom removed, atom::ListOfBonds introduced. Unit Test for ListOfBonds manipulation introduced.

  • changes to builder.cpp: removed CreateListOfBondsPerAtom() calls, as the creation of the global arrays is not necessary anymore
  • changes to LinkedCell: LinkedCell::CheckBounds(int[NDIM]) does not admonish out of bonds as this is not desired for the local offset which may become out of bounds.
  • changes to lists.hpp templates: BUGFIX: unlink() now sets ->next and ->previous to NULL, cleanup() uses removedwithoutcheck()
  • new templates for molecule.hpp: SumPerAtom() allows for summation of the return value of atom:...() member fiunctions. This is needed e.g. for atom::CorrectBondDegree()

Signed-off-by: Frederik Heber <heber@…>

  • Property mode set to 100644
File size: 5.1 KB
Line 
1/*
2 * atom.hpp
3 *
4 * Created on: Aug 3, 2009
5 * Author: heber
6 */
7
8#ifndef ATOM_HPP_
9#define ATOM_HPP_
10
11using namespace std;
12
13/*********************************************** includes ***********************************/
14
15// include config.h
16#ifdef HAVE_CONFIG_H
17#include <config.h>
18#endif
19
20#include <iostream>
21#include <list>
22#include <vector>
23
24#include <gsl/gsl_randist.h>
25
26#include "tesselation.hpp"
27
28/****************************************** forward declarations *****************************/
29
30class bond;
31class config;
32class element;
33class ForceMatrix;
34class Vector;
35
36#define BondList list<bond *>
37
38/********************************************** declarations *******************************/
39
40/** Single atom.
41 * Class incorporates position, type
42 */
43class atom : public TesselPoint {
44 public:
45 struct
46 {
47 vector<Vector> R; //!< position vector
48 vector<Vector> U; //!< velocity vector
49 vector<Vector> F; //!< last force vector
50 } Trajectory;
51
52 Vector x; //!< coordinate vector of atom, giving last position within cell
53 Vector v; //!< velocity vector of atom, giving last velocity within cell
54 Vector F; //!< Force vector of atom, giving last force within cell
55 BondList ListOfBonds; //!< list of all bonds
56 element *type; //!< pointing to element
57 atom *previous; //!< previous atom in molecule list
58 atom *next; //!< next atom in molecule list
59 atom *father; //!< In many-body bond order fragmentations points to originating atom
60 atom *Ancestor; //!< "Father" in Depth-First-Search
61 //char *Name; //!< unique name used during many-body bond-order fragmentation, comes from TesselPoint
62 int FixedIon; //!< config variable that states whether forces act on the ion or not
63 int *sort; //!< sort criteria
64 //int nr; //!< continuous, unique number, comes from TesselPoint
65 int GraphNr; //!< unique number, given in DepthFirstSearchAnalysis()
66 int *ComponentNr;//!< belongs to this nonseparable components, given in DepthFirstSearchAnalysis() (if more than one, then is SeparationVertex)
67 int LowpointNr; //!< needed in DepthFirstSearchAnalysis() to detect nonseparable components, is the lowest possible number of an atom to reach via tree edges only followed by at most one back edge.
68 bool SeparationVertex; //!< whether this atom separates off subsets of atoms or not, determined in DepthFirstSearchAnalysis()
69 bool IsCyclic; //!< whether atom belong to as cycle or not, determined in DepthFirstSearchAnalysis()
70 unsigned char AdaptiveOrder; //!< current present bond order at site (0 means "not set")
71 bool MaxOrder; //!< whether this atom as a root in fragmentation still creates more fragments on higher orders or not
72
73 atom();
74 atom(class atom *pointer);
75 virtual ~atom();
76
77 bool Output(ofstream *out, int ElementNo, int AtomNo, const char *comment = NULL) const;
78 bool Output(ofstream *out, int *ElementNo, int *AtomNo, const char *comment = NULL);
79 bool OutputXYZLine(ofstream *out) const;
80 bool OutputTrajectory(ofstream *out, int *ElementNo, int *AtomNo, int step) const;
81 bool OutputTrajectoryXYZ(ofstream *out, int step) const;
82 bool OutputBondOfAtom(ofstream *out) const;
83 void OutputAdjacency(ofstream *AdjacencyFile) const;
84
85
86 void EqualsFather ( atom *ptr, atom **res );
87 void CorrectFather();
88 atom *GetTrueFather();
89 bool Compare(const atom &ptr);
90
91 // trajectory stuff
92 void ResizeTrajectory(int MaxSteps);
93 void CopyStepOnStep(int dest, int src);
94 void VelocityVerletUpdate(int MDSteps, config *configuration, ForceMatrix *Force);
95 void SumUpKineticEnergy( int Step, double *TotalMass, Vector *TotalVelocity );
96
97 double DistanceToVector(Vector &origin);
98 double DistanceSquaredToVector(Vector &origin);
99
100 bool IsInParallelepiped(Vector offset, double *parallelepiped);
101
102 // bond order stuff
103 void OutputOrder(ofstream *file);
104 void OutputGraphInfo(ofstream *out) const;
105 void OutputComponentNumber(ofstream *out) const;
106 int CountBonds() const;
107 int CorrectBondDegree(ofstream *out);
108
109 bool RegisterBond(bond *Binder);
110 bool UnregisterBond(bond *Binder);
111 void UnregisterAllBond();
112
113 // constraint potential and dynamics stuff
114 void AddKineticToTemperature(double *temperature, int step) const;
115 void EvaluateConstrainedForce(int startstep, int endstep, atom **PermutationMap, ForceMatrix *Force);
116 void CorrectVelocity(double *ActualTemp, int Step, Vector *CoGVelocity);
117
118 // thermostats
119 void Thermostat_Woodcock(double ScaleTempFactor, int Step, double *ekin);
120 void Thermostat_Gaussian_init(int Step, double *G, double *E);
121 void Thermostat_Gaussian_least_constraint(int Step, double G_over_E, double *ekin, config *configuration);
122 void Thermostat_Langevin(int Step, gsl_rng * r, double *ekin, config *configuration);
123 void Thermostat_Berendsen(int Step, double ScaleTempFactor, double *ekin, config *configuration);
124 void Thermostat_NoseHoover_init(int Step, double *delta_alpha);
125 void Thermostat_NoseHoover_scale(int Step, double *ekin, config *configuration);
126
127
128 ostream & operator << (ostream &ost);
129
130 private:
131};
132
133ostream & operator << (ostream &ost, const atom &a);
134
135#endif /* ATOM_HPP_ */
Note: See TracBrowser for help on using the repository browser.