ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/tengDissertation/Appendix.tex
(Generate patch)

Comparing trunk/tengDissertation/Appendix.tex (file contents):
Revision 2881 by tim, Thu Jun 22 22:19:02 2006 UTC vs.
Revision 2882 by tim, Fri Jun 23 21:33:52 2006 UTC

# Line 1 | Line 1
1   \appendix
2   \chapter{\label{chapt:oopse}Object-Oriented Parallel Simulation Engine}
3  
4 < Absence of applying modern software development practices is the
5 < bottleneck of Scientific Computing community\cite{Wilson2006}. In
6 < the last 20 years , there are quite a few MD
7 < packages\cite{Brooks1983, Vincent1995, Kale1999} that were developed
8 < to solve common MD problems and perform robust simulations .
9 < Unfortunately, most of them are commercial programs that are either
10 < poorly written or extremely complicate. Consequently, it prevents
11 < the researchers to reuse or extend those packages to do cutting-edge
12 < research effectively. Along the way of studying structural and
13 < dynamic processes in condensed phase systems like biological
14 < membranes and nanoparticles, we developed an open source
4 > The absence of modern software development practices has been a
5 > bottleneck limiting progress in the Scientific Computing
6 > community\cite{Wilson2006}. In the last 20 years , a large number of
7 > few MD packages\cite{Brooks1983, Vincent1995, Kale1999} were
8 > developed to solve common MD problems and perform robust simulations
9 > . Most of these are commercial programs that are either poorly
10 > written or extremely complicated to use correctly. This situation
11 > prevents researchers from reusing or extending those packages to do
12 > cutting-edge research effectively. In the process of studying
13 > structural and dynamic processes in condensed phase systems like
14 > biological membranes and nanoparticles, we developed an open source
15   Object-Oriented Parallel Simulation Engine ({\sc OOPSE}). This new
16   molecular dynamics package has some unique features
17   \begin{enumerate}
# Line 33 | Line 33 | Mainly written by \texttt{C/C++} and \texttt{Fortran90
33  
34   \section{\label{appendixSection:architecture }Architecture}
35  
36 < Mainly written by \texttt{C/C++} and \texttt{Fortran90}, {\sc OOPSE}
37 < uses C++ Standard Template Library (STL) and fortran modules as the
38 < foundation. As an extensive set of the STL and Fortran90 modules,
39 < {\sc Base Classes} provide generic implementations of mathematical
40 < objects (e.g., matrices, vectors, polynomials, random number
41 < generators) and advanced data structures and algorithms(e.g., tuple,
42 < bitset, generic data, string manipulation). The molecular data
43 < structures for the representation of atoms, bonds, bends, torsions,
44 < rigid bodies and molecules \textit{etc} are contained in the {\sc
45 < Kernel} which is implemented with {\sc Base Classes} and are
46 < carefully designed to provide maximum extensibility and flexibility.
47 < The functionality required for applications is provide by the third
48 < layer which contains Input/Output, Molecular Mechanics and Structure
49 < modules. Input/Output module not only implements general methods for
50 < file handling, but also defines a generic force field interface.
51 < Another important component of Input/Output module is the meta-data
52 < file parser, which is rewritten using ANother Tool for Language
53 < Recognition(ANTLR)\cite{Parr1995, Schaps1999} syntax. The Molecular
54 < Mechanics module consists of energy minimization and a wide
55 < varieties of integration methods(see Chap.~\ref{chapt:methodology}).
56 < The structure module contains a flexible and powerful selection
57 < library which syntax is elaborated in
58 < Sec.~\ref{appendixSection:syntax}. The top layer is made of the main
59 < program of the package, \texttt{oopse} and it corresponding parallel
60 < version \texttt{oopse\_MPI}, as well as other useful utilities, such
61 < as \texttt{StatProps} (see Sec.~\ref{appendixSection:StaticProps}),
62 < \texttt{DynamicProps} (see Sec.~\ref{appendixSection:DynamicProps}),
63 < \texttt{Dump2XYZ} (see Sec.~\ref{appendixSection:Dump2XYZ}),
64 < \texttt{Hydro} (see Sec.~\ref{appendixSection:hydrodynamics})
65 < \textit{etc}.
36 > Mainly written by C++ and Fortran90, {\sc OOPSE} uses C++ Standard
37 > Template Library (STL) and fortran modules as a foundation. As an
38 > extensive set of the STL and Fortran90 modules, {\sc Base Classes}
39 > provide generic implementations of mathematical objects (e.g.,
40 > matrices, vectors, polynomials, random number generators) and
41 > advanced data structures and algorithms(e.g., tuple, bitset, generic
42 > data and string manipulation). The molecular data structures for the
43 > representation of atoms, bonds, bends, torsions, rigid bodies and
44 > molecules \textit{etc} are contained in the {\sc Kernel} which is
45 > implemented with {\sc Base Classes} and are carefully designed to
46 > provide maximum extensibility and flexibility. The functionality
47 > required for applications is provided by the third layer which
48 > contains Input/Output, Molecular Mechanics and Structure modules.
49 > The Input/Output module not only implements general methods for file
50 > handling, but also defines a generic force field interface. Another
51 > important component of Input/Output module is the parser for
52 > meta-data files, which has been implemented using the ANother Tool
53 > for Language Recognition(ANTLR)\cite{Parr1995, Schaps1999} syntax.
54 > The Molecular Mechanics module consists of energy minimization and a
55 > wide varieties of integration methods(see
56 > Chap.~\ref{chapt:methodology}). The structure module contains a
57 > flexible and powerful selection library which syntax is elaborated
58 > in Sec.~\ref{appendixSection:syntax}. The top layer is made of the
59 > main program of the package, \texttt{oopse} and it corresponding
60 > parallel version \texttt{oopse\_MPI}, as well as other useful
61 > utilities, such as \texttt{StatProps} (see
62 > Sec.~\ref{appendixSection:StaticProps}), \texttt{DynamicProps} (see
63 > Sec.~\ref{appendixSection:DynamicProps}), \texttt{Dump2XYZ} (see
64 > Sec.~\ref{appendixSection:Dump2XYZ}), \texttt{Hydro} (see
65 > Sec.~\ref{appendixSection:hydrodynamics}) \textit{etc}.
66  
67   \begin{figure}
68   \centering
# Line 71 | Line 71 | of {\sc OOPSE}} \label{appendixFig:architecture}
71   of {\sc OOPSE}} \label{appendixFig:architecture}
72   \end{figure}
73  
74 < \section{\label{appendixSection:desginPattern}Design Pattern}
74 > \section{\label{appendixSection:desginPattern}Design Patterns}
75  
76   Design patterns are optimal solutions to commonly-occurring problems
77   in software design. Although originated as an architectural concept
# Line 82 | Line 82 | different problems as necessary. Pattern are expressiv
82   the experience, knowledge and insights of developers who have
83   successfully used these patterns in their own work. Patterns are
84   reusable. They provide a ready-made solution that can be adapted to
85 < different problems as necessary. Pattern are expressive. they
86 < provide a common vocabulary of solutions that can express large
87 < solutions succinctly. As one of the latest advanced techniques
88 < emerged from object-oriented community, design patterns were applied
89 < in some of the modern scientific software applications, such as
90 < JMol, {\sc OOPSE}\cite{Meineke2005} and PROTOMOL\cite{Matthey2004}
91 < \textit{etc}. The following sections enumerates some of the patterns
92 < used in {\sc OOPSE}.
85 > different problems as necessary. As one of the latest advanced
86 > techniques to emerge from object-oriented community, design patterns
87 > were applied in some of the modern scientific software applications,
88 > such as JMol, {\sc OOPSE}\cite{Meineke2005} and
89 > PROTOMOL\cite{Matthey2004} \textit{etc}. The following sections
90 > enumerates some of the patterns used in {\sc OOPSE}.
91  
92 < \subsection{\label{appendixSection:singleton}Singleton}
92 > \subsection{\label{appendixSection:singleton}Singletons}
93  
94   The Singleton pattern not only provides a mechanism to restrict
95   instantiation of a class to one object, but also provides a global
96 < point of access to the object. Currently implemented as a global
97 < variable, the logging utility which reports error and warning
98 < messages to the console in {\sc OOPSE} is a good candidate for
99 < applying the Singleton pattern to avoid the global namespace
102 < pollution. Although the singleton pattern can be implemented in
103 < various ways  to account for different aspects of the software
104 < designs, such as lifespan control \textit{etc}, we only use the
105 < static data approach in {\sc OOPSE}. The declaration and
96 > point of access to the object. Although the singleton pattern can be
97 > implemented in various ways  to account for different aspects of the
98 > software designs, such as lifespan control \textit{etc}, we only use
99 > the static data approach in {\sc OOPSE}. The declaration and
100   implementation of IntegratorFactory class are given by declared in
101   List.~\ref{appendixScheme:singletonDeclaration} and
102   Scheme.~\ref{appendixScheme:singletonImplementation} respectively.
103 < Since constructor is declared as protected, a client can not
103 > Since the constructor is declared as protected, a client can not
104   instantiate IntegratorFactory directly. Moreover, since the member
105   function getInstance serves as the only entry of access to
106   IntegratorFactory, this approach fulfills the basic requirement, a
107   single instance. Another consequence of this approach is the
108   automatic destruction since static data are destroyed upon program
109   termination.
110 +
111 + \subsection{\label{appendixSection:factoryMethod}Factory Methods}
112 +
113 + The Factory Method pattern is a creational pattern and deals with
114 + the problem of creating objects without specifying the exact class
115 + of object that will be created. Factory method is typically
116 + implemented by delegating the creation operation to the subclasses.
117 + Parameterized Factory pattern where factory method (
118 + createIntegrator member function) creates products based on the
119 + identifier (see Scheme.~\ref{appendixScheme:factoryDeclaration}). If
120 + the identifier has been already registered, the factory method will
121 + invoke the corresponding creator (see
122 + Scheme.~\ref{appendixScheme:integratorCreator}) which utilizes the
123 + modern C++ template technique to avoid excess subclassing.
124 +
125 + \subsection{\label{appendixSection:visitorPattern}Visitor}
126 +
127 + The visitor pattern is designed to decouple the data structure and
128 + algorithms used upon them by collecting related operation from
129 + element classes into other visitor classes, which is equivalent to
130 + adding virtual functions into a set of classes without modifying
131 + their interfaces. Fig.~\ref{appendixFig:visitorUML} demonstrates the
132 + structure of a Visitor pattern which is used extensively in {\tt
133 + Dump2XYZ}. In order to convert an OOPSE dump file, a series of
134 + distinct operations are performed on different StuntDoubles (See the
135 + class hierarchy in Fig.~\ref{oopseFig:hierarchy} and the declaration
136 + in Scheme.~\ref{appendixScheme:element}). Since the hierarchies
137 + remain stable, it is easy to define a visit operation (see
138 + Scheme.~\ref{appendixScheme:visitor}) for each class of StuntDouble.
139 + Note that using Composite pattern\cite{Gamma1994}, CompositeVisitor
140 + manages a priority visitor list and handles the execution of every
141 + visitor in the priority list on different StuntDoubles.
142 +
143   \begin{lstlisting}[float,caption={[A classic Singleton design pattern implementation(I)] The declaration of of simple Singleton pattern.},label={appendixScheme:singletonDeclaration}]
144  
145 < class IntegratorFactory {
146 < public:
120 <  static IntegratorFactory*
121 <  getInstance();
122 < protected:
145 > class IntegratorFactory { public:
146 >  static IntegratorFactory* getInstance(); protected:
147    IntegratorFactory();
148   private:
149    static IntegratorFactory* instance_;
# Line 140 | Line 164 | IntegratorFactory* getInstance() {
164  
165   \end{lstlisting}
166  
143
144 \subsection{\label{appendixSection:factoryMethod}Factory Method}
145
146 Categoried as a creational pattern, the Factory Method pattern deals
147 with the problem of creating objects without specifying the exact
148 class of object that will be created. Factory Method is typically
149 implemented by delegating the creation operation to the subclasses.
150 Parameterized Factory pattern where factory method (
151 createIntegrator member function) creates products based on the
152 identifier (see Scheme.~\ref{appendixScheme:factoryDeclaration}). If
153 the identifier has been already registered, the factory method will
154 invoke the corresponding creator (see
155 Scheme.~\ref{appendixScheme:integratorCreator}) which utilizes the
156 modern C++ template technique to avoid excess subclassing.
157
167   \begin{lstlisting}[float,caption={[The implementation of Parameterized Factory pattern (I)]Source code of IntegratorFactory class.},label={appendixScheme:factoryDeclaration}]
168  
169 < class IntegratorFactory {
161 < public:
169 > class IntegratorFactory { public:
170    typedef std::map<string, IntegratorCreator*> CreatorMapType;
171  
172    bool registerIntegrator(IntegratorCreator* creator) {
# Line 182 | Line 190 | class IntegratorCreator { (public)
190   \begin{lstlisting}[float,caption={[The implementation of Parameterized Factory pattern (III)]Source code of creator classes.},label={appendixScheme:integratorCreator}]
191  
192   class IntegratorCreator {
193 < public:
193 >  public:
194      IntegratorCreator(const string& ident) : ident_(ident) {}
195  
196      const string& getIdent() const { return ident_; }
# Line 193 | Line 201 | template<class ConcreteIntegrator>
201      string ident_;
202   };
203  
204 < template<class ConcreteIntegrator>
205 < class IntegratorBuilder : public IntegratorCreator {
206 < public:
207 <  IntegratorBuilder(const string& ident)
208 <                   : IntegratorCreator(ident) {}
209 <  virtual  Integrator* create(SimInfo* info) const {
210 <    return new ConcreteIntegrator(info);
211 <  }
204 > template<class ConcreteIntegrator> class IntegratorBuilder : public
205 > IntegratorCreator {
206 >  public:
207 >    IntegratorBuilder(const string& ident)
208 >                     : IntegratorCreator(ident) {}
209 >    virtual  Integrator* create(SimInfo* info) const {
210 >      return new ConcreteIntegrator(info);
211 >    }
212   };
213   \end{lstlisting}
214  
207 \subsection{\label{appendixSection:visitorPattern}Visitor}
208
209 The visitor pattern is designed to decouple the data structure and
210 algorithms used upon them by collecting related operation from
211 element classes into other visitor classes, which is equivalent to
212 adding virtual functions into a set of classes without modifying
213 their interfaces. Fig.~\ref{appendixFig:visitorUML} demonstrates the
214 structure of Visitor pattern which is used extensively in {\tt
215 Dump2XYZ}. In order to convert an OOPSE dump file, a series of
216 distinct operations are performed on different StuntDoubles (See the
217 class hierarchy in Fig.~\ref{oopseFig:hierarchy} and the declaration
218 in Scheme.~\ref{appendixScheme:element}). Since the hierarchies
219 remains stable, it is easy to define a visit operation (see
220 Scheme.~\ref{appendixScheme:visitor}) for each class of StuntDouble.
221 Note that using Composite pattern\cite{Gamma1994}, CompositVisitor
222 manages a priority visitor list and handles the execution of every
223 visitor in the priority list on different StuntDoubles.
224
225 \begin{figure}
226 \centering
227 \includegraphics[width=\linewidth]{visitor.eps}
228 \caption[The UML class diagram of Visitor patten] {The UML class
229 diagram of Visitor patten.} \label{appendixFig:visitorUML}
230 \end{figure}
231
232 \begin{figure}
233 \centering
234 \includegraphics[width=\linewidth]{hierarchy.eps}
235 \caption[Class hierarchy for ojects in {\sc OOPSE}]{ A diagram of
236 the class hierarchy. } \label{oopseFig:hierarchy}
237 \end{figure}
238
215   \begin{lstlisting}[float,caption={[The implementation of Visitor pattern (II)]Source code of the element classes.},label={appendixScheme:element}]
216  
217 < class StuntDouble { public:
218 <  virtual void accept(BaseVisitor* v) = 0;
217 > class StuntDouble {
218 >  public:
219 >    virtual void accept(BaseVisitor* v) = 0;
220   };
221  
222 < class Atom: public StuntDouble { public:
223 <  virtual void accept{BaseVisitor* v*} {
224 <    v->visit(this);
225 <  }
222 > class Atom: public StuntDouble {
223 >  public:
224 >    virtual void accept{BaseVisitor* v*} {
225 >      v->visit(this);
226 >    }
227   };
228  
229 < class DirectionalAtom: public Atom { public:
230 <  virtual void accept{BaseVisitor* v*} {
231 <    v->visit(this);
232 <  }
229 > class DirectionalAtom: public Atom {
230 >  public:
231 >    virtual void accept{BaseVisitor* v*} {
232 >      v->visit(this);
233 >    }
234   };
235  
236 < class RigidBody: public StuntDouble { public:
237 <  virtual void accept{BaseVisitor* v*} {
238 <    v->visit(this);
239 <  }
236 > class RigidBody: public StuntDouble {
237 >  public:
238 >    virtual void accept{BaseVisitor* v*} {
239 >      v->visit(this);
240 >    }
241   };
242  
243   \end{lstlisting}
# Line 265 | Line 245 | class BaseVisitor{ (public)
245   \begin{lstlisting}[float,caption={[The implementation of Visitor pattern (I)]Source code of the visitor classes.},label={appendixScheme:visitor}]
246  
247   class BaseVisitor{
248 < public:
249 <  virtual void visit(Atom* atom);
250 <  virtual void visit(DirectionalAtom* datom);
251 <  virtual void visit(RigidBody* rb);
248 >  public:
249 >    virtual void visit(Atom* atom);
250 >    virtual void visit(DirectionalAtom* datom);
251 >    virtual void visit(RigidBody* rb);
252   };
253  
254 < class BaseAtomVisitor:public BaseVisitor{ public:
255 <  virtual void visit(Atom* atom);
256 <  virtual void visit(DirectionalAtom* datom);
257 <  virtual void visit(RigidBody* rb);
254 > class BaseAtomVisitor:public BaseVisitor{
255 >  public:
256 >    virtual void visit(Atom* atom);
257 >    virtual void visit(DirectionalAtom* datom);
258 >    virtual void visit(RigidBody* rb);
259   };
260  
261   class CompositeVisitor: public BaseVisitor {
262 < public:
282 <
262 >  public:
263    typedef list<pair<BaseVisitor*, int> > VistorListType;
264    typedef VistorListType::iterator VisitorListIterator;
265    virtual void visit(Atom* atom) {
# Line 303 | Line 283 | class CompositeVisitor: public BaseVisitor { (public)
283      std::vector<Atom*> myAtoms;
284      std::vector<Atom*>::iterator ai;
285      myAtoms = rb->getAtoms();
286 <    for(i = visitorScheme.begin();i != visitorScheme.end();++i) {{
286 >    for(i = visitorScheme.begin();i != visitorScheme.end();++i) {
287        rb->accept(*i);
288        for(ai = myAtoms.begin(); ai != myAtoms.end(); ++ai){
289          (*ai)->accept(*i);
290 +      }
291      }
311  }
292  
293    void addVisitor(BaseVisitor* v, int priority);
314
294    protected:
295      VistorListType visitorList;
296   };
297   \end{lstlisting}
298  
299 + \begin{figure}
300 + \centering
301 + \includegraphics[width=\linewidth]{visitor.eps}
302 + \caption[The UML class diagram of Visitor patten] {The UML class
303 + diagram of Visitor patten.} \label{appendixFig:visitorUML}
304 + \end{figure}
305 +
306 + \begin{figure}
307 + \centering
308 + \includegraphics[width=\linewidth]{hierarchy.eps}
309 + \caption[Class hierarchy for ojects in {\sc OOPSE}]{ A diagram of
310 + the class hierarchy. Objects below others on the diagram inherit
311 + data structures and functions from their parent classes above them.}
312 + \label{oopseFig:hierarchy}
313 + \end{figure}
314 +
315   \section{\label{appendixSection:concepts}Concepts}
316  
317   OOPSE manipulates both traditional atoms as well as some objects
# Line 325 | Line 320 | specified in the {\tt .md} file. In contrast, RigidBod
320   freedom.  A diagram of the class hierarchy is illustrated in
321   Fig.~\ref{oopseFig:hierarchy}. Every Molecule, Atom and
322   DirectionalAtom in {\sc OOPSE} have their own names which are
323 < specified in the {\tt .md} file. In contrast, RigidBodies are
323 > specified in the meta data file. In contrast, RigidBodies are
324   denoted by their membership and index inside a particular molecule:
325   [MoleculeName]\_RB\_[index] (the contents inside the brackets depend
326   on the specifics of the simulation). The names of rigid bodies are
# Line 496 | Line 491 | numbers of selected stuntdobules from {\tt -{}-sele1}
491   \caption[A representation of the three-stage correlations in
492   \texttt{StaticProps}]{This diagram illustrates three-stage
493   processing used by \texttt{StaticProps}. $S_1$ and $S_2$ are the
494 < numbers of selected stuntdobules from {\tt -{}-sele1} and {\tt
495 < -{}-sele2} respectively, while $C$ is the number of stuntdobules
494 > numbers of selected StuntDobules from {\tt -{}-sele1} and {\tt
495 > -{}-sele2} respectively, while $C$ is the number of StuntDobules
496   appearing at both sets. The first stage($S_1-C$ and $S_2$) and
497   second stages ($S_1$ and $S_2-C$) are completely non-overlapping. On
498   the contrary, the third stage($C$ and $C$) are completely
499   overlapping} \label{oopseFig:staticPropsProcess}
500 + \end{figure}
501 +
502 + \begin{figure}
503 + \centering
504 + \includegraphics[width=3in]{definition.eps}
505 + \caption[Definitions of the angles between directional objects]{Any
506 + two directional objects (DirectionalAtoms and RigidBodies) have a
507 + set of two angles ($\theta$, and $\omega$) between the z-axes of
508 + their body-fixed frames.} \label{oopseFig:gofr}
509   \end{figure}
510  
511   There are five seperate radial distribution functions availiable in
# Line 548 | Line 552 | Fig.~\ref{oopseFig:gofr}
552  
553   The vectors (and angles) associated with these angular pair
554   distribution functions are most easily seen in
555 < Fig.~\ref{oopseFig:gofr}
555 > Fig.~\ref{oopseFig:gofr}.
556  
553 \begin{figure}
554 \centering
555 \includegraphics[width=3in]{definition.eps}
556 \caption[Definitions of the angles between directional objects]{ \\
557 Any two directional objects (DirectionalAtoms and RigidBodies) have
558 a set of two angles ($\theta$, and $\omega$) between the z-axes of
559 their body-fixed frames.} \label{oopseFig:gofr}
560 \end{figure}
561
557   The options available for {\tt StaticProps} are as follows:
558   \begin{longtable}[c]{|EFG|}
559   \caption{StaticProps Command-line Options}
# Line 623 | Line 618 | trajectories, \texttt{dynamicProps} will estimate the
618   For large simulations, the trajectory files can sometimes reach
619   sizes in excess of several gigabytes. In order to prevent a
620   situation where the program runs out of memory due to large
621 < trajectories, \texttt{dynamicProps} will estimate the size of free
622 < memory at first, and determine the number of frames in each block,
623 < which allows the operating system to load two blocks of data
621 > trajectories, \texttt{dynamicProps} will first estimate the size of
622 > free memory, and determine the number of frames in each block, which
623 > will allow the operating system to load two blocks of data
624   simultaneously without swapping. Upon reading two blocks of the
625   trajectory, \texttt{dynamicProps} will calculate the time
626   correlation within the first block and the cross correlations

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines